| 5 |
uses |
uses |
| 6 |
Windows, Classes, SysUtils, Menus, |
Windows, Classes, SysUtils, Menus, |
| 7 |
IdHTTP, IdComponent, IdGlobal, IdException, |
IdHTTP, IdComponent, IdGlobal, IdException, |
| 8 |
AbonUnit; |
AbonUnit, IdAntiFreezeBase; |
| 9 |
|
|
| 10 |
type |
type |
| 11 |
|
|
| 46 |
): TAcceptType; stdcall; // URL の種類 |
): TAcceptType; stdcall; // URL の種類 |
| 47 |
|
|
| 48 |
// ************************************************************************* |
// ************************************************************************* |
| 49 |
|
// 指定したURLを現在のURLに変換する |
| 50 |
|
// ************************************************************************* |
| 51 |
|
TOnExtractBoardURL = procedure( |
| 52 |
|
inURL : PChar; // 変換するURL; |
| 53 |
|
var outURL: PChar // 変換されたURL |
| 54 |
|
); stdcall; // 変換されたURL |
| 55 |
|
|
| 56 |
|
// ************************************************************************* |
| 57 |
// メニューハンドラ |
// メニューハンドラ |
| 58 |
// ************************************************************************* |
// ************************************************************************* |
| 59 |
TOnPlugInMenu = procedure( |
TOnPlugInMenu = procedure( |
| 82 |
|
|
| 83 |
implementation |
implementation |
| 84 |
|
|
| 85 |
uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup, Giko; |
uses ExternalBoardManager, ExternalThreadItem, GikoSystem, BoardGroup, Giko, |
| 86 |
|
ReplaceDataModule; |
| 87 |
|
|
| 88 |
// ************************************************************************* |
// ************************************************************************* |
| 89 |
// 戻り値が PChar である API のメモリを確保する |
// 戻り値が PChar である API のメモリを確保する |
| 187 |
inSocket.Request.UserAgent := GikoSys.GetUserAgent; |
inSocket.Request.UserAgent := GikoSys.GetUserAgent; |
| 188 |
inSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize; |
inSocket.RecvBufferSize := Gikosys.Setting.RecvBufferSize; |
| 189 |
inSocket.ProxyParams.BasicAuthentication := False; |
inSocket.ProxyParams.BasicAuthentication := False; |
| 190 |
|
inSocket.ReadTimeout := GikoSys.Setting.ReadTimeOut; |
| 191 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 192 |
Writeln('------------------------------------------------------------'); |
Writeln('------------------------------------------------------------'); |
| 193 |
{$ENDIF} |
{$ENDIF} |
| 243 |
LIVEDOOR_URL = 'http://jbbs.livedoor.jp/'; |
LIVEDOOR_URL = 'http://jbbs.livedoor.jp/'; |
| 244 |
begin |
begin |
| 245 |
|
|
| 246 |
|
|
| 247 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 248 |
Writeln('ExternalBoardManager.InternalDownload'); |
Writeln('ExternalBoardManager.InternalDownload'); |
| 249 |
{$ENDIF} |
{$ENDIF} |
| 252 |
socket := TIdHTTP.Create( nil ); |
socket := TIdHTTP.Create( nil ); |
| 253 |
try |
try |
| 254 |
InitializeSocket( socket ); |
InitializeSocket( socket ); |
|
|
|
| 255 |
socket.Request.ContentRangeStart := inRangeStart; |
socket.Request.ContentRangeStart := inRangeStart; |
| 256 |
socket.Request.ContentRangeEnd := inRangeEnd; |
socket.Request.ContentRangeEnd := inRangeEnd; |
| 257 |
if (ioModified <> 0) and (ioModified <> ZERO_DATE) then |
if (ioModified <> 0) and (ioModified <> ZERO_DATE) then |
| 269 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 270 |
Writeln('URL: ' + inURL); |
Writeln('URL: ' + inURL); |
| 271 |
{$ENDIF} |
{$ENDIF} |
| 272 |
|
//AntiFreezeをDL時のみ有効にすることで、ココでのチェック不要 |
| 273 |
socket.Get( inURL, resStream ); |
socket.Get( inURL, resStream ); |
| 274 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 275 |
Writeln('取得で例外なし'); |
Writeln('取得で例外なし'); |
| 276 |
{$ENDIF} |
{$ENDIF} |
|
|
|
| 277 |
content := GikoSys.GzipDecompress( resStream, socket.Response.ContentEncoding ); |
content := GikoSys.GzipDecompress( resStream, socket.Response.ContentEncoding ); |
| 278 |
|
// 置換する |
| 279 |
|
if GikoSys.Setting.ReplaceDat then begin |
| 280 |
|
content := ReplaceDM.Replace(content); |
| 281 |
|
end; |
| 282 |
|
|
| 283 |
ioModified := socket.Response.LastModified; |
ioModified := socket.Response.LastModified; |
| 284 |
|
|
| 285 |
Result := socket.ResponseCode; |
Result := socket.ResponseCode; |
| 286 |
if (Length( content ) = 0) and (Result = 206) then |
if (Length( content ) = 0) and (Result = 206) then |
| 287 |
Result := 304; |
Result := 304; |
| 288 |
//したらばJBBSはヘッダにエラー情報が載るらしいので、ここでチェック |
//したらばJBBSはヘッダにエラー情報が載るらしいので、ここでチェック |
| 289 |
if ( AnsiPos(LIVEDOOR_URL, inURL) > 0 ) and (Result = 200) then begin |
if ( AnsiPos(LIVEDOOR_URL, inURL) > 0 ) and (Result = 200) then begin |
| 290 |
if( AnsiPos('STORAGE IN', socket.Response.RawHeaders.Text) > 0 ) then begin |
if( AnsiPos('STORAGE IN', socket.Response.RawHeaders.Text) > 0 ) then begin |
| 291 |
Result := 302; |
Result := 302; |
| 339 |
function InternalPost( |
function InternalPost( |
| 340 |
inURL : PChar; // 送信する URL |
inURL : PChar; // 送信する URL |
| 341 |
inSource : PChar; // 送信する内容 |
inSource : PChar; // 送信する内容 |
| 342 |
|
inReferer : PChar; // Referer |
| 343 |
var outResultData : PChar // 返ってきた文字列 |
var outResultData : PChar // 返ってきた文字列 |
| 344 |
) : Longint; stdcall; // レスポンスコード |
) : Longint; stdcall; // レスポンスコード |
| 345 |
var |
var |
| 347 |
content : string; |
content : string; |
| 348 |
resStream : TStringStream; |
resStream : TStringStream; |
| 349 |
sourceStream : TStringStream; |
sourceStream : TStringStream; |
| 350 |
tmpURL, Protocol, Host, Path, Document, Port, Bookmark : string; |
|
| 351 |
begin |
begin |
| 352 |
|
|
| 353 |
{$IFDEF DEBUG} |
{$IFDEF DEBUG} |
| 358 |
httpSocket := TIdHTTP.Create( nil ); |
httpSocket := TIdHTTP.Create( nil ); |
| 359 |
try |
try |
| 360 |
InitializeSocket( httpSocket ); |
InitializeSocket( httpSocket ); |
|
tmpURL := string(inURL); |
|
|
GikoSys.ParseURI(tmpURL, Protocol,Host, Path, Document, Port, Bookmark); |
|
| 361 |
httpSocket.Request.CustomHeaders.Add('Pragma: no-cache'); |
httpSocket.Request.CustomHeaders.Add('Pragma: no-cache'); |
| 362 |
httpSocket.Request.AcceptLanguage := 'ja'; |
httpSocket.Request.AcceptLanguage := 'ja'; |
| 363 |
httpSocket.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*'; |
httpSocket.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*'; |
| 364 |
httpSocket.Request.ContentType := 'application/x-www-form-urlencoded'; |
httpSocket.Request.ContentType := 'application/x-www-form-urlencoded'; |
| 365 |
httpSocket.Request.Referer := Protocol + '://' + Host; |
httpSocket.Request.Referer := string(inReferer); |
| 366 |
resStream := TStringStream.Create( content ); |
resStream := TStringStream.Create( content ); |
| 367 |
sourceStream := TStringStream.Create( string( inSource ) ); |
sourceStream := TStringStream.Create( string( inSource ) ); |
| 368 |
try |
try |
| 474 |
|
|
| 475 |
// ダミーのクラス |
// ダミーのクラス |
| 476 |
board := TBoard.Create( nil, 'about://dummy/' ); |
board := TBoard.Create( nil, 'about://dummy/' ); |
| 477 |
threadItem := TThreadItem.Create( nil, 'about://dummy/test/read.cgi/dummy/' ); |
threadItem := TThreadItem.Create( nil, board, 'about://dummy/test/read.cgi/dummy/' ); |
| 478 |
try |
try |
| 479 |
try |
try |
| 480 |
board.Add( threadItem ); |
board.Add( threadItem ); |