OSDN Git Service

・TThreadItem の作成時に IsLogFile が設定されるようになった。
[gikonavigoeson/gikonavi.git] / BoardGroup.pas
index 149fef7..1db76d2 100644 (file)
@@ -4,7 +4,7 @@ interface
 
 uses
        Windows, SysUtils, Classes, ComCtrls, IniFiles, {HTTPApp,} YofUtils, IdGlobal,
-       ExternalBoardManager;
+       ExternalBoardManager, ExternalBoardPlugInMain;
 
 type
        //\83\8a\83X\83g\82Ì\95\\8e¦\83A\83C\83e\83\80\91I\91ð
@@ -47,7 +47,7 @@ type
 }
 
 {
-       TBBS2ch = class(TBBS)
+       TBBS = class(TBBS)
        end;
        TBoard2ch = class(TBoard)
        end;
@@ -71,7 +71,7 @@ type
        TThreadItem = class;
 
        //\82Æ\82è\82 \82¦\82¸\82Q\82¿\82á\82ñ\82Ë\82é\82Ì\83\8b\81[\83g
-       TBBS2ch = class(TList)
+       TBBS = class(TList)
        private
                FTitle: string;
                FLogFolder: string;
@@ -87,10 +87,6 @@ type
                constructor Create(LogFolder: string);
                destructor Destroy; override;
 
-               procedure ReadBoardFile;
-
-               function GetBoardFromBBSID(BBSID: string): TBoard;
-
                function Add(item: TCategory): integer;
                procedure Delete(index: integer);
                procedure Clear; override;
@@ -98,13 +94,14 @@ type
                function FindBBSID(BBSID: string): TBoard;
                function FindBoardFromTitle(Title: string): TBoard;
                function FindBoardFromURL(inURL: string): TBoard;
+               function FindThreadFromURL( inURL : string ) : TThreadItem;
                function FindThreadItem(BBSID: string; FileName: string): TThreadItem;
                function GetLogFolder: string;
 
                property Items[index: integer]: TCategory read GetCategory write SetCategory;
                property Title: string read FTitle write FTitle;
                property NodeExpand: Boolean read FExpand write FExpand;
-
+                                                                                
                property KubetsuChk: Boolean read FKubetsuChk write FKubetsuChk;
                property SelectText: string read FSelectText write SetSelectText;
                property ShortSelectText: string read FShortSelectText write FShortSelectText;
@@ -115,7 +112,7 @@ type
        private
                FNo: Integer;
                FTitle: string;
-               FParentBBS2ch: TBBS2ch;
+               FParenTBBS: TBBS;
                FExpand: Boolean;
 
                function GetBoard(index: integer): TBoard;
@@ -127,7 +124,7 @@ 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);
@@ -136,6 +133,7 @@ type
                function FindBBSID(BBSID: string): TBoard;
                function FindBoardFromTitle(Title: string): TBoard;
                function FindBoardFromURL(inURL: string): TBoard;
+               function FindThreadFromURL( inURL : string ) : TThreadItem;
                function IsMidoku: Boolean;
 
                property NodeExpand: Boolean read FExpand write FExpand;
@@ -183,9 +181,9 @@ type
                procedure SetUnRead(i: Integer);
                procedure SetKotehanName(s: string);
                procedure SetKotehanMail(s: string);
+               procedure Create; overload;
        public
-               constructor Create; overload;
-               constructor Create( inPlugIn : TBoardPlugIn; inURL : string = '' ); overload;
+               constructor Create( inPlugIn : TBoardPlugIn; inURL : string ); overload;
                destructor Destroy; override;
 
                property Context: DWORD read FContext write FContext;
@@ -218,6 +216,7 @@ type
                procedure DeleteList(index: integer);
                procedure Clear; override;
                function Find(ItemFileName: string): TThreadItem;
+               function FindThreadFromURL( inURL : string ) : TThreadItem;
                function GetIndex(ItemFileName: string): Integer;
                function GetIndexFromURL(URL: string): Integer;
                procedure LoadSettings;
@@ -285,10 +284,9 @@ type
                procedure SetKokomade(i: Integer);
                procedure SetUnRead(b: Boolean);
                procedure SetScrollTop(i: Integer);
-               function GetURLWrapper: string;
+               procedure Create; overload;
        public
-               constructor Create; overload;
-               constructor Create( inPlugIn : TBoardPlugIn; inURL : string = '' ); overload;
+               constructor Create( inPlugIn : TBoardPlugIn; inURL : string ); overload;
                destructor Destroy; override;
 
                function GetDatURL: string;
