X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=BoardGroup.pas;h=752daa0679c74d12b4cb7a4b16dd48451cb658e3;hb=46822cbb30a2bc643fdb53335c4f6af85c878421;hp=80a3a4bc6ea8cc193b6f66ae382ce0fbcd9415dd;hpb=9e4b0cdc98b41876ecc332c59e5054b754eb56ef;p=gikonavigoeson%2Fgikonavi.git diff --git a/BoardGroup.pas b/BoardGroup.pas index 80a3a4b..752daa0 100644 --- a/BoardGroup.pas +++ b/BoardGroup.pas @@ -3,73 +3,20 @@ unit BoardGroup; interface uses - Windows, SysUtils, Classes, ComCtrls, IniFiles, {HTTPApp,} YofUtils, IdGlobal, - ExternalBoardManager, ExternalBoardPlugInMain, StrUtils, DateUtils; + Windows, SysUtils, Classes, ComCtrls, {HTTPApp,} YofUtils, IdGlobal, + ExternalBoardManager, ExternalBoardPlugInMain, StrUtils; type //ƒŠƒXƒg‚Ì•\Ž¦ƒAƒCƒeƒ€‘I‘ð - TGikoViewType = (gvtAll, gvtLog, gvtNew, gvtUser); - //ƒŠƒXƒg‚̎擾Œ” - //TGikoListCount = (glc50, glc100, glc200, glc500, glc1000, glcAll); - //„‰ñ”ԍ† - //TGikoRoundNo = (grnNone, grn1, grn2, grn3, grn4, grn5, grnOnce); + TGikoViewType = (gvtAll, gvtLog, gvtNew, gvtLive, gvtArch, gvtUser); //ƒŠƒXƒg‚̏グ‰º‚° - TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew, gasNull); - -{ TFolder = class - private - FItemList: TList; //ŽqƒAƒCƒeƒ€ƒŠƒXƒg - FLeaf: Boolean; //‰º‚ɃtƒHƒ‹ƒ_‚ðŽ‚Â‚±‚Æ‚ªo—ˆ‚é‚© - public - function Add(Item: TFolder): Integer; - procedure Clear; - procedure Delete(Index: Integer); - procedure Exchange(Index1, Index2: Integer); - procedure Insert(Index: Integer; Item: TFolder); - procedure Move(CurIndex, NewIndex: Integer); - function Remove(Item: TFolder): Integer; - procedure Sort(Compare: TListSortCompare); - property Capacity: Integer read FCapacity write SetCapacity; - property Count: Integer read FCount write SetCount; - property Items[Index: Integer]: TFolder read Get write Put; default; - - property Leaf: Boolean read FLeaf; - end; - - TBBS = class(TFolder) - end; - TCategory class(TFolder) - end; - TBoard = class(TFolder) - end; - TThreadItem = class(TFolder) - end; -} - -{ - TBBS = class(TBBS) - end; - TBoard2ch = class(TBoard) - end; - TThreadItem2ch = class(TThreadItem) - end; -} - -// ITest = interface -// end; -// IBBS = interface -// end; -// ICategory = interface -// end; -// IBoard = interface -// end; -// IThreadItem = interface -// end; + TGikoAgeSage = (gasNone, gasAge, gasSage, gasNew, gasArch, gasNull); TCategory = class; TBoard = class; TThreadItem = class; + // BBS ‚̃‹[ƒg TBBS = class(TList) private @@ -112,7 +59,6 @@ type end; // ƒJƒeƒSƒŠ(” URL ‚̃ŠƒXƒg) -// TCategory = class(THashedStringList) TCategory = class(TStringList) private FNo: Integer; @@ -144,8 +90,10 @@ type property NodeExpand: Boolean read FExpand write FExpand; end; + //! ƒXƒŒƒbƒh”ƒJƒEƒ“ƒgðŒ•¶ + TThreadCount = function(Item : TThreadItem): Boolean; + // ”Â(ƒXƒŒƒbƒh URL ‚̃ŠƒXƒg) -// TBoard = class(THashedStringList) TBoard = class(TStringList) private FContext: DWORD; // ƒvƒ‰ƒOƒCƒ“‚ªŽ©—R‚ɐݒ肵‚Ä‚¢‚¢’l(Žå‚ɃCƒ“ƒXƒ^ƒ“ƒX‚ª“ü‚é) @@ -166,6 +114,8 @@ type FBoolData: Boolean; //‚¢‚ë‚ñ‚È—p“r‚ÉŽg‚¤yo FSPID: string; //‘‚«ž‚Ý—pSPID FPON: string; //‘‚«ž‚Ý—pPON + FCookie: string; //‘‚«ž‚Ý—pCookie•¶Žš—ñ + FExpires: TDateTime; //Cookie‚Ì—LŒøŠúŒÀ FKotehanName: string; //ƒRƒeƒnƒ“–¼‘O FKotehanMail: string; //ƒRƒeƒnƒ“ƒ[ƒ‹ @@ -178,16 +128,23 @@ type FIntData : Integer; // D‚«‚É‚¢‚¶‚Á‚Ă悵B‚¢‚ë‚ñ‚È—p“r‚ÉŽg‚¤yo FListData : TList; // D‚«‚É‚¢‚¶‚Á‚Ă悵B‚¢‚ë‚ñ‚È—p“r‚ÉŽg‚¤yo - FSETTINGTXTTime: TDateTime; //SETTING.TXT‚ðŽæ“¾‚µ‚½“úŽž - FIsSETTINGTXT: boolean; //SETTING.TXT‚ðŽæ“¾‚µ‚Ä‚¢‚é‚© - FHEADTXTTime: TDateTime; //HEAD.TXT‚ðŽæ“¾‚µ‚½“úŽž - FIsHEADTXT: boolean; //HEAD.TXT‚ðŽæ“¾‚µ‚Ä‚¢‚é‚© - FTitlePictureURL: string; //topŠG‚ÌURL - FMultiplicity : Integer; //d•¡‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©H + FSETTINGTXTTime : TDateTime; //SETTING.TXT‚ðŽæ“¾‚µ‚½“úŽž + FIsSETTINGTXT : boolean; //SETTING.TXT‚ðŽæ“¾‚µ‚Ä‚¢‚é‚© + FHEADTXTTime : TDateTime; //HEAD.TXT‚ðŽæ“¾‚µ‚½“úŽž + FIsHEADTXT : boolean; //HEAD.TXT‚ðŽæ“¾‚µ‚Ä‚¢‚é‚© + FTitlePictureURL: string; //topŠG‚ÌURL + FMultiplicity : Integer; //d•¡‚µ‚Ä‚¢‚é‚©‚Ç‚¤‚©H + FIs2ch : Boolean; //host‚ª2ch‚©‚Ç‚¤‚© + FNewThreadCount: Integer; //V’…ƒXƒŒƒbƒh‚̐” + FLogThreadCount: Integer; //ƒƒO—L‚èƒXƒŒƒbƒh‚̐” + FUserThreadCount: Integer; //H + FLiveThreadCount: Integer; //¶‘¶ƒXƒŒƒbƒh” + FArchiveThreadCount: Integer; //DAT—Ž‚¿ƒXƒŒƒbƒh” function GetThreadItem(index: integer): TThreadItem; procedure SetThreadItem(index: integer; value: TThreadItem); procedure SetRound(b: Boolean); procedure SetRoundName(s: string); + //procedure SetRoundName(s: PChar); procedure SetLastModified(d: TDateTime); procedure SetLastGetTime(d: TDateTime); procedure SetUnRead(i: Integer); @@ -206,6 +163,7 @@ type property BBSID: string read FBBSID write FBBSID; property URL: string read FURL write FURL; property Round: Boolean read FRound write SetRound; + //property RoundName: PChar read FRoundName write SetRoundName; property RoundName: string read FRoundName write SetRoundName; property RoundDate: TDateTime read FRoundDate write FRoundDate; property LastModified: TDateTime read FLastModified write SetLastModified; @@ -230,7 +188,7 @@ type function FindThreadFromFileName(const ItemFileName: string): TThreadItem; function FindThreadFromURL(const inURL : string ) : TThreadItem; function GetIndexFromFileName(const ItemFileName: string): Integer; - function GetIndexFromURL(const URL: string): Integer; + function GetIndexFromURL(const URL: string; reverse : Boolean = False): Integer; procedure LoadSettings; procedure SaveSettings; function GetReadCgiURL: string; @@ -243,11 +201,16 @@ type function GetNewThreadCount: Integer; function GetLogThreadCount: Integer; + function GetArchiveThreadCount: Integer; + function GetLiveThreadCount: Integer; function GetUserThreadCount: Integer; function GetNewThread(Index: Integer): TThreadItem; - function GetLogThread(Index: Integer): TThreadItem; + function GetLogThread(Index: Integer): TThreadItem; overload; + function GetArchiveThread(Index: Integer): TThreadItem; + function GetLiveThread(Index: Integer): TThreadItem; function GetUserThread(Index: Integer): TThreadItem; - + function GetThreadCount(func :TThreadCount ): Integer; + function GetThread(func :TThreadCount;const Index :Integer ): TThreadItem; procedure BeginUpdate; procedure EndUpdate; property NodeExpand: Boolean read FExpand write FExpand; @@ -261,15 +224,23 @@ type property IsSETTINGTXT: boolean read FIsSETTINGTXT write FIsSETTINGTXT; property HEADTXTTime: TDateTime read FHEADTXTTime write FHEADTXTTime; property IsHEADTXT: boolean read FIsHEADTXT write FIsHEADTXT; - property TitlePictureURL: string read FTitlePictureURL write FTitlePictureURL; + property TitlePictureURL: string read FTitlePictureURL write FTitlePictureURL; property Multiplicity: Integer read FMultiplicity write FMultiplicity; + property Is2ch : boolean read FIs2ch write FIs2ch; + property NewThreadCount: Integer read FNewThreadCount write FNewThreadCount; //V’…ƒXƒŒƒbƒh‚̐” + property LogThreadCount: Integer read FLogThreadCount write FLogThreadCount; //ƒƒO—L‚èƒXƒŒƒbƒh‚̐” + property UserThreadCount: Integer read FUserThreadCount write FUserThreadCount; //H + property LiveThreadCount: Integer read FLiveThreadCount write FLiveThreadCount; + property ArchiveThreadCount: Integer read FArchiveThreadCount write FArchiveThreadCount; + + property Cookie: string read FCookie write FCookie; + property Expires: TDateTime read FExpires write FExpires; end; //ƒXƒŒ TThreadItem = class(TObject) private FContext: DWORD; // ƒvƒ‰ƒOƒCƒ“‚ªŽ©—R‚ɐݒ肵‚Ä‚¢‚¢’l(Žå‚ɃCƒ“ƒXƒ^ƒ“ƒX‚ª“ü‚é) - FNo: Integer; //”ԍ† FFileName: string; //ƒXƒŒƒbƒhƒtƒ@ƒCƒ‹–¼ FTitle: string; //ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹ @@ -291,25 +262,24 @@ type FScrollTop: Integer; //ƒXƒNƒ[ƒ‹ˆÊ’u FDownloadHost: string; //¡‚̃zƒXƒg‚ƈႤê‡‚̃zƒXƒg FAgeSage: TGikoAgeSage; //ƒAƒCƒeƒ€‚̏グ‰º‚° -// FSPID: string; //‘‚«ž‚Ý—pSPID - FUpdate: Boolean; FExpand: Boolean; FURL : string; // ‚±‚̃XƒŒ‚ðƒuƒ‰ƒEƒU‚Å•\Ž¦‚·‚éÛ‚Ì URL - FBoardPlugIn : TBoardPlugIn; // ‚±‚̃XƒŒ‚ðƒTƒ|[ƒg‚·‚éƒvƒ‰ƒOƒCƒ“ - FFilePath : string; // ‚±‚̃XƒŒ‚ª•Û‘¶‚³‚ê‚Ä‚¢‚éƒpƒX - + FJumpAddress : Integer; //ƒŒƒX”ԍ†Žw’èURL‚𓥂ñ‚¾‚Æ‚«‚ÉŽw’肳‚ê‚郌ƒX‚̔ԍ†‚ª“ü‚é procedure SetLastModified(d: TDateTime); procedure SetRound(b: Boolean); procedure SetRoundName(const s: string); + //procedure SetRoundName(const s: PChar); procedure SetKokomade(i: Integer); procedure SetUnRead(b: Boolean); procedure SetScrollTop(i: Integer); procedure Init; function GetCreateDate: TDateTime; + function GetFilePath: String; public - constructor Create( inPlugIn : TBoardPlugIn; inURL : string ); overload; - constructor Create( is2ch : Boolean; const inURL, inHost, inBBSID, inBBSKey : string ); overload; + constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard; inURL : string ); overload; + constructor Create(const inPlugIn : TBoardPlugIn; const inBoard : TBoard; + const inURL : string; inExist: Boolean; const inFilename: string ); overload; destructor Destroy; override; @@ -337,6 +307,7 @@ type property Size: Integer read FSize write FSize; property Round: Boolean read FRound write SetRound; property RoundName: string read FRoundName write SetRoundName; + //property RoundName: PChar read FRoundName write SetRoundName; property IsLogFile: Boolean read FIsLogFile write FIsLogFile; property ParentBoard: TBoard read FParentBoard write FParentBoard; @@ -348,31 +319,27 @@ type property Expand: Boolean read FExpand write FExpand; property DownloadHost: string read FDownloadHost write FDownloadHost; property AgeSage: TGikoAgeSage read FAgeSage write FAgeSage; -// property SPID: string read FSPID write FSPID; property CreateDate: TDateTime read GetCreateDate; property URL : string read FURL write FURL; - property BoardPlugIn : TBoardPlugIn read FBoardPlugIn; - property FilePath : string read FFilePath write FFilePath; - function IsBoardPlugInAvailable : Boolean; + property FilePath : string read GetFilePath; + property JumpAddress : Integer read FJumpAddress write FJumpAddress; end; - - - //ŒŸõŒ‹‰ÊƒŠƒXƒg -{ TSearchList = class(TList) - private - function GetThreadItem(index: integer): TThreadItem; - procedure SetThreadItem(index: integer; value: TThreadItem); - public - constructor Create; + TBoardGroup = class(TStringList) + private + FBoardPlugIn : TBoardPlugIn; // ‚±‚̔‚ðƒTƒ|[ƒg‚·‚éƒvƒ‰ƒOƒCƒ“ + public destructor Destroy; override; + procedure Clear ; override; + property BoardPlugIn : TBoardPlugIn read FBoardPlugIn write FBoardPlugIn; + end; - property Items[index: integer]: TThreadItem read GetThreadItem write SetThreadItem; - - function Add(item: TThreadItem): integer; - procedure Delete(index: integer); - procedure Clear; override; - end;} + // “ÁŽê—p“r—pTBoard + TSpecialBoard = class(TBoard) + public + function Add(item: TThreadItem): integer; overload; + procedure Clear; overload; + end; function BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard; function BBSsFindBoardFromURL( inURL : string ) : TBoard; @@ -380,13 +347,18 @@ type function BBSsFindThreadFromURL(const inURL : string ) : TThreadItem; function ConvertDateTimeString( inDateTimeString : string) : TDateTime; + procedure DestorySpecialBBS( inBBS : TBBS ); + var BBSs : array of TBBS; + BoardGroups : array of TBoardGroup; + SpecialBBS : TBBS; + SpecialBoard: TSpecialBoard; implementation uses - GikoSystem, RoundData, MojuUtils; + GikoSystem, RoundData, MojuUtils, DateUtils, IniFiles; const BBS2CH_NAME: string = '‚Q‚¿‚á‚ñ‚Ë‚é'; @@ -401,9 +373,34 @@ const HEADTXT_FILENAME: string = 'head.html'; //DEFAULT_LIST_COUNT: Integer = 100; -// COLUMN_CATEGORY: array[0..0] of string = ('ƒJƒeƒSƒŠ–¼'); -// COLUMN_BOARD: array[0..3] of string = ('”–¼', 'Žæ“¾”', '„‰ñ—\–ñ', '‘O‰ñ„‰ñ“úŽž'); -// COLUMN_THREADITEM: array[0..3] of string = ('ƒXƒŒƒbƒh–¼', 'ƒJƒEƒ“ƒg', '„‰ñ—\–ñ', '‘O‰ñ„‰ñ“úŽž'); +//! ƒƒO‚ðŽ‚Á‚Ä‚¢‚é‚È‚ç^‚ð•Ô‚· +function CountLog(Item: TThreadItem): Boolean; +begin + Result := Item.IsLogFile; +end; +//! V’…‚È‚ç^‚ð•Ô‚· +function CountNew(Item: TThreadItem): Boolean; +begin + Result := Item.NewArrival; +end; +//! DAT—Ž‚¿‚È‚ç^‚ð•Ô‚· +function CountDat(Item: TThreadItem): Boolean; +begin + Result := (Item.AgeSage = gasArch); +end; +//! ¶‘¶ƒXƒŒ‚È‚ç^‚ð•Ô‚· +function CountLive(Item: TThreadItem): Boolean; +begin + Result := (Item.AgeSage <> gasArch); +end; + +//! í‚ɐ^ +function CountAll(Item: TThreadItem): Boolean; +begin + Result := True; +end; + + // BBSID ‚ð—p‚¢‚é 2 ‚¿‚á‚ñ‚Ë‚é‚Ì‚Ý’T‚µo‚µ‚Ü‚· // BBSID ‚ÌŽg—p‚Í‹É—Í”ð‚¯‚Ä‚­‚¾‚³‚¢B @@ -411,26 +408,67 @@ const function BBSsFindBoardFromBBSID( inBBSID : string ) : TBoard; +var + i : Integer; + tmpBoard : TBoard; begin - Result := BBSs[ 0 ].FindBBSID( inBBSID ); +// Result := BBSs[ 0 ].FindBBSID( inBBSID ); + Result := nil; + if Length(BoardGroups) > 0 then begin + for i := BoardGroups[0].Count - 1 downto 0 do begin + tmpBoard := TBoard(BoardGroups[0].Objects[i]); + if tmpBoard.Is2ch then begin + if AnsiCompareStr(tmpBoard.BBSID, inBBSID) = 0 then begin + Result := tmpBoard; + EXIT; + end; + end; + end; + end; end; - +{********************************************** +‚±‚̊֐”‚Í•K‚¸”‚ÌURL‚ÌŒ`Ž®‚Å“n‚µ‚Ä‚­‚¾‚³‚¢B +plugin‚ðŽg—p‚·‚é‚È‚ç‚΁AExtractBoardURL( inURL ) +2ch‚È‚ç‚΁AGikoSys.Get2chThreadURL2BoardURL( inURL ); +‚Å•ÏŠ·‚µ‚Ä‚©‚çŒÄ‚яo‚µ‚Ä‚­‚¾‚³‚¢B +**********************************************} function BBSsFindBoardFromURL( inURL : string ) : TBoard; var - i : Integer; + i,p : Integer; + accept : TAcceptType; + protocol, host, path, document, port, bookmark : string; begin - - for i := Length( BBSs ) - 1 downto 0 do begin - Result := BBSs[ i ].FindBoardFromURL( inURL ); - if Result <> nil then - Exit; - end; - Result := nil; + for i := Length(BoardGroups) - 1 downto 1 do begin + accept := BoardGroups[i].BoardPlugIn.AcceptURL(inURL); + if (accept = atBoard) or (accept = atThread) then begin + if BoardGroups[i].Find(inURL, p) then begin + Result := TBoard(BoardGroups[i].Objects[p]); + Exit; + end else begin + inURL := BoardGroups[i].BoardPlugIn.ExtractBoardURL(inURL); + if BoardGroups[i].Find(inURL, p) then begin + Result := TBoard(BoardGroups[i].Objects[p]); + Exit; + end; + end; + end; + end; + //‚±‚±‚É‚«‚½‚çAplugin‚ðŽg‚í‚È‚¢‚â‚‚ç‚𒲂ׂé + if BoardGroups[0].Find(inURL, p) then + Result := TBoard(BoardGroups[0].Objects[p]); + + if (Result = nil) then begin + GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark ); + //ƒzƒXƒg‚ª2ch‚È‚çBBSID‚Å’²‚ׂé + if GikoSys.Is2chHost(host) then begin + Result := BBSsFindBoardFromBBSID(GikoSys.URLToID( inURL )); + end; + end; end; @@ -438,17 +476,20 @@ function BBSsFindBoardFromTitle( inTitle : string ) : TBoard; var - i : Integer; + i,j : Integer; + tmpBoard : TBoard; begin - + Result := nil; for i := Length( BBSs ) - 1 downto 0 do begin - Result := BBSs[ i ].FindBoardFromTitle( inTitle ); - if Result <> nil then - Exit; + for j := BoardGroups[i].Count - 1 downto 0 do begin + tmpBoard := TBoard(BoardGroups[i].Objects[j]); + if ( AnsiCompareStr(tmpBoard.Title, inTitle) = 0) then begin + Result := tmpBoard; + Exit; + end; + end; end; - Result := nil; - end; function BBSsFindThreadFromURL( @@ -456,17 +497,70 @@ function BBSsFindThreadFromURL( ) : TThreadItem; var board : TBoard; + tmpThread : TThreadItem; boardURL : string; + protocol, host, path, document, port, bookmark : string; + BBSID, BBSKey : string; + i, bi : Integer; begin boardURL := GikoSys.GetThreadURL2BoardURL( inURL ); board := BBSsFindBoardFromURL( boardURL ); if board = nil then Result := nil - else + else begin Result := board.FindThreadFromURL( inURL ); + //‚à‚µ‚à2ch‚̔‚Ȃç + if (Result = nil) and (board.Is2ch) then begin + GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark ); + GikoSys.Parse2chURL( inURL, path, document, BBSID, BBSKey ); + Result := board.FindThreadFromFileName(BBSKey + '.dat'); + end else if (Result = nil) and not (board.Is2ch) then begin + //ƒvƒ‰ƒOƒCƒ“Œn‚Ì’TõiŽå‚ÉURL‚ª“r’†‚ŕύX‚É‚È‚Á‚½—Þ) + try + bi := Length(BoardGroups) - 1; + for i := 1 to bi do begin + if (BoardGroups[i].BoardPlugIn <> nil) and (Assigned(Pointer(BoardGroups[i].BoardPlugIn.Module))) then begin + if BoardGroups[i].BoardPlugIn.AcceptURL( inURL ) = atThread then begin + tmpThread := TThreadItem.Create( BoardGroups[i].BoardPlugIn, Board, inURL ); + if not board.IsThreadDatRead then begin + GikoSys.ReadSubjectFile( board ); + end; + Result := Board.FindThreadFromFileName( tmpThread.FileName ); + tmpThread.Free; + Break; + end; + end; + end; + except + Result := nil; + end; + end; + end; end; +{! +\brief “ÁŽê—p“rBBSíœ +\param bbs íœ‚·‚é“ÁŽê—p“rBBS +} +procedure DestorySpecialBBS( inBBS : TBBS ); +var + sCategory : TCategory; + sBoard : TSpecialBoard; +begin + if inBBS <> nil then begin + sCategory := inBBS.Items[0]; + if sCategory <> nil then begin + sBoard := TSpecialBoard(sCategory.Items[0]); + if sBoard <> nil then begin + sBoard.Modified := False; + sBoard.Clear; + FreeAndNil(sBoard); + end; + end; + FreeAndNil(inBBS); + end; +end; (************************************************************************* *‹@”\–¼FTBBSƒRƒ“ƒXƒgƒ‰ƒNƒ^ @@ -553,7 +647,7 @@ var i: Integer; begin if not IsBoardFileRead then - GikoSys.ReadBoardFile( Self ); + GikoSys.ReadBoardFile( Self ); for i := Count - 1 downto 0 do begin Result := Items[ i ].FindBoardFromTitle(Title); if Result <> nil then @@ -570,7 +664,7 @@ var i : Integer; begin if not IsBoardFileRead then - GikoSys.ReadBoardFile( Self ); + GikoSys.ReadBoardFile( Self ); for i := Count - 1 downto 0 do begin Result := Items[ i ].FindBoardFromURL( inURL ); if Result <> nil then @@ -677,16 +771,7 @@ end; procedure TCategory.Delete(index: integer); begin - if (Items[index] <> nil) then begin - try - if TBoard(Items[index]).Multiplicity = 0 then - TBoard(Items[index]).Free - else - TBoard(Items[index]).Multiplicity := TBoard(Items[index]).Multiplicity - 1; - except - end; - end; - inherited Delete(index); + inherited Delete(index); end; procedure TCategory.Clear; @@ -814,6 +899,7 @@ begin FLastGetTime := ZERO_DATE; FIsThreadDatRead := False; FUnRead := 0; + FMultiplicity := 0; // FListStyle := vsReport; // FItemNoVisible := True; @@ -841,17 +927,21 @@ begin if inPlugIn = nil then begin // subject.txt ‚Ì•Û‘¶ƒpƒX‚ðÝ’è GikoSys.ParseURI( inURL, protocol, host, path, document, port, bookmark ); - if GikoSys.Is2chHost( host ) then + if GikoSys.Is2chHost( host ) then begin + Self.Is2ch := True; FilePath := GikoSys.Setting.LogFolderP + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME - else + end else begin + Self.Is2ch := False; FilePath := GikoSys.Setting.LogFolderP + EXTERNAL_LOG_FOLDER + PATH_DELIM + host + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME + end; end else begin // ƒvƒ‰ƒOƒCƒ“‚É TBoardItem ‚ªì¬‚³‚ꂽ‚±‚Æ‚ð“`‚¦‚é inPlugIn.CreateBoardItem( DWORD( Self ) ); + //Self.Is2ch := False; //plugin‘¤‚Őݒ肷‚é end; end; @@ -969,9 +1059,21 @@ begin end; end; -function TBoard.GetIndexFromURL(const URL: string): Integer; +function TBoard.GetIndexFromURL(const URL: string; reverse : Boolean = False): Integer; +var + i : Integer; begin - Result := IndexOf( URL ); + if not reverse then + Result := IndexOf( URL ) + else begin + Result := -1; + for i := Self.Count - 1 downto 0 do begin + if Strings[i] = URL then begin + Result := i; + break; + end; + end; + end; end; function TBoard.FindThreadFromURL(const inURL : string ) : TThreadItem; @@ -1040,6 +1142,9 @@ begin FUnRead := ini.ReadInteger('Status', 'UnRead', 0); FSPID := ini.ReadString('Cookie', 'SPID', ''); FPON := ini.ReadString('Cookie', 'PON', ''); + FCookie := ini.ReadString('Cookie', 'Cookie', ''); + tmp := ini.ReadString('Cookie', 'Expires', DateTimeToStr(ZERO_DATE)); + FExpires := ConvertDateTimeString(tmp); FKotehanName := ini.ReadString('Kotehan', 'Name', ''); FKotehanMail := ini.ReadString('Kotehan', 'Mail', ''); @@ -1074,6 +1179,8 @@ begin ini.WriteInteger('Status', 'UnRead', FUnRead); ini.WriteString('Cookie', 'SPID', FSPID); ini.WriteString('Cookie', 'PON', FPON); + ini.WriteString('Cookie', 'Cookie', FCookie); + ini.WriteDateTime('Cookie', 'Expires', FExpires); ini.WriteString('Kotehan', 'Name', FKotehanName); ini.WriteString('Kotehan', 'Mail', FKotehanMail); @@ -1147,17 +1254,14 @@ begin // Result := inDateTimeString; end; -// ƒTƒuƒWƒFƒNƒgURLŽæ“¾ +//! ƒTƒuƒWƒFƒNƒgURLŽæ“¾ function TBoard.GetReadCgiURL: string; begin - //Result := URL + SUBJECT_FILENAME; - //Result := GikoSys.UrlToServer(URL) - // + 'test/read.cgi/' + BBSID + '/?raw=0.0'; Result := URL + SUBJECT_FILENAME; end; -// ƒTƒuƒWƒFƒNƒgƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +//! ƒTƒuƒWƒFƒNƒgƒtƒ@ƒCƒ‹–¼Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j function TBoard.GetSubjectFileName: string; begin if Length( FilePath ) > 0 then @@ -1167,7 +1271,7 @@ begin + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + SUBJECT_FILENAME; end; -// ƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹–¼(folder.idx)Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j +//! ƒCƒ“ƒfƒbƒNƒXƒtƒ@ƒCƒ‹–¼(folder.idx)Žæ“¾iƒpƒX{ƒtƒ@ƒCƒ‹–¼j function TBoard.GetFolderIndexFileName: string; begin if Length( FilePath ) > 0 then @@ -1176,7 +1280,7 @@ begin Result := GikoSys.Setting.LogFolderP + BBS2CH_LOG_FOLDER + PATH_DELIM + BBSID + PATH_DELIM + FOLDER_INDEX_FILENAME; end; -//SETTING.TXT‚̃tƒ@ƒCƒ‹–¼Žæ“¾ +//! SETTING.TXT‚̃tƒ@ƒCƒ‹–¼Žæ“¾ function TBoard.GetSETTINGTXTFileName: string; begin if Length( FilePath ) > 0 then @@ -1212,12 +1316,9 @@ end; // ƒXƒŒ—§‚Ä‘—MURL function TBoard.GetSendURL: string; -var - Protocol, Host, Path, Document, Port, Bookmark : string; begin Result := GikoSys.UrlToServer(URL); - GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark ); - if GikoSys.Is2chHost(Host) then + if Self.Is2ch then Result := Result + 'test/bbs.cgi' else Result := Result + 'test/subbbs.cgi'; @@ -1284,8 +1385,8 @@ begin if FUpdate then FModified := True; end; - -function TBoard.GetNewThreadCount: Integer; +//! func‚ÌðŒ‚Éˆê’v‚·‚éƒXƒŒƒbƒh‚̐”‚ð•Ô‚· +function TBoard.GetThreadCount(func :TThreadCount ): Integer; var i: Integer; begin @@ -1293,12 +1394,12 @@ begin if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then begin for i := 0 to Count - 1 do begin - if Items[i].NewArrival then + if func(Items[i]) then inc(Result); end; end else begin for i := 0 to Count - 1 do begin - if Items[i].NewArrival then + if func(Items[i]) then begin if Items[i].ShortTitle = '' then Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', ''); @@ -1308,48 +1409,33 @@ begin end; end; end; - +//! V’…ƒXƒŒƒbƒh‚̐”‚ðŽæ“¾‚·‚é +function TBoard.GetNewThreadCount: Integer; +begin + Result := GetThreadCount(CountNew); +end; +//! ƒƒO—L‚èƒXƒŒƒbƒh‚̐”‚ðŽæ“¾‚·‚é function TBoard.GetLogThreadCount: Integer; -var - i: Integer; begin - Result := 0; - if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then - begin - for i := 0 to Count - 1 do begin - if Items[i].IsLogFile then - inc(Result); - end; - end else begin - for i := 0 to Count - 1 do begin - if Items[i].IsLogFile then - begin - if Items[i].ShortTitle = '' then - Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', ''); - if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then - inc(Result); - end; - end; - end; + Result := GetThreadCount(CountLog); end; - +//! iž‚ÝðŒ‚Éˆê’v‚·‚éƒXƒŒƒbƒh‚̐”‚ðŽæ“¾‚·‚é function TBoard.GetUserThreadCount: Integer; -var - i: Integer; begin - Result := 0; - if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then - Result := Count - else - for i := 0 to Count - 1 do begin - if Items[i].ShortTitle = '' then - Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', ''); - if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then - inc(Result); - end; + Result := GetThreadCount(CountAll); end; - -function TBoard.GetNewThread(Index: Integer): TThreadItem; +//! DAT—Ž‚¿ƒXƒŒƒbƒh‚̐”‚ðŽæ“¾‚·‚é +function TBoard.GetArchiveThreadCount: Integer; +begin + Result := GetThreadCount(CountDat); +end; +//! ¶‘¶ƒXƒŒƒbƒh‚̐”‚ðŽæ“¾‚·‚é +function TBoard.GetLiveThreadCount: Integer; +begin + Result := GetThreadCount(CountLive); +end; +//! func‚ÌðŒ‚É“K‡‚·‚éIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é +function TBoard.GetThread(func :TThreadCount;const Index :Integer ): TThreadItem; var i: Integer; Cnt: Integer; @@ -1359,8 +1445,7 @@ begin if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then begin for i := 0 to Count - 1 do begin - if Items[i].NewArrival then - begin + if func(Items[i]) then begin if Index = Cnt then begin Result := Items[i]; Exit; @@ -1370,9 +1455,8 @@ begin end; end else begin for i := 0 to Count - 1 do begin - if Items[i].NewArrival then - begin - if Items[i].ShortTitle = '' then + if func(Items[i]) then begin + if Length(Items[i].ShortTitle) = 0 then Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', ''); if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin if Index = Cnt then begin @@ -1385,74 +1469,30 @@ begin end; end; end; - +//! DAT—Ž‚¿ƒXƒŒƒbƒh‚ÅIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é +function TBoard.GetArchiveThread(Index: Integer): TThreadItem; +begin + Result := GetThread(CountDat, Index); +end; +//! ¶‘¶ƒXƒŒƒbƒh‚ÅIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é +function TBoard.GetLiveThread(Index: Integer): TThreadItem; +begin + Result := GetThread(CountLive, Index); +end; +//! V’…ƒXƒŒƒbƒh‚ÅIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é +function TBoard.GetNewThread(Index: Integer): TThreadItem; +begin + Result := GetThread(CountNew, Index); +end; +//! Log‚ ‚èƒXƒŒƒbƒh‚ÌIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é function TBoard.GetLogThread(Index: Integer): TThreadItem; -var - i: Integer; - Cnt: Integer; begin - Cnt := 0; - if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then - begin - for i := 0 to Count - 1 do begin - if Items[i].IsLogFile then - begin - if Index = Cnt then begin - Result := Items[i]; - Exit; - end; - inc(Cnt); - end; - end; - end else begin - for i := 0 to Count - 1 do begin - if Items[i].IsLogFile then - begin - if Items[i].ShortTitle = '' then - Items[i].ShortTitle := ZenToHan(Items[i].Title); - if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin - if Index = Cnt then begin - Result := Items[i]; - Exit; - end; - inc(Cnt); - end; - end; - end; - end; - Result := nil; + Result := GetThread(CountLog, Index); end; - +//! iž‚Ý‚ÅIndex”Ԗڂ̃XƒŒƒbƒh‚ðŽæ“¾‚·‚é function TBoard.GetUserThread(Index: Integer): TThreadItem; -var - i: Integer; - Cnt: Integer; begin - Result := nil; - Cnt := 0; - if Length( ParentCategory.ParenTBBS.ShortSelectText ) = 0 then - begin - for i := 0 to Count - 1 do begin - if Index = Cnt then - begin - Result := Items[ i ]; - Exit; - end; - inc( Cnt ); - end; - end else begin - for i := 0 to Count - 1 do begin - if Items[i].ShortTitle = '' then - Items[i].ShortTitle := CustomStringReplace(ZenToHan(Items[i].Title), ' ', ''); - if AnsiPos(ParentCategory.ParenTBBS.ShortSelectText, Items[i].ShortTitle) <> 0 then begin - if Index = Cnt then begin - Result := Items[i]; - Exit; - end; - inc(Cnt); - end; - end; - end; + Result := GetThread(CountAll, Index); end; procedure TBoard.BeginUpdate; @@ -1465,16 +1505,6 @@ begin FUpdate := True; end; -{class function TBoard.GetColumnName(Index: Integer): string; -begin - Result := COLUMN_THREADITEM[Index]; -end; - -class function TBoard.GetColumnCount: Integer; -begin - Result := Length(COLUMN_THREADITEM); -end;} - //constructor TThreadItem.Create(AOwner: TComponent); procedure TThreadItem.Init; begin @@ -1496,15 +1526,16 @@ begin FUpdate := True; FURL := ''; - FBoardPlugIn := nil; + FJumpAddress := 0; end; // ************************************************************************* // ŠO•””ƒvƒ‰ƒOƒCƒ“‚ðŽw’肵‚½ƒRƒ“ƒXƒgƒ‰ƒNƒ^ // ************************************************************************* constructor TThreadItem.Create( - inPlugIn : TBoardPlugIn; - inURL : string + const inPlugIn : TBoardPlugIn; + const inBoard : TBoard; + inURL : string ); var foundPos : Integer; @@ -1516,9 +1547,9 @@ begin inherited Create; Init; - - FBoardPlugIn := inPlugIn; - URL := inURL; + FParentBoard := inBoard; + //FBoardPlugIn := inPlugIn; + URL := inURL; if inPlugIn = nil then begin foundPos := Pos( READ_PATH, inURL ); @@ -1526,14 +1557,6 @@ begin // dat ‚Ì•Û‘¶ƒpƒX‚ðÝ’è 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 ); @@ -1544,42 +1567,33 @@ begin end; end; - // ************************************************************************* -// ƒvƒ‰ƒOƒCƒ“‚ð—˜—p‚µ‚È‚¢ƒRƒ“ƒXƒgƒ‰ƒNƒ^ +// ŠO•””ƒvƒ‰ƒOƒCƒ“‚ðŽw’肵‚½ƒRƒ“ƒXƒgƒ‰ƒNƒ^ Log—L‚è‚©‚Ç‚¤‚©”»’fÏ‚Ý +// FileName‚àŽæ“¾Ï‚݁@¨@ReadSubject—p // ************************************************************************* constructor TThreadItem.Create( - is2ch : Boolean; - const inURL, inHost, inBBSID, inBBSKey : string + const inPlugIn : TBoardPlugIn; + const inBoard : TBoard; + const inURL : string; + inExist: Boolean; + const inFilename: string ); -var - foundPos : Integer; -const - READ_PATH = '/test/read.cgi'; begin inherited Create; Init; + FParentBoard := inBoard; + URL := inURL; - FBoardPlugIn := nil; - - foundPos := Pos( READ_PATH, inURL ); - if foundPos > 0 then begin - // dat ‚Ì•Û‘¶ƒpƒX‚ðÝ’è - 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; + if inPlugIn = nil then begin + // dat ‚Ì•Û‘¶ƒpƒX‚ðÝ’è + FileName := inFilename; + IsLogFile := inExist; + URL := inURL; + end else begin + // ƒvƒ‰ƒOƒCƒ“‚É TThreadItem ‚ªì¬‚³‚ꂽ‚±‚Æ‚ð“`‚¦‚é + inPlugIn.CreateThreadItem( DWORD( Self ) ); + end; end; // ************************************************************************* @@ -1589,34 +1603,13 @@ destructor TThreadItem.Destroy; begin // ƒvƒ‰ƒOƒCƒ“‚É TThreadItem ‚ª”jŠü‚³‚ꂽ‚±‚Æ‚ð“`‚¦‚é - if IsBoardPlugInAvailable then - FBoardPlugIn.DisposeThreadItem( DWORD( Self ) ); + if Self.ParentBoard.IsBoardPlugInAvailable then + Self.ParentBoard.BoardPlugIn.DisposeThreadItem( DWORD( Self ) ); inherited; end; -// ************************************************************************* -// ŠO•””ƒvƒ‰ƒOƒCƒ“‚ªŽg—p‰Â”\‚© -// ************************************************************************* -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; var Protocol, Host, Path, Document, Port, Bookmark: string; @@ -1680,31 +1673,8 @@ begin end; end; -{function TThreadItem.GetOldDatgzURL: string; -var - Protocol, Host, Path, Document, Port, Bookmark: string; -begin - Result := Format('%s%s/%.3s/%s.gz', [ParentBoard.URL, - 'kako', - FileName, - FileName]); - if FDownloadHost <> '' then begin - ParseURI(Result, Protocol, Host, Path, Document, Port, Bookmark); - Result := Format('%s://%s%s%s', [Protocol, - DownloadHost, - Path, - Document]); - - end; -end;} - function TThreadItem.GetOfflawCgiURL(const SessionID: string): string; -//var -// Protocol, Host, Path, Document, Port, Bookmark: string; begin -// Result := GikoSys.UrlToServer(ParentBoard.URL) -// + 'test/offlaw.cgi/' + ParentBoard.BBSID + '/' -// + ChangeFileExt(FileName, '') + '/?raw=.0&sid=' + HttpEncode(SessionID); if FDownloadHost = '' then begin Result := GikoSys.UrlToServer(ParentBoard.URL) + 'test/offlaw.cgi/' + ParentBoard.BBSID + '/' @@ -1715,10 +1685,6 @@ begin Result := 'http://' + FDownloadHost + '/test/offlaw.cgi/' + ParentBoard.BBSID + '/' + ChangeFileExt(FileName, '') + '/?raw=.0&sid=' + HttpEncode(SessionID); -// Result := Format('%s://%s%s%s', [Protocol, -// DownloadHost, -// Path, -// Document]); end; end; @@ -1729,12 +1695,18 @@ begin end; procedure TThreadItem.DeleteLogFile; +var + tmpFileName: String; begin ParentBoard.BeginUpdate; if FUnRead then ParentBoard.UnRead := ParentBoard.UnRead - 1; DeleteFile(GetThreadFileName); + //ŽŽŒ±“I‚Étmp‚àíœ‚µ‚Ä‚Ý‚é + tmpFileName := StringReplace(GetThreadFileName, 'dat', 'tmp', [rfReplaceAll]); + DeleteFile(tmpFileName); + if FileExists(ChangeFileExt(GetThreadFileName,'.NG')) = true then DeleteFile(ChangeFileExt(GetThreadFileName,'.NG')); FRoundDate := ZERO_DATE; @@ -1775,14 +1747,6 @@ begin ParentBoard.FModified := True; end; -{procedure TThreadItem.SetRoundNo(i: Integer); -begin - if FRoundNo = i then Exit; - FRoundNo := i; - if FUpdate and (ParentBoard <> nil) then - ParentBoard.FModified := True; -end;} - procedure TThreadItem.SetRound(b: Boolean); begin if b then @@ -1803,6 +1767,7 @@ begin ParentBoard.FModified := True; end; + procedure TThreadItem.SetKokomade(i: Integer); begin if FKokomade = i then Exit; @@ -1815,8 +1780,14 @@ procedure TThreadItem.SetUnRead(b: Boolean); begin if FUnRead = b then Exit; FUnRead := b; - if FUpdate and (ParentBoard <> nil) then + if FUpdate and (ParentBoard <> nil) then begin ParentBoard.FModified := True; + if FUnRead then begin + ParentBoard.UnRead := ParentBoard.UnRead + 1; + end else begin + ParentBoard.UnRead := ParentBoard.UnRead - 1; + end; + end; end; procedure TThreadItem.SetScrollTop(i: Integer); @@ -1837,16 +1808,7 @@ begin FUpdate := True; end; -{initialization - BBS2ch := TBBS.Create; - -finalization - if BBS2ch <> nil then - BBS2ch.Free;} function TThreadItem.GetCreateDate: TDateTime; -var - unixtime: Int64; - tmp: string; begin // ƒtƒ@ƒCƒ‹–¼‚©‚çƒXƒŒì¬“úŽž‚ð‹‚ß‚é try @@ -1854,18 +1816,7 @@ begin Result := ZERO_DATE else begin // ƒƒOƒtƒ@ƒCƒ‹‚ÌŠg’£Žq‚ð‚Í‚¸‚µ‚½‚à‚Ì‚ªƒXƒŒì¬“úŽž - tmp := ChangeFileExt(FFileName, ''); - if AnsiPos('_', tmp) <> 0 then - if AnsiPos('_', tmp) > 9 then - tmp := Copy(tmp, 1, AnsiPos('_', tmp)-1) - else - Delete(tmp, AnsiPos('_', tmp), 1); - - if ( Length(tmp) = 9) and ( tmp[1] = '0' ) then - Insert('1', tmp, 1); - - unixtime := StrToInt64Def(tmp, ZERO_DATE); - Result := UnixToDateTime(unixtime) + OffsetFromUTC; + Result := GikoSys.GetCreateDateFromName(FFileName); if GikoSys.Setting.FutureThread then begin if CompareDateTime(Result, Now) = 1 then Result := ZERO_DATE; @@ -1877,6 +1828,53 @@ begin Result := ZERO_DATE; end; end; +function TThreadItem.GetFilePath: String; +var + path : String; +begin + path := ExtractFilePath(Self.ParentBoard.FilePath) + Self.FileName; + Result := path; +end; + +destructor TBoardGroup.Destroy; +begin + Clear; + inherited; +end; +procedure TBoardGroup.Clear; +var + i : Integer; +begin + for i := Self.Count - 1 downto 0 do begin + try + TBoard(Self.Objects[i]).Free; + except + end; + end; + inherited Clear; + Self.Capacity := 0; + try + if FBoardPlugIn <> nil then + FBoardPlugIn.Free; + FBoardPlugIn := nil; + except + end; + +end; + +function TSpecialBoard.Add(item: TThreadItem): integer; +begin + Result := inherited AddObject(Item.URL, Item); +end; + +procedure TSpecialBoard.Clear; +var + i: integer; +begin + for i := Count - 1 downto 0 do + DeleteList(i); + Capacity := 0; +end; end.