OSDN Git Service

ギコナビ更新で、利用したインストーラのexeを削除する処理を追加。
[gikonavigoeson/gikonavi.git] / BoardGroup.pas
index 268cc42..4b3d7f7 100644 (file)
@@ -3,73 +3,20 @@ unit BoardGroup;
 interface
 
 uses
-       Windows, SysUtils, Classes, ComCtrls, IniFiles, {HTTPApp,} YofUtils, IdGlobal,
-       ExternalBoardManager, ExternalBoardPlugInMain, StrUtils, DateUtils;
+       Windows, SysUtils, Classes, ComCtrls, {HTTPApp,} YofUtils, IdGlobal,
+       ExternalBoardManager, ExternalBoardPlugInMain, StrUtils;
 
 type
        //\83\8a\83X\83g\82Ì\95\\8e¦\83A\83C\83e\83\80\91I\91ð
-       TGikoViewType = (gvtAll, gvtLog, gvtNew, gvtUser);
-       //\83\8a\83X\83g\82Ì\8eæ\93¾\8c\8f\90\94
-       //TGikoListCount = (glc50, glc100, glc200, glc500, glc1000, glcAll);
-       //\8f\84\89ñ\94Ô\8d\86
-       //TGikoRoundNo = (grnNone, grn1, grn2, grn3, grn4, grn5, grnOnce);
+       TGikoViewType = (gvtAll, gvtLog, gvtNew, gvtLive, gvtArch, gvtUser);
        //\83\8a\83X\83g\82Ì\8fã\82°\89º\82°
-       TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew, gasNull);
-
-{      TFolder = class
-       private
-               FItemList: TList;       //\8eq\83A\83C\83e\83\80\83\8a\83X\83g
-               FLeaf: Boolean;         //\89º\82É\83t\83H\83\8b\83_\82ð\8e\9d\82Â\82±\82Æ\82ª\8fo\97\88\82é\82©
-       public
-               function Add(Item: TFolder): Integer;
-               procedure Clear;
-               procedure Delete(Index: Integer);
-               procedure Exchange(Index1, Index2: Integer);
-               procedure Insert(Index: Integer; Item: TFolder);
-               procedure Move(CurIndex, NewIndex: Integer);
-               function Remove(Item: TFolder): Integer;
-               procedure Sort(Compare: TListSortCompare);
-               property Capacity: Integer read FCapacity write SetCapacity;
-               property Count: Integer read FCount write SetCount;
-               property Items[Index: Integer]: TFolder read Get write Put; default;
-
-               property Leaf: Boolean read FLeaf;
-       end;
-
-       TBBS = class(TFolder)
-       end;
-       TCategory class(TFolder)
-       end;
-       TBoard = class(TFolder)
-       end;
-       TThreadItem = class(TFolder)
-       end;
-}
-
-{
-       TBBS = class(TBBS)
-       end;
-       TBoard2ch = class(TBoard)
-       end;
-       TThreadItem2ch = class(TThreadItem)
-       end;
-}
-
-//     ITest = interface
-//     end;
-//     IBBS = interface
-//     end;
-//     ICategory = interface
-//     end;
-//     IBoard = interface
-//     end;
-//     IThreadItem = interface
-//     end;
+       TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew, gasArch, gasNull);
 
        TCategory = class;
        TBoard = class;
        TThreadItem = class;
 
+
        // BBS \82Ì\83\8b\81[\83g
        TBBS = class(TList)
        private
@@ -112,7 +59,6 @@ type
        end;
 
        // \83J\83e\83S\83\8a(\94 URL \82Ì\83\8a\83X\83g)
-//     TCategory = class(THashedStringList)
        TCategory = class(TStringList)
        private
                FNo: Integer;
@@ -144,8 +90,10 @@ type
                property NodeExpand: Boolean read FExpand write FExpand;
        end;
 
+       //! \83X\83\8c\83b\83h\90\94\83J\83E\83\93\83g\8fð\8c\8f\95
+       TThreadCount = function(Item : TThreadItem): Boolean;
+
        // \94Â(\83X\83\8c\83b\83h URL \82Ì\83\8a\83X\83g)
-//     TBoard = class(THashedStringList)
        TBoard = class(TStringList)
        private
                FContext: DWORD;                                                        // \83v\83\89\83O\83C\83\93\82ª\8e©\97R\82É\90Ý\92è\82µ\82Ä\82¢\82¢\92l(\8eå\82É\83C\83\93\83X\83^\83\93\83X\82ª\93ü\82é)
@@ -166,6 +114,8 @@ type
                FBoolData: Boolean;                                             //\82¢\82ë\82ñ\82È\97p\93r\82É\8eg\82¤yo
                FSPID: string;                                                          //\8f\91\82«\8d\9e\82Ý\97pSPID
                FPON: string;                                                                   //\8f\91\82«\8d\9e\82Ý\97pPON
+               FCookie: string;                                                //\8f\91\82«\8d\9e\82Ý\97pCookie\95\8e\9a\97ñ
+               FExpires: TDateTime;                                    //Cookie\82Ì\97L\8cø\8aú\8cÀ
                FKotehanName: string;                                   //\83R\83e\83n\83\93\96¼\91O
                FKotehanMail: string;                                   //\83R\83e\83n\83\93\83\81\81[\83\8b
 
@@ -178,16 +128,23 @@ type
                FIntData                        : Integer;                      // \8dD\82«\82É\82¢\82\82Á\82Ä\82æ\82µ\81B\82¢\82ë\82ñ\82È\97p\93r\82É\8eg\82¤yo
                FListData                       : TList;                                // \8dD\82«\82É\82¢\82\82Á\82Ä\82æ\82µ\81B\82¢\82ë\82ñ\82È\97p\93r\82É\8eg\82¤yo
 
-               FSETTINGTXTTime: TDateTime;     //SETTING.TXT\82ð\8eæ\93¾\82µ\82½\93ú\8e\9e
-               FIsSETTINGTXT:          boolean;        //SETTING.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82é\82©
-               FHEADTXTTime: TDateTime;                //HEAD.TXT\82ð\8eæ\93¾\82µ\82½\93ú\8e\9e
-               FIsHEADTXT:             boolean;        //HEAD.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82é\82©
-        FTitlePictureURL:      string; //top\8aG\82ÌURL
-               FMultiplicity : Integer; //\8fd\95¡\82µ\82Ä\82¢\82é\82©\82Ç\82¤\82©\81H
+               FSETTINGTXTTime : TDateTime;    //SETTING.TXT\82ð\8eæ\93¾\82µ\82½\93ú\8e\9e
+               FIsSETTINGTXT   : boolean;      //SETTING.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82é\82©
+               FHEADTXTTime    : TDateTime;            //HEAD.TXT\82ð\8eæ\93¾\82µ\82½\93ú\8e\9e
+               FIsHEADTXT              : boolean;      //HEAD.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82é\82©
+               FTitlePictureURL: string;       //top\8aG\82ÌURL
+               FMultiplicity   : Integer; //\8fd\95¡\82µ\82Ä\82¢\82é\82©\82Ç\82¤\82©\81H
+               FIs2ch                  : Boolean; //host\82ª2ch\82©\82Ç\82¤\82©
+               FNewThreadCount: Integer;       //\90V\92\85\83X\83\8c\83b\83h\82Ì\90\94
+               FLogThreadCount: Integer;       //\83\8d\83O\97L\82è\83X\83\8c\83b\83h\82Ì\90\94
+               FUserThreadCount: Integer;      //\81H
+               FLiveThreadCount: Integer;      //\90\91\83X\83\8c\83b\83h\90\94
+               FArchiveThreadCount: Integer;   //DAT\97\8e\82¿\83X\83\8c\83b\83h\90\94
                function GetThreadItem(index: integer): TThreadItem;
                procedure SetThreadItem(index: integer; value: TThreadItem);
                procedure SetRound(b: Boolean);
                procedure SetRoundName(s: string);
+               //procedure SetRoundName(s: PChar);
                procedure SetLastModified(d: TDateTime);
                procedure SetLastGetTime(d: TDateTime);
                procedure SetUnRead(i: Integer);
@@ -206,6 +163,7 @@ type
                property BBSID: string read FBBSID write FBBSID;
                property URL: string read FURL write FURL;
                property Round: Boolean read FRound write SetRound;
+               //property RoundName: PChar read FRoundName write SetRoundName;
                property RoundName: string read FRoundName write SetRoundName;
                property RoundDate: TDateTime read FRoundDate write FRoundDate;
                property LastModified: TDateTime read FLastModified write SetLastModified;
@@ -230,7 +188,7 @@ type
                function FindThreadFromFileName(const ItemFileName: string): TThreadItem;
                function FindThreadFromURL(const inURL : string ) : TThreadItem;
                function GetIndexFromFileName(const ItemFileName: string): Integer;
-               function GetIndexFromURL(const URL: string): Integer;
+               function GetIndexFromURL(const URL: string; reverse : Boolean = False): Integer;
                procedure LoadSettings;
                procedure SaveSettings;
                function GetReadCgiURL: string;
@@ -243,11 +201,16 @@ type
 
                function GetNewThreadCount: Integer;
                function GetLogThreadCount: Integer;
+               function GetArchiveThreadCount: Integer;
+               function GetLiveThreadCount: Integer;
                function GetUserThreadCount: Integer;
                function GetNewThread(Index: Integer): TThreadItem;
-               function GetLogThread(Index: Integer): TThreadItem;
+               function GetLogThread(Index: Integer): TThreadItem; overload;
+               function GetArchiveThread(Index: Integer): TThreadItem;
+               function GetLiveThread(Index: Integer): TThreadItem;
                function GetUserThread(Index: Integer): TThreadItem;
-
+               function GetThreadCount(func :TThreadCount ): Integer;
+               function GetThread(func :TThreadCount;const Index :Integer ): TThreadItem;
                procedure BeginUpdate;
                procedure EndUpdate;
                property NodeExpand: Boolean read FExpand write FExpand;
@@ -261,15 +224,23 @@ type
                property IsSETTINGTXT:  boolean read FIsSETTINGTXT write FIsSETTINGTXT;
                property HEADTXTTime: TDateTime read FHEADTXTTime write FHEADTXTTime;
                property IsHEADTXT:     boolean read FIsHEADTXT write FIsHEADTXT;
-        property TitlePictureURL: string read FTitlePictureURL write FTitlePictureURL;
+               property TitlePictureURL: string read FTitlePictureURL write FTitlePictureURL;
                property Multiplicity: Integer read FMultiplicity write FMultiplicity;
+               property Is2ch  : boolean       read FIs2ch     write FIs2ch;
+               property NewThreadCount: Integer        read FNewThreadCount write FNewThreadCount;     //\90V\92\85\83X\83\8c\83b\83h\82Ì\90\94
+               property LogThreadCount: Integer        read FLogThreadCount write FLogThreadCount;             //\83\8d\83O\97L\82è\83X\83\8c\83b\83h\82Ì\90\94
+               property UserThreadCount: Integer       read FUserThreadCount write FUserThreadCount;   //\81H
+               property LiveThreadCount: Integer       read FLiveThreadCount write     FLiveThreadCount;
+               property ArchiveThreadCount: Integer read FArchiveThreadCount write FArchiveThreadCount;
+
+               property Cookie: string                         read FCookie write FCookie;
+               property Expires: TDateTime                     read FExpires write FExpires;
        end;
 
        //\83X\83\8c
        TThreadItem = class(TObject)
        private
                FContext: DWORD;                                        // \83v\83\89\83O\83C\83\93\82ª\8e©\97R\82É\90Ý\92è\82µ\82Ä\82¢\82¢\92l(\8eå\82É\83C\83\93\83X\83^\83\93\83X\82ª\93ü\82é)
-
                FNo: Integer;                                                   //\94Ô\8d\86
                FFileName: string;                              //\83X\83\8c\83b\83h\83t\83@\83C\83\8b\96¼
                FTitle: string;                                         //\83X\83\8c\83b\83h\83^\83C\83g\83\8b
@@ -291,24 +262,25 @@ type
                FScrollTop: Integer;                    //\83X\83N\83\8d\81[\83\8b\88Ê\92u
                FDownloadHost: string;          //\8d¡\82Ì\83z\83X\83g\82Æ\88á\82¤\8fê\8d\87\82Ì\83z\83X\83g
                FAgeSage: TGikoAgeSage;         //\83A\83C\83e\83\80\82Ì\8fã\82°\89º\82°
-//             FSPID: string;                                          //\8f\91\82«\8d\9e\82Ý\97pSPID
-
                FUpdate: Boolean;
                FExpand: Boolean;
                FURL                                    : string;                               // \82±\82Ì\83X\83\8c\82ð\83u\83\89\83E\83U\82Å\95\\8e¦\82·\82é\8dÛ\82Ì URL
