*** empty log message ***

svn path=/trunk/boinc/; revision=5799
This commit is contained in:
Rom Walton 2005-04-08 04:23:37 +00:00
parent 1c4a881fe1
commit 59614e090e
7 changed files with 451 additions and 264 deletions

View File

@ -26847,3 +26847,19 @@ David 7 April 2005
user/
host_edit_form.php
show_user.php
Rom 7 April 2005
- Switch the connection errors and connection initialization routines
from a polling style routines to an event style, this fixes the
issues of the attach to project dialog being displayed at odd
times.
- Warn the user of connection failures to a new host.
- Deal with various odd issues that cropped up due to the connection
thread being introduced to the system.
clientgui/
BOINCGUIApp.cpp
MainDocument.cpp, .h
MainFrame.cpp, .h
lib/
gui_rpc_client.C

View File

@ -305,8 +305,8 @@ void CBOINCGUIApp::InitSupportedLanguages() {
bool CBOINCGUIApp::IsBOINCCoreRunning() {
wxString strMachineName = wxT("localhost");
return (0 == m_pDocument->Connect(strMachineName, FALSE));
RPC_CLIENT rpc;
return (0 == rpc.init( wxT("localhost") ) );
}
@ -436,7 +436,6 @@ void CBOINCGUIApp::ShutdownBOINCCore() {
// The user may have gone off to look at another machine on the network, and
// we don't want to leave any dangling processes if we started them up.
m_pDocument->Connect(strMachineName);
if (GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
if (STILL_ACTIVE == dwExitCode) {
m_pDocument->CoreClientQuit();
@ -463,8 +462,12 @@ void CBOINCGUIApp::ShutdownBOINCCore() {
void CBOINCGUIApp::ShutdownBOINCCore() {
wxInt32 iCount = 0;
bool bClientQuit = false;
wxString strMachineName = wxT("localhost");
if (m_bBOINCStartedByManager) {
// The user may have gone off to look at another machine on the network, and
// we don't want to leave any dangling processes if we started them up.
m_pDocument->Connect(strMachineName);
if (wxProcess::Exists(m_lBOINCCoreProcessId)) {
m_pDocument->CoreClientQuit();
for (iCount = 0; iCount <= 10; iCount++) {

View File

@ -30,6 +30,31 @@
CNetworkConnectionThread::CNetworkConnectionThread(CMainDocument* pDocument) :
wxThread(wxTHREAD_JOINABLE) {
m_pDocument = pDocument;
m_strConnectedComputerName = wxEmptyString;
m_strConnectedComputerPassword = wxEmptyString;
m_strNewComputerName = wxEmptyString;
m_strNewComputerPassword = wxEmptyString;
m_bConnectEvent = false;
m_bConnected = false;
m_bReconnecting = false;
m_bForceReconnect = false;
m_bReconnectOnError = false;
}
CNetworkConnectionThread::~CNetworkConnectionThread() {
m_bReconnectOnError = false;
m_bForceReconnect = false;
m_bReconnecting = false;
m_bConnected = false;
m_bConnectEvent = false;
m_strNewComputerPassword = wxEmptyString;
m_strNewComputerName = wxEmptyString;
m_strConnectedComputerPassword = wxEmptyString;
m_strConnectedComputerName = wxEmptyString;
m_pDocument = NULL;
}
@ -39,80 +64,122 @@ void* CNetworkConnectionThread::Entry() {
std::string strComputerPassword;
while (!TestDestroy()) {
if (m_pDocument->m_bNCTConnectEvent) {
if (m_pDocument->IsConnected() && m_pDocument->m_bNCTNewShouldReconnect) {
m_pDocument->rpc.close();
m_pDocument->state.clear();
m_pDocument->host.clear();
m_pDocument->project_status.clear();
m_pDocument->results.clear();
m_pDocument->messages.clear();
m_pDocument->ft.clear();
m_pDocument->resource_status.clear();
m_pDocument->proxy_info.clear();
m_pDocument->m_dtCachedStateLockTimestamp = wxDateTime::Now();
m_pDocument->m_dtCachedStateTimestamp = wxDateTime((time_t)0);
m_pDocument->m_iMessageSequenceNumber = 0;
m_pDocument->m_bIsConnected = false;
m_pDocument->m_bIsReconnecting = true;
if (IsConnectEventSignaled() || m_bReconnectOnError ) {
if ( ( IsConnected() && m_bForceReconnect ) ||
( !IsConnected() && m_bReconnectOnError )
) {
m_pDocument->ResetState();
SetStateReconnecting();
}
if (m_pDocument->IsConnected())
return BOINC_SUCCESS;
if (!IsConnected()) {
// determine computer name and password to use.
if (!m_strNewComputerName.empty()) {
strComputer = m_strNewComputerName;
strComputerPassword = m_strNewComputerPassword;
} else {
if (!m_strConnectedComputerName.empty()) {
strComputer = m_strConnectedComputerName.c_str();
strComputerPassword = m_strConnectedComputerPassword.c_str();
}
}
if (strComputer.empty()) {
iRetVal = m_pDocument->rpc.init(NULL);
} else {
iRetVal = m_pDocument->rpc.init(strComputer.c_str());
}
if (!m_pDocument->m_strNCTNewConnectedComputerName.empty())
strComputer = m_pDocument->m_strNCTNewConnectedComputerName;
else
if (!m_pDocument->m_strConnectedComputerName.empty())
strComputer = m_pDocument->m_strConnectedComputerName.c_str();
if (0 == iRetVal) {
if (!strComputerPassword.empty()) {
iRetVal = m_pDocument->rpc.authorize(strComputerPassword.c_str());
}
if (!m_pDocument->m_strNCTNewConnectedComputerPassword.empty())
strComputerPassword = m_pDocument->m_strNCTNewConnectedComputerPassword;
else
if (!m_pDocument->m_strConnectedComputerPassword.empty())
strComputerPassword = m_pDocument->m_strConnectedComputerPassword.c_str();
if (strComputer.empty())
iRetVal = m_pDocument->rpc.init(NULL);
else
iRetVal = m_pDocument->rpc.init(strComputer.c_str());
if (iRetVal) {
wxLogTrace("CMainDocument::Connect - RPC Initialization Failed '%d'", iRetVal);
}
if (!strComputerPassword.empty())
iRetVal = m_pDocument->rpc.authorize(strComputerPassword.c_str());
if (iRetVal) {
wxLogTrace("CMainDocument::Connect - RPC Authorization Failed '%d'", iRetVal);
}
if (0 == iRetVal) {
m_pDocument->m_bIsConnected = true;
m_pDocument->m_bIsReconnecting = false;
m_pDocument->m_strConnectedComputerName = strComputer.c_str();
m_pDocument->m_strConnectedComputerPassword = strComputerPassword.c_str();
m_pDocument->m_bNCTNewShouldReconnect = false;
m_pDocument->m_strNCTNewConnectedComputerName = wxEmptyString;
m_pDocument->m_strNCTNewConnectedComputerPassword = wxEmptyString;
m_pDocument->m_bNCTConnectEvent = false;
if (0 == iRetVal) {
wxLogTrace("CNetworkConnectionThread::Entry - Connection Success");
SetStateSuccess( strComputer, strComputerPassword );
} else {
wxLogTrace("CNetworkConnectionThread::Entry - RPC Authorization Failed '%d'", iRetVal);
SetStateError();
}
} else {
wxLogTrace("CNetworkConnectionThread::Entry - RPC Initialization Failed '%d'", iRetVal);
SetStateError();
}
}
}
Sleep(1000);
Sleep(250);
}
return NULL;
}
wxInt32 CNetworkConnectionThread::GetConnectedComputerName( wxString& strMachine ) {
strMachine = m_strConnectedComputerName;
return 0;
}
wxInt32 CNetworkConnectionThread::GetConnectingComputerName( wxString& strMachine ) {
strMachine = m_strNewComputerName;
return 0;
}
wxInt32 CNetworkConnectionThread::SetNewComputerName( const wxChar* szComputer ) {
m_strNewComputerName = szComputer;
return 0;
}
wxInt32 CNetworkConnectionThread::SetNewComputerPassword( const wxChar* szPassword ) {
m_strNewComputerPassword = szPassword;
return 0;
}
void CNetworkConnectionThread::SetStateError() {
CMainFrame* pFrame = wxGetApp().GetFrame();
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
m_bConnected = false;
m_bReconnecting = false;
m_bReconnectOnError = false;
m_bConnectEvent = false;
pFrame->FireConnectError();
}
void CNetworkConnectionThread::SetStateReconnecting() {
m_bConnected = false;
m_bReconnectOnError = false;
m_bForceReconnect = false;
m_bReconnecting = true;
}
void CNetworkConnectionThread::SetStateSuccess( std::string& strComputer, std::string& strComputerPassword ) {
CMainFrame* pFrame = wxGetApp().GetFrame();
wxASSERT(wxDynamicCast(pFrame, CMainFrame));
m_bConnected = true;
m_bReconnecting = false;
m_bReconnectOnError = true;
m_strConnectedComputerName = strComputer.c_str();
m_strConnectedComputerPassword = strComputerPassword.c_str();
m_strNewComputerName = wxEmptyString;
m_strNewComputerPassword = wxEmptyString;
m_bConnectEvent = false;
pFrame->FireConnect();
}
IMPLEMENT_DYNAMIC_CLASS(CMainDocument, wxObject)
@ -127,11 +194,6 @@ CMainDocument::CMainDocument() {
}
#endif
m_bIsConnected = false;
m_bIsReconnecting = false;
m_strConnectedComputerName = wxEmptyString;
m_strConnectedComputerPassword = wxEmptyString;
m_iCachedActivityRunMode = 0;
m_iCachedNetworkRunMode = 0;
@ -163,11 +225,6 @@ CMainDocument::~CMainDocument() {
m_iCachedActivityRunMode = 0;
m_iCachedNetworkRunMode = 0;
m_strConnectedComputerPassword = wxEmptyString;
m_strConnectedComputerName = wxEmptyString;
m_bIsConnected = false;
m_bIsReconnecting = false;
#ifdef __WIN32__
WSACleanup();
#endif
@ -178,14 +235,13 @@ wxInt32 CMainDocument::CachedStateUpdate() {
wxInt32 retval = 0;
wxTimeSpan ts(m_dtCachedStateLockTimestamp - m_dtCachedStateTimestamp);
if (!m_bCachedStateLocked && (ts.GetSeconds() > 3600)) {
if (!m_bCachedStateLocked && IsConnected() && (ts.GetSeconds() > 3600) ) {
wxLogStatus(_("Retrieving system state; please wait..."));
m_dtCachedStateTimestamp = m_dtCachedStateLockTimestamp;
retval = rpc.get_state(state);
if (retval) {
wxLogTrace("CMainDocument::CachedStateUpdate - Get State Failed '%d'", retval);
Connect(wxEmptyString);
}
wxLogStatus(_("Retrieving host information; please wait..."));
@ -193,7 +249,6 @@ wxInt32 CMainDocument::CachedStateUpdate() {
retval = rpc.get_host_info(host);
if (retval) {
wxLogTrace("CMainDocument::CachedStateUpdate - Get Host Information Failed '%d'", retval);
Connect(wxEmptyString);
}
wxLogStatus(wxEmptyString);
@ -223,11 +278,6 @@ wxInt32 CMainDocument::OnInit() {
m_pNetworkConnectionThread->Run();
// provide the default connection information
if (!IsConnected())
iRetVal = Connect(wxEmptyString);
return iRetVal;
}
@ -256,35 +306,58 @@ wxInt32 CMainDocument::OnRefreshState() {
}
wxInt32 CMainDocument::Connect(const wxChar* szComputer, const wxChar* szComputerPassword, bool bDisconnect) {
m_bNCTNewShouldReconnect = bDisconnect;
m_strNCTNewConnectedComputerName = szComputer;
m_strNCTNewConnectedComputerPassword = szComputerPassword;
wxInt32 CMainDocument::ResetState() {
rpc.close();
state.clear();
host.clear();
project_status.clear();
results.clear();
messages.clear();
ft.clear();
resource_status.clear();
proxy_info.clear();
m_dtCachedStateLockTimestamp = wxDateTime::Now();
m_dtCachedStateTimestamp = wxDateTime((time_t)0);
m_bNCTConnectEvent = true;
m_iMessageSequenceNumber = 0;
return 0;
}
wxInt32 CMainDocument::Connect(const wxChar* szComputer, const wxChar* szComputerPassword, bool bDisconnect) {
if ( bDisconnect ) {
m_pNetworkConnectionThread->ForceReconnect();
}
m_pNetworkConnectionThread->SetNewComputerName( szComputer );
m_pNetworkConnectionThread->SetNewComputerPassword( szComputerPassword );
m_pNetworkConnectionThread->FireReconnectEvent();
return 0;
}
wxInt32 CMainDocument::GetConnectedComputerName(wxString& strMachine) {
strMachine = m_strConnectedComputerName;
m_pNetworkConnectionThread->GetConnectedComputerName( strMachine );
return 0;
}
wxInt32 CMainDocument::GetConnectingComputerName(wxString& strMachine) {
strMachine = m_strNCTNewConnectedComputerName;
m_pNetworkConnectionThread->GetConnectingComputerName( strMachine );
return 0;
}
bool CMainDocument::IsConnected() {
return m_bIsConnected;
return m_pNetworkConnectionThread->IsConnected();
}
bool CMainDocument::IsReconnecting() {
return m_bIsReconnecting;
return m_pNetworkConnectionThread->IsReconnecting();
}
@ -419,15 +492,16 @@ wxInt32 CMainDocument::CachedProjectStatusUpdate() {
wxInt32 iRetVal = 0;
wxInt32 i = 0;
iRetVal = rpc.get_project_status(project_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedProjectStatusUpdate - Get Project Status Failed '%d'", iRetVal);
Connect(wxEmptyString);
}
if ( IsConnected() ) {
iRetVal = rpc.get_project_status(project_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedProjectStatusUpdate - Get Project Status Failed '%d'", iRetVal);
}
m_fProjectTotalResourceShare = 0.0;
for (i=0; i < (long)project_status.projects.size(); i++) {
m_fProjectTotalResourceShare += project_status.projects.at(i)->resource_share;
m_fProjectTotalResourceShare = 0.0;
for (i=0; i < (long)project_status.projects.size(); i++) {
m_fProjectTotalResourceShare += project_status.projects.at(i)->resource_share;
}
}
return iRetVal;
@ -435,7 +509,7 @@ wxInt32 CMainDocument::CachedProjectStatusUpdate() {
wxInt32 CMainDocument::GetProjectCount() {
wxInt32 iCount = 0;
wxInt32 iCount = -1;
CachedStateUpdate();
CachedProjectStatusUpdate();
@ -847,10 +921,11 @@ wxInt32 CMainDocument::ProjectResume(wxInt32 iIndex) {
wxInt32 CMainDocument::CachedResultsStatusUpdate() {
wxInt32 iRetVal = 0;
iRetVal = rpc.get_results(results);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedResultsStatusUpdate - Get Result Status Failed '%d'", iRetVal);
Connect(wxEmptyString);
if ( IsConnected() ) {
iRetVal = rpc.get_results(results);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedResultsStatusUpdate - Get Result Status Failed '%d'", iRetVal);
}
}
return iRetVal;
@ -858,7 +933,7 @@ wxInt32 CMainDocument::CachedResultsStatusUpdate() {
wxInt32 CMainDocument::GetWorkCount() {
wxInt32 iCount = 0;
wxInt32 iCount = -1;
CachedStateUpdate();
CachedResultsStatusUpdate();
@ -1365,21 +1440,22 @@ wxInt32 CMainDocument::WorkAbort(wxInt32 iIndex) {
wxInt32 CMainDocument::CachedMessageUpdate() {
wxInt32 iRetVal = 0;
iRetVal = rpc.get_messages(m_iMessageSequenceNumber, messages);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedMessageUpdate - Get Messages Failed '%d'", iRetVal);
Connect(wxEmptyString);
}
if ( IsConnected() ) {
iRetVal = rpc.get_messages(m_iMessageSequenceNumber, messages);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedMessageUpdate - Get Messages Failed '%d'", iRetVal);
}
if (messages.messages.size() != 0)
m_iMessageSequenceNumber = messages.messages.at(messages.messages.size()-1)->seqno;
if (messages.messages.size() != 0)
m_iMessageSequenceNumber = messages.messages.at(messages.messages.size()-1)->seqno;
}
return iRetVal;
}
wxInt32 CMainDocument::GetMessageCount() {
wxInt32 iCount = 0;
wxInt32 iCount = -1;
CachedStateUpdate();
CachedMessageUpdate();
@ -1473,12 +1549,12 @@ wxInt32 CMainDocument::ResetMessageState() {
wxInt32 CMainDocument::CachedFileTransfersUpdate() {
wxInt32 iRetVal = 0;
wxString strEmpty = wxEmptyString;
iRetVal = rpc.get_file_transfers(ft);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedFileTransfersUpdate - Get File Transfers Failed '%d'", iRetVal);
Connect(strEmpty);
if ( IsConnected() ) {
iRetVal = rpc.get_file_transfers(ft);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedFileTransfersUpdate - Get File Transfers Failed '%d'", iRetVal);
}
}
return iRetVal;
@ -1721,10 +1797,11 @@ wxInt32 CMainDocument::TransferAbort(wxInt32 iIndex) {
wxInt32 CMainDocument::CachedResourceStatusUpdate() {
wxInt32 iRetVal = 0;
iRetVal = rpc.get_disk_usage(resource_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedResourceStatusUpdate - Get Disk Usage Failed '%d'", iRetVal);
Connect(wxEmptyString);
if ( IsConnected() ) {
iRetVal = rpc.get_disk_usage(resource_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedResourceStatusUpdate - Get Disk Usage Failed '%d'", iRetVal);
}
}
return iRetVal;
@ -1732,7 +1809,7 @@ wxInt32 CMainDocument::CachedResourceStatusUpdate() {
wxInt32 CMainDocument::GetResourceCount() {
wxInt32 iCount = 0;
wxInt32 iCount = -1;
CachedStateUpdate();
CachedResourceStatusUpdate();
@ -1791,10 +1868,11 @@ wxInt32 CMainDocument::CachedStatisticsStatusUpdate() {
wxInt32 iRetVal = 0;
wxString strEmpty = wxEmptyString;
iRetVal = rpc.get_statistics(statistics_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedStatisticsStatusUpdate - Get Statistics Failed '%d'", iRetVal);
Connect(strEmpty);
if ( IsConnected() ) {
iRetVal = rpc.get_statistics(statistics_status);
if (iRetVal) {
wxLogTrace("CMainDocument::CachedStatisticsStatusUpdate - Get Statistics Failed '%d'", iRetVal);
}
}
return iRetVal;
@ -1802,7 +1880,7 @@ wxInt32 CMainDocument::CachedStatisticsStatusUpdate() {
wxInt32 CMainDocument::GetStatisticsCount() {
wxInt32 iCount = 0;
wxInt32 iCount = -1;
CachedStateUpdate();
CachedStatisticsStatusUpdate();
@ -1846,7 +1924,6 @@ wxInt32 CMainDocument::GetProxyConfiguration() {
iRetVal = rpc.get_proxy_settings(proxy_info);
if (iRetVal) {
wxLogTrace("CMainDocument::GetProxyInfo - Get Proxy Info Failed '%d'", iRetVal);
Connect(strEmpty);
}
return iRetVal;
@ -1932,7 +2009,6 @@ wxInt32 CMainDocument::SetProxyConfiguration() {
iRetVal = rpc.set_proxy_settings(proxy_info);
if (iRetVal) {
wxLogTrace("CMainDocument::SetProxyInfo - Set Proxy Info Failed '%d'", iRetVal);
Connect(wxEmptyString);
}
return iRetVal;
@ -2024,7 +2100,6 @@ wxInt32 CMainDocument::UpdateAccountManagerAccounts() {
);
if (iRetVal) {
wxLogTrace("CMainDocument::UpdateAccountManagerAccounts - Account Manager RPC Failed '%d'", iRetVal);
Connect(wxEmptyString);
}
return iRetVal;

View File

@ -33,11 +33,33 @@ class CNetworkConnectionThread : public wxThread
{
public:
CNetworkConnectionThread( CMainDocument* pDocument );
~CNetworkConnectionThread();
virtual void* Entry();
virtual void* Entry();
void FireReconnectEvent() { m_bConnectEvent = true; };
void ForceReconnect() { m_bForceReconnect = true; };
wxInt32 GetConnectedComputerName( wxString& strMachine );
wxInt32 GetConnectingComputerName( wxString& strMachine );
wxInt32 SetNewComputerName( const wxChar* szComputer );
wxInt32 SetNewComputerPassword( const wxChar* szPassword );
void SetStateError();
void SetStateReconnecting();
void SetStateSuccess( std::string& strComputer, std::string& strComputerPassword );
bool IsConnectEventSignaled() { return m_bConnectEvent; };
bool IsConnected() { return m_bConnected; };
bool IsReconnecting() { return m_bReconnecting; };
private:
CMainDocument* m_pDocument;
bool m_bConnectEvent;
bool m_bForceReconnect;
bool m_bReconnectOnError;
bool m_bConnected;
bool m_bReconnecting;
wxString m_strNewComputerName;
wxString m_strNewComputerPassword;
wxString m_strConnectedComputerName;
wxString m_strConnectedComputerPassword;
};
@ -79,10 +101,10 @@ public:
//
private:
bool m_bCachedStateLocked;
CNetworkConnectionThread* m_pNetworkConnectionThread;
bool m_bCachedStateLocked;
wxDateTime m_dtCachedActivityRunModeTimestamp;
wxDateTime m_dtCachedNetworkRunModeTimestamp;
wxDateTime m_dtCachedActivityStateTimestamp;
@ -98,18 +120,22 @@ public:
wxInt32 OnInit();
wxInt32 OnExit();
wxInt32 OnRefreshState();
wxInt32 Connect( const wxChar* szComputer, const wxChar* szComputerPassword = wxEmptyString, bool bDisconnect = TRUE );
wxInt32 GetConnectedComputerName( wxString& strMachine );
wxInt32 GetConnectingComputerName( wxString& strMachine );
bool IsConnected();
bool IsReconnecting();
wxInt32 OnRefreshState();
wxInt32 ResetState();
wxInt32 Connect( const wxChar* szComputer, const wxChar* szComputerPassword = wxEmptyString, bool bDisconnect = FALSE );
wxInt32 CachedStateLock();
wxInt32 CachedStateUnlock();
wxInt32 GetCoreClientVersion();
wxInt32 CoreClientQuit();
wxInt32 GetConnectedComputerName( wxString& strMachine );
wxInt32 GetConnectingComputerName( wxString& strMachine );
bool IsConnected();
bool IsReconnecting();
wxInt32 GetActivityRunMode( wxInt32& iMode );
wxInt32 SetActivityRunMode( wxInt32 iMode );
@ -118,7 +144,6 @@ public:
wxInt32 GetActivityState( bool& bActivitiesSuspended, bool& bNetworkSuspended );
wxInt32 RunBenchmarks();
wxInt32 CoreClientQuit();
RPC_CLIENT rpc;
CC_STATE state;
@ -126,15 +151,6 @@ public:
wxDateTime m_dtCachedStateTimestamp;
wxDateTime m_dtCachedStateLockTimestamp;
bool m_bNCTConnectEvent;
bool m_bNCTNewShouldReconnect;
wxString m_strNCTNewConnectedComputerName;
wxString m_strNCTNewConnectedComputerPassword;
bool m_bIsConnected;
bool m_bIsReconnecting;
wxString m_strConnectedComputerName;
wxString m_strConnectedComputerPassword;
//
// Project Tab

View File

@ -134,6 +134,12 @@ void CStatusBar::OnSize(wxSizeEvent& event) {
}
DEFINE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT )
DEFINE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT_ERROR )
DEFINE_EVENT_TYPE( wxEVT_MAINFRAME_INITIALIZED )
DEFINE_EVENT_TYPE( wxEVT_MAINFRAME_REFRESHVIEW )
IMPLEMENT_DYNAMIC_CLASS(CMainFrame, wxFrame)
BEGIN_EVENT_TABLE (CMainFrame, wxFrame)
@ -148,6 +154,10 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame)
EVT_MENU(wxID_ABOUT, CMainFrame::OnAbout)
EVT_CLOSE(CMainFrame::OnClose)
EVT_CHAR(CMainFrame::OnChar)
EVT_MAINFRAME_CONNECT(CMainFrame::OnConnect)
EVT_MAINFRAME_CONNECT_ERROR(CMainFrame::OnConnectError)
EVT_MAINFRAME_INITIALIZED(CMainFrame::OnInitialized)
EVT_MAINFRAME_REFRESH(CMainFrame::OnRefreshView)
EVT_TIMER(ID_REFRESHSTATETIMER, CMainFrame::OnRefreshState)
EVT_TIMER(ID_FRAMERENDERTIMER, CMainFrame::OnFrameRender)
EVT_TIMER(ID_FRAMELISTRENDERTIMER, CMainFrame::OnListPanelRender)
@ -174,8 +184,6 @@ CMainFrame::CMainFrame(wxString strTitle) :
m_strBaseTitle = strTitle;
m_bRunInitialClientConnectionChecks = true;
m_aSelectedComputerMRU.Clear();
@ -204,6 +212,11 @@ CMainFrame::CMainFrame(wxString strTitle) :
SetStatusBarPane(0);
// Complete any remaining initialization that has to happen after we are up
// and running
CMainFrameEvent event(wxEVT_MAINFRAME_INITIALIZED, this);
AddPendingEvent( event );
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::CMainFrame - Function End"));
}
@ -725,45 +738,6 @@ bool CMainFrame::RestoreState() {
}
bool CMainFrame::AttachToProjectPrompt() {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::AttachToProjectPrompt - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
CDlgAttachProject* pDlg = new CDlgAttachProject(this);
wxInt32 iAnswer = 0;
long lProjectCount = 0;
wxASSERT(NULL != m_pNotebook);
wxASSERT(NULL != pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
wxASSERT(NULL != pDlg);
// Only present the attach to project dialog if no projects are currently
// detected.
lProjectCount = pDoc->GetProjectCount();
if (0 == lProjectCount) {
iAnswer = pDlg->ShowModal();
if (wxID_OK == iAnswer) {
pDoc->ProjectAttach(
pDlg->GetProjectAddress(),
pDlg->GetProjectAccountKey()
);
}
m_pNotebook->SetSelection(ID_LIST_MESSAGESVIEW - ID_LIST_BASE);
}
if (pDlg)
pDlg->Destroy();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::AttachToProjectPrompt - Function End"));
return true;
}
void CMainFrame::OnHide(wxCommandEvent& WXUNUSED(event)) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnHide - Function Begin"));
@ -868,17 +842,13 @@ void CMainFrame::OnSelectComputer(wxCommandEvent& WXUNUSED(event)) {
lAnswer = pDlg->ShowModal();
if (wxID_OK == lAnswer) {
lRetVal = pDoc->Connect(pDlg->m_ComputerNameCtrl->GetValue(), pDlg->m_ComputerPasswordCtrl->GetValue());
lRetVal = pDoc->Connect(pDlg->m_ComputerNameCtrl->GetValue(), pDlg->m_ComputerPasswordCtrl->GetValue(), TRUE);
if (!(0 == lRetVal)) {
::wxMessageBox(
_("Failed to connect to the requested computer, please check the name of the computer and try again."),
_("Failed to connect..."),
wxICON_ERROR
);
} else {
// Run any checks that may need to be run upon an initial
// connection.
m_bRunInitialClientConnectionChecks = true;
}
// Insert a copy of the current combo box value to the head of the
@ -1096,28 +1066,101 @@ void CMainFrame::OnChar(wxKeyEvent& event)
}
void CMainFrame::OnNotebookSelectionChanged(wxNotebookEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnNotebookSelectionChanged - Function Begin"));
void CMainFrame::OnConnect(CMainFrameEvent &event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnect - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
CDlgAttachProject* pDlg = new CDlgAttachProject(this);
wxInt32 iAnswer = 0;
long lProjectCount = 0;
if ((-1 != event.GetSelection()) && IsShown()) {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxTimerEvent timerEvent;
wxASSERT(NULL != m_pNotebook);
wxASSERT(NULL != pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
wxASSERT(NULL != pDlg);
wxASSERT(NULL != m_pNotebook);
pwndNotebookPage = m_pNotebook->GetPage(event.GetSelection());
wxASSERT(NULL != pwndNotebookPage);
// Only present the attach to project dialog if no projects are currently
// detected.
lProjectCount = pDoc->GetProjectCount();
if (0 == lProjectCount) {
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(NULL != pView);
iAnswer = pDlg->ShowModal();
if (wxID_OK == iAnswer) {
pDoc->ProjectAttach(
pDlg->GetProjectAddress(),
pDlg->GetProjectAccountKey()
);
}
pView->FireOnListRender(timerEvent);
m_pNotebook->SetSelection(ID_LIST_MESSAGESVIEW - ID_LIST_BASE);
}
event.Skip();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnNotebookSelectionChanged - Function End"));
if (pDlg)
pDlg->Destroy();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnect - Function End"));
}
void CMainFrame::OnConnectError(CMainFrameEvent &event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnectError - Function Begin"));
::wxMessageBox(
_("The BOINC client you have attempted to connect you could not be reached, please "
"check the computer name/password and try again."),
_("Connection Error"),
wxICON_ERROR
);
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnectError - Function End"));
}
void CMainFrame::OnInitialized(CMainFrameEvent &event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnInitialized - Function Begin"));
CMainDocument* pDoc = wxGetApp().GetDocument();
wxASSERT(NULL != pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
if ( !pDoc->IsConnected() )
pDoc->Connect( wxEmptyString );
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnInitialized - Function End"));
}
void CMainFrame::OnRefreshView(CMainFrameEvent &event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnRefreshView - Function Begin"));
static bool bAlreadyRunningLoop = false;
if (!bAlreadyRunningLoop) {
bAlreadyRunningLoop = true;
if (IsShown()) {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxTimerEvent timerEvent;
wxASSERT(NULL != m_pNotebook);
pwndNotebookPage = m_pNotebook->GetPage(m_pNotebook->GetSelection());
wxASSERT(NULL != pwndNotebookPage);
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(NULL != pView);
pView->FireOnListRender( timerEvent );
}
bAlreadyRunningLoop = false;
}
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnRefreshView - Function End"));
}
@ -1136,16 +1179,7 @@ void CMainFrame::OnRefreshState(wxTimerEvent &event) {
// for their next use
SaveState();
// Refresh the state data at the document level
CMainDocument* pDoc = wxGetApp().GetDocument();
if (NULL != pDoc) {
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
pDoc->OnRefreshState();
}
bAlreadyRunningLoop = false;
}
event.Skip();
@ -1169,17 +1203,6 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
if (NULL != pDoc) {
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
// Run stuff that we want to display on startup
if (m_bRunInitialClientConnectionChecks && pDoc->IsConnected()) {
m_bRunInitialClientConnectionChecks = false;
// If we don't detect any attached projects for this BOINC Daemon,
// prompt to add one.
AttachToProjectPrompt();
}
// Update the menu bar
wxMenuBar* pMenuBar = GetMenuBar();
wxInt32 iActivityMode = -1;
@ -1197,13 +1220,12 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
if (NULL != pMenuBar->FindItem(ID_ACTIVITYRUNBASEDONPREPERENCES, NULL))
pMenuBar->Check(ID_ACTIVITYRUNBASEDONPREPERENCES, false);
if (0 == pDoc->GetActivityRunMode(iActivityMode)) {
if ( (pDoc->IsConnected()) && (0 == pDoc->GetActivityRunMode(iActivityMode)) ) {
if (CMainDocument::MODE_ALWAYS == iActivityMode)
pMenuBar->Check(ID_ACTIVITYRUNALWAYS, true);
if (CMainDocument::MODE_NEVER == iActivityMode)
pMenuBar->Check(ID_ACTIVITYSUSPEND, true);
if (CMainDocument::MODE_AUTO == iActivityMode)
pMenuBar->Check(ID_ACTIVITYRUNBASEDONPREPERENCES, true);
}
@ -1220,7 +1242,7 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
pMenuBar->Check(ID_NETWORKRUNBASEDONPREPERENCES, false);
#endif
if (0 == pDoc->GetNetworkRunMode(iNetworkMode)) {
if ( (pDoc->IsConnected()) && (0 == pDoc->GetNetworkRunMode(iNetworkMode)) ) {
#if 0
if (CMainDocument::MODE_ALWAYS == iNetworkMode)
pMenuBar->Check(ID_NETWORKRUNALWAYS, true);
@ -1280,6 +1302,8 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
m_pStatusbar->m_ptxtConnected->Hide();
m_pStatusbar->m_pbmpDisconnect->Show();
m_pStatusbar->m_ptxtDisconnect->Show();
SetTitle(m_strBaseTitle);
}
}
}
@ -1296,33 +1320,56 @@ void CMainFrame::OnFrameRender(wxTimerEvent &event) {
void CMainFrame::OnListPanelRender(wxTimerEvent &event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListPanelRender - Function Begin"));
static bool bAlreadyRunningLoop = false;
if (!bAlreadyRunningLoop) {
bAlreadyRunningLoop = true;
if (IsShown()) {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxASSERT(NULL != m_pNotebook);
pwndNotebookPage = m_pNotebook->GetPage(m_pNotebook->GetSelection());
wxASSERT(NULL != pwndNotebookPage);
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(NULL != pView);
pView->FireOnListRender(event);
}
bAlreadyRunningLoop = false;
}
event.Skip();
FireRefreshView();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnListPanelRender - Function End"));
}
void CMainFrame::OnNotebookSelectionChanged(wxNotebookEvent& event) {
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnNotebookSelectionChanged - Function Begin"));
if ((-1 != event.GetSelection()) && IsShown()) {
wxWindow* pwndNotebookPage = NULL;
CBOINCBaseView* pView = NULL;
wxTimerEvent timerEvent;
wxASSERT(NULL != m_pNotebook);
pwndNotebookPage = m_pNotebook->GetPage(event.GetSelection());
wxASSERT(NULL != pwndNotebookPage);
pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView);
wxASSERT(NULL != pView);
pView->FireOnListRender(timerEvent);
}
event.Skip();
wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnNotebookSelectionChanged - Function End"));
}
void CMainFrame::FireConnect()
{
CMainFrameEvent event(wxEVT_MAINFRAME_CONNECT, this);
AddPendingEvent( event );
}
void CMainFrame::FireConnectError()
{
CMainFrameEvent event(wxEVT_MAINFRAME_CONNECT_ERROR, this);
AddPendingEvent( event );
}
void CMainFrame::FireRefreshView()
{
CMainFrameEvent event(wxEVT_MAINFRAME_REFRESHVIEW, this);
AddPendingEvent( event );
}
const char *BOINC_RCSID_d881a56dc5 = "$Id$";

View File

@ -46,6 +46,7 @@ private:
DECLARE_EVENT_TABLE()
};
class CMainFrameEvent;
class CMainFrame : public wxFrame
{
@ -77,6 +78,15 @@ public:
void OnNotebookSelectionChanged( wxNotebookEvent& event );
void OnConnect( CMainFrameEvent& event );
void OnConnectError( CMainFrameEvent& event );
void OnInitialized( CMainFrameEvent& event );
void OnRefreshView( CMainFrameEvent& event );
void FireConnect();
void FireConnectError();
void FireRefreshView();
private:
wxMenuBar* m_pMenubar;
@ -88,8 +98,6 @@ private:
wxString m_strBaseTitle;
bool m_bRunInitialClientConnectionChecks;
wxInt32 m_iSelectedLanguage;
wxArrayString m_aSelectedComputerMRU;
@ -108,13 +116,35 @@ private:
bool SaveState();
bool RestoreState();
bool AttachToProjectPrompt();
DECLARE_EVENT_TABLE()
};
class CMainFrameEvent : public wxEvent
{
public:
CMainFrameEvent(wxEventType evtType, CMainFrame *frame)
: wxEvent(-1, evtType)
{
SetEventObject(frame);
}
virtual wxEvent *Clone() const { return new CMainFrameEvent(*this); }
};
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT, 10000 )
DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT_ERROR, 10001 )
DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_INITIALIZED, 10002 )
DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_REFRESHVIEW, 10003 )
END_DECLARE_EVENT_TYPES()
#define EVT_MAINFRAME_CONNECT(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_CONNECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
#define EVT_MAINFRAME_CONNECT_ERROR(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_CONNECT_ERROR, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
#define EVT_MAINFRAME_INITIALIZED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_INITIALIZED, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
#define EVT_MAINFRAME_REFRESH(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_REFRESHVIEW, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
#endif

View File

@ -926,12 +926,12 @@ void MESSAGES::clear() {
}
RPC_CLIENT::RPC_CLIENT() {
sock = 0;
close();
client_version = 0;
}
RPC_CLIENT::~RPC_CLIENT() {
sock = 0;
close();
client_version = 0;
}