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 //
\8ew
\92è
\82µ
\82½ URL
\82ð
\83_
\83E
\83\93\83\8d\81[
\83h
\82µ
\82Ä
\95Ô
\82·
106 // *************************************************************************
107 function InternalDownload(
108 inURL : PChar; //
\83_
\83E
\83\93\83\8d\81[
\83h
\82·
\82é URL
109 var ioModified : Double; //
\8dÅ
\8cã
\82É
\8eæ
\93¾
\82µ
\82½
\93ú
\8e\9e
110 var outResultData : PChar; //
\83_
\83E
\83\93\83\8d\81[
\83h
\82³
\82ê
\82½
\95¶
\8e\9a\97ñ
111 inRangeStart : DWORD; //
\8aJ
\8en
\88Ê
\92u
112 inRangeEnd : DWORD //
\8fI
\97¹
\88Ê
\92u
113 ) : Longint; stdcall; //
\83\8c\83X
\83|
\83\93\83X
\83R
\81[
\83h
115 httpSocket : TIdHTTP;
116 resStream : TMemoryStream;
121 Writeln('ExternalBoardManager.InternalDownload');
125 httpSocket := TIdHTTP.Create( nil );
127 //
\83C
\83x
\83\93\83g
\82Ì
\90Ý
\92è
128 if Assigned( OnWork ) then
129 httpSocket.OnWork := OnWork;
130 if Assigned( OnWorkBegin ) then
131 httpSocket.OnWorkBegin := OnWorkBegin;
132 if Assigned( OnWorkEnd ) then
133 httpSocket.OnWorkEnd := OnWorkEnd;
135 //
\92Ê
\90M
\82É
\8aÖ
\82·
\82é
\90Ý
\92è
136 httpSocket.Request.CustomHeaders.Clear;
137 httpSocket.Response.Clear;
138 httpSocket.Request.Clear;
140 httpSocket.Request.UserAgent := GikoSys.GetUserAgent;
141 httpSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
142 httpSocket.ProxyParams.BasicAuthentication := False;
144 Writeln('------------------------------------------------------------');
146 //httpSocket.AllowCookies := False;
147 if GikoSys.Setting.ReadProxy then begin
148 if GikoSys.Setting.ProxyProtocol then
149 httpSocket.ProtocolVersion := pv1_1
151 httpSocket.ProtocolVersion := pv1_0;
152 httpSocket.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
153 httpSocket.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
154 httpSocket.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
155 httpSocket.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
156 if GikoSys.Setting.ReadProxyUserID <> '' then
157 httpSocket.ProxyParams.BasicAuthentication := True;
159 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82 \82è');
160 Writeln('
\83z
\83X
\83g: ' + GikoSys.Setting.ReadProxyAddress);
161 Writeln('
\83|
\81[
\83g: ' + IntToStr( GikoSys.Setting.ReadProxyPort ));
164 if GikoSys.Setting.Protocol then
165 httpSocket.ProtocolVersion := pv1_1
167 httpSocket.ProtocolVersion := pv1_0;
168 httpSocket.ProxyParams.ProxyServer := '';
169 httpSocket.ProxyParams.ProxyPort := 80;
170 httpSocket.ProxyParams.ProxyUsername := '';
171 httpSocket.ProxyParams.ProxyPassword := '';
173 Writeln('
\83v
\83\8d\83L
\83V
\90Ý
\92è
\82È
\82µ');
177 httpSocket.Request.ContentRangeStart := inRangeStart;
178 httpSocket.Request.ContentRangeEnd := inRangeEnd;
179 if (ioModified <> 0) and (ioModified <> ZERO_DATE) then
180 httpSocket.Request.LastModified := ioModified - OffsetFromUTC;
181 if inRangeStart = 0 then
182 httpSocket.Request.AcceptEncoding := 'gzip'
184 httpSocket.Request.AcceptEncoding := '';
185 httpSocket.Request.Accept := 'text/html';
187 resStream := TMemoryStream.Create;
193 Writeln('URL: ' + inURL);
195 httpSocket.Get( inURL, resStream );
197 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82È
\82µ');
200 content := GikoSys.GzipDecompress( resStream, httpSocket.Response.ContentEncoding );
201 ioModified := httpSocket.Response.LastModified;
203 Result := httpSocket.ResponseCode;
204 if (Length( content ) = 0) and (Result = 206) then
207 outResultData := CreateResultString( content );
209 on E: EIdSocketError do begin
210 ioModified := ZERO_DATE;
211 outResultData := nil;
213 on E: EIdConnectException do begin
214 ioModified := ZERO_DATE;
215 outResultData := nil;
216 //Item.ErrText := E.Message;
218 on E: Exception do begin
220 Writeln('
\8eæ
\93¾
\82Å
\97á
\8aO
\82 \82è');
221 Writeln('E.Message: ' + E.Message);
223 ioModified := ZERO_DATE;
224 outResultData := nil;
225 Result := httpSocket.ResponseCode;
226 //Item.ErrText := E.Message;
239 // *************************************************************************
240 //
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\82Ì dat
\8c`
\8e®
\82ð
\83\8d\81[
\83J
\83\8b\82 \82Ú
\81`
\82ñ
\82É
\92Ê
\82·
241 // *************************************************************************
242 function InternalAbon(
243 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
244 ) : PChar; stdcall; //
\82 \82Ú
\81`
\82ñ
\8dÏ
\82Ý
\82Ì dat
\8c`
\8e®
\83e
\83L
\83X
\83g
246 datList : TStringList;
250 Writeln('ExternalBoardManager.InternalAbon');
252 datList := TStringList.Create;
253 datList.Text := string( inDatText );
254 //GikoSys.FAbon.IndividualAbon( datList, ChangeFileExt(FileName,'.NG'));
255 GikoSys.FAbon.Execute( datList );
256 GikoSys.FSelectResFilter.Execute( datList );
258 Result := CreateResultString( datList.Text );
262 // *************************************************************************
263 //
\82Q
\82¿
\82á
\82ñ
\82Ë
\82é
\82Ì dat
\8c`
\8e® 1
\8ds
\82ð HTML
\82É
\95Ï
\8a·
\82·
\82é
264 // *************************************************************************
265 function InternalDat2HTML(
266 inDatRes : PChar; //
\96¼
\91O<>
\83\81\81[
\83\8b<>
\93ú
\95tID<>
\96{
\95¶<>
\82Å
\8d\
\90¬
\82³
\82ê
\82½
\83e
\83L
\83X
\83g
267 inResNo : DWORD; //
\83\8c\83X
\94Ô
\8d\86
268 inIsNew : Boolean //
\90V
\92\85\83\8c\83X
\82È
\82ç True
269 ) : PChar; stdcall; //
\90®
\8c`
\82³
\82ê
\82½ HTML
272 threadItem : TThreadItem;
276 Writeln('ExternalBoardManager.InternalDat2HTML');
278 //
\83_
\83~
\81[
\82Ì
\83N
\83\89\83X
279 board := TBoard.Create;
280 threadItem := TThreadItem.Create;
283 threadItem.ParentBoard := Board;
285 Result := ThreadItemDat2HTML( DWORD( threadItem ), inDatRes, inResNo, inIsNew );