mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=7465
This commit is contained in:
parent
f7109138d1
commit
d546a29485
|
@ -10908,3 +10908,9 @@ Charlie 22 Aug 2005
|
|||
boinc.pbproj/
|
||||
project.pbxproj
|
||||
|
||||
Rom 23 Aug 2005
|
||||
- Do not allow the checks for need network to happen while the manager
|
||||
is attempting to connect to the CC.
|
||||
|
||||
clientgui/
|
||||
MainFrame.cpp
|
||||
|
|
|
@ -1410,229 +1410,231 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
|
|||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
static wxDateTime dtLastDialupIsAlreadyOnlineCheck = wxDateTime((time_t)0);
|
||||
static wxDateTime dtLastDialupAlertSent = wxDateTime((time_t)0);
|
||||
static wxDateTime dtLastDialupRequest = wxDateTime((time_t)0);
|
||||
static wxDateTime dtFirstDialupDisconnectEvent = wxDateTime((time_t)0);
|
||||
static bool already_notified_update_all_projects = false;
|
||||
static bool connected_successfully = false;
|
||||
static bool reset_timers = false;
|
||||
static bool was_dialing = false;
|
||||
static bool is_already_online = true;
|
||||
bool should_check_connection = false;
|
||||
bool is_dialing = false;
|
||||
bool is_online = false;
|
||||
int want_network = 0;
|
||||
int answer = 0;
|
||||
wxString strConnectionName = wxEmptyString;
|
||||
wxString strConnectionUsername = wxEmptyString;
|
||||
wxString strConnectionPassword = wxEmptyString;
|
||||
wxString strBuffer = wxEmptyString;
|
||||
wxTimeSpan tsLastDialupIsAlreadyOnlineCheck;
|
||||
wxTimeSpan tsLastDialupAlertSent;
|
||||
wxTimeSpan tsLastDialupRequest;
|
||||
wxTimeSpan tsFirstDialupDisconnectEvent;
|
||||
if (pDoc->IsConnected()) {
|
||||
static wxDateTime dtLastDialupIsAlreadyOnlineCheck = wxDateTime((time_t)0);
|
||||
static wxDateTime dtLastDialupAlertSent = wxDateTime((time_t)0);
|
||||
static wxDateTime dtLastDialupRequest = wxDateTime((time_t)0);
|
||||
static wxDateTime dtFirstDialupDisconnectEvent = wxDateTime((time_t)0);
|
||||
static bool already_notified_update_all_projects = false;
|
||||
static bool connected_successfully = false;
|
||||
static bool reset_timers = false;
|
||||
static bool was_dialing = false;
|
||||
static bool is_already_online = true;
|
||||
bool should_check_connection = false;
|
||||
bool is_dialing = false;
|
||||
bool is_online = false;
|
||||
int want_network = 0;
|
||||
int answer = 0;
|
||||
wxString strConnectionName = wxEmptyString;
|
||||
wxString strConnectionUsername = wxEmptyString;
|
||||
wxString strConnectionPassword = wxEmptyString;
|
||||
wxString strBuffer = wxEmptyString;
|
||||
wxTimeSpan tsLastDialupIsAlreadyOnlineCheck;
|
||||
wxTimeSpan tsLastDialupAlertSent;
|
||||
wxTimeSpan tsLastDialupRequest;
|
||||
wxTimeSpan tsFirstDialupDisconnectEvent;
|
||||
|
||||
wxASSERT(m_pDialupManager->IsOk());
|
||||
if (m_pDialupManager && pDoc) {
|
||||
// Update the always online flag every 60 seconds. This call is expensive
|
||||
// on slow machines.
|
||||
tsLastDialupIsAlreadyOnlineCheck = wxDateTime::Now() - dtLastDialupIsAlreadyOnlineCheck;
|
||||
if (tsLastDialupIsAlreadyOnlineCheck.GetSeconds() > 60) {
|
||||
dtLastDialupIsAlreadyOnlineCheck = wxDateTime::Now();
|
||||
is_already_online = m_pDialupManager->IsAlwaysOnline();
|
||||
}
|
||||
|
||||
// Are we configured to detect a network or told one already exists?
|
||||
if (ID_NETWORKLAN != m_iNetworkConnectionType) {
|
||||
if (ID_NETWORKDIALUP == m_iNetworkConnectionType) {
|
||||
should_check_connection = true;
|
||||
wxASSERT(m_pDialupManager->IsOk());
|
||||
if (m_pDialupManager && pDoc) {
|
||||
// Update the always online flag every 60 seconds. This call is expensive
|
||||
// on slow machines.
|
||||
tsLastDialupIsAlreadyOnlineCheck = wxDateTime::Now() - dtLastDialupIsAlreadyOnlineCheck;
|
||||
if (tsLastDialupIsAlreadyOnlineCheck.GetSeconds() > 60) {
|
||||
dtLastDialupIsAlreadyOnlineCheck = wxDateTime::Now();
|
||||
is_already_online = m_pDialupManager->IsAlwaysOnline();
|
||||
}
|
||||
if (ID_NETWORKAUTODETECT == m_iNetworkConnectionType) {
|
||||
if (!is_already_online) {
|
||||
|
||||
// Are we configured to detect a network or told one already exists?
|
||||
if (ID_NETWORKLAN != m_iNetworkConnectionType) {
|
||||
if (ID_NETWORKDIALUP == m_iNetworkConnectionType) {
|
||||
should_check_connection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (should_check_connection) {
|
||||
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
||||
|
||||
// cache the various states
|
||||
is_dialing = m_pDialupManager->IsDialing();
|
||||
is_online = m_pDialupManager->IsOnline();
|
||||
pDoc->rpc.network_query(want_network);
|
||||
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Dialup Flags"));
|
||||
wxLogTrace(wxT("Function Status"),
|
||||
wxT("CMainFrame::OnFrameRender - -- is_online = '%d', is_dialing = '%d', was_dialing = '%d', want_network = '%d'"),
|
||||
is_online, is_dialing, was_dialing, want_network
|
||||
);
|
||||
wxLogTrace(wxT("Function Status"),
|
||||
wxT("CMainFrame::OnFrameRender - -- reset_timers = '%d', already_notified_update_all_projects = '%d', connected_successfully = '%d'"),
|
||||
reset_timers, already_notified_update_all_projects, connected_successfully
|
||||
);
|
||||
|
||||
// If we have received any connection event, then we should reset the
|
||||
// dtLastDialupAlertSent and dtLastDialupRequest variables
|
||||
// so that if we are disconnected without completing the user will
|
||||
// be notifed in a prompt fashion.
|
||||
if (reset_timers) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Resetting dial-up notification timers"));
|
||||
|
||||
reset_timers = false;
|
||||
dtLastDialupAlertSent = wxDateTime((time_t)0);
|
||||
dtLastDialupRequest = wxDateTime((time_t)0);
|
||||
}
|
||||
|
||||
if (!is_online && !is_dialing && !was_dialing && want_network)
|
||||
{
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Internet connection needed"));
|
||||
if (!IsShown()) {
|
||||
// BOINC Manager is hidden and displaying a dialog might interupt what they
|
||||
// are doing.
|
||||
tsLastDialupAlertSent = wxDateTime::Now() - dtLastDialupAlertSent;
|
||||
if (tsLastDialupAlertSent.GetSeconds() >= (m_iReminderFrequency * 60)) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Manager not shown, notify instead"));
|
||||
|
||||
dtLastDialupAlertSent = wxDateTime::Now();
|
||||
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC needs a connection to the Internet to perform some maintenance, open the BOINC Manager to connect up and perform the needed work."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
if (ID_NETWORKAUTODETECT == m_iNetworkConnectionType) {
|
||||
if (!is_already_online) {
|
||||
should_check_connection = true;
|
||||
}
|
||||
} else {
|
||||
// BOINC Manager is visable and can process user input.
|
||||
tsLastDialupRequest = wxDateTime::Now() - dtLastDialupRequest;
|
||||
if (tsLastDialupRequest.GetSeconds() >= (m_iReminderFrequency * 60)) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Begin connection process"));
|
||||
}
|
||||
}
|
||||
|
||||
dtLastDialupRequest = wxDateTime::Now();
|
||||
if (should_check_connection) {
|
||||
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
||||
|
||||
// cache the various states
|
||||
is_dialing = m_pDialupManager->IsDialing();
|
||||
is_online = m_pDialupManager->IsOnline();
|
||||
pDoc->rpc.network_query(want_network);
|
||||
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Dialup Flags"));
|
||||
wxLogTrace(wxT("Function Status"),
|
||||
wxT("CMainFrame::OnFrameRender - -- is_online = '%d', is_dialing = '%d', was_dialing = '%d', want_network = '%d'"),
|
||||
is_online, is_dialing, was_dialing, want_network
|
||||
);
|
||||
wxLogTrace(wxT("Function Status"),
|
||||
wxT("CMainFrame::OnFrameRender - -- reset_timers = '%d', already_notified_update_all_projects = '%d', connected_successfully = '%d'"),
|
||||
reset_timers, already_notified_update_all_projects, connected_successfully
|
||||
);
|
||||
|
||||
// If we have received any connection event, then we should reset the
|
||||
// dtLastDialupAlertSent and dtLastDialupRequest variables
|
||||
// so that if we are disconnected without completing the user will
|
||||
// be notifed in a prompt fashion.
|
||||
if (reset_timers) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Resetting dial-up notification timers"));
|
||||
|
||||
reset_timers = false;
|
||||
dtLastDialupAlertSent = wxDateTime((time_t)0);
|
||||
dtLastDialupRequest = wxDateTime((time_t)0);
|
||||
}
|
||||
|
||||
if (!is_online && !is_dialing && !was_dialing && want_network)
|
||||
{
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Internet connection needed"));
|
||||
if (!IsShown()) {
|
||||
// BOINC Manager is hidden and displaying a dialog might interupt what they
|
||||
// are doing.
|
||||
tsLastDialupAlertSent = wxDateTime::Now() - dtLastDialupAlertSent;
|
||||
if (tsLastDialupAlertSent.GetSeconds() >= (m_iReminderFrequency * 60)) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Manager not shown, notify instead"));
|
||||
|
||||
dtLastDialupAlertSent = wxDateTime::Now();
|
||||
|
||||
if(pDoc->state.global_prefs.confirm_before_connecting) {
|
||||
answer = ::wxMessageBox(
|
||||
_("BOINC needs to connect to the network.\nMay it do so now?"),
|
||||
_("BOINC Manager - Network Status"),
|
||||
wxYES_NO | wxICON_QUESTION,
|
||||
this
|
||||
);
|
||||
} else {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC is connecting to the internet."),
|
||||
_("BOINC needs a connection to the Internet to perform some maintenance, open the BOINC Manager to connect up and perform the needed work."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
answer = wxYES;
|
||||
}
|
||||
} else {
|
||||
// BOINC Manager is visable and can process user input.
|
||||
tsLastDialupRequest = wxDateTime::Now() - dtLastDialupRequest;
|
||||
if (tsLastDialupRequest.GetSeconds() >= (m_iReminderFrequency * 60)) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Begin connection process"));
|
||||
|
||||
// Are we allow to connect?
|
||||
if (wxYES == answer) {
|
||||
if (m_strNetworkDialupConnectionName.size())
|
||||
strConnectionName = m_strNetworkDialupConnectionName;
|
||||
dtLastDialupRequest = wxDateTime::Now();
|
||||
|
||||
if (m_bNetworkDialupPromptCredentials) {
|
||||
CDlgDialupCredentials* pDlgDialupCredentials = new CDlgDialupCredentials(this);
|
||||
|
||||
answer = pDlgDialupCredentials->ShowModal();
|
||||
if (wxID_OK == answer) {
|
||||
strConnectionUsername = pDlgDialupCredentials->GetUsername();
|
||||
strConnectionPassword = pDlgDialupCredentials->GetPassword();
|
||||
}
|
||||
|
||||
if (pDlgDialupCredentials) {
|
||||
pDlgDialupCredentials->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
already_notified_update_all_projects = false;
|
||||
connected_successfully = false;
|
||||
m_pDialupManager->Dial(strConnectionName, strConnectionUsername, strConnectionPassword, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!is_dialing && !was_dialing) {
|
||||
if (is_online && want_network && connected_successfully && !already_notified_update_all_projects) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, notifing user of update to all projects"));
|
||||
|
||||
already_notified_update_all_projects = true;
|
||||
|
||||
// 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
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has detected it is now connected to the internet. Updating all projects and retrying all transfers."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
|
||||
// Sleep for a couple of seconds to let the network interface finish
|
||||
// initializing.
|
||||
::wxSleep(2);
|
||||
|
||||
// Signal BOINC to update all projects and transfers.
|
||||
pDoc->rpc.network_available();
|
||||
|
||||
} else if (is_online && !want_network && connected_successfully) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, Don't need the network, We successfully connected."));
|
||||
|
||||
// Should we disconnect now? The first time we see the disconnect event
|
||||
// we should ignore it and wait for 5 seconds to see if it is really
|
||||
// safe to disconnect.
|
||||
if (wxDateTime((time_t)0) == dtFirstDialupDisconnectEvent) {
|
||||
dtFirstDialupDisconnectEvent = wxDateTime::Now();
|
||||
}
|
||||
tsFirstDialupDisconnectEvent = wxDateTime::Now() - dtFirstDialupDisconnectEvent;
|
||||
if (tsFirstDialupDisconnectEvent.GetSeconds() >= 5) {
|
||||
if (pDoc->state.global_prefs.hangup_if_dialed) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, Don't need the network, Hanging up."));
|
||||
if (m_pDialupManager->HangUp()) {
|
||||
ShowAlert(
|
||||
if(pDoc->state.global_prefs.confirm_before_connecting) {
|
||||
answer = ::wxMessageBox(
|
||||
_("BOINC needs to connect to the network.\nMay it do so now?"),
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has successfully disconnected from the internet."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
wxYES_NO | wxICON_QUESTION,
|
||||
this
|
||||
);
|
||||
|
||||
connected_successfully = false;
|
||||
} else {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC failed to disconnected from the internet."),
|
||||
wxICON_ERROR
|
||||
_("BOINC is connecting to the internet."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
answer = wxYES;
|
||||
}
|
||||
|
||||
// Are we allow to connect?
|
||||
if (wxYES == answer) {
|
||||
if (m_strNetworkDialupConnectionName.size())
|
||||
strConnectionName = m_strNetworkDialupConnectionName;
|
||||
|
||||
if (m_bNetworkDialupPromptCredentials) {
|
||||
CDlgDialupCredentials* pDlgDialupCredentials = new CDlgDialupCredentials(this);
|
||||
|
||||
answer = pDlgDialupCredentials->ShowModal();
|
||||
if (wxID_OK == answer) {
|
||||
strConnectionUsername = pDlgDialupCredentials->GetUsername();
|
||||
strConnectionPassword = pDlgDialupCredentials->GetPassword();
|
||||
}
|
||||
|
||||
if (pDlgDialupCredentials) {
|
||||
pDlgDialupCredentials->Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
already_notified_update_all_projects = false;
|
||||
connected_successfully = false;
|
||||
m_pDialupManager->Dial(strConnectionName, strConnectionUsername, strConnectionPassword, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!is_dialing && !was_dialing) {
|
||||
if (is_online && want_network && connected_successfully && !already_notified_update_all_projects) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, notifing user of update to all projects"));
|
||||
|
||||
already_notified_update_all_projects = true;
|
||||
|
||||
// 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
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has detected it is now connected to the internet. Updating all projects and retrying all transfers."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
|
||||
// Sleep for a couple of seconds to let the network interface finish
|
||||
// initializing.
|
||||
::wxSleep(2);
|
||||
|
||||
// Signal BOINC to update all projects and transfers.
|
||||
pDoc->rpc.network_available();
|
||||
|
||||
} else if (is_online && !want_network && connected_successfully) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, Don't need the network, We successfully connected."));
|
||||
|
||||
// Should we disconnect now? The first time we see the disconnect event
|
||||
// we should ignore it and wait for 5 seconds to see if it is really
|
||||
// safe to disconnect.
|
||||
if (wxDateTime((time_t)0) == dtFirstDialupDisconnectEvent) {
|
||||
dtFirstDialupDisconnectEvent = wxDateTime::Now();
|
||||
}
|
||||
tsFirstDialupDisconnectEvent = wxDateTime::Now() - dtFirstDialupDisconnectEvent;
|
||||
if (tsFirstDialupDisconnectEvent.GetSeconds() >= 5) {
|
||||
if (pDoc->state.global_prefs.hangup_if_dialed) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - Connection Detected, Don't need the network, Hanging up."));
|
||||
if (m_pDialupManager->HangUp()) {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has successfully disconnected from the internet."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
|
||||
connected_successfully = false;
|
||||
} else {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC failed to disconnected from the internet."),
|
||||
wxICON_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!is_dialing && was_dialing) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - We were dialing and now we are not, detect success or failure of the connection."));
|
||||
was_dialing = false;
|
||||
reset_timers = true;
|
||||
if (is_online) {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has successfully connected to the internet."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
connected_successfully = true;
|
||||
} else {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC failed to connect to the internet."),
|
||||
wxICON_ERROR,
|
||||
true
|
||||
);
|
||||
connected_successfully = false;
|
||||
}
|
||||
} else if (is_dialing && !was_dialing) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - We are now dialing, where before we were not."));
|
||||
was_dialing = true;
|
||||
}
|
||||
} else if (!is_dialing && was_dialing) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - We were dialing and now we are not, detect success or failure of the connection."));
|
||||
was_dialing = false;
|
||||
reset_timers = true;
|
||||
if (is_online) {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC has successfully connected to the internet."),
|
||||
wxICON_INFORMATION,
|
||||
true
|
||||
);
|
||||
connected_successfully = true;
|
||||
} else {
|
||||
ShowAlert(
|
||||
_("BOINC Manager - Network Status"),
|
||||
_("BOINC failed to connect to the internet."),
|
||||
wxICON_ERROR,
|
||||
true
|
||||
);
|
||||
connected_successfully = false;
|
||||
}
|
||||
} else if (is_dialing && !was_dialing) {
|
||||
wxLogTrace(wxT("Function Status"), wxT("CMainFrame::OnFrameRender - We are now dialing, where before we were not."));
|
||||
was_dialing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue