6 Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP,
7 {HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,}
8 GikoSystem, BoardGroup, MonaUtils, ExternalBoardManager;
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) 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;
45 procedure FireDownloadEnd;
46 procedure FireDownloadMsg;
47 procedure GetSessionID;
48 procedure WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
49 procedure WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
50 procedure Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
51 function ParseCgiStatus(Content: string): TCgiStatus;
52 function CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
53 function DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
54 function DeleteStatusLine(Content: string): string;
56 procedure Execute; override;
58 property Item: TDownloadItem read FItem write FItem;
59 property Number: Integer read FNumber write FNumber;
60 constructor Create(CreateSuspended: Boolean);
61 destructor Destroy; override;
63 property OnWork: TGikoWorkEvent read FOnWork write FOnWork;
64 property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin;
65 property OnWorkEnd: TGikoWorkEndEvent read FOnWorkEnd write FOnWorkEnd;
66 property OnDownloadEnd: TDownloadEndEvent read FOnDownloadEnd write FOnDownloadEnd;
67 property OnDownloadMsg: TDownloadMsgEvent read FOnDownloadMsg write FOnDownloadMsg;
70 TDownloadItem = class(TObject)
72 FDownType: TGikoDownloadType;
74 FThreadItem: TThreadItem;
76 FContentLength: Integer;
77 FLastModified: TDateTime;
79 FResponseCode: Smallint;
80 FState: TGikoDownloadState;
83 procedure SaveListFile;
84 procedure SaveItemFile;
86 property DownType: TGikoDownloadType read FDownType write FDownType;
87 property Board: TBoard read FBoard write FBoard;
88 property ThreadItem: TThreadItem read FThreadItem write FThreadItem;
90 property ContentLength: Integer read FContentLength write FContentLength;
91 property LastModified: TDateTime read FLastModified write FLastModified;
92 property Content: string read FContent write FContent;
93 property ResponseCode: Smallint read FResponseCode write FResponseCode;
94 property State: TGikoDownloadState read FState write FState;
95 property ErrText: string read FErrText write FErrText;
100 constructor TDownloadThread.Create(CreateSuspended: Boolean);
102 inherited Create(CreateSuspended);
103 FIndy := TIdHttp.Create(nil);
105 FIndy.OnWorkBegin := WorkBegin;
106 FIndy.OnWorkEnd := WorkEnd;
107 FIndy.OnWork := Work;
110 destructor TDownloadThread.Destroy;
116 function RFC1123_Date(aDate : TDateTime) : String;
118 StrWeekDay : String = 'MonTueWedThuFriSatSun';
119 StrMonth : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
121 Year, Month, Day : Word;
122 Hour, Min, Sec, MSec : Word;
125 DecodeDate(aDate, Year, Month, Day);
126 DecodeTime(aDate, Hour, Min, Sec, MSec);
127 DayOfWeek := ((Trunc(aDate) - 2) mod 7);
128 Result := Copy(StrWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
129 Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
130 [Day, Copy(StrMonth, 1 + 3 * (Month - 1), 3),
131 Year, Hour, Min, Sec]);
134 procedure TDownloadThread.Execute;
136 ResStream: TMemoryStream;
139 CgiStatus: TCgiStatus;
145 DownloadResult: Boolean;
148 boardPlugIn : TBoardPlugIn;
149 listContent : string;
151 while not Terminated do begin
152 //=====
\83v
\83\89\83O
\83C
\83\93
154 ExternalBoardManager.OnWork := Work;
155 ExternalBoardManager.OnWorkBegin := WorkBegin;
156 ExternalBoardManager.OnWorkEnd := WorkEnd;
158 case FItem.FDownType of
161 if FItem.FBoard <> nil then begin
162 if FItem.FBoard.IsBoardPlugInAvailable then begin
163 boardPlugIn := FItem.FBoard.BoardPlugIn;
164 Item.State := TGikoDownloadState( boardPlugIn.DownloadBoard( DWORD( FItem.FBoard ) ) );
170 if FItem.FThreadItem <> nil then begin
171 if FItem.FThreadItem.IsBoardPlugInAvailable then begin
172 boardPlugIn := FItem.FThreadItem.BoardPlugIn;
173 Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
179 if boardPlugIn <> nil then begin
181 Item.State := gdsAbort;
182 if Assigned( OnDownloadEnd ) then
183 Synchronize( FireDownloadEnd );
191 //=====
\83v
\83\89\83O
\83C
\83\93\82ð
\8eg
\97p
\82µ
\82È
\82¢
\8fê
\8d\87
193 FIndy.Request.CustomHeaders.Clear;
194 FIndy.Response.Clear;
196 FIndy.ProxyParams.Clear;
198 FIndy.Request.UserAgent := GikoSys.GetUserAgent;
199 FIndy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
200 FIndy.ProxyParams.BasicAuthentication := False;
202 Writeln('------------------------------------------------------------');
204 //FIndy.AllowCookies := False;
205 if GikoSys.Setting.ReadProxy then begin
206 if GikoSys.Setting.ProxyProtocol then
207 FIndy.ProtocolVersion := pv1_1
209 FIndy.ProtocolVersion := pv1_0;
210 FIndy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
211 FIndy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
212 FIndy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
213 FIndy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
214 if GikoSys.Setting.ReadProxyUserID <> '' then
215 FIndy.ProxyParams.BasicAuthentication := True;
217 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
218 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
219 Writeln('
\83|
\81[
\83g: ' + IntToStr(GikoSys.Setting.ReadProxyPort));
222 if GikoSys.Setting.Protocol then
223 FIndy.ProtocolVersion := pv1_1
225 FIndy.ProtocolVersion := pv1_0;
226 FIndy.ProxyParams.ProxyServer := '';
227 FIndy.ProxyParams.ProxyPort := 80;
228 FIndy.ProxyParams.ProxyUsername := '';
229 FIndy.ProxyParams.ProxyPassword := '';
231 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
235 FIndy.Request.ContentRangeStart := 0;
236 FIndy.Request.LastModified := ZERO_DATE;
237 ResStream := TMemoryStream.Create;
240 //********************
241 //DAT or Subject
\8eæ
\93¾
242 //********************
243 Item.ResponseCode := 0;
247 if Item.DownType = gdtBoard then begin
249 Writeln('Subject
\8eæ
\93¾');
250 Writeln('URL: ' + Item.Board.GetReadCgiURL);
251 Writeln('Modified: ' + FloatToStr(Item.Board.LastModified));
253 URL := Item.Board.GetReadCgiURL;
254 Modified := Item.Board.LastModified;
255 end else if Item.DownType = gdtThread then begin
257 Writeln('DAT
\8eæ
\93¾');
258 Writeln('URL: ' + Item.ThreadItem.GetDatURL);
259 Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified));
261 URL := Item.ThreadItem.GetDatURL;
262 Modified := Item.ThreadItem.LastModified;
263 if Item.ThreadItem.Size > 0 then begin
265 Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size));
267 //
\82 \82Ú
\81[
\82ñ
\83`
\83F
\83b
\83N
\82Ì
\82½
\82ß
\82P
\83o
\83C
\83g
\91O
\82©
\82ç
\8eæ
\93¾
268 RangeStart := Item.ThreadItem.Size;
273 DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen);
275 Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode));
277 if Item.DownType = gdtThread then begin
278 if Item.ResponseCode = 416 then begin
280 DownloadResult := True;
281 end else if DownloadResult and (AdjustLen = -1) and (Item.Content[1] <> #10) then
285 if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin
286 if Item.DownType = gdtBoard then
287 Item.Board.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date'])
289 Item.ThreadItem.ParentBoard.LastGetTime := MonaUtils.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date']);
292 if DownloadResult then begin
294 Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']);
298 Writeln('
\82 \82Ú
\81[
\82ñ
\8c\9f\8fo');
300 ATitle := Item.ThreadItem.Title;
302 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
303 //
\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¾
306 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 + ']';
308 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
309 DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
310 if Assigned(OnDownloadMsg) then
311 Synchronize(FireDownloadMsg);
312 if not DatDownload(Item.DownType, URL, ZERO_DATE, RangeStart, AdjustLen) then
313 Item.State := gdsError;
315 Writeln('
\82 \82Ú
\81[
\82ñ
\8dÄ
\8eæ
\93¾
\8cã');
316 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
318 end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin
319 //
\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
320 Item.Content := Copy(Item.Content, 2, Length(Item.Content));
323 Item.State := gdsError;
324 if (Item.DownType = gdtBoard) and (Item.ResponseCode = 302) then begin
325 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';
327 if Assigned(OnDownloadMsg) then
328 Synchronize(FireDownloadMsg);
332 //********************
334 //********************
335 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
337 Writeln('dat.gz
\8eæ
\93¾');
339 ATitle := Item.ThreadItem.Title;
341 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
342 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 + ']';
344 if Assigned(OnDownloadMsg) then
345 Synchronize(FireDownloadMsg);
346 URL := Item.ThreadItem.GetDatgzURL;
347 Modified := Item.ThreadItem.LastModified;
350 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
351 Item.State := gdsError;
353 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
357 //********************
359 //********************
361 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
362 ATitle := Item.ThreadItem.Title;
364 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
365 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 + ']';
367 if Assigned(OnDownloadMsg) then
368 Synchronize(FireDownloadMsg);
369 URL := Item.ThreadItem.GetOldDatgzURL;
370 Modified := Item.ThreadItem.LastModified;
373 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
374 Item.State := gdsError;
378 //********************
379 //offlaw.cgi
\82Å
\8eæ
\93¾
380 //********************
382 Synchronize(GetSessionID);
383 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID <> '') then begin
385 Writeln('offlaw.cgi
\82Å
\8eæ
\93¾');
387 ATitle := Item.ThreadItem.Title;
389 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
390 FMsg := '
\81\9adat.gz
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ßofflaw.cgi
\82ð
\97\98\97p
\82µ
\82Ü
\82· - [' + ATitle + ']';
392 if Assigned(OnDownloadMsg) then
393 Synchronize(FireDownloadMsg);
394 URL := Item.ThreadItem.GetOfflawCgiURL(FSessionID);
395 Modified := Item.ThreadItem.LastModified;
398 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then begin
400 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
402 Item.State := gdsError;
404 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
405 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';
407 if Assigned(OnDownloadMsg) then
408 Synchronize(FireDownloadMsg);
412 CgiStatus := ParseCgiStatus(Item.Content);
414 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
416 case CgiStatus.FStatus of
419 Writeln('CGIStatus: OK');
421 Item.ResponseCode := 200;
422 Item.Content := DeleteStatusLine(Item.Content);
423 Item.ContentLength := CgiStatus.FSize;
426 //
\8d¡
\82Í
\82 \82è
\82¦
\82È
\82¢
428 Writeln('CGIStatus: 206');
430 Item.ResponseCode := 206;
431 Item.Content := DeleteStatusLine(Item.Content);
432 Item.ContentLength := CgiStatus.FSize;
436 Writeln('CGIStatus: 404(ERROR)');
438 Item.ResponseCode := 404;
439 Item.State := gdsError;
440 Item.ErrText := CgiStatus.FErrText;
443 if (Item.ResponseCode = 404) and (AnsiPos('
\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c©', Item.ErrText) <> 0) then begin
445 Writeln('
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾');
447 ATitle := Item.ThreadItem.Title;
449 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
450 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O
\91q
\8cÉ
\82Å
\94
\8c© - [' + ATitle + ']';
452 if Assigned(OnDownloadMsg) then
453 Synchronize(FireDownloadMsg);
454 Idx := Pos(' ', Item.ErrText);
455 if Idx <> 0 then begin
456 URL := Copy(Item.ErrText, Idx + 1, Length(Item.ErrText));
457 if Pos( '://', URL ) = 0 then begin
458 if Pos('../', URL) = 1 then
459 URL := Copy(URL, 4, MaxInt );
460 if Pos( '/', URL ) = 1 then
461 URL := Copy( URL, 2, MaxInt );
462 URL := GikoSys.UrlToServer(Item.ThreadItem.ParentBoard.URL) + URL;
464 Modified := Item.ThreadItem.LastModified;
467 if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
468 Item.State := gdsError;
470 Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
476 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID = '') then begin
478 Writeln('
\83\8d\83O
\83C
\83\93\82³
\82ê
\82Ä
\82È
\82¢
\82Ì
\82Å
\89ß
\8b\8e\83\8d\83O
\8eæ
\93¾
\95s
\89Â');
480 ATitle := Item.ThreadItem.Title;
482 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
483 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 + ']';
485 if Assigned(OnDownloadMsg) then
486 Synchronize(FireDownloadMsg);
491 if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
492 ATitle := Item.ThreadItem.Title;
494 ATitle := '
\81i
\96¼
\8fÌ
\95s
\96¾
\81j';
495 FMsg := '
\81\9a\89ß
\8b\8e\83\8d\83O(1)
\82ª
\91¶
\8dÝ
\82µ
\82È
\82¢
\82½
\82ßgoogle
\83L
\83\83\83b
\83V
\83\85\82©
\82ç
\92T
\82µ
\82Ü
\82· - [' + ATitle + ']';
497 if Assigned(OnDownloadMsg) then
498 Synchronize(FireDownloadMsg);
499 URL := 'http://www.google.co.jp/search?q=cache:' + Item.ThreadItem.URL;
500 URL := StringReplace( URL, 'l50', '', [rfReplaceAll] );
501 Modified := Item.ThreadItem.LastModified;
503 if not CgiDownload(Item.DownType, URL, Modified) then
504 Item.State := gdsError;
505 URL := FIndy.Response.Location;
506 Until Item.ResponseCode <> 301;
507 if Item.ResponseCode = 200 then begin
508 foundPos := Pos( '<dt>', Item.Content ) + Length( '<dt>' );
509 Item.Content := Copy( Item.Content, foundPos, Length( Item.Content ) );
510 foundPos := Pos( '</dl>', Item.Content );
512 Item.Content := Copy( Item.Content, 1, foundPos - 1 );
513 Item.Content := StringReplace( Item.Content, '<dt>', '<>' + #13#10, [rfReplaceAll] );
514 Item.Content := StringReplace( Item.Content, '<a href="mailto:', '', [rfReplaceAll] );
515 Item.Content := StringReplace( Item.Content, '"><b>', '<>', [rfReplaceAll] );
516 Item.Content := StringReplace( Item.Content, '<b>', '<>', [rfReplaceAll] );
517 Item.Content := StringReplace( Item.Content, '</b></a>', '<>', [rfReplaceAll] );
518 Item.Content := StringReplace( Item.Content, '</b>', '<>', [rfReplaceAll] );
519 Item.Content := StringReplace( Item.Content, '<dd>', '<>', [rfReplaceAll] );
524 case Item.ResponseCode of
525 200: Item.State := gdsComplete;
526 206: Item.State := gdsDiffComplete;
527 304: Item.State := gdsNotModify;
529 Item.State := gdsError;
532 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
533 if (Item.ResponseCode in [200, 206]) and (Item.Content = '') then
534 Item.State := gdsError;
535 Item.LastModified := FIndy.Response.LastModified;
536 //
\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é
537 Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
540 FIndy.Get(URL, ResStream);
541 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
542 if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] <> #10) then begin
543 //
\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¾
544 //
\82±
\82±
\82Å
\83\81\83b
\83Z
\81[
\83W
\95\
\8e¦
\83C
\83x
\83\93\83g
546 FMsg := '
\81u
\82 \82Ú
\81[
\82ñ
\81v
\82ð
\8c\9f\8fo
\82µ
\82½
\82Ì
\82Å
\8dÄ
\8eæ
\93¾
\82ð
\8ds
\82¢
\82Ü
\82·';
547 if Assigned(OnDownloadMsg) then
548 Synchronize(FireDownloadMsg);
549 FIndy.Request.ContentRangeStart := 0;
550 FIndy.Request.ContentRangeEnd := 0;
553 FIndy.Get(URL, ResStream);
554 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
555 end else if (Item.DownType = gdtThread) and (AdjustLen = -1) and (Item.Content[1] = #10) then begin
556 //
\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
557 Item.Content := Copy(Item.Content, 2, Length(Item.Content));
560 Item.State := gdsError;
562 Item.ResponseCode := FIndy.ResponseCode;
567 FIndy.Get(URL, ResStream);
568 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
570 Item.State := gdsError;
573 CgiStatus := ParseCgiStatus(Item.Content);
574 if CgiStatus.FStatus = gcsOK then begin
575 if CgiStatus.FSize = 0 then
576 Item.State := gdsNotModify
577 else if Item.DownType = gdtBoard then
578 Item.State := gdsComplete
580 Item.State := gdsDiffComplete;
581 end else if CgiStatus.FStatus = gcsINCR then begin
582 Item.State := gdsComplete;
583 end else if CgiStatus.FStatus = gcsERR then begin
584 Item.State := gdsError;
585 Item.ErrText := CgiStatus.FErrText;
587 Item.ContentLength := CgiStatus.FSize;
590 Item.State := gdsError;
592 //Item.ResponseCode := FIndy.ResponseCode;
594 Item.State := gdsAbort;
596 if Assigned(OnDownloadEnd) then
597 Synchronize(FireDownloadEnd);
600 if Terminated then Break;
605 function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
607 ResponseCode: Integer;
608 ResStream: TMemoryStream;
611 FIndy.Request.ContentRangeStart := 0;
612 FIndy.Request.ContentRangeEnd := 0;
614 FIndy.Request.CustomHeaders.Clear;
615 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
616 FIndy.Request.LastModified := modified - OffsetFromUTC;
618 FIndy.Request.AcceptEncoding := '';
619 FIndy.Request.Accept := 'text/html';
620 ResStream := TMemoryStream.Create;
625 Writeln('URL: ' + URL);
627 FIndy.Get(URL, ResStream);
628 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
629 Item.LastModified := FIndy.Response.LastModified;
630 //
\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é
631 Item.ContentLength := Length(Item.Content);
632 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
633 if Item.Content = '' then
638 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
640 ResponseCode := FIndy.ResponseCode;
642 on E: EIdSocketError do begin
644 Item.LastModified := ZERO_DATE;
645 Item.ContentLength := 0;
646 Item.ErrText := E.Message;
649 Screen.Cursor := crDefault;
651 on E: EIdConnectException do begin
653 Item.LastModified := ZERO_DATE;
654 Item.ContentLength := 0;
655 Item.ErrText := E.Message;
658 Screen.Cursor := crDefault;
660 on E: Exception do begin
662 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
663 Writeln('E.Message: ' + E.Message);
666 Item.LastModified := ZERO_DATE;
667 Item.ContentLength := 0;
668 Item.ErrText := E.Message;
669 ResponseCode := FIndy.ResponseCode;
671 Screen.Cursor := crDefault;
675 if (Item.ContentLength = 0) and (ResponseCode = 206) then
676 Item.ResponseCode := 304
678 Item.ResponseCode := ResponseCode;
683 function TDownloadThread.DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
685 ResponseCode: Integer;
686 ResStream: TMemoryStream;
689 if (ItemType = gdtThread) and (RangeStart > 0) then begin
690 // if (ItemType = gdtThread) and (Item.ThreadItem.Size > 0) then begin
691 // FIndy.Request.ContentRangeStart := Item.ThreadItem.Size + AdjustLen;
692 FIndy.Request.ContentRangeStart := RangeStart + AdjustLen;
693 FIndy.Request.ContentRangeEnd := 0;
695 FIndy.Request.ContentRangeStart := 0;
696 FIndy.Request.ContentRangeEnd := 0;
699 FIndy.Request.CustomHeaders.Clear;
700 FIndy.Request.CacheControl := 'no-cache';
701 FIndy.Request.CustomHeaders.Add('Pragma: no-cache');
702 if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
703 FIndy.Request.LastModified := modified - OffsetFromUTC;
704 //FIndy.Request.CustomHeaders.Add('If-Modified-Since: ' + RFC1123_Date(modified - OffsetFromUTC) + ' GMT');
706 // FIndy.Request.AcceptEncoding := 'gzip';
707 if RangeStart = 0 then
708 FIndy.Request.AcceptEncoding := 'gzip'
710 FIndy.Request.AcceptEncoding := '';
711 ResStream := TMemoryStream.Create;
716 Writeln('URL: ' + URL);
718 FIndy.Get(URL, ResStream);
719 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
720 Item.LastModified := FIndy.Response.LastModified;
721 //
\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é
722 // Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
723 Item.ContentLength := Length(Item.Content) + AdjustLen;
724 //
\96³
\82¢
\82Æ
\8ev
\82¤
\82¯
\82Ç
\81B
\81B
\81B
725 // if (FIndy.ResponseCode in [200, 206]) and (Item.Content = '') then
727 if Item.Content = '' then
732 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
734 ResponseCode := FIndy.ResponseCode;
736 on E: EIdSocketError do begin
738 Item.LastModified := ZERO_DATE;
739 Item.ContentLength := 0;
740 Item.ErrText := E.Message;
743 Screen.Cursor := crDefault;
745 on E: EIdConnectException do begin
747 Item.LastModified := ZERO_DATE;
748 Item.ContentLength := 0;
749 Item.ErrText := E.Message;
752 Screen.Cursor := crDefault;
754 on E: Exception do begin
756 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
757 Writeln('E.Message: ' + E.Message);
760 Item.LastModified := ZERO_DATE;
761 Item.ContentLength := 0;
762 Item.ErrText := E.Message;
763 ResponseCode := FIndy.ResponseCode;
765 Screen.Cursor := crDefault;
769 if (Item.ContentLength = 0) and (ResponseCode = 206) then
770 Item.ResponseCode := 304
772 Item.ResponseCode := ResponseCode;
777 procedure TDownloadThread.FireDownloadEnd;
779 OnDownloadEnd(self, Item);
782 procedure TDownloadThread.FireDownloadMsg;
784 OnDownloadMsg(Self, Item, FMsg, FIcon);
787 procedure TDownloadThread.GetSessionID;
789 FSessionID := GikoSys.Dolib.SessionID;
792 procedure TDownloadThread.Abort;
795 FIndy.DisconnectSocket;
798 procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
800 if Assigned(OnWorkBegin) then
801 OnWorkBegin(Sender, AWorkMode, AWorkCountMax, FNumber);
804 procedure TDownloadThread.WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
806 if Assigned(OnWorkEnd) then
807 OnWorkEnd(Sender, AWorkMode, FNumber);
810 procedure TDownloadThread.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
812 if Assigned(OnWork) then
813 OnWork(Sender, AWorkMode, AWorkCount, FNumber);
816 function TDownloadThread.ParseCgiStatus(Content: string): TCgiStatus;
825 // [+OK]
\82Ì
\8fê
\8d\87\82Í
\8d·
\95ª
826 // [-INCR] (Incorrect)
\82Ì
\8fê
\8d\87\82Í
\82·
\82×
\82Ä
\82Ì
\83f
\81[
\83^
827 // [-ERR (
\83e
\83L
\83X
\83g)]
\82Ì
\8fê
\8d\87\82Í
\82È
\82ñ
\82©
\83G
\83\89\81[
828 //
\97á
\81F+OK 23094/512K
830 // -ERR
\82»
\82ñ
\82È
\94Â
\82È
\82¢
\82Å
\82·
831 Idx := AnsiPos(#10, Content);
832 StatusLine := Copy(Content, 0, Idx);
834 Idx := AnsiPos(' ', Content);
835 Status := Copy(StatusLine, 0, Idx - 1);
836 Line := Copy(StatusLine, Idx + 1, Length(StatusLine));
838 // Idx := AnsiPos('/', Line);
839 if Trim(Status) = '-ERR' then
842 Size := Copy(Line, 0, Idx - 1);
844 if Trim(Status) = '+OK' then
845 Result.FStatus := gcsOK
846 else if Trim(Status) = '-INCR' then
847 Result.FStatus := gcsINCR
848 else if Trim(Status) = '-ERR' then begin
849 Result.FStatus := gcsERR;
850 Result.FErrText := Msg;
857 Result.FStatus := gcsERR;
858 Result.FErrText := '
\83G
\83\89\81[
\82È
\82ñ
\82¾
\82¯
\82Ç
\81A
\82æ
\82
\95ª
\82©
\82ç
\82È
\82¢
\83G
\83\89\81[';
863 if GikoSys.IsNumeric(Size) then
864 Result.FSize := StrToInt(Size)
867 Result.FStatus := gcsERR;
868 Result.FErrText := '
\83X
\83e
\81[
\83^
\83X
\89ð
\90Í
\8e¸
\94s[' + StatusLine + ']';
872 //
\8eè
\94²
\82«
\82È
\8f\88\97\9d\82Å1
\8ds
\96Ú
\82ð
\8fÁ
\82·
873 function TDownloadThread.DeleteStatusLine(Content: string): string;
877 SList := TStringList.Create;
879 SList.Text := Content;
880 if SList.Count > 1 then
882 Result := SList.Text;
888 procedure TDownloadItem.SaveListFile;
892 NewItem: TThreadItem;
893 // SaveCount: Integer;
897 function MakeThreadCallBack(
898 inInstance : DWORD; // TBoardItem
\82Ì
\83C
\83\93\83X
\83^
\83\93\83X
899 inURL : PChar; //
\83X
\83\8c\83b
\83h
\82Ì URL
900 inTitle : PChar; //
\83X
\83\8c\83^
\83C
901 inCount : DWORD //
\83\8c\83X
\82Ì
\90\94
902 ) : Boolean; stdcall; //
\97ñ
\8b\93\82ð
\91±
\82¯
\82é
\82È
\82ç True
904 threadItem : TThreadItem;
908 boardItem := TBoard( inInstance );
910 boardItem.IntData := boardItem.IntData + 1;
911 index := boardItem.GetIndexFromURL( string( inURL ) );
912 if index = -1 then begin
913 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
914 threadItem := TThreadItem.Create( boardItem.BoardPlugIn, string( inURL ) );
916 threadItem.Title := string( inTitle );
917 // threadItem.Count := inCount;
918 threadItem.AllResCount := inCount;
919 threadItem.ParentBoard := Board;
920 threadItem.No := boardItem.IntData;
921 threadItem.RoundDate := ZERO_DATE;
922 threadItem.LastModified := ZERO_DATE;
923 threadItem.AgeSage := gasNew;
924 boardItem.ListData.Add( threadItem );
926 //boardItem.Items[index].Count := Count;
927 //boardItem.Items[index].Count := Rec.FCount;
928 if boardItem.Items[index].No > boardItem.IntData then
929 boardItem.Items[index].AgeSage := gasAge
930 else if boardItem.Items[index].AllResCount < inCount then
931 boardItem.Items[index].AgeSage := gasSage
933 boardItem.Items[index].AgeSage := gasNone;
935 boardItem.Items[index].No := boardItem.IntData;
936 boardItem.Items[index].AllResCount := inCount;
937 // if not boardItem.Items[index].IsLogFile then
938 // boardItem.Items[index].Count := inCountt;
939 boardItem.ListData.Add( boardItem.Items[index] );
940 boardItem.DeleteList( index );
944 Board.ListData := TList.Create;
945 Body := TStringList.Create;
947 //
\83_
\83E
\83\93\83\8d\81[
\83h
\93ú
\8e\9e\90Ý
\92è
\81i
\83\8d\81[
\83J
\83\8b\93ú
\8e\9e\81j
948 Board.RoundDate := Now;
949 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
950 Board.LastModified := LastModified;
952 if Board.IsBoardPlugInAvailable then begin
953 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
954 //
\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Á
955 //
\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¬
957 Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack );
959 //
\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Á
960 for i := 0 to Board.Count - 1 do begin
961 if Board.Items[i].IsLogFile then begin
962 Board.IntData := Board.IntData + 1;
963 Board.Items[i].No := Board.IntData;
964 Board.Items[i].AllResCount := Board.Items[i].Count;
965 Board.Items[i].NewResCount := 0;
966 Board.Items[i].AgeSage := gasNone;
967 Board.ListData.Add( Board.Items[i] );
971 //
\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
972 for i := Board.Count - 1 downto 0 do
973 Board.DeleteList( i );
975 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
976 for i := 0 to Board.ListData.Count - 1 do
977 Board.Add( TThreadItem(Board.ListData[i]) );
979 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
980 //
\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Á
981 //
\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¬
982 Body.Text := Content;
984 for i := 0 to Body.Count - 1 do begin
985 //if i = 0 then Continue; //
\82P
\8ds
\96Ú
\82Í
\83X
\83e
\81[
\83^
\83X
\8ds
\82Ì
\82½
\82ß
\8f\88\97\9d\82È
\82µ
987 Rec := GikoSys.DivideSubject(Body[i]);
988 Rec.FFileName := Trim(Rec.FFileName);
989 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
991 index := Board.GetIndex(Rec.FFileName);
992 if index = -1 then begin
993 //
\90V
\82µ
\82¢
\83X
\83\8c\83b
\83h
994 NewItem := TThreadItem.Create(
995 nil, GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
996 NewItem.FileName := Rec.FFileName;
997 NewItem.Title := Rec.FTitle;
998 // NewItem.Count := Rec.FCount;
999 NewItem.AllResCount := Rec.FCount;
1000 NewItem.ParentBoard := Board;
1001 NewItem.No := NumCount;
1002 NewItem.RoundDate := ZERO_DATE;
1003 NewItem.LastModified := ZERO_DATE;
1004 NewItem.AgeSage := gasNew;
1005 Board.ListData.Add(NewItem);
1007 //Board.Items[index].Count := Count;
1008 //Board.Items[index].Count := Rec.FCount;
1009 if Board.Items[index].No > NumCount then
1010 Board.Items[index].AgeSage := gasAge
1011 else if Board.Items[index].AllResCount < Rec.FCount then
1012 Board.Items[index].AgeSage := gasSage
1014 Board.Items[index].AgeSage := gasNone;
1017 Board.Items[index].No := NumCount;
1018 Board.Items[index].AllResCount := Rec.FCount;
1019 // if not Board.Items[index].IsLogFile then
1020 // Board.Items[index].Count := Rec.FCount;
1021 Board.ListData.Add(Board.Items[index]);
1022 Board.DeleteList(index);
1026 //
\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Á
1027 for i := 0 to Board.Count - 1 do begin
1028 if Board.Items[i].IsLogFile then begin
1030 Board.Items[i].No := NumCount;
1031 Board.Items[i].AllResCount := Board.Items[i].Count;
1032 Board.Items[i].NewResCount := 0;
1033 Board.Items[i].AgeSage := gasNone;
1034 Board.ListData.Add(Board.Items[i]);
1038 //
\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
1039 for i := Board.Count - 1 downto 0 do
1040 Board.DeleteList(i);
1042 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
1043 for i := 0 to Board.ListData.Count - 1 do
1044 Board.Add(TThreadItem(Board.ListData[i]));
1046 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1047 // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1048 // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1049 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1050 Body.SaveToFile(Board.GetSubjectFileName);
1054 Board.ListData.Free;
1058 {procedure TDownloadItem.SaveListFile;
1062 NewItem: TThreadItem;
1064 // SaveCount: Integer;
1069 NewList := TList.Create;
1070 Body := TStringList.Create;
1072 //
\8f\84\89ñ
\93ú
\8e\9e\90Ý
\92è
1073 Board.RoundDate := Now;
1074 //
\83T
\81[
\83o
\8fã
\83t
\83@
\83C
\83\8b\82Ì
\8dX
\90V
\8e\9e\8d\8f\90Ý
\92è
1075 Board.LastModified := LastModified;
1077 //
\83\8a\83X
\83g
\95Û
\91¶
\8c\8f\90\94\8eæ
\93¾
1078 //SaveCount := MaxInt;
1080 //
\8cÃ
\82¢
\83\8a\83X
\83g
\82©
\82ç
\83\8d\83O
\96³
\82µ
\83A
\83C
\83e
\83\80\82ð
\8dí
\8f\9c
1081 for i := Board.Count - 1 downto 0 do
1082 if not Board.Items[i].IsLogFile then
1085 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\8dì
\90¬
\82·
\82é
1086 //
\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Á
1087 //
\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¬
1088 Body.Text := Content;
1089 // Loop := Min(Body.Count, SaveCount);
1091 // for i := 0 to Loop - 1 do begin
1092 for i := 0 to Body.Count - 1 do begin
1093 if i = 0 then Continue; //
\82P
\8ds
\96Ú
\82Í
\83X
\83e
\81[
\83^
\83X
\8ds
\82Ì
\82½
\82ß
\8f\88\97\9d\82È
\82µ
1095 Rec := GikoSys.DivideSubject(Body[i]);
1096 if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1098 index := Board.GetIndex(Rec.FFileName);
1099 if index = -1 then begin
1100 NewItem := TThreadItem.Create;
1101 NewItem.FileName := Rec.FFileName;
1102 NewItem.Title := Rec.FTitle;
1103 NewItem.Count := Rec.FCount;
1104 NewItem.ParentBoard := Board;
1105 NewItem.No := NumCount;
1106 NewItem.RoundDate := ZERO_DATE;
1107 NewItem.LastModified := ZERO_DATE;
1108 NewList.Add(NewItem);
1110 //Board.Items[index].Count := Count;
1111 Board.Items[index].No := NumCount;
1112 NewList.Add(Board.Items[index]);
1113 Board.DeleteList(index);
1117 //
\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Á
1118 for i := 0 to Board.Count - 1 do begin
1120 Board.Items[i].No := NumCount;
1121 NewList.Add(Board.Items[i]);
1124 //
\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
1125 for i := Board.Count - 1 downto 0 do
1126 Board.DeleteList(i);
1128 //
\90V
\82µ
\82¢
\83\8a\83X
\83g
\82ð
\83{
\81[
\83h
\83I
\83u
\83W
\83F
\83N
\83g
\82É
\92Ç
\89Á
1129 for i := 0 to NewList.Count - 1 do
1130 Board.Add(TThreadItem(NewList[i]));
1132 //
\83\8a\83X
\83g(subject.txt)
\82ð
\95Û
\91¶
1133 // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1134 // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1135 GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1136 Body.SaveToFile(Board.GetSubjectFileName);
1143 procedure TDownloadItem.SaveItemFile;
1153 FileName := ThreadItem.GetThreadFileName;
1155 if not ThreadItem.IsBoardPlugInAvailable then begin
1156 if Trim(Content) = '' then
1158 GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName));
1161 Body := TStringList.Create;
1163 // if FileExists(FileName) and (ResponseCode = 206) then begin
1164 if FileExists(FileName) and (State = gdsDiffComplete) then begin
1165 // Body.Text := Content;
1166 // if Body.Count > 0 then
1168 // Content := Body.Text;
1169 Body.LoadFromFile(FileName);
1170 OldCnt := Body.Count;
1171 Body.Text := Body.Text + Content;
1172 Body.SaveToFile(FileName);
1173 NewRes := Body.Count - OldCnt;
1176 Body.Text := Content;
1177 // if Body.Count > 0 then
1179 Body.SaveToFile(FileName);
1181 if ThreadItem.Title = '' then begin
1182 Res := GikoSys.DivideStrLine(Body[0]);
1183 ThreadItem.Title := Res.FTitle;
1185 ThreadItem.Size := 0;
1186 //ThreadItem.Count := 0;
1187 ThreadItem.AllResCount := 0;
1188 ThreadItem.NewResCount := 0;
1190 NewRes := Body.Count;
1197 ThreadItem.Size := ThreadItem.Size + ContentLength;
1198 ThreadItem.LastModified := LastModified;
1199 ThreadItem.Count := Cnt;
1200 ThreadItem.AllResCount := Cnt;
1201 ThreadItem.NewResCount := NewRes;
1202 ThreadItem.NewReceive := OldCnt + 1;
1205 ThreadItem.IsLogFile := True;
1206 ThreadItem.RoundDate := Now;
1207 ThreadItem.UnRead := True;
1208 ThreadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead + 1;
1209 // if ThreadItem.RoundNo = 6 then
1210 // ThreadItem.RoundNo := 0;
1212 //
\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
1213 //
\90³
\8fí
\8fI
\97¹
\8e\9e\82É
\82Í
\8dí
\8f\9c
1214 //
\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
1215 ini := TMemIniFile.Create(ChangeFileExt(FileName, '.tmp'));
1217 ini.WriteDateTime('Setting', 'RoundDate', ThreadItem.RoundDate);
1218 ini.WriteDateTime('Setting', 'LastModified', ThreadItem.LastModified);
1219 ini.WriteInteger('Setting', 'Size', ThreadItem.Size);
1220 ini.WriteInteger('Setting', 'Count', ThreadItem.Count);
1221 ini.WriteInteger('Setting', 'AllResCount', ThreadItem.AllResCount);
1222 ini.WriteInteger('Setting', 'NewResCount', ThreadItem.NewResCount);
1223 ini.WriteInteger('Setting', 'NewReceive', ThreadItem.NewReceive);
1224 // ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo);
1225 ini.WriteBool('Setting', 'Round', ThreadItem.Round);
1226 ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead);