int CBOINCDialUpManager::Disconnect() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); 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)); wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Disconnect - Connection Detected, disconnect requested via the CC.")); // 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.hangup_if_dialed) { wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Disconnect - Connection Detected, Don't need the network, Hanging up.")); if (m_pDialupManager->HangUp()) { // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s has successfully disconnected from the Internet."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION, true ); m_bConnectedSuccessfully = false; } else { // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s failed to disconnected from the Internet."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_ERROR ); } } return 0; }
int CBOINCDialUpManager::ConnectionFailed() { CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxString strDialogMessage = wxEmptyString; wxASSERT(pFrame); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s failed to connect to the Internet."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_ERROR, true ); m_bConnectedSuccessfully = false; return 0; }
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; }
int CBOINCDialUpManager::NetworkAvailable() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxString strDialogMessage = wxEmptyString; wxASSERT(pDoc); wxASSERT(pFrame); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::NetworkAvailable - Connection Detected, notifing user of update to all projects")); m_bNotifyConnectionAvailable = false; // We are already online but BOINC for some reason is in a state // where it belives it has some pending work to do, so give it // a nudge // %s is the project name // i.e. 'BOINC', 'GridRepublic' strDialogMessage.Printf( _("%s has detected it is now connected to the Internet.\n" "Updating all projects and retrying all transfers."), pSkinAdvanced->GetApplicationShortName().c_str() ); pFrame->ShowAlert( m_strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION, true ); // Signal BOINC to update all projects and transfers. pDoc->rpc.network_available(); return 0; }
bool CDlgOptions::SaveSettings() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); long lBuffer = 0; wxString strBuffer = wxEmptyString; wxASSERT(pDoc); wxASSERT(pFrame); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame)); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); // General Tab if (pFrame->GetSelectedLanguage() != m_LanguageSelectionCtrl->GetSelection()) { wxString strDialogTitle; wxString strDialogMessage; // %s is the application name // i.e. 'BOINC Manager', 'GridRepublic Manager' strDialogTitle.Printf( _("%s - Language Selection"), pSkinAdvanced->GetApplicationName().c_str() ); // %s is the application name // i.e. 'BOINC Manager', 'GridRepublic Manager' strDialogMessage.Printf( _("The %s's default language has been changed, in order for this change to take affect you must restart the %s."), pSkinAdvanced->GetApplicationName().c_str(), pSkinAdvanced->GetApplicationName().c_str() ); pFrame->ShowAlert( strDialogTitle, strDialogMessage, wxOK | wxICON_INFORMATION ); } pFrame->SetSelectedLanguage(m_LanguageSelectionCtrl->GetSelection()); switch(m_ReminderFrequencyCtrl->GetSelection()) { case 0: pFrame->SetReminderFrequency(1); break; case 1: pFrame->SetReminderFrequency(60); break; case 2: pFrame->SetReminderFrequency(360); break; case 3: pFrame->SetReminderFrequency(1440); break; case 4: pFrame->SetReminderFrequency(10080); break; case 5: pFrame->SetReminderFrequency(0); break; } wxGetApp().SetBOINCMGRDisplayExitMessage(m_EnableBOINCManagerExitMessageCtrl->GetValue()); #ifdef __WXMSW__ wxGetApp().SetBOINCMGRDisableAutoStart(!m_EnableBOINCManagerAutoStartCtrl->GetValue()); // Connection Tab pFrame->SetDialupConnectionName(GetDefaultDialupConnection()); #endif // Proxy Tabs if (m_bRetrievedProxyConfiguration) { pDoc->proxy_info.use_http_proxy = m_EnableHTTPProxyCtrl->GetValue(); pDoc->proxy_info.http_server_name = (const char*)m_HTTPAddressCtrl->GetValue().mb_str(); pDoc->proxy_info.http_user_name = (const char*)m_HTTPUsernameCtrl->GetValue().mb_str(); pDoc->proxy_info.http_user_passwd = (const char*)m_HTTPPasswordCtrl->GetValue().mb_str(); if(pDoc->proxy_info.use_http_proxy) { pDoc->proxy_info.noproxy_hosts = (const char*)m_HTTPNoProxiesCtrl->GetValue().mb_str(); } strBuffer = m_HTTPPortCtrl->GetValue(); strBuffer.ToLong((long*)&lBuffer); pDoc->proxy_info.http_server_port = lBuffer; pDoc->proxy_info.use_socks_proxy = m_EnableSOCKSProxyCtrl->GetValue(); pDoc->proxy_info.socks_server_name = (const char*)m_SOCKSAddressCtrl->GetValue().mb_str(); pDoc->proxy_info.socks5_user_name = (const char*)m_SOCKSUsernameCtrl->GetValue().mb_str(); pDoc->proxy_info.socks5_user_passwd = (const char*)m_SOCKSPasswordCtrl->GetValue().mb_str(); if(pDoc->proxy_info.use_socks_proxy) { pDoc->proxy_info.noproxy_hosts = (const char*)m_SOCKSNoProxiesCtrl->GetValue().mb_str(); } strBuffer = m_SOCKSPortCtrl->GetValue(); strBuffer.ToLong((long*)&lBuffer); pDoc->proxy_info.socks_server_port = lBuffer; pDoc->SetProxyConfiguration(); } 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; }