OSDN Git Service

重複処理をメソッド化
[gikonavigoeson/gikonavi.git] / NewBoard.pas
index 6d15bd1..a242402 100644 (file)
@@ -44,6 +44,7 @@ type
                procedure UpdateIgnoreList(Sender: TObject);
        public
                { Public \90é\8c¾ }
+        class procedure InitHTTPClient(client : TIdHTTP);
        end;
 
 var
@@ -61,8 +62,10 @@ var
        Item: TNewBoardItem;
        URL : String;
        protocol, host, path, document, port, bookmark: String;
+    TabURLs: TStringList;
 begin
        try
+               MessageMemo.Clear;
                GikoSys.Setting.BoardURLSelected := BoardURLComboBox.ItemIndex + 1;
                FAbort := False;
                UpdateButton.Enabled := False;
@@ -71,7 +74,6 @@ begin
                EditIgnoreListsButton.Enabled := False;
                URL := BoardURLComboBox.Text;
                GikoSys.ParseURI(URL, protocol, host, path, document, port, bookmark);
-               Writeln(protocol);
                if (protocol = '') then begin
                        Item.FContent := BoardLoardFromFile(URL);
                end else if (AnsiPos('http', protocol) > 0) then begin
@@ -81,14 +83,16 @@ begin
                if FAbort then
                        Exit;
                if Item.FContent <> '' then begin
-                       GikoDM.TabsSaveAction.Tag := 1;
-                       GikoDM.TabsOpenAction.Tag := 1;
-                       GikoDM.TabsSaveAction.Execute;
-                       if (UpdateURL(Item.FContent)) then begin
-                               GikoForm.ReloadBBS;
-                       end;
-                       GikoDM.TabsSaveAction.Tag := 0;
-                       GikoDM.TabsOpenAction.Tag := 0;
+            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
@@ -116,33 +120,8 @@ var
        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';
@@ -431,4 +410,33 @@ begin
                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.