-               FBoardPlugIn    : TBoardPlugIn; // \82±\82Ì\83X\83\8c\82ð\83T\83|\81[\83g\82·\82é\83v\83\89\83O\83C\83\93
-               FFilePath                       : string;                               // \82±\82Ì\83X\83\8c\82ª\95Û\91\82³\82ê\82Ä\82¢\82é\83p\83X
-
+               FJumpAddress : Integer;         //\83\8c\83X\94Ô\8d\86\8ew\92èURL\82ð\93¥\82ñ\82¾\82Æ\82«\82É\8ew\92è\82³\82ê\82é\83\8c\83X\82Ì\94Ô\8d\86\82ª\93ü\82é
                procedure SetLastModified(d: TDateTime);
                procedure SetRound(b: Boolean);
                procedure SetRoundName(const s: string);
+               //procedure SetRoundName(const s: PChar);
                procedure SetKokomade(i: Integer);
                procedure SetUnRead(b: Boolean);
                procedure SetScrollTop(i: Integer);
                procedure Init;
                function GetCreateDate: TDateTime;
+        function GetFilePath: String;
        public
-               constructor Create( inPlugIn : TBoardPlugIn; inURL : string );
+               constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard; inURL : string ); overload;
+               constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard;
+                                        inURL : string; inExist: Boolean; const inFilename: string ); overload;
+
                destructor Destroy; override;
 
                function GetDatURL: string;
@@ -335,6 +307,7 @@ type
                property Size: Integer read FSize write FSize;
                property Round: Boolean read FRound write SetRound;
                property RoundName: string read FRoundName write SetRoundName;
+               //property RoundName: PChar read FRoundName write SetRoundName;
 
                property IsLogFile: Boolean read FIsLogFile write FIsLogFile;
                property ParentBoard: TBoard read FParentBoard write FParentBoard;
@@ -346,31 +319,27 @@ type
                property Expand: Boolean read FExpand write FExpand;
                property DownloadHost: string read FDownloadHost write FDownloadHost;
                property AgeSage: TGikoAgeSage read FAgeSage write FAgeSage;
-//             property SPID: string read FSPID write FSPID;
                property CreateDate: TDateTime read GetCreateDate;
                property        URL                                     : string                                read FURL write FURL;
-               property        BoardPlugIn     : TBoardPlugIn  read FBoardPlugIn;
-               property        FilePath                : string                                read FFilePath write FFilePath;
-               function        IsBoardPlugInAvailable : Boolean;
+               property        FilePath                : string        read GetFilePath;
+               property JumpAddress : Integer read FJumpAddress write FJumpAddress;
        end;
 
-
-
-       //\8c\9f\8dõ\8c\8b\89Ê\83\8a\83X\83g
-{      TSearchList = class(TList)
-       private
-               function GetThreadItem(index: integer): TThreadItem;
-               procedure SetThreadItem(index: integer; value: TThreadItem);
-       public
-               constructor Create;
+       TBoardGroup = class(TStringList)
+    private
+       FBoardPlugIn    : TBoardPlugIn; // \82±\82Ì\94Â\82ð\83T\83|\81[\83g\82·\82é\83v\83\89\83O\83C\83\93
+    public
                destructor Destroy; override;
+               procedure       Clear   ; override;
+        property       BoardPlugIn     : TBoardPlugIn  read FBoardPlugIn write FBoardPlugIn;
+    end;
 
-               property Items[index: integer]: TThreadItem read GetThreadItem write SetThreadItem;
-
-               function Add(item: TThreadItem): integer;
-               procedure Delete(index: integer);
-               procedure Clear; override;
-       end;}
+    // \93Á\8eê\97p\93r\97pTBoard
+    TSpecialBoard = class(TBoard)
+    public
+        function Add(item: TThreadItem): integer; overload;
+        procedure Clear; overload;
+    end;
 
        function        BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard;
        function        BBSsFindBoardFromURL( inURL : string ) : TBoard;
@@ -378,13 +347,18 @@ type
        function        BBSsFindThreadFromURL(const inURL : string ) : TThreadItem;
        function        ConvertDateTimeString( inDateTimeString : string) : TDateTime;
 
+    procedure    DestorySpecialBBS( inBBS : TBBS );
+
 var
        BBSs            : array of TBBS;
+    BoardGroups : array of TBoardGroup;
+    SpecialBBS  : TBBS;
+    SpecialBoard: TSpecialBoard;
 
 implementation
 
 uses
-       GikoSystem, RoundData, MojuUtils;
+       GikoSystem, RoundData, MojuUtils, DateUtils, IniFiles;
 
 const
        BBS2CH_NAME:                                     string = '\82Q\82¿\82á\82ñ\82Ë\82é';
@@ -399,9 +373,34 @@ const
     HEADTXT_FILENAME:          string = 'head.html';
        //DEFAULT_LIST_COUNT:           Integer = 100;
 
-//     COLUMN_CATEGORY:         array[0..0] of string = ('\83J\83e\83S\83\8a\96¼');
-//     COLUMN_BOARD:                   array[0..3] of string = ('\94Â\96¼', '\8eæ\93¾\90\94', '\8f\84\89ñ\97\\96ñ', '\91O\89ñ\8f\84\89ñ\93ú\8e\9e');
-//     COLUMN_THREADITEM: array[0..3] of string = ('\83X\83\8c\83b\83h\96¼', '\83J\83E\83\93\83g', '\8f\84\89ñ\97\\96ñ', '\91O\89ñ\8f\84\89ñ\93ú\8e\9e');
+//! \83\8d\83O\82ð\8e\9d\82Á\82Ä\82¢\82é\82È\82ç\90^\82ð\95Ô\82·
+function CountLog(Item: TThreadItem): Boolean;
+begin
+       Result := Item.IsLogFile;
+end;
+//! \90V\92\85\82È\82ç\90^\82ð\95Ô\82·
+function CountNew(Item: TThreadItem): Boolean;
+begin
+       Result := Item.NewArrival;
+end;
+//! DAT\97\8e\82¿\82È\82ç\90^\82ð\95Ô\82·
+function CountDat(Item: TThreadItem): Boolean;
+begin
+       Result := (Item.AgeSage = gasArch);
+end;
+//! \90\91\83X\83\8c\82È\82ç\90^\82ð\95Ô\82·
+function CountLive(Item: TThreadItem): Boolean;
+begin
+       Result := (Item.AgeSage <> gasArch);
+end;
+
+//! \8fí\82É\90^
+function CountAll(Item: TThreadItem): Boolean;
+begin
+    Result := True;
+end;
+
+
 
 // BBSID \82ð\97p\82¢\82é 2 \82¿\82á\82ñ\82Ë\82é\82Ì\82Ý\92T\82µ\8fo\82µ\82Ü\82·
 // BBSID \82Ì\8eg\97p\82Í\8bÉ\97Í\94ð\82¯\82Ä\82­\82¾\82³\82¢\81B
@@ -409,26 +408,67 @@ const
 function       BBSsFindBoardFromBBSID(
        inBBSID : string
 ) : TBoard;
+var
+       i : Integer;
+       tmpBoard : TBoard;
 begin
 
-       Result := BBSs[ 0 ].FindBBSID( inBBSID );
+//     Result := BBSs[ 0 ].FindBBSID( inBBSID );
+       Result := nil;
+       if Length(BoardGroups) > 0 then begin
+               for i := BoardGroups[0].Count - 1 downto 0 do begin
+                       tmpBoard := TBoard(BoardGroups[0].Objects[i]);
+                       if tmpBoard.Is2ch then begin
+                               if AnsiCompareStr(tmpBoard.BBSID, inBBSID) = 0 then begin
+                                       Result := tmpBoard;
+                                       EXIT;
+                               end;
+                       end;
+               end;
+       end;
 
 end;
-
+{**********************************************
+\82±\82Ì\8aÖ\90\94\82Í\95K\82¸\94Â\82ÌURL\82Ì\8c`\8e®\82Å\93n\82µ\82Ä\82­\82¾\82³\82¢\81B
+plugin\82ð\8eg\97p\82·\82é\82È\82ç\82Î\81AExtractBoardURL( inURL )
+2ch\82È\82ç\82Î\81AGikoSys.Get2chThreadURL2BoardURL( inURL );
+\82Å\95Ï\8a·\82µ\82Ä\82©\82ç\8cÄ\82Ñ\8fo\82µ\82Ä\82­\82¾\82³\82¢\81B
+**********************************************}
 function       BBSsFindBoardFromURL(
        inURL   : string
 ) : TBoard;
 var
-       i                       : Integer;
+       i,p                     : Integer;
+       accept          : TAcceptType;
+       protocol, host, path, document, port, bookmark : string;
 begin
-
-       for i := Length( BBSs ) - 1 downto 0 do begin
-               Result := BBSs[ i ].FindBoardFromURL( inURL );
-               if Result <> nil then
-                       Exit;
-       end;
-
        Result := nil;
+       for i := Length(BoardGroups) - 1 downto 1 do begin
+               accept := BoardGroups[i].BoardPlugIn.AcceptURL(inURL);
+               if (accept = atBoard) or (accept = atThread) then begin
+                       if BoardGroups[i].Find(inURL, p) then begin
+                               Result := TBoard(BoardGroups[i].Objects[p]);
+                               Exit;
+                       end else begin
+                               inURL := BoardGroups[i].BoardPlugIn.ExtractBoardURL(inURL);
+                               if BoardGroups[i].Find(inURL, p) then begin
+                                       Result := TBoard(BoardGroups[i].Objects[p]);
+                                       Exit;
+                               end;
+                       end;
+               end;
+       end;
+       //\82±\82±\82É\82«\82½\82ç\81Aplugin\82ð\8eg\82í\82È\82¢\82â\82Â\82ç\82ð\92²\82×\82é
+       if BoardGroups[0].Find(inURL, p) then
+               Result := TBoard(BoardGroups[0].Objects[p]);
+               
+       if (Result = nil) then begin
+               GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
+               //\83z\83X\83g\82ª2ch\82È\82çBBSID\82Å\92²\82×\82é
+               if GikoSys.Is2chHost(host) then begin
+                       Result := BBSsFindBoardFromBBSID(GikoSys.URLToID( inURL ));
+               end;
+       end;
 
 end;
 
@@ -436,17 +476,20 @@ function  BBSsFindBoardFromTitle(
        inTitle : string
 ) : TBoard;
 var
-       i                               : Integer;
+       i,j                             : Integer;
+       tmpBoard                : TBoard;
 begin
-
+    Result := nil;
        for i := Length( BBSs ) - 1 downto 0 do begin
-               Result := BBSs[ i ].FindBoardFromTitle( inTitle );
-               if Result <> nil then
-                       Exit;
+               for j := BoardGroups[i].Count - 1 downto 0 do begin
+                       tmpBoard := TBoard(BoardGroups[i].Objects[j]);
+                       if ( AnsiCompareStr(tmpBoard.Title, inTitle) = 0) then begin
+                               Result := tmpBoard;
+                               Exit;
+                       end;
+               end;
        end;
 
-       Result := nil;
-
 end;
 
 function       BBSsFindThreadFromURL(
@@ -454,17 +497,70 @@ function  BBSsFindThreadFromURL(
 ) : TThreadItem;
 var
        board                   : TBoard;
+       tmpThread               : TThreadItem;
        boardURL        : string;
+       protocol, host, path, document, port, bookmark : string;
+       BBSID, BBSKey : string;
+       i, bi : Integer;
 begin
 
        boardURL        := GikoSys.GetThreadURL2BoardURL( inURL );
        board                   := BBSsFindBoardFromURL( boardURL );
        if board = nil then
                Result := nil
-       else
+       else begin
                Result := board.FindThreadFromURL( inURL );
+               //\82à\82µ\82à2ch\82Ì\94Â\82È\82ç
+               if (Result = nil) and (board.Is2ch) then begin
+                       GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
+                       GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
+                       Result := board.FindThreadFromFileName(BBSKey + '.dat');
+               end else if (Result = nil) and not (board.Is2ch) then begin
+               //\83v\83\89\83O\83C\83\93\8cn\82Ì\92T\8dõ\81i\8eå\82ÉURL\82ª\93r\92\86\82Å\95Ï\8dX\82É\82È\82Á\82½\97Þ)
+                       try
+                               bi := Length(BoardGroups) - 1;
+                               for i := 1 to bi do begin
+                                       if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin
+                                               if BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) = atThread then begin
+                                                       tmpThread               := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL );
+                                                       if not board.IsThreadDatRead then begin
+                                                               GikoSys.ReadSubjectFile( board );
+                                                       end;
+                                                       Result := Board.FindThreadFromFileName( tmpThread.FileName );
+                                                       tmpThread.Free;
+                                                       Break;
+                                               end;
+                                       end;
+                               end;
+                       except
+               Result := nil;
+                       end;
+               end;
+       end;
 
 end;
+{!
+\brief \93Á\8eê\97p\93rBBS\8dí\8f\9c
+\param bbs \8dí\8f\9c\82·\82é\93Á\8eê\97p\93rBBS
+}
+procedure DestorySpecialBBS( inBBS : TBBS );
+var
+    sCategory : TCategory;
+    sBoard    : TSpecialBoard;
+begin
+    if inBBS <> nil then begin
+        sCategory := inBBS.Items[0];
+        if sCategory <> nil then begin
+            sBoard := TSpecialBoard(sCategory.Items[0]);
+            if sBoard <> nil then begin
+                sBoard.Modified := False;
+                sBoard.Clear;
+                FreeAndNil(sBoard);
+            end;
+        end;
+        FreeAndNil(inBBS);
+    end;
+end;
 
 (*************************************************************************
  *\8b@\94\\96¼\81FTBBS\83R\83\93\83X\83g\83\89\83N\83^
@@ -551,7 +647,7 @@ var
        i: Integer;
 begin
        if not IsBoardFileRead then
-       GikoSys.ReadBoardFile( Self );
+       GikoSys.ReadBoardFile( Self );
        for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindBoardFromTitle(Title);
                if Result <> nil then
@@ -568,7 +664,7 @@ var
        i                                       : Integer;
 begin
        if not IsBoardFileRead then
-       GikoSys.ReadBoardFile( Self );
+       GikoSys.ReadBoardFile( Self );
        for i := Count - 1 downto 0 do begin
                Result := Items[ i ].FindBoardFromURL( inURL );
                if Result <> nil then
@@ -675,16 +771,7 @@ end;
 
 procedure TCategory.Delete(index: integer);
 begin
-       if (Items[index] <> nil) then begin
-               try
-                       if TBoard(Items[index]).Multiplicity = 0 then
-                               TBoard(Items[index]).Free
-                       else
-                               TBoard(Items[index]).Multiplicity := TBoard(Items[index]).Multiplicity - 1;
-               except
-               end;
-       end;
-       inherited Delete(index);
+    inherited Delete(index);
 end;
 
 procedure TCategory.Clear;
@@ -812,6 +899,7 @@ begin
        FLastGetTime := ZERO_DATE;
        FIsThreadDatRead := False;
        FUnRead := 0;
+       FMultiplicity := 0;
 //     FListStyle := vsReport;
 //     FItemNoVisible := True;
 
@@ -839,17 +927,21 @@ begin
        if inPlugIn = nil then begin
                // subject.txt \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
                GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
-               if GikoSys.Is2chHost( host ) then
+               if GikoSys.Is2chHost( host ) then begin
+                       Self.Is2ch := True;
                        FilePath :=
-                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               GikoSys.Setting.LogFolderP  +
                                BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
-               else
+               end else begin
+                       Self.Is2ch := False;
                        FilePath :=
-                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               GikoSys.Setting.LogFolderP +
                                EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+               end;
        end else begin
                // \83v\83\89\83O\83C\83\93\82É TBoardItem \82ª\8dì\90¬\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
                inPlugIn.CreateBoardItem( DWORD( Self ) );
+               //Self.Is2ch := False;  //plugin\91¤\82Å\90Ý\92è\82·\82é
        end;
 
 end;
@@ -967,9 +1059,21 @@ begin
        end;
 end;
 
-function TBoard.GetIndexFromURL(const URL: string): Integer;
+function TBoard.GetIndexFromURL(const URL: string; reverse : Boolean = False): Integer;
+var
+       i : Integer;
 begin
-       Result := IndexOf( URL );
+       if not reverse then
+               Result := IndexOf( URL )
+       else begin
+        Result := -1;
+               for i := Self.Count - 1 downto 0 do begin
+                       if Strings[i] = URL then begin
+                               Result := i;
+                               break;
+                       end;
+               end;
+       end;
 end;
 
 function TBoard.FindThreadFromURL(const inURL : string ) : TThreadItem;
@@ -1011,7 +1115,7 @@ begin
        if Length( FilePath ) > 0 then
                FileName := ExtractFilePath( FilePath ) + FOLDER_INI_FILENAME
        else
-               FileName := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               FileName := GikoSys.Setting.LogFolderP
                                                        + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + FOLDER_INI_FILENAME;
 
        if not FileExists(FileName) then
@@ -1038,6 +1142,9 @@ begin
                FUnRead := ini.ReadInteger('Status', 'UnRead', 0);
                FSPID := ini.ReadString('Cookie', 'SPID', '');
                FPON := ini.ReadString('Cookie', 'PON', '');
+               FCookie  := ini.ReadString('Cookie', 'Cookie', '');
+               tmp := ini.ReadString('Cookie', 'Expires', DateTimeToStr(ZERO_DATE));
+               FExpires := ConvertDateTimeString(tmp);
                FKotehanName := ini.ReadString('Kotehan', 'Name', '');
                FKotehanMail := ini.ReadString('Kotehan', 'Mail', '');
 
@@ -1056,7 +1163,7 @@ begin
        if Length( FilePath ) > 0 then
                FileName := ExtractFilePath( FilePath )
        else
-               FileName := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               FileName := GikoSys.Setting.LogFolderP
                                                        + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM;
        if not GikoSys.DirectoryExistsEx(FileName) then
                GikoSys.ForceDirectoriesEx(FileName);
@@ -1072,6 +1179,8 @@ begin
                ini.WriteInteger('Status', 'UnRead', FUnRead);
                ini.WriteString('Cookie', 'SPID', FSPID);
                ini.WriteString('Cookie', 'PON', FPON);
+               ini.WriteString('Cookie', 'Cookie', FCookie);
+               ini.WriteDateTime('Cookie', 'Expires', FExpires);
                ini.WriteString('Kotehan', 'Name', FKotehanName);
                ini.WriteString('Kotehan', 'Mail', FKotehanMail);
 
@@ -1145,42 +1254,39 @@ begin
 
    // Result := inDateTimeString;
 end;
-// \83T\83u\83W\83F\83N\83gURL\8eæ\93¾
+//! \83T\83u\83W\83F\83N\83gURL\8eæ\93¾
 function TBoard.GetReadCgiURL: string;
 begin
-       //Result := URL + SUBJECT_FILENAME;
-       //Result := GikoSys.UrlToServer(URL)
-       //                              + 'test/read.cgi/' + BBSID + '/?raw=0.0';
        Result := URL + SUBJECT_FILENAME;
 
 end;
 
-// \83T\83u\83W\83F\83N\83g\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
+//! \83T\83u\83W\83F\83N\83g\83t\83@\83C\83\8b\96¼\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
 function TBoard.GetSubjectFileName: string;
 begin
        if Length( FilePath ) > 0 then
                Result := FilePath
        else
-               Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               Result := GikoSys.Setting.LogFolderP
                                                + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME;
 end;
 
-// \83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b\96¼(folder.idx)\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
+//! \83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b\96¼(folder.idx)\8eæ\93¾\81i\83p\83X\81{\83t\83@\83C\83\8b\96¼\81j
 function TBoard.GetFolderIndexFileName: string;
 begin
        if Length( FilePath ) > 0 then
                Result := ExtractFilePath( FilePath ) + FOLDER_INDEX_FILENAME
        else
-               Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               Result := GikoSys.Setting.LogFolderP
                                                + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + FOLDER_INDEX_FILENAME;
 end;
-//SETTING.TXT\82Ì\83t\83@\83C\83\8b\96¼\8eæ\93¾
+//SETTING.TXT\82Ì\83t\83@\83C\83\8b\96¼\8eæ\93¾
 function TBoard.GetSETTINGTXTFileName: string;
 begin
        if Length( FilePath ) > 0 then
                Result := ExtractFilePath( FilePath ) + SETTINGTXT_FILENAME
        else
-               Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               Result := GikoSys.Setting.LogFolderP
                                                + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SETTINGTXT_FILENAME;
 end;
 
@@ -1189,7 +1295,7 @@ begin
        if Length( FilePath ) > 0 then
                Result := ExtractFilePath( FilePath ) + HEADTXT_FILENAME
        else
-               Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               Result := GikoSys.Setting.LogFolderP
                                                + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + HEADTXT_FILENAME;
 end;
 function TBoard.GetTitlePictureFileName: string;
@@ -1203,19 +1309,16 @@ begin
                if Length( FilePath ) > 0 then
                        Result := ExtractFilePath( FilePath ) + tmpName
                else
-                       Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+                       Result := GikoSys.Setting.LogFolderP
                                                        + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + tmpName;
        end;
 end;
 
 // \83X\83\8c\97§\82Ä\91\97\90MURL
 function TBoard.GetSendURL: string;
-var
-       Protocol, Host, Path, Document, Port, Bookmark : string;
 begin
     Result := GikoSys.UrlToServer(URL);
-    GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
-    if GikoSys.Is2chHost(Host) then
+       if Self.Is2ch then
         Result := Result + 'test/bbs.cgi'
     else
         Result := Result + 'test/subbbs.cgi';
@@ -1282,8 +1385,8 @@ begin
        if FUpdate then
                FModified := True;
 end;
-
-function TBoard.GetNewThreadCount: Integer;
+//! func\82Ì\8fð\8c\8f\82É\88ê\92v\82·\82é\83X\83\8c\83b\83h\82Ì\90\94\82ð\95Ô\82·
+function TBoard.GetThreadCount(func :TThreadCount ): Integer;
 var
        i: Integer;
 begin
@@ -1291,12 +1394,12 @@ begin
        if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
        begin
                for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival then
+                       if func(Items[i]) then
                                inc(Result);
                end;
        end else begin
                for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival then
+                       if func(Items[i]) then
                        begin
                                if Items[i].ShortTitle = '' then
                                        Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', '');
@@ -1306,48 +1409,33 @@ begin
                end;
        end;
 end;
-
+//! \90V\92\85\83X\83\8c\83b\83h\82Ì\90\94\82ð\8eæ\93¾\82·\82é
+function TBoard.GetNewThreadCount: Integer;
+begin
+       Result := GetThreadCount(CountNew);
+end;
+//! \83\8d\83O\97L\82è\83X\83\8c\83b\83h\82Ì\90\94\82ð\8eæ\93¾\82·\82é
 function TBoard.GetLogThreadCount: Integer;
-var
-       i: Integer;
 begin
-       Result := 0;
-       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
-       begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].IsLogFile then
-                               inc(Result);
-               end;
-       end else begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].IsLogFile then
-                       begin
-                               if Items[i].ShortTitle = '' then
-                                       Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', '');
-                               if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then
-                                       inc(Result);
-                       end;
-               end;
-       end;
+       Result := GetThreadCount(CountLog);
 end;
-
+//! \8di\8d\9e\82Ý\8fð\8c\8f\82É\88ê\92v\82·\82é\83X\83\8c\83b\83h\82Ì\90\94\82ð\8eæ\93¾\82·\82é
 function TBoard.GetUserThreadCount: Integer;
-var
-       i: Integer;
 begin
-       Result := 0;
-       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
-               Result := Count
-       else
-               for i := 0 to Count - 1 do begin
-                       if Items[i].ShortTitle = '' then
-                               Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', '');
-                       if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then
-                               inc(Result);
-               end;
+       Result := GetThreadCount(CountAll);
 end;
-
-function TBoard.GetNewThread(Index: Integer): TThreadItem;
+//! DAT\97\8e\82¿\83X\83\8c\83b\83h\82Ì\90\94\82ð\8eæ\93¾\82·\82é
+function TBoard.GetArchiveThreadCount: Integer;
+begin
+       Result := GetThreadCount(CountDat);
+end;
+//! \90\91\83X\83\8c\83b\83h\82Ì\90\94\82ð\8eæ\93¾\82·\82é
+function TBoard.GetLiveThreadCount: Integer;
+begin
+       Result := GetThreadCount(CountLive);
+end;
+//! func\82Ì\8fð\8c\8f\82É\93K\8d\87\82·\82éIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
+function TBoard.GetThread(func :TThreadCount;const Index :Integer ): TThreadItem;
 var
        i: Integer;
        Cnt: Integer;
@@ -1357,8 +1445,7 @@ begin
        if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
        begin
                for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival then
-                                                                       begin
+                       if func(Items[i]) then begin
                                if Index = Cnt then begin
                                        Result := Items[i];
                                        Exit;
@@ -1368,9 +1455,8 @@ begin
                end;
        end else begin
                for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival then
-                       begin
-                               if Items[i].ShortTitle = '' then
+                       if func(Items[i]) then begin
+                               if Length(Items[i].ShortTitle) = 0 then
                                        Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', '');
                                if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
                                        if Index = Cnt then begin
@@ -1383,74 +1469,30 @@ begin
                end;
        end;
 end;
-
+//! DAT\97\8e\82¿\83X\83\8c\83b\83h\82ÅIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
+function TBoard.GetArchiveThread(Index: Integer): TThreadItem;
+begin
+       Result := GetThread(CountDat, Index);
+end;
+//! \90\91\83X\83\8c\83b\83h\82ÅIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
+function TBoard.GetLiveThread(Index: Integer): TThreadItem;
+begin
+       Result := GetThread(CountLive, Index);
+end;
+//! \90V\92\85\83X\83\8c\83b\83h\82ÅIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
+function TBoard.GetNewThread(Index: Integer): TThreadItem;
+begin
+       Result := GetThread(CountNew, Index);
+end;
+//! Log\82 \82è\83X\83\8c\83b\83h\82ÌIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
 function TBoard.GetLogThread(Index: Integer): TThreadItem;
-var
-       i: Integer;
-       Cnt: Integer;
 begin
-       Cnt := 0;
-       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
-       begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].IsLogFile then
-                                                                       begin
-                               if Index = Cnt then begin
-                                       Result := Items[i];
-                                       Exit;
-                               end;
-                               inc(Cnt);
-                       end;
-               end;
-       end else begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].IsLogFile then
-                               begin
-                                       if Items[i].ShortTitle = '' then
-                                               Items[i].ShortTitle := ZenToHan(Items[i].Title);
-                                       if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
-                                               if Index = Cnt then begin
-                                                       Result := Items[i];
-                                                       Exit;
-                                       end;
-                                       inc(Cnt);
-                               end;
-                       end;
-               end;
-       end;
-       Result := nil;
+       Result := GetThread(CountLog, Index);
 end;
-
+//! \8di\8d\9e\82Ý\82ÅIndex\94Ô\96Ú\82Ì\83X\83\8c\83b\83h\82ð\8eæ\93¾\82·\82é
 function TBoard.GetUserThread(Index: Integer): TThreadItem;
-var
-       i: Integer;
-       Cnt: Integer;
 begin
-       Result := nil;
-       Cnt := 0;
-       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
-       begin
-               for i := 0 to Count - 1 do begin
-                       if Index = Cnt then
-                       begin
-                               Result := Items[ i ];
-                               Exit;
-                       end;
-                       inc( Cnt );
-               end;
-       end else begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].ShortTitle = '' then
-                               Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', '');
-                       if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
-                               if Index = Cnt then begin
-                                       Result := Items[i];
-                                       Exit;
-                               end;
-                               inc(Cnt);
-                       end;
-               end;
-       end;
+       Result := GetThread(CountAll, Index);
 end;
 
 procedure TBoard.BeginUpdate;
@@ -1463,16 +1505,6 @@ begin
        FUpdate := True;
 end;
 
-{class function TBoard.GetColumnName(Index: Integer): string;
-begin
-       Result := COLUMN_THREADITEM[Index];
-end;
-
-class function TBoard.GetColumnCount: Integer;
-begin
-       Result := Length(COLUMN_THREADITEM);
-end;}
-
 //constructor TThreadItem.Create(AOwner: TComponent);
 procedure TThreadItem.Init;
 begin
@@ -1494,15 +1526,16 @@ begin
 
        FUpdate := True;
        FURL := '';
-       FBoardPlugIn := nil;
+       FJumpAddress := 0;
 end;
 
 // *************************************************************************
 // \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\8ew\92è\82µ\82½\83R\83\93\83X\83g\83\89\83N\83^
 // *************************************************************************
 constructor TThreadItem.Create(
-       inPlugIn        : TBoardPlugIn;
-       inURL                   : string
+       const inPlugIn : TBoardPlugIn;
+       const inBoard : TBoard;
+       inURL : string
 );
 var
        foundPos                        : Integer;
@@ -1514,9 +1547,9 @@ begin
 
        inherited Create;
        Init;
-
-       FBoardPlugIn    := inPlugIn;
-       URL                                             := inURL;
+       FParentBoard    := inBoard;
+       //FBoardPlugIn  := inPlugIn;
+       URL                             := inURL;
 
        if inPlugIn = nil then begin
                foundPos := Pos( READ_PATH, inURL );
@@ -1524,14 +1557,6 @@ begin
                        // dat \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
                        GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark );
                        GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey );
-                       if GikoSys.Is2chHost( host ) then
-                               FilePath :=
-                                       IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
-                                       BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat'
-                       else
-                               FilePath :=
-                                       IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
-                                       EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat';
                        FileName        := BBSKey + '.dat';
                        IsLogFile       := FileExists( FilePath );
                        URL                             := GikoSys.Get2chBrowsableThreadURL( inURL );
@@ -1542,39 +1567,46 @@ begin
        end;
 
 end;
-
 // *************************************************************************
-// \83f\83X\83g\83\89\83N\83^
+// \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ð\8ew\92è\82µ\82½\83R\83\93\83X\83g\83\89\83N\83^ Log\97L\82è\82©\82Ç\82¤\82©\94»\92f\8dÏ\82Ý
+// FileName\82à\8eæ\93¾\8dÏ\82Ý\81@\81¨\81@ReadSubject\97p
 // *************************************************************************
-destructor TThreadItem.Destroy;
+constructor TThreadItem.Create(
+       const inPlugIn : TBoardPlugIn;
+       const inBoard : TBoard;
+       inURL : string;
+       inExist: Boolean;
+       const inFilename: string
+);
 begin
 
-       // \83v\83\89\83O\83C\83\93\82É TThreadItem \82ª\94j\8aü\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
-       if IsBoardPlugInAvailable then
-               FBoardPlugIn.DisposeThreadItem( DWORD( Self ) );
+       inherited Create;
+       Init;
+       FParentBoard    := inBoard;
+       URL                             := inURL;
 
-       inherited;
+       if inPlugIn = nil then begin
+               // dat \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
+               FileName        := inFilename;
+               IsLogFile       := inExist;
+               URL                             := GikoSys.Get2chBrowsableThreadURL( inURL );
+       end else begin
+               // \83v\83\89\83O\83C\83\93\82É TThreadItem \82ª\8dì\90¬\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
+               inPlugIn.CreateThreadItem( DWORD( Self ) );
+       end;
 
 end;
-
 // *************************************************************************
-// \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ª\8eg\97p\89Â\94\\82©
+// \83f\83X\83g\83\89\83N\83^
 // *************************************************************************
-function       TThreadItem.IsBoardPlugInAvailable : Boolean;
+destructor TThreadItem.Destroy;
 begin
 
-       repeat
-               if BoardPlugIn = nil then
-                       Break;
-
-               if not Assigned( Pointer( BoardPlugIn.Module ) ) then
-                       Break;
-
-               Result := True;
-               Exit;
-       until True;
+       // \83v\83\89\83O\83C\83\93\82É TThreadItem \82ª\94j\8aü\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
+       if Self.ParentBoard.IsBoardPlugInAvailable then
+               Self.ParentBoard.BoardPlugIn.DisposeThreadItem( DWORD( Self ) );
 
-       Result := False;
+       inherited;
 
 end;
 
@@ -1641,31 +1673,8 @@ begin
        end;
 end;
 
-{function TThreadItem.GetOldDatgzURL: string;
-var
-       Protocol, Host, Path, Document, Port, Bookmark: string;
-begin
-       Result := Format('%s%s/%.3s/%s.gz', [ParentBoard.URL,
-                                                                                                                                                        'kako',
-                                                                                                                                                        FileName,
-                                                                                                                                                        FileName]);
-       if FDownloadHost <> '' then begin
-               ParseURI(Result, Protocol, Host, Path, Document, Port, Bookmark);
-               Result := Format('%s://%s%s%s', [Protocol,
-                                                                                                                                                DownloadHost,
-                                                                                                                                                Path,
-                                                                                                                                                Document]);
-
-       end;
-end;}
-
 function TThreadItem.GetOfflawCgiURL(const SessionID: string): string;
-//var
-//     Protocol, Host, Path, Document, Port, Bookmark: string;
 begin
-//     Result := GikoSys.UrlToServer(ParentBoard.URL)
-//                                     + 'test/offlaw.cgi/' + ParentBoard.BBSID + '/'
-//                                     + ChangeFileExt(FileName, '') + '/?raw=.0&sid=' + HttpEncode(SessionID);
        if FDownloadHost = '' then begin
                Result := GikoSys.UrlToServer(ParentBoard.URL)
                                                + 'test/offlaw.cgi/' + ParentBoard.BBSID + '/'
@@ -1676,10 +1685,6 @@ begin
                Result := 'http://' + FDownloadHost
                                                + '/test/offlaw.cgi/' + ParentBoard.BBSID + '/'
                                                + ChangeFileExt(FileName, '') + '/?raw=.0&sid=' + HttpEncode(SessionID);
-//             Result := Format('%s://%s%s%s', [Protocol,
-//                                                                                                                                              DownloadHost,
-//                                                                                                                                              Path,
-//                                                                                                                                              Document]);
        end;
 end;
 
@@ -1690,12 +1695,18 @@ begin
 end;
 
 procedure TThreadItem.DeleteLogFile;
+var
+        tmpFileName: String;
 begin
        ParentBoard.BeginUpdate;
 
        if FUnRead then
                ParentBoard.UnRead := ParentBoard.UnRead - 1;
        DeleteFile(GetThreadFileName);
+        //\8e\8e\8c±\93I\82Étmp\82à\8dí\8f\9c\82µ\82Ä\82Ý\82é
+        tmpFileName := StringReplace(GetThreadFileName, 'dat', 'tmp', [rfReplaceAll]);
+        DeleteFile(tmpFileName);
+
        if FileExists(ChangeFileExt(GetThreadFileName,'.NG')) = true then
                DeleteFile(ChangeFileExt(GetThreadFileName,'.NG'));
        FRoundDate := ZERO_DATE;
@@ -1724,7 +1735,7 @@ begin
        if Length( FilePath ) > 0 then
                Result := FilePath
        else
-               Result := IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder )
+               Result := GikoSys.Setting.LogFolderP
                                                + BBS2CH_LOG_FOLDER + PATH_DELIM + ParentBoard.BBSID + PATH_DELIM + FileName;
 end;
 
@@ -1736,14 +1747,6 @@ begin
                ParentBoard.FModified := True;
 end;
 
-{procedure TThreadItem.SetRoundNo(i: Integer);
-begin
-       if FRoundNo = i then Exit;
-       FRoundNo := i;
-       if FUpdate and (ParentBoard <> nil) then
-               ParentBoard.FModified := True;
-end;}
-
 procedure TThreadItem.SetRound(b: Boolean);
 begin
        if b then
@@ -1764,6 +1767,7 @@ begin
                ParentBoard.FModified := True;
 end;
 
+
 procedure TThreadItem.SetKokomade(i: Integer);
 begin
        if FKokomade = i then Exit;
@@ -1776,8 +1780,14 @@ procedure TThreadItem.SetUnRead(b: Boolean);
 begin
        if FUnRead = b then Exit;
        FUnRead := b;
-       if FUpdate and (ParentBoard <> nil) then
+       if FUpdate and (ParentBoard <> nil) then begin
                ParentBoard.FModified := True;
+               if FUnRead then begin
+                       ParentBoard.UnRead := ParentBoard.UnRead + 1;
+               end else begin
+            ParentBoard.UnRead := ParentBoard.UnRead - 1;
+               end;
+       end;
 end;
 
 procedure TThreadItem.SetScrollTop(i: Integer);
@@ -1798,16 +1808,7 @@ begin
        FUpdate := True;
 end;
 
-{initialization
-       BBS2ch := TBBS.Create;
-
-finalization
-       if BBS2ch <> nil then
-               BBS2ch.Free;}
 function TThreadItem.GetCreateDate: TDateTime;
-var
-       unixtime: Int64;
-    tmp: string;
 begin
        // \83t\83@\83C\83\8b\96¼\82©\82ç\83X\83\8c\8dì\90¬\93ú\8e\9e\82ð\8b\81\82ß\82é
        try
@@ -1815,18 +1816,7 @@ begin
             Result := ZERO_DATE
         else begin
             // \83\8d\83O\83t\83@\83C\83\8b\82Ì\8ag\92£\8eq\82ð\82Í\82¸\82µ\82½\82à\82Ì\82ª\83X\83\8c\8dì\90¬\93ú\8e\9e
-                       tmp := ChangeFileExt(FFileName, '');
-                       if AnsiPos('_', tmp) <> 0 then
-                               if AnsiPos('_', tmp) > 9 then
-                                       tmp := Copy(tmp, 1, AnsiPos('_', tmp)-1)
-                               else
-                                       Delete(tmp, AnsiPos('_', tmp), 1);
-
-                       if ( Length(tmp) = 9) and ( tmp[1] = '0' ) then
-                               Insert('1', tmp, 1);
-
-                       unixtime := StrToInt64Def(tmp, ZERO_DATE);
-                       Result := UnixToDateTime(unixtime) + OffsetFromUTC;
+            Result := GikoSys.GetCreateDateFromName(FFileName);
                        if GikoSys.Setting.FutureThread then begin
                        if CompareDateTime(Result, Now) = 1 then
                        Result := ZERO_DATE;
@@ -1838,6 +1828,53 @@ begin
                        Result := ZERO_DATE;
        end;
 end;
+function TThreadItem.GetFilePath: String;
+var
+       path : String;
+begin
+       path := ExtractFilePath(Self.ParentBoard.FilePath) + Self.FileName;
+    Result := path;
+end;
+
+destructor TBoardGroup.Destroy;
+begin
+       Clear;
+       inherited;
+end;
+procedure      TBoardGroup.Clear;
+var
+       i       : Integer;
+begin
+       for i := Self.Count - 1 downto 0 do begin
+               try
+                       TBoard(Self.Objects[i]).Free;
+               except
+               end;
+    end;
+    inherited Clear;
+       Self.Capacity := 0;
+       try
+               if FBoardPlugIn <> nil then
+                       FBoardPlugIn.Free;
+        FBoardPlugIn := nil;
+       except
+       end;
+
+end;
+
+function TSpecialBoard.Add(item: TThreadItem): integer;
+begin
+    Result := inherited AddObject(Item.URL, Item);
+end;
+
+procedure TSpecialBoard.Clear;
+var
+       i: integer;
+begin
+    for i := Count - 1 downto 0 do
+               DeleteList(i);
+    Capacity := 0;
+end;
 
 end.