From 50dc9e51ae02f0b310448a0b1badba4aa073da67 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Thu, 28 Oct 2004 07:03:06 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4452 --- clientgui/Events.h | 13 +++--- clientgui/MainDocument.cpp | 84 ++++++++++++++++++++++++++++++------ clientgui/MainDocument.h | 5 +++ clientgui/MainFrame.cpp | 40 ++++++++++++++++- clientgui/MainFrame.h | 4 ++ clientgui/res/connect.xpm | 5 ++- clientgui/res/disconnect.xpm | 5 ++- clientgui/stdwx.h | 2 + 8 files changed, 135 insertions(+), 23 deletions(-) diff --git a/clientgui/Events.h b/clientgui/Events.h index 371b301cf8..1e5eacd866 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -39,12 +39,13 @@ #define ID_NETWORKRUNBASEDONPREPERENCES 6010 #define ID_NETWORKSUSPEND 6011 #define ID_RUNBENCHMARKS 6012 -#define ID_TB_ACTIVITYRUNALWAYS 6013 -#define ID_TB_ACTIVITYRUNBASEDONPREPERENCES 6014 -#define ID_TB_ACTIVITYSUSPEND 6015 -#define ID_TB_NETWORKRUNALWAYS 6016 -#define ID_TB_NETWORKRUNBASEDONPREPERENCES 6017 -#define ID_TB_NETWORKSUSPEND 6018 +#define ID_SELECTCOMPUTER 6013 +#define ID_TB_ACTIVITYRUNALWAYS 6014 +#define ID_TB_ACTIVITYRUNBASEDONPREPERENCES 6015 +#define ID_TB_ACTIVITYSUSPEND 6016 +#define ID_TB_NETWORKRUNALWAYS 6017 +#define ID_TB_NETWORKRUNBASEDONPREPERENCES 6018 +#define ID_TB_NETWORKSUSPEND 6019 #define ID_LIST_BASE 7000 #define ID_LIST_PROJECTSVIEW 7000 #define ID_LIST_WORKVIEW 7001 diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 6e512268c1..3998affba5 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -48,6 +48,7 @@ CMainDocument::CMainDocument() #endif m_bIsConnected = false; + m_strConnectedComputer = wxEmptyString; m_iCachedActivityRunMode = 0; m_iCachedNetworkRunMode = 0; @@ -79,6 +80,7 @@ CMainDocument::~CMainDocument() m_iCachedActivityRunMode = 0; m_iCachedNetworkRunMode = 0; + m_strConnectedComputer = wxEmptyString; m_bIsConnected = false; #ifdef __WIN32__ @@ -126,41 +128,95 @@ wxInt32 CMainDocument::CachedStateUpdate() wxInt32 CMainDocument::OnInit() { - wxInt32 retval = 0; + wxInt32 iRetVal = -1; + wxString strMachine = wxEmptyString; - if (!m_bIsConnected) - { - retval = rpc.init(NULL); - if (retval) - wxLogTrace("CMainDocument::OnInit - RPC Initialization Failed '%d'", retval); - } + if ( !IsConnected() ) + iRetVal = Connect( strMachine ); - return retval; + return iRetVal; } wxInt32 CMainDocument::OnExit() { - wxInt32 retval = 0; + wxInt32 iRetVal = 0; - if (m_bIsConnected) - rpc.close(); + if ( IsConnected() ) + iRetVal = Disconnect(); - return retval; + return iRetVal; } wxInt32 CMainDocument::OnIdle() { - if (m_bIsConnected) - { + if ( IsConnected() ) CachedStateUpdate(); + + return 0; +} + + +wxInt32 CMainDocument::Connect( wxString& strMachine ) +{ + wxInt32 iRetVal = -1; + std::string str; + + if ( IsConnected() ) + Disconnect(); + + str.clear(); + + if ( strMachine.empty() && !m_strConnectedComputer.empty() ) + str = m_strConnectedComputer.c_str(); + else + str = strMachine.c_str(); + + if ( str.empty() ) + iRetVal = rpc.init( NULL ); + else + iRetVal = rpc.init( str.c_str() ); + + if ( 0 == iRetVal ) + m_strConnectedComputer = strMachine; + else + wxLogTrace("CMainDocument::Connect - RPC Initialization Failed '%d'", iRetVal); + + return iRetVal; +} + + +wxInt32 CMainDocument::Disconnect() +{ + if ( IsConnected() ) + { + 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_bIsConnected = false; } return 0; } +bool CMainDocument::IsConnected() +{ + return m_bIsConnected; +} + + wxInt32 CMainDocument::CachedStateLock() { m_bCachedStateLocked = true; diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index f6f3738c7b..ab462803f3 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -79,6 +79,7 @@ private: bool m_bCachedStateLocked; bool m_bIsConnected; + wxString m_strConnectedComputer; wxInt32 m_iCachedActivityRunMode; wxInt32 m_iCachedNetworkRunMode; @@ -91,6 +92,10 @@ public: wxInt32 OnExit(); wxInt32 OnIdle(); + wxInt32 Connect( wxString& strMachine ); + wxInt32 Disconnect(); + bool IsConnected(); + wxInt32 CachedStateLock(); wxInt32 CachedStateUnlock(); diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 4fb3c1b9f9..a624907c6e 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -39,6 +39,8 @@ #include "DlgOptions.h" #include "res/BOINCGUIApp.xpm" +#include "res/connect.xpm" +#include "res/disconnect.xpm" IMPLEMENT_DYNAMIC_CLASS(CMainFrame, wxFrame) @@ -48,6 +50,7 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame) EVT_MENU_RANGE(ID_ACTIVITYRUNALWAYS, ID_ACTIVITYSUSPEND, CMainFrame::OnActivitySelection) EVT_MENU_RANGE(ID_NETWORKRUNALWAYS, ID_NETWORKSUSPEND, CMainFrame::OnNetworkSelection) EVT_MENU(ID_RUNBENCHMARKS, CMainFrame::OnRunBenchmarks) + EVT_MENU(ID_SELECTCOMPUTER, CMainFrame::OnSelectComputer) EVT_MENU(wxID_EXIT, CMainFrame::OnExit) EVT_MENU(ID_TOOLSOPTIONS, CMainFrame::OnToolsOptions) EVT_MENU(wxID_ABOUT, CMainFrame::OnAbout) @@ -181,6 +184,14 @@ bool CMainFrame::CreateMenu() menuFile->AppendSeparator(); + menuFile->Append( + ID_SELECTCOMPUTER, + _("Select Computer..."), + _("Allows you to remotely connect up to another computer running BOINC") + ); + + menuFile->AppendSeparator(); + menuFile->Append( wxID_EXIT, _("E&xit"), @@ -287,7 +298,7 @@ bool CMainFrame::CreateStatusbar() wxInt32 ch = GetCharWidth(); - const wxInt32 widths[] = {-1, 20*ch, 15}; + const wxInt32 widths[] = {-1, 16, 15}; m_pStatusbar = CreateStatusBar(WXSIZEOF(widths), wxST_SIZEGRIP, ID_STATUSBAR); wxASSERT(NULL != m_pStatusbar); @@ -297,6 +308,9 @@ bool CMainFrame::CreateStatusbar() SetStatusBar(m_pStatusbar); SendSizeEvent(); + m_pbmpConnected = new wxStaticBitmap(m_pStatusbar, -1, wxIcon(connect_xpm)); + m_pbmpDisconnected = new wxStaticBitmap(m_pStatusbar, -1, wxIcon(disconnect_xpm)); + return true; } @@ -541,6 +555,30 @@ void CMainFrame::OnRunBenchmarks( wxCommandEvent& WXUNUSED(event) ) } +void CMainFrame::OnSelectComputer( wxCommandEvent& WXUNUSED(event) ) +{ + wxInt32 iRetVal = -1; + wxString strMachine = wxEmptyString; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(NULL != pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + strMachine = ::wxGetTextFromUser( + _("Which computer do you wish to connect to?"), + _("Select Computer...") + ); + + iRetVal = pDoc->Connect( strMachine ); + if ( !(0 == iRetVal) ) + ::wxMessageBox( + _("Failed to connect to the requested computer, please check the name of the computer and try again."), + _("Failed to connect..."), + wxICON_ERROR + ); +} + + void CMainFrame::OnExit( wxCommandEvent& WXUNUSED(event) ) { Close(true); diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index c6568bc71d..a9fd3c1b29 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -46,6 +46,7 @@ public: void OnActivitySelection( wxCommandEvent& event ); void OnNetworkSelection( wxCommandEvent& event ); void OnRunBenchmarks( wxCommandEvent& event ); + void OnSelectComputer( wxCommandEvent& event ); void OnExit( wxCommandEvent& event ); void OnToolsOptions( wxCommandEvent& event ); @@ -74,6 +75,9 @@ private: wxTimer* m_pFrameTaskPanelRenderTimer; wxTimer* m_pFrameListPanelRenderTimer; + wxStaticBitmap* m_pbmpConnected; + wxStaticBitmap* m_pbmpDisconnected; + bool CreateMenu(); bool DeleteMenu(); diff --git a/clientgui/res/connect.xpm b/clientgui/res/connect.xpm index 1d784a9b47..359be545d8 100644 --- a/clientgui/res/connect.xpm +++ b/clientgui/res/connect.xpm @@ -21,6 +21,9 @@ // Revision History: // // $Log$ +// Revision 1.2 2004/10/28 07:03:06 rwalton +// *** empty log message *** +// // Revision 1.1 2004/10/28 06:53:17 rwalton // *** empty log message *** // @@ -31,7 +34,7 @@ static const char *connect_xpm[] = { "16 16 6 1", " c #000000", ". c #C0C0C0", -"X c #FF00FF", +"X c None", "o c #FFFFFF", "O c #808080", "+ c #FF0000", diff --git a/clientgui/res/disconnect.xpm b/clientgui/res/disconnect.xpm index 1e436668ea..fd3cc8fd78 100644 --- a/clientgui/res/disconnect.xpm +++ b/clientgui/res/disconnect.xpm @@ -21,6 +21,9 @@ // Revision History: // // $Log$ +// Revision 1.2 2004/10/28 07:03:06 rwalton +// *** empty log message *** +// // Revision 1.1 2004/10/28 06:53:17 rwalton // *** empty log message *** // @@ -31,7 +34,7 @@ static const char *disconnect_xpm[] = { "16 16 6 1", " c #000000", ". c #C0C0C0", -"X c #FF00FF", +"X c None", "o c #FFFFFF", "O c #808080", "+ c #FF0000", diff --git a/clientgui/stdwx.h b/clientgui/stdwx.h index 9da8f24d25..f2435fb9db 100644 --- a/clientgui/stdwx.h +++ b/clientgui/stdwx.h @@ -72,9 +72,11 @@ #include // notebook support #include // html window support #include // static line support +#include // static bitmap support #include // taskbar support #include // clipboard support #include // date/time support +#include #include #include #include