1 unit ExternalBoardPlugInMain;
6 Windows, Classes, SysUtils,
7 IdHTTP, IdComponent, IdGlobal, IdException,
12 //
\83_
\83E
\83\93\83\8d\81[
\83h
\82ª
\90¬
\8c÷
\82µ
\82½
\82©
\82Ç
\82¤
\82©
13 TDownloadState = (dsWait, dsWork, dsComplete, dsDiffComplete, dsNotModify, dsAbort, dsError);
15 // *************************************************************************
16 //
\83v
\83\89\83O
\83C
\83\93\82Ì
\83o
\81[
\83W
\83\87\83\93
17 // *************************************************************************
18 TOnVersionInfo = procedure(
19 var outAgent : PChar; //
\83o
\81[
\83W
\83\87\83\93\82ð
\88ê
\90Ø
\8aÜ
\82Ü
\82È
\82¢
\8f\83\90\88\82È
\96¼
\8fÌ
20 var outMajor : DWORD; //
\83\81\83W
\83\83\81[
\83o
\81[
\83W
\83\87\83\93
21 var outMinor : DWORD; //
\83}
\83C
\83i
\81[
\83o
\81[
\83W
\83\87\83\93
22 var outRelease : PChar; //
\83\8a\83\8a\81[
\83X
\92i
\8aK
\96¼
23 var outRevision : DWORD //
\83\8a\83r
\83W
\83\87\83\93\83i
\83\93\83o
\81[
26 // *************************************************************************
27 //
\8ew
\92è
\82µ
\82½ URL
\82ð
\82±
\82Ì
\83v
\83\89\83O
\83C
\83\93\82Å
\8eó
\82¯
\95t
\82¯
\82é
\82©
\82Ç
\82¤
\82©
28 // *************************************************************************
29 TOnAcceptURL = function(
30 inURL : PChar //
\94»
\92f
\82ð
\8bÂ
\82¢
\82Å
\82¢
\82é URL
31 ): Boolean; stdcall; //
\8eó
\82¯
\95t
\82¯
\82é
\82È
\82ç True
33 // *************************************************************************
34 //
\83X
\83\8c\88ê
\97\97\82Ì URL
\82©
\82ç
\83X
\83\8c\83b
\83h
\82Ì URL
\82ð
\93±
\82«
\8fo
\82·
35 // *************************************************************************
36 TOnListURL2ThreadURL = function(
37 inListURL : PChar; //
\83X
\83\8c\88ê
\97\97\82ð
\8e¦
\82µ
\82½ URL
38 inFileName : PChar //
\83X
\83\8c\83b
\83h
\83t
\83@
\83C
\83\8b\96¼
39 ) : PChar; stdcall; //
\83X
\83\8c\83b
\83h
\82Ì URL
41 function CreateResultString(
45 procedure DisposeResultString(
51 uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup;
53 // *************************************************************************
54 //
\96ß
\82è
\92l
\82ª PChar
\82Å
\82 \82é API
\82Ì
\83\81\83\82\83\8a\82ð
\8am
\95Û
\82·
\82é
55 // *************************************************************************
56 function CreateResultString(
63 tmp := PChar( resultStr );
64 GetMem( Result, Length( tmp ) + 1 );
65 Move( tmp^, Result^, Length( tmp ) + 1 );
69 // *************************************************************************
70 //
\96ß
\82è
\92l
\82ª PChar
\82Å
\82 \82é API
\82Ì
\83\81\83\82\83\8a\82ð
\8aJ
\95ú
\82·
\82é
71 // *************************************************************************
72 procedure DisposeResultString(
81 // *************************************************************************
82 //
\83v
\83\8d\83O
\83\89\83\80\96{
\91Ì
\82Ì
\83o
\81[
\83W
\83\87\83\93\82ð
\8eæ
\93¾
\82·
\82é
83 // *************************************************************************
84 procedure VersionInfo(
85 var outAgent : PChar; //
\83o
\81[
\83W
\83\87\83\93\82ð
\88ê
\90Ø
\8aÜ
\82Ü
\82È
\82¢
\8f\83\90\88\82È
\96¼
\8fÌ
86 var outMajor : DWORD; //
\83\81\83W
\83\83\81[
\83o
\81[
\83W
\83\87\83\93
87 var outMinor : DWORD; //
\83}
\83C
\83i
\81[
\83o
\81[
\83W
\83\87\83\93
88 var outRelease : PChar; //
\83\8a\83\8a\81[
\83X
\92i
\8aK
\96¼
89 var outRevision : DWORD //
\83\8a\83r
\83W
\83\87\83\93\83i
\83\93\83o
\81[
94 Writeln('ExternalBoardManager.VersionInfo');
96 outAgent := CreateResultString( PChar( APP_NAME ) );
99 outRelease := CreateResultString( PChar( BETA_VERSION_NAME_E ) );
100 outRevision := BETA_VERSION;
104 // *************************************************************************
105 //
\83\
\83P
\83b
\83g
\82ð
\8f\89\8aú
\89»
\82·
\82é(
\8eG
\97p
\8aÖ
\90\94)
106 // *************************************************************************
107 procedure InitializeSocket(
112 if inSocket <> nil then begin
113 //
\83C
\83x
\83\93\83g
\82Ì
\90Ý
\92è
114 if Assigned( OnWork ) then
115 inSocket.OnWork := OnWork;
116 if Assigned( OnWorkBegin ) then
117 inSocket.OnWorkBegin := OnWorkBegin;
118 if Assigned( OnWorkEnd ) then
119 inSocket.OnWorkEnd := OnWorkEnd;
121 //
\92Ê
\90M
\82É
\8aÖ
\82·
\82é
\90Ý
\92è
122 inSocket.Request.CustomHeaders.Clear;
123 inSocket.Response.Clear;
124 inSocket.Request.Clear;
126 inSocket.Request.UserAgent := GikoSys.GetUserAgent;
127 inSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
128 inSocket.ProxyParams.BasicAuthentication := False;
130 Writeln('------------------------------------------------------------');
132 //inSocket.AllowCookies := False;
133 if GikoSys.Setting.ReadProxy then begin
134 if GikoSys.Setting.ProxyProtocol then
135 inSocket.ProtocolVersion := pv1_1
137 inSocket.ProtocolVersion := pv1_0;
138 inSocket.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
139 inSocket.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
140 inSocket.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
141 inSocket.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
142 if GikoSys.Setting.ReadProxyUserID <> '' then
143 inSocket.ProxyParams.BasicAuthentication := True;
145 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
146 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
147 Writeln('
\83|
\81[
\83g: ' + IntToStr( GikoSys.Setting.ReadProxyPort ));
150 if GikoSys.Setting.Protocol then
151 inSocket.ProtocolVersion := pv1_1
153 inSocket.ProtocolVersion := pv1_0;
154 inSocket.ProxyParams.ProxyServer := '';
155 inSocket.ProxyParams.ProxyPort := 80;
156 inSocket.ProxyParams.ProxyUsername := '';
157 inSocket.ProxyParams.ProxyPassword := '';
159 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
166 // *************************************************************************
167 //
\8ew
\92è
\82µ
\82½ URL
\82ð
\83_
\83E
\83\93\83\8d\81[
\83h
\82µ
\82Ä
\95Ô
\82·
168 // *************************************************************************
169 function InternalDownload(
170 inURL : PChar; //
\83_
\83E
\83\93\83\8d\81[
\83h
\82·
\82é URL
171 var ioModified : Double; //
\8dÅ
\8cã
\82É
\8eæ
\93¾
\82µ
\82½
\93ú
\8e\9e
172 var outResultData : PChar; //
\83_
\83E
\83\93\83\8d\81[
\83h
\82³
\82ê
\82½
\95¶
\8e\9a\97ñ
173 inRangeStart : DWORD; //
\8aJ
\8en
\88Ê
\92u
174 inRangeEnd : DWORD //
\8fI
\97¹
\88Ê
\92u
175 ) : Longint; stdcall; //
\83\8c\83X
\83|
\83\93\83X
\83R
\81[
\83h
177 httpSocket : TIdHTTP;
178 resStream : TMemoryStream;
183 Writeln('ExternalBoardManager.InternalDownload');
187 httpSocket := TIdHTTP.Create( nil );
189 InitializeSocket( httpSocket );
191 httpSocket.Request.ContentRangeStart := inRangeStart;
192 httpSocket.Request.ContentRangeEnd := inRangeEnd;
193 if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
194 httpSocket.Request.LastModified := ioModified - OffsetFromUTC;
195 if inRangeStart = 0 then
196 httpSocket.Request.AcceptEncoding := 'gzip'
198 httpSocket.Request.AcceptEncoding := '';
199 httpSocket.Request.Accept := 'text/html';
201 resStream := TMemoryStream.Create;
207 Writeln('URL: ' + inURL);
209 httpSocket.Get( inURL, resStream );
211 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
214 content := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );
215 ioModified := httpSocket.Response.LastModified;
217 Result := httpSocket.ResponseCode;
218 if (Length( content ) = 0) and (Result = 206) then
221 outResultData := CreateResultString( content );
223 on E: EIdSocketError do begin
224 ioModified := ZERO_DATE;
225 outResultData := nil;
227 on E: EIdConnectException do begin
228 ioModified := ZERO_DATE;
229 outResultData := nil;
230 //Item.ErrText := E.Message;
232 on E: Exception do begin
234 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
235 Writeln('E.Message: ' + E.Message);
237 ioModified := ZERO_DATE;
238 outResultData := nil;
239 Result := httpSocket.ResponseCode;
240 //Item.ErrText := E.Message;
253 // *************************************************************************
254 //
\8ew
\92è
\82µ
\82½ URL
\82Ö
\83f
\81[
\83^
\82ð
\91\97\90M
\82·
\82é
255 // *************************************************************************
256 function InternalPost(
257 inURL : PChar; //
\91\97\90M
\82·
\82é URL
258 inSource : PChar; //
\91\97\90M
\82·
\82é
\93à
\97e
259 var outResultData : PChar //
\95Ô
\82Á
\82Ä
\82«
\82½
\95¶
\8e\9a\97ñ
260 ) : Longint; stdcall; //
\83\8c\83X
\83|
\83\93\83X
\83R
\81[
\83h
262 httpSocket : TIdHTTP;
264 resStream : TStringStream;
265 sourceStream : TStringStream;
269 Writeln('ExternalBoardManager.InternalPost');
273 httpSocket := TIdHTTP.Create( nil );
275 InitializeSocket( httpSocket );
277 httpSocket.Request.CustomHeaders.Add('Pragma: no-cache');
278 httpSocket.Request.AcceptLanguage := 'ja';
279 httpSocket.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
280 httpSocket.Request.ContentType := 'application/x-www-form-urlencoded';
282 resStream := TStringStream.Create( content );
283 sourceStream := TStringStream.Create( string( inSource ) );
287 Writeln('URL: ' + inURL);
288 Writeln('Source: ' + inSource);
290 httpSocket.Post( string( inURL ), sourceStream, resStream );
292 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
295 Result := httpSocket.ResponseCode;
297 outResultData := CreateResultString( resStream.DataString );
299 on E: EIdSocketError do begin
300 outResultData := nil;
302 on E: EIdConnectException do begin
303 outResultData := nil;
305 on E: Exception do begin
307 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
308 Writeln('E.Message: ' + E.Message);
310 outResultData := nil;
311 Result := httpSocket.ResponseCode;
324 // *************************************************************************
325 //
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\82Ì dat
\8c`
\8e®
\82ð
\83\8d\81[
\83J
\83\8b\82 \82Ú
\81`
\82ñ
\82É
\92Ê
\82·
326 // *************************************************************************
327 function InternalAbon(
328 inDatText : PChar; //
\96¼
\91O<>
\83\81\81[
\83\8b<>
\93ú
\95tID<>
\96{
\95¶<>[
\89ü
\8ds]
\82Å
\8d\
\90¬
\82³
\82ê
\82½
\83e
\83L
\83X
\83g
329 inDatPath : PChar // dat
\83t
\83@
\83C
\83\8b\82Ì
\83t
\83\8b\83p
\83X
330 ) : PChar; stdcall; //
\82 \82Ú
\81`
\82ñ
\8dÏ
\82Ý
\82Ì dat
\8c`
\8e®
\83e
\83L
\83X
\83g
332 datList : TStringList;
335 datList := TStringList.Create;
336 datList.Text := string( inDatText );
337 //GikoSys.FAbon.IndividualAbon( datList, ChangeFileExt(FileName,'.NG'));
338 GikoSys.FAbon.Execute( datList );
339 GikoSys.FSelectResFilter.Execute( datList );
341 Result := CreateResultString( datList.Text );
345 // *************************************************************************
346 //
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\82Ì dat
\8c`
\8e® 1
\8ds
\82ð HTML
\82É
\95Ï
\8a·
\82·
\82é
347 // *************************************************************************
348 function InternalDat2HTML(
349 inDatRes : PChar; //
\96¼
\91O<>
\83\81\81[
\83\8b<>
\93ú
\95tID<>
\96{
\95¶<>
\82Å
\8d\
\90¬
\82³
\82ê
\82½
\83e
\83L
\83X
\83g
350 inResNo : DWORD; //
\83\8c\83X
\94Ô
\8d\86
351 inIsNew : Boolean //
\90V
\92\85\83\8c\83X
\82È
\82ç True
352 ) : PChar; stdcall; //
\90®
\8c`
\82³
\82ê
\82½ HTML
355 threadItem : TThreadItem;
358 //
\83_
\83~
\81[
\82Ì
\83N
\83\89\83X
359 board := TBoard.Create;
360 threadItem := TThreadItem.Create;
363 threadItem.ParentBoard := Board;
365 Result := ThreadItemDat2HTML( DWORD( threadItem ), inDatRes, inResNo, inIsNew );