@@ -328,7 +326,7 @@ type
                property AgeSage: TGikoAgeSage read FAgeSage write FAgeSage;
 //             property SPID: string read FSPID write FSPID;
 
-               property        URL                                     : string                                read GetURLWrapper write FURL;
+               property        URL                                     : string                                read FURL write FURL;
                property        BoardPlugIn     : TBoardPlugIn  read FBoardPlugIn;
                property        FilePath                : string                                read FFilePath write FFilePath;
                property        SizeByte                : Integer                               read FSizeByte write FSizeByte;
@@ -353,8 +351,13 @@ type
                procedure Clear; override;
        end;}
 
+       function        BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard;
+       function        BBSsFindBoardFromURL( inURL : string ) : TBoard;
+       function        BBSsFindBoardFromTitle( inTitle : string ) : TBoard;
+       function        BBSsFindThreadFromURL( inURL : string ) : TThreadItem;
+
 var
-       BBS2ch: TBBS2ch;
+       BBSs            : array of TBBS;
 
 implementation
 
@@ -364,6 +367,7 @@ uses
 const
        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';
@@ -375,11 +379,79 @@ const
 //     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');
 
+function       BBSsFindBoardFromBBSID(
+       inBBSID : string
+) : TBoard;
+var
+       i                               : Integer;
+begin
+
+       for i := Length( BBSs ) - 1 downto 0 do begin
+               Result := BBSs[ i ].FindBBSID( inBBSID );
+               if Result <> nil then
+                       Exit;
+       end;
+
+       Result := nil;
+
+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(
+       inURL   : string
+) : TThreadItem;
+var
+       i                       : Integer;
+begin
+
+       for i := Length( BBSs ) - 1 downto 0 do begin
+               Result := BBSs[ i ].FindThreadFromURL( inURL );
+               if Result <> nil then
+                       Exit;
+       end;
+
+       Result := nil;
+
+end;
+
 (*************************************************************************
  *\8b@\94\\96¼\81FTBBS\83R\83\93\83X\83g\83\89\83N\83^
  *Public
  *************************************************************************)
-constructor TBBS2ch.Create(LogFolder: string);
+constructor TBBS.Create(LogFolder: string);
 begin
        Title := BBS2CH_NAME;
        FLogFolder := LogFolder;
@@ -389,7 +461,7 @@ end;
  *\8b@\94\\96¼\81FTBBS\83f\83X\83g\83\89\83N\83^
  *Public
  *************************************************************************)
-destructor TBBS2ch.Destroy;
+destructor TBBS.Destroy;
 begin
        Clear;
        inherited;
@@ -399,23 +471,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;
@@ -423,7 +495,7 @@ begin
        inherited Delete(index);
 end;
 
-procedure TBBS2ch.Clear;
+procedure TBBS.Clear;
 var
        i: integer;
 begin
@@ -431,281 +503,101 @@ begin
                Delete(i);
 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(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;
+       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(Title: string): TBoard;
 var
        i: Integer;
-       Category: TCategory;
-       Board: TBoard;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               Category := Items[i];
-               Board := Category.FindBoardFromTitle(Title);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromTitle(Title);
+               if Result <> nil then
                        Exit;
-               end;
        end;
+       Result := nil;
 end;
 
-function TBBS2ch.FindBoardFromURL(inURL: string): TBoard;
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\94Â\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindBoardFromURL(inURL: 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.FindBoardFromURL(inURL);
-               if Board <> nil then begin
-                       Result := Board;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindBoardFromURL( inURL );
+               if Result <> nil then
                        Exit;
-               end;
        end;
-end;
-
-function TBBS2ch.FindThreadItem(BBSID: string; FileName: string): TThreadItem;
-var
-       Board: TBoard;
-begin
        Result := nil;
-       Board := FindBBSID(BBSID);
-       if Board = nil then
-               Exit;
-       Result := Board.Find(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;
-type
-       // \8dÅ\8f\89\82Ì\88ê\82Â(\93Y\82¦\8e\9a 0)\82ª BBS \96¼\82Å\81A\82»\82Ì\8cã\82É\83J\83e\83S\83\8a\82ª\91±\82­
-       TCategories = array of TCategory;
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\83X\83\8c\83b\83h\82ð\92T\82·
+//*************************************************************************)
+function TBBS.FindThreadFromURL(inURL: string): TThreadItem;
 var
-       i, j, k: integer;
-       jbound, kbound: Integer;
-       idx: Integer;
-       ini: TMemIniFile;
-       CategoryList: TStringList;
-       BoardList: TStringList;
-       Category: TCategory;
-       Board: TBoard;
-       inistr: string;
-       RoundItem: TRoundItem;
-       BBSList: TStringList;
-       CustomList: TStringList;
-       BoardFileList: TStringList;
-
-       plugInBBSs                              : array of TCategories;
-       plugInCategories        : TCategories;
-       agent                           : string;
-       major                           : DWORD;
-       minor                           : DWORD;
-       release                 : string;
-       revision                : DWORD;
-       plugInIndex     : Integer;
-const
-       BBS_NAME_SIGNATURE = #$1B;      // \90â\91Î\82É\94Â\96¼\82Æ\82µ\82Ä\82 \82è\93¾\82È\82¢\8bL\8d\86\82ð\8eg\82¤
+       i       : Integer;
 begin
-       ini := TMemIniFile.Create('');
-       BBSList := TStringList.Create;
-       CustomList := TStringList.Create;
-       BoardFileList := TStringList.Create;
-       try
-               // \94Â\83\8a\83X\83g\82Ì\93Ç\82Ý\8d\9e\82Ý
-               // \81¦\96{\93\96\82Í TBBS2ch \82ð\8cf\8e¦\94Â\82Ì\90\94\82¾\82¯\90\90¬\82·\82é\82×\82«\82¾\82ª
-               // \81@\8dÅ\8f\89\82©\82ç BBS2ch \82ª 1 \82Â\91O\92ñ\82Å\8dì\82ç\82ê\82Ä\82¢\82é\82½\82ß\81A
-               // \81@\83v\83\89\83O\83C\83\93\82ª\95Ï\82í\82é\82²\82Æ\82É\83_\83~\81[\82Ì TCategory \82ð\8b²\82ñ\82Å\91Î\8f\88\82·\82é
-
-               // \82Q\82¿\82á\82ñ\82Ë\82é
-               if FileExists(GikoSys.GetBoardFileName) then
-                       BBSList.LoadFromFile(GikoSys.GetBoardFileName);
-               // \83J\83X\83^\83\80
-               if FileExists(GikoSys.GetCustomBoardFileName) then
-                       CustomList.LoadFromFile(GikoSys.GetCustomBoardFileName);
-               BBSList.AddStrings(CustomList);
-               // Board \83t\83H\83\8b\83_
-               if DirectoryExists(GikoSys.Setting.GetBoardDir) then begin
-                       GikoSys.GetFileList( GikoSys.Setting.GetBoardDir, '*', BoardFileList, True, True );
-                       for i := BoardFileList.Count - 1 downto 0 do begin
-                               CustomList.Clear;
-                               CustomList.LoadFromFile( BoardFileList[ i ] );
-                               BBSList.AddStrings( CustomList );
-                       end;
-               end;
-               ini.SetStrings(BBSList);
-
-               // \83v\83\89\83O\83C\83\93\97p\82Ì\83_\83~\81[\83J\83e\83S\83\8a\82ð\90\90¬
-               try
-                       k                               := Low( BoardPlugIns );
-                       kbound  := High( BoardPlugIns );
-                       SetLength(
-                               plugInBBSs,
-                               Max( 0, kbound - k + 1 ) );
-                       for k := k to kbound do begin
-                               SetLength( plugInBBSs[ k ], 1 );
-                               if Assigned( Pointer( BoardPlugIns[ k ].Module ) ) then begin
-                                       // BBS \96¼\82Ì\91ã\82í\82è\82É\82Æ\82è\82 \82¦\82¸\83v\83\89\83O\83C\83\93\96¼\82ð\93ü\82ê\82Ä\82¨\82­
-                                       // \81¦\8d¡\8cã BBS \96¼\82ð\93ü\82ê\82é\82æ\82¤\82É\89ü\97Ç\82·\82é\82±\82Æ
-                                       plugInBBSs[ k ][ 0 ] := TCategory.Create;
-                                       BoardPlugIns[ k ].VersionInfo( agent, major, minor, release, revision );
-                                       plugInBBSs[ k ][ 0 ].Title      := BBS_NAME_SIGNATURE + agent;
-                               end;
-                       end;
-               except
-               end;
-
-               // \82Q\82¿\82á\82ñ\82Ë\82é\82ð\92Ç\89Á
-               Category := TCategory.Create;
-               Category.Title := BBS_NAME_SIGNATURE + '\82Q\82¿\82á\82ñ\82Ë\82é';
-                BBS2ch.Add( Category );
-
-               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];
-                               plugInIndex := -1;
-
-                               for j := 0 to BoardList.Count - 1 do begin
-                                       Board := nil;
-                                       inistr := ini.ReadString(CategoryList[i], BoardList[j], '');
-
-                                       //===== \83v\83\89\83O\83C\83\93
-                                       try
-                                               kbound := High( BoardPlugIns );
-                                               for k := Low( BoardPlugIns ) to kbound do begin
-                                                       if Assigned( Pointer( BoardPlugIns[ k ].Module ) ) then begin
-                                                               if BoardPlugIns[ k ].AcceptURL( inistr ) then begin
-                                                                       Board := TBoard.Create( BoardPlugIns[ k ], inistr );
-                                                                       plugInIndex := k;
-
-                                                                       Break;
-                                                               end;
-                                                       end;
-                                               end;
-                                       except
-                                               // exception \82ª\94­\90\82µ\82½\8fê\8d\87\82Í\93à\95\94\8f\88\97\9d\82É\94C\82¹\82½\82¢\82Ì\82Å\82±\82±\82Å\82Í\89½\82à\82µ\82È\82¢
-                                       end;
-
-                                       if Board = nil then begin
-                                               Board := TBoard.Create;
-                                               Board.URL := inistr;
-                                       end;
-                                       Board.BeginUpdate;
-                                       Board.No := j + 1;
-                                       Board.Title := BoardList[j];
-                                       Board.BBSID := GikoSys.UrlToID(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;
-                               if plugInIndex >= 0 then begin
-                                       k := High( plugInBBSs[ plugInIndex ] ) + 1;
-                                       SetLength( plugInBBSs[ plugInIndex ], k + 1 );
-                                       plugInBBSs[ plugInIndex ][ k ] := Category;
-                               end else begin
-                                       BBS2ch.Add(Category);
-                               end;
-                       end;
-               finally
-                       BoardList.Free;
-                       CategoryList.Free;
-               end;
-
-               // \83v\83\89\83O\83C\83\93\97p\82Ì\83_\83~\81[\83J\83e\83S\83\8a\82ð\96\96\94ö\82É\92Ç\89Á
-               try
-                       k                               := Low( plugInBBSs );
-                       kbound  := High( plugInBBSs );
-                       for k := k to kbound do begin
-                               j                               := Low( plugInBBSs[ k ] );
-                               jbound  := High( plugInBBSs[ k ] );
-                               for j := j to jbound do begin
-                                       BBS2ch.Add( plugInBBSs[ k ][ j ] );
-                               end;
-                       end;
-               except
-               end;
-       finally
-               BBSList.Free;
-               CustomList.Free;
-               BoardFileList.Free;
-               ini.Free;
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindThreadFromURL( inURL );
+               if Result <> nil then
+                       Exit;
        end;
+       Result := nil;
 end;
 
-function TBBS2ch.GetBoardFromBBSID(BBSID: string): TBoard;
+function TBBS.FindThreadItem(BBSID: string; FileName: string): TThreadItem;
 var
-       i: integer;
+       Board: TBoard;
 begin
        Result := nil;
-       for i := 0 to BBS2ch.Count - 1 do begin
-               Result := BBS2ch.Items[i].FindBBSID(BBSID);
-               if Result <> nil then
-                       Exit;
-       end;
+       Board := FindBBSID(BBSID);
+       if Board = nil then
+               Exit;
+       Result := Board.Find(FileName);
 end;
 
 (*************************************************************************
  *\83\8d\83O\83t\83H\83\8b\83_\8eæ\93¾
  *
  *************************************************************************)
-function TBBS2ch.GetLogFolder: string;
+function TBBS.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);
 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;}
@@ -762,41 +654,64 @@ end;
 
 function TCategory.FindBBSID(BBSID: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FBBSID = BBSID then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
 end;
 
+//*************************************************************************
+// \83^\83C\83g\83\8b\82Ì\88ê\92v\82·\82é\94Â\82ð\92T\82·
+//*************************************************************************)
 function TCategory.FindBoardFromTitle(Title: string): TBoard;
 var
-       i: integer;
+       i       : integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
+       for i := Count - 1 downto 0 do begin
                if Items[i].FTitle = Title 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(inURL: string): TBoard;
 var
-       i: integer;
+       i       : Integer;
 begin
-       Result := nil;
-       for i := 0 to Count - 1 do begin
-               if Items[i].URL = inURL then begin
+       for i := Count - 1 downto 0 do begin
+               if Pos( Items[i].URL, inURL ) = 1 then begin
                        Result := Items[i];
                        Exit;
                end;
        end;
+       Result := nil;
+end;
+
+//*************************************************************************
+// URL \82ð\8eó\82¯\95t\82¯\82é\83X\83\8c\83b\83h\82ð\92T\82·
+//*************************************************************************)
+function TCategory.FindThreadFromURL(inURL: string): TThreadItem;
+var
+       i                                               : Integer;
+begin
+
+       for i := Count - 1 downto 0 do begin
+               Result := Items[ i ].FindThreadFromURL( inURL );
+               if Result <> nil then
+                       Exit;
+       end;
+       Result := nil;
+
 end;
 
 function TCategory.IsMidoku: Boolean;
@@ -833,7 +748,7 @@ end;}
 //===================
 //TBoard
 //===================
-constructor TBoard.Create;
+procedure TBoard.Create;
 begin
        FNo := 0;
        FTitle := '';
@@ -858,17 +773,34 @@ end;
 // *************************************************************************
 constructor TBoard.Create(
        inPlugIn        : TBoardPlugIn;
-       inURL                   : string = ''
+       inURL                   : string
 );
+var
+       protocol, host, path, document, port, bookmark  : string;
+       BBSID                   : string;
 begin
 
        Create;
 
        FBoardPlugIn    := inPlugIn;
        URL                                             := inURL;
+       BBSID                                   := GikoSys.UrlToID( inURL );
 
        // \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 ) );
+       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 :=
+                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+               else
+                       FilePath :=
+                               IncludeTrailingPathDelimiter( GikoSys.Setting.LogFolder ) +
+                               EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME
+       end else begin
+               inPlugIn.CreateBoardItem( DWORD( Self ) );
+       end;
 
 end;
 
@@ -996,6 +928,24 @@ begin
        end;
 end;
 
+function TBoard.FindThreadFromURL( inURL : string ) : TThreadItem;
+var
+       i : Integer;
+begin
+
+       if not IsThreadDatRead then
+               GikoSys.ReadSubjectFile( Self );
+               
+       for i := Count - 1 downto 0 do begin
+               if Pos( Items[ i ].URL, inURL ) = 1 then begin
+                       Result := Items[ i ];
+                       Exit;
+               end;
+       end;
+       Result := nil;
+
+end;
+
 {function TBoard.GetMidokuCount: Integer;
 var
        i: integer;
@@ -1018,7 +968,7 @@ begin
        if Length( FilePath ) > 0 then
                FileName := ExtractFilePath( FilePath ) + FOLDER_INI_FILENAME
        else
-               FileName := ParentCategory.ParentBBS2ch.GetLogFolder
+               FileName := ParentCategory.ParenTBBS.GetLogFolder
                                                        + BBSID + PATH_DELIM + FOLDER_INI_FILENAME;
 
        if not FileExists(FileName) then
@@ -1052,7 +1002,7 @@ begin
        if Length( FilePath ) > 0 then
                FileName := ExtractFilePath( FilePath )
        else
-               FileName := ParentCategory.ParentBBS2ch.GetLogFolder
+               FileName := ParentCategory.ParenTBBS.GetLogFolder
                                                        + BBSID + PATH_DELIM;
        if not GikoSys.DirectoryExistsEx(FileName) then
                GikoSys.ForceDirectoriesEx(FileName);
@@ -1095,7 +1045,7 @@ begin
        if Length( FilePath ) > 0 then
                Result := FilePath
        else
-               Result := ParentCategory.ParentBBS2ch.GetLogFolder
+               Result := ParentCategory.ParenTBBS.GetLogFolder
                                                + BBSID + PATH_DELIM + SUBJECT_FILENAME;
 end;
 
@@ -1105,7 +1055,7 @@ begin
        if Length( FilePath ) > 0 then
                Result := ExtractFilePath( FilePath ) + FOLDER_INDEX_FILENAME
        else
-               Result := ParentCategory.ParentBBS2ch.GetLogFolder
+               Result := ParentCategory.ParenTBBS.GetLogFolder
                                                + BBSID + PATH_DELIM + FOLDER_INDEX_FILENAME;
 end;
 
@@ -1181,7 +1131,7 @@ var
        i: Integer;
 begin
        Result := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
                                begin
                                        for i := 0 to Count - 1 do begin
                                                if Items[i].NewArrival then
@@ -1193,7 +1143,7 @@ begin
                                                                                                begin
                                                                                                                                if Items[i].ShortTitle = '' then
                                                                                        Items[i].ShortTitle := GikoSys.ZenToHan(Items[i].Title);
-                                                                                                                               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
+                                                                                                                               if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then
                                                                                                                                                                inc(Result);
                                                                                                end;
                                        end;
@@ -1205,7 +1155,7 @@ var
        i: Integer;
 begin
        Result := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
                                begin
                                        for i := 0 to Count - 1 do begin
                                                if Items[i].IsLogFile then
@@ -1217,7 +1167,7 @@ begin
                                                                                                begin
                                                                                                                                if Items[i].ShortTitle = '' then
                                                                                        Items[i].ShortTitle := GikoSys.ZenToHan(Items[i].Title);
-                                                                                                                               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
+                                                                                                                               if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then
                                                                                                                                                                inc(Result);
                                                                                                end;
                                        end;
@@ -1229,13 +1179,13 @@ var
        i: Integer;
 begin
        Result := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               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 := GikoSys.ZenToHan(Items[i].Title);
-               if AnsiPos(ParentCategory.ParentBBS2ch.ShortSelectText, Items[i].ShortTitle) <> 0 then
+               if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then
                        inc(Result);
        end;
 end;
@@ -1247,7 +1197,7 @@ var
 begin
        Result := nil;
        Cnt := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
                                begin
                                        for i := 0 to Count - 1 do begin
                                                if Items[i].NewArrival then
@@ -1265,7 +1215,7 @@ begin
                                                                                                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 AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
                                                                                        if Index = Cnt then begin
                                                                                                Result := Items[i];
                                                                                                Exit;
@@ -1283,7 +1233,7 @@ var
        Cnt: Integer;
 begin
                                Cnt := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
                                begin
                                        for i := 0 to Count - 1 do begin
                                                if Items[i].IsLogFile then
@@ -1301,7 +1251,7 @@ begin
                                                                                                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 AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
                                                                                        if Index = Cnt then begin
                                                                                                Result := Items[i];
                                                                                                Exit;
@@ -1321,7 +1271,7 @@ var
 begin
        Result := nil;
        Cnt := 0;
-                               if Length( ParentCategory.ParentBBS2ch.ShortSelectText ) = 0 then
+                               if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then
                                begin
                                                                for i := 0 to Count - 1 do begin
                                                                                                if Index = Cnt then
@@ -1335,7 +1285,7 @@ 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 AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin
                                                        if Index = Cnt then begin
                                                                Result := Items[i];
                                                                Exit;
@@ -1367,7 +1317,7 @@ begin
 end;}
 
 //constructor TThreadItem.Create(AOwner: TComponent);
-constructor TThreadItem.Create;
+procedure TThreadItem.Create;
 begin
        FNo := 0;
        FFileName := '';
@@ -1395,8 +1345,14 @@ end;
 // *************************************************************************
 constructor TThreadItem.Create(
        inPlugIn        : TBoardPlugIn;
-       inURL                   : string = ''
+       inURL                   : string
 );
+var
+       foundPos                        : Integer;
+       protocol, host, path, document, port, bookmark  : string;
+       BBSID, BBSKey   : string;
+const
+       READ_PATH                                                       = '/test/read.cgi';
 begin
 
        Create;
@@ -1404,8 +1360,27 @@ begin
        FBoardPlugIn    := inPlugIn;
        URL                                             := inURL;
 
-       // \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 ) );
+       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 :=
+                                       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 );
+               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;
 
@@ -1583,7 +1558,7 @@ begin
        if Length( FilePath ) > 0 then
                Result := FilePath
        else
-               Result := ParentBoard.ParentCategory.ParentBBS2ch.GetLogFolder
+               Result := ParentBoard.ParentCategory.ParenTBBS.GetLogFolder
                                                + ParentBoard.BBSID + PATH_DELIM + FileName;
 end;
 
@@ -1657,18 +1632,8 @@ begin
        FUpdate := True;
 end;
 
-function TThreadItem.GetURLWrapper: string;
-begin
-
-       If FURL = '' Then
-               Result := GikoSys.GetURL( ParentBoard.BBSID, FileName )
-       Else
-               Result := FURL;
-
-end;
-
 {initialization
-       BBS2ch := TBBS2ch.Create;
+       BBS2ch := TBBS.Create;
 
 finalization
        if BBS2ch <> nil then