| 5 |
uses |
uses |
| 6 |
Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP, |
Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP, |
| 7 |
{HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,} |
{HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,} |
| 8 |
GikoSystem, BoardGroup, MonaUtils, ExternalBoardManager; |
GikoSystem, BoardGroup, MonaUtils, ExternalBoardManager, ExternalBoardPlugInMain, |
| 9 |
|
Sort; |
| 10 |
|
|
| 11 |
type |
type |
| 12 |
TDownloadItem = class; |
TDownloadItem = class; |
| 60 |
property Item: TDownloadItem read FItem write FItem; |
property Item: TDownloadItem read FItem write FItem; |
| 61 |
property Number: Integer read FNumber write FNumber; |
property Number: Integer read FNumber write FNumber; |
| 62 |
constructor Create(CreateSuspended: Boolean); |
constructor Create(CreateSuspended: Boolean); |
| 63 |
destructor Destroy; override; |
destructor Destroy; override; |
| 64 |
procedure Abort; |
procedure Abort; |
| 65 |
property OnWork: TGikoWorkEvent read FOnWork write FOnWork; |
property OnWork: TGikoWorkEvent read FOnWork write FOnWork; |
| 66 |
property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin; |
property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin; |
| 81 |
FResponseCode: Smallint; |
FResponseCode: Smallint; |
| 82 |
FState: TGikoDownloadState; |
FState: TGikoDownloadState; |
| 83 |
FErrText: string; |
FErrText: string; |
| 84 |
|
FForceDownload: Boolean; |
| 85 |
|
FIsAbone : Boolean; |
| 86 |
public |
public |
| 87 |
procedure SaveListFile; |
procedure SaveListFile; |
| 88 |
procedure SaveItemFile; |
procedure SaveItemFile; |
| 97 |
property ResponseCode: Smallint read FResponseCode write FResponseCode; |
property ResponseCode: Smallint read FResponseCode write FResponseCode; |
| 98 |
property State: TGikoDownloadState read FState write FState; |
property State: TGikoDownloadState read FState write FState; |
| 99 |
property ErrText: string read FErrText write FErrText; |
property ErrText: string read FErrText write FErrText; |
| 100 |
|
property ForceDownload: Boolean read FForceDownload write FForceDownload; |
| 101 |
|
property IsAbone : Boolean read FIsAbone write FIsAbone; |
| 102 |
end; |
end; |
| 103 |
|
|
| 104 |
implementation |
implementation |
| 122 |
FIndy.Response.RawHeaders.Clear; |
FIndy.Response.RawHeaders.Clear; |
| 123 |
FIndy.Response.Clear; |
FIndy.Response.Clear; |
| 124 |
FIndy.ProxyParams.Clear; |
FIndy.ProxyParams.Clear; |
|
|
|
| 125 |
FIndy.Free; |
FIndy.Free; |
| 126 |
inherited; |
inherited; |
| 127 |
end; |
end; |
| 156 |
Idx: Integer; |
Idx: Integer; |
| 157 |
ATitle: string; |
ATitle: string; |
| 158 |
DownloadResult: Boolean; |
DownloadResult: Boolean; |
|
Abone: Boolean; |
|
| 159 |
foundPos: Integer; |
foundPos: Integer; |
| 160 |
boardPlugIn : TBoardPlugIn; |
boardPlugIn : TBoardPlugIn; |
| 161 |
listContent : string; |
listContent : string; |
| 162 |
|
lastContent : string; |
| 163 |
|
logFile : TFileStream; |
| 164 |
|
adjustMargin : Integer; |
| 165 |
|
const |
| 166 |
|
ADJUST_MARGIN = 16; |
| 167 |
begin |
begin |
| 168 |
while not Terminated do begin |
while not Terminated do begin |
| 169 |
//===== プラグイン |
//===== プラグイン |
| 170 |
|
FAbort := False; |
| 171 |
boardPlugIn := nil; |
boardPlugIn := nil; |
| 172 |
ExternalBoardManager.OnWork := Work; |
ExternalBoardManager.OnWork := Work; |
| 173 |
ExternalBoardManager.OnWorkBegin := WorkBegin; |
ExternalBoardManager.OnWorkBegin := WorkBegin; |
| 200 |
FDownloadTitle := '(名称不明)'; |
FDownloadTitle := '(名称不明)'; |
| 201 |
|
|
| 202 |
if boardPlugIn <> nil then begin |
if boardPlugIn <> nil then begin |
| 203 |
if FAbort then |
if FAbort then begin |
| 204 |
Item.State := gdsAbort; |
Item.State := gdsAbort; |
| 205 |
|
end; |
| 206 |
if Assigned( OnDownloadEnd ) then |
if Assigned( OnDownloadEnd ) then |
| 207 |
Synchronize( FireDownloadEnd ); |
Synchronize( FireDownloadEnd ); |
| 208 |
if Terminated then |
if Terminated then |
| 256 |
{$ENDIF} |
{$ENDIF} |
| 257 |
end; |
end; |
| 258 |
|
|
| 259 |
|
adjustMargin := 0; |
| 260 |
|
if Item.DownType = gdtThread then begin |
| 261 |
|
if FileExists( Item.ThreadItem.GetThreadFileName ) then begin |
| 262 |
|
// dat ファイルの最後を読み出す |
| 263 |
|
SetLength( lastContent, ADJUST_MARGIN + 1 ); |
| 264 |
|
logFile := TFileStream.Create( Item.ThreadItem.GetThreadFileName, fmOpenRead or fmShareDenyWrite ); |
| 265 |
|
try |
| 266 |
|
logFile.Seek( -(ADJUST_MARGIN + 1), soFromEnd ); |
| 267 |
|
logFile.Read( lastContent[ 1 ], ADJUST_MARGIN + 1 ); |
| 268 |
|
lastContent := StringReplace( lastContent, #13, '', [] ); // CR の削除 |
| 269 |
|
finally |
| 270 |
|
logFile.Free; |
| 271 |
|
end; |
| 272 |
|
end else begin |
| 273 |
|
lastContent := ''; |
| 274 |
|
end; |
| 275 |
|
adjustMargin := Length( lastContent ); |
| 276 |
|
end; |
| 277 |
|
|
| 278 |
FIndy.Request.ContentRangeStart := 0; |
FIndy.Request.ContentRangeStart := 0; |
| 279 |
FIndy.Request.LastModified := ZERO_DATE; |
FIndy.Request.LastModified := ZERO_DATE; |
| 280 |
ResStream := TMemoryStream.Create; |
ResStream := TMemoryStream.Create; |
| 294 |
Writeln('Modified: ' + FloatToStr(Item.Board.LastModified)); |
Writeln('Modified: ' + FloatToStr(Item.Board.LastModified)); |
| 295 |
{$ENDIF} |
{$ENDIF} |
| 296 |
URL := Item.Board.GetReadCgiURL; |
URL := Item.Board.GetReadCgiURL; |
| 297 |
Modified := Item.Board.LastModified; |
if Item.ForceDownload then begin |
| 298 |
|
// 強制取得 |
| 299 |
|
ATitle := Item.Board.Title; |
| 300 |
|
if ATitle = '' then |
| 301 |
|
ATitle := '(名称不明)'; |
| 302 |
|
FMsg := '★強制取得を行います - [' + ATitle + ']'; |
| 303 |
|
FIcon := gmiWhat; |
| 304 |
|
if Assigned(OnDownloadMsg) then |
| 305 |
|
Synchronize(FireDownloadMsg); |
| 306 |
|
Modified := ZERO_DATE |
| 307 |
|
end else begin |
| 308 |
|
Modified := Item.Board.LastModified; |
| 309 |
|
end; |
| 310 |
end else if Item.DownType = gdtThread then begin |
end else if Item.DownType = gdtThread then begin |
| 311 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 312 |
Writeln('DAT取得'); |
Writeln('DAT取得'); |
| 314 |
Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified)); |
Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified)); |
| 315 |
{$ENDIF} |
{$ENDIF} |
| 316 |
URL := Item.ThreadItem.GetDatURL; |
URL := Item.ThreadItem.GetDatURL; |
| 317 |
Modified := Item.ThreadItem.LastModified; |
if Item.ForceDownload then begin |
| 318 |
if Item.ThreadItem.Size > 0 then begin |
// 強制取得 |
| 319 |
{$IFDEF DEBUG} |
ATitle := Item.ThreadItem.Title; |
| 320 |
Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size)); |
if ATitle = '' then |
| 321 |
{$ENDIF} |
ATitle := '(名称不明)'; |
| 322 |
//あぼーんチェックのため1バイト前から取得 |
FMsg := '★強制取得を行います - [' + ATitle + ']'; |
| 323 |
RangeStart := Item.ThreadItem.Size; |
FIcon := gmiWhat; |
| 324 |
AdjustLen := -1; |
if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then |
| 325 |
|
DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')); |
| 326 |
|
if Assigned(OnDownloadMsg) then |
| 327 |
|
Synchronize(FireDownloadMsg); |
| 328 |
|
Modified := ZERO_DATE; |
| 329 |
|
RangeStart := 0; |
| 330 |
|
AdjustLen := 0; |
| 331 |
|
end else begin |
| 332 |
|
Modified := Item.ThreadItem.LastModified; |
| 333 |
|
if Item.ThreadItem.Size > 0 then begin |
| 334 |
|
{$IFDEF DEBUG} |
| 335 |
|
Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size)); |
| 336 |
|
{$ENDIF} |
| 337 |
|
// あぼーんチェックのため adjustMargin バイト前から取得 |
| 338 |
|
RangeStart := Item.ThreadItem.Size; |
| 339 |
|
AdjustLen := -adjustMargin; |
| 340 |
|
end; |
| 341 |
end; |
end; |
| 342 |
end; |
end; |
| 343 |
Abone := False; |
Item.IsAbone := False; |
| 344 |
DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen); |
DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen); |
| 345 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 346 |
Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode)); |
Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode)); |
| 347 |
{$ENDIF} |
{$ENDIF} |
| 348 |
if Item.DownType = gdtThread then begin |
if Item.DownType = gdtThread then begin |
| 349 |
if Item.ResponseCode = 416 then begin |
if Item.ResponseCode = 416 then begin |
| 350 |
Abone := True; |
Item.IsAbone := True; |
| 351 |
DownloadResult := True; |
DownloadResult := True; |
| 352 |
end else if DownloadResult and (AdjustLen = -1) and (Item.Content[1] <> #10) then |
end else if DownloadResult and (AdjustLen < 0) then begin |
| 353 |
Abone := True; |
if Copy( Item.Content, 1, adjustMargin ) <> lastContent then |
| 354 |
|
Item.IsAbone := True; |
| 355 |
|
end; |
| 356 |
end; |
end; |
| 357 |
|
|
| 358 |
if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin |
if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin |
| 366 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 367 |
Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']); |
Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']); |
| 368 |
{$ENDIF} |
{$ENDIF} |
| 369 |
if Abone then begin |
if Item.IsAbone then begin |
| 370 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 371 |
Writeln('あぼーん検出'); |
Writeln('あぼーん検出'); |
| 372 |
{$ENDIF} |
{$ENDIF} |
| 388 |
Writeln('あぼーん再取得後'); |
Writeln('あぼーん再取得後'); |
| 389 |
Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode)); |
Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode)); |
| 390 |
{$ENDIF} |
{$ENDIF} |
| 391 |
end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin |
end else if (Item.DownType = gdtThread) and (AdjustLen < 0) then begin |
| 392 |
//差分取得かつ1バイト目がLFの場合(正常取得)は頭のLFを削除 |
// 差分取得が出来た場合はあぼーんチェック用に取得した余分なサイズを削除 |
| 393 |
Item.Content := Copy(Item.Content, 2, Length(Item.Content)); |
Item.Content := Copy(Item.Content, adjustMargin + 1, MaxInt); |
| 394 |
end; |
end; |
| 395 |
end else begin |
end else begin |
| 396 |
Item.State := gdsError; |
Item.State := gdsError; |
| 841 |
begin |
begin |
| 842 |
FAbort := True; |
FAbort := True; |
| 843 |
FIndy.DisconnectSocket; |
FIndy.DisconnectSocket; |
| 844 |
|
if socket <> nil then begin |
| 845 |
|
socket.DisconnectSocket; |
| 846 |
|
end; |
| 847 |
end; |
end; |
| 848 |
|
|
| 849 |
procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); |
procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); |
| 941 |
i: Integer; |
i: Integer; |
| 942 |
index: Integer; |
index: Integer; |
| 943 |
NewItem: TThreadItem; |
NewItem: TThreadItem; |
|
// SaveCount: Integer; |
|
| 944 |
NumCount: Integer; |
NumCount: Integer; |
| 945 |
Body: TStringList; |
Body: TStringList; |
| 946 |
Rec: TSubjectRec; |
Rec: TSubjectRec; |
| 970 |
_ThreadItem.RoundDate := ZERO_DATE; |
_ThreadItem.RoundDate := ZERO_DATE; |
| 971 |
_ThreadItem.LastModified := ZERO_DATE; |
_ThreadItem.LastModified := ZERO_DATE; |
| 972 |
_ThreadItem.AgeSage := gasNew; |
_ThreadItem.AgeSage := gasNew; |
| 973 |
boardItem.ListData.Add( _ThreadItem ); |
boardItem.Add(_ThreadItem); |
| 974 |
end else begin |
end else begin |
| 975 |
if boardItem.Items[index].No > boardItem.IntData then |
if boardItem.Items[index].No > boardItem.IntData then |
| 976 |
boardItem.Items[index].AgeSage := gasAge |
boardItem.Items[index].AgeSage := gasAge |
| 981 |
|
|
| 982 |
boardItem.Items[index].No := boardItem.IntData; |
boardItem.Items[index].No := boardItem.IntData; |
| 983 |
boardItem.Items[index].AllResCount := inCount; |
boardItem.Items[index].AllResCount := inCount; |
|
boardItem.ListData.Add( boardItem.Items[index] ); |
|
|
boardItem.DeleteList( index ); |
|
| 984 |
end; |
end; |
| 985 |
end; |
end; |
| 986 |
begin |
begin |
| 987 |
Board.ListData := TList.Create; |
//Board.ListData := TList.Create; |
| 988 |
Body := TStringList.Create; |
Body := TStringList.Create; |
| 989 |
try |
try |
| 990 |
//ダウンロード日時設定(ローカル日時) |
//ダウンロード日時設定(ローカル日時) |
| 992 |
//サーバ上ファイルの更新時刻設定 |
//サーバ上ファイルの更新時刻設定 |
| 993 |
Board.LastModified := LastModified; |
Board.LastModified := LastModified; |
| 994 |
|
|
| 995 |
|
//dat落ちスレのソート順を決定するためにソートする |
| 996 |
|
if GikoSys.Setting.DatOchiSortIndex >= 0 then begin |
| 997 |
|
Sort.SortNoFlag := true; |
| 998 |
|
Sort.SortOrder := GikoSys.Setting.DatOchiSortOrder; |
| 999 |
|
Sort.SortIndex := GikoSys.Setting.DatOchiSortIndex; |
| 1000 |
|
//Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount; |
| 1001 |
|
Board.CustomSort(ThreadItemSortProc); |
| 1002 |
|
end; |
| 1003 |
|
|
| 1004 |
|
for i := Board.Count - 1 downto 0 do |
| 1005 |
|
Board.Items[i].AgeSage := gasNull; |
| 1006 |
|
|
| 1007 |
if Board.IsBoardPlugInAvailable then begin |
if Board.IsBoardPlugInAvailable then begin |
| 1008 |
// 新しいリストを作成する |
// 新しいリストを作成する |
| 1009 |
// 新しいリストに古いリストのログがあるならそれを新しいリストに追加 |
// 新しいリストに古いリストのログがあるならそれを新しいリストに追加 |
| 1011 |
Board.IntData := 0; |
Board.IntData := 0; |
| 1012 |
Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack ); |
Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack ); |
| 1013 |
|
|
| 1014 |
|
//古いリストにしかないやつらを削除 |
| 1015 |
|
for i := Board.Count - 1 downto 0 do begin |
| 1016 |
|
if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then |
| 1017 |
|
Board.Delete(i); |
| 1018 |
|
end; |
| 1019 |
|
|
| 1020 |
// 新しいリストに無かったアイテムを新しいリストに追加 |
// 新しいリストに無かったアイテムを新しいリストに追加 |
| 1021 |
for i := 0 to Board.Count - 1 do begin |
for i := 0 to Board.Count - 1 do begin |
| 1022 |
if Board.Items[i].IsLogFile then begin |
if(Board.Items[i].AgeSage = gasNull) and (Board.Items[i].IsLogFile) then begin |
| 1023 |
Board.IntData := Board.IntData + 1; |
Board.IntData := Board.IntData + 1; |
| 1024 |
Board.Items[i].No := Board.IntData; |
Board.Items[i].No := Board.IntData; |
| 1025 |
Board.Items[i].AllResCount := Board.Items[i].Count; |
Board.Items[i].AllResCount := Board.Items[i].Count; |
| 1026 |
Board.Items[i].NewResCount := 0; |
Board.Items[i].NewResCount := 0; |
| 1027 |
Board.Items[i].AgeSage := gasNone; |
Board.Items[i].AgeSage := gasNone; |
|
Board.ListData.Add( Board.Items[i] ); |
|
| 1028 |
end; |
end; |
| 1029 |
end; |
end; |
|
|
|
|
// 古いリストを消す(リストのみ。スレオブジェクト自体は消さない) |
|
|
for i := Board.Count - 1 downto 0 do |
|
|
Board.DeleteList( i ); |
|
|
|
|
|
// 新しいリストをボードオブジェクトに追加 |
|
|
for i := 0 to Board.ListData.Count - 1 do |
|
|
Board.Add( TThreadItem(Board.ListData[i]) ); |
|
| 1030 |
end else begin |
end else begin |
| 1031 |
//新しいリストを作成する |
//新しいリストを作成する |
| 1032 |
//新しいリストに古いリストのログがあるならそれを新しいリストに追加 |
//新しいリストに古いリストのログがあるならそれを新しいリストに追加 |
| 1034 |
Body.Text := Content; |
Body.Text := Content; |
| 1035 |
NumCount := 0; |
NumCount := 0; |
| 1036 |
for i := 0 to Body.Count - 1 do begin |
for i := 0 to Body.Count - 1 do begin |
|
//if i = 0 then Continue; //1行目はステータス行のため処理なし |
|
|
|
|
| 1037 |
Rec := GikoSys.DivideSubject(Body[i]); |
Rec := GikoSys.DivideSubject(Body[i]); |
| 1038 |
Rec.FFileName := Trim(Rec.FFileName); |
Rec.FFileName := Trim(Rec.FFileName); |
| 1039 |
if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue; |
if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue; |
| 1042 |
if index = -1 then begin |
if index = -1 then begin |
| 1043 |
//新しいスレッド |
//新しいスレッド |
| 1044 |
NewItem := TThreadItem.Create( |
NewItem := TThreadItem.Create( |
| 1045 |
nil, GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) ); |
nil, GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) ); |
| 1046 |
NewItem.Title := Rec.FTitle; |
NewItem.Title := Rec.FTitle; |
| 1047 |
NewItem.AllResCount := Rec.FCount; |
NewItem.AllResCount := Rec.FCount; |
| 1048 |
NewItem.ParentBoard := Board; |
NewItem.ParentBoard := Board; |
| 1050 |
NewItem.RoundDate := ZERO_DATE; |
NewItem.RoundDate := ZERO_DATE; |
| 1051 |
NewItem.LastModified := ZERO_DATE; |
NewItem.LastModified := ZERO_DATE; |
| 1052 |
NewItem.AgeSage := gasNew; |
NewItem.AgeSage := gasNew; |
| 1053 |
Board.ListData.Add(NewItem); |
Board.Add(NewItem); |
| 1054 |
end else begin |
end else begin |
| 1055 |
if Board.Items[index].No > NumCount then |
if Board.Items[index].No > NumCount then |
| 1056 |
Board.Items[index].AgeSage := gasAge |
Board.Items[index].AgeSage := gasAge |
| 1061 |
|
|
| 1062 |
Board.Items[index].No := NumCount; |
Board.Items[index].No := NumCount; |
| 1063 |
Board.Items[index].AllResCount := Rec.FCount; |
Board.Items[index].AllResCount := Rec.FCount; |
|
Board.ListData.Add(Board.Items[index]); |
|
|
Board.DeleteList(index); |
|
| 1064 |
end; |
end; |
| 1065 |
end; |
end; |
| 1066 |
|
//古いリストの削除 |
| 1067 |
|
for i := Board.Count - 1 downto 0 do begin |
| 1068 |
|
if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then |
| 1069 |
|
Board.Delete(i); |
| 1070 |
|
end; |
| 1071 |
|
|
| 1072 |
//新しいリストに無かったアイテムを新しいリストに追加 |
//新しいリストに無かったアイテムの更新 |
| 1073 |
for i := 0 to Board.Count - 1 do begin |
for i := 0 to Board.Count - 1 do begin |
| 1074 |
if Board.Items[i].IsLogFile then begin |
if( Board.Items[i].AgeSage = gasNull )and (Board.Items[i].IsLogFile) then begin |
| 1075 |
inc(NumCount); |
inc(NumCount); |
| 1076 |
Board.Items[i].No := NumCount; |
Board.Items[i].No := NumCount; |
| 1077 |
Board.Items[i].AllResCount := Board.Items[i].Count; |
Board.Items[i].AllResCount := Board.Items[i].Count; |
| 1078 |
Board.Items[i].NewResCount := 0; |
Board.Items[i].NewResCount := 0; |
| 1079 |
Board.Items[i].AgeSage := gasNone; |
Board.Items[i].AgeSage := gasNone; |
|
Board.ListData.Add(Board.Items[i]); |
|
| 1080 |
end; |
end; |
| 1081 |
end; |
end; |
|
|
|
|
//古いリストを消す(リストのみ。スレオブジェクト自体は消さない) |
|
|
for i := Board.Count - 1 downto 0 do |
|
|
Board.DeleteList(i); |
|
|
|
|
|
//新しいリストをボードオブジェクトに追加 |
|
|
for i := 0 to Board.ListData.Count - 1 do |
|
|
Board.Add(TThreadItem(Board.ListData[i])); |
|
|
|
|
| 1082 |
//リスト(subject.txt)を保存 |
//リスト(subject.txt)を保存 |
|
// GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID); |
|
|
// Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID)); |
|
| 1083 |
GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName)); |
GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName)); |
| 1084 |
Body.SaveToFile(Board.GetSubjectFileName); |
Body.SaveToFile(Board.GetSubjectFileName); |
| 1085 |
end; |
end; |
| 1086 |
finally |
finally |
| 1087 |
Body.Free; |
Body.Free; |
|
Board.ListData.Free; |
|
| 1088 |
end; |
end; |
| 1089 |
|
|
| 1090 |
|
|
| 1091 |
end; |
end; |
| 1092 |
|
|
| 1093 |
{procedure TDownloadItem.SaveListFile; |
{procedure TDownloadItem.SaveListFile; |
| 1184 |
ini: TMemIniFile; |
ini: TMemIniFile; |
| 1185 |
Res: TResRec; |
Res: TResRec; |
| 1186 |
NewRes: Integer; |
NewRes: Integer; |
| 1187 |
finish : Boolean; |
finish : Boolean; |
| 1188 |
loopCnt : Integer; |
loopCnt : Integer; |
| 1189 |
|
KokoTxt : string; |
| 1190 |
|
KokoIdx : Integer; |
| 1191 |
|
NewTxt : string; |
| 1192 |
|
NewIdx : Integer; |
| 1193 |
|
LastTxt : string; |
| 1194 |
|
LastIdx : Integer; |
| 1195 |
begin |
begin |
| 1196 |
FileName := ThreadItem.GetThreadFileName; |
FileName := ThreadItem.GetThreadFileName; |
| 1197 |
|
|
| 1198 |
if not ThreadItem.IsBoardPlugInAvailable then begin |
if not ThreadItem.IsBoardPlugInAvailable then begin |
| 1199 |
if Trim(Content) = '' then |
if Trim(Content) = '' then |
| 1200 |
Exit; |
Exit; |
| 1201 |
|
|
| 1202 |
GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName)); |
GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName)); |
| 1203 |
|
|
| 1204 |
// Cnt := 0; |
// Cnt := 0; |
| 1205 |
Body := TStringList.Create; |
Body := TStringList.Create; |
| 1206 |
NewRes := 0; |
NewRes := 0; |
| 1207 |
OldCnt := 0; |
OldCnt := 0; |
| 1208 |
try |
try |
| 1209 |
// if FileExists(FileName) and (ResponseCode = 206) then begin |
// if FileExists(FileName) and (ResponseCode = 206) then begin |
| 1210 |
if FileExists(FileName) and (State = gdsDiffComplete) then begin |
if FileExists(FileName) and (State = gdsDiffComplete) then begin |
| 1211 |
// Body.Text := Content; |
// Body.Text := Content; |
| 1212 |
// if Body.Count > 0 then |
// if Body.Count > 0 then |
| 1213 |
// Body.Delete(0); |
// Body.Delete(0); |
| 1214 |
// Content := Body.Text; |
// Content := Body.Text; |
| 1215 |
loopCnt := 10; |
loopCnt := 10; |
| 1216 |
repeat |
repeat |
| 1217 |
finish := true; |
finish := true; |
| 1218 |
try |
try |
| 1219 |
Body.LoadFromFile(FileName); |
Body.LoadFromFile(FileName); |
| 1220 |
OldCnt := Body.Count; |
OldCnt := Body.Count; |
| 1221 |
Body.Text := Body.Text + Content; |
Body.Text := Body.Text + Content; |
| 1222 |
Body.SaveToFile(FileName); |
Body.SaveToFile(FileName); |
| 1223 |
NewRes := Body.Count - OldCnt; |
NewRes := Body.Count - OldCnt; |
| 1224 |
except |
except |
| 1225 |
on E:EFOpenError do begin |
on E:EFOpenError do begin |
| 1226 |
sleep(10); |
sleep(10); |
| 1227 |
finish := false; |
finish := false; |
| 1228 |
Dec(loopCnt); |
Dec(loopCnt); |
| 1229 |
end; |
end; |
| 1230 |
end; |
end; |
| 1231 |
until finish and ( loopCnt > 0 ); |
until finish and ( loopCnt > 0 ); |
| 1232 |
//Cnt := Body.Count; |
//Cnt := Body.Count; |
| 1233 |
end else begin |
end else begin |
| 1234 |
Body.Text := Content; |
if IsAbone then begin |
| 1235 |
|
// あぼーんを検出したのでここまで読んだと新着レス番のつけなおし |
| 1236 |
|
loopCnt := 10; |
| 1237 |
|
repeat |
| 1238 |
|
finish := true; |
| 1239 |
|
try |
| 1240 |
|
Body.LoadFromFile(FileName); |
| 1241 |
|
except |
| 1242 |
|
on E:EFOpenError do begin |
| 1243 |
|
sleep(10); |
| 1244 |
|
finish := false; |
| 1245 |
|
Dec(loopCnt); |
| 1246 |
|
end; |
| 1247 |
|
end; |
| 1248 |
|
until finish and ( loopCnt > 0 ); |
| 1249 |
|
LastTxt := Body.Strings[ Body.Count - 1 ]; |
| 1250 |
|
if ThreadItem.Kokomade > 0 then begin |
| 1251 |
|
KokoTxt := Body.Strings[ ThreadItem.Kokomade - 1 ]; |
| 1252 |
|
end; |
| 1253 |
|
if ThreadItem.NewReceive > 0 then begin |
| 1254 |
|
NewTxt := Body.Strings[ ThreadItem.NewReceive - 1 ]; |
| 1255 |
|
end; |
| 1256 |
|
|
| 1257 |
|
Body.Text := Content; |
| 1258 |
|
Body.Find( LastTxt, LastIdx ); |
| 1259 |
|
OldCnt := LastIdx + 1; |
| 1260 |
|
NewRes := Body.Count - OldCnt; |
| 1261 |
|
|
| 1262 |
|
if ThreadItem.Kokomade > 0 then begin |
| 1263 |
|
Body.Find( KokoTxt, KokoIdx ); |
| 1264 |
|
ThreadItem.Kokomade := KokoIdx + 1; |
| 1265 |
|
end; |
| 1266 |
|
if ThreadItem.NewReceive > 0 then begin |
| 1267 |
|
Body.Find( NewTxt, NewIdx ); |
| 1268 |
|
Inc( NewIdx ); |
| 1269 |
|
if OldCnt < NewIdx then begin |
| 1270 |
|
OldCnt := NewIdx; |
| 1271 |
|
NewRes := Body.Count - NewIdx; |
| 1272 |
|
end; |
| 1273 |
|
end; |
| 1274 |
|
end else begin |
| 1275 |
|
Body.Text := Content; |
| 1276 |
|
//ThreadItem.Count := 0; |
| 1277 |
|
OldCnt := 0; |
| 1278 |
|
NewRes := Body.Count; |
| 1279 |
|
//Cnt := Body.Count; |
| 1280 |
|
end; |
| 1281 |
// if Body.Count > 0 then |
// if Body.Count > 0 then |
| 1282 |
// Body.Delete(0); |
// Body.Delete(0); |
| 1283 |
Body.SaveToFile(FileName); |
Body.SaveToFile(FileName); |
| 1287 |
ThreadItem.Title := Res.FTitle; |
ThreadItem.Title := Res.FTitle; |
| 1288 |
end; |
end; |
| 1289 |
ThreadItem.Size := 0; |
ThreadItem.Size := 0; |
|
//ThreadItem.Count := 0; |
|
|
ThreadItem.AllResCount := 0; |
|
|
ThreadItem.NewResCount := 0; |
|
|
OldCnt := 0; |
|
|
NewRes := Body.Count; |
|
|
//Cnt := Body.Count; |
|
| 1290 |
end; |
end; |
| 1291 |
Cnt := Body.Count; |
Cnt := Body.Count; |
| 1292 |
finally |
finally |
| 1293 |
Body.Free; |
Body.Free; |
| 1294 |
end; |
end; |
| 1295 |
|
|
| 1296 |
ThreadItem.Size := ThreadItem.Size + ContentLength; |
ThreadItem.Size := ThreadItem.Size + ContentLength; |
| 1297 |
ThreadItem.LastModified := LastModified; |
ThreadItem.LastModified := LastModified; |
| 1298 |
ThreadItem.Count := Cnt; |
ThreadItem.Count := Cnt; |
| 1300 |
ThreadItem.NewResCount := NewRes; |
ThreadItem.NewResCount := NewRes; |
| 1301 |
ThreadItem.NewReceive := OldCnt + 1; |
ThreadItem.NewReceive := OldCnt + 1; |
| 1302 |
end; |
end; |
| 1303 |
ThreadItem.AllResCount := ThreadItem.Count; |
ThreadItem.AllResCount := ThreadItem.Count; |
| 1304 |
ThreadItem.IsLogFile := True; |
ThreadItem.IsLogFile := True; |
| 1305 |
ThreadItem.RoundDate := Now; |
ThreadItem.RoundDate := Now; |
| 1306 |
ThreadItem.UnRead := True; |
ThreadItem.UnRead := True; |
| 1323 |
// ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo); |
// ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo); |
| 1324 |
ini.WriteBool('Setting', 'Round', ThreadItem.Round); |
ini.WriteBool('Setting', 'Round', ThreadItem.Round); |
| 1325 |
ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead); |
ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead); |
| 1326 |
ini.UpdateFile; |
ini.UpdateFile; |
| 1327 |
finally |
finally |
| 1328 |
ini.Free; |
ini.Free; |
| 1329 |
end; |
end; |