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;
109 constructor TDownloadThread.Create(CreateSuspended: Boolean);
111 inherited Create(CreateSuspended);
112 FIndy := TIdHttp.Create(nil);
114 FIndy.OnWorkBegin := WorkBegin;
115 FIndy.OnWorkEnd := WorkEnd;
116 FIndy.OnWork := Work;
119 destructor TDownloadThread.Destroy;
121 FIndy.Request.CustomHeaders.Clear;
122 FIndy.Request.RawHeaders.Clear;
124 FIndy.Response.CustomHeaders.Clear;
125 FIndy.Response.RawHeaders.Clear;
126 FIndy.Response.Clear;
127 FIndy.ProxyParams.Clear;
132 function RFC1123_Date(aDate : TDateTime) : String;
134 StrWeekDay : String = 'MonTueWedThuFriSatSun';
135 StrMonth : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
137 Year, Month, Day : Word;
138 Hour, Min, Sec, MSec : Word;
141 DecodeDate(aDate, Year, Month, Day);
142 DecodeTime(aDate, Hour, Min, Sec, MSec);
143 DayOfWeek := ((Trunc(aDate) - 2) mod 7);
144 Result := Copy(StrWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
145 Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
146 [Day, Copy(StrMonth, 1 + 3 * (Month - 1), 3),
147 Year, Hour, Min, Sec]);
150 procedure TDownloadThread.Execute;
152 ResStream: TMemoryStream;
155 CgiStatus: TCgiStatus;
161 DownloadResult: Boolean;
162 boardPlugIn : TBoardPlugIn;
163 lastContent : string;
164 logFile : TFileStream;
165 adjustMargin : Integer;
169 while not Terminated do begin
170 //=====
\83v
\83\89\83O
\83C
\83\93
173 ExternalBoardManager.OnWork := Work;
174 ExternalBoardManager.OnWorkBegin := WorkBegin;
175 ExternalBoardManager.OnWorkEnd := WorkEnd;
177 FDownloadTitle := '';
178 case FItem.FDownType of
181 FDownloadTitle := FItem.FBoard.Title;
182 if FItem.FBoard <> nil then begin
183 if FItem.FBoard.IsBoardPlugInAvailable then begin
184 boardPlugIn := FItem.FBoard.BoardPlugIn;
185 Item.State := TGikoDownloadState( boardPlugIn.DownloadBoard( DWORD( FItem.FBoard ) ) );
191 FDownloadTitle := FItem.FThreadItem.Title;
192 if FItem.FThreadItem <> nil then begin
193 if FItem.FThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
194 boardPlugIn := FItem.FThreadItem.ParentBoard.BoardPlugIn;
195 Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
197 //if FItem.FThreadItem.IsBoardPlugInAvailable then begin
198 // boardPlugIn := FItem.FThreadItem.BoardPlugIn;
199 // Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
204 if Length(FDownloadTitle) = 0 then
205 FDownloadTitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
207 if boardPlugIn <> nil then begin
209 Item.State := gdsAbort;
211 if Assigned( OnDownloadEnd ) then
212 Synchronize( FireDownloadEnd );
220 //=====
\83v
\83\89\83O
\83C
\83\93\82ð
\8eg
\97p
\82µ
\82È
\82¢
\8fê
\8d\87
222 FIndy.Request.CustomHeaders.Clear;
223 FIndy.Response.Clear;
225 FIndy.ProxyParams.Clear;
227 FIndy.Request.UserAgent := GikoSys.GetUserAgent;
228 FIndy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
229 FIndy.ProxyParams.BasicAuthentication := False;
230 FIndy.ReadTimeout := GikoSys.Setting.ReadTimeOut;
232 Writeln('------------------------------------------------------------');
234 //FIndy.AllowCookies := False;
235 if GikoSys.Setting.ReadProxy then begin
236 if GikoSys.Setting.ProxyProtocol then
237 FIndy.ProtocolVersion := pv1_1
239 FIndy.ProtocolVersion := pv1_0;
240 FIndy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
241 FIndy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
242 FIndy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
243 FIndy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
244 if GikoSys.Setting.ReadProxyUserID <> '' then
245 FIndy.ProxyParams.BasicAuthentication := True;
247 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
248 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
249 Writeln('
\83|
\81[
\83g: ' + IntToStr(GikoSys.Setting.ReadProxyPort));
252 if GikoSys.Setting.Protocol then
253 FIndy.ProtocolVersion := pv1_1
255 FIndy.ProtocolVersion := pv1_0;
256 FIndy.ProxyParams.ProxyServer := '';
257 FIndy.ProxyParams.ProxyPort := 80;
258 FIndy.ProxyParams.ProxyUsername := '';
259 FIndy.ProxyParams.ProxyPassword := '';
261 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
266 if Item.DownType = gdtThread then begin
267 if FileExists( Item.ThreadItem.GetThreadFileName ) then begin
268 // dat
\83t
\83@
\83C
\83\8b\82Ì
\8dÅ
\8cã
\82ð
\93Ç
\82Ý
\8fo
\82·
269 SetLength( lastContent, ADJUST_MARGIN + 1 );
270 logFile := TFileStream.Create( Item.ThreadItem.GetThreadFileName, fmOpenRead or fmShareDenyWrite );
272 logFile.Seek( -(ADJUST_MARGIN + 1), soFromEnd );
273 logFile.Read( lastContent[ 1 ], ADJUST_MARGIN + 1 );
274 lastContent := StringReplace( lastContent, #13, '', [] ); // CR
\82Ì
\8dí
\8f\9c
281 adjustMargin := Length( lastContent );
284 FIndy.Request.ContentRangeStart := 0;
285 FIndy.Request.LastModified := ZERO_DATE;
286 ResStream := TMemoryStream.Create;
289 //********************
290 //DAT or Subject
\8eæ
\93¾
291 //********************
292 Item.ResponseCode := 0;
296 if Item.DownType = gdtBoard then begin
298 Writeln('Subject
\8eæ
\93¾');
299 Writeln('URL: ' + Item.Board.GetReadCgiURL);
300 Writeln('Modified: ' + FloatToStr(Item.Board.LastModified));
302 URL := Item.Board.GetReadCgiURL;
303 if Item.ForceDownload then begin
305 ATitle := Item.Board.Title;
307 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
308 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
310 if Assigned(OnDownloadMsg) then
311 Synchronize(FireDownloadMsg);
312 Modified := ZERO_DATE
314 Modified := Item.Board.LastModified;
316 end else if Item.DownType = gdtThread then begin
318 Writeln('DAT
\8eæ
\93¾');
319 Writeln('URL: ' + Item.ThreadItem.GetDatURL);
320 Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified));
322 URL := Item.ThreadItem.GetDatURL;
323 if Item.ForceDownload then begin
325 ATitle := Item.ThreadItem.Title;
327 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
328 FMsg := '
\81\9a\8b
\90§
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82· - [' + ATitle + ']';
330 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
331 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
332 if Assigned(OnDownloadMsg) then
333 Synchronize(FireDownloadMsg);
334 Modified := ZERO_DATE;
338 Modified := Item.ThreadItem.LastModified;
339 if Item.ThreadItem.Size > 0 then begin
341 Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size));
343 //
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
\82Ì
\82½
\82ß adjustMargin
\83o
\83C
\83g
\91O
\82©
\82ç
\8eæ
\93¾
344 RangeStart := Item.ThreadItem.Size;
345 AdjustLen := -adjustMargin;
349 Item.IsAbone := False;
350 DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen);
352 Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode));
354 if Item.DownType = gdtThread then begin
355 if Item.ResponseCode = 416 then begin
356 Item.IsAbone := True;
357 DownloadResult := True;
358 end else if DownloadResult and (AdjustLen < 0) then begin
359 if Copy( Item.Content, 1, adjustMargin ) <> lastContent then
360 Item.IsAbone := True;
364 if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin
365 if Item.DownType = gdtBoard then
366 Item.Board.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date'])
368 Item.ThreadItem.ParentBoard.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date']);
371 if DownloadResult then begin
373 Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']);
375 if Item.IsAbone then begin
377 Writeln('
\82 \82Ú
\81[
\82ñ
\8c\9f\8fo');
379 ATitle := Item.ThreadItem.Title;
381 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
382 //
\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¾
385 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 + ']';
387 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
388 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
389 if Assigned(OnDownloadMsg) then
390 Synchronize(FireDownloadMsg);
391 if not DatDownload(Item.DownType, URL, ZERO_DATE, RangeStart, AdjustLen) then
392 Item.State := gdsError;
394 Writeln('
\82 \82Ú
\81[
\82ñ
\8dÄ
\8eæ
\93¾
\8cã');
395 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
397 end else if (Item.DownType = gdtThread) and (AdjustLen < 0) then begin
398 //
\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
399 Item.Content := Copy(Item.Content, adjustMargin + 1, MaxInt);
402 Item.State := gdsError;
403 if (Item.DownType = gdtBoard) and (Item.ResponseCode = 302) then begin
404 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';
406 if Assigned(OnDownloadMsg) then
407 Synchronize(FireDownloadMsg);
411 //********************
413 //********************
414 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
416 Writeln('dat.gz
\8eæ
\93¾');
418 ATitle := Item.ThreadItem.Title;
420 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
421 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 + ']';
423 if Assigned(OnDownloadMsg) then
424 Synchronize(FireDownloadMsg);
425 URL := Item.ThreadItem.GetDatgzURL;
426 Modified := Item.ThreadItem.LastModified;
429 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
430 Item.State := gdsError;
432 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
436 //********************
438 //********************
440 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
441 ATitle := Item.ThreadItem.Title;
443 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
444 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 + ']';
446 if Assigned(OnDownloadMsg) then
447 Synchronize(FireDownloadMsg);
448 URL := Item.ThreadItem.GetOldDatgzURL;
449 Modified := Item.ThreadItem.LastModified;
452 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
453 Item.State := gdsError;
457 //********************
458 //offlaw.cgi
\82Å
\8eæ
\93¾
459 //********************
461 Synchronize(GetSessionID);
462 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID <> '') then begin
464 Writeln('offlaw.cgi
\82Å
\8eæ
\93¾');
466 ATitle := Item.ThreadItem.Title;
468 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
469 FMsg := '
\81\9adat.gz
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ßofflaw.cgi
\82ð
\97\98\97p
\82µ
\82Ü
\82· - [' + ATitle + ']';
471 if Assigned(OnDownloadMsg) then
472 Synchronize(FireDownloadMsg);
473 URL := Item.ThreadItem.GetOfflawCgiURL(FSessionID);
474 Modified := Item.ThreadItem.LastModified;
477 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then begin
479 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
481 Item.State := gdsError;
483 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
484 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';
486 if Assigned(OnDownloadMsg) then
487 Synchronize(FireDownloadMsg);
491 CgiStatus := ParseCgiStatus(Item.Content);
493 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
495 case CgiStatus.FStatus of
498 Writeln('CGIStatus: OK');
500 Item.ResponseCode := 200;
501 Item.Content := DeleteStatusLine(Item.Content);
502 Item.ContentLength := CgiStatus.FSize;
505 //
\8d¡
\82Í
\82 \82è
\82¦
\82È
\82¢
507 Writeln('CGIStatus: 206');
509 Item.ResponseCode := 206;
510 Item.Content := DeleteStatusLine(Item.Content);
511 Item.ContentLength := CgiStatus.FSize;
515 Writeln('CGIStatus: 404(ERROR)');
517 Item.ResponseCode := 404;
518 Item.State := gdsError;
519 Item.ErrText := CgiStatus.FErrText;
522 if (Item.ResponseCode = 404) and (AnsiPos('
\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c©', Item.ErrText) <> 0) then begin
524 Writeln('
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾');
526 ATitle := Item.ThreadItem.Title;
528 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
529 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c© - [' + ATitle + ']';
531 if Assigned(OnDownloadMsg) then
532 Synchronize(FireDownloadMsg);
533 Idx := Pos(' ', Item.ErrText);
534 if Idx <> 0 then begin
535 URL := Copy(Item.ErrText, Idx + 1, Length(Item.ErrText));
536 if Pos( '://', URL ) = 0 then begin
537 if Pos('../', URL) = 1 then
538 URL := Copy(URL, 4, MaxInt );
539 if Pos( '/', URL ) = 1 then
540 URL := Copy( URL, 2, MaxInt );
541 URL := GikoSys.UrlToServer(Item.ThreadItem.ParentBoard.URL) + URL;
543 Modified := Item.ThreadItem.LastModified;
546 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
547 Item.State := gdsError;
549 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
555 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID = '') then begin
557 Writeln('
\83\8d\83O
\83C
\83\93\82³
\82ê
\82Ä
\82È
\82¢
\82Ì
\82Å
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾
\95s
\89Â');
559 ATitle := Item.ThreadItem.Title;
561 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
562 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 + ']';
564 if Assigned(OnDownloadMsg) then
565 Synchronize(FireDownloadMsg);
569 case Item.ResponseCode of
570 200: Item.State := gdsComplete;
571 206: Item.State := gdsDiffComplete;
572 304: Item.State := gdsNotModify;
574 Item.State := gdsError;
577 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
578 if (Item.ResponseCode in [200, 206]) and (Item.Content = '') then
579 Item.State := gdsError;
580 Item.LastModified := FIndy.Response.LastModified;
581 //
\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é
582 Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
585 FIndy.Get(URL, ResStream);
586 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
587 if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] <> #10) then begin
588 //
\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¾
589 //
\82±
\82±
\82Å
\83\81\83b
\83Z
\81[
\83W
\95\
\8e¦
\83C
\83x
\83\93\83g
591 FMsg := '
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82·';
592 if Assigned(OnDownloadMsg) then
593 Synchronize(FireDownloadMsg);
594 FIndy.Request.ContentRangeStart := 0;
595 FIndy.Request.ContentRangeEnd := 0;
598 FIndy.Get(URL, ResStream);
599 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
600 end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin
601 //
\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
602 Item.Content := Copy(Item.Content, 2, Length(Item.Content));
605 Item.State := gdsError;
607 Item.ResponseCode := FIndy.ResponseCode;
612 FIndy.Get(URL, ResStream);
613 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
615 Item.State := gdsError;
618 CgiStatus := ParseCgiStatus(Item.Content);
619 if CgiStatus.FStatus = gcsOK then begin
620 if CgiStatus.FSize = 0 then
621 Item.State := gdsNotModify
622 else if Item.DownType = gdtBoard then
623 Item.State := gdsComplete
625 Item.State := gdsDiffComplete;
626 end else if CgiStatus.FStatus = gcsINCR then begin
627 Item.State := gdsComplete;
628 end else if CgiStatus.FStatus = gcsERR then begin
629 Item.State := gdsError;
630 Item.ErrText := CgiStatus.FErrText;
632 Item.ContentLength := CgiStatus.FSize;
635 Item.State := gdsError;
637 //Item.ResponseCode := FIndy.ResponseCode;
639 Item.State := gdsAbort;
641 if Assigned(OnDownloadEnd) then
642 Synchronize(FireDownloadEnd);
646 FIndy.Request.CustomHeaders.Clear;
647 FIndy.Request.RawHeaders.Clear;
649 FIndy.Response.CustomHeaders.Clear;
650 FIndy.Response.RawHeaders.Clear;
651 FIndy.Response.Clear;
652 FIndy.ProxyParams.Clear;
654 if Terminated then Break;
659 function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
661 ResponseCode: Integer;
662 ResStream: TMemoryStream;
665 FIndy.Request.ContentRangeStart := 0;
666 FIndy.Request.ContentRangeEnd := 0;
668 FIndy.Request.CustomHeaders.Clear;
669 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
670 FIndy.Request.LastModified := modified - OffsetFromUTC;
672 FIndy.Request.AcceptEncoding := '';
673 FIndy.Request.Accept := 'text/html';
674 ResStream := TMemoryStream.Create;
679 Writeln('URL: ' + URL);
681 FIndy.Get(URL, ResStream);
682 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
683 Item.LastModified := FIndy.Response.LastModified;
684 //
\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é
685 Item.ContentLength := Length(Item.Content);
686 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
687 if Item.Content = '' then
692 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
694 ResponseCode := FIndy.ResponseCode;
696 on E: EIdSocketError do begin
698 Item.LastModified := ZERO_DATE;
699 Item.ContentLength := 0;
700 Item.ErrText := E.Message;
703 Screen.Cursor := crDefault;
705 on E: EIdConnectException do begin
707 Item.LastModified := ZERO_DATE;
708 Item.ContentLength := 0;
709 Item.ErrText := E.Message;
712 Screen.Cursor := crDefault;
714 on E: Exception do begin
716 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
717 Writeln('E.Message: ' + E.Message);
720 Item.LastModified := ZERO_DATE;
721 Item.ContentLength := 0;
722 Item.ErrText := E.Message;
723 ResponseCode := FIndy.ResponseCode;
725 Screen.Cursor := crDefault;
729 if (Item.ContentLength = 0) and (ResponseCode = 206) then
730 Item.ResponseCode := 304
732 Item.ResponseCode := ResponseCode;
737 function TDownloadThread.DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
739 ResponseCode: Integer;
740 ResStream: TMemoryStream;
743 if (ItemType = gdtThread) and (RangeStart > 0) then begin
744 // if (ItemType = gdtThread) and (Item.ThreadItem.Size > 0) then begin
745 // FIndy.Request.ContentRangeStart := Item.ThreadItem.Size + AdjustLen;
746 FIndy.Request.ContentRangeStart := RangeStart + AdjustLen;
747 FIndy.Request.ContentRangeEnd := 0;
749 FIndy.Request.ContentRangeStart := 0;
750 FIndy.Request.ContentRangeEnd := 0;
753 FIndy.Request.CustomHeaders.Clear;
754 FIndy.Request.CacheControl := 'no-cache';
755 FIndy.Request.CustomHeaders.Add('Pragma: no-cache');
756 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
757 FIndy.Request.LastModified := modified - OffsetFromUTC;
758 //FIndy.Request.CustomHeaders.Add('If-Modified-Since: ' + RFC1123_Date(modified - OffsetFromUTC) + ' GMT');
760 // FIndy.Request.AcceptEncoding := 'gzip';
761 if RangeStart = 0 then
762 FIndy.Request.AcceptEncoding := 'gzip'
764 FIndy.Request.AcceptEncoding := '';
765 ResStream := TMemoryStream.Create;
770 Writeln('URL: ' + URL);
772 FIndy.Get(URL, ResStream);
773 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
775 if (FIndy.URL.Host = 'be.2ch.net') and (FIndy.URL.Path = '/be/') then begin
776 Item.Content := EUCtoSJIS(Item.Content);
779 Item.LastModified := FIndy.Response.LastModified;
780 //
\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é
781 // Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
782 Item.ContentLength := Length(Item.Content) + AdjustLen;
783 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
784 // if (FIndy.ResponseCode in [200, 206]) and (Item.Content = '') then
786 if Item.Content = '' then
791 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
793 ResponseCode := FIndy.ResponseCode;
795 on E: EIdSocketError do begin
797 Item.LastModified := ZERO_DATE;
798 Item.ContentLength := 0;
799 Item.ErrText := E.Message;
802 Screen.Cursor := crDefault;
804 on E: EIdConnectException do begin
806 Item.LastModified := ZERO_DATE;
807 Item.ContentLength := 0;
808 Item.ErrText := E.Message;
811 Screen.Cursor := crDefault;
813 on E: Exception do begin
815 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
816 Writeln('E.Message: ' + E.Message);
819 Item.LastModified := ZERO_DATE;
820 Item.ContentLength := 0;
821 Item.ErrText := E.Message;
822 ResponseCode := FIndy.ResponseCode;
824 Screen.Cursor := crDefault;
828 if (Item.ContentLength = 0) and (ResponseCode = 206) then
829 Item.ResponseCode := 304
831 Item.ResponseCode := ResponseCode;
836 procedure TDownloadThread.FireDownloadEnd;
838 OnDownloadEnd(self, Item);
841 procedure TDownloadThread.FireDownloadMsg;
843 OnDownloadMsg(Self, Item, FMsg, FIcon);
846 procedure TDownloadThread.GetSessionID;
848 FSessionID := GikoSys.Dolib.SessionID;
851 procedure TDownloadThread.Abort;
854 FIndy.DisconnectSocket;
855 if socket <> nil then begin
856 socket.DisconnectSocket;
860 procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
862 if Assigned(OnWorkBegin) then
863 OnWorkBegin(Sender, AWorkMode, AWorkCountMax, FNumber, FDownloadTitle);
866 procedure TDownloadThread.WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
868 if Assigned(OnWorkEnd) then
869 OnWorkEnd(Sender, AWorkMode, FNumber);
872 procedure TDownloadThread.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
874 if Assigned(OnWork) then
875 OnWork(Sender, AWorkMode, AWorkCount, FNumber);
878 function TDownloadThread.ParseCgiStatus(Content: string): TCgiStatus;
887 // [+OK]
\82Ì
\8fê
\8d\87\82Í
\8d·
\95ª
888 // [-INCR] (Incorrect)
\82Ì
\8fê
\8d\87\82Í
\82·
\82×
\82Ä
\82Ì
\83f
\81[
\83^
889 // [-ERR (
\83e
\83L
\83X
\83g)]
\82Ì
\8fê
\8d\87\82Í
\82È
\82ñ
\82©
\83G
\83\89\81[
890 //
\97á
\81F+OK 23094/512K
892 // -ERR
\82»
\82ñ
\82È
\94Â
\82È
\82¢
\82Å
\82·
893 Idx := AnsiPos(#10, Content);
894 StatusLine := Copy(Content, 0, Idx);
896 Idx := AnsiPos(' ', Content);
897 Status := Copy(StatusLine, 0, Idx - 1);
898 Line := Copy(StatusLine, Idx + 1, Length(StatusLine));
900 // Idx := AnsiPos('/', Line);
901 if Trim(Status) = '-ERR' then
904 Size := Copy(Line, 0, Idx - 1);
906 if Trim(Status) = '+OK' then
907 Result.FStatus := gcsOK
908 else if Trim(Status) = '-INCR' then
909 Result.FStatus := gcsINCR
910 else if Trim(Status) = '-ERR' then begin
911 Result.FStatus := gcsERR;
912 Result.FErrText := Msg;
919 Result.FStatus := gcsERR;
920 Result.FErrText := '
\83G
\83\89\81[
\82È
\82ñ
\82¾
\82¯
\82Ç
\81A
\82æ
\82
\95ª
\82©
\82ç
\82È
\82¢
\83G
\83\89\81[';
925 if GikoSys.IsNumeric(Size) then
926 Result.FSize := StrToInt(Size)
929 Result.FStatus := gcsERR;
930 Result.FErrText := '
\83X
\83e
\81[
\83^
\83X
\89ð
\90Í
\8e¸
\94s[' + StatusLine + ']';
934 //
\8eè
\94²
\82«
\82È
\8f\88\97\9d\82Å1
\8ds
\96Ú
\82ð
\8fÁ
\82·
935 function TDownloadThread.DeleteStatusLine(Content: string): string;
939 SList := TStringList.Create;
941 SList.Text := Content;
942 if SList.Count > 1 then
944 Result := SList.Text;
950 procedure TDownloadItem.SaveListFile;
954 NewItem: TThreadItem;
959 function MakeThreadCallBack(
960 inInstance : DWORD; // TBoardItem
\82Ì
\83C
\83\93\83X
\83^
\83\93\83X
961 inURL : PChar; //
\83X
\83\8c\83b
\83h
\82Ì URL
962 inTitle : PChar; //
\83X
\83\8c\83^
\83C
963 inCount : DWORD //
\83\8c\83X
\82Ì
\90\94
964 ) : Boolean; stdcall; //
\97ñ
\8b\93\82ð
\91±
\82¯
\82é
\82È
\82ç True
966 _ThreadItem : TThreadItem; // '_'
\82Í
\83N
\83\89\83X
\82Ì
\83v
\83\8d\83p
\83e
\83B
\82Æ
\82©
\82Ô
\82Á
\82Ä
\82é
\82Ì
\82Å
970 boardItem := TBoard( inInstance );
972 boardItem.IntData := boardItem.IntData + 1;
973 if boardItem.IntData < (boardItem.Count shr 2) then
974 index := boardItem.GetIndexFromURL( string( inURL ) )
976 index := boardItem.GetIndexFromURL( string( inURL ), True );
977 if index = -1 then begin
978 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
979 _ThreadItem := TThreadItem.Create( boardItem.BoardPlugIn, boardItem, string( inURL ) );
981 _ThreadItem.Title := string( inTitle );
982 _ThreadItem.AllResCount := inCount;
983 _ThreadItem.ParentBoard := Board;
984 _ThreadItem.No := boardItem.IntData;
985 _ThreadItem.RoundDate := ZERO_DATE;
986 _ThreadItem.LastModified := ZERO_DATE;
987 _ThreadItem.AgeSage := gasNew;
988 boardItem.Add(_ThreadItem);
990 //
\8f\87\88Ê
\82ª
\8fã
\82ª
\82Á
\82Ä
\82¢
\82ê
\82ÎAge
\82É
\82·
\82é
991 if boardItem.Items[index].No > boardItem.IntData then
992 boardItem.Items[index].AgeSage := gasAge
993 //
\8f\87\88Ê
\82ª
\8fã
\82ª
\82Á
\82Ä
\82È
\82¢
\82¯
\82Ç
\81A
\83\8c\83X
\82ª
\82Â
\82¢
\82Ä
\82½
\82ç
\81ASage
\82É
994 else if boardItem.Items[index].AllResCount <> inCount then
995 boardItem.Items[index].AgeSage := gasSage
996 //
\8f\87\88Ê
\8fã
\82ª
\82Á
\82Ä
\82È
\82¢
\82µ
\81A
\83\8c\83X
\82Ì
\91\9d\8c¸
\82à
\96³
\82¯
\82ê
\82Î
\81ANone
998 boardItem.Items[index].AgeSage := gasNone;
1000 boardItem.Items[index].No := boardItem.IntData;
1001 boardItem.Items[index].AllResCount := inCount;
1008 Writeln('SAVELIST');
1010 //Board.ListData := TList.Create;
1011 Body := TStringList.Create;
1013 //
\83_
\83E
\83\93\83\8d\81[
\83h
\93ú
\8e\9e\90Ý
\92è
\81i
\83\8d\81[
\83J
\83\8b\93ú
\8e\9e\81j
1014 Board.RoundDate := Now;
1015 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
1016 Board.LastModified := LastModified;
1019 //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é
1020 if GikoSys.Setting.DatOchiSortIndex >= 0 then begin
1021 Sort.SortNoFlag := true;
1022 Sort.SortOrder := GikoSys.Setting.DatOchiSortOrder;
1023 Sort.SortIndex := GikoSys.Setting.DatOchiSortIndex;
1024 //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
1025 Board.CustomSort(ThreadItemSortProc);
1029 rt := GetTickCount - st;
1030 Writeln('END Sortd' + IntToStr(rt) + ' ms');
1033 for i := Board.Count - 1 downto 0 do
1034 Board.Items[i].AgeSage := gasNull;
1036 if Board.IsBoardPlugInAvailable then begin
1037 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1038 //
\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Á
1039 //
\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¬
1042 rt := GetTickCount - st;
1043 Writeln('Start Enum' + IntToStr(rt) + ' ms');
1046 //
\82±
\82ê
\82ª
\92x
\82¢
\81@
\97v
\89ü
\91P
1048 Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack );
1052 rt := GetTickCount - st;
1053 Writeln('End Enum' + IntToStr(rt) + ' ms');
1056 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82É
\82µ
\82©
\82È
\82¢
\82â
\82Â
\82ç
\82ð
\8dí
\8f\9c
1057 for i := Board.Count - 1 downto 0 do begin
1058 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1062 //
\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Á
1063 for i := 0 to Board.Count - 1 do begin
1064 if(Board.Items[i].AgeSage = gasNull) and (Board.Items[i].IsLogFile) then begin
1065 Board.IntData := Board.IntData + 1;
1066 Board.Items[i].No := Board.IntData;
1067 Board.Items[i].AllResCount := Board.Items[i].Count;
1068 Board.Items[i].NewResCount := 0;
1069 Board.Items[i].AgeSage := gasNone;
1074 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1075 //
\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Á
1076 //
\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¬
1077 Body.Text := Content;
1079 for i := 0 to Body.Count - 1 do begin
1080 Rec := GikoSys.DivideSubject(Body[i]);
1081 Rec.FFileName := Trim(Rec.FFileName);
1082 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1084 index := Board.GetIndexFromFileName(Rec.FFileName);
1085 if index = -1 then begin
1086 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
1087 NewItem := TThreadItem.Create(
1090 GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
1091 NewItem.Title := Rec.FTitle;
1092 NewItem.AllResCount := Rec.FCount;
1093 NewItem.ParentBoard := Board;
1094 NewItem.No := NumCount;
1095 NewItem.RoundDate := ZERO_DATE;
1096 NewItem.LastModified := ZERO_DATE;
1097 NewItem.AgeSage := gasNew;
1100 if Board.Items[index].No > NumCount then
1101 Board.Items[index].AgeSage := gasAge
1102 else if Board.Items[index].AllResCount < Rec.FCount then
1103 Board.Items[index].AgeSage := gasSage
1105 Board.Items[index].AgeSage := gasNone;
1107 Board.Items[index].No := NumCount;
1108 Board.Items[index].AllResCount := Rec.FCount;
1111 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82Ì
\8dí
\8f\9c
1112 for i := Board.Count - 1 downto 0 do begin
1113 if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1117 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82É
\96³
\82©
\82Á
\82½
\83A
\83C
\83e
\83\80\82Ì
\8dX
\90V
1118 for i := 0 to Board.Count - 1 do begin
1119 if( Board.Items[i].AgeSage = gasNull )and (Board.Items[i].IsLogFile) then begin
1121 Board.Items[i].No := NumCount;
1122 Board.Items[i].AllResCount := Board.Items[i].Count;
1123 Board.Items[i].NewResCount := 0;
1124 Board.Items[i].AgeSage := gasNone;
1127 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1128 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1129 Body.SaveToFile(Board.GetSubjectFileName);
1138 {procedure TDownloadItem.SaveListFile;
1142 NewItem: TThreadItem;
1144 // SaveCount: Integer;
1149 NewList := TList.Create;
1150 Body := TStringList.Create;
1152 //
\8f\84\89ñ
\93ú
\8e\9e\90Ý
\92è
1153 Board.RoundDate := Now;
1154 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
1155 Board.LastModified := LastModified;
1157 //
\83\8a\83X
\83g
\95Û
\91¶
\8c\8f\90\94\8eæ
\93¾
1158 //SaveCount := MaxInt;
1160 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82©
\82ç
\83\8d\83O
\96³
\82µ
\83A
\83C
\83e
\83\80\82ð
\8dí
\8f\9c
1161 for i := Board.Count - 1 downto 0 do
1162 if not Board.Items[i].IsLogFile then
1165 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1166 //
\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Á
1167 //
\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¬
1168 Body.Text := Content;
1169 // Loop := Min(Body.Count, SaveCount);
1171 // for i := 0 to Loop - 1 do begin
1172 for i := 0 to Body.Count - 1 do begin
1173 if i = 0 then Continue; //
\82P
\8ds
\96Ú
\82Í
\83X
\83e
\81[
\83^
\83X
\8ds
\82Ì
\82½
\82ß
\8f\88\97\9d\82È
\82µ
1175 Rec := GikoSys.DivideSubject(Body[i]);
1176 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1178 index := Board.GetIndex(Rec.FFileName);
1179 if index = -1 then begin
1180 NewItem := TThreadItem.Create;
1181 NewItem.FileName := Rec.FFileName;
1182 NewItem.Title := Rec.FTitle;
1183 NewItem.Count := Rec.FCount;
1184 NewItem.ParentBoard := Board;
1185 NewItem.No := NumCount;
1186 NewItem.RoundDate := ZERO_DATE;
1187 NewItem.LastModified := ZERO_DATE;
1188 NewList.Add(NewItem);
1190 //Board.Items[index].Count := Count;
1191 Board.Items[index].No := NumCount;
1192 NewList.Add(Board.Items[index]);
1193 Board.DeleteList(index);
1197 //
\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Á
1198 for i := 0 to Board.Count - 1 do begin
1200 Board.Items[i].No := NumCount;
1201 NewList.Add(Board.Items[i]);
1204 //
\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
1205 for i := Board.Count - 1 downto 0 do
1206 Board.DeleteList(i);
1208 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
1209 for i := 0 to NewList.Count - 1 do
1210 Board.Add(TThreadItem(NewList[i]));
1212 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1213 // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1214 // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1215 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1216 Body.SaveToFile(Board.GetSubjectFileName);
1223 procedure TDownloadItem.SaveItemFile;
1225 Body, oldBody: TStringList;
1234 // KokoTxt : string;
1235 // KokoIdx : Integer;
1237 // NewIdx : Integer;
1238 // LastTxt : string;
1241 FileName := ThreadItem.GetThreadFileName;
1243 //if not ThreadItem.IsBoardPlugInAvailable then begin
1244 if not ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
1245 if Trim(Content) = '' then
1248 GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName));
1251 Body := TStringList.Create;
1255 // if FileExists(FileName) and (ResponseCode = 206) then begin
1256 if FileExists(FileName) and (State = gdsDiffComplete) then begin
1261 Body.LoadFromFile(FileName);
1262 OldCnt := Body.Count;
1263 Body.Text := Body.Text + Content;
1264 Body.SaveToFile(FileName);
1265 NewRes := Body.Count - OldCnt;
1267 on E:EFOpenError do begin
1275 //Cnt := Body.Count;
1277 if IsAbone then begin
1278 //
\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µ
1279 oldBody := TStringList.Create;
1285 oldBody.LoadFromFile(FileName);
1287 on E:EFOpenError do begin
1298 Body.Text := Content;
1299 if (ThreadItem.Kokomade > 0) and (ThreadItem.Kokomade <= oldBody.Count) then begin
1300 ThreadItem.Kokomade := Body.IndexOf(oldBody.Strings[ ThreadItem.Kokomade - 1 ]);
1301 if ThreadItem.Kokomade <> -1 then ThreadItem.Kokomade := ThreadItem.Kokomade + 1;
1304 LastIdx := oldBody.Count;
1307 OldCnt := Body.IndexOf(oldBody.Strings[ LastIdx ]) + 1;
1308 until ( OldCnt <> 0 ) or (LastIdx = 0);
1310 if OldCnt >= Body.Count then OldCnt := Body.Count - 1;
1311 NewRes := Body.Count - OldCnt;
1313 //
\82±
\82±
\82Ü
\82Å
\93Ç
\82ñ
\82¾
\82ª
\90V
\92\85\83\8c\83X
\94Ô
\82ð
\92´
\82³
\82È
\82¢
\82æ
\82¤
\82É(
\88Ù
\8fí
\8fI
\97¹
\8e\9e\82Ì
\83\8a\83J
\83o
\83\8a)
1314 if ThreadItem.Kokomade > OldCnt then begin
1316 ThreadItem.Kokomade := OldCnt
1318 ThreadItem.Kokomade := 1;
1326 Body.Text := Content;
1327 //ThreadItem.Count := 0;
1329 NewRes := Body.Count;
1330 //Cnt := Body.Count;
1332 // if Body.Count > 0 then
1334 Body.SaveToFile(FileName);
1336 if ThreadItem.Title = '' then begin
1337 Res := GikoSys.DivideStrLine(Body[0]);
1338 ThreadItem.Title := Res.FTitle;
1340 ThreadItem.Size := 0;
1347 ThreadItem.Size := ThreadItem.Size + ContentLength;
1348 ThreadItem.LastModified := LastModified;
1349 ThreadItem.Count := Cnt;
1350 //ThreadItem.AllResCount := Cnt;
1351 ThreadItem.NewResCount := NewRes;
1352 ThreadItem.NewReceive := OldCnt + 1;
1354 ThreadItem.AllResCount := ThreadItem.Count;
1355 ThreadItem.IsLogFile := True;
1356 ThreadItem.RoundDate := Now;
1357 if not ThreadItem.UnRead then begin
1358 ThreadItem.UnRead := True;
1359 ThreadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead + 1;
1361 // if ThreadItem.RoundNo = 6 then
1362 // ThreadItem.RoundNo := 0;
1364 //
\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
1365 //
\90³
\8fí
\8fI
\97¹
\8e\9e\82É
\82Í
\8dí
\8f\9c
1366 //
\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
1367 ini := TMemIniFile.Create(ChangeFileExt(FileName, '.tmp'));
1369 ini.WriteDateTime('Setting', 'RoundDate', ThreadItem.RoundDate);
1370 ini.WriteDateTime('Setting', 'LastModified', ThreadItem.LastModified);
1371 ini.WriteInteger('Setting', 'Size', ThreadItem.Size);
1372 ini.WriteInteger('Setting', 'Count', ThreadItem.Count);
1373 ini.WriteInteger('Setting', 'AllResCount', ThreadItem.AllResCount);
1374 ini.WriteInteger('Setting', 'NewResCount', ThreadItem.NewResCount);
1375 ini.WriteInteger('Setting', 'NewReceive', ThreadItem.NewReceive);
1376 // ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo);
1377 ini.WriteBool('Setting', 'Round', ThreadItem.Round);
1378 ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead);