2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2006-02-09 21:51:07 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2006-02-09 21:51:07 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2006-02-09 21:51:07 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2006-02-09 21:51:07 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2006-03-28 07:45:27 +00:00
|
|
|
#pragma implementation "BOINCDialupManager.h"
|
2006-02-09 21:51:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include "diagnostics.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
2006-02-13 10:20:42 +00:00
|
|
|
#include "error_numbers.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
2006-11-10 11:24:12 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCBaseFrame.h"
|
2006-03-28 04:32:14 +00:00
|
|
|
#include "BOINCDialupManager.h"
|
2006-02-09 21:51:07 +00:00
|
|
|
#include "DlgOptions.h"
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCDialUpManager::CBOINCDialUpManager() {
|
2006-03-03 19:46:00 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCDialUpManager::CBOINCDialUpManager - Function Begin"));
|
|
|
|
|
2006-03-28 04:32:14 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-02-09 21:51:07 +00:00
|
|
|
m_pDialupManager = wxDialUpManager::Create();
|
|
|
|
wxASSERT(m_pDialupManager->IsOk());
|
2006-03-28 04:32:14 +00:00
|
|
|
#endif
|
2006-02-17 20:59:15 +00:00
|
|
|
ResetReminderTimers();
|
2006-02-13 10:20:42 +00:00
|
|
|
m_bSetConnectionTimer = false;
|
2006-02-09 21:51:07 +00:00
|
|
|
m_bNotifyConnectionAvailable = false;
|
|
|
|
m_bConnectedSuccessfully = false;
|
|
|
|
m_bResetTimers = false;
|
|
|
|
m_bWasDialing = false;
|
|
|
|
m_iNetworkStatus = 0;
|
2006-02-13 10:20:42 +00:00
|
|
|
m_iConnectAttemptRetVal = 0;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Construct the default dialog title for dial-up messages
|
|
|
|
//
|
|
|
|
// %s is the application name
|
|
|
|
// i.e. 'BOINC Manager', 'GridRepublic Manager'
|
|
|
|
m_strDialogTitle.Printf(
|
|
|
|
_("%s - Network Status"),
|
2006-10-20 15:00:14 +00:00
|
|
|
wxGetApp().GetSkinManager()->GetAdvanced()->GetApplicationName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
2006-03-03 19:46:00 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCDialUpManager::CBOINCDialUpManager - Function End"));
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CBOINCDialUpManager::~CBOINCDialUpManager() {
|
2006-03-03 19:46:00 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCDialUpManager::~CBOINCDialUpManager - Function Begin"));
|
|
|
|
|
2006-03-28 04:32:14 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-02-09 21:51:07 +00:00
|
|
|
delete m_pDialupManager;
|
2006-03-28 04:32:14 +00:00
|
|
|
#endif
|
2006-03-03 19:46:00 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCDialUpManager::~CBOINCDialUpManager - Function End"));
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CBOINCDialUpManager::IsOk() {
|
2006-03-28 04:32:14 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-02-09 21:51:07 +00:00
|
|
|
return m_pDialupManager->IsOk();
|
2006-03-28 04:32:14 +00:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t CBOINCDialUpManager::GetISPNames(wxArrayString& names) {
|
|
|
|
return m_pDialupManager->GetISPNames(names);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-29 16:35:33 +00:00
|
|
|
void CBOINCDialUpManager::OnPoll() {
|
2006-02-09 21:51:07 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2007-03-15 16:03:11 +00:00
|
|
|
static bool bAlreadyRunningLoop = false;
|
2006-02-09 21:51:07 +00:00
|
|
|
bool bIsOnline = false;
|
|
|
|
bool bWantConnection = false;
|
|
|
|
bool bWantDisconnect = false;
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
2006-09-18 05:29:33 +00:00
|
|
|
CC_STATUS cc_status;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
// We are ready to rock and roll.
|
2008-07-30 15:17:11 +00:00
|
|
|
if (!bAlreadyRunningLoop && pDoc && pFrame) {
|
2006-02-09 21:51:07 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2008-08-01 02:58:20 +00:00
|
|
|
|
2007-03-15 16:03:11 +00:00
|
|
|
bAlreadyRunningLoop = true;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
// cache the various states
|
|
|
|
|
|
|
|
// The dialup manager tells us if we are still dialing or if we have
|
|
|
|
// successfully connected. IsNetworkAlive/IsOnline both report the
|
|
|
|
// success or failure of the dialup device to establish a connection
|
|
|
|
// to the outside world.
|
2007-05-31 18:02:53 +00:00
|
|
|
pDoc->GetCoreClientStatus(cc_status);
|
2006-03-29 06:53:21 +00:00
|
|
|
|
2006-08-11 17:58:48 +00:00
|
|
|
bIsOnline = (cc_status.network_status == NETWORK_STATUS_ONLINE);
|
|
|
|
bWantConnection = (cc_status.network_status == NETWORK_STATUS_WANT_CONNECTION);
|
|
|
|
bWantDisconnect = (cc_status.network_status == NETWORK_STATUS_WANT_DISCONNECT);
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
// The timers are used to keep from spamming the user with the same
|
|
|
|
// messages over each iteration of the poll loop. we only need to
|
|
|
|
// reset them during a connect event in case we randomly loose
|
|
|
|
// a connection.
|
|
|
|
if (m_bResetTimers) {
|
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - Resetting dial-up notification timers"));
|
|
|
|
|
|
|
|
m_bResetTimers = false;
|
2006-02-13 10:20:42 +00:00
|
|
|
m_bSetConnectionTimer = false;
|
2006-02-17 20:59:15 +00:00
|
|
|
ResetReminderTimers();
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
|
2006-02-09 23:55:40 +00:00
|
|
|
// Log out the trace information for debugging purposes.
|
2006-02-17 19:18:24 +00:00
|
|
|
/*
|
2006-02-09 23:55:40 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - Dialup Flags"));
|
|
|
|
wxLogTrace(wxT("Function Status"),
|
2006-02-10 00:19:55 +00:00
|
|
|
wxT("CBOINCDialUpManager::poll - -- bIsOnline = '%d', bIsDialing = '%d', m_bWasDialing = '%d', iNetworkStatus = '%d', bWantConnection = '%d'"),
|
|
|
|
bIsOnline, bIsDialing, m_bWasDialing, iNetworkStatus, bWantConnection
|
2006-02-09 23:55:40 +00:00
|
|
|
);
|
|
|
|
wxLogTrace(wxT("Function Status"),
|
|
|
|
wxT("CBOINCDialUpManager::poll - -- m_bResetTimers = '%d', m_bNotifyConnectionAvailable = '%d', m_bConnectedSuccessfully = '%d'"),
|
|
|
|
m_bResetTimers, m_bNotifyConnectionAvailable, m_bConnectedSuccessfully
|
|
|
|
);
|
|
|
|
wxLogTrace(wxT("Function Status"),
|
|
|
|
wxT("CBOINCDialUpManager::poll - -- confirm_before_connecting = '%d', hangup_if_dialed = '%d'"),
|
|
|
|
pDoc->state.global_prefs.confirm_before_connecting, pDoc->state.global_prefs.hangup_if_dialed
|
|
|
|
);
|
2006-02-17 19:18:24 +00:00
|
|
|
*/
|
2010-08-03 09:09:45 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-29 06:53:21 +00:00
|
|
|
bool bIsDialing = m_pDialupManager->IsDialing();
|
2006-09-18 05:29:33 +00:00
|
|
|
if (!bIsOnline && !bIsDialing && !m_bWasDialing && bWantConnection) {
|
2006-02-13 10:20:42 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - !bIsOnline && !bIsDialing && !m_bWasDialing && bWantConnection"));
|
2010-08-02 17:29:19 +00:00
|
|
|
if (pFrame->IsShown()) {
|
2006-02-09 21:51:07 +00:00
|
|
|
// BOINC Manager is visable and can process user input.
|
2006-02-13 10:20:42 +00:00
|
|
|
m_bSetConnectionTimer = true;
|
2006-02-09 21:51:07 +00:00
|
|
|
Connect();
|
|
|
|
}
|
|
|
|
} else if (!bIsDialing && !m_bWasDialing) {
|
2006-02-09 23:55:40 +00:00
|
|
|
// We are not doing anything now, were we up to something before?
|
2006-02-14 01:38:27 +00:00
|
|
|
if (bIsOnline && m_bConnectedSuccessfully && m_bNotifyConnectionAvailable) {
|
2006-02-09 23:55:40 +00:00
|
|
|
// Ah ha, we are online and we initiated the connection, so we need to
|
|
|
|
// notify the CC that the network is available.
|
2006-02-14 01:38:27 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - bIsOnline && m_bConnectedSuccessfully && m_bNotifyConnectionAvailable"));
|
2006-02-09 23:55:40 +00:00
|
|
|
NetworkAvailable();
|
2006-02-14 05:00:20 +00:00
|
|
|
} else if (bWantDisconnect && m_bConnectedSuccessfully) {
|
2006-02-09 23:55:40 +00:00
|
|
|
// We are online, and the CC says it is safe to disconnect. Since we
|
|
|
|
// initiated the connection we need to disconnect now.
|
2006-02-14 05:00:20 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - bWantDisconnect && m_bConnectedSuccessfully"));
|
2006-02-09 21:51:07 +00:00
|
|
|
Disconnect();
|
|
|
|
}
|
|
|
|
} else if (!bIsDialing && m_bWasDialing) {
|
2006-02-13 10:20:42 +00:00
|
|
|
// We initiated a connection attempt and now we are either online or failed to
|
|
|
|
// connect because of a modem error or a users credentials were wrong.
|
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - !bIsDialing && m_bWasDialing"));
|
|
|
|
|
|
|
|
if (m_bSetConnectionTimer) {
|
2006-02-14 00:30:18 +00:00
|
|
|
m_bSetConnectionTimer = false;
|
2006-02-13 10:20:42 +00:00
|
|
|
m_dtDialupConnectionTimeout = wxDateTime::Now();
|
|
|
|
m_iConnectAttemptRetVal = ERR_NO_NETWORK_CONNECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTimeSpan tsTimeout = wxDateTime::Now() - m_dtDialupConnectionTimeout;
|
|
|
|
if (30 > tsTimeout.GetSeconds()) {
|
|
|
|
if(m_iConnectAttemptRetVal != BOINC_SUCCESS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-09 21:51:07 +00:00
|
|
|
m_bWasDialing = false;
|
|
|
|
m_bResetTimers = true;
|
2006-02-13 10:20:42 +00:00
|
|
|
if (!m_iConnectAttemptRetVal) {
|
2006-02-09 21:51:07 +00:00
|
|
|
ConnectionSucceeded();
|
|
|
|
} else {
|
|
|
|
ConnectionFailed();
|
|
|
|
}
|
|
|
|
} else if (bIsDialing && !m_bWasDialing) {
|
2006-02-13 10:20:42 +00:00
|
|
|
// Setup the state machine so that it knows when we have finished the connection
|
|
|
|
// attempt.
|
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::poll - bIsDialing && !m_bWasDialing"));
|
2006-02-09 21:51:07 +00:00
|
|
|
m_bWasDialing = true;
|
|
|
|
}
|
2010-08-03 09:09:45 +00:00
|
|
|
#endif
|
2007-03-15 16:03:11 +00:00
|
|
|
bAlreadyRunningLoop = false;
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCDialUpManager::Connect() {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-02-09 21:51:07 +00:00
|
|
|
wxTimeSpan tsLastDialupRequest;
|
|
|
|
int iAnswer;
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
2007-08-02 08:11:29 +00:00
|
|
|
GLOBAL_PREFS_MASK mask;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-02-09 21:51:07 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
tsLastDialupRequest = wxDateTime::Now() - m_dtLastDialupRequest;
|
2011-03-03 16:32:35 +00:00
|
|
|
if ((tsLastDialupRequest.GetMinutes() >= (pFrame->GetReminderFrequency() * 60)) && (pFrame->GetReminderFrequency() != 0)) {
|
2006-02-13 10:20:42 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Connect - Begin connection process"));
|
2006-02-09 21:51:07 +00:00
|
|
|
m_dtLastDialupRequest = wxDateTime::Now();
|
|
|
|
|
2006-02-13 10:20:42 +00:00
|
|
|
if(pFrame->GetDialupConnectionName().size()) {
|
|
|
|
// We have a valid connection name that we can dial.
|
2007-08-02 08:11:29 +00:00
|
|
|
// Update current working preferences (including any overrides) from client
|
|
|
|
pDoc->rpc.get_global_prefs_working_struct(pDoc->state.global_prefs, mask);
|
2006-02-13 10:20:42 +00:00
|
|
|
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?"),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-13 10:20:42 +00:00
|
|
|
);
|
2008-08-20 16:07:06 +00:00
|
|
|
iAnswer = wxGetApp().SafeMessageBox(
|
2006-02-13 10:20:42 +00:00
|
|
|
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."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-13 10:20:42 +00:00
|
|
|
);
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_INFORMATION,
|
2006-02-13 10:20:42 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
iAnswer = wxYES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Are we allow to connect?
|
|
|
|
if (wxYES == iAnswer) {
|
2006-02-14 01:17:20 +00:00
|
|
|
m_bNotifyConnectionAvailable = true;
|
2006-02-13 10:20:42 +00:00
|
|
|
m_bConnectedSuccessfully = false;
|
|
|
|
m_pDialupManager->Dial(
|
|
|
|
pFrame->GetDialupConnectionName(),
|
|
|
|
wxEmptyString,
|
|
|
|
wxEmptyString,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2006-02-09 21:51:07 +00:00
|
|
|
} else {
|
2006-02-13 10:20:42 +00:00
|
|
|
// 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.
|
2006-02-09 21:51:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCDialUpManager::ConnectionSucceeded() {
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-02-09 21:51:07 +00:00
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
// %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
2006-02-13 10:20:42 +00:00
|
|
|
_("%s has successfully connected to the Internet."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_INFORMATION,
|
2006-02-09 21:51:07 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
m_bConnectedSuccessfully = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCDialUpManager::ConnectionFailed() {
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-02-09 21:51:07 +00:00
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
// %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
2006-02-13 10:20:42 +00:00
|
|
|
_("%s failed to connect to the Internet."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_ERROR,
|
2006-02-09 21:51:07 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
m_bConnectedSuccessfully = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-09 23:55:40 +00:00
|
|
|
int CBOINCDialUpManager::NetworkAvailable() {
|
2006-02-09 21:51:07 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-02-09 21:51:07 +00:00
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-02-09 21:51:07 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2006-02-09 21:51:07 +00:00
|
|
|
|
2006-02-13 10:20:42 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::NetworkAvailable - Connection Detected, notifing user of update to all projects"));
|
2006-02-09 23:55:40 +00:00
|
|
|
|
2006-02-14 01:17:20 +00:00
|
|
|
m_bNotifyConnectionAvailable = false;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
|
|
|
// 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(
|
2008-07-08 20:05:07 +00:00
|
|
|
_("%s has detected it is now connected to the Internet.\nUpdating all projects and retrying all transfers."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_INFORMATION,
|
2006-02-09 21:51:07 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
// Signal BOINC to update all projects and transfers.
|
|
|
|
pDoc->rpc.network_available();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCDialUpManager::Disconnect() {
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
|
2006-10-20 15:00:14 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2006-02-09 21:51:07 +00:00
|
|
|
wxString strDialogMessage = wxEmptyString;
|
2007-08-02 08:11:29 +00:00
|
|
|
GLOBAL_PREFS_MASK mask;
|
2006-02-09 21:51:07 +00:00
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(pFrame);
|
|
|
|
wxASSERT(pSkinAdvanced);
|
2006-02-09 21:51:07 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-06-23 08:20:08 +00:00
|
|
|
wxASSERT(wxDynamicCast(pFrame, CBOINCBaseFrame));
|
2006-10-20 15:00:14 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
2006-02-09 21:51:07 +00:00
|
|
|
|
2006-02-09 23:55:40 +00:00
|
|
|
|
2006-02-13 10:20:42 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Disconnect - Connection Detected, disconnect requested via the CC."));
|
2006-02-09 23:55:40 +00:00
|
|
|
|
2007-08-02 08:11:29 +00:00
|
|
|
// Update current working preferences (including any overrides) from client
|
|
|
|
pDoc->rpc.get_global_prefs_working_struct(pDoc->state.global_prefs, mask);
|
2006-02-09 21:51:07 +00:00
|
|
|
if (pDoc->state.global_prefs.hangup_if_dialed) {
|
2006-02-13 10:20:42 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCDialUpManager::Disconnect - Connection Detected, Don't need the network, Hanging up."));
|
2006-02-09 21:51:07 +00:00
|
|
|
if (m_pDialupManager->HangUp()) {
|
|
|
|
|
|
|
|
// %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
2006-02-13 10:20:42 +00:00
|
|
|
_("%s has successfully disconnected from the Internet."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_INFORMATION,
|
2006-02-09 21:51:07 +00:00
|
|
|
true
|
|
|
|
);
|
|
|
|
m_bConnectedSuccessfully = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// %s is the project name
|
|
|
|
// i.e. 'BOINC', 'GridRepublic'
|
|
|
|
strDialogMessage.Printf(
|
2006-02-13 10:20:42 +00:00
|
|
|
_("%s failed to disconnected from the Internet."),
|
2007-08-16 18:53:42 +00:00
|
|
|
pSkinAdvanced->GetApplicationShortName().c_str()
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
pFrame->ShowAlert(
|
|
|
|
m_strDialogTitle,
|
|
|
|
strDialogMessage,
|
2006-04-14 22:30:59 +00:00
|
|
|
wxOK | wxICON_ERROR
|
2006-02-09 21:51:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-17 20:59:15 +00:00
|
|
|
|
2006-02-17 23:10:39 +00:00
|
|
|
void CBOINCDialUpManager::ResetReminderTimers() {
|
2006-02-17 20:59:15 +00:00
|
|
|
m_dtLastDialupRequest = wxDateTime((time_t)0);
|
|
|
|
m_dtDialupConnectionTimeout = wxDateTime((time_t)0);
|
|
|
|
}
|
|
|
|
|