int CBOINCDialUpManager::NotifyUserNeedConnection(bool bNotificationOnly) { CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxTimeSpan tsLastDialupAlertSent; wxString strDialogMessage = wxEmptyString; wxASSERT(pFrame); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); tsLastDialupAlertSent = wxDateTime::Now() - m_dtLastDialupAlertSent; if ((tsLastDialupAlertSent.GetMinutes() >= pFrame->GetReminderFrequency()) && (pFrame->GetReminderFrequency() != 0)) { wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::NotifyUserNeedConnection - Manager not shown, notify instead")); m_dtLastDialupAlertSent = wxDateTime::Now(); #ifdef __WXWIN__ // 1st %s is the project name // i.e. 'BOINC', 'GridRepublic' // 2st %s is the application name // i.e. 'BOINC Manager', 'GridRepublic Manager' strDialogMessage.Printf( _("%s needs to connect to the Internet. Please click to open %s."), pSkinAdvanced->GetApplicationShortName().c_str(), pSkinAdvanced->GetApplicationName().c_str() ); #else // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s is unable to communicate with a project and needs an Internet connection.\n" "Please connect to the Internet, then select the 'Do network communications' " "item from the Advanced menu."), pSkinAdvanced->GetApplicationShortName().c_str() ); #endif pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION, bNotificationOnly ); } return 0; }
bool CDlgOptions::ReadSettings() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); wxString strBuffer = wxEmptyString; wxArrayString astrDialupConnections; wxASSERT(pDoc); wxASSERT(pFrame); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); // General Tab m_LanguageSelectionCtrl->Append(wxGetApp().GetSupportedLanguages()); m_LanguageSelectionCtrl->SetSelection(pFrame->GetSelectedLanguage()); m_ReminderFrequencyCtrl->Append(_("always")); m_ReminderFrequencyCtrl->Append(_("1 hour")); m_ReminderFrequencyCtrl->Append(_("6 hours")); m_ReminderFrequencyCtrl->Append(_("1 day")); m_ReminderFrequencyCtrl->Append(_("1 week")); m_ReminderFrequencyCtrl->Append(_("never")); switch(pFrame->GetReminderFrequency()) { case 1: m_ReminderFrequencyCtrl->SetSelection(0); break; case 60: m_ReminderFrequencyCtrl->SetSelection(1); break; case 360: m_ReminderFrequencyCtrl->SetSelection(2); break; case 1440: m_ReminderFrequencyCtrl->SetSelection(3); break; case 10080: m_ReminderFrequencyCtrl->SetSelection(4); break; case 0: m_ReminderFrequencyCtrl->SetSelection(5); break; } //m_ReminderFrequencyCtrl->SetValue(m_iReminderFrequency); m_EnableBOINCManagerExitMessageCtrl->SetValue(wxGetApp().GetBOINCMGRDisplayExitMessage() != 0); #ifdef __WXMSW__ m_EnableBOINCManagerAutoStartCtrl->SetValue(!wxGetApp().GetBOINCMGRDisableAutoStart()); // Connection Tab if (pFrame) { pFrame->GetDialupManager()->GetISPNames(astrDialupConnections); m_DialupConnectionsCtrl->Append(astrDialupConnections); SetDefaultDialupConnection(pFrame->GetDialupConnectionName()); } else { m_DialupSetDefaultCtrl->Disable(); m_DialupClearDefaultCtrl->Disable(); } #endif // Proxy Tabs m_bRetrievedProxyConfiguration = (0 == pDoc->GetProxyConfiguration()); if(!m_bRetrievedProxyConfiguration) { // We were unable to get the proxy configuration, so disable // the controls m_EnableHTTPProxyCtrl->Enable(false); m_EnableSOCKSProxyCtrl->Enable(false); } else { m_EnableHTTPProxyCtrl->Enable(true); m_EnableSOCKSProxyCtrl->Enable(true); } m_EnableHTTPProxyCtrl->SetValue(pDoc->proxy_info.use_http_proxy); m_HTTPAddressCtrl->SetValue(wxString(pDoc->proxy_info.http_server_name.c_str(), wxConvUTF8)); m_HTTPUsernameCtrl->SetValue(wxString(pDoc->proxy_info.http_user_name.c_str(), wxConvUTF8)); m_HTTPPasswordCtrl->SetValue(wxString(pDoc->proxy_info.http_user_passwd.c_str(), wxConvUTF8)); m_HTTPNoProxiesCtrl->SetValue(wxString(pDoc->proxy_info.noproxy_hosts.c_str(), wxConvUTF8)); strBuffer.Printf(wxT("%d"), pDoc->proxy_info.http_server_port); m_HTTPPortCtrl->SetValue(strBuffer); m_EnableSOCKSProxyCtrl->SetValue(pDoc->proxy_info.use_socks_proxy); m_SOCKSAddressCtrl->SetValue(wxString(pDoc->proxy_info.socks_server_name.c_str(), wxConvUTF8)); m_SOCKSUsernameCtrl->SetValue(wxString(pDoc->proxy_info.socks5_user_name.c_str(), wxConvUTF8)); m_SOCKSPasswordCtrl->SetValue(wxString(pDoc->proxy_info.socks5_user_passwd.c_str(), wxConvUTF8)); m_SOCKSNoProxiesCtrl->SetValue(wxString(pDoc->proxy_info.noproxy_hosts.c_str(),wxConvUTF8)); strBuffer.Printf(wxT("%d"), pDoc->proxy_info.socks_server_port); m_SOCKSPortCtrl->SetValue(strBuffer); return true; }
int CBOINCDialUpManager::Connect() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxTimeSpan tsLastDialupRequest; int iAnswer; wxString strDialogMessage = wxEmptyString; GLOBAL_PREFS_MASK mask; wxASSERT(pDoc); wxASSERT(pFrame); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); tsLastDialupRequest = wxDateTime::Now() - m_dtLastDialupRequest; if ((tsLastDialupRequest.GetMinutes() >= pFrame->GetReminderFrequency()) && (pFrame->GetReminderFrequency() != 0)) { wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Connect - Begin connection process")); m_dtLastDialupRequest = wxDateTime::Now(); if (!pFrame->GetDialupConnectionName().empty()) { // We have a valid connection name that we can dial. // Update current working preferences (including any overrides) from client pDoc->rpc.get_global_prefs_working_struct(pDoc->state.global_prefs, mask); if(pDoc->state.global_prefs.confirm_before_connecting) { // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s needs to connect to the Internet.\nMay it do so now?"), pSkinAdvanced->GetApplicationShortName().c_str() ); iAnswer = ::wxMessageBox( strDialogMessage, m_strDialogTitle, wxYES_NO | wxICON_QUESTION, pFrame ); } else { // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s is connecting to the Internet."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION, true ); iAnswer = wxYES; } // Are we allow to connect? if (wxYES == iAnswer) { m_bNotifyConnectionAvailable = true; m_bConnectedSuccessfully = false; m_pDialupManager->Dial( pFrame->GetDialupConnectionName(), wxEmptyString, wxEmptyString, true ); } } else { // The user hasn't given us a valid connection to dial. Inform them // that we need a connection and that they may need to set a default // connection. // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s couldn't do Internet communication, and no default connection is selected.\n" "Please connect to the Internet, or select a default connection\n" "using Advanced/Options/Connections."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION, false ); } } return 0; }