6 Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP,
7 {HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,}
8 GikoSystem, BoardGroup, MonaUtils, ExternalBoardManager, ExternalBoardPlugInMain,
12 TDownloadItem = class;
13 TGikoDownloadType = (gdtBoard, gdtThread);
14 TGikoDownloadState = (gdsWait, gdsWork, gdsComplete, gdsDiffComplete, gdsNotModify, gdsAbort, gdsError);
15 TGikoCgiStatus = (gcsOK, gcsINCR, gcsERR);
16 TGikoDLProgress = (gdpStd, gdpAll, gdpDatOchi, gdpOfflaw);
18 TGikoWorkEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; ID: Integer) of object;
19 TGikoWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; ID: Integer; const AWorkTitle: string) of object;
20 TGikoWorkEndEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; ID: Integer) of object;
21 TDownloadEndEvent = procedure(Sender: TObject; Item: TDownloadItem) of object;
22 TDownloadMsgEvent = procedure(Sender: TObject; Item: TDownloadItem; Msg: string; Icon: TGikoMessageIcon) of object;
25 FStatus: TGikoCgiStatus;
31 TDownloadThread = class(TThread)
38 FIcon: TGikoMessageIcon;
40 FOnWork: TGikoWorkEvent;
41 FOnWorkBegin: TGikoWorkBeginEvent;
42 FOnWorkEnd: TGikoWorkEndEvent;
43 FOnDownloadEnd: TDownloadEndEvent;
44 FOnDownloadMsg: TDownloadMsgEvent;
45 FDownloadTitle: string;
47 procedure FireDownloadEnd;
48 procedure FireDownloadMsg;
49 procedure GetSessionID;
50 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
51 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
52 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
53 function ParseCgiStatus(Content: string): TCgiStatus;
54 function CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
55 function DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
56 function DeleteStatusLine(Content: string): string;
58 procedure Execute; override;
60 property Item: TDownloadItem read FItem write FItem;
61 property Number: Integer read FNumber write FNumber;
62 constructor Create(CreateSuspended: Boolean);
63 destructor Destroy; override;
65 property OnWork: TGikoWorkEvent read FOnWork write FOnWork;
66 property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin;
67 property OnWorkEnd: TGikoWorkEndEvent read FOnWorkEnd write FOnWorkEnd;
68 property OnDownloadEnd: TDownloadEndEvent read FOnDownloadEnd write FOnDownloadEnd;
69 property OnDownloadMsg: TDownloadMsgEvent read FOnDownloadMsg write FOnDownloadMsg;
72 TDownloadItem = class(TObject)
74 FDownType: TGikoDownloadType;
76 FThreadItem: TThreadItem;
78 FContentLength: Integer;
79 FLastModified: TDateTime;
81 FResponseCode: Smallint;
82 FState: TGikoDownloadState;
84 FForceDownload: Boolean;
87 procedure SaveListFile;
88 procedure SaveItemFile;
90 property DownType: TGikoDownloadType read FDownType write FDownType;
91 property Board: TBoard read FBoard write FBoard;
92 property ThreadItem: TThreadItem read FThreadItem write FThreadItem;
94 property ContentLength: Integer read FContentLength write FContentLength;
95 property LastModified: TDateTime read FLastModified write FLastModified;
96 property Content: string read FContent write FContent;
97 property ResponseCode: Smallint read FResponseCode write FResponseCode;
98 property State: TGikoDownloadState read FState write FState;
99 property ErrText: string read FErrText write FErrText;
100 property ForceDownload: Boolean read FForceDownload write FForceDownload;
101 property IsAbone : Boolean read FIsAbone write FIsAbone;
106 constructor TDownloadThread.Create(CreateSuspended: Boolean);
108 inherited Create(CreateSuspended);
109 FIndy := TIdHttp.Create(nil);
111 FIndy.OnWorkBegin := WorkBegin;
112 FIndy.OnWorkEnd := WorkEnd;
113 FIndy.OnWork := Work;
116 destructor TDownloadThread.Destroy;
118 FIndy.Request.CustomHeaders.Clear;
119 FIndy.Request.RawHeaders.Clear;
121 FIndy.Response.CustomHeaders.Clear;
122 FIndy.Response.RawHeaders.Clear;
123 FIndy.Response.Clear;
124 FIndy.ProxyParams.Clear;
129 function RFC1123_Date(aDate : TDateTime) : String;
131 StrWeekDay : String = 'MonTueWedThuFriSatSun';
132 StrMonth : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
134 Year, Month, Day : Word;
135 Hour, Min, Sec, MSec : Word;
138 DecodeDate(aDate, Year, Month, Day);
139 DecodeTime(aDate, Hour, Min, Sec, MSec);
140 DayOfWeek := ((Trunc(aDate) - 2) mod 7);
141 Result := Copy(StrWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
142 Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
143 [Day, Copy(StrMonth, 1 + 3 * (Month - 1), 3),
144 Year, Hour, Min, Sec]);
147 procedure TDownloadThread.Execute;
149 ResStream: TMemoryStream;
152 CgiStatus: TCgiStatus;
158 DownloadResult: Boolean;
159 boardPlugIn : TBoardPlugIn;
160 lastContent : string;
161 logFile : TFileStream;
162 adjustMargin : Integer;
166 while not Terminated do begin
167 //=====
\83v
\83\89\83O
\83C
\83\93
170 ExternalBoardManager.OnWork := Work;
171 ExternalBoardManager.OnWorkBegin := WorkBegin;
172 ExternalBoardManager.OnWorkEnd := WorkEnd;
174 FDownloadTitle := '';
175 case FItem.FDownType of
178 FDownloadTitle := FItem.FBoard.Title;
179 if FItem.FBoard <> nil then begin
180 if FItem.FBoard.IsBoardPlugInAvailable then begin
181 boardPlugIn := FItem.FBoard.BoardPlugIn;
182 Item.State := TGikoDownloadState( boardPlugIn.DownloadBoard( DWORD( FItem.FBoard ) ) );
188 FDownloadTitle := FItem.FThreadItem.Title;
189 if FItem.FThreadItem <> nil then begin
190 if FItem.FThreadItem.IsBoardPlugInAvailable then begin
191 boardPlugIn := FItem.FThreadItem.BoardPlugIn;
192 Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
197 if Length(FDownloadTitle) = 0 then
198 FDownloadTitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
200 if boardPlugIn <> nil then begin
202 Item.State := gdsAbort;
204 if Assigned( OnDownloadEnd ) then
205 Synchronize( FireDownloadEnd );
213 //=====
\83v
\83\89\83O
\83C
\83\93\82ð
\8eg
\97p
\82µ
\82È
\82¢
\8fê
\8d\87
215 FIndy.Request.CustomHeaders.Clear;
216 FIndy.Response.Clear;
218 FIndy.ProxyParams.Clear;
220 FIndy.Request.UserAgent := GikoSys.GetUserAgent;
221 FIndy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
222 FIndy.ProxyParams.BasicAuthentication := False;
224 Writeln('------------------------------------------------------------');
226 //FIndy.AllowCookies := False;
227 if GikoSys.Setting.ReadProxy then begin
228 if GikoSys.Setting.ProxyProtocol then
229 FIndy.ProtocolVersion := pv1_1
231 FIndy.ProtocolVersion := pv1_0;
232 FIndy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
233 FIndy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
234 FIndy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
235 FIndy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
236 if GikoSys.Setting.ReadProxyUserID <> '' then
237 FIndy.ProxyParams.BasicAuthentication := True;
239 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
240 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
241 Writeln('
\83|
\81[
\83g: ' + IntToStr(GikoSys.Setting.ReadProxyPort));
244 if GikoSys.Setting.Protocol then
245 FIndy.ProtocolVersion := pv1_1
247 FIndy.ProtocolVersion := pv1_0;
248 FIndy.ProxyParams.ProxyServer := '';
249 FIndy.ProxyParams.ProxyPort := 80;
250 FIndy.ProxyParams.ProxyUsername := '';
251 FIndy.ProxyParams.ProxyPassword := '';
253 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
258 if Item.DownType = gdtThread then begin
259 if FileExists( Item.ThreadItem.GetThreadFileName ) then begin
260 // dat
\83t
\83@
\83C
\83\8b\82Ì
\8dÅ
\8cã
\82ð
\93Ç
\82Ý
\8fo
\82·
261 SetLength( lastContent, ADJUST_MARGIN + 1 );
262 logFile := TFileStream.Create( Item.ThreadItem.GetThreadFileName, fmOpenRead or fmShareDenyWrite );
264 logFile.Seek( -(ADJUST_MARGIN + 1), soFromEnd );
265 logFile.Read( lastContent[ 1 ], ADJUST_MARGIN + 1 );
266 lastContent := StringReplace( lastContent, #13, '', [] ); // CR
\82Ì
\8dí
\8f\9c
273 adjustMargin := Length( lastContent );
276 FIndy.Request.ContentRangeStart := 0;
277 FIndy.Request.LastModified := ZERO_DATE;
278 ResStream := TMemoryStream.Create;
281 //********************
282 //DAT or Subject
\8eæ
\93¾
283 //********************
284 Item.ResponseCode := 0;
288 if Item.DownType = gdtBoard then begin
290 Writeln('Subject
\8eæ
\93¾');
291 Writeln('URL: ' + Item.Board.GetReadCgiURL);
292 Writeln('Modified: ' + FloatToStr(Item.Board.LastModified));
294 URL := Item.Board.GetReadCgiURL;
295 if Item.ForceDownload then begin
297 ATitle := Item.Board.Title;
299 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
300 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
302 if Assigned(OnDownloadMsg) then
303 Synchronize(FireDownloadMsg);
304 Modified := ZERO_DATE
306 Modified := Item.Board.LastModified;
308 end else if Item.DownType = gdtThread then begin
310 Writeln('DAT
\8eæ
\93¾');
311 Writeln('URL: ' + Item.ThreadItem.GetDatURL);
312 Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified));
314 URL := Item.ThreadItem.GetDatURL;
315 if Item.ForceDownload then begin
317 ATitle := Item.ThreadItem.Title;
319 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
320 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
322 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
323 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
324 if Assigned(OnDownloadMsg) then
325 Synchronize(FireDownloadMsg);
326 Modified := ZERO_DATE;
330 Modified := Item.ThreadItem.LastModified;
331 if Item.ThreadItem.Size > 0 then begin
333 Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size));
335 //
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
\82Ì
\82½
\82ß adjustMargin
\83o
\83C
\83g
\91O
\82©
\82ç
\8eæ
\93¾
336 RangeStart := Item.ThreadItem.Size;
337 AdjustLen := -adjustMargin;
341 Item.IsAbone := False;
342 DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen);
344 Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode));
346 if Item.DownType = gdtThread then begin
347 if Item.ResponseCode = 416 then begin
348 Item.IsAbone := True;
349 DownloadResult := True;
350 end else if DownloadResult and (AdjustLen < 0) then begin
351 if Copy( Item.Content, 1, adjustMargin ) <> lastContent then
352 Item.IsAbone := True;
356 if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin
357 if Item.DownType = gdtBoard then
358 Item.Board.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date'])
360 Item.ThreadItem.ParentBoard.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date']);
363 if DownloadResult then begin
365 Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']);
367 if Item.IsAbone then begin
369 Writeln('
\82 \82Ú
\81[
\82ñ
\8c\9f\8fo');
371 ATitle := Item.ThreadItem.Title;
373 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
374 //
\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¾
377 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 + ']';
379 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
380 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
381 if Assigned(OnDownloadMsg) then
382 Synchronize(FireDownloadMsg);
383 if not DatDownload(Item.DownType, URL, ZERO_DATE, RangeStart, AdjustLen) then
384 Item.State := gdsError;
386 Writeln('
\82 \82Ú
\81[
\82ñ
\8dÄ
\8eæ
\93¾
\8cã');
387 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
389 end else if (Item.DownType = gdtThread) and (AdjustLen < 0) then begin
390 //
\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
391 Item.Content := Copy(Item.Content, adjustMargin + 1, MaxInt);
394 Item.State := gdsError;
395 if (Item.DownType = gdtBoard) and (Item.ResponseCode = 302) then begin
396 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';
398 if Assigned(OnDownloadMsg) then
399 Synchronize(FireDownloadMsg);
403 //********************
405 //********************
406 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
408 Writeln('dat.gz
\8eæ
\93¾');
410 ATitle := Item.ThreadItem.Title;
412 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
413 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 + ']';
415 if Assigned(OnDownloadMsg) then
416 Synchronize(FireDownloadMsg);
417 URL := Item.ThreadItem.GetDatgzURL;
418 Modified := Item.ThreadItem.LastModified;
421 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
422 Item.State := gdsError;
424 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
428 //********************
430 //********************
432 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
433 ATitle := Item.ThreadItem.Title;
435 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
436 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 + ']';
438 if Assigned(OnDownloadMsg) then
439 Synchronize(FireDownloadMsg);
440 URL := Item.ThreadItem.GetOldDatgzURL;
441 Modified := Item.ThreadItem.LastModified;
444 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
445 Item.State := gdsError;
449 //********************
450 //offlaw.cgi
\82Å
\8eæ
\93¾
451 //********************
453 Synchronize(GetSessionID);
454 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID <> '') then begin
456 Writeln('offlaw.cgi
\82Å
\8eæ
\93¾');
458 ATitle := Item.ThreadItem.Title;
460 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
461 FMsg := '
\81\9adat.gz
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ßofflaw.cgi
\82ð
\97\98\97p
\82µ
\82Ü
\82· - [' + ATitle + ']';
463 if Assigned(OnDownloadMsg) then
464 Synchronize(FireDownloadMsg);
465 URL := Item.ThreadItem.GetOfflawCgiURL(FSessionID);
466 Modified := Item.ThreadItem.LastModified;
469 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then begin
471 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
473 Item.State := gdsError;
475 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
476 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';
478 if Assigned(OnDownloadMsg) then
479 Synchronize(FireDownloadMsg);
483 CgiStatus := ParseCgiStatus(Item.Content);
485 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
487 case CgiStatus.FStatus of
490 Writeln('CGIStatus: OK');
492 Item.ResponseCode := 200;
493 Item.Content := DeleteStatusLine(Item.Content);
494 Item.ContentLength := CgiStatus.FSize;
497 //
\8d¡
\82Í
\82 \82è
\82¦
\82È
\82¢
499 Writeln('CGIStatus: 206');
501 Item.ResponseCode := 206;
502 Item.Content := DeleteStatusLine(Item.Content);
503 Item.ContentLength := CgiStatus.FSize;
507 Writeln('CGIStatus: 404(ERROR)');
509 Item.ResponseCode := 404;
510 Item.State := gdsError;
511 Item.ErrText := CgiStatus.FErrText;
514 if (Item.ResponseCode = 404) and (AnsiPos('
\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c©', Item.ErrText) <> 0) then begin
516 Writeln('
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾');
518 ATitle := Item.ThreadItem.Title;
520 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
521 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c© - [' + ATitle + ']';
523 if Assigned(OnDownloadMsg) then
524 Synchronize(FireDownloadMsg);
525 Idx := Pos(' ', Item.ErrText);
526 if Idx <> 0 then begin
527 URL := Copy(Item.ErrText, Idx + 1, Length(Item.ErrText));
528 if Pos( '://', URL ) = 0 then begin
529 if Pos('../', URL) = 1 then
530 URL := Copy(URL, 4, MaxInt );
531 if Pos( '/', URL ) = 1 then
532 URL := Copy( URL, 2, MaxInt );
533 URL := GikoSys.UrlToServer(Item.ThreadItem.ParentBoard.URL) + URL;
535 Modified := Item.ThreadItem.LastModified;
538 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
539 Item.State := gdsError;
541 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
547 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID = '') then begin
549 Writeln('
\83\8d\83O
\83C
\83\93\82³
\82ê
\82Ä
\82È
\82¢
\82Ì
\82Å
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾
\95s
\89Â');
551 ATitle := Item.ThreadItem.Title;
553 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
554 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 + ']';
556 if Assigned(OnDownloadMsg) then
557 Synchronize(FireDownloadMsg);
561 case Item.ResponseCode of
562 200: Item.State := gdsComplete;
563 206: Item.State := gdsDiffComplete;
564 304: Item.State := gdsNotModify;
566 Item.State := gdsError;
569 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
570 if (Item.ResponseCode in [200, 206]) and (Item.Content = '') then
571 Item.State := gdsError;
572 Item.LastModified := FIndy.Response.LastModified;
573 //
\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é
574 Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
577 FIndy.Get(URL, ResStream);
578 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
579 if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] <> #10) then begin
580 //
\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¾
581 //
\82±
\82±
\82Å
\83\81\83b
\83Z
\81[
\83W
\95\
\8e¦
\83C
\83x
\83\93\83g
583 FMsg := '
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82·';
584 if Assigned(OnDownloadMsg) then
585 Synchronize(FireDownloadMsg);
586 FIndy.Request.ContentRangeStart := 0;
587 FIndy.Request.ContentRangeEnd := 0;
590 FIndy.Get(URL, ResStream);
591 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
592 end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin
593 //
\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
594 Item.Content := Copy(Item.Content, 2, Length(Item.Content));
597 Item.State := gdsError;
599 Item.ResponseCode := FIndy.ResponseCode;
604 FIndy.Get(URL, ResStream);
605 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
607 Item.State := gdsError;
610 CgiStatus := ParseCgiStatus(Item.Content);
611 if CgiStatus.FStatus = gcsOK then begin
612 if CgiStatus.FSize = 0 then
613 Item.State := gdsNotModify
614 else if Item.DownType = gdtBoard then
615 Item.State := gdsComplete
617 Item.State := gdsDiffComplete;
618 end else if CgiStatus.FStatus = gcsINCR then begin
619 Item.State := gdsComplete;
620 end else if CgiStatus.FStatus = gcsERR then begin
621 Item.State := gdsError;
622 Item.ErrText := CgiStatus.FErrText;
624 Item.ContentLength := CgiStatus.FSize;
627 Item.State := gdsError;
629 //Item.ResponseCode := FIndy.ResponseCode;
631 Item.State := gdsAbort;
633 if Assigned(OnDownloadEnd) then
634 Synchronize(FireDownloadEnd);
638 FIndy.Request.CustomHeaders.Clear;
639 FIndy.Request.RawHeaders.Clear;
641 FIndy.Response.CustomHeaders.Clear;
642 FIndy.Response.RawHeaders.Clear;
643 FIndy.Response.Clear;
644 FIndy.ProxyParams.Clear;
646 if Terminated then Break;
651 function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
653 ResponseCode: Integer;
654 ResStream: TMemoryStream;
657 FIndy.Request.ContentRangeStart := 0;
658 FIndy.Request.ContentRangeEnd := 0;
660 FIndy.Request.CustomHeaders.Clear;
661 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
662 FIndy.Request.LastModified := modified - OffsetFromUTC;
664 FIndy.Request.AcceptEncoding := '';
665 FIndy.Request.Accept := 'text/html';
666 ResStream := TMemoryStream.Create;
671 Writeln('URL: ' + URL);
673 FIndy.Get(URL, ResStream);
674 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
675 Item.LastModified := FIndy.Response.LastModified;
676 //
\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é
677 Item.ContentLength := Length(Item.Content);
678 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
679 if Item.Content = '' then
684 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
686 ResponseCode := FIndy.ResponseCode;
688 on E: EIdSocketError do begin
690 Item.LastModified := ZERO_DATE;
691 Item.ContentLength := 0;
692 Item.ErrText := E.Message;
695 Screen.Cursor := crDefault;
697 on E: EIdConnectException do begin
699 Item.LastModified := ZERO_DATE;
700 Item.ContentLength := 0;
701 Item.ErrText := E.Message;
704 Screen.Cursor := crDefault;
706 on E: Exception do begin
708 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
709 Writeln('E.Message: ' + E.Message);
712 Item.LastModified := ZERO_DATE;
713 Item.ContentLength := 0;
714 Item.ErrText := E.Message;
715 ResponseCode := FIndy.ResponseCode;
717 Screen.Cursor := crDefault;
721 if (Item.ContentLength = 0) and (ResponseCode = 206) then
722 Item.ResponseCode := 304
724 Item.ResponseCode := ResponseCode;
729 function TDownloadThread.DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
731 ResponseCode: Integer;
732 ResStream: TMemoryStream;
735 if (ItemType = gdtThread) and (RangeStart > 0) then begin
736 // if (ItemType = gdtThread) and (Item.ThreadItem.Size > 0) then begin
737 // FIndy.Request.ContentRangeStart := Item.ThreadItem.Size + AdjustLen;
738 FIndy.Request.ContentRangeStart := RangeStart + AdjustLen;
739 FIndy.Request.ContentRangeEnd := 0;
741 FIndy.Request.ContentRangeStart := 0;
742 FIndy.Request.ContentRangeEnd := 0;
745 FIndy.Request.CustomHeaders.Clear;
746 FIndy.Request.CacheControl := 'no-cache';
747 FIndy.Request.CustomHeaders.Add('Pragma: no-cache');
748 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
749 FIndy.Request.LastModified := modified - OffsetFromUTC;
750 //FIndy.Request.CustomHeaders.Add('If-Modified-Since: ' + RFC1123_Date(modified - OffsetFromUTC) + ' GMT');
752 // FIndy.Request.AcceptEncoding := 'gzip';
753 if RangeStart = 0 then
754 FIndy.Request.AcceptEncoding := 'gzip'
756 FIndy.Request.AcceptEncoding := '';
757 ResStream := TMemoryStream.Create;
762 Writeln('URL: ' + URL);
764 FIndy.Get(URL, ResStream);
765 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
766 Item.LastModified := FIndy.Response.LastModified;
767 //
\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é
768 // Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
769 Item.ContentLength := Length(Item.Content) + AdjustLen;
770 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
771 // if (FIndy.ResponseCode in [200, 206]) and (Item.Content = '') then
773 if Item.Content = '' then
778 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
780 ResponseCode := FIndy.ResponseCode;
782 on E: EIdSocketError do begin
784 Item.LastModified := ZERO_DATE;
785 Item.ContentLength := 0;
786 Item.ErrText := E.Message;
789 Screen.Cursor := crDefault;
791 on E: EIdConnectException do begin
793 Item.LastModified := ZERO_DATE;
794 Item.ContentLength := 0;
795 Item.ErrText := E.Message;
798 Screen.Cursor := crDefault;
800 on E: Exception do begin
802 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
803 Writeln('E.Message: ' + E.Message);
806 Item.LastModified := ZERO_DATE;
807 Item.ContentLength := 0;
808 Item.ErrText := E.Message;
809 ResponseCode := FIndy.ResponseCode;
811 Screen.Cursor := crDefault;
815 if (Item.ContentLength = 0) and (ResponseCode = 206) then
816 Item.ResponseCode := 304
818 Item.ResponseCode := ResponseCode;
823 procedure TDownloadThread.FireDownloadEnd;
825 OnDownloadEnd(self, Item);
828 procedure TDownloadThread.FireDownloadMsg;
830 OnDownloadMsg(Self, Item, FMsg, FIcon);
833 procedure TDownloadThread.GetSessionID;
835 FSessionID := GikoSys.Dolib.SessionID;
838 procedure TDownloadThread.Abort;
841 FIndy.DisconnectSocket;
842 if socket <> nil then begin
843 socket.DisconnectSocket;
847 procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
849 if Assigned(OnWorkBegin) then
850 OnWorkBegin(Sender, AWorkMode, AWorkCountMax, FNumber, FDownloadTitle);
853 procedure TDownloadThread.WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
855 if Assigned(OnWorkEnd) then
856 OnWorkEnd(Sender, AWorkMode, FNumber);
859 procedure TDownloadThread.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
861 if Assigned(OnWork) then
862 OnWork(Sender, AWorkMode, AWorkCount, FNumber);
865 function TDownloadThread.ParseCgiStatus(Content: string): TCgiStatus;
874 // [+OK]
\82Ì
\8fê
\8d\87\82Í
\8d·
\95ª
875 // [-INCR] (Incorrect)
\82Ì
\8fê
\8d\87\82Í
\82·
\82×
\82Ä
\82Ì
\83f
\81[
\83^
876 // [-ERR (
\83e
\83L
\83X
\83g)]
\82Ì
\8fê
\8d\87\82Í
\82È
\82ñ
\82©
\83G
\83\89\81[
877 //
\97á
\81F+OK 23094/512K
879 // -ERR
\82»
\82ñ
\82È
\94Â
\82È
\82¢
\82Å
\82·
880 Idx := AnsiPos(#10, Content);
881 StatusLine := Copy(Content, 0, Idx);
883 Idx := AnsiPos(' ', Content);
884 Status := Copy(StatusLine, 0, Idx - 1);
885 Line := Copy(StatusLine, Idx + 1, Length(StatusLine));
887 // Idx := AnsiPos('/', Line);
888 if Trim(Status) = '-ERR' then
891 Size := Copy(Line, 0, Idx - 1);
893 if Trim(Status) = '+OK' then
894 Result.FStatus := gcsOK
895 else if Trim(Status) = '-INCR' then
896 Result.FStatus := gcsINCR
897 else if Trim(Status) = '-ERR' then begin
898 Result.FStatus := gcsERR;
899 Result.FErrText := Msg;
906 Result.FStatus := gcsERR;
907 Result.FErrText := '
\83G
\83\89\81[
\82È
\82ñ
\82¾
\82¯
\82Ç
\81A
\82æ
\82
\95ª
\82©
\82ç
\82È
\82¢
\83G
\83\89\81[';
912 if GikoSys.IsNumeric(Size) then
913 Result.FSize := StrToInt(Size)
916 Result.FStatus := gcsERR;
917 Result.FErrText := '
\83X
\83e
\81[
\83^
\83X
\89ð
\90Í
\8e¸
\94s[' + StatusLine + ']';
921 //
\8eè
\94²
\82«
\82È
\8f\88\97\9d\82Å1
\8ds
\96Ú
\82ð
\8fÁ
\82·
922 function TDownloadThread.DeleteStatusLine(Content: string): string;
926 SList := TStringList.Create;
928 SList.Text := Content;
929 if SList.Count > 1 then
931 Result := SList.Text;
937 procedure TDownloadItem.SaveListFile;
941 NewItem: TThreadItem;
945 function MakeThreadCallBack(
946 inInstance : DWORD; // TBoardItem
\82Ì
\83C
\83\93\83X
\83^
\83\93\83X
947 inURL : PChar; //
\83X
\83\8c\83b
\83h
\82Ì URL
948 inTitle : PChar; //
\83X
\83\8c\83^
\83C
949 inCount : DWORD //
\83\8c\83X
\82Ì
\90\94
950 ) : Boolean; stdcall; //
\97ñ
\8b\93\82ð
\91±
\82¯
\82é
\82È
\82ç True
952 _ThreadItem : TThreadItem; // '_'
\82Í
\83N
\83\89\83X
\82Ì
\83v
\83\8d\83p
\83e
\83B
\82Æ
\82©
\82Ô
\82Á
\82Ä
\82é
\82Ì
\82Å
956 boardItem := TBoard( inInstance );
958 boardItem.IntData := boardItem.IntData + 1;
959 index := boardItem.GetIndexFromURL( string( inURL ) );
960 if index = -1 then begin
961 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
962 _ThreadItem := TThreadItem.Create( boardItem.BoardPlugIn, string( inURL ) );
964 _ThreadItem.Title := string( inTitle );
965 _ThreadItem.AllResCount := inCount;
966 _ThreadItem.ParentBoard := Board;
967 _ThreadItem.No := boardItem.IntData;
968 _ThreadItem.RoundDate := ZERO_DATE;
969 _ThreadItem.LastModified := ZERO_DATE;
970 _ThreadItem.AgeSage := gasNew;
971 boardItem.Add(_ThreadItem);
973 if boardItem.Items[index].No > boardItem.IntData then
974 boardItem.Items[index].AgeSage := gasAge
975 else if boardItem.Items[index].AllResCount < inCount then
976 boardItem.Items[index].AgeSage := gasSage
978 boardItem.Items[index].AgeSage := gasNone;
980 boardItem.Items[index].No := boardItem.IntData;
981 boardItem.Items[index].AllResCount := inCount;
985 //Board.ListData := TList.Create;
986 Body := TStringList.Create;
988 //
\83_
\83E
\83\93\83\8d\81[
\83h
\93ú
\8e\9e\90Ý
\92è
\81i
\83\8d\81[
\83J
\83\8b\93ú
\8e\9e\81j
989 Board.RoundDate := Now;
990 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
991 Board.LastModified := LastModified;
993 //dat
\97\8e\82¿
\83X
\83\8c\82Ì
\83\
\81[
\83g
\8f\87\82ð
\8c\88\92è
\82·
\82é
\82½
\82ß
\82É
\83\
\81[
\83g
\82·
\82é
994 if GikoSys.Setting.DatOchiSortIndex >= 0 then begin
995 Sort.SortNoFlag := true;
996 Sort.SortOrder := GikoSys.Setting.DatOchiSortOrder;
997 Sort.SortIndex := GikoSys.Setting.DatOchiSortIndex;
998 //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
999 Board.CustomSort(ThreadItemSortProc);
1002 for i := Board.Count - 1 downto 0 do
1003 Board.Items[i].AgeSage := gasNull;
1005 if Board.IsBoardPlugInAvailable then begin
1006 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1007 //
\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Á
1008 //
\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¬
1010 Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack );
1012 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82É
\82µ
\82©
\82È
\82¢
\82â
\82Â
\82ç
\82ð
\8dí
\8f\9c
1013 for i := Board.Count - 1 downto 0 do begin
1014 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1018 //
\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Á
1019 for i := 0 to Board.Count - 1 do begin
1020 if(Board.Items[i].AgeSage = gasNull) and (Board.Items[i].IsLogFile) then begin
1021 Board.IntData := Board.IntData + 1;
1022 Board.Items[i].No := Board.IntData;
1023 Board.Items[i].AllResCount := Board.Items[i].Count;
1024 Board.Items[i].NewResCount := 0;
1025 Board.Items[i].AgeSage := gasNone;
1029 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1030 //
\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Á
1031 //
\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¬
1032 Body.Text := Content;
1034 for i := 0 to Body.Count - 1 do begin
1035 Rec := GikoSys.DivideSubject(Body[i]);
1036 Rec.FFileName := Trim(Rec.FFileName);
1037 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1039 index := Board.GetIndexFromFileName(Rec.FFileName);
1040 if index = -1 then begin
1041 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
1042 NewItem := TThreadItem.Create(
1043 nil, GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
1044 NewItem.Title := Rec.FTitle;
1045 NewItem.AllResCount := Rec.FCount;
1046 NewItem.ParentBoard := Board;
1047 NewItem.No := NumCount;
1048 NewItem.RoundDate := ZERO_DATE;
1049 NewItem.LastModified := ZERO_DATE;
1050 NewItem.AgeSage := gasNew;
1053 if Board.Items[index].No > NumCount then
1054 Board.Items[index].AgeSage := gasAge
1055 else if Board.Items[index].AllResCount < Rec.FCount then
1056 Board.Items[index].AgeSage := gasSage
1058 Board.Items[index].AgeSage := gasNone;
1060 Board.Items[index].No := NumCount;
1061 Board.Items[index].AllResCount := Rec.FCount;
1064 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\8dí
\8f\9c
1065 for i := Board.Count - 1 downto 0 do begin
1066 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1070 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\96³
\82©
\82Á
\82½
\83A
\83C
\83e
\83\80\82Ì
\8dX
\90V
1071 for i := 0 to Board.Count - 1 do begin
1072 if( Board.Items[i].AgeSage = gasNull )and (Board.Items[i].IsLogFile) then begin
1074 Board.Items[i].No := NumCount;
1075 Board.Items[i].AllResCount := Board.Items[i].Count;
1076 Board.Items[i].NewResCount := 0;
1077 Board.Items[i].AgeSage := gasNone;
1080 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1081 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1082 Body.SaveToFile(Board.GetSubjectFileName);
1091 {procedure TDownloadItem.SaveListFile;
1095 NewItem: TThreadItem;
1097 // SaveCount: Integer;
1102 NewList := TList.Create;
1103 Body := TStringList.Create;
1105 //
\8f\84\89ñ
\93ú
\8e\9e\90Ý
\92è
1106 Board.RoundDate := Now;
1107 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
1108 Board.LastModified := LastModified;
1110 //
\83\8a\83X
\83g
\95Û
\91¶
\8c\8f\90\94\8eæ
\93¾
1111 //SaveCount := MaxInt;
1113 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82©
\82ç
\83\8d\83O
\96³
\82µ
\83A
\83C
\83e
\83\80\82ð
\8dí
\8f\9c
1114 for i := Board.Count - 1 downto 0 do
1115 if not Board.Items[i].IsLogFile then
1118 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1119 //
\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Á
1120 //
\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¬
1121 Body.Text := Content;
1122 // Loop := Min(Body.Count, SaveCount);
1124 // for i := 0 to Loop - 1 do begin
1125 for i := 0 to Body.Count - 1 do begin
1126 if i = 0 then Continue; //
\82P
\8ds
\96Ú
\82Í
\83X
\83e
\81[
\83^
\83X
\8ds
\82Ì
\82½
\82ß
\8f\88\97\9d\82È
\82µ
1128 Rec := GikoSys.DivideSubject(Body[i]);
1129 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1131 index := Board.GetIndex(Rec.FFileName);
1132 if index = -1 then begin
1133 NewItem := TThreadItem.Create;
1134 NewItem.FileName := Rec.FFileName;
1135 NewItem.Title := Rec.FTitle;
1136 NewItem.Count := Rec.FCount;
1137 NewItem.ParentBoard := Board;
1138 NewItem.No := NumCount;
1139 NewItem.RoundDate := ZERO_DATE;
1140 NewItem.LastModified := ZERO_DATE;
1141 NewList.Add(NewItem);
1143 //Board.Items[index].Count := Count;
1144 Board.Items[index].No := NumCount;
1145 NewList.Add(Board.Items[index]);
1146 Board.DeleteList(index);
1150 //
\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Á
1151 for i := 0 to Board.Count - 1 do begin
1153 Board.Items[i].No := NumCount;
1154 NewList.Add(Board.Items[i]);
1157 //
\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
1158 for i := Board.Count - 1 downto 0 do
1159 Board.DeleteList(i);
1161 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
1162 for i := 0 to NewList.Count - 1 do
1163 Board.Add(TThreadItem(NewList[i]));
1165 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1166 // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1167 // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1168 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1169 Body.SaveToFile(Board.GetSubjectFileName);
1176 procedure TDownloadItem.SaveItemFile;
1178 Body, oldBody: TStringList;
1187 // KokoTxt : string;
1188 // KokoIdx : Integer;
1190 // NewIdx : Integer;
1191 // LastTxt : string;
1194 FileName := ThreadItem.GetThreadFileName;
1196 if not ThreadItem.IsBoardPlugInAvailable then begin
1197 if Trim(Content) = '' then
1200 GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName));
1203 Body := TStringList.Create;
1207 // if FileExists(FileName) and (ResponseCode = 206) then begin
1208 if FileExists(FileName) and (State = gdsDiffComplete) then begin
1213 Body.LoadFromFile(FileName);
1214 OldCnt := Body.Count;
1215 Body.Text := Body.Text + Content;
1216 Body.SaveToFile(FileName);
1217 NewRes := Body.Count - OldCnt;
1219 on E:EFOpenError do begin
1227 //Cnt := Body.Count;
1229 if IsAbone then begin
1230 //
\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µ
1231 oldBody := TStringList.Create;
1237 oldBody.LoadFromFile(FileName);
1239 on E:EFOpenError do begin
1250 Body.Text := Content;
1251 if (ThreadItem.Kokomade > 0) and (ThreadItem.Kokomade <= oldBody.Count) then begin
1252 ThreadItem.Kokomade := Body.IndexOf(oldBody.Strings[ ThreadItem.Kokomade - 1 ]);
1253 if ThreadItem.Kokomade <> -1 then ThreadItem.Kokomade := ThreadItem.Kokomade + 1;
1256 LastIdx := oldBody.Count;
1259 OldCnt := Body.IndexOf(oldBody.Strings[ LastIdx ]) + 1;
1260 until ( OldCnt <> 0 ) or (LastIdx = 0);
1262 if OldCnt >= Body.Count then OldCnt := Body.Count - 1;
1263 NewRes := Body.Count - OldCnt;
1271 Body.Text := Content;
1272 //ThreadItem.Count := 0;
1274 NewRes := Body.Count;
1275 //Cnt := Body.Count;
1277 // if Body.Count > 0 then
1279 Body.SaveToFile(FileName);
1281 if ThreadItem.Title = '' then begin
1282 Res := GikoSys.DivideStrLine(Body[0]);
1283 ThreadItem.Title := Res.FTitle;
1285 ThreadItem.Size := 0;
1292 ThreadItem.Size := ThreadItem.Size + ContentLength;
1293 ThreadItem.LastModified := LastModified;
1294 ThreadItem.Count := Cnt;
1295 //ThreadItem.AllResCount := Cnt;
1296 ThreadItem.NewResCount := NewRes;
1297 ThreadItem.NewReceive := OldCnt + 1;
1299 ThreadItem.AllResCount := ThreadItem.Count;
1300 ThreadItem.IsLogFile := True;
1301 ThreadItem.RoundDate := Now;
1302 if not ThreadItem.UnRead then begin
1303 ThreadItem.UnRead := True;
1304 ThreadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead + 1;
1306 // if ThreadItem.RoundNo = 6 then
1307 // ThreadItem.RoundNo := 0;
1309 //
\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
1310 //
\90³
\8fí
\8fI
\97¹
\8e\9e\82É
\82Í
\8dí
\8f\9c
1311 //
\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
1312 ini := TMemIniFile.Create(ChangeFileExt(FileName, '.tmp'));
1314 ini.WriteDateTime('Setting', 'RoundDate', ThreadItem.RoundDate);
1315 ini.WriteDateTime('Setting', 'LastModified', ThreadItem.LastModified);
1316 ini.WriteInteger('Setting', 'Size', ThreadItem.Size);
1317 ini.WriteInteger('Setting', 'Count', ThreadItem.Count);
1318 ini.WriteInteger('Setting', 'AllResCount', ThreadItem.AllResCount);
1319 ini.WriteInteger('Setting', 'NewResCount', ThreadItem.NewResCount);
1320 ini.WriteInteger('Setting', 'NewReceive', ThreadItem.NewReceive);
1321 // ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo);
1322 ini.WriteBool('Setting', 'Round', ThreadItem.Round);
1323 ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead);