Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdAntiFreezeBase, IdAntiFreeze, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, IDException, StdCtrls, IniFiles,
- GikoSystem, BoardGroup, MojuUtils;
+ GikoSystem, BoardGroup;
type
TNewBoardItem = record
Indy: TIdHTTP;
IdAntiFreeze: TIdAntiFreeze;
StopButton: TButton;
- Label2: TLabel;
BoardURLComboBox: TComboBox;
Label13: TLabel;
EditIgnoreListsButton: TButton;
+ Label2: TLabel;
procedure UpdateButtonClick(Sender: TObject);
procedure StopButtonClick(Sender: TObject);
procedure CloseButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure EditIgnoreListsButtonClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
+ procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private \90é\8c¾ }
IgnoreLists : TStringList;
FAbort: Boolean;
- function BoardDownload: TNewBoardItem;
- procedure UpdateURL(s: string);
+ function BoardDownload(const URL: String): TNewBoardItem;
+ function BoardLoardFromFile(const FilePath: String): String;
+ function UpdateURL(s: string): boolean;
procedure SetIgnoreCategory(b: boolean);
procedure EditIgnoreList(Sender: TObject);
procedure UpdateIgnoreList(Sender: TObject);
public
{ Public \90é\8c¾ }
+ class procedure InitHTTPClient(client : TIdHTTP);
end;
var
implementation
-uses Giko, IdHeaderList;
+uses Giko, IdHeaderList, MojuUtils, GikoDataModule;
{$R *.dfm}
procedure TNewBoardDialog.UpdateButtonClick(Sender: TObject);
var
Item: TNewBoardItem;
+ URL : String;
+ protocol, host, path, document, port, bookmark: String;
+ TabURLs: TStringList;
begin
try
- GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
+ MessageMemo.Clear;
+ GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
FAbort := False;
UpdateButton.Enabled := False;
StopButton.Enabled := True;
CloseButton.Enabled := False;
- Item := BoardDownload;
+ EditIgnoreListsButton.Enabled := False;
+ URL := BoardURLComboBox.Text;
+ GikoSys.ParseURI(URL, protocol, host, path, document, port, bookmark);
+ if (protocol = '') then begin
+ Item.FContent := BoardLoardFromFile(URL);
+ end else if (AnsiPos('http', protocol) > 0) then begin
+ Item := BoardDownload(URL);
+ end;
StopButton.Enabled := False;
if FAbort then
Exit;
if Item.FContent <> '' then begin
- GikoForm.TabsSaveAction.Execute;
- UpdateURL(Item.FContent);
- GikoForm.ReloadBBS;
+ TabURLs := TStringList.Create;
+ try
+ GikoDM.GetTabURLs(TabURLs);
+ if (UpdateURL(Item.FContent)) then begin
+ GikoForm.ReloadBBS;
+ end;
+ GikoDM.OpenURLs(TabURLs);
+ finally
+ TabURLs.Free;
+ end;
end else
MessageMemo.Lines.Add('\83_\83E\83\93\83\8d\81[\83h\82ª\8e¸\94s\82µ\82Ü\82µ\82½[' + IntToStr(Item.FResponseCode) + ']');
finally
UpdateButton.Enabled := True;
StopButton.Enabled := False;
CloseButton.Enabled := True;
+ EditIgnoreListsButton.Enabled := True;
end;
end;
Close;
end;
-function TNewBoardDialog.BoardDownload: TNewBoardItem;
+function TNewBoardDialog.BoardDownload(const URL: String): TNewBoardItem;
var
- URL: string;
Stream: TMemoryStream;
s: string;
i: Integer;
begin
- MessageMemo.Clear;
- Indy.Request.Clear;
- Indy.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
- Indy.ProxyParams.BasicAuthentication := False;
- if GikoSys.Setting.ReadProxy then begin
- if GikoSys.Setting.ProxyProtocol then
- Indy.ProtocolVersion := pv1_1
- else
- Indy.ProtocolVersion := pv1_0;
- Indy.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
- Indy.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
- Indy.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
- Indy.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
- if GikoSys.Setting.ReadProxyUserID <> '' then
- Indy.ProxyParams.BasicAuthentication := True;
- end else begin
- if GikoSys.Setting.Protocol then
- Indy.ProtocolVersion := pv1_1
- else
- Indy.ProtocolVersion := pv1_0;
- Indy.ProxyParams.ProxyServer := '';
- Indy.ProxyParams.ProxyPort := 80;
- Indy.ProxyParams.ProxyUsername := '';
- Indy.ProxyParams.ProxyPassword := '';
- end;
- //URL := GikoSys.Setting.BoardURL2ch;
- URL := BoardURLComboBox.Text;
+ InitHTTPClient( Indy );
+
Indy.Request.UserAgent := GikoSys.GetUserAgent;
Indy.Request.Referer := '';
Indy.Request.AcceptEncoding := 'gzip';
try
MessageMemo.Lines.Add('\88È\89º\82Ì\8fê\8f\8a\82©\82ç\8eæ\93¾\82µ\82Ü\82·');
//MessageMemo.Lines.Add(GikoSys.Setting.BoardURL2ch);
- MessageMemo.Lines.Add(URL);
+ MessageMemo.Lines.Add(URL);
MessageMemo.Lines.Add('\83_\83E\83\93\83\8d\81[\83h\82ð\8aJ\8en\82µ\82Ü\82·');
- Indy.Get(URL, Stream);
+ IdAntiFreeze.Active := True;
+ try
+ Indy.Get(URL, Stream);
+ finally
+ IdAntiFreeze.Active := False;
+ end;
Result.FContent := GikoSys.GzipDecompress(Stream, Indy.Response.ContentEncoding);
MessageMemo.Lines.Add('\83_\83E\83\93\83\8d\81[\83h\82ª\8a®\97¹\82µ\82Ü\82µ\82½');
except
end;
end;
-procedure TNewBoardDialog.UpdateURL(s: string);
+function TNewBoardDialog.UpdateURL(s: string): boolean;
var
i: Integer;
-// j: Integer;
idx: Integer;
idx1: Integer;
idx2: Integer;
oldURLs.Free;
newURLs.Free;
end;
+ Result := Change;
end;
procedure TNewBoardDialog.FormCreate(Sender: TObject);
var
i: Integer;
begin
- Label2.Caption := '\81¦\8c»\8dÝ\81A\8aJ\82¢\82Ä\82¢\82é\83^\83u\82â\83q\83X\83g\83\8a\82È\82Ç\82Í\94Â\8dX\90V\8e\9e\82É\83N\83\8a\83A\82³\82ê\82Ü\82·';
+ Label2.Caption := '';
UpdateButton.Enabled := true;
EditIgnoreListsButton.Caption := '\8f\9c\8aO\83J\83e\83S\83\8a\81[\95Ò\8fW';
IgnoreLists.Clear;
begin
IgnoreLists.Free;
end;
+//! \83\8d\81[\83J\83\8b\83t\83@\83C\83\8b\82ð\83\8d\81[\83h\82·\82é
+function TNewBoardDialog.BoardLoardFromFile(const FilePath: String): String;
+var
+ html : TStringList;
+begin
+ Result := '';
+ // \83t\83@\83C\83\8b\82ª\91¶\8dÝ\82µ\82Ä\82¢\82é\82©\83`\83F\83b\83N
+ if (FileExists(FilePath)) then begin
+ html := TStringList.Create();
+ try
+ html.LoadFromFile(FilePath);
+ Result := html.Text;
+ finally
+ html.Free;
+ end;
+ end;
+end;
+class procedure TNewBoardDialog.InitHTTPClient(client : TIdHTTP);
+begin
+ client.Request.Clear;
+ client.Request.CustomHeaders.Clear;
+ client.RecvBufferSize := Gikosys.Setting.RecvBufferSize;
+ client.ProxyParams.BasicAuthentication := False;
+ if GikoSys.Setting.ReadProxy then begin
+ if GikoSys.Setting.ProxyProtocol then
+ client.ProtocolVersion := pv1_1
+ else
+ client.ProtocolVersion := pv1_0;
+ client.ProxyParams.ProxyServer := GikoSys.Setting.ReadProxyAddress;
+ client.ProxyParams.ProxyPort := GikoSys.Setting.ReadProxyPort;
+ client.ProxyParams.ProxyUsername := GikoSys.Setting.ReadProxyUserID;
+ client.ProxyParams.ProxyPassword := GikoSys.Setting.ReadProxyPassword;
+ if GikoSys.Setting.ReadProxyUserID <> '' then
+ client.ProxyParams.BasicAuthentication := True;
+ end else begin
+ if GikoSys.Setting.Protocol then
+ client.ProtocolVersion := pv1_1
+ else
+ client.ProtocolVersion := pv1_0;
+ client.ProxyParams.ProxyServer := '';
+ client.ProxyParams.ProxyPort := 80;
+ client.ProxyParams.ProxyUsername := '';
+ client.ProxyParams.ProxyPassword := '';
+ end;
+end;
end.