Develop and Download Open Source Software

Browse CVS Repository

Annotation of /gikonavigoeson/gikonavi/ExternalBoardPlugInMain.pas

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


Revision 1.5 - (hide annotations) (download) (as text)
Fri Nov 21 13:50:56 2003 UTC (20 years, 5 months ago) by h677
Branch: MAIN
Changes since 1.4: +32 -3 lines
File MIME type: text/x-pascal
plugin(一行ずつあぼ〜んの処理が必要なやつ)用の関数追加

1 yoffy 1.1 unit ExternalBoardPlugInMain;
2    
3     interface
4    
5     uses
6     Windows, Classes, SysUtils,
7     IdHTTP, IdComponent, IdGlobal, IdException,
8     AbonUnit;
9    
10     type
11    
12     // ?????潟???若????????????????????
13     TDownloadState = (dsWait, dsWork, dsComplete, dsDiffComplete, dsNotModify, dsAbort, dsError);
14    
15 yoffy 1.4 // ??絎????? URL ???????????違?ゃ?潟?у???篁?????????????
16     TAcceptType = (atNoAccept, atBBS, atBoard, atThread);
17    
18 yoffy 1.1 // *************************************************************************
19     // ?????違?ゃ?潟?????若?吾?с??/span>
20     // *************************************************************************
21     TOnVersionInfo = procedure(
22     var outAgent : PChar; // ???若?吾?с?潟??筝??????障????膣?膕?????腱?/span>
23     var outMajor : DWORD; // ?<?吾?c?若???若?吾?с??/span>
24     var outMinor : DWORD; // ???ゃ???若???若?吾?с??/span>
25     var outRelease : PChar; // ?????若?号?????
26     var outRevision : DWORD // ?????吾?с?潟???潟????/span>
27     ); stdcall;
28    
29     // *************************************************************************
30     // ??絎????? URL ???????????違?ゃ?潟?у???篁?????????????
31     // *************************************************************************
32     TOnAcceptURL = function(
33     inURL : PChar // ?ゆ????篁違???с???? URL
34 yoffy 1.4 ): TAcceptType; stdcall; // URL ??┏蕁?
35 yoffy 1.1
36     // *************************************************************************
37     // ?鴻???荀с? URL ?????鴻??????? URL ??絨????冴??
38     // *************************************************************************
39     TOnListURL2ThreadURL = function(
40     inListURL : PChar; // ?鴻???荀с??腓冴???? URL
41     inFileName : PChar // ?鴻?????????<?ゃ????
42     ) : PChar; stdcall; // ?鴻??????? URL
43    
44     function CreateResultString(
45     resultStr : string
46     ) : PChar; stdcall;
47    
48     procedure DisposeResultString(
49     resultStr : PChar
50     ); stdcall;
51    
52     implementation
53    
54     uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup;
55    
56     // *************************************************************************
57     // ?祉???ゃ?? PChar ?с???? API ???<?≪????腆坂?????
58     // *************************************************************************
59     function CreateResultString(
60     resultStr : string
61     ) : PChar; stdcall;
62     var
63     tmp : PChar;
64     begin
65    
66     tmp := PChar( resultStr );
67     GetMem( Result, Length( tmp ) + 1 );
68     Move( tmp^, Result^, Length( tmp ) + 1 );
69    
70     end;
71    
72     // *************************************************************************
73     // ?祉???ゃ?? PChar ?с???? API ???<?≪???????障????
74     // *************************************************************************
75     procedure DisposeResultString(
76     resultStr : PChar
77     ); stdcall;
78     begin
79    
80     FreeMem( resultStr );
81    
82     end;
83    
84     // *************************************************************************
85     // ?????違????????????若?吾?с?潟????緇?????
86     // *************************************************************************
87     procedure VersionInfo(
88     var outAgent : PChar; // ???若?吾?с?潟??筝??????障????膣?膕?????腱?/span>
89     var outMajor : DWORD; // ?<?吾?c?若???若?吾?с??/span>
90     var outMinor : DWORD; // ???ゃ???若???若?吾?с??/span>
91     var outRelease : PChar; // ?????若?号?????
92     var outRevision : DWORD // ?????吾?с?潟???潟????/span>
93     ); stdcall;
94     begin
95    
96     {$IFDEF DEBUG}
97     Writeln('ExternalBoardManager.VersionInfo');
98     {$ENDIF}
99     outAgent := CreateResultString( PChar( APP_NAME ) );
100     outMajor := 1;
101     outMinor := 0;
102     outRelease := CreateResultString( PChar( BETA_VERSION_NAME_E ) );
103     outRevision := BETA_VERSION;
104    
105     end;
106    
107     // *************************************************************************
108 yoffy 1.2 // ?純?宴????????????????(?????∽??
109 yoffy 1.1 // *************************************************************************
110 yoffy 1.2 procedure InitializeSocket(
111     inSocket : TIdHTTP
112     );
113 yoffy 1.1 begin
114    
115 yoffy 1.2 if inSocket <> nil then begin
116 yoffy 1.1 // ?ゃ???潟????┃絎?
117     if Assigned( OnWork ) then
118 yoffy 1.2 inSocket.OnWork := OnWork;
119 yoffy 1.1 if Assigned( OnWorkBegin ) then
120 yoffy 1.2 inSocket.OnWorkBegin := OnWorkBegin;
121 yoffy 1.1 if Assigned( OnWorkEnd ) then
122 yoffy 1.2 inSocket.OnWorkEnd := OnWorkEnd;
123 yoffy 1.1
124     // ??篆<???≪????荐??
125 yoffy 1.2 inSocket.Request.CustomHeaders.Clear;
126     inSocket.Response.Clear;
127     inSocket.Request.Clear;
128    
129     inSocket.Request.UserAgent := GikoSys.GetUserAgent;
130     inSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
131     inSocket.ProxyParams.BasicAuthentication := False;
132 yoffy 1.1 {$IFDEF DEBUG}
133     Writeln('------------------------------------------------------------');
134     {$ENDIF}
135 yoffy 1.2 //inSocket.AllowCookies := False;
136 yoffy 1.1 if GikoSys.Setting.ReadProxy then begin
137     if GikoSys.Setting.ProxyProtocol then
138 yoffy 1.2 inSocket.ProtocolVersion := pv1_1
139 yoffy 1.1 else
140 yoffy 1.2 inSocket.ProtocolVersion := pv1_0;
141     inSocket.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
142     inSocket.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
143     inSocket.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
144     inSocket.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
145 yoffy 1.1 if GikoSys.Setting.ReadProxyUserID <> '' then
146 yoffy 1.2 inSocket.ProxyParams.BasicAuthentication := True;
147 yoffy 1.1 {$IFDEF DEBUG}
148     Writeln('???????決┃絎?????');
149     Writeln('???鴻??: ' + GikoSys.Setting.ReadProxyAddress);
150     Writeln('???若??: ' + IntToStr( GikoSys.Setting.ReadProxyPort ));
151     {$ENDIF}
152     end else begin
153     if GikoSys.Setting.Protocol then
154 yoffy 1.2 inSocket.ProtocolVersion := pv1_1
155 yoffy 1.1 else
156 yoffy 1.2 inSocket.ProtocolVersion := pv1_0;
157     inSocket.ProxyParams.ProxyServer := '';
158     inSocket.ProxyParams.ProxyPort := 80;
159     inSocket.ProxyParams.ProxyUsername := '';
160     inSocket.ProxyParams.ProxyPassword := '';
161 yoffy 1.1 {$IFDEF DEBUG}
162     Writeln('???????決┃絎?????');
163     {$ENDIF}
164     end;
165 yoffy 1.2 end;
166    
167     end;
168    
169     // *************************************************************************
170     // ??絎????? URL ???????潟???若?????????
171     // *************************************************************************
172     function InternalDownload(
173     inURL : PChar; // ?????潟???若?????? URL
174     var ioModified : Double; // ??緇??????????ユ??
175     var outResultData : PChar; // ?????潟???若??????????絖???
176     inRangeStart : DWORD; // ??紮?篏?臀?/span>
177     inRangeEnd : DWORD // 腟?篋?篏?臀?/span>
178     ) : Longint; stdcall; // ???鴻???潟?鴻?潟?若??
179     var
180     httpSocket : TIdHTTP;
181     resStream : TMemoryStream;
182     content : string;
183     begin
184    
185     {$IFDEF DEBUG}
186     Writeln('ExternalBoardManager.InternalDownload');
187     {$ENDIF}
188     Result := -1;
189    
190     httpSocket := TIdHTTP.Create( nil );
191     try
192     InitializeSocket( httpSocket );
193 yoffy 1.1
194     httpSocket.Request.ContentRangeStart := inRangeStart;
195     httpSocket.Request.ContentRangeEnd := inRangeEnd;
196     if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
197     httpSocket.Request.LastModified := ioModified - OffsetFromUTC;
198     if inRangeStart = 0 then
199     httpSocket.Request.AcceptEncoding := 'gzip'
200     else
201     httpSocket.Request.AcceptEncoding := '';
202     httpSocket.Request.Accept := 'text/html';
203    
204     resStream := TMemoryStream.Create;
205     try
206     try
207     resStream.Clear;
208    
209     {$IFDEF DEBUG}
210     Writeln('URL: ' + inURL);
211     {$ENDIF}
212     httpSocket.Get( inURL, resStream );
213     {$IFDEF DEBUG}
214     Writeln('??緇??т?紊?????');
215     {$ENDIF}
216    
217     content := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );
218     ioModified := httpSocket.Response.LastModified;
219    
220     Result := httpSocket.ResponseCode;
221     if (Length( content ) = 0) and (Result = 206) then
222     Result := 304;
223    
224     outResultData := CreateResultString( content );
225     except
226     on E: EIdSocketError do begin
227     ioModified := ZERO_DATE;
228     outResultData := nil;
229     end;
230     on E: EIdConnectException do begin
231     ioModified := ZERO_DATE;
232     outResultData := nil;
233     //Item.ErrText := E.Message;
234     end;
235     on E: Exception do begin
236     {$IFDEF DEBUG}
237     Writeln('??緇??т?紊?????');
238     Writeln('E.Message: ' + E.Message);
239     {$ENDIF}
240     ioModified := ZERO_DATE;
241     outResultData := nil;
242     Result := httpSocket.ResponseCode;
243     //Item.ErrText := E.Message;
244     end;
245     end;
246     finally
247     resStream.Free;
248     end;
249    
250     finally
251     httpSocket.Free;
252     end;
253    
254     end;
255    
256     // *************************************************************************
257 yoffy 1.2 // ??絎????? URL ?吾???若?帥????篆<????
258     // *************************************************************************
259     function InternalPost(
260     inURL : PChar; // ??篆<???? URL
261     inSource : PChar; // ??篆<??????絎?/span>
262     var outResultData : PChar // 菴??c????????絖???
263     ) : Longint; stdcall; // ???鴻???潟?鴻?潟?若??
264     var
265     httpSocket : TIdHTTP;
266     content : string;
267     resStream : TStringStream;
268     sourceStream : TStringStream;
269     begin
270    
271     {$IFDEF DEBUG}
272     Writeln('ExternalBoardManager.InternalPost');
273     {$ENDIF}
274     Result := -1;
275    
276     httpSocket := TIdHTTP.Create( nil );
277     try
278     InitializeSocket( httpSocket );
279    
280     httpSocket.Request.CustomHeaders.Add('Pragma: no-cache');
281     httpSocket.Request.AcceptLanguage := 'ja';
282     httpSocket.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
283     httpSocket.Request.ContentType := 'application/x-www-form-urlencoded';
284    
285     resStream := TStringStream.Create( content );
286     sourceStream := TStringStream.Create( string( inSource ) );
287     try
288     try
289     {$IFDEF DEBUG}
290     Writeln('URL: ' + inURL);
291     Writeln('Source: ' + inSource);
292     {$ENDIF}
293     httpSocket.Post( string( inURL ), sourceStream, resStream );
294     {$IFDEF DEBUG}
295     Writeln('??緇??т?紊?????');
296     {$ENDIF}
297    
298     Result := httpSocket.ResponseCode;
299    
300     outResultData := CreateResultString( resStream.DataString );
301     except
302     on E: EIdSocketError do begin
303     outResultData := nil;
304     end;
305     on E: EIdConnectException do begin
306     outResultData := nil;
307     end;
308     on E: Exception do begin
309     {$IFDEF DEBUG}
310     Writeln('??緇??т?紊?????');
311     Writeln('E.Message: ' + E.Message);
312     {$ENDIF}
313     outResultData := nil;
314     Result := httpSocket.ResponseCode;
315     end;
316     end;
317     finally
318     resStream.Free;
319     sourceStream.Free;
320     end;
321     finally
322     httpSocket.Free;
323     end;
324    
325     end;
326    
327     // *************************************************************************
328 yoffy 1.1 // 鐚??<????????? dat 綵√??????若???????若??????????
329     // *************************************************************************
330 h677 1.5
331 yoffy 1.1 function InternalAbon(
332 yoffy 1.3 inDatText : PChar; // ????<>?<?若??lt;>?ヤ?ID<>????<>[?壕?] ?ф??????????????鴻??
333 h677 1.5 inDatPath : PChar // dat ???<?ゃ????????????/span>
334    
335     ) : PChar; stdcall; // ???若????羝??帥? dat 綵√??????鴻??
336 yoffy 1.1 var
337     datList : TStringList;
338 h677 1.5 FileName : String;
339 yoffy 1.1 begin
340    
341     datList := TStringList.Create;
342     datList.Text := string( inDatText );
343 h677 1.5 FileName := string( inDatPath );
344     GikoSys.FAbon.IndividualAbon( datList, ChangeFileExt(FileName,'.NG'));
345 yoffy 1.1 GikoSys.FAbon.Execute( datList );
346     GikoSys.FSelectResFilter.Execute( datList );
347    
348     Result := CreateResultString( datList.Text );
349    
350     end;
351 h677 1.5 // *************************************************************************
352     // 鐚??<????????? dat 綵√??????若???????若??????????
353     // ????????鐚????鴻????/span>
354     // *************************************************************************
355    
356     function InternalAbonForOne(
357     inDatText : PChar; // ????<>?<?若??lt;>?ヤ?ID<>????<>[?壕?] ?ф??????????????鴻??
358     inDatPath : PChar; // dat ???<?ゃ????????????/span>
359     inNo : Integer //荀?羆??????????合???/span>
360     ) : PChar; stdcall; // ???若????羝??帥? dat 綵√??????鴻??
361     var
362     datString : String;
363     FileName : String;
364     begin
365    
366     datString := string( inDatText );
367     FileName := string( inDatPath );
368     GikoSys.FAbon.IndividualAbon( datString, ChangeFileExt(FileName,'.NG'), inNo);
369     GikoSys.FAbon.Execute( datString , inNo);
370     GikoSys.FSelectResFilter.Execute( datString , inNo );
371    
372     Result := CreateResultString( datString );
373    
374     end;
375 yoffy 1.1
376     // *************************************************************************
377     // 鐚??<????????? dat 綵√? 1 茵??? HTML ?????????
378     // *************************************************************************
379     function InternalDat2HTML(
380     inDatRes : PChar; // ????<>?<?若??lt;>?ヤ?ID<>????<> ?ф??????????????鴻??
381     inResNo : DWORD; // ???合???/span>
382     inIsNew : Boolean // ?亥?????鴻???? True
383     ) : PChar; stdcall; // ?翫就?????? HTML
384     var
385     board : TBoard;
386     threadItem : TThreadItem;
387     begin
388    
389     // ?????若????????/span>
390     board := TBoard.Create;
391     threadItem := TThreadItem.Create;
392    
393     try
394     threadItem.ParentBoard := Board;
395    
396     Result := ThreadItemDat2HTML( DWORD( threadItem ), inDatRes, inResNo, inIsNew );
397     except
398     Result := nil;
399     end;
400    
401     end;
402    
403     exports
404     CreateResultString,
405     DisposeResultString,
406     VersionInfo,
407     InternalDownload,
408 yoffy 1.2 InternalPost,
409 yoffy 1.1 InternalAbon,
410 h677 1.5 InternalAbonForOne,
411 yoffy 1.1 InternalDat2HTML;
412    
413     end.

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