From 051249189e85072f8f57f21e636454b595c25aac Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 27 Oct 2004 03:17:40 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4445 --- clientgui/DlgOptions.cpp | 88 +++++++++++++++++++++++++++++++++++--- clientgui/DlgOptions.h | 2 +- clientgui/MainDocument.cpp | 40 ++++------------- clientgui/MainDocument.h | 4 -- clientgui/MainFrame.cpp | 66 ++++++++++++++++++++++++++-- lib/gui_rpc_client.C | 18 ++++---- 6 files changed, 164 insertions(+), 54 deletions(-) diff --git a/clientgui/DlgOptions.cpp b/clientgui/DlgOptions.cpp index f56e8d2b92..b3d7e95e42 100644 --- a/clientgui/DlgOptions.cpp +++ b/clientgui/DlgOptions.cpp @@ -69,7 +69,7 @@ bool CDlgOptions::Create( wxWindow* parent, wxWindowID id, const wxString& capti m_SOCKSAddressCtrl = NULL; m_SOCKSPortCtrl = NULL; m_SOCKSUsernameCtrl = NULL; - m_SOCKPasswordCtrl = NULL; + m_SOCKSPasswordCtrl = NULL; SetExtraStyle(wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); @@ -219,7 +219,7 @@ void CDlgOptions::CreateControls() wxTextCtrl* itemTextCtrl38 = new wxTextCtrl; itemTextCtrl38->Create( itemPanel23, ID_SOCKSPASSWORDCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD ); - m_SOCKPasswordCtrl = itemTextCtrl38; + m_SOCKSPasswordCtrl = itemTextCtrl38; itemFlexGridSizer34->Add(itemTextCtrl38, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); itemNotebook3->AddPage(itemPanel23, _("SOCKS Proxy")); @@ -255,28 +255,104 @@ void CDlgOptions::OnNotebookUpdate( wxUpdateUIEvent& event ) void CDlgOptions::OnEnableHTTPProxyCtrlClick( wxCommandEvent& event ) { - // Insert custom code here + if ( event.IsChecked() ) + { + m_HTTPAddressCtrl->Enable(true); + m_HTTPPortCtrl->Enable(true); + m_HTTPUsernameCtrl->Enable(true); + m_HTTPPasswordCtrl->Enable(true); + } + else + { + m_HTTPAddressCtrl->Enable(false); + m_HTTPPortCtrl->Enable(false); + m_HTTPUsernameCtrl->Enable(false); + m_HTTPPasswordCtrl->Enable(false); + } event.Skip(); } void CDlgOptions::OnEnableHTTPProxyCtrlUpdate( wxUpdateUIEvent& event ) { - // Insert custom code here + if ( m_bProxySectionConfigured ) + { + m_EnableHTTPProxyCtrl->Enable(true); + if ( m_EnableHTTPProxyCtrl->IsChecked() ) + { + m_HTTPAddressCtrl->Enable(true); + m_HTTPPortCtrl->Enable(true); + m_HTTPUsernameCtrl->Enable(true); + m_HTTPPasswordCtrl->Enable(true); + } + else + { + m_HTTPAddressCtrl->Enable(false); + m_HTTPPortCtrl->Enable(false); + m_HTTPUsernameCtrl->Enable(false); + m_HTTPPasswordCtrl->Enable(false); + } + } + else + { + m_EnableHTTPProxyCtrl->Enable(false); + m_HTTPAddressCtrl->Enable(false); + m_HTTPPortCtrl->Enable(false); + m_HTTPUsernameCtrl->Enable(false); + m_HTTPPasswordCtrl->Enable(false); + } event.Skip(); } void CDlgOptions::OnEnableSOCKSProxyCtrlClick( wxCommandEvent& event ) { - // Insert custom code here + if ( event.IsChecked() ) + { + m_SOCKSAddressCtrl->Enable(true); + m_SOCKSPortCtrl->Enable(true); + m_SOCKSUsernameCtrl->Enable(true); + m_SOCKSPasswordCtrl->Enable(true); + } + else + { + m_SOCKSAddressCtrl->Enable(false); + m_SOCKSPortCtrl->Enable(false); + m_SOCKSUsernameCtrl->Enable(false); + m_SOCKSPasswordCtrl->Enable(false); + } event.Skip(); } void CDlgOptions::OnEnableSOCKSProxyCtrlUpdate( wxUpdateUIEvent& event ) { - // Insert custom code here + if ( m_bProxySectionConfigured ) + { + m_EnableSOCKSProxyCtrl->Enable(true); + if ( m_EnableSOCKSProxyCtrl->IsChecked() ) + { + m_SOCKSAddressCtrl->Enable(true); + m_SOCKSPortCtrl->Enable(true); + m_SOCKSUsernameCtrl->Enable(true); + m_SOCKSPasswordCtrl->Enable(true); + } + else + { + m_SOCKSAddressCtrl->Enable(false); + m_SOCKSPortCtrl->Enable(false); + m_SOCKSUsernameCtrl->Enable(false); + m_SOCKSPasswordCtrl->Enable(false); + } + } + else + { + m_EnableSOCKSProxyCtrl->Enable(false); + m_SOCKSAddressCtrl->Enable(false); + m_SOCKSPortCtrl->Enable(false); + m_SOCKSUsernameCtrl->Enable(false); + m_SOCKSPasswordCtrl->Enable(false); + } event.Skip(); } diff --git a/clientgui/DlgOptions.h b/clientgui/DlgOptions.h index 9f8edca57b..94e21d4476 100644 --- a/clientgui/DlgOptions.h +++ b/clientgui/DlgOptions.h @@ -102,7 +102,7 @@ public: wxTextCtrl* m_SOCKSAddressCtrl; wxTextCtrl* m_SOCKSPortCtrl; wxTextCtrl* m_SOCKSUsernameCtrl; - wxTextCtrl* m_SOCKPasswordCtrl; + wxTextCtrl* m_SOCKSPasswordCtrl; }; #endif diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 0911420660..a946b6889b 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -1411,20 +1411,14 @@ wxInt32 CMainDocument::GetProxyConfiguration() wxInt32 CMainDocument::GetProxyHTTPProxyEnabled( bool& bEnabled ) { - bEnabled = proxy_info.use_http_authentication; - return 0; -} - - -wxInt32 CMainDocument::GetProxyHTTPAuthenticationEnabled( bool& bEnabled ) -{ - bEnabled = proxy_info.use_http_authentication; + bEnabled = proxy_info.use_http_proxy; return 0; } wxInt32 CMainDocument::GetProxyHTTPServerName( wxString& strServerName ) { + strServerName.Clear(); strServerName = proxy_info.http_server_name.c_str(); return 0; } @@ -1439,6 +1433,7 @@ wxInt32 CMainDocument::GetProxyHTTPServerPort( wxInt32& iPortNumber ) wxInt32 CMainDocument::GetProxyHTTPUserName( wxString& strUserName ) { + strUserName.Clear(); strUserName = proxy_info.http_user_name.c_str(); return 0; } @@ -1446,6 +1441,7 @@ wxInt32 CMainDocument::GetProxyHTTPUserName( wxString& strUserName ) wxInt32 CMainDocument::GetProxyHTTPPassword( wxString& strPassword ) { + strPassword.Clear(); strPassword = proxy_info.http_user_passwd.c_str(); return 0; } @@ -1458,15 +1454,9 @@ wxInt32 CMainDocument::GetProxySOCKSProxyEnabled( bool& bEnabled ) } -wxInt32 CMainDocument::GetProxySOCKSVersion( wxInt32& iVersion ) -{ - iVersion = proxy_info.socks_version; - return 0; -} - - wxInt32 CMainDocument::GetProxySOCKSServerName( wxString& strServerName ) { + strServerName.Clear(); strServerName = proxy_info.socks_server_name.c_str(); return 0; } @@ -1481,6 +1471,7 @@ wxInt32 CMainDocument::GetProxySOCKSServerPort( wxInt32& iPortNumber ) wxInt32 CMainDocument::GetProxySOCKSUserName( wxString& strUserName ) { + strUserName.Clear(); strUserName = proxy_info.socks5_user_name.c_str(); return 0; } @@ -1488,6 +1479,7 @@ wxInt32 CMainDocument::GetProxySOCKSUserName( wxString& strUserName ) wxInt32 CMainDocument::GetProxySOCKSPassword( wxString& strPassword ) { + strPassword.Clear(); strPassword = proxy_info.socks5_user_passwd.c_str(); return 0; } @@ -1497,7 +1489,7 @@ wxInt32 CMainDocument::SetProxyConfiguration() { wxInt32 retval = 0; - retval = rpc.set_proxy_settings(proxy_info); + retval = rpc.set_proxy_settings( proxy_info ); if (retval) { wxLogTrace("CMainDocument::SetProxyInfo - Set Proxy Info Failed '%d'", retval); @@ -1510,14 +1502,7 @@ wxInt32 CMainDocument::SetProxyConfiguration() wxInt32 CMainDocument::SetProxyHTTPProxyEnabled( const bool bEnabled ) { - proxy_info.use_http_authentication = bEnabled; - return 0; -} - - -wxInt32 CMainDocument::SetProxyHTTPAuthenticationEnabled( const bool bEnabled ) -{ - proxy_info.use_http_authentication = bEnabled; + proxy_info.use_http_proxy = bEnabled; return 0; } @@ -1557,13 +1542,6 @@ wxInt32 CMainDocument::SetProxySOCKSProxyEnabled( const bool bEnabled ) } -wxInt32 CMainDocument::SetProxySOCKSVersion( const wxInt32 iVersion ) -{ - proxy_info.socks_version = iVersion; - return 0; -} - - wxInt32 CMainDocument::SetProxySOCKSServerName( const wxString& strServerName ) { proxy_info.socks_server_name = strServerName.c_str(); diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index d17ef8f1fa..d5eaea1f4e 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -246,13 +246,11 @@ public: wxInt32 GetProxyConfiguration(); wxInt32 GetProxyHTTPProxyEnabled( bool& bEnabled ); - wxInt32 GetProxyHTTPAuthenticationEnabled( bool& bEnabled ); wxInt32 GetProxyHTTPServerName( wxString& strServerName ); wxInt32 GetProxyHTTPServerPort( wxInt32& iPortNumber ); wxInt32 GetProxyHTTPUserName( wxString& strUserName ); wxInt32 GetProxyHTTPPassword( wxString& strPassword ); wxInt32 GetProxySOCKSProxyEnabled( bool& bEnabled ); - wxInt32 GetProxySOCKSVersion( wxInt32& iVersion ); wxInt32 GetProxySOCKSServerName( wxString& strServerName ); wxInt32 GetProxySOCKSServerPort( wxInt32& iPortNumber ); wxInt32 GetProxySOCKSUserName( wxString& strUserName ); @@ -260,13 +258,11 @@ public: wxInt32 SetProxyConfiguration(); wxInt32 SetProxyHTTPProxyEnabled( const bool bEnabled ); - wxInt32 SetProxyHTTPAuthenticationEnabled( const bool bEnabled ); wxInt32 SetProxyHTTPServerName( const wxString& strServerName ); wxInt32 SetProxyHTTPServerPort( const wxInt32 iPortNumber ); wxInt32 SetProxyHTTPUserName( const wxString& strUserName ); wxInt32 SetProxyHTTPPassword( const wxString& strPassword ); wxInt32 SetProxySOCKSProxyEnabled( const bool bEnabled ); - wxInt32 SetProxySOCKSVersion( const wxInt32 iVersion ); wxInt32 SetProxySOCKSServerName( const wxString& strServerName ); wxInt32 SetProxySOCKSServerPort( const wxInt32 iPortNumber ); wxInt32 SetProxySOCKSUserName( const wxString& strUserName ); diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 57e1848049..b8a29cd44a 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -531,18 +531,78 @@ void CMainFrame::OnToolsOptions( wxCommandEvent& WXUNUSED(event) ) CMainDocument* pDoc = wxGetApp().GetDocument(); CDlgOptions* pDlg = new CDlgOptions(this); wxInt32 iAnswer = 0; + bool bProxyInformationConfigured = false; + bool bBuffer = false; + wxInt32 iBuffer = 0; + wxString strBuffer = wxEmptyString; wxASSERT(NULL != pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(NULL != pDlg); - - iAnswer = pDlg->ShowModal(); - if ( wxOK == iAnswer ) + bProxyInformationConfigured = ( 0 == pDoc->GetProxyConfiguration() ); + if ( bProxyInformationConfigured ) { + pDlg->m_bProxySectionConfigured = true; + if ( 0 == pDoc->GetProxyHTTPProxyEnabled( bBuffer ) ) + pDlg->m_EnableHTTPProxyCtrl->SetValue( bBuffer ); + if ( 0 == pDoc->GetProxyHTTPServerName( strBuffer ) ) + pDlg->m_HTTPAddressCtrl->SetValue( strBuffer ); + if ( 0 == pDoc->GetProxyHTTPServerPort( iBuffer ) ) + { + strBuffer.Printf( wxT("%d"), iBuffer ); + pDlg->m_HTTPPortCtrl->SetValue( strBuffer ); + } + if ( 0 == pDoc->GetProxyHTTPUserName( strBuffer ) ) + pDlg->m_HTTPUsernameCtrl->SetValue( strBuffer ); + if ( 0 == pDoc->GetProxyHTTPPassword( strBuffer ) ) + pDlg->m_HTTPPasswordCtrl->SetValue( strBuffer ); + + if ( 0 == pDoc->GetProxySOCKSProxyEnabled( bBuffer ) ) + pDlg->m_EnableSOCKSProxyCtrl->SetValue( bBuffer ); + if ( 0 == pDoc->GetProxySOCKSServerName( strBuffer ) ) + pDlg->m_SOCKSAddressCtrl->SetValue( strBuffer ); + if ( 0 == pDoc->GetProxySOCKSServerPort( iBuffer ) ) + { + strBuffer.Printf( wxT("%d"), iBuffer ); + pDlg->m_SOCKSPortCtrl->SetValue( strBuffer ); + } + if ( 0 == pDoc->GetProxySOCKSUserName( strBuffer ) ) + pDlg->m_SOCKSUsernameCtrl->SetValue( strBuffer ); + if ( 0 == pDoc->GetProxySOCKSPassword( strBuffer ) ) + pDlg->m_SOCKSPasswordCtrl->SetValue( strBuffer ); } + iAnswer = pDlg->ShowModal(); + if ( wxID_OK == iAnswer ) + { + bBuffer = pDlg->m_EnableHTTPProxyCtrl->GetValue(); + pDoc->SetProxyHTTPProxyEnabled( bBuffer ); + strBuffer = pDlg->m_HTTPAddressCtrl->GetValue(); + pDoc->SetProxyHTTPServerName( strBuffer ); + strBuffer = pDlg->m_HTTPPortCtrl->GetValue(); + strBuffer.ToLong( (long*)&iBuffer ); + pDoc->SetProxyHTTPServerPort( iBuffer ); + strBuffer = pDlg->m_HTTPUsernameCtrl->GetValue(); + pDoc->SetProxyHTTPUserName( strBuffer ); + strBuffer = pDlg->m_HTTPPasswordCtrl->GetValue(); + pDoc->SetProxyHTTPPassword( strBuffer ); + bBuffer = pDlg->m_EnableHTTPProxyCtrl->GetValue(); + + pDoc->SetProxySOCKSProxyEnabled( bBuffer ); + strBuffer = pDlg->m_SOCKSAddressCtrl->GetValue(); + pDoc->SetProxySOCKSServerName( strBuffer ); + strBuffer = pDlg->m_SOCKSPortCtrl->GetValue(); + strBuffer.ToLong( (long*)&iBuffer ); + pDoc->SetProxySOCKSServerPort( iBuffer ); + strBuffer = pDlg->m_SOCKSUsernameCtrl->GetValue(); + pDoc->SetProxySOCKSUserName( strBuffer ); + strBuffer = pDlg->m_SOCKSPasswordCtrl->GetValue(); + pDoc->SetProxySOCKSPassword( strBuffer ); + + pDoc->SetProxyConfiguration(); + } if (pDlg) pDlg->Destroy(); diff --git a/lib/gui_rpc_client.C b/lib/gui_rpc_client.C index 74b83aeaf4..9ce7e0764e 100644 --- a/lib/gui_rpc_client.C +++ b/lib/gui_rpc_client.C @@ -1254,30 +1254,30 @@ int RPC_CLIENT::run_benchmarks() { } int RPC_CLIENT::set_proxy_settings(PROXY_INFO& pi) { - char buf[256]; + char buf[1024]; RPC rpc(this); sprintf(buf, "\n%s%s" " \n" - " %s\n" - " %d\n" " %s\n" " %d\n" - " %d\n" - " %d\n" - " %d\n" - " %d\n" + " %s\n" + " %s\n" + " %s\n" + " %d\n" + " %s\n" + " %s\n" " \n" "\n", pi.use_http_proxy?" \n":"", pi.use_socks_proxy?" \n":"", - pi.socks_server_name.c_str(), - pi.socks_server_port, pi.http_server_name.c_str(), pi.http_server_port, pi.http_user_name.c_str(), pi.http_user_passwd.c_str(), + pi.socks_server_name.c_str(), + pi.socks_server_port, pi.socks5_user_name.c_str(), pi.socks5_user_passwd.c_str() );