6 Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP,
7 {HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,}
8 GikoSystem, BoardGroup, MonaUtils, ExternalBoardManager, ExternalBoardPlugInMain;
11 TDownloadItem = class;
12 TGikoDownloadType = (gdtBoard, gdtThread);
13 TGikoDownloadState = (gdsWait, gdsWork, gdsComplete, gdsDiffComplete, gdsNotModify, gdsAbort, gdsError);
14 TGikoCgiStatus = (gcsOK, gcsINCR, gcsERR);
15 TGikoDLProgress = (gdpStd, gdpAll, gdpDatOchi, gdpOfflaw);
17 TGikoWorkEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; ID: Integer) of object;
18 TGikoWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; ID: Integer; const AWorkTitle: string) of object;
19 TGikoWorkEndEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; ID: Integer) of object;
20 TDownloadEndEvent = procedure(Sender: TObject; Item: TDownloadItem) of object;
21 TDownloadMsgEvent = procedure(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon) of object;
24 FStatus: TGikoCgiStatus;
30 TDownloadThread = class(TThread)
37 FIcon: TGikoMessageIcon;
39 FOnWork: TGikoWorkEvent;
40 FOnWorkBegin: TGikoWorkBeginEvent;
41 FOnWorkEnd: TGikoWorkEndEvent;
42 FOnDownloadEnd: TDownloadEndEvent;
43 FOnDownloadMsg: TDownloadMsgEvent;
44 FDownloadTitle: string;
46 procedure FireDownloadEnd;
47 procedure FireDownloadMsg;
48 procedure GetSessionID;
49 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
50 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
51 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
52 function ParseCgiStatus(Content: string): TCgiStatus;
53 function CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
54 function DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
55 function DeleteStatusLine(Content: string): string;
57 procedure Execute; override;
59 property Item: TDownloadItem read FItem write FItem;
60 property Number: Integer read FNumber write FNumber;
61 constructor Create(CreateSuspended: Boolean);
62 destructor Destroy; override;
64 property OnWork: TGikoWorkEvent read FOnWork write FOnWork;
65 property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin;
66 property OnWorkEnd: TGikoWorkEndEvent read FOnWorkEnd write FOnWorkEnd;
67 property OnDownloadEnd: TDownloadEndEvent read FOnDownloadEnd write FOnDownloadEnd;
68 property OnDownloadMsg: TDownloadMsgEvent read FOnDownloadMsg write FOnDownloadMsg;
71 TDownloadItem = class(TObject)
73 FDownType: TGikoDownloadType;
75 FThreadItem: TThreadItem;
77 FContentLength: Integer;
78 FLastModified: TDateTime;
80 FResponseCode: Smallint;
81 FState: TGikoDownloadState;
83 FForceDownload: Boolean;
86 procedure SaveListFile;
87 procedure SaveItemFile;
89 property DownType: TGikoDownloadType read FDownType write FDownType;
90 property Board: TBoard read FBoard write FBoard;
91 property ThreadItem: TThreadItem read FThreadItem write FThreadItem;
93 property ContentLength: Integer read FContentLength write FContentLength;
94 property LastModified: TDateTime read FLastModified write FLastModified;
95 property Content: string read FContent write FContent;
96 property ResponseCode: Smallint read FResponseCode write FResponseCode;
97 property State: TGikoDownloadState read FState write FState;
98 property ErrText: string read FErrText write FErrText;
99 property ForceDownload: Boolean read FForceDownload write FForceDownload;
100 property IsAbone : Boolean read FIsAbone write FIsAbone;
105 constructor TDownloadThread.Create(CreateSuspended: Boolean);
107 inherited Create(CreateSuspended);
108 FIndy := TIdHttp.Create(nil);
110 FIndy.OnWorkBegin := WorkBegin;
111 FIndy.OnWorkEnd := WorkEnd;
112 FIndy.OnWork := Work;
115 destructor TDownloadThread.Destroy;
117 FIndy.Request.CustomHeaders.Clear;
118 FIndy.Request.RawHeaders.Clear;
120 FIndy.Response.CustomHeaders.Clear;
121 FIndy.Response.RawHeaders.Clear;
122 FIndy.Response.Clear;
123 FIndy.ProxyParams.Clear;
128 function RFC1123_Date(aDate : TDateTime) : String;
130 StrWeekDay : String = 'MonTueWedThuFriSatSun';
131 StrMonth : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
133 Year, Month, Day : Word;
134 Hour, Min, Sec, MSec : Word;
137 DecodeDate(aDate, Year, Month, Day);
138 DecodeTime(aDate, Hour, Min, Sec, MSec);
139 DayOfWeek := ((Trunc(aDate) - 2) mod 7);
140 Result := Copy(StrWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
141 Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
142 [Day, Copy(StrMonth, 1 + 3 * (Month - 1), 3),
143 Year, Hour, Min, Sec]);
146 procedure TDownloadThread.Execute;
148 ResStream: TMemoryStream;
151 CgiStatus: TCgiStatus;
157 DownloadResult: Boolean;
159 boardPlugIn : TBoardPlugIn;
160 listContent : string;
161 lastContent : string;
162 logFile : TFileStream;
163 adjustMargin : Integer;
167 while not Terminated do begin
168 //=====
\83v
\83\89\83O
\83C
\83\93
171 ExternalBoardManager.OnWork := Work;
172 ExternalBoardManager.OnWorkBegin := WorkBegin;
173 ExternalBoardManager.OnWorkEnd := WorkEnd;
175 FDownloadTitle := '';
176 case FItem.FDownType of
179 FDownloadTitle := FItem.FBoard.Title;
180 if FItem.FBoard <> nil then begin
181 if FItem.FBoard.IsBoardPlugInAvailable then begin
182 boardPlugIn := FItem.FBoard.BoardPlugIn;
183 Item.State := TGikoDownloadState( boardPlugIn.DownloadBoard( DWORD( FItem.FBoard ) ) );
189 FDownloadTitle := FItem.FThreadItem.Title;
190 if FItem.FThreadItem <> nil then begin
191 if FItem.FThreadItem.IsBoardPlugInAvailable then begin
192 boardPlugIn := FItem.FThreadItem.BoardPlugIn;
193 Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
198 if Length(FDownloadTitle) = 0 then
199 FDownloadTitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
201 if boardPlugIn <> nil then begin
203 Item.State := gdsAbort;
205 if Assigned( OnDownloadEnd ) then
206 Synchronize( FireDownloadEnd );
214 //=====
\83v
\83\89\83O
\83C
\83\93\82ð
\8eg
\97p
\82µ
\82È
\82¢
\8fê
\8d\87
216 FIndy.Request.CustomHeaders.Clear;
217 FIndy.Response.Clear;
219 FIndy.ProxyParams.Clear;
221 FIndy.Request.UserAgent := GikoSys.GetUserAgent;
222 FIndy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
223 FIndy.ProxyParams.BasicAuthentication := False;
225 Writeln('------------------------------------------------------------');
227 //FIndy.AllowCookies := False;
228 if GikoSys.Setting.ReadProxy then begin
229 if GikoSys.Setting.ProxyProtocol then
230 FIndy.ProtocolVersion := pv1_1
232 FIndy.ProtocolVersion := pv1_0;
233 FIndy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
234 FIndy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
235 FIndy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
236 FIndy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
237 if GikoSys.Setting.ReadProxyUserID <> '' then
238 FIndy.ProxyParams.BasicAuthentication := True;
240 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
241 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
242 Writeln('
\83|
\81[
\83g: ' + IntToStr(GikoSys.Setting.ReadProxyPort));
245 if GikoSys.Setting.Protocol then
246 FIndy.ProtocolVersion := pv1_1
248 FIndy.ProtocolVersion := pv1_0;
249 FIndy.ProxyParams.ProxyServer := '';
250 FIndy.ProxyParams.ProxyPort := 80;
251 FIndy.ProxyParams.ProxyUsername := '';
252 FIndy.ProxyParams.ProxyPassword := '';
254 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
259 if Item.DownType = gdtThread then begin
260 if FileExists( Item.ThreadItem.GetThreadFileName ) then begin
261 // dat
\83t
\83@
\83C
\83\8b\82Ì
\8dÅ
\8cã
\82ð
\93Ç
\82Ý
\8fo
\82·
262 SetLength( lastContent, ADJUST_MARGIN + 1 );
263 logFile := TFileStream.Create( Item.ThreadItem.GetThreadFileName, fmOpenRead or fmShareDenyWrite );
265 logFile.Seek( -(ADJUST_MARGIN + 1), soFromEnd );
266 logFile.Read( lastContent[ 1 ], ADJUST_MARGIN + 1 );
267 lastContent := StringReplace( lastContent, #13, '', [] ); // CR
\82Ì
\8dí
\8f\9c
274 adjustMargin := Length( lastContent );
277 FIndy.Request.ContentRangeStart := 0;
278 FIndy.Request.LastModified := ZERO_DATE;
279 ResStream := TMemoryStream.Create;
282 //********************
283 //DAT or Subject
\8eæ
\93¾
284 //********************
285 Item.ResponseCode := 0;
289 if Item.DownType = gdtBoard then begin
291 Writeln('Subject
\8eæ
\93¾');
292 Writeln('URL: ' + Item.Board.GetReadCgiURL);
293 Writeln('Modified: ' + FloatToStr(Item.Board.LastModified));
295 URL := Item.Board.GetReadCgiURL;
296 if Item.ForceDownload then begin
298 ATitle := Item.Board.Title;
300 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
301 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
303 if Assigned(OnDownloadMsg) then
304 Synchronize(FireDownloadMsg);
305 Modified := ZERO_DATE
307 Modified := Item.Board.LastModified;
309 end else if Item.DownType = gdtThread then begin
311 Writeln('DAT
\8eæ
\93¾');
312 Writeln('URL: ' + Item.ThreadItem.GetDatURL);
313 Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified));
315 URL := Item.ThreadItem.GetDatURL;
316 if Item.ForceDownload then begin
318 ATitle := Item.ThreadItem.Title;
320 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
321 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
323 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
324 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
325 if Assigned(OnDownloadMsg) then
326 Synchronize(FireDownloadMsg);
327 Modified := ZERO_DATE;
331 Modified := Item.ThreadItem.LastModified;
332 if Item.ThreadItem.Size > 0 then begin
334 Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size));
336 //
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
\82Ì
\82½
\82ß adjustMargin
\83o
\83C
\83g
\91O
\82©
\82ç
\8eæ
\93¾
337 RangeStart := Item.ThreadItem.Size;
338 AdjustLen := -adjustMargin;
342 Item.IsAbone := False;
343 DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen);
345 Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode));
347 if Item.DownType = gdtThread then begin
348 if Item.ResponseCode = 416 then begin
349 Item.IsAbone := True;
350 DownloadResult := True;
351 end else if DownloadResult and (AdjustLen < 0) then begin
352 if Copy( Item.Content, 1, adjustMargin ) <> lastContent then
353 Item.IsAbone := True;
357 if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin
358 if Item.DownType = gdtBoard then
359 Item.Board.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date'])
361 Item.ThreadItem.ParentBoard.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date']);
364 if DownloadResult then begin
366 Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']);
368 if Item.IsAbone then begin
370 Writeln('
\82 \82Ú
\81[
\82ñ
\8c\9f\8fo');
372 ATitle := Item.ThreadItem.Title;
374 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
375 //
\8d·
\95ª
\8eæ
\93¾
\82©
\82Â
\82P
\83o
\83C
\83g
\96Ú
\82ªLF
\82Å
\82È
\82¢
\8fê
\8d\87\82Í
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82³
\82ê
\82Ä
\82¢
\82é
\82©
\82à
\82µ
\82ê
\82ñ
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
378 FMsg := '
\81\9a\81u
\82 \82Ú
\81[
\82ñ
\81v
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
380 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
381 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
382 if Assigned(OnDownloadMsg) then
383 Synchronize(FireDownloadMsg);
384 if not DatDownload(Item.DownType, URL, ZERO_DATE, RangeStart, AdjustLen) then
385 Item.State := gdsError;
387 Writeln('
\82 \82Ú
\81[
\82ñ
\8dÄ
\8eæ
\93¾
\8cã');
388 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
390 end else if (Item.DownType = gdtThread) and (AdjustLen < 0) then begin
391 //
\8d·
\95ª
\8eæ
\93¾
\82ª
\8fo
\97\88\82½
\8fê
\8d\87\82Í
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
\97p
\82É
\8eæ
\93¾
\82µ
\82½
\97]
\95ª
\82È
\83T
\83C
\83Y
\82ð
\8dí
\8f\9c
392 Item.Content := Copy(Item.Content, adjustMargin + 1, MaxInt);
395 Item.State := gdsError;
396 if (Item.DownType = gdtBoard) and (Item.ResponseCode = 302) then begin
397 FMsg := '
\81\9a\81\9a\94Â
\82ª
\88Ú
\93]
\82µ
\82½
\82©
\82à
\82µ
\82ê
\82È
\82¢
\82Ì
\82Å
\94Â
\8dX
\90V
\82ð
\8ds
\82Á
\82Ä
\82
\82¾
\82³
\82¢
\81\9a\81\9a';
399 if Assigned(OnDownloadMsg) then
400 Synchronize(FireDownloadMsg);
404 //********************
406 //********************
407 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
409 Writeln('dat.gz
\8eæ
\93¾');
411 ATitle := Item.ThreadItem.Title;
413 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
414 FMsg := '
\81\9adat
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ß
\89ß
\8b\8e\83\8d\83O(dat.gz)
\82ð
\92T
\82µ
\82Ü
\82· - [' + ATitle + ']';
416 if Assigned(OnDownloadMsg) then
417 Synchronize(FireDownloadMsg);
418 URL := Item.ThreadItem.GetDatgzURL;
419 Modified := Item.ThreadItem.LastModified;
422 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
423 Item.State := gdsError;
425 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
429 //********************
431 //********************
433 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
434 ATitle := Item.ThreadItem.Title;
436 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
437 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O(1)
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ß
\89ß
\8b\8e\83\8d\83O(2)
\82©
\82ç
\92T
\82µ
\82Ü
\82· - [' + ATitle + ']';
439 if Assigned(OnDownloadMsg) then
440 Synchronize(FireDownloadMsg);
441 URL := Item.ThreadItem.GetOldDatgzURL;
442 Modified := Item.ThreadItem.LastModified;
445 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
446 Item.State := gdsError;
450 //********************
451 //offlaw.cgi
\82Å
\8eæ
\93¾
452 //********************
454 Synchronize(GetSessionID);
455 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID <> '') then begin
457 Writeln('offlaw.cgi
\82Å
\8eæ
\93¾');
459 ATitle := Item.ThreadItem.Title;
461 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
462 FMsg := '
\81\9adat.gz
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ßofflaw.cgi
\82ð
\97\98\97p
\82µ
\82Ü
\82· - [' + ATitle + ']';
464 if Assigned(OnDownloadMsg) then
465 Synchronize(FireDownloadMsg);
466 URL := Item.ThreadItem.GetOfflawCgiURL(FSessionID);
467 Modified := Item.ThreadItem.LastModified;
470 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then begin
472 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
474 Item.State := gdsError;
476 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
477 FMsg := '
\94Â
\82ª
\88Ú
\93]
\82µ
\82½
\82©
\82à
\82µ
\82ê
\82È
\82¢
\82Ì
\82Å
\94Â
\8dX
\90V
\82ð
\8ds
\82Á
\82Ä
\82
\82¾
\82³
\82¢
\81B';
479 if Assigned(OnDownloadMsg) then
480 Synchronize(FireDownloadMsg);
484 CgiStatus := ParseCgiStatus(Item.Content);
486 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
488 case CgiStatus.FStatus of
491 Writeln('CGIStatus: OK');
493 Item.ResponseCode := 200;
494 Item.Content := DeleteStatusLine(Item.Content);
495 Item.ContentLength := CgiStatus.FSize;
498 //
\8d¡
\82Í
\82 \82è
\82¦
\82È
\82¢
500 Writeln('CGIStatus: 206');
502 Item.ResponseCode := 206;
503 Item.Content := DeleteStatusLine(Item.Content);
504 Item.ContentLength := CgiStatus.FSize;
508 Writeln('CGIStatus: 404(ERROR)');
510 Item.ResponseCode := 404;
511 Item.State := gdsError;
512 Item.ErrText := CgiStatus.FErrText;
515 if (Item.ResponseCode = 404) and (AnsiPos('
\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c©', Item.ErrText) <> 0) then begin
517 Writeln('
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾');
519 ATitle := Item.ThreadItem.Title;
521 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
522 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c© - [' + ATitle + ']';
524 if Assigned(OnDownloadMsg) then
525 Synchronize(FireDownloadMsg);
526 Idx := Pos(' ', Item.ErrText);
527 if Idx <> 0 then begin
528 URL := Copy(Item.ErrText, Idx + 1, Length(Item.ErrText));
529 if Pos( '://', URL ) = 0 then begin
530 if Pos('../', URL) = 1 then
531 URL := Copy(URL, 4, MaxInt );
532 if Pos( '/', URL ) = 1 then
533 URL := Copy( URL, 2, MaxInt );
534 URL := GikoSys.UrlToServer(Item.ThreadItem.ParentBoard.URL) + URL;
536 Modified := Item.ThreadItem.LastModified;
539 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
540 Item.State := gdsError;
542 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
548 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID = '') then begin
550 Writeln('
\83\8d\83O
\83C
\83\93\82³
\82ê
\82Ä
\82È
\82¢
\82Ì
\82Å
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾
\95s
\89Â');
552 ATitle := Item.ThreadItem.Title;
554 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
555 FMsg := '
\81\9a\83\8d\83O
\83C
\83\93\82³
\82ê
\82Ä
\82¢
\82È
\82¢
\82½
\82ß
\92T
\82·
\82±
\82Æ
\82ª
\8fo
\97\88\82Ü
\82¹
\82ñ - [' + ATitle + ']';
557 if Assigned(OnDownloadMsg) then
558 Synchronize(FireDownloadMsg);
562 case Item.ResponseCode of
563 200: Item.State := gdsComplete;
564 206: Item.State := gdsDiffComplete;
565 304: Item.State := gdsNotModify;
567 Item.State := gdsError;
570 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
571 if (Item.ResponseCode in [200, 206]) and (Item.Content = '') then
572 Item.State := gdsError;
573 Item.LastModified := FIndy.Response.LastModified;
574 //
\8d·
\95ª
\8eæ
\93¾
\82Å
\82P
\83o
\83C
\83g
\91O
\82©
\82ç
\82Æ
\82Á
\82Ä
\82«
\82½
\82Æ
\82«
\82Í
\83}
\83C
\83i
\83X
\82·
\82é
575 Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
578 FIndy.Get(URL, ResStream);
579 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
580 if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] <> #10) then begin
581 //
\8d·
\95ª
\8eæ
\93¾
\82©
\82Â
\82P
\83o
\83C
\83g
\96Ú
\82ªLF
\82Å
\82È
\82¢
\8fê
\8d\87\82Í
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82³
\82ê
\82Ä
\82¢
\82é
\82©
\82à
\82µ
\82ê
\82ñ
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
582 //
\82±
\82±
\82Å
\83\81\83b
\83Z
\81[
\83W
\95\
\8e¦
\83C
\83x
\83\93\83g
584 FMsg := '
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82·';
585 if Assigned(OnDownloadMsg) then
586 Synchronize(FireDownloadMsg);
587 FIndy.Request.ContentRangeStart := 0;
588 FIndy.Request.ContentRangeEnd := 0;
591 FIndy.Get(URL, ResStream);
592 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
593 end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin
594 //
\8d·
\95ª
\8eæ
\93¾
\82©
\82Â
\82P
\83o
\83C
\83g
\96Ú
\82ªLF
\82Ì
\8fê
\8d\87\81i
\90³
\8fí
\8eæ
\93¾
\81j
\82Í
\93ª
\82ÌLF
\82ð
\8dí
\8f\9c
595 Item.Content := Copy(Item.Content, 2, Length(Item.Content));
598 Item.State := gdsError;
600 Item.ResponseCode := FIndy.ResponseCode;
605 FIndy.Get(URL, ResStream);
606 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
608 Item.State := gdsError;
611 CgiStatus := ParseCgiStatus(Item.Content);
612 if CgiStatus.FStatus = gcsOK then begin
613 if CgiStatus.FSize = 0 then
614 Item.State := gdsNotModify
615 else if Item.DownType = gdtBoard then
616 Item.State := gdsComplete
618 Item.State := gdsDiffComplete;
619 end else if CgiStatus.FStatus = gcsINCR then begin
620 Item.State := gdsComplete;
621 end else if CgiStatus.FStatus = gcsERR then begin
622 Item.State := gdsError;
623 Item.ErrText := CgiStatus.FErrText;
625 Item.ContentLength := CgiStatus.FSize;
628 Item.State := gdsError;
630 //Item.ResponseCode := FIndy.ResponseCode;
632 Item.State := gdsAbort;
634 if Assigned(OnDownloadEnd) then
635 Synchronize(FireDownloadEnd);
639 FIndy.Request.CustomHeaders.Clear;
640 FIndy.Request.RawHeaders.Clear;
642 FIndy.Response.CustomHeaders.Clear;
643 FIndy.Response.RawHeaders.Clear;
644 FIndy.Response.Clear;
645 FIndy.ProxyParams.Clear;
647 if Terminated then Break;
652 function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
654 ResponseCode: Integer;
655 ResStream: TMemoryStream;
658 FIndy.Request.ContentRangeStart := 0;
659 FIndy.Request.ContentRangeEnd := 0;
661 FIndy.Request.CustomHeaders.Clear;
662 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
663 FIndy.Request.LastModified := modified - OffsetFromUTC;
665 FIndy.Request.AcceptEncoding := '';
666 FIndy.Request.Accept := 'text/html';
667 ResStream := TMemoryStream.Create;
672 Writeln('URL: ' + URL);
674 FIndy.Get(URL, ResStream);
675 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
676 Item.LastModified := FIndy.Response.LastModified;
677 //
\8d·
\95ª
\8eæ
\93¾
\82Å
\82P
\83o
\83C
\83g
\91O
\82©
\82ç
\82Æ
\82Á
\82Ä
\82«
\82½
\82Æ
\82«
\82Í
\83}
\83C
\83i
\83X
\82·
\82é
678 Item.ContentLength := Length(Item.Content);
679 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
680 if Item.Content = '' then
685 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
687 ResponseCode := FIndy.ResponseCode;
689 on E: EIdSocketError do begin
691 Item.LastModified := ZERO_DATE;
692 Item.ContentLength := 0;
693 Item.ErrText := E.Message;
696 Screen.Cursor := crDefault;
698 on E: EIdConnectException do begin
700 Item.LastModified := ZERO_DATE;
701 Item.ContentLength := 0;
702 Item.ErrText := E.Message;
705 Screen.Cursor := crDefault;
707 on E: Exception do begin
709 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
710 Writeln('E.Message: ' + E.Message);
713 Item.LastModified := ZERO_DATE;
714 Item.ContentLength := 0;
715 Item.ErrText := E.Message;
716 ResponseCode := FIndy.ResponseCode;
718 Screen.Cursor := crDefault;
722 if (Item.ContentLength = 0) and (ResponseCode = 206) then
723 Item.ResponseCode := 304
725 Item.ResponseCode := ResponseCode;
730 function TDownloadThread.DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
732 ResponseCode: Integer;
733 ResStream: TMemoryStream;
736 if (ItemType = gdtThread) and (RangeStart > 0) then begin
737 // if (ItemType = gdtThread) and (Item.ThreadItem.Size > 0) then begin
738 // FIndy.Request.ContentRangeStart := Item.ThreadItem.Size + AdjustLen;
739 FIndy.Request.ContentRangeStart := RangeStart + AdjustLen;
740 FIndy.Request.ContentRangeEnd := 0;
742 FIndy.Request.ContentRangeStart := 0;
743 FIndy.Request.ContentRangeEnd := 0;
746 FIndy.Request.CustomHeaders.Clear;
747 FIndy.Request.CacheControl := 'no-cache';
748 FIndy.Request.CustomHeaders.Add('Pragma: no-cache');
749 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
750 FIndy.Request.LastModified := modified - OffsetFromUTC;
751 //FIndy.Request.CustomHeaders.Add('If-Modified-Since: ' + RFC1123_Date(modified - OffsetFromUTC) + ' GMT');
753 // FIndy.Request.AcceptEncoding := 'gzip';
754 if RangeStart = 0 then
755 FIndy.Request.AcceptEncoding := 'gzip'
757 FIndy.Request.AcceptEncoding := '';
758 ResStream := TMemoryStream.Create;
763 Writeln('URL: ' + URL);
765 FIndy.Get(URL, ResStream);
766 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
767 Item.LastModified := FIndy.Response.LastModified;
768 //
\8d·
\95ª
\8eæ
\93¾
\82Å
\82P
\83o
\83C
\83g
\91O
\82©
\82ç
\82Æ
\82Á
\82Ä
\82«
\82½
\82Æ
\82«
\82Í
\83}
\83C
\83i
\83X
\82·
\82é
769 // Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
770 Item.ContentLength := Length(Item.Content) + AdjustLen;
771 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
772 // if (FIndy.ResponseCode in [200, 206]) and (Item.Content = '') then
774 if Item.Content = '' then
779 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
781 ResponseCode := FIndy.ResponseCode;
783 on E: EIdSocketError do begin
785 Item.LastModified := ZERO_DATE;
786 Item.ContentLength := 0;
787 Item.ErrText := E.Message;
790 Screen.Cursor := crDefault;
792 on E: EIdConnectException do begin
794 Item.LastModified := ZERO_DATE;
795 Item.ContentLength := 0;
796 Item.ErrText := E.Message;
799 Screen.Cursor := crDefault;
801 on E: Exception do begin
803 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
804 Writeln('E.Message: ' + E.Message);
807 Item.LastModified := ZERO_DATE;
808 Item.ContentLength := 0;
809 Item.ErrText := E.Message;
810 ResponseCode := FIndy.ResponseCode;
812 Screen.Cursor := crDefault;
816 if (Item.ContentLength = 0) and (ResponseCode = 206) then
817 Item.ResponseCode := 304
819 Item.ResponseCode := ResponseCode;
824 procedure TDownloadThread.FireDownloadEnd;
826 OnDownloadEnd(self, Item);
829 procedure TDownloadThread.FireDownloadMsg;
831 OnDownloadMsg(Self, Item, FMsg, FIcon);
834 procedure TDownloadThread.GetSessionID;
836 FSessionID := GikoSys.Dolib.SessionID;
839 procedure TDownloadThread.Abort;
842 FIndy.DisconnectSocket;
843 if socket <> nil then begin
844 socket.DisconnectSocket;
848 procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
850 if Assigned(OnWorkBegin) then
851 OnWorkBegin(Sender, AWorkMode, AWorkCountMax, FNumber, FDownloadTitle);
854 procedure TDownloadThread.WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
856 if Assigned(OnWorkEnd) then
857 OnWorkEnd(Sender, AWorkMode, FNumber);
860 procedure TDownloadThread.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
862 if Assigned(OnWork) then
863 OnWork(Sender, AWorkMode, AWorkCount, FNumber);
866 function TDownloadThread.ParseCgiStatus(Content: string): TCgiStatus;
875 // [+OK]
\82Ì
\8fê
\8d\87\82Í
\8d·
\95ª
876 // [-INCR] (Incorrect)
\82Ì
\8fê
\8d\87\82Í
\82·
\82×
\82Ä
\82Ì
\83f
\81[
\83^
877 // [-ERR (
\83e
\83L
\83X
\83g)]
\82Ì
\8fê
\8d\87\82Í
\82È
\82ñ
\82©
\83G
\83\89\81[
878 //
\97á
\81F+OK 23094/512K
880 // -ERR
\82»
\82ñ
\82È
\94Â
\82È
\82¢
\82Å
\82·
881 Idx := AnsiPos(#10, Content);
882 StatusLine := Copy(Content, 0, Idx);
884 Idx := AnsiPos(' ', Content);
885 Status := Copy(StatusLine, 0, Idx - 1);
886 Line := Copy(StatusLine, Idx + 1, Length(StatusLine));
888 // Idx := AnsiPos('/', Line);
889 if Trim(Status) = '-ERR' then
892 Size := Copy(Line, 0, Idx - 1);
894 if Trim(Status) = '+OK' then
895 Result.FStatus := gcsOK
896 else if Trim(Status) = '-INCR' then
897 Result.FStatus := gcsINCR
898 else if Trim(Status) = '-ERR' then begin
899 Result.FStatus := gcsERR;
900 Result.FErrText := Msg;
907 Result.FStatus := gcsERR;
908 Result.FErrText := '
\83G
\83\89\81[
\82È
\82ñ
\82¾
\82¯
\82Ç
\81A
\82æ
\82
\95ª
\82©
\82ç
\82È
\82¢
\83G
\83\89\81[';
913 if GikoSys.IsNumeric(Size) then
914 Result.FSize := StrToInt(Size)
917 Result.FStatus := gcsERR;
918 Result.FErrText := '
\83X
\83e
\81[
\83^
\83X
\89ð
\90Í
\8e¸
\94s[' + StatusLine + ']';
922 //
\8eè
\94²
\82«
\82È
\8f\88\97\9d\82Å1
\8ds
\96Ú
\82ð
\8fÁ
\82·
923 function TDownloadThread.DeleteStatusLine(Content: string): string;
927 SList := TStringList.Create;
929 SList.Text := Content;
930 if SList.Count > 1 then
932 Result := SList.Text;
938 procedure TDownloadItem.SaveListFile;
942 NewItem: TThreadItem;
946 function MakeThreadCallBack(
947 inInstance : DWORD; // TBoardItem
\82Ì
\83C
\83\93\83X
\83^
\83\93\83X
948 inURL : PChar; //
\83X
\83\8c\83b
\83h
\82Ì URL
949 inTitle : PChar; //
\83X
\83\8c\83^
\83C
950 inCount : DWORD //
\83\8c\83X
\82Ì
\90\94
951 ) : Boolean; stdcall; //
\97ñ
\8b\93\82ð
\91±
\82¯
\82é
\82È
\82ç True
953 _ThreadItem : TThreadItem; // '_'
\82Í
\83N
\83\89\83X
\82Ì
\83v
\83\8d\83p
\83e
\83B
\82Æ
\82©
\82Ô
\82Á
\82Ä
\82é
\82Ì
\82Å
957 boardItem := TBoard( inInstance );
959 boardItem.IntData := boardItem.IntData + 1;
960 index := boardItem.GetIndexFromURL( string( inURL ) );
961 if index = -1 then begin
962 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
963 _ThreadItem := TThreadItem.Create( boardItem.BoardPlugIn, string( inURL ) );
965 _ThreadItem.Title := string( inTitle );
966 _ThreadItem.AllResCount := inCount;
967 _ThreadItem.ParentBoard := Board;
968 _ThreadItem.No := boardItem.IntData;
969 _ThreadItem.RoundDate := ZERO_DATE;
970 _ThreadItem.LastModified := ZERO_DATE;
971 _ThreadItem.AgeSage := gasNew;
972 boardItem.Add(_ThreadItem);
974 if boardItem.Items[index].No > boardItem.IntData then
975 boardItem.Items[index].AgeSage := gasAge
976 else if boardItem.Items[index].AllResCount < inCount then
977 boardItem.Items[index].AgeSage := gasSage
979 boardItem.Items[index].AgeSage := gasNone;
981 boardItem.Items[index].No := boardItem.IntData;
982 boardItem.Items[index].AllResCount := inCount;
986 //Board.ListData := TList.Create;
987 Body := TStringList.Create;
989 //
\83_
\83E
\83\93\83\8d\81[
\83h
\93ú
\8e\9e\90Ý
\92è
\81i
\83\8d\81[
\83J
\83\8b\93ú
\8e\9e\81j
990 Board.RoundDate := Now;
991 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
992 Board.LastModified := LastModified;
993 for i := Board.Count - 1 downto 0 do
994 Board.Items[i].AgeSage := gasNull;
996 if Board.IsBoardPlugInAvailable then begin
997 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
998 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\83\8d\83O
\82ª
\82 \82é
\82È
\82ç
\82»
\82ê
\82ð
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\92Ç
\89Á
999 //
\8cÃ
\82¢
\83\8d\83O
\82ª
\82È
\82¯
\82ê
\82Î
\81A
\90V
\82½
\82É
\83X
\83\8c\83I
\83u
\83W
\83F
\83N
\83g
\82ð
\8dì
\90¬
1001 Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack );
1003 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82É
\82µ
\82©
\82È
\82¢
\82â
\82Â
\82ç
\82ð
\8dí
\8f\9c
1004 for i := Board.Count - 1 downto 0 do begin
1005 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1009 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\96³
\82©
\82Á
\82½
\83A
\83C
\83e
\83\80\82ð
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\92Ç
\89Á
1010 for i := 0 to Board.Count - 1 do begin
1011 if(Board.Items[i].AgeSage = gasNull) and (Board.Items[i].IsLogFile) then begin
1012 Board.IntData := Board.IntData + 1;
1013 Board.Items[i].No := Board.IntData;
1014 Board.Items[i].AllResCount := Board.Items[i].Count;
1015 Board.Items[i].NewResCount := 0;
1016 Board.Items[i].AgeSage := gasNone;
1020 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1021 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\83\8d\83O
\82ª
\82 \82é
\82È
\82ç
\82»
\82ê
\82ð
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\92Ç
\89Á
1022 //
\8cÃ
\82¢
\83\8d\83O
\82ª
\82È
\82¯
\82ê
\82Î
\81A
\90V
\82½
\82É
\83X
\83\8c\83I
\83u
\83W
\83F
\83N
\83g
\82ð
\8dì
\90¬
1023 Body.Text := Content;
1025 for i := 0 to Body.Count - 1 do begin
1026 Rec := GikoSys.DivideSubject(Body[i]);
1027 Rec.FFileName := Trim(Rec.FFileName);
1028 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1030 index := Board.GetIndexFromFileName(Rec.FFileName);
1031 if index = -1 then begin
1032 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
1033 NewItem := TThreadItem.Create(
1034 nil, GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
1035 NewItem.Title := Rec.FTitle;
1036 NewItem.AllResCount := Rec.FCount;
1037 NewItem.ParentBoard := Board;
1038 NewItem.No := NumCount;
1039 NewItem.RoundDate := ZERO_DATE;
1040 NewItem.LastModified := ZERO_DATE;
1041 NewItem.AgeSage := gasNew;
1044 if Board.Items[index].No > NumCount then
1045 Board.Items[index].AgeSage := gasAge
1046 else if Board.Items[index].AllResCount < Rec.FCount then
1047 Board.Items[index].AgeSage := gasSage
1049 Board.Items[index].AgeSage := gasNone;
1051 Board.Items[index].No := NumCount;
1052 Board.Items[index].AllResCount := Rec.FCount;
1055 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\8dí
\8f\9c
1056 for i := Board.Count - 1 downto 0 do begin
1057 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1061 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\96³
\82©
\82Á
\82½
\83A
\83C
\83e
\83\80\82Ì
\8dX
\90V
1062 for i := 0 to Board.Count - 1 do begin
1063 if( Board.Items[i].AgeSage = gasNull )and (Board.Items[i].IsLogFile) then begin
1065 Board.Items[i].No := NumCount;
1066 Board.Items[i].AllResCount := Board.Items[i].Count;
1067 Board.Items[i].NewResCount := 0;
1068 Board.Items[i].AgeSage := gasNone;
1071 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1072 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1073 Body.SaveToFile(Board.GetSubjectFileName);
1082 {procedure TDownloadItem.SaveListFile;
1086 NewItem: TThreadItem;
1088 // SaveCount: Integer;
1093 NewList := TList.Create;
1094 Body := TStringList.Create;
1096 //
\8f\84\89ñ
\93ú
\8e\9e\90Ý
\92è
1097 Board.RoundDate := Now;
1098 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
1099 Board.LastModified := LastModified;
1101 //
\83\8a\83X
\83g
\95Û
\91¶
\8c\8f\90\94\8eæ
\93¾
1102 //SaveCount := MaxInt;
1104 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82©
\82ç
\83\8d\83O
\96³
\82µ
\83A
\83C
\83e
\83\80\82ð
\8dí
\8f\9c
1105 for i := Board.Count - 1 downto 0 do
1106 if not Board.Items[i].IsLogFile then
1109 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1110 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\83\8d\83O
\82ª
\82 \82é
\82È
\82ç
\82»
\82ê
\82ð
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\92Ç
\89Á
1111 //
\8cÃ
\82¢
\83\8d\83O
\82ª
\82È
\82¯
\82ê
\82Î
\81A
\90V
\82½
\82É
\83X
\83\8c\83I
\83u
\83W
\83F
\83N
\83g
\82ð
\8dì
\90¬
1112 Body.Text := Content;
1113 // Loop := Min(Body.Count, SaveCount);
1115 // for i := 0 to Loop - 1 do begin
1116 for i := 0 to Body.Count - 1 do begin
1117 if i = 0 then Continue; //
\82P
\8ds
\96Ú
\82Í
\83X
\83e
\81[
\83^
\83X
\8ds
\82Ì
\82½
\82ß
\8f\88\97\9d\82È
\82µ
1119 Rec := GikoSys.DivideSubject(Body[i]);
1120 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1122 index := Board.GetIndex(Rec.FFileName);
1123 if index = -1 then begin
1124 NewItem := TThreadItem.Create;
1125 NewItem.FileName := Rec.FFileName;
1126 NewItem.Title := Rec.FTitle;
1127 NewItem.Count := Rec.FCount;
1128 NewItem.ParentBoard := Board;
1129 NewItem.No := NumCount;
1130 NewItem.RoundDate := ZERO_DATE;
1131 NewItem.LastModified := ZERO_DATE;
1132 NewList.Add(NewItem);
1134 //Board.Items[index].Count := Count;
1135 Board.Items[index].No := NumCount;
1136 NewList.Add(Board.Items[index]);
1137 Board.DeleteList(index);
1141 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\96³
\82©
\82Á
\82½
\8cÃ
\82¢
\83\8d\83O
\97L
\82è
\83A
\83C
\83e
\83\80\82ð
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\92Ç
\89Á
1142 for i := 0 to Board.Count - 1 do begin
1144 Board.Items[i].No := NumCount;
1145 NewList.Add(Board.Items[i]);
1148 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82ð
\8fÁ
\82·
\81i
\83\8a\83X
\83g
\82Ì
\82Ý
\81B
\83X
\83\8c\83I
\83u
\83W
\83F
\83N
\83g
\8e©
\91Ì
\82Í
\8fÁ
\82³
\82È
\82¢
\81j
1149 for i := Board.Count - 1 downto 0 do
1150 Board.DeleteList(i);
1152 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
1153 for i := 0 to NewList.Count - 1 do
1154 Board.Add(TThreadItem(NewList[i]));
1156 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1157 // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1158 // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1159 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1160 Body.SaveToFile(Board.GetSubjectFileName);
1167 procedure TDownloadItem.SaveItemFile;
1185 FileName := ThreadItem.GetThreadFileName;
1187 if not ThreadItem.IsBoardPlugInAvailable then begin
1188 if Trim(Content) = '' then
1191 GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName));
1194 Body := TStringList.Create;
1198 // if FileExists(FileName) and (ResponseCode = 206) then begin
1199 if FileExists(FileName) and (State = gdsDiffComplete) then begin
1200 // Body.Text := Content;
1201 // if Body.Count > 0 then
1203 // Content := Body.Text;
1208 Body.LoadFromFile(FileName);
1209 OldCnt := Body.Count;
1210 Body.Text := Body.Text + Content;
1211 Body.SaveToFile(FileName);
1212 NewRes := Body.Count - OldCnt;
1214 on E:EFOpenError do begin
1220 until finish and ( loopCnt > 0 );
1221 //Cnt := Body.Count;
1223 if IsAbone then begin
1224 //
\82 \82Ú
\81[
\82ñ
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
\82Æ
\90V
\92\85\83\8c\83X
\94Ô
\82Ì
\82Â
\82¯
\82È
\82¨
\82µ
1229 Body.LoadFromFile(FileName);
1231 on E:EFOpenError do begin
1237 until finish and ( loopCnt > 0 );
1238 LastTxt := Body.Strings[ ThreadItem.Count - 1 ];
1239 if ThreadItem.Kokomade > 0 then begin
1240 KokoTxt := Body.Strings[ ThreadItem.Kokomade - 1 ];
1242 if ThreadItem.NewReceive > 0 then begin
1243 NewTxt := Body.Strings[ ThreadItem.NewReceive - 1 ];
1246 Body.Text := Content;
1247 ThreadItem.AllResCount := 0;
1248 ThreadItem.NewResCount := 0;
1249 NewRes := Body.Count;
1251 Body.Find( LastTxt, LastIdx );
1252 OldCnt := LastIdx + 1;
1253 if ThreadItem.Kokomade > 0 then begin
1254 Body.Find( KokoTxt, KokoIdx );
1255 ThreadItem.Kokomade := KokoIdx + 1;
1257 if ThreadItem.NewReceive > 0 then begin
1258 Body.Find( NewTxt, NewIdx );
1260 ThreadItem.AllResCount := NewIdx;
1261 if OldCnt >= NewIdx then
1262 NewRes := Body.Count - OldCnt
1264 NewRes := Body.Count - NewIdx;
1267 Body.Text := Content;
1268 //ThreadItem.Count := 0;
1269 ThreadItem.AllResCount := 0;
1270 ThreadItem.NewResCount := 0;
1272 NewRes := Body.Count;
1273 //Cnt := Body.Count;
1275 // if Body.Count > 0 then
1277 Body.SaveToFile(FileName);
1279 if ThreadItem.Title = '' then begin
1280 Res := GikoSys.DivideStrLine(Body[0]);
1281 ThreadItem.Title := Res.FTitle;
1283 ThreadItem.Size := 0;
1290 ThreadItem.Size := ThreadItem.Size + ContentLength;
1291 ThreadItem.LastModified := LastModified;
1292 ThreadItem.Count := Cnt;
1293 //ThreadItem.AllResCount := Cnt;
1294 ThreadItem.NewResCount := NewRes;
1295 ThreadItem.NewReceive := OldCnt + 1;
1297 ThreadItem.AllResCount := ThreadItem.Count;
1298 ThreadItem.IsLogFile := True;
1299 ThreadItem.RoundDate := Now;
1300 ThreadItem.UnRead := True;
1301 ThreadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead + 1;
1302 // if ThreadItem.RoundNo = 6 then
1303 // ThreadItem.RoundNo := 0;
1305 //
\88Ù
\8fí
\8fI
\97¹
\8e\9e\82Í
\83C
\83\93\83f
\83b
\83N
\83X
\82ª
\8dX
\90V
\82³
\82ê
\82È
\82¢
\82½
\82ß
\81A
\83e
\83\93\83|
\83\89\83\8a\82ð
\8dì
\90¬
\82·
\82é
\81B
1306 //
\90³
\8fí
\8fI
\97¹
\8e\9e\82É
\82Í
\8dí
\8f\9c
1307 //
\88Ù
\8fí
\8fI
\97¹
\8e\9e\82Í
\81A
\8e\9f\89ñ
\8bN
\93®
\8e\9e\82É
\83e
\83\93\83|
\83\89\83\8a\82ð
\8c©
\82Ä
\8dX
\90V
1308 ini := TMemIniFile.Create(ChangeFileExt(FileName, '.tmp'));
1310 ini.WriteDateTime('Setting', 'RoundDate', ThreadItem.RoundDate);
1311 ini.WriteDateTime('Setting', 'LastModified', ThreadItem.LastModified);
1312 ini.WriteInteger('Setting', 'Size', ThreadItem.Size);
1313 ini.WriteInteger('Setting', 'Count', ThreadItem.Count);
1314 ini.WriteInteger('Setting', 'AllResCount', ThreadItem.AllResCount);
1315 ini.WriteInteger('Setting', 'NewResCount', ThreadItem.NewResCount);
1316 ini.WriteInteger('Setting', 'NewReceive', ThreadItem.NewReceive);
1317 // ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo);
1318 ini.WriteBool('Setting', 'Round', ThreadItem.Round);
1319 ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead);