OSDN Git Service

LogFolderPプロパティ追加による変更。
[gikonavigoeson/gikonavi.git] / BoardGroup.pas
index 412db2e..80a3a4b 100644 (file)
@@ -3,7 +3,8 @@ unit BoardGroup;
 interface
 
 uses
-       SysUtils, Classes, ComCtrls, IniFiles, {HTTPApp,} YofUtils, IdGlobal;
+       Windows, SysUtils, Classes, ComCtrls, IniFiles, {HTTPApp,} YofUtils, IdGlobal,
+       ExternalBoardManager, ExternalBoardPlugInMain, StrUtils, DateUtils;
 
 type
        //\83\8a\83X\83g\82Ì\95\\8e¦\83A\83C\83e\83\80\91I\91ð
@@ -13,7 +14,7 @@ type
        //\8f\84\89ñ\94Ô\8d\86
        //TGikoRoundNo = (grnNone, grn1, grn2, grn3, grn4, grn5, grnOnce);
        //\83\8a\83X\83g\82Ì\8fã\82°\89º\82°
-       TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew);
+       TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew, gasNull);
 
 {      TFolder = class
        private
@@ -46,7 +47,7 @@ type
 }
 
 {
-       TBBS2ch = class(TBBS)
+       TBBS = class(TBBS)
        end;
        TBoard2ch = class(TBoard)
        end;
@@ -69,35 +70,35 @@ type
        TBoard = class;
        TThreadItem = class;
 
-       //\82Æ\82è\82 \82¦\82¸\82Q\82¿\82á\82ñ\82Ë\82é\82Ì\83\8b\81[\83g
-       TBBS2ch = class(TList)
+       // BBS \82Ì\83\8b\81[\83g
+       TBBS = class(TList)
        private
                FTitle: string;
-               FLogFolder: string;
+               FFilePath : string;                                             // \94Â\83\8a\83X\83g\82Ì\83p\83X
                FExpand: Boolean;
                FKubetsuChk: Boolean;                                   //\8di\8d\9e\82Ý\8e\9e\91å\95\8e\9a\8f¬\95\8e\9a\8bæ\95Ê
                FSelectText: string;                                    //\8di\8d\9e\82Ý\95\8e\9a\97ñ
                FShortSelectText: string;
+               FIsBoardFileRead : Boolean;             // \94Â\83\8a\83X\83g\82Í\93Ç\82Ý\8d\9e\82Ü\82ê\82Ä\82¢\82é\82©\81H
 
                function GetCategory(index: integer): TCategory;
                procedure SetCategory(index: integer; value: TCategory);
                procedure SetSelectText(s: string);
        public
-               constructor Create(LogFolder: string);
+               constructor Create( boardFilePath : string );
                destructor Destroy; override;
 
-               procedure ReadBoardFile;
-
-               function GetBoardFromBBSID(BBSID: string): TBoard;
-
                function Add(item: TCategory): integer;
                procedure Delete(index: integer);
                procedure Clear; override;
                function Find(key: string): TCategory;
-               function FindBBSID(BBSID: string): TBoard;
-               function FindBoardFromTitle(Title: string): TBoard;
-               function FindThreadItem(BBSID: string; FileName: string): TThreadItem;
-               function GetLogFolder: string;
+               function FindBBSID(const BBSID: string): TBoard;
+               function FindBoardFromTitle(const Title: string): TBoard;
+               function FindBoardFromURL(const inURL: string): TBoard;
+               function FindThreadFromURL(const inURL : string ) : TThreadItem;
+               function FindThreadItem(const BBSID, FileName: string): TThreadItem;
+               function FindCategoryFromTitle(const inTitle : string ) : TCategory;
+               property FilePath : string read FFilePath write FFilePath;
 
                property Items[index: integer]: TCategory read GetCategory write SetCategory;
                property Title: string read FTitle write FTitle;
@@ -106,14 +107,17 @@ type
                property KubetsuChk: Boolean read FKubetsuChk write FKubetsuChk;
                property SelectText: string read FSelectText write SetSelectText;
                property ShortSelectText: string read FShortSelectText write FShortSelectText;
+
+               property        IsBoardFileRead : Boolean read FIsBoardFileRead write FIsBoardFileRead;
        end;
 
-       //\83J\83e\83S\83\8a
-       TCategory = class(TList)
+       // \83J\83e\83S\83\8a(\94 URL \82Ì\83\8a\83X\83g)
+//     TCategory = class(THashedStringList)
+       TCategory = class(TStringList)
        private
                FNo: Integer;
                FTitle: string;
-               FParentBBS2ch: TBBS2ch;
+               FParenTBBS: TBBS;
                FExpand: Boolean;
 
                function GetBoard(index: integer): TBoard;
@@ -125,22 +129,27 @@ type
                property No: Integer read FNo write FNo;
                property Title: string read FTitle write FTitle;
                property Items[index: integer]: TBoard read GetBoard write SetBoard;
-               property ParentBBS2ch: TBBS2ch read FParentBBS2ch write FParentBBS2ch;
+               property ParenTBBS: TBBS read FParenTBBS write FParenTBBS;
 
                function Add(item: TBoard): integer;
                procedure Delete(index: integer);
                procedure Clear; override;
-               function FindName(key: string): TBoard;
-               function FindBBSID(BBSID: string): TBoard;
-               function FindBoardFromTitle(Title: string): TBoard;
+               function FindName(const key: string): TBoard;
+               function FindBBSID(const BBSID: string): TBoard;
+               function FindBoardFromTitle(const Title: string): TBoard;
+               function FindBoardFromURL(const inURL: string): TBoard;
+               function FindThreadFromURL(const inURL : string ) : TThreadItem;
                function IsMidoku: Boolean;
 
                property NodeExpand: Boolean read FExpand write FExpand;
        end;
 
-       //\94Â
-       TBoard = class(TList)
+       // \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é)
+
                FNo: Integer;                                                                   //\94Ô\8d\86
                FTitle: string;                                                         //\83{\81[\83h\83^\83C\83g\83\8b
                FBBSID: string;                                                         //BBSID
@@ -152,7 +161,7 @@ type
                FLastGetTime: TDateTime;                        //\83X\83\8c\83b\83h\82Ü\82½\82Í\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\8cã\82É\8dX\90V\82µ\82½\93ú\8e\9e\81i\83T\81[\83o\91¤\93ú\8e\9e\81E\8f\91\82«\8d\9e\82Ý\8e\9e\82É\8eg\97p\82·\82é\81j
                FIsThreadDatRead: Boolean;              //\83X\83\8c\83b\83h\83\8a\83X\83g\82Í\93Ç\82Ý\8d\9e\82Ü\82ê\82Ä\82¢\82é\82©\81H
                FUnRead: Integer;                                                       //\83X\83\8c\83b\83h\96¢\93Ç\90\94
-               FParentCategory: TCategory;   //\90e\83J\83e\83S\83\8a
+               FParentCategory: TCategory;             //\90e\83J\83e\83S\83\8a
                FModified: Boolean;                                             //\8fC\90³\83t\83\89\83O
                FBoolData: Boolean;                                             //\82¢\82ë\82ñ\82È\97p\93r\82É\8eg\82¤yo
                FSPID: string;                                                          //\8f\91\82«\8d\9e\82Ý\97pSPID
@@ -163,6 +172,18 @@ type
                FUpdate: Boolean;
                FExpand: Boolean;
 
+               FBoardPlugIn    : TBoardPlugIn; // \82±\82Ì\94Â\82ð\83T\83|\81[\83g\82·\82é\83v\83\89\83O\83C\83\93
+               FFilePath                       : string;                               // \82±\82Ì\83X\83\8c\88ê\97\97\82ª\95Û\91\82³\82ê\82Ä\82¢\82é\83p\83X
+               FIsLogFile              : Boolean;                      // \83\8d\83O\91\8dÝ\83t\83\89\83O
+               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
                function GetThreadItem(index: integer): TThreadItem;
                procedure SetThreadItem(index: integer; value: TThreadItem);
                procedure SetRound(b: Boolean);
@@ -172,10 +193,13 @@ type
                procedure SetUnRead(i: Integer);
                procedure SetKotehanName(s: string);
                procedure SetKotehanMail(s: string);
+               procedure Init;
        public
-               constructor Create;
+               constructor Create( inPlugIn : TBoardPlugIn; inURL : string );
                destructor Destroy; override;
 
+               property Context: DWORD read FContext write FContext;
+
                property Items[index: integer]: TThreadItem read GetThreadItem write SetThreadItem;
                property No: Integer read FNo write FNo;
                property Title: string read FTitle write FTitle;
@@ -191,18 +215,30 @@ type
                property IsThreadDatRead: Boolean read FIsThreadDatRead write FIsThreadDatRead;
                property ParentCategory: TCategory read FParentCategory write FParentCategory;
 
+               property        BoardPlugIn     : TBoardPlugIn  read FBoardPlugIn;
+               property        FilePath                : string                                read FFilePath write FFilePath;
+               property        IsLogFile               : Boolean                               read FIsLogFile write FIsLogFile;
+               property        IntData                 : Integer                               read FIntData write FIntData;
+               property        ListData                : TList                                 read FListData write FListData;
+               function        IsBoardPlugInAvailable : Boolean;
+
                function Add(item: TThreadItem): integer;
                procedure Insert(Index: Integer; Item: TThreadItem);
                procedure Delete(index: integer);
                procedure DeleteList(index: integer);
                procedure Clear; override;
-               function Find(ItemFileName: string): TThreadItem;
-               function GetIndex(ItemFileName: string): Integer;
+               function FindThreadFromFileName(const ItemFileName: string): TThreadItem;
+               function FindThreadFromURL(const inURL : string ) : TThreadItem;
+               function GetIndexFromFileName(const ItemFileName: string): Integer;
+               function GetIndexFromURL(const URL: string): Integer;
                procedure LoadSettings;
                procedure SaveSettings;
                function GetReadCgiURL: string;
                function GetSubjectFileName: string;
                function GetFolderIndexFileName: string;
+               function GetSETTINGTXTFileName: string;
+               function GETHEADTXTFileName: string;
+               function GetTitlePictureFileName: string;
                function GetSendURL: string;
 
                function GetNewThreadCount: Integer;
@@ -220,11 +256,20 @@ type
                property PON: string read FPON write FPON;
                property KotehanName: string read FKotehanName write SetKotehanName;
                property KotehanMail: string read FKotehanMail write SetKotehanMail;
+
+               property SETTINGTXTTime: TDateTime read FSETTINGTXTTime write FSETTINGTXTTime;
+               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 Multiplicity: Integer read FMultiplicity write FMultiplicity;
        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
@@ -250,27 +295,36 @@ type
 
                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
 
                procedure SetLastModified(d: TDateTime);
                procedure SetRound(b: Boolean);
-               procedure SetRoundName(s: string);
+               procedure SetRoundName(const s: string);
                procedure SetKokomade(i: Integer);
                procedure SetUnRead(b: Boolean);
                procedure SetScrollTop(i: Integer);
+               procedure Init;
+               function GetCreateDate: TDateTime;
        public
-               constructor Create;
+               constructor Create( inPlugIn : TBoardPlugIn; inURL : string ); overload;
+        constructor Create( is2ch : Boolean; const inURL, inHost, inBBSID, inBBSKey : string ); overload;
+
                destructor Destroy; override;
 
                function GetDatURL: string;
                function GetDatgzURL: string;
 //             function GetOldDatgzURL: string;
-               function GetOfflawCgiURL(SessionID: string): string;
+               function GetOfflawCgiURL(const SessionID: string): string;
                function GetSendURL: string;
                procedure DeleteLogFile;
                function GetThreadFileName: string;
                procedure BeginUpdate;
                procedure EndUpdate;
 
+               property Context: DWORD read FContext write FContext;
+
                property No: Integer read FNo write FNo;
                property FileName: string read FFileName write FFileName;
                property Title: string read FTitle write FTitle;
@@ -295,6 +349,11 @@ type
                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;
        end;
 
 
@@ -315,43 +374,116 @@ type
                procedure Clear; override;
        end;}
 
+       function        BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard;
+       function        BBSsFindBoardFromURL( inURL : string ) : TBoard;
+       function        BBSsFindBoardFromTitle( inTitle : string ) : TBoard;
+       function        BBSsFindThreadFromURL(const inURL : string ) : TThreadItem;
+       function        ConvertDateTimeString( inDateTimeString : string) : TDateTime;
+
 var
-       BBS2ch: TBBS2ch;
+       BBSs            : array of TBBS;
 
 implementation
 
 uses
-       GikoSystem, RoundData;
+       GikoSystem, RoundData, MojuUtils;
 
 const
-       BBS2CH_NAME:           string  = '\82Q\82¿\82á\82ñ\82Ë\82é';
-       BBS2CH_LOG_FOLDER:     string  = '2ch';
+       BBS2CH_NAME:                                     string = '\82Q\82¿\82á\82ñ\82Ë\82é';
+       BBS2CH_LOG_FOLDER:               string = '2ch';
+       EXTERNAL_LOG_FOLDER:            string  = 'exboard';
+
+       FOLDER_INI_FILENAME:     string = 'Folder.ini';
+       FOLDER_INDEX_FILENAME: string   = 'Folder.idx';
+       SUBJECT_FILENAME:                       string  = 'subject.txt';
+       PATH_DELIM:                                             string  = '\';
+       SETTINGTXT_FILENAME:            string = 'SETTING.TXT';
+    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');
 
-       FOLDER_INI_FILENAME:   string  = 'Folder.ini';
-       FOLDER_INDEX_FILENAME: string  = 'Folder.idx';
-       SUBJECT_FILENAME:      string  = 'subject.txt';
-       PATH_DELIM:            string  = '\';
-       //DEFAULT_LIST_COUNT:    Integer = 100;
+// 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
+// \89Â\94\\82È\8fê\8d\87\82Í URL \82ð\8eg\97p\82µ\82Ä\82­\82¾\82³\82¢\81B
+function       BBSsFindBoardFromBBSID(
+       inBBSID : string
+) : TBoard;
+begin
 
-//     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');
+       Result := BBSs[ 0 ].FindBBSID( inBBSID );
+
+end;
+
+function       BBSsFindBoardFromURL(
+       inURL   : string
+) : TBoard;
+var
+       i                       : Integer;
+begin
+
+       for i := Length( BBSs ) - 1 downto 0 do begin
+               Result := BBSs[ i ].FindBoardFromURL( inURL );
+               if Result <> nil then
+                       Exit;
+       end;
+
+       Result := nil;
+
+end;
+
+function       BBSsFindBoardFromTitle(
+       inTitle : string
+) : TBoard;
+var
+       i                               : Integer;
+begin
+
+       for i := Length( BBSs ) - 1 downto 0 do begin
+               Result := BBSs[ i ].FindBoardFromTitle( inTitle );
+               if Result <> nil then
+                       Exit;
+       end;
+
+       Result := nil;
+
+end;
+
+function       BBSsFindThreadFromURL(
+       const inURL                     : string
+) : TThreadItem;
+var
+       board                   : TBoard;
+       boardURL        : string;
+begin
+
+       boardURL        := GikoSys.GetThreadURL2BoardURL( inURL );
+       board                   := BBSsFindBoardFromURL( boardURL );
+       if board = nil then
+               Result := nil
+       else
+               Result := board.FindThreadFromURL( inURL );
+
+end;
 
 (*************************************************************************
  *\8b@\94\\96¼\81FTBBS\83R\83\93\83X\83g\83\89\83N\83^
  *Public
  *************************************************************************)
-constructor TBBS2ch.Create(LogFolder: string);
+constructor TBBS.Create( boardFilePath : string );
 begin
+       inherited Create;
        Title := BBS2CH_NAME;
-       FLogFolder := LogFolder;
+       FFilePath := boardFilePath;
 end;
 
 (*************************************************************************
  *\8b@\94\\96¼\81FTBBS\83f\83X\83g\83\89\83N\83^
  *Public
  *************************************************************************)
-destructor TBBS2ch.Destroy;
+destructor TBBS.Destroy;
 begin
        Clear;
        inherited;
@@ -361,23 +493,23 @@ end;
  *\8b@\94\\96¼\81F
  *Public
  *************************************************************************)
-function TBBS2ch.GetCategory(index: integer): TCategory;
+function TBBS.GetCategory(index: integer): TCategory;
 begin
        Result := TCategory(inherited Items[index]);
 end;
 
-procedure TBBS2ch.SetCategory(index: integer; value: TCategory);
+procedure TBBS.SetCategory(index: integer; value: TCategory);
 begin
        inherited Items[index] := value;
 end;
 
-function TBBS2ch.Add(item: TCategory): integer;
+function TBBS.Add(item: TCategory): integer;
 begin
-       Item.ParentBBS2ch := self;
+       Item.ParenTBBS := self;
        Result := inherited Add(item);
 end;
 
-procedure TBBS2ch.Delete(index: integer);
+procedure TBBS.Delete(index: integer);
 begin
        if Items[index] <> nil then
                TCategory(Items[index]).Free;
@@ -385,54 +517,87 @@ begin
        inherited Delete(index);
 end;
 
-procedure TBBS2ch.Clear;
+procedure TBBS.Clear;
 var
        i: integer;
 begin
        for i := Count - 1 downto 0 do
                Delete(i);
+    Capacity := Count;
 end;
 
-function TBBS2ch.Find(key: string): TCategory;
+function TBBS.Find(key: string): TCategory;
 begin
        Result := nil;
 end;
 
-function TBBS2ch.FindBBSID(BBSID: string): TBoard;
+function TBBS.FindBBSID(const BBSID: string): TBoard;
 var
-       i: Integer;
-       Category: TCategory;
-       Board: TBoard;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBBSID(BBSID);
-               if Board <> nil then begin
-                       Result := Board;
+       if not IsBoardFileRead then
+       GikoSys.ReadBoardFile( Self );
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBBSID(BBSID);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
-function TBBS2ch.FindBoardFromTitle(Title: string): TBoard;
+//*************************************************************************
+// \83^\83C\83g\83\8b\82Ì\88ê\92v\82·\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindBoardFromTitle(const Title: string): TBoard;
 var
        i: Integer;
-       Category: TCategory;
-       Board: TBoard;
 begin
+       if not IsBoardFileRead then
+       GikoSys.ReadBoardFile( Self );
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromTitle(Title);
+               if Result <> nil then
+                       Exit;
+       end;
        Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromTitle(Title);
-               if Board <> nil then begin
-                       Result := Board;
+end;
+
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindBoardFromURL(const inURL: string): TBoard;
+var
+       i                                       : Integer;
+begin
+       if not IsBoardFileRead then
+       GikoSys.ReadBoardFile( Self );
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromURL( inURL );
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
-function TBBS2ch.FindThreadItem(BBSID: string; FileName: string): TThreadItem;
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\83X\83\8c\83b\83h\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindThreadFromURL(const inURL: string): TThreadItem;
+var
+       board                   : TBoard;
+       boardURL        : string;
+begin
+
+       boardURL        := GikoSys.GetThreadURL2BoardURL( inURL );
+       board                   := FindBoardFromURL( boardURL );
+       if board = nil then
+               Result := nil
+       else
+               Result := board.FindThreadFromURL( inURL );
+
+end;
+
+function TBBS.FindThreadItem(const BBSID, FileName: string): TThreadItem;
 var
        Board: TBoard;
 begin
@@ -440,116 +605,37 @@ begin
        Board := FindBBSID(BBSID);
        if Board = nil then
                Exit;
-       Result := Board.Find(FileName);
+       Result := Board.FindThreadFromFileName(FileName);
 end;
 
-(*************************************************************************
- *\8b@\94\\96¼\81@\81@\81F\83{\81[\83h\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý
- *\89Â\8e\8b\81@\81@\81@\81FPublic
- *\97\9a\97ð\82P\81@\81@\81F\90V\8bK\8dì\90¬
- *************************************************************************)
-procedure TBBS2ch.ReadBoardFile;
+function TBBS.FindCategoryFromTitle(const inTitle : string ) : TCategory;
 var
-       i, j: integer;
-       idx: Integer;
-       ini: TMemIniFile;
-       CategoryList: TStringList;
-       BoardList: TStringList;
-       Category: TCategory;
-       Board: TBoard;
-       inistr: string;
-       RoundItem: TRoundItem;
-       BBSList: TStringList;
-       CustomList: TStringList;
-begin
-       ini := TMemIniFile.Create('');
-       BBSList := TStringList.Create;
-       CustomList := TStringList.Create;
-       try
-               if FileExists(GikoSys.GetBoardFileName) then
-                       BBSList.LoadFromFile(GikoSys.GetBoardFileName);
-               if FileExists(GikoSys.GetCustomBoardFileName) then
-                       CustomList.LoadFromFile(GikoSys.GetCustomBoardFileName);
-               BBSList.AddStrings(CustomList);
-               ini.SetStrings(BBSList);
-
-               CategoryList := TStringList.Create;
-               BoardList := TStringList.Create;
-               try
-                       ini.ReadSections(CategoryList);
-                       for i := 0 to CategoryList.Count - 1 do begin
-
-                               ini.ReadSection(CategoryList[i], BoardList);
-                               Category := TCategory.Create;
-                               Category.No := i + 1;
-                               Category.Title := CategoryList[i];
-
-                               for j := 0 to BoardList.Count - 1 do begin
-                                       inistr := ini.ReadString(CategoryList[i], BoardList[j], '');
-                                       Board := TBoard.Create;
-                                       Board.BeginUpdate;
-                                       Board.No := j + 1;
-                                       Board.Title := BoardList[j];
-                                       Board.BBSID := GikoSys.UrlToID(inistr);
-                                       Board.URL := inistr;
-                                       Board.RoundDate := ZERO_DATE;
-
-                                       idx := RoundList.Find(Board);
-                                       if idx <> -1 then begin
-                                               RoundItem := RoundList.Items[idx, grtBoard];
-                                               Board.Round := True;
-                                               Board.RoundName := RoundItem.RoundName;
-                                       end;
-                                       Category.Add(Board);
-                                       Board.EndUpdate;
-                               end;
-                               BBS2ch.Add(Category);
-                       end;
-               finally
-                       BoardList.Free;
-                       CategoryList.Free;
+       i : Integer;
+begin
+
+       for i := Count - 1 downto 0 do begin
+               if AnsiCompareStr(Items[ i ].Title, inTitle) = 0 then begin
+                       Result := Items[ i ];
+                       Exit;
                end;
-       finally
-               BBSList.Free;
-               CustomList.Free;
-               ini.Free;
        end;
-end;
 
-function TBBS2ch.GetBoardFromBBSID(BBSID: string): TBoard;
-var
-       i: integer;
-begin
        Result := nil;
-       for i := 0 to BBS2ch.Count - 1 do begin
-               Result := BBS2ch.Items[i].FindBBSID(BBSID);
-               if Result <> nil then
-                       Exit;
-       end;
-end;
 
-(*************************************************************************
- *\83\8d\83O\83t\83H\83\8b\83_\8eæ\93¾
- *
- *************************************************************************)
-function TBBS2ch.GetLogFolder: string;
-begin
-       Result := IncludeTrailingPathDelimiter(FLogFolder)
-                                       + BBS2CH_LOG_FOLDER + PATH_DELIM;
 end;
 
-procedure TBBS2ch.SetSelectText(s: string);
+procedure TBBS.SetSelectText(s: string);
 begin
        FSelectText := s;
-       ShortSelectText := GikoSys.ZenToHan(s);
+       ShortSelectText := CustomStringReplace(ZenToHan(s), ' ', '');
 end;
 
-{class function TBBS2ch.GetColumnName(Index: Integer): string;
+{class function TBBS.GetColumnName(Index: Integer): string;
 begin
        Result := COLUMN_CATEGORY[Index];
 end;
 
-class function TBBS2ch.GetColumnCount: Integer;
+class function TBBS.GetColumnCount: Integer;
 begin
        Result := Length(COLUMN_CATEGORY);
 end;}
@@ -559,6 +645,11 @@ end;}
 //===================
 constructor TCategory.Create;
 begin
+       inherited;
+
+       Duplicates              := dupIgnore;
+       CaseSensitive   := False;
+       //Sorted                                := True;
 end;
 
 destructor TCategory.Destroy;
@@ -569,25 +660,32 @@ end;
 
 function TCategory.GetBoard(index: integer): TBoard;
 begin
-       Result := TBoard(inherited Items[index]);
+       Result := TBoard( Objects[index] );
 end;
 
 procedure TCategory.SetBoard(index: integer; value: TBoard);
 begin
-       inherited Items[index] := value;
+       Objects[index] := value;
+       Strings[index] := value.URL
 end;
 
 function TCategory.Add(item: TBoard): integer;
 begin
        Item.ParentCategory := self;
-       Result := inherited Add(item);
+       Result := AddObject( item.URL, item );
 end;
 
 procedure TCategory.Delete(index: integer);
 begin
-       if Items[index] <> nil then
-               TBoard(Items[index]).Free;
-       Items[index] := nil;
+       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);
 end;
 
@@ -597,37 +695,73 @@ var
 begin
        for i := Count - 1 downto 0 do
                Delete(i);
+       Capacity := Count;
 end;
 
-function TCategory.FindName(key: string): TBoard;
+function TCategory.FindName(const key: string): TBoard;
 begin
        Result := nil;
 end;
 
-function TCategory.FindBBSID(BBSID: string): TBoard;
+function TCategory.FindBBSID(const BBSID: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               if Items[i].FBBSID = BBSID then begin
+       for i := Count - 1 downto 0 do begin
+               if AnsiCompareStr(Items[i].FBBSID, BBSID) = 0 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
-function TCategory.FindBoardFromTitle(Title: string): TBoard;
+//*************************************************************************
+// \83^\83C\83g\83\8b\82Ì\88ê\92v\82·\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TCategory.FindBoardFromTitle(const Title: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               if Items[i].FTitle = Title then begin
+       for i := Count - 1 downto 0 do begin
+               if AnsiCompareStr(Items[i].FTitle, Title) = 0 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
+end;
+
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TCategory.FindBoardFromURL(const inURL: string): TBoard;
+var
+       i       : Integer;
+begin
+       i := IndexOf( inURL );
+       if i >= 0 then
+               Result := TBoard( Objects[ i ] )
+       else
+               Result := nil;
+end;
+
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\83X\83\8c\83b\83h\82ð\92T\82·
+//*************************************************************************)
+function TCategory.FindThreadFromURL(const inURL: string): TThreadItem;
+var
+       board                   : TBoard;
+       boardURL        : string;
+begin
+
+       boardURL        := GikoSys.GetThreadURL2BoardURL( inURL );
+       board                   := FindBoardFromURL( boardURL );
+       if board = nil then
+               Result := nil
+       else
+               Result := board.FindThreadFromURL( inURL );
+
 end;
 
 function TCategory.IsMidoku: Boolean;
@@ -664,8 +798,12 @@ end;}
 //===================
 //TBoard
 //===================
-constructor TBoard.Create;
+procedure TBoard.Init;
 begin
+       Duplicates              := dupIgnore;
+       CaseSensitive   := False;
+       //Sorted                                := True;
+
        FNo := 0;
        FTitle := '';
        FBBSID := '';
@@ -682,6 +820,45 @@ begin
        FUpdate := True;
 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 TBoard.Create(
+       inPlugIn        : TBoardPlugIn;
+       inURL                   : string
+);
+var
+       protocol, host, path, document, port, bookmark  : string;
+begin
+
+       inherited Create;
+       Init;
+
+       FBoardPlugIn    := inPlugIn;
+       URL                                             := inURL;
+       BBSID                                   := GikoSys.UrlToID( inURL );
+
+       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
+                       FilePath :=
+                               GikoSys.Setting.LogFolderP  +
+                               BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+               else
+                       FilePath :=
+                               GikoSys.Setting.LogFolderP +
+                               EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+       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 ) );
+       end;
+
+end;
+
+// *************************************************************************
+// \83f\83X\83g\83\89\83N\83^
+// *************************************************************************
 destructor TBoard.Destroy;
 begin
        if FModified then begin
@@ -689,30 +866,57 @@ begin
                SaveSettings;
        end;
 
+       // \83v\83\89\83O\83C\83\93\82É TBoardItem \82ª\94j\8aü\82³\82ê\82½\82±\82Æ\82ð\93`\82¦\82é
+       if IsBoardPlugInAvailable then
+               BoardPlugIn.DisposeBoardItem( DWORD( Self ) );
+
        Clear;
        inherited;
 end;
 
+// *************************************************************************
+// \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ª\8eg\97p\89Â\94\\82©
+// *************************************************************************
+function       TBoard.IsBoardPlugInAvailable : Boolean;
+begin
+
+       repeat
+               if BoardPlugIn = nil then
+                       Break;
+                       
+               if not Assigned( Pointer( BoardPlugIn.Module ) ) then
+                       Break;
+
+               Result := True;
+               Exit;
+       until True;
+
+       Result := False;
+
+end;
+
 function TBoard.GetThreadItem(index: integer): TThreadItem;
 begin
-       Result := TThreadItem(inherited Items[index]);
+       Result := TThreadItem( Objects[index] );
 end;
 
 procedure TBoard.SetThreadItem(index: integer; value: TThreadItem);
 begin
-       inherited Items[index] := value;
+       Objects[index] := value;
+       Strings[index] := value.URL;
 end;
 
 function TBoard.Add(Item: TThreadItem): Integer;
 begin
        Item.ParentBoard := Self;
-       Result := inherited Add(Item);
+       Result := inherited AddObject(Item.URL, Item);
 end;
 
 procedure TBoard.Insert(Index: Integer; Item: TThreadItem);
 begin
        Item.ParentBoard := Self;
-       inherited Insert(Index, Item);
+       inherited InsertObject(Index, Item.URL, Item);
+
 end;
 
 //Index\82Å\8ew\92è\82³\82ê\82½\83X\83\8c\83b\83h\83I\83u\83W\83F\83N\83g\82ð\94j\8aü
@@ -720,7 +924,6 @@ procedure TBoard.Delete(index: Integer);
 begin
        if Items[index] <> nil then
                TThreadItem(Items[index]).Free;
-       Items[index] := nil;
        inherited Delete(index);
 end;
 
@@ -737,22 +940,23 @@ begin
 //     FUnRead := 0;
        for i := Count - 1 downto 0 do
                Delete(i);
+        Capacity := Count;
 end;
 
-function TBoard.Find(ItemFileName: string): TThreadItem;
+function TBoard.FindThreadFromFileName(const ItemFileName: string): TThreadItem;
 var
        i: integer;
 begin
        Result := nil;
        for i := 0 to Count - 1 do begin
-               if Items[i].FileName = ItemFileName then begin
+               if AnsiCompareStr(Items[i].FileName, ItemFileName) = 0 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
 end;
 
-function TBoard.GetIndex(ItemFileName: string): Integer;
+function TBoard.GetIndexFromFileName(const ItemFileName: string): Integer;
 var
        i: integer;
 begin
@@ -765,6 +969,27 @@ begin
        end;
 end;
 
+function TBoard.GetIndexFromURL(const URL: string): Integer;
+begin
+       Result := IndexOf( URL );
+end;
+
+function TBoard.FindThreadFromURL(const inURL : string ) : TThreadItem;
+var
+       i : Integer;
+begin
+
+       if not IsThreadDatRead then
+               GikoSys.ReadSubjectFile( Self );
+
+       i := IndexOf( inURL );
+       if i >= 0 then
+               Result := TThreadItem( Objects[ i ] )
+       else
+               Result := nil;
+
+end;
+
 {function TBoard.GetMidokuCount: Integer;
 var
        i: integer;
@@ -783,26 +1008,41 @@ procedure TBoard.LoadSettings;
 var
        ini: TMemIniFile;
        FileName: string;
+       tmp: string;
 begin
-       FileName := ParentCategory.ParentBBS2ch.GetLogFolder
-                                               + BBSID + PATH_DELIM + FOLDER_INI_FILENAME;
+       if Length( FilePath ) > 0 then
+               FileName := ExtractFilePath( FilePath ) + FOLDER_INI_FILENAME
+       else
+               FileName := GikoSys.Setting.LogFolderP
+                                                       + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + FOLDER_INI_FILENAME;
 
        if not FileExists(FileName) then
                Exit;
        ini := TMemIniFile.Create(FileName);
        try
 //             Round := ini.ReadBool('Status', 'Round', False);
-               FRoundDate := ini.ReadDateTime('Status', 'RoundDate', ZERO_DATE);
-               FLastModified := ini.ReadDateTime('Status', 'LastModified', ZERO_DATE);
-               FLastGetTime := ini.ReadDateTime('Status', 'LastGetTime', ZERO_DATE);
+               tmp := ini.ReadString('Status', 'RoundDate', DateTimeToStr(ZERO_DATE));
+               FRoundDate := ConvertDateTimeString(tmp);
+               tmp := ini.ReadString('Status', 'LastModified', DateTimeToStr(ZERO_DATE));
+               FLastModified := ConvertDateTimeString(tmp);
+               tmp := ini.ReadString('Status', 'LastGetTime', DateTimeToStr(ZERO_DATE));
+               FLastGetTime := ConvertDateTimeString(tmp);
+
+               tmp := ini.ReadString('BoardInformation', 'SETTINGTXTTime', DateTimeToStr(ZERO_DATE));
+               FSETTINGTXTTime := ConvertDateTimeString(tmp);
+               tmp := ini.ReadString('BoardInformation', 'HEADTXTTime', DateTimeToStr(ZERO_DATE));
+               FHEADTXTTime := ConvertDateTimeString(tmp);
+
+               FIsSETTINGTXT := ini.ReadBool('BoardInformation', 'IsSETTINGTXT', false);
+               FIsHEADTXT := ini.ReadBool('BoardInformation', 'IsHEADTXT', false);
+               FTitlePictureURL := ini.ReadString('BoardInformation', 'TitlePictureURL', '');
+
                FUnRead := ini.ReadInteger('Status', 'UnRead', 0);
                FSPID := ini.ReadString('Cookie', 'SPID', '');
                FPON := ini.ReadString('Cookie', 'PON', '');
                FKotehanName := ini.ReadString('Kotehan', 'Name', '');
                FKotehanMail := ini.ReadString('Kotehan', 'Mail', '');
-//             ListStyle := TViewStyle(Ord(ini.ReadInteger('Status', 'ListStyle', 3)));
-//             ItemNoVisible := ini.ReadBool('Status', 'ItemNoVisible', True);
-//             ViewType := TGikoViewType(Ord(ini.ReadInteger('Status', 'ViewType', 0)));
+
                if UnRead < 0 then
                        UnRead := 0;
        finally
@@ -815,8 +1055,11 @@ var
        ini: TMemIniFile;
        FileName: string;
 begin
-       FileName := ParentCategory.ParentBBS2ch.GetLogFolder
-                                               + BBSID + PATH_DELIM;
+       if Length( FilePath ) > 0 then
+               FileName := ExtractFilePath( FilePath )
+       else
+               FileName := GikoSys.Setting.LogFolderP
+                                                       + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM;
        if not GikoSys.DirectoryExistsEx(FileName) then
                GikoSys.ForceDirectoriesEx(FileName);
        FileName := FileName + FOLDER_INI_FILENAME;
@@ -833,6 +1076,13 @@ begin
                ini.WriteString('Cookie', 'PON', FPON);
                ini.WriteString('Kotehan', 'Name', FKotehanName);
                ini.WriteString('Kotehan', 'Mail', FKotehanMail);
+
+               ini.WriteDateTime('BoardInformation', 'SETTINGTXTTime', FSETTINGTXTTime);
+               ini.WriteDateTime('BoardInformation', 'HEADTXTTime', FHEADTXTTime);
+
+               ini.WriteBool('BoardInformation', 'IsSETTINGTXT', FIsSETTINGTXT);
+               ini.WriteBool('BoardInformation', 'IsHEADTXT', FIsHEADTXT);
+               ini.WriteString('BoardInformation', 'TitlePictureURL', FTitlePictureURL);
 //             ini.WriteInteger('Status', 'ListStyle', Ord(ListStyle));
 //             ini.WriteBool('Status', 'ItemNoVisible', ItemNoVisible);
 //             ini.WriteInteger('Status', 'ViewType', Ord(ViewType));
@@ -841,7 +1091,62 @@ begin
                ini.Free;
        end;
 end;
+//\82Æ\82«\82½\82Ü2003 02 08 0:32:13\82±\82ñ\82È\8c`\8e®\82Ì\93ú\95t\82ª\82 \82é\82Ì\82Å\82»\82ê\82ð
+//        2003/02/08 0:32:13\82É\95Ï\8a·\82·\82é
+function       ConvertDateTimeString( inDateTimeString : string) : TDateTime;
+const
+       ZERO_DATE_STRING : string = '1970/01/01 0:00:00';
+var
+       i : Integer;
+    y: Integer;
+    m: Integer;
+    d: Integer;
+    hour: Integer;
+    min: Integer;
+    sec: Integer;
+begin
+    if inDateTimeString = '' then
+       inDateTimeString := ZERO_DATE_STRING;
+
+    if ( AnsiPos('/', inDateTimeString ) = 0 ) and
+       ( AnsiCompareStr( DateTimeToStr(ZERO_DATE), inDateTimeString) <> 0 ) then begin
+               for i := 0 to 1 do begin
+               Insert('/',inDateTimeString, AnsiPos(' ', inDateTimeString) + 1 );
+               Delete(inDateTimeString, AnsiPos(' ', inDateTimeString), 1);
+       end;
+    end;
+    try
+       Result := StrToDateTime( inDateTimeString );
+    except
+       if( inDateTimeString[5] = '/' ) and ( inDateTimeString[8] = '/' ) then begin
+            y := StrToIntDef( Copy(inDateTimeString, 1, 4), 1970 );
+                       m := StrToIntDef( Copy(inDateTimeString, 6, 2), 1 );
+            d := StrToIntDef( Copy(inDateTimeString, 9, 2), 1 );
+            hour := 0; min  := 0; sec  := 0;
+
+               if Length(inDateTimeString) > 11 then begin
+               if( inDateTimeString[13] = ':' ) and ( inDateTimeString[16] = ':' ) then begin
+                       hour := StrToIntDef( Copy(inDateTimeString, 12, 1), 0 );
+                    min  := StrToIntDef( Copy(inDateTimeString, 14, 2), 0 );
+                    sec  := StrToIntDef( Copy(inDateTimeString, 17, 2), 0 );
+                end else if( inDateTimeString[14] = ':' ) and ( inDateTimeString[17] = ':' ) then begin
+                       hour := StrToIntDef( Copy(inDateTimeString, 12, 2), 0 );
+                    min  := StrToIntDef( Copy(inDateTimeString, 15, 2), 0 );
+                    sec  := StrToIntDef( Copy(inDateTimeString, 18, 2), 0 );
+                end;
+            end;
+            try
+               Result := EncodeDateTime(y ,m, d, hour, min, sec, 0);
+            except
+                Result := ZERO_DATE;
+            end;
+        end else
+               Result := ZERO_DATE;
+    end;
+
 
+   // Result := inDateTimeString;
+end;
 // \83T\83u\83W\83F\83N\83gURL\8eæ\93¾
 function TBoard.GetReadCgiURL: string;
 begin
@@ -855,21 +1160,68 @@ 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
 function TBoard.GetSubjectFileName: string;
 begin
-       Result := ParentCategory.ParentBBS2ch.GetLogFolder
-                                       + BBSID + PATH_DELIM + SUBJECT_FILENAME;
+       if Length( FilePath ) > 0 then
+               Result := FilePath
+       else
+               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
 function TBoard.GetFolderIndexFileName: string;
 begin
-       Result := ParentCategory.ParentBBS2ch.GetLogFolder
-                                       + BBSID + PATH_DELIM + FOLDER_INDEX_FILENAME;
+       if Length( FilePath ) > 0 then
+               Result := ExtractFilePath( FilePath ) + FOLDER_INDEX_FILENAME
+       else
+               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¾
+function TBoard.GetSETTINGTXTFileName: string;
+begin
+       if Length( FilePath ) > 0 then
+               Result := ExtractFilePath( FilePath ) + SETTINGTXT_FILENAME
+       else
+               Result := GikoSys.Setting.LogFolderP
+                                               + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SETTINGTXT_FILENAME;
+end;
+
+function TBoard.GETHEADTXTFileName: string;
+begin
+       if Length( FilePath ) > 0 then
+               Result := ExtractFilePath( FilePath ) + HEADTXT_FILENAME
+       else
+               Result := GikoSys.Setting.LogFolderP
+                                               + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + HEADTXT_FILENAME;
+end;
+function TBoard.GetTitlePictureFileName: string;
+var
+       tmpName: string;
+begin
+       if FTitlePictureURL = '' then
+               Result := ''
+       else begin
+               tmpName := Copy(FTitlePictureURL, LastDelimiter('/', FTitlePictureURL) + 1, Length(FTitlePictureURL));
+               if Length( FilePath ) > 0 then
+                       Result := ExtractFilePath( FilePath ) + tmpName
+               else
+                       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) + 'test/subbbs.cgi';
+    Result := GikoSys.UrlToServer(URL);
+    GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
+    if GikoSys.Is2chHost(Host) then
+        Result := Result + 'test/bbs.cgi'
+    else
+        Result := Result + 'test/subbbs.cgi';
+
 end;
 
 procedure TBoard.SetRound(b: Boolean);
@@ -938,23 +1290,23 @@ var
        i: Integer;
 begin
        Result := 0;
-        if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
-        begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival then
-                               inc(Result);
-               end;
-        end else begin
-               for i := 0 to Count - 1 do begin
-                        if Items[i].NewArrival then
-                        begin
-                                if Items[i].ShortTitle = '' then
-                                       Items[i].ShortTitle := GikoSys.ZenToHan(Items[i].Title);
-                                if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
-                                        inc(Result);
-                        end;
-               end;
-        end;
+       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
+       begin
+               for i := 0 to Count - 1 do begin
+                       if Items[i].NewArrival then
+                               inc(Result);
+               end;
+       end else begin
+               for i := 0 to Count - 1 do begin
+                       if Items[i].NewArrival 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;
 end;
 
 function TBoard.GetLogThreadCount: Integer;
@@ -962,23 +1314,23 @@ var
        i: Integer;
 begin
        Result := 0;
-        if Length( ParentCategory.ParentBBS2ch.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 := GikoSys.ZenToHan(Items[i].Title);
-                                if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
-                                        inc(Result);
-                        end;
-               end;
-        end;
+       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;
 end;
 
 function TBoard.GetUserThreadCount: Integer;
@@ -986,15 +1338,15 @@ var
        i: Integer;
 begin
        Result := 0;
-        if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
-                Result := Count
-        else
-       for i := 0 to Count - 1 do begin
-               if Items[i].ShortTitle = '' then
-                       Items[i].ShortTitle := GikoSys.ZenToHan(Items[i].Title);
-               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
-                       inc(Result);
-       end;
+       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;
 end;
 
 function TBoard.GetNewThread(Index: Integer): TThreadItem;
@@ -1004,34 +1356,34 @@ var
 begin
        Result := nil;
        Cnt := 0;
-        if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
-        begin
-               for i := 0 to Count - 1 do begin
-                       if Items[i].NewArrival 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].NewArrival then
-                        begin
-                               if Items[i].ShortTitle = '' then
-                                       Items[i].ShortTitle := GikoSys.ZenToHan(Items[i].Title);
-                               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
-                                       if Index = Cnt then begin
-                                               Result := Items[i];
-                                               Exit;
-                                       end;
-                                       inc(Cnt);
-                                end;
-                        end;
-               end;
-        end;
+       if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
+       begin
+               for i := 0 to Count - 1 do begin
+                       if Items[i].NewArrival 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].NewArrival 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 begin
+                                       if Index = Cnt then begin
+                                               Result := Items[i];
+                                               Exit;
+                                       end;
+                                       inc(Cnt);
+                               end;
+                       end;
+               end;
+       end;
 end;
 
 function TBoard.GetLogThread(Index: Integer): TThreadItem;
@@ -1039,34 +1391,36 @@ var
        i: Integer;
        Cnt: Integer;
 begin
-        if Length( ParentCategory.ParentBBS2ch.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 := GikoSys.ZenToHan(Items[i].Title);
-                               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
-                                       if Index = Cnt then begin
-                                               Result := Items[i];
-                                               Exit;
-                                       end;
-                                       inc(Cnt);
-                                end;
-                        end;
-               end;
-        end;
+       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;
 end;
 
 function TBoard.GetUserThread(Index: Integer): TThreadItem;
@@ -1076,29 +1430,29 @@ var
 begin
        Result := nil;
        Cnt := 0;
-        if Length( ParentCategory.ParentBBS2ch.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 := GikoSys.ZenToHan(Items[i].Title);
-                       if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
-                               if Index = Cnt then begin
-                                       Result := Items[i];
-                                       Exit;
-                               end;
-                               inc(Cnt);
-                       end;
-               end;
-        end;
+       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;
 end;
 
 procedure TBoard.BeginUpdate;
@@ -1122,7 +1476,7 @@ begin
 end;}
 
 //constructor TThreadItem.Create(AOwner: TComponent);
-constructor TThreadItem.Create;
+procedure TThreadItem.Init;
 begin
        FNo := 0;
        FFileName := '';
@@ -1141,11 +1495,126 @@ begin
        FNewArrival := False;
 
        FUpdate := True;
+       FURL := '';
+       FBoardPlugIn := nil;
+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
+);
+var
+       foundPos                        : Integer;
+       protocol, host, path, document, port, bookmark  : string;
+       BBSID, BBSKey   : string;
+const
+       READ_PATH                                                       = '/test/read.cgi';
+begin
+
+       inherited Create;
+       Init;
+
+       FBoardPlugIn    := inPlugIn;
+       URL                                             := inURL;
+
+       if inPlugIn = nil then begin
+               foundPos := Pos( READ_PATH, inURL );
+               if foundPos > 0 then 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 :=
+                                       GikoSys.Setting.LogFolderP +
+                                       BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat'
+                       else
+                               FilePath :=
+                                       GikoSys.Setting.LogFolderP +
+                                       EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + BBSKey + '.dat';
+                       FileName        := BBSKey + '.dat';
+                       IsLogFile       := FileExists( FilePath );
+                       URL                             := GikoSys.Get2chBrowsableThreadURL( inURL );
+               end;
+       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;
 
+// *************************************************************************
+// \83v\83\89\83O\83C\83\93\82ð\97\98\97p\82µ\82È\82¢\83R\83\93\83X\83g\83\89\83N\83^
+// *************************************************************************
+constructor TThreadItem.Create(
+       is2ch : Boolean;
+    const inURL, inHost, inBBSID, inBBSKey : string
+);
+var
+       foundPos                        : Integer;
+const
+       READ_PATH                                                       = '/test/read.cgi';
+begin
+
+       inherited Create;
+       Init;
+
+       FBoardPlugIn    := nil;
+
+    foundPos := Pos( READ_PATH, inURL );
+    if foundPos > 0 then begin
+        // dat \82Ì\95Û\91\83p\83X\82ð\90Ý\92è
+        if is2ch then
+            FilePath :=
+
+                GikoSys.Setting.LogFolderP +
+                BBS2CH_LOG_FOLDER + PATH_DELIM + inBBSID + PATH_DELIM + inBBSKey + '.dat'
+        else
+            FilePath :=
+                GikoSys.Setting.LogFolderP +
+                EXTERNAL_LOG_FOLDER + PATH_DELIM + inHost + PATH_DELIM + inBBSID + PATH_DELIM + inBBSKey + '.dat';
+        FileName       := inBBSKey + '.dat';
+        IsLogFile      := FileExists( FilePath );
+        URL                            := GikoSys.Get2chBrowsableThreadURL( inURL );
+    end else
+       URL                             := inURL;
+
+end;
+// *************************************************************************
+// \83f\83X\83g\83\89\83N\83^
+// *************************************************************************
 destructor TThreadItem.Destroy;
 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;
+
+end;
+
+// *************************************************************************
+// \8aO\95\94\94Â\83v\83\89\83O\83C\83\93\82ª\8eg\97p\89Â\94\\82©
+// *************************************************************************
+function       TThreadItem.IsBoardPlugInAvailable : Boolean;
+begin
+
+       repeat
+               if BoardPlugIn = nil then
+                       Break;
+
+               if not Assigned( Pointer( BoardPlugIn.Module ) ) then
+                       Break;
+
+               Result := True;
+               Exit;
+       until True;
+
+       Result := False;
+
 end;
 
 function TThreadItem.GetDatURL: string;
@@ -1229,7 +1698,7 @@ begin
        end;
 end;}
 
-function TThreadItem.GetOfflawCgiURL(SessionID: string): string;
+function TThreadItem.GetOfflawCgiURL(const SessionID: string): string;
 //var
 //     Protocol, Host, Path, Document, Port, Bookmark: string;
 begin
@@ -1261,8 +1730,13 @@ end;
 
 procedure TThreadItem.DeleteLogFile;
 begin
-       DeleteFile(GetThreadFileName);
+       ParentBoard.BeginUpdate;
 
+       if FUnRead then
+               ParentBoard.UnRead := ParentBoard.UnRead - 1;
+       DeleteFile(GetThreadFileName);
+       if FileExists(ChangeFileExt(GetThreadFileName,'.NG')) = true then
+               DeleteFile(ChangeFileExt(GetThreadFileName,'.NG'));
        FRoundDate := ZERO_DATE;
        FLastModified := ZERO_DATE;
        FSize := 0;
@@ -1279,12 +1753,18 @@ begin
        FCount := 0;
        FNewResCount := 0;
        FRoundName := '';
+
+       ParentBoard.EndUpdate;
+       ParentBoard.Modified := True;
 end;
 
 function TThreadItem.GetThreadFileName: string;
 begin
-       Result := ParentBoard.ParentCategory.ParentBBS2ch.GetLogFolder
-                                       + ParentBoard.BBSID + PATH_DELIM + FileName;
+       if Length( FilePath ) > 0 then
+               Result := FilePath
+       else
+               Result := GikoSys.Setting.LogFolderP
+                                               + BBS2CH_LOG_FOLDER + PATH_DELIM + ParentBoard.BBSID + PATH_DELIM + FileName;
 end;
 
 procedure TThreadItem.SetLastModified(d: TDateTime);
@@ -1315,7 +1795,7 @@ begin
                ParentBoard.FModified := True;
 end;
 
-procedure TThreadItem.SetRoundName(s: string);
+procedure TThreadItem.SetRoundName(const s: string);
 begin
        if FRoundName = s then Exit;
        FRoundName := s;
@@ -1358,10 +1838,45 @@ begin
 end;
 
 {initialization
-       BBS2ch := TBBS2ch.Create;
+       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
+               if ( GikoSys.Setting.CreationTimeLogs ) and not IsLogFile  then
+            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;
+                       if GikoSys.Setting.FutureThread then begin
+                       if CompareDateTime(Result, Now) = 1 then
+                       Result := ZERO_DATE;
+               end;
+        end;
+
+       except
+               on E: Exception do
+                       Result := ZERO_DATE;
+       end;
+end;
+
 end.