Develop and Download Open Source Software

Browse CVS Repository

Annotation of /gikonavigoeson/gikonavi/ItemDownload.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.55 - (hide annotations) (download) (as text)
Sun Jun 25 15:04:06 2006 UTC (17 years, 9 months ago) by h677
Branch: MAIN
CVS Tags: v1_53_0_671, v1_53_0_664, v1_53_0_661, v1_53_0_663, v1_53_0_662, v1_53_0_665, v1_53_0_667, v1_53_0_666, v1_53_0_669, v1_53_0_668, v1_53_0_672, v1_53_0_670, v1_54_0_675, root-of-Bb53, v1_54_0_674, v1_52_0_660, v1_53_1_673
Branch point for: Bb53
Changes since 1.54: +3 -3 lines
File MIME type: text/x-pascal
ほとんど使用していないクラス(ファイル)の削除

1 hi_ 1.1 unit ItemDownload;
2    
3     interface
4    
5     uses
6 yoffy 1.7 Windows, SysUtils, Classes, ComCtrls, Controls, Forms, IdHTTP,
7 yoffy 1.2 {HTTPApp,} YofUtils, IdGlobal, IdException, IdComponent, IniFiles, {DateUtils,}
8 h677 1.55 GikoSystem, BoardGroup, ExternalBoardManager, ExternalBoardPlugInMain,
9 q9_ 1.31 Sort;
10 hi_ 1.1
11     type
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);
17    
18     TGikoWorkEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer; ID: Integer) of object;
19 q9_ 1.23 TGikoWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer; ID: Integer; const AWorkTitle: string) of object;
20 hi_ 1.1 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;
23    
24     TCgiStatus = record
25     FStatus: TGikoCgiStatus;
26     FSize: Integer;
27     FErrText: string;
28     end;
29    
30    
31     TDownloadThread = class(TThread)
32     private
33     FIndy: TIdHttp;
34     FItem: TDownloadItem;
35     FNumber: Integer;
36     FAbort: Boolean;
37     FMsg: string;
38     FIcon: TGikoMessageIcon;
39     FSessionID: string;
40     FOnWork: TGikoWorkEvent;
41     FOnWorkBegin: TGikoWorkBeginEvent;
42     FOnWorkEnd: TGikoWorkEndEvent;
43     FOnDownloadEnd: TDownloadEndEvent;
44     FOnDownloadMsg: TDownloadMsgEvent;
45 q9_ 1.23 FDownloadTitle: string;
46 hi_ 1.1
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 yoffy 1.13 function CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
55 hi_ 1.1 function DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
56 h677 1.51 procedure DeleteStatusLine(Item: TDownloadItem);
57 h677 1.50 procedure InitHttpClient(client: TIdHttp);
58     procedure ClearHttpClient(client: TIdHttp);
59 hi_ 1.1 protected
60     procedure Execute; override;
61     public
62     property Item: TDownloadItem read FItem write FItem;
63     property Number: Integer read FNumber write FNumber;
64     constructor Create(CreateSuspended: Boolean);
65 yoffy 1.30 destructor Destroy; override;
66 hi_ 1.1 procedure Abort;
67     property OnWork: TGikoWorkEvent read FOnWork write FOnWork;
68     property OnWorkBegin: TGikoWorkBeginEvent read FOnWorkBegin write FOnWorkBegin;
69     property OnWorkEnd: TGikoWorkEndEvent read FOnWorkEnd write FOnWorkEnd;
70     property OnDownloadEnd: TDownloadEndEvent read FOnDownloadEnd write FOnDownloadEnd;
71     property OnDownloadMsg: TDownloadMsgEvent read FOnDownloadMsg write FOnDownloadMsg;
72     end;
73    
74     TDownloadItem = class(TObject)
75     private
76     FDownType: TGikoDownloadType;
77     FBoard: TBoard;
78     FThreadItem: TThreadItem;
79    
80     FContentLength: Integer;
81     FLastModified: TDateTime;
82     FContent: string;
83     FResponseCode: Smallint;
84     FState: TGikoDownloadState;
85     FErrText: string;
86 q9_ 1.25 FForceDownload: Boolean;
87 yoffy 1.30 FIsAbone : Boolean;
88 hi_ 1.1 public
89     procedure SaveListFile;
90     procedure SaveItemFile;
91    
92     property DownType: TGikoDownloadType read FDownType write FDownType;
93     property Board: TBoard read FBoard write FBoard;
94     property ThreadItem: TThreadItem read FThreadItem write FThreadItem;
95    
96     property ContentLength: Integer read FContentLength write FContentLength;
97     property LastModified: TDateTime read FLastModified write FLastModified;
98     property Content: string read FContent write FContent;
99     property ResponseCode: Smallint read FResponseCode write FResponseCode;
100     property State: TGikoDownloadState read FState write FState;
101     property ErrText: string read FErrText write FErrText;
102 q9_ 1.25 property ForceDownload: Boolean read FForceDownload write FForceDownload;
103 yoffy 1.30 property IsAbone : Boolean read FIsAbone write FIsAbone;
104 hi_ 1.1 end;
105    
106     implementation
107    
108 h677 1.43 uses
109 h677 1.48 Y_TextConverter, MojuUtils, HTMLCreate;
110 h677 1.43
111 hi_ 1.1 constructor TDownloadThread.Create(CreateSuspended: Boolean);
112     begin
113     inherited Create(CreateSuspended);
114     FIndy := TIdHttp.Create(nil);
115    
116     FIndy.OnWorkBegin := WorkBegin;
117     FIndy.OnWorkEnd := WorkEnd;
118     FIndy.OnWork := Work;
119     end;
120    
121     destructor TDownloadThread.Destroy;
122     begin
123 h677 1.50 ClearHttpClient(FIndy);
124 hi_ 1.1 FIndy.Free;
125     inherited;
126     end;
127    
128     function RFC1123_Date(aDate : TDateTime) : String;
129     const
130     StrWeekDay : String = 'MonTueWedThuFriSatSun';
131 yoffy 1.13 StrMonth : String = 'JanFebMarAprMayJunJulAugSepOctNovDec';
132 hi_ 1.1 var
133 yoffy 1.13 Year, Month, Day : Word;
134     Hour, Min, Sec, MSec : Word;
135     DayOfWeek : Word;
136 hi_ 1.1 begin
137     DecodeDate(aDate, Year, Month, Day);
138 yoffy 1.13 DecodeTime(aDate, Hour, Min, Sec, MSec);
139 hi_ 1.1 DayOfWeek := ((Trunc(aDate) - 2) mod 7);
140     Result := Copy(StrWeekDay, 1 + DayOfWeek * 3, 3) + ', ' +
141     Format('%2.2d %s %4.4d %2.2d:%2.2d:%2.2d',
142     [Day, Copy(StrMonth, 1 + 3 * (Month - 1), 3),
143     Year, Hour, Min, Sec]);
144     end;
145 h677 1.50 // ******************************************************************
146     // HTTPClient鐃緒申鐃緒申鐃緒申鐃緒申
147     // ******************************************************************
148     procedure TDownloadThread.InitHttpClient(client: TIdHttp);
149     begin
150     ClearHttpClient(client);
151     client.Disconnect;
152     client.Request.UserAgent := GikoSys.GetUserAgent;
153     client.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
154     client.ProxyParams.BasicAuthentication := False;
155     client.ReadTimeout := GikoSys.Setting.ReadTimeOut;
156     {$IFDEF DEBUG}
157     Writeln('------------------------------------------------------------');
158     {$ENDIF}
159     //FIndy.AllowCookies := False;
160     if GikoSys.Setting.ReadProxy then begin
161     if GikoSys.Setting.ProxyProtocol then
162     client.ProtocolVersion := pv1_1
163     else
164     client.ProtocolVersion := pv1_0;
165     client.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
166     client.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
167     client.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
168     client.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
169     if GikoSys.Setting.ReadProxyUserID <> '' then
170     client.ProxyParams.BasicAuthentication := True;
171     {$IFDEF DEBUG}
172     Writeln('鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申');
173     Writeln('鐃?鐃?鐃?: ' + GikoSys.Setting.ReadProxyAddress);
174     Writeln('鐃?鐃?鐃?: ' + IntToStr(GikoSys.Setting.ReadProxyPort));
175     {$ENDIF}
176     end else begin
177     if GikoSys.Setting.Protocol then
178     client.ProtocolVersion := pv1_1
179     else
180     client.ProtocolVersion := pv1_0;
181     client.ProxyParams.ProxyServer := '';
182     client.ProxyParams.ProxyPort := 80;
183     client.ProxyParams.ProxyUsername := '';
184     client.ProxyParams.ProxyPassword := '';
185     {$IFDEF DEBUG}
186     Writeln('鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申');
187     {$ENDIF}
188     end;
189     end;
190     // ******************************************************************
191     // HTTPClient鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
192     // ******************************************************************
193     procedure TDownloadThread.ClearHttpClient(client: TIdHttp);
194     begin
195     client.Request.CustomHeaders.Clear;
196     client.Request.RawHeaders.Clear;
197     client.Request.Clear;
198     client.Response.CustomHeaders.Clear;
199     client.Response.RawHeaders.Clear;
200     client.Response.Clear;
201 hi_ 1.1
202 h677 1.50 client.ProxyParams.Clear;
203     end;
204 hi_ 1.1 procedure TDownloadThread.Execute;
205     var
206     ResStream: TMemoryStream;
207    
208     URL: string;
209     CgiStatus: TCgiStatus;
210     Modified: TDateTime;
211     RangeStart: Integer;
212     AdjustLen: Integer;
213     Idx: Integer;
214     ATitle: string;
215     DownloadResult: Boolean;
216 yoffy 1.29 boardPlugIn : TBoardPlugIn;
217     lastContent : string;
218     logFile : TFileStream;
219     adjustMargin : Integer;
220     const
221     ADJUST_MARGIN = 16;
222 hi_ 1.1 begin
223     while not Terminated do begin
224 yoffy 1.9 //===== 鐃?鐃緒申鐃?鐃?鐃緒申
225 h677 1.28 FAbort := False;
226 yoffy 1.13 boardPlugIn := nil;
227     ExternalBoardManager.OnWork := Work;
228     ExternalBoardManager.OnWorkBegin := WorkBegin;
229     ExternalBoardManager.OnWorkEnd := WorkEnd;
230    
231 q9_ 1.23 FDownloadTitle := '';
232 yoffy 1.13 case FItem.FDownType of
233     gdtBoard:
234     begin
235 q9_ 1.23 FDownloadTitle := FItem.FBoard.Title;
236 yoffy 1.13 if FItem.FBoard <> nil then begin
237     if FItem.FBoard.IsBoardPlugInAvailable then begin
238     boardPlugIn := FItem.FBoard.BoardPlugIn;
239     Item.State := TGikoDownloadState( boardPlugIn.DownloadBoard( DWORD( FItem.FBoard ) ) );
240     end;
241     end;
242     end;
243     gdtThread:
244     begin
245 q9_ 1.23 FDownloadTitle := FItem.FThreadItem.Title;
246 yoffy 1.13 if FItem.FThreadItem <> nil then begin
247 h677 1.50 if FItem.FThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
248     boardPlugIn := FItem.FThreadItem.ParentBoard.BoardPlugIn;
249     Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
250     end;
251     //if FItem.FThreadItem.IsBoardPlugInAvailable then begin
252 h677 1.43 // boardPlugIn := FItem.FThreadItem.BoardPlugIn;
253     // Item.State := TGikoDownloadState( boardPlugIn.DownloadThread( DWORD( FItem.FThreadItem ) ) );
254     //end;
255 yoffy 1.13 end;
256     end;
257     end;
258 q9_ 1.23 if Length(FDownloadTitle) = 0 then
259     FDownloadTitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
260 yoffy 1.13
261     if boardPlugIn <> nil then begin
262 h677 1.28 if FAbort then begin
263 yoffy 1.13 Item.State := gdsAbort;
264 h677 1.28 end;
265 yoffy 1.13 if Assigned( OnDownloadEnd ) then
266     Synchronize( FireDownloadEnd );
267     if Terminated then
268     Break;
269    
270     Suspend;
271     Continue;
272     end;
273 yoffy 1.9
274 h677 1.50 FAbort := False;
275 yoffy 1.9 //===== 鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
276 h677 1.50 InitHttpClient(FIndy);
277 yoffy 1.29 adjustMargin := 0;
278     if Item.DownType = gdtThread then begin
279     if FileExists( Item.ThreadItem.GetThreadFileName ) then begin
280     // dat 鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申
281     SetLength( lastContent, ADJUST_MARGIN + 1 );
282     logFile := TFileStream.Create( Item.ThreadItem.GetThreadFileName, fmOpenRead or fmShareDenyWrite );
283     try
284     logFile.Seek( -(ADJUST_MARGIN + 1), soFromEnd );
285     logFile.Read( lastContent[ 1 ], ADJUST_MARGIN + 1 );
286     lastContent := StringReplace( lastContent, #13, '', [] ); // CR 鐃緒申鐃緒申鐃緒申
287     finally
288     logFile.Free;
289     end;
290     end else begin
291     lastContent := '';
292     end;
293     adjustMargin := Length( lastContent );
294     end;
295    
296 hi_ 1.1 FIndy.Request.ContentRangeStart := 0;
297     FIndy.Request.LastModified := ZERO_DATE;
298     ResStream := TMemoryStream.Create;
299     try
300     try
301     //********************
302     //DAT or Subject鐃緒申鐃緒申
303     //********************
304     Item.ResponseCode := 0;
305     RangeStart := 0;
306     AdjustLen := 0;
307     Modified := 0;
308     if Item.DownType = gdtBoard then begin
309     {$IFDEF DEBUG}
310     Writeln('Subject鐃緒申鐃緒申');
311     Writeln('URL: ' + Item.Board.GetReadCgiURL);
312     Writeln('Modified: ' + FloatToStr(Item.Board.LastModified));
313     {$ENDIF}
314     URL := Item.Board.GetReadCgiURL;
315 q9_ 1.25 if Item.ForceDownload then begin
316     // 鐃緒申鐃緒申鐃緒申鐃緒申
317     ATitle := Item.Board.Title;
318     if ATitle = '' then
319     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
320     FMsg := '鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
321     FIcon := gmiWhat;
322     if Assigned(OnDownloadMsg) then
323     Synchronize(FireDownloadMsg);
324     Modified := ZERO_DATE
325     end else begin
326     Modified := Item.Board.LastModified;
327     end;
328 hi_ 1.1 end else if Item.DownType = gdtThread then begin
329     {$IFDEF DEBUG}
330     Writeln('DAT鐃緒申鐃緒申');
331     Writeln('URL: ' + Item.ThreadItem.GetDatURL);
332     Writeln('Modified: ' + FloatToStr(Item.ThreadItem.LastModified));
333     {$ENDIF}
334     URL := Item.ThreadItem.GetDatURL;
335 q9_ 1.25 if Item.ForceDownload then begin
336     // 鐃緒申鐃緒申鐃緒申鐃緒申
337     ATitle := Item.ThreadItem.Title;
338     if ATitle = '' then
339     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
340     FMsg := '鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
341     FIcon := gmiWhat;
342     if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
343     DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
344     if Assigned(OnDownloadMsg) then
345     Synchronize(FireDownloadMsg);
346     Modified := ZERO_DATE;
347     RangeStart := 0;
348     AdjustLen := 0;
349     end else begin
350     Modified := Item.ThreadItem.LastModified;
351     if Item.ThreadItem.Size > 0 then begin
352     {$IFDEF DEBUG}
353     Writeln('RangeStart: ' + IntToStr(Item.ThreadItem.Size));
354     {$ENDIF}
355 yoffy 1.29 // 鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申 adjustMargin 鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申
356 q9_ 1.25 RangeStart := Item.ThreadItem.Size;
357 yoffy 1.29 AdjustLen := -adjustMargin;
358 q9_ 1.25 end;
359 hi_ 1.1 end;
360     end;
361 yoffy 1.30 Item.IsAbone := False;
362 hi_ 1.1 DownloadResult := DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen);
363     {$IFDEF DEBUG}
364     Writeln('ResponseCode: ' + IntToStr(FIndy.ResponseCode));
365     {$ENDIF}
366     if Item.DownType = gdtThread then begin
367     if Item.ResponseCode = 416 then begin
368 yoffy 1.30 Item.IsAbone := True;
369 hi_ 1.1 DownloadResult := True;
370 yoffy 1.29 end else if DownloadResult and (AdjustLen < 0) then begin
371     if Copy( Item.Content, 1, adjustMargin ) <> lastContent then
372 yoffy 1.30 Item.IsAbone := True;
373 yoffy 1.29 end;
374 hi_ 1.1 end;
375    
376     if Trim(FIndy.Response.RawHeaders.Values['Date']) <> '' then begin
377     if Item.DownType = gdtBoard then
378 h677 1.55 Item.Board.LastGetTime := GikoSys.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date'])
379 hi_ 1.1 else
380 h677 1.55 Item.ThreadItem.ParentBoard.LastGetTime := GikoSys.DateStrToDateTime(FIndy.Response.RawHeaders.Values['Date']);
381 hi_ 1.1 end;
382    
383     if DownloadResult then begin
384     {$IFDEF DEBUG}
385     Writeln('Date:' + FIndy.Response.RawHeaders.Values['Date']);
386     {$ENDIF}
387 yoffy 1.30 if Item.IsAbone then begin
388 hi_ 1.1 {$IFDEF DEBUG}
389     Writeln('鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?');
390     {$ENDIF}
391     ATitle := Item.ThreadItem.Title;
392     if ATitle = '' then
393     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
394     //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申LF鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
395     RangeStart := 0;
396     AdjustLen := 0;
397     FMsg := '鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
398     FIcon := gmiWhat;
399 yoffy 1.13 if FileExists(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG')) = true then
400     DeleteFile(ChangeFileExt(Item.FThreadItem.GetThreadFileName,'.NG'));
401 hi_ 1.1 if Assigned(OnDownloadMsg) then
402     Synchronize(FireDownloadMsg);
403     if not DatDownload(Item.DownType, URL, ZERO_DATE, RangeStart, AdjustLen) then
404     Item.State := gdsError;
405     {$IFDEF DEBUG}
406     Writeln('鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申');
407     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
408     {$ENDIF}
409 yoffy 1.29 end else if (Item.DownType = gdtThread) and (AdjustLen < 0) then begin
410     // 鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
411     Item.Content := Copy(Item.Content, adjustMargin + 1, MaxInt);
412 hi_ 1.1 end;
413     end else begin
414     Item.State := gdsError;
415     if (Item.DownType = gdtBoard) and (Item.ResponseCode = 302) then begin
416     FMsg := '鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申';
417     FIcon := gmiNG;
418     if Assigned(OnDownloadMsg) then
419     Synchronize(FireDownloadMsg);
420     end;
421     end;
422    
423     //********************
424     //dat.gz鐃緒申鐃緒申(1)
425     //********************
426     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
427     {$IFDEF DEBUG}
428     Writeln('dat.gz鐃緒申鐃緒申');
429     {$ENDIF}
430     ATitle := Item.ThreadItem.Title;
431     if ATitle = '' then
432     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
433     FMsg := '鐃緒申dat鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?(dat.gz)鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
434     FIcon := gmiWhat;
435     if Assigned(OnDownloadMsg) then
436     Synchronize(FireDownloadMsg);
437     URL := Item.ThreadItem.GetDatgzURL;
438     Modified := Item.ThreadItem.LastModified;
439     RangeStart := 0;
440     AdjustLen := 0;
441     if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
442     Item.State := gdsError;
443     {$IFDEF DEBUG}
444     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
445     {$ENDIF}
446     end;
447    
448     //********************
449 h677 1.44 //dat.gz鐃?鐃緒申鐃?dat鐃緒申鐃緒申鐃緒申鐃?2005鐃?6鐃緒申鐃緒申鐃緒申鐃?by鐃緒申鐃緒申鐃緒申
450     //********************
451     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
452     {$IFDEF DEBUG}
453     Writeln('dat鐃緒申鐃緒申');
454     {$ENDIF}
455     FMsg := '鐃緒申鐃緒申鐃緒申鐃?(dat.gz)鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?(dat)鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
456     FIcon := gmiWhat;
457     if Assigned(OnDownloadMsg) then
458     Synchronize(FireDownloadMsg);
459     URL := ChangeFileExt(URL, '');
460     Modified := Item.ThreadItem.LastModified;
461     RangeStart := 0;
462     AdjustLen := 0;
463     if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
464     Item.State := gdsError;
465     {$IFDEF DEBUG}
466     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
467     {$ENDIF}
468     end;
469    
470     //********************
471 hi_ 1.1 //dat.gz鐃緒申鐃緒申(2)
472     //********************
473     {
474     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
475     ATitle := Item.ThreadItem.Title;
476     if ATitle = '' then
477     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
478     FMsg := '鐃緒申鐃緒申鐃緒申鐃緒申鐃?(1)鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?(2)鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
479     FIcon := gmiWhat;
480     if Assigned(OnDownloadMsg) then
481     Synchronize(FireDownloadMsg);
482     URL := Item.ThreadItem.GetOldDatgzURL;
483     Modified := Item.ThreadItem.LastModified;
484     RangeStart := 0;
485     AdjustLen := 0;
486     if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
487     Item.State := gdsError;
488     end;
489     }
490    
491     //********************
492     //offlaw.cgi鐃緒申鐃緒申鐃緒申
493     //********************
494     FSessionID := '';
495     Synchronize(GetSessionID);
496     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID <> '') then begin
497     {$IFDEF DEBUG}
498     Writeln('offlaw.cgi鐃緒申鐃緒申鐃緒申');
499     {$ENDIF}
500     ATitle := Item.ThreadItem.Title;
501     if ATitle = '' then
502     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
503     FMsg := '鐃緒申dat.gz鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申offlaw.cgi鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
504     FIcon := gmiWhat;
505     if Assigned(OnDownloadMsg) then
506     Synchronize(FireDownloadMsg);
507     URL := Item.ThreadItem.GetOfflawCgiURL(FSessionID);
508     Modified := Item.ThreadItem.LastModified;
509     RangeStart := 0;
510     AdjustLen := 0;
511     if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then begin
512     {$IFDEF DEBUG}
513     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
514     {$ENDIF}
515     Item.State := gdsError;
516    
517     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) then begin
518     FMsg := '鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?';
519     FIcon := gmiNG;
520     if Assigned(OnDownloadMsg) then
521     Synchronize(FireDownloadMsg);
522     end;
523    
524     end else begin
525     CgiStatus := ParseCgiStatus(Item.Content);
526     {$IFDEF DEBUG}
527     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
528     {$ENDIF}
529     case CgiStatus.FStatus of
530     gcsOK: begin
531     {$IFDEF DEBUG}
532     Writeln('CGIStatus: OK');
533     {$ENDIF}
534     Item.ResponseCode := 200;
535 h677 1.51 DeleteStatusLine(Item);
536 hi_ 1.1 end;
537     gcsINCR: begin
538     //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
539     {$IFDEF DEBUG}
540     Writeln('CGIStatus: 206');
541     {$ENDIF}
542     Item.ResponseCode := 206;
543 h677 1.51 DeleteStatusLine(Item);
544 hi_ 1.1 end;
545     gcsERR: begin
546     {$IFDEF DEBUG}
547     Writeln('CGIStatus: 404(ERROR)');
548     {$ENDIF}
549     Item.ResponseCode := 404;
550     Item.State := gdsError;
551     Item.ErrText := CgiStatus.FErrText;
552     end;
553     end;
554     if (Item.ResponseCode = 404) and (AnsiPos('鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申', Item.ErrText) <> 0) then begin
555     {$IFDEF DEBUG}
556     Writeln('鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申');
557     {$ENDIF}
558     ATitle := Item.ThreadItem.Title;
559     if ATitle = '' then
560     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
561     FMsg := '鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
562     FIcon := gmiWhat;
563     if Assigned(OnDownloadMsg) then
564     Synchronize(FireDownloadMsg);
565     Idx := Pos(' ', Item.ErrText);
566     if Idx <> 0 then begin
567     URL := Copy(Item.ErrText, Idx + 1, Length(Item.ErrText));
568 yoffy 1.17 if Pos( '://', URL ) = 0 then begin
569     if Pos('../', URL) = 1 then
570     URL := Copy(URL, 4, MaxInt );
571     if Pos( '/', URL ) = 1 then
572     URL := Copy( URL, 2, MaxInt );
573     URL := GikoSys.UrlToServer(Item.ThreadItem.ParentBoard.URL) + URL;
574     end;
575 hi_ 1.1 Modified := Item.ThreadItem.LastModified;
576     RangeStart := 0;
577     AdjustLen := 0;
578     if not DatDownload(Item.DownType, URL, Modified, RangeStart, AdjustLen) then
579     Item.State := gdsError;
580     {$IFDEF DEBUG}
581     Writeln('ResponseCode: ' + IntToStr(Item.ResponseCode));
582     {$ENDIF}
583     end;
584     end;
585     end;
586     end else begin
587     if (Item.DownType = gdtThread) and (Item.ResponseCode = 302) and (FSessionID = '') then begin
588     {$IFDEF DEBUG}
589     Writeln('鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申');
590     {$ENDIF}
591     ATitle := Item.ThreadItem.Title;
592     if ATitle = '' then
593     ATitle := '鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?';
594     FMsg := '鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申 - [' + ATitle + ']';
595     FIcon := gmiSAD;
596     if Assigned(OnDownloadMsg) then
597     Synchronize(FireDownloadMsg);
598     end;
599     end;
600    
601     case Item.ResponseCode of
602     200: Item.State := gdsComplete;
603     206: Item.State := gdsDiffComplete;
604     304: Item.State := gdsNotModify;
605     else
606     Item.State := gdsError;
607     end;
608     except
609     Item.State := gdsError;
610     end;
611     if FAbort then
612     Item.State := gdsAbort;
613     finally
614     if Assigned(OnDownloadEnd) then
615     Synchronize(FireDownloadEnd);
616     ResStream.Free;
617     end;
618 h677 1.22
619 h677 1.50 ClearHttpClient(FIndy);
620 h677 1.22
621 hi_ 1.1 if Terminated then Break;
622     Suspend;
623 yoffy 1.5 end;
624     end;
625    
626     function TDownloadThread.CgiDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime): Boolean;
627     var
628     ResponseCode: Integer;
629     ResStream: TMemoryStream;
630     begin
631     ResponseCode := -1;
632     FIndy.Request.ContentRangeStart := 0;
633     FIndy.Request.ContentRangeEnd := 0;
634    
635     FIndy.Request.CustomHeaders.Clear;
636     if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
637     FIndy.Request.LastModified := modified - OffsetFromUTC;
638     end;
639     FIndy.Request.AcceptEncoding := '';
640 yoffy 1.13 FIndy.Request.Accept := 'text/html';
641 yoffy 1.5 ResStream := TMemoryStream.Create;
642     try
643     try
644     ResStream.Clear;
645     {$IFDEF DEBUG}
646     Writeln('URL: ' + URL);
647     {$ENDIF}
648     FIndy.Get(URL, ResStream);
649     Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
650     Item.LastModified := FIndy.Response.LastModified;
651     //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申
652     Item.ContentLength := Length(Item.Content);
653     //鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?
654     if Item.Content = '' then
655     Result := False
656     else
657     Result := True;
658     {$IFDEF DEBUG}
659     Writeln('鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申');
660     {$ENDIF}
661     ResponseCode := FIndy.ResponseCode;
662     except
663     on E: EIdSocketError do begin
664     Item.Content := '';
665     Item.LastModified := ZERO_DATE;
666     Item.ContentLength := 0;
667     Item.ErrText := E.Message;
668     Result := False;
669     ResponseCode := -1;
670 yoffy 1.13 Screen.Cursor := crDefault;
671 yoffy 1.5 end;
672     on E: EIdConnectException do begin
673     Item.Content := '';
674     Item.LastModified := ZERO_DATE;
675     Item.ContentLength := 0;
676     Item.ErrText := E.Message;
677     Result := False;
678     ResponseCode := -1;
679 yoffy 1.13 Screen.Cursor := crDefault;
680 yoffy 1.5 end;
681     on E: Exception do begin
682     {$IFDEF DEBUG}
683     Writeln('鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申');
684     Writeln('E.Message: ' + E.Message);
685     {$ENDIF}
686     Item.Content := '';
687     Item.LastModified := ZERO_DATE;
688     Item.ContentLength := 0;
689     Item.ErrText := E.Message;
690     ResponseCode := FIndy.ResponseCode;
691     Result := False;
692 yoffy 1.13 Screen.Cursor := crDefault;
693 yoffy 1.5 end;
694     end;
695     finally
696     if (Item.ContentLength = 0) and (ResponseCode = 206) then
697     Item.ResponseCode := 304
698     else
699     Item.ResponseCode := ResponseCode;
700     ResStream.Free;
701 hi_ 1.1 end;
702     end;
703    
704     function TDownloadThread.DatDownload(ItemType: TGikoDownloadType; URL: string; Modified: TDateTime; RangeStart: Integer; AdjustLen: Integer): Boolean;
705     var
706     ResponseCode: Integer;
707     ResStream: TMemoryStream;
708     begin
709     ResponseCode := -1;
710     if (ItemType = gdtThread) and (RangeStart > 0) then begin
711     FIndy.Request.ContentRangeStart := RangeStart + AdjustLen;
712     FIndy.Request.ContentRangeEnd := 0;
713     end else begin
714     FIndy.Request.ContentRangeStart := 0;
715     FIndy.Request.ContentRangeEnd := 0;
716     end;
717    
718     FIndy.Request.CustomHeaders.Clear;
719     FIndy.Request.CacheControl := 'no-cache';
720     FIndy.Request.CustomHeaders.Add('Pragma: no-cache');
721     if (Modified <> 0) and (Modified <> ZERO_DATE) then begin
722     FIndy.Request.LastModified := modified - OffsetFromUTC;
723     end;
724     if RangeStart = 0 then
725     FIndy.Request.AcceptEncoding := 'gzip'
726     else
727     FIndy.Request.AcceptEncoding := '';
728     ResStream := TMemoryStream.Create;
729     try
730     try
731     ResStream.Clear;
732     {$IFDEF DEBUG}
733     Writeln('URL: ' + URL);
734     {$ENDIF}
735     FIndy.Get(URL, ResStream);
736 h677 1.43 Item.Content := GikoSys.GzipDecompress(ResStream, FIndy.Response.ContentEncoding);
737 hi_ 1.1 Item.LastModified := FIndy.Response.LastModified;
738     //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申
739     // Item.ContentLength := FIndy.Response.ContentLength + AdjustLen;
740     Item.ContentLength := Length(Item.Content) + AdjustLen;
741     //鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?
742     // if (FIndy.ResponseCode in [200, 206]) and (Item.Content = '') then
743     // Result := False
744     if Item.Content = '' then
745     Result := False
746     else
747     Result := True;
748     {$IFDEF DEBUG}
749     Writeln('鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申');
750     {$ENDIF}
751     ResponseCode := FIndy.ResponseCode;
752     except
753     on E: EIdSocketError do begin
754     Item.Content := '';
755     Item.LastModified := ZERO_DATE;
756     Item.ContentLength := 0;
757     Item.ErrText := E.Message;
758     Result := False;
759     ResponseCode := -1;
760 yoffy 1.13 Screen.Cursor := crDefault;
761 hi_ 1.1 end;
762     on E: EIdConnectException do begin
763     Item.Content := '';
764     Item.LastModified := ZERO_DATE;
765     Item.ContentLength := 0;
766     Item.ErrText := E.Message;
767     Result := False;
768     ResponseCode := -1;
769 yoffy 1.13 Screen.Cursor := crDefault;
770 hi_ 1.1 end;
771     on E: Exception do begin
772     {$IFDEF DEBUG}
773     Writeln('鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申');
774     Writeln('E.Message: ' + E.Message);
775     {$ENDIF}
776     Item.Content := '';
777     Item.LastModified := ZERO_DATE;
778     Item.ContentLength := 0;
779     Item.ErrText := E.Message;
780     ResponseCode := FIndy.ResponseCode;
781     Result := False;
782 yoffy 1.13 Screen.Cursor := crDefault;
783 hi_ 1.1 end;
784     end;
785     finally
786     if (Item.ContentLength = 0) and (ResponseCode = 206) then
787     Item.ResponseCode := 304
788     else
789     Item.ResponseCode := ResponseCode;
790     ResStream.Free;
791     end;
792     end;
793    
794     procedure TDownloadThread.FireDownloadEnd;
795     begin
796     OnDownloadEnd(self, Item);
797     end;
798    
799     procedure TDownloadThread.FireDownloadMsg;
800     begin
801     OnDownloadMsg(Self, Item, FMsg, FIcon);
802     end;
803    
804     procedure TDownloadThread.GetSessionID;
805     begin
806     FSessionID := GikoSys.Dolib.SessionID;
807     end;
808    
809     procedure TDownloadThread.Abort;
810     begin
811     FAbort := True;
812     FIndy.DisconnectSocket;
813 h677 1.28 if socket <> nil then begin
814     socket.DisconnectSocket;
815     end;
816 hi_ 1.1 end;
817    
818     procedure TDownloadThread.WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
819     begin
820     if Assigned(OnWorkBegin) then
821 q9_ 1.23 OnWorkBegin(Sender, AWorkMode, AWorkCountMax, FNumber, FDownloadTitle);
822 hi_ 1.1 end;
823    
824     procedure TDownloadThread.WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
825     begin
826     if Assigned(OnWorkEnd) then
827     OnWorkEnd(Sender, AWorkMode, FNumber);
828     end;
829    
830     procedure TDownloadThread.Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
831     begin
832     if Assigned(OnWork) then
833     OnWork(Sender, AWorkMode, AWorkCount, FNumber);
834     end;
835    
836     function TDownloadThread.ParseCgiStatus(Content: string): TCgiStatus;
837     var
838     StatusLine: string;
839     Line: string;
840     Idx: Integer;
841     Status: string;
842     Size: string;
843     Msg: string;
844     begin
845     // [+OK] 鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
846     // [-INCR] (Incorrect)鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?
847     // [-ERR (鐃?鐃?鐃?鐃?)]鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?
848     // 鐃緒申鐃?+OK 23094/512K
849 yoffy 1.13 // -INCR 23094/512K
850     // -ERR 鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
851 hi_ 1.1 Idx := AnsiPos(#10, Content);
852     StatusLine := Copy(Content, 0, Idx);
853    
854     Idx := AnsiPos(' ', Content);
855     Status := Copy(StatusLine, 0, Idx - 1);
856     Line := Copy(StatusLine, Idx + 1, Length(StatusLine));
857    
858     // Idx := AnsiPos('/', Line);
859     if Trim(Status) = '-ERR' then
860     Msg := Trim(Line)
861     else
862     Size := Copy(Line, 0, Idx - 1);
863    
864     if Trim(Status) = '+OK' then
865     Result.FStatus := gcsOK
866     else if Trim(Status) = '-INCR' then
867     Result.FStatus := gcsINCR
868     else if Trim(Status) = '-ERR' then begin
869     Result.FStatus := gcsERR;
870     Result.FErrText := Msg;
871     Result.FSize := 0;
872     Exit;
873     end else begin
874     {$IFDEF DEBUG}
875     Writeln(Status);
876     {$ENDIF}
877     Result.FStatus := gcsERR;
878     Result.FErrText := '鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?';
879     Result.FSize := 0;
880     Exit;
881     end;
882    
883     if GikoSys.IsNumeric(Size) then
884     Result.FSize := StrToInt(Size)
885     else begin
886     Result.FSize := 0;
887     Result.FStatus := gcsERR;
888     Result.FErrText := '鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃?[' + StatusLine + ']';
889     end;
890     end;
891    
892 h677 1.51 //鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
893     procedure TDownloadThread.DeleteStatusLine(Item: TDownloadItem);
894 hi_ 1.1 var
895     SList: TStringList;
896     begin
897     SList := TStringList.Create;
898     try
899 h677 1.51 SList.Text := Item.Content;
900     //1鐃?鐃緒申鐃緒申鐃緒申鐃緒申
901 hi_ 1.1 if SList.Count > 1 then
902     SList.Delete(0);
903 h677 1.52 Item.Content := SList.Text;
904 h677 1.51 //鐃緒申鐃?鐃?鐃?鐃?鐃緒申CRLF -> LF鐃緒申鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃?
905     Item.ContentLength := Length(SList.Text) - SList.Count;
906 hi_ 1.1 finally
907     SList.Free;
908     end;
909     end;
910    
911     procedure TDownloadItem.SaveListFile;
912     var
913     i: Integer;
914     index: Integer;
915     NewItem: TThreadItem;
916     NumCount: Integer;
917     Body: TStringList;
918     Rec: TSubjectRec;
919 h677 1.46 {$IFDEF DEBUG}
920     st, rt : Cardinal;
921     {$ENDIF}
922 yoffy 1.9 function MakeThreadCallBack(
923 yoffy 1.13 inInstance : DWORD; // TBoardItem 鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃?
924 yoffy 1.10 inURL : PChar; // 鐃?鐃緒申鐃?鐃?鐃緒申 URL
925     inTitle : PChar; // 鐃?鐃緒申鐃?鐃?
926     inCount : DWORD // 鐃緒申鐃?鐃緒申鐃緒申
927     ) : Boolean; stdcall; // 鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 True
928 yoffy 1.13 var
929 yoffy 1.18 _ThreadItem : TThreadItem; // '_' 鐃緒申鐃?鐃緒申鐃?鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
930 yoffy 1.13 boardItem : TBoard;
931     begin
932     Result := True;
933     boardItem := TBoard( inInstance );
934    
935     boardItem.IntData := boardItem.IntData + 1;
936 h677 1.43 if boardItem.IntData < (boardItem.Count shr 2) then
937     index := boardItem.GetIndexFromURL( string( inURL ) )
938     else
939     index := boardItem.GetIndexFromURL( string( inURL ), True );
940 yoffy 1.13 if index = -1 then begin
941     //鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?
942 h677 1.43 _ThreadItem := TThreadItem.Create( boardItem.BoardPlugIn, boardItem, string( inURL ) );
943 yoffy 1.9
944 yoffy 1.18 _ThreadItem.Title := string( inTitle );
945     _ThreadItem.AllResCount := inCount;
946     _ThreadItem.ParentBoard := Board;
947     _ThreadItem.No := boardItem.IntData;
948     _ThreadItem.RoundDate := ZERO_DATE;
949     _ThreadItem.LastModified := ZERO_DATE;
950     _ThreadItem.AgeSage := gasNew;
951 h677 1.26 boardItem.Add(_ThreadItem);
952 yoffy 1.13 end else begin
953 h677 1.43 //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申Age鐃緒申鐃緒申鐃緒申
954 yoffy 1.13 if boardItem.Items[index].No > boardItem.IntData then
955     boardItem.Items[index].AgeSage := gasAge
956 h677 1.43 //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?Sage鐃緒申
957     else if boardItem.Items[index].AllResCount <> inCount then
958 yoffy 1.13 boardItem.Items[index].AgeSage := gasSage
959 h677 1.43 //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?None
960 yoffy 1.13 else
961     boardItem.Items[index].AgeSage := gasNone;
962 yoffy 1.9
963 yoffy 1.13 boardItem.Items[index].No := boardItem.IntData;
964     boardItem.Items[index].AllResCount := inCount;
965     end;
966 h677 1.43
967 yoffy 1.13 end;
968 hi_ 1.1 begin
969 h677 1.43 {$IFDEF DEBUG}
970     st := GetTickCount;
971     Writeln('SAVELIST');
972     {$ENDIF}
973 h677 1.26 //Board.ListData := TList.Create;
974 hi_ 1.1 Body := TStringList.Create;
975     try
976     //鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃?
977     Board.RoundDate := Now;
978     //鐃?鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申
979     Board.LastModified := LastModified;
980 q9_ 1.31
981 h677 1.43
982 q9_ 1.31 //dat鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申
983 q9_ 1.32 if GikoSys.Setting.DatOchiSortIndex >= 0 then begin
984 h677 1.54 Sort.SetSortNoFlag(true);
985     Sort.SetSortOrder(GikoSys.Setting.DatOchiSortOrder);
986     Sort.SetSortIndex(GikoSys.Setting.DatOchiSortIndex);
987 q9_ 1.32 //Sort.SortNonAcquiredCountFlag := GikoSys.Setting.NonAcquiredCount;
988     Board.CustomSort(ThreadItemSortProc);
989     end;
990 q9_ 1.31
991 h677 1.43 {$IFDEF DEBUG}
992     rt := GetTickCount - st;
993     Writeln('END Sortd' + IntToStr(rt) + ' ms');
994     {$ENDIF}
995    
996 h677 1.26 for i := Board.Count - 1 downto 0 do
997     Board.Items[i].AgeSage := gasNull;
998 hi_ 1.1
999 yoffy 1.13 if Board.IsBoardPlugInAvailable then begin
1000     // 鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1001     // 鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1002     // 鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
1003     Board.IntData := 0;
1004 h677 1.43 {$IFDEF DEBUG}
1005     rt := GetTickCount - st;
1006     Writeln('Start Enum' + IntToStr(rt) + ' ms');
1007     {$ENDIF}
1008    
1009     //鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃?
1010     Board.BeginUpdate;
1011 yoffy 1.13 Board.BoardPlugIn.EnumThread( DWORD( Board ), @MakeThreadCallBack );
1012 h677 1.43 Board.EndUpdate;
1013    
1014     {$IFDEF DEBUG}
1015     rt := GetTickCount - st;
1016     Writeln('End Enum' + IntToStr(rt) + ' ms');
1017     {$ENDIF}
1018 yoffy 1.13
1019 h677 1.43 //鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1020 h677 1.27 for i := Board.Count - 1 downto 0 do begin
1021     if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1022     Board.Delete(i);
1023     end;
1024    
1025 yoffy 1.13 // 鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1026     for i := 0 to Board.Count - 1 do begin
1027 h677 1.26 if(Board.Items[i].AgeSage = gasNull) and (Board.Items[i].IsLogFile) then begin
1028 yoffy 1.13 Board.IntData := Board.IntData + 1;
1029     Board.Items[i].No := Board.IntData;
1030     Board.Items[i].AllResCount := Board.Items[i].Count;
1031     Board.Items[i].NewResCount := 0;
1032 h677 1.53 Board.Items[i].AgeSage := gasArch;
1033 yoffy 1.13 end;
1034     end;
1035 h677 1.43
1036 yoffy 1.13 end else begin
1037     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1038     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1039     //鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
1040     Body.Text := Content;
1041     NumCount := 0;
1042     for i := 0 to Body.Count - 1 do begin
1043     Rec := GikoSys.DivideSubject(Body[i]);
1044     Rec.FFileName := Trim(Rec.FFileName);
1045     if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1046     Inc(NumCount);
1047 yoffy 1.24 index := Board.GetIndexFromFileName(Rec.FFileName);
1048 yoffy 1.13 if index = -1 then begin
1049     //鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?
1050 yoffy 1.16 NewItem := TThreadItem.Create(
1051 h677 1.43 nil,
1052     Board,
1053     GikoSys.Get2chBoard2ThreadURL( Board, ChangeFileExt( Rec.FFileName, '' ) ) );
1054 yoffy 1.13 NewItem.Title := Rec.FTitle;
1055     NewItem.AllResCount := Rec.FCount;
1056     NewItem.ParentBoard := Board;
1057     NewItem.No := NumCount;
1058     NewItem.RoundDate := ZERO_DATE;
1059     NewItem.LastModified := ZERO_DATE;
1060     NewItem.AgeSage := gasNew;
1061 h677 1.26 Board.Add(NewItem);
1062 yoffy 1.13 end else begin
1063     if Board.Items[index].No > NumCount then
1064     Board.Items[index].AgeSage := gasAge
1065     else if Board.Items[index].AllResCount < Rec.FCount then
1066     Board.Items[index].AgeSage := gasSage
1067     else
1068     Board.Items[index].AgeSage := gasNone;
1069    
1070     Board.Items[index].No := NumCount;
1071     Board.Items[index].AllResCount := Rec.FCount;
1072     end;
1073 h677 1.27 end;
1074     //鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1075     for i := Board.Count - 1 downto 0 do begin
1076     if( Board.Items[i].AgeSage = gasNull )and not (Board.Items[i].IsLogFile) then
1077     Board.Delete(i);
1078 yoffy 1.13 end;
1079    
1080 h677 1.26 //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?
1081 yoffy 1.13 for i := 0 to Board.Count - 1 do begin
1082 h677 1.26 if( Board.Items[i].AgeSage = gasNull )and (Board.Items[i].IsLogFile) then begin
1083 yoffy 1.13 inc(NumCount);
1084     Board.Items[i].No := NumCount;
1085     Board.Items[i].AllResCount := Board.Items[i].Count;
1086     Board.Items[i].NewResCount := 0;
1087 h677 1.53 Board.Items[i].AgeSage := gasArch;
1088 yoffy 1.13 end;
1089     end;
1090     //鐃緒申鐃?鐃?(subject.txt)鐃緒申鐃緒申鐃緒申
1091     GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1092     Body.SaveToFile(Board.GetSubjectFileName);
1093     end;
1094 hi_ 1.1 finally
1095     Body.Free;
1096     end;
1097 h677 1.26
1098    
1099 hi_ 1.1 end;
1100    
1101     {procedure TDownloadItem.SaveListFile;
1102     var
1103     i: Integer;
1104     index: Integer;
1105     NewItem: TThreadItem;
1106     NewList: TList;
1107     // SaveCount: Integer;
1108     NumCount: Integer;
1109     Body: TStringList;
1110     Rec: TSubjectRec;
1111     begin
1112     NewList := TList.Create;
1113     Body := TStringList.Create;
1114     try
1115     //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1116     Board.RoundDate := Now;
1117     //鐃?鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申
1118     Board.LastModified := LastModified;
1119    
1120     //鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1121     //SaveCount := MaxInt;
1122    
1123     //鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申
1124     for i := Board.Count - 1 downto 0 do
1125     if not Board.Items[i].IsLogFile then
1126     Board.Delete(i);
1127    
1128     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1129     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1130     //鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
1131     Body.Text := Content;
1132     // Loop := Min(Body.Count, SaveCount);
1133     NumCount := 0;
1134     // for i := 0 to Loop - 1 do begin
1135     for i := 0 to Body.Count - 1 do begin
1136     if i = 0 then Continue; //鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1137    
1138     Rec := GikoSys.DivideSubject(Body[i]);
1139     if (Rec.FTitle = '') and (Rec.FCount = 0) then Continue;
1140     Inc(NumCount);
1141     index := Board.GetIndex(Rec.FFileName);
1142     if index = -1 then begin
1143     NewItem := TThreadItem.Create;
1144     NewItem.FileName := Rec.FFileName;
1145     NewItem.Title := Rec.FTitle;
1146     NewItem.Count := Rec.FCount;
1147     NewItem.ParentBoard := Board;
1148     NewItem.No := NumCount;
1149     NewItem.RoundDate := ZERO_DATE;
1150     NewItem.LastModified := ZERO_DATE;
1151     NewList.Add(NewItem);
1152     end else begin
1153     //Board.Items[index].Count := Count;
1154     Board.Items[index].No := NumCount;
1155     NewList.Add(Board.Items[index]);
1156     Board.DeleteList(index);
1157     end;
1158     end;
1159    
1160     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申
1161     for i := 0 to Board.Count - 1 do begin
1162     inc(NumCount);
1163     Board.Items[i].No := NumCount;
1164     NewList.Add(Board.Items[i]);
1165     end;
1166    
1167     //鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?
1168     for i := Board.Count - 1 downto 0 do
1169     Board.DeleteList(i);
1170    
1171     //鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申
1172     for i := 0 to NewList.Count - 1 do
1173     Board.Add(TThreadItem(NewList[i]));
1174    
1175     //鐃緒申鐃?鐃?(subject.txt)鐃緒申鐃緒申鐃緒申
1176     // GikoSys.ForceDirectoriesEx(GikoSys.GetLogDir + Board.BBSID);
1177     // Body.SaveToFile(GikoSys.GetSubjectFileName(Board.BBSID));
1178     GikoSys.ForceDirectoriesEx(ExtractFilePath(Board.GetSubjectFileName));
1179     Body.SaveToFile(Board.GetSubjectFileName);
1180     finally
1181     Body.Free;
1182     NewList.Free;
1183     end;
1184     end;
1185     }
1186     procedure TDownloadItem.SaveItemFile;
1187     var
1188 h677 1.35 Body, oldBody: TStringList;
1189 hi_ 1.1 Cnt: Integer;
1190     OldCnt: Integer;
1191     FileName: string;
1192     ini: TMemIniFile;
1193     Res: TResRec;
1194     NewRes: Integer;
1195 yoffy 1.30 finish : Boolean;
1196     loopCnt : Integer;
1197     LastIdx : Integer;
1198 hi_ 1.1 begin
1199     FileName := ThreadItem.GetThreadFileName;
1200    
1201 h677 1.43 //if not ThreadItem.IsBoardPlugInAvailable then begin
1202     if not ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
1203 yoffy 1.15 if Trim(Content) = '' then
1204     Exit;
1205 yoffy 1.30
1206 yoffy 1.15 GikoSys.ForceDirectoriesEx(ExtractFilePath(FileName));
1207    
1208 yoffy 1.30 // Cnt := 0;
1209 yoffy 1.15 Body := TStringList.Create;
1210 yoffy 1.30 NewRes := 0;
1211     OldCnt := 0;
1212 yoffy 1.15 try
1213 yoffy 1.30 // if FileExists(FileName) and (ResponseCode = 206) then begin
1214 yoffy 1.15 if FileExists(FileName) and (State = gdsDiffComplete) then begin
1215 yoffy 1.30 loopCnt := 10;
1216 h677 1.19 repeat
1217 yoffy 1.30 finish := true;
1218     try
1219 h677 1.19 Body.LoadFromFile(FileName);
1220     OldCnt := Body.Count;
1221     Body.Text := Body.Text + Content;
1222     Body.SaveToFile(FileName);
1223     NewRes := Body.Count - OldCnt;
1224 yoffy 1.30 except
1225     on E:EFOpenError do begin
1226     sleep(10);
1227     Dec(loopCnt);
1228 h677 1.35 if loopCnt > 0 then
1229     finish := false;
1230 yoffy 1.30 end;
1231     end;
1232 h677 1.35 until finish;
1233 h677 1.19 //Cnt := Body.Count;
1234 yoffy 1.15 end else begin
1235 yoffy 1.30 if IsAbone then begin
1236     // 鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1237 h677 1.35 oldBody := TStringList.Create;
1238     try
1239     loopCnt := 10;
1240     repeat
1241     finish := true;
1242     try
1243     oldBody.LoadFromFile(FileName);
1244     except
1245     on E:EFOpenError do begin
1246     sleep(10);
1247     Dec(loopCnt);
1248     if loopCnt > 0 then
1249     finish := false
1250     else
1251     finish := true;
1252     end;
1253 yoffy 1.30 end;
1254 h677 1.35 until finish;
1255    
1256     Body.Text := Content;
1257     if (ThreadItem.Kokomade > 0) and (ThreadItem.Kokomade <= oldBody.Count) then begin
1258 h677 1.36 ThreadItem.Kokomade := Body.IndexOf(oldBody.Strings[ ThreadItem.Kokomade - 1 ]);
1259     if ThreadItem.Kokomade <> -1 then ThreadItem.Kokomade := ThreadItem.Kokomade + 1;
1260 yoffy 1.30 end;
1261 h677 1.35
1262     LastIdx := oldBody.Count;
1263     repeat
1264     Dec(LastIdx);
1265     OldCnt := Body.IndexOf(oldBody.Strings[ LastIdx ]) + 1;
1266     until ( OldCnt <> 0 ) or (LastIdx = 0);
1267    
1268 h677 1.38 if OldCnt >= Body.Count then OldCnt := Body.Count - 1;
1269 h677 1.35 NewRes := Body.Count - OldCnt;
1270    
1271 q9_ 1.41 // 鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申(鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申)
1272     if ThreadItem.Kokomade > OldCnt then begin
1273     if OldCnt > 0 then
1274 q9_ 1.42 ThreadItem.Kokomade := OldCnt
1275 q9_ 1.41 else
1276     ThreadItem.Kokomade := 1;
1277     end;
1278 h677 1.38
1279 h677 1.35 finally
1280     oldBody.Free;
1281 yoffy 1.30 end;
1282    
1283     end else begin
1284     Body.Text := Content;
1285     //ThreadItem.Count := 0;
1286     OldCnt := 0;
1287     NewRes := Body.Count;
1288     //Cnt := Body.Count;
1289     end;
1290 yoffy 1.15 // if Body.Count > 0 then
1291     // Body.Delete(0);
1292     Body.SaveToFile(FileName);
1293 hi_ 1.1
1294 yoffy 1.15 if ThreadItem.Title = '' then begin
1295 h677 1.48 THTMLCreate.DivideStrLine(Body[0], @Res);
1296 yoffy 1.15 ThreadItem.Title := Res.FTitle;
1297     end;
1298     ThreadItem.Size := 0;
1299 hi_ 1.1 end;
1300     Cnt := Body.Count;
1301 yoffy 1.15 finally
1302     Body.Free;
1303 hi_ 1.1 end;
1304 yoffy 1.30
1305 yoffy 1.15 ThreadItem.Size := ThreadItem.Size + ContentLength;
1306     ThreadItem.LastModified := LastModified;
1307     ThreadItem.Count := Cnt;
1308 h677 1.19 //ThreadItem.AllResCount := Cnt;
1309 yoffy 1.15 ThreadItem.NewResCount := NewRes;
1310     ThreadItem.NewReceive := OldCnt + 1;
1311 hi_ 1.1 end;
1312 yoffy 1.30 ThreadItem.AllResCount := ThreadItem.Count;
1313 yoffy 1.15 ThreadItem.IsLogFile := True;
1314 hi_ 1.1 ThreadItem.RoundDate := Now;
1315 h677 1.39 if not ThreadItem.UnRead then begin
1316     ThreadItem.UnRead := True;
1317     end;
1318 hi_ 1.1 // if ThreadItem.RoundNo = 6 then
1319     // ThreadItem.RoundNo := 0;
1320    
1321     //鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃?鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?
1322     //鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申
1323     //鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃?
1324     ini := TMemIniFile.Create(ChangeFileExt(FileName, '.tmp'));
1325     try
1326     ini.WriteDateTime('Setting', 'RoundDate', ThreadItem.RoundDate);
1327     ini.WriteDateTime('Setting', 'LastModified', ThreadItem.LastModified);
1328     ini.WriteInteger('Setting', 'Size', ThreadItem.Size);
1329     ini.WriteInteger('Setting', 'Count', ThreadItem.Count);
1330     ini.WriteInteger('Setting', 'AllResCount', ThreadItem.AllResCount);
1331     ini.WriteInteger('Setting', 'NewResCount', ThreadItem.NewResCount);
1332     ini.WriteInteger('Setting', 'NewReceive', ThreadItem.NewReceive);
1333     // ini.WriteInteger('Setting', 'RoundNo', ThreadItem.RoundNo);
1334 h677 1.44 // ini.WriteBool('Setting', 'Round', ThreadItem.Round);
1335 hi_ 1.1 ini.WriteBool('Setting', 'UnRead', ThreadItem.UnRead);
1336 yoffy 1.30 ini.UpdateFile;
1337 hi_ 1.1 finally
1338     ini.Free;
1339     end;
1340     end;
1341    
1342     end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26