OSDN Git Service

認証が必要なProxyへの対応(Basic認証のみ・環境がないので未テスト)
authorC.Ponapalt <ponapalt@shillest.net>
Sun, 14 Nov 2004 05:57:27 +0000 (05:57 +0000)
committerC.Ponapalt <ponapalt@shillest.net>
Sun, 14 Nov 2004 05:57:27 +0000 (05:57 +0000)
bottleclient/BottleDef.pas
bottleclient/HttpThread.pas
bottleclient/Logs.pas
bottleclient/MainForm.pas
bottleclient/SettingForm.dfm
bottleclient/SettingForm.pas

index 872a7cf..f53d668 100755 (executable)
@@ -62,6 +62,9 @@ type
     FAskUseHttpProxy: boolean;
     FProxyPort: integer;
     FProxyAddress: String;
+    FProxyNeedAuthentication: boolean;
+    FProxyUser: String;
+    FProxyPass: String;
     FConfirmOnExit: boolean;
     FFixMessySurface: boolean;
     FResetIfGhostAfterSend: boolean;
@@ -131,6 +134,9 @@ type
     procedure SetLogWindowDividerPos(const Value: integer);
     procedure SetProxyAddress(const Value: String);
     procedure SetProxyPort(const Value: integer);
+    procedure SetProxyUser(const Value: String);
+    procedure SetProxyPass(const Value: String);
+    procedure SetProxyNeedAuthentication(const Value: boolean);
     procedure SetUseHttpProxy(const Value: boolean);
     procedure SetAskUseHttpProxy(const Value: boolean);
     procedure SetConfirmOnExit(const Value: boolean);
@@ -241,6 +247,9 @@ type
     property AskUseHttpProxy: boolean read FAskUseHttpProxy write SetAskUseHttpProxy;
     property ProxyAddress: String read FProxyAddress write SetProxyAddress;
     property ProxyPort: integer read FProxyPort write SetProxyPort;
+    property ProxyUser: String read FProxyUser write SetProxyUser;
+    property ProxyPass: String read FProxyPass write SetProxyPass;
+    property ProxyNeedAuthentication: boolean read FProxyNeedAuthentication write SetProxyNeedAuthentication;
     //\8dÄ\90Ú\91±
     property ReconnectWait: integer read FReconnectWait write SetReconnectWait;
     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
@@ -662,6 +671,9 @@ begin
     AskUseHttpProxy := FIni.ReadBool('System', 'AskUseHttpProxy', false);
     ProxyAddress := FIni.ReadString('System', 'ProxyAddress', '');
     ProxyPort    := FIni.ReadInteger('System', 'ProxyPort', 0);
+    ProxyUser    := FIni.ReadString('System', 'ProxyUser', '');
+    ProxyPass    := FIni.ReadString('System', 'ProxyPass', '');
+    ProxyNeedAuthentication := FIni.ReadBool('System', 'ProxyNeedAuthentication', false);
     //
     ReconnectWait := FIni.ReadInteger('System', 'ReconnectWait', 6);
     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
@@ -846,6 +858,21 @@ begin
   FProxyPort := Value;
 end;
 
+procedure TBottlePrefs.SetProxyNeedAuthentication(const Value: boolean);
+begin
+  FProxyNeedAuthentication := Value;
+end;
+
+procedure TBottlePrefs.SetProxyPass(const Value: String);
+begin
+  FProxyPass := Value;
+end;
+
+procedure TBottlePrefs.SetProxyUser(const Value: String);
+begin
+  FProxyUser := Value;
+end;
+
 procedure TBottlePrefs.SetResetIfGhostAfterSend(const Value: boolean);
 begin
   FResetIfGhostAfterSend := Value;
@@ -1028,6 +1055,9 @@ begin
   FIni.WriteBool('System', 'AskUseHttpProxy', AskUseHttpProxy);
   FIni.WriteString('System', 'ProxyAddress', ProxyAddress);
   FIni.WriteInteger('System', 'ProxyPort', ProxyPort);
+  FIni.WriteBool('System', 'ProxyNeedAuthentication', ProxyNeedAuthentication);
+  FIni.WriteString('System', 'ProxyUser', ProxyUser);
+  FIni.WriteString('System', 'ProxyPass', ProxyPass);
   //
   FIni.WriteInteger('System', 'ReconnectWait', ReconnectWait);
   //
index b1b67f8..fcc8e80 100755 (executable)
@@ -17,6 +17,8 @@ type
     FRecvString: String;
     FProxyServer: String;
     FProxyPort: integer;
+    FProxyUser: String;
+    FProxyPass: String;
     FOnSuccess: TNotifyEvent;
     FOnConnectionFailed: TNotifyEvent;
     FLastErrorMessage: String;
@@ -26,6 +28,8 @@ type
     FTriggerWorkEventBy: integer;
     procedure SetProxyPort(const Value: integer);
     procedure SetProxyServer(const Value: String);
+    procedure SetProxyUser(const Value: String);
+    procedure SetProxyPass(const Value: String);
     procedure SetOnConnectionFailed(const Value: TNotifyEvent);
     procedure SetOnSuccess(const Value: TNotifyEvent);
     procedure SetOnHttpWork(const Value: THttpWorkEvent);
@@ -42,6 +46,8 @@ type
     property RecvString: String read FRecvString;
     property ProxyServer: String read FProxyServer write SetProxyServer;
     property ProxyPort: integer read FProxyPort write SetProxyPort;
+    property ProxyUser: String read FProxyUser write SetProxyUser;
+    property ProxyPass: String read FProxyPass write SetProxyPass;
     property OnConnectionFailed: TNotifyEvent read FOnConnectionFailed write SetOnConnectionFailed;
     property OnSuccess: TNotifyEvent read FOnSuccess write SetOnSuccess;
     property OnHttpWork: THttpWorkEvent read FOnHttpWork write SetOnHttpWork;
@@ -114,6 +120,15 @@ begin
       Http.Host := FHost;
       Http.ProxyParams.ProxyServer := ProxyServer;
       Http.ProxyParams.ProxyPort := ProxyPort;
+
+      if ProxyUser <> '' then begin
+        if ProxyPass <> '' then begin
+          Http.ProxyParams.BasicAuthentication := true;
+          Http.ProxyParams.ProxyUsername := ProxyUser;
+          Http.ProxyParams.ProxyPassword := ProxyPass;
+        end;
+      end;
+
       Http.OnWork := WorkHandler;
       if FPost = '' then begin
         FRecvString := Http.Get(FURL);
@@ -167,6 +182,22 @@ begin
     raise EIdException.Create('Tried to change proxy without suspending');
 end;
 
+procedure THTTPDownloadThread.SetProxyUser(const Value: String);
+begin
+  if Suspended then
+    FProxyUser := Value
+  else
+    raise EIdException.Create('Tried to change proxy without suspending');
+end;
+
+procedure THTTPDownloadThread.SetProxyPass(const Value: String);
+begin
+  if Suspended then
+    FProxyPass := Value
+  else
+    raise EIdException.Create('Tried to change proxy without suspending');
+end;
+
 procedure THTTPDownloadThread.SetTriggerWorkEventBy(const Value: integer);
 begin
   FTriggerWorkEventBy := Value;
index d371dca..037c538 100755 (executable)
@@ -534,6 +534,10 @@ begin
   if Pref.UseHttpProxy then begin
     FHttpThread.ProxyServer := Pref.ProxyAddress;
     FHttpThread.ProxyPort   := Pref.ProxyPort;
+    if Pref.ProxyNeedAuthentication then begin
+      FHttpThread.ProxyUser := Pref.ProxyUser;
+      FHttpThread.ProxyPass := Pref.ProxyPass;
+    end;
   end;
   FHttpThread.FreeOnTerminate := true;
   FHttpThread.OnSuccess := HttpSuccess;
index e3467b5..71c73ce 100755 (executable)
@@ -755,8 +755,13 @@ begin
     IdSlpp20.Host := Pref.ProxyAddress;
     IdSlpp20.Port := Pref.ProxyPort;
     IdSlpp20.ProxyMode := true;
-    IdSlpp20.ProxyUser := '';
-    IdSlpp20.ProxyPass := '';
+    if Pref.ProxyNeedAuthentication then begin
+      IdSlpp20.ProxyUser := Pref.ProxyUser;
+      IdSlpp20.ProxyPass := Pref.ProxyPass;
+    end else begin
+      IdSlpp20.ProxyUser := '';
+      IdSlpp20.ProxyPass := '';
+    end;
   end else begin
     IdSlpp20.Host := Pref.BottleServer;
     IdSlpp20.Port := Pref.BottleServerPort;
@@ -1917,6 +1922,10 @@ begin
     if Pref.UseHttpProxy then begin
       FHttp.ProxyServer := Pref.ProxyAddress;
       FHttp.ProxyPort   := Pref.ProxyPort;
+      if Pref.ProxyNeedAuthentication then begin
+        FHttp.ProxyUser := Pref.ProxyUser;
+        FHttp.ProxyPass := Pref.ProxyPass;
+      end;
     end;
     FHttp.OnSuccess := HttpSuccess;
     FHttp.OnConnectionFailed := HttpFailure;
index b2988c9..77e8e1b 100755 (executable)
@@ -36,7 +36,7 @@ object frmSetting: TfrmSetting
     Top = 32
     Width = 440
     Height = 291
-    ActivePage = tstGeneral
+    ActivePage = tstConnection
     Anchors = [akLeft, akTop, akRight, akBottom]
     MultiLine = True
     TabOrder = 0
@@ -735,7 +735,7 @@ object frmSetting: TfrmSetting
       TabVisible = False
       object lblReconnectWait: TLabel
         Left = 8
-        Top = 168
+        Top = 216
         Width = 156
         Height = 12
         Caption = #20877#25509#32154#12434#35430#12415#12427#12414#12391#12398#20998#25968'(&R):'
@@ -745,12 +745,12 @@ object frmSetting: TfrmSetting
         Left = 8
         Top = 8
         Width = 417
-        Height = 145
+        Height = 193
         Caption = 'HTTP Proxy'#35373#23450
         TabOrder = 0
         object lblProxyAddress: TLabel
           Left = 16
-          Top = 92
+          Top = 84
           Width = 56
           Height = 12
           Caption = #12450#12489#12524#12473'(&D)'
@@ -758,7 +758,7 @@ object frmSetting: TfrmSetting
         end
         object lblProxyPort: TLabel
           Left = 16
-          Top = 116
+          Top = 108
           Width = 47
           Height = 12
           Caption = #12509#12540#12488'(&O)'
@@ -777,9 +777,23 @@ object frmSetting: TfrmSetting
           Font.Style = []
           ParentFont = False
         end
+        object Label2: TLabel
+          Left = 16
+          Top = 164
+          Width = 48
+          Height = 12
+          Caption = #12518#12540#12470#21517
+        end
+        object Label3: TLabel
+          Left = 216
+          Top = 164
+          Width = 54
+          Height = 12
+          Caption = #12497#12473#12527#12540#12489
+        end
         object edtProxyAddress: TEdit
           Left = 80
-          Top = 88
+          Top = 80
           Width = 257
           Height = 20
           Hint = 'Proxy'#12469#12540#12496#12398#12450#12489#12524#12473
@@ -787,7 +801,7 @@ object frmSetting: TfrmSetting
         end
         object edtProxyPort: TEdit
           Left = 80
-          Top = 112
+          Top = 104
           Width = 81
           Height = 20
           Hint = 'Proxy'#12469#12540#12496#12398#12509#12540#12488#30058#21495
@@ -805,17 +819,42 @@ object frmSetting: TfrmSetting
         end
         object cbxAskUseHttpProxy: TCheckBox
           Left = 16
-          Top = 64
+          Top = 56
           Width = 305
           Height = 17
           Hint = #12463#12521#12452#12450#12531#12488#36215#21205#26178#12395#12289'Proxy'#12434#21033#29992#12377#12427#12363#12393#12358#12363#30906#35469#12375#12414#12377
           Caption = #36215#21205#26178#12395'Proxy'#12434#21033#29992#12377#12427#12363#12393#12358#12363#12383#12378#12397#12427'(&A)'
           TabOrder = 3
         end
+        object cbxProxyNeedAuthentication: TCheckBox
+          Left = 16
+          Top = 136
+          Width = 273
+          Height = 17
+          Hint = #35469#35388#12364#24517#35201#12394'Proxy'#12434#21033#29992#12377#12427#22580#21512#12395#12481#12455#12483#12463#12375#12414#12377#12290#36890#24120#12399#12481#12455#12483#12463#12377#12427#24517#35201#12399#12354#12426#12414#12379#12435#12290
+          Caption = #12371#12398'Proxy'#12399#35469#35388#12364#24517#35201
+          TabOrder = 4
+        end
+        object edtProxyUser: TEdit
+          Left = 80
+          Top = 160
+          Width = 121
+          Height = 20
+          Hint = 'Proxy'#12469#12540#12496#12398#12518#12540#12470#21517
+          TabOrder = 5
+        end
+        object edtProxyPass: TEdit
+          Left = 280
+          Top = 160
+          Width = 121
+          Height = 20
+          Hint = 'Proxy'#12469#12540#12496#12398#12497#12473#12527#12540#12489
+          TabOrder = 6
+        end
       end
       object spnReconnectWait: TSpinEdit
         Left = 168
-        Top = 164
+        Top = 212
         Width = 57
         Height = 21
         Hint = #28961#36890#20449#29366#24907#12391#20877#25509#32154#12434#35430#12415#12427#12414#12391#12398#20998#25968#12290#36890#24120#12399#22793#26356#12377#12427#24517#35201#12399#12394#12356
index bbdccc1..11706c0 100755 (executable)
@@ -109,6 +109,11 @@ type
     ReplacePresetList: TfrmReplacePresetList;
     cbxAskUseHttpProxy: TCheckBox;
     cbxNoWarnOfEmptyFMO: TCheckBox;
+    cbxProxyNeedAuthentication: TCheckBox;
+    edtProxyUser: TEdit;
+    edtProxyPass: TEdit;
+    Label2: TLabel;
+    Label3: TLabel;
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
     procedure edtProxyPortKeyPress(Sender: TObject; var Key: Char);
     procedure ctvBottleNodeChecked(Sender: TObject;
@@ -234,8 +239,11 @@ begin
   //
   cbxUseHttpProxy.Checked := Pref.UseHttpProxy;
   cbxAskUseHttpProxy.Checked := Pref.AskUseHttpProxy;
+  cbxProxyNeedAuthentication.Checked := Pref.ProxyNeedAuthentication;
   edtProxyAddress.Text := Pref.ProxyAddress;
   edtProxyPort.Text := IntToStr(Pref.ProxyPort);
+  edtProxyUser.Text := Pref.ProxyUser;
+  edtProxyPass.Text := Pref.ProxyPass;
   //
   spnReconnectWait.Value := Pref.ReconnectWait;
   //
@@ -330,6 +338,9 @@ begin
   Pref.AskUseHttpProxy := cbxAskUseHttpProxy.Checked;
   Pref.ProxyAddress := edtProxyAddress.Text;
   Pref.ProxyPort := StrToInt(edtProxyPort.Text);
+  Pref.ProxyUser := edtProxyUser.Text;
+  Pref.ProxyPass := edtProxyPass.Text;
+  Pref.ProxyNeedAuthentication := cbxProxyNeedAuthentication.Checked;
   //
   Pref.ReconnectWait := spnReconnectWait.Value;
   //