From e9d2bdc3e803604fefec2fd999dda4d247601171 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 29 Dec 2006 16:35:33 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=11737 --- checkin_notes | 13 +++ client/win/win_screensaver.cpp | 31 +++--- clientgui/AdvancedFrame.cpp | 144 ++++++++++++---------------- clientgui/AdvancedFrame.h | 7 +- clientgui/BOINCBaseFrame.cpp | 18 +++- clientgui/BOINCBaseFrame.h | 4 + clientgui/BOINCBaseView.cpp | 8 ++ clientgui/BOINCBaseView.h | 1 + clientgui/BOINCDialupManager.cpp | 2 +- clientgui/BOINCDialupManager.h | 2 +- clientgui/ViewStatistics.cpp | 8 ++ clientgui/ViewStatistics.h | 1 + win_build/boincmgr_curl_2003.vcproj | 12 +-- 13 files changed, 139 insertions(+), 112 deletions(-) diff --git a/checkin_notes b/checkin_notes index 70995c2e97..a5c3c2a7cf 100755 --- a/checkin_notes +++ b/checkin_notes @@ -13777,3 +13777,16 @@ David 28 Dec 2006 inc/ cache.inc util.inc + +Rom 29 Dec 2006 + - SCRSAV: Fix build break. + - MGR: Refactor the timer management code whithin the advanced frame. + + client/win/ + win_screensaver.cpp + clientgui/ + AdvancedFrame.cpp, .h + BOINCBaseFrame.cpp, .h + BOINCBaseView.cpp, .h + BOINCDialupManager.cpp, .h + ViewStatistics.cpp, .h diff --git a/client/win/win_screensaver.cpp b/client/win/win_screensaver.cpp index 836fff6ee6..c836398906 100755 --- a/client/win/win_screensaver.cpp +++ b/client/win/win_screensaver.cpp @@ -1541,21 +1541,24 @@ LRESULT CScreensaver::SaverProc( if (wParam == PBT_APMQUERYSUSPEND && gspfnMyVerifyPwdProc == NULL) InterruptSaver(); break; - - case WM_SETTIMER: - BOINCTRACE(_T("CScreensaver::SaverProc Received WM_SETTIMER\n")); - // All initialization messages have gone through. Allow - // 500ms of idle time, then proceed with initialization. - SetTimer(hWnd, 1, 500, NULL); - break; - - case WM_INTERRUPTSAVER: - BOINCTRACE(_T("CScreensaver::SaverProc Received WM_INTERRUPTSAVER\n")); - if (hWnd == m_Monitors[0].hWnd) { - InterruptSaver(); - } - break; } + + if (WM_SETTIMER == uMsg) { + + BOINCTRACE(_T("CScreensaver::SaverProc Received WM_SETTIMER\n")); + // All initialization messages have gone through. Allow + // 500ms of idle time, then proceed with initialization. + SetTimer(hWnd, 1, 500, NULL); + + } else if (WM_INTERRUPTSAVER == uMsg) { + + BOINCTRACE(_T("CScreensaver::SaverProc Received WM_INTERRUPTSAVER\n")); + if (hWnd == m_Monitors[0].hWnd) { + InterruptSaver(); + } + + } + return DefWindowProc(hWnd, uMsg, wParam, lParam); } diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index efae1a7405..b7074164bd 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1085,10 +1085,8 @@ void CAdvancedFrame::OnProjectsAttachToAccountManager(wxCommandEvent& WXUNUSED(e return; if (pDoc->IsConnected()) { - m_pRefreshStateTimer->Stop(); - m_pFrameRenderTimer->Stop(); - m_pFrameListPanelRenderTimer->Stop(); - m_pDocumentPollTimer->Stop(); + // Stop all timers so that the wizard is the only thing doing anything + StopTimers(); CWizardAccountManager* pWizard = new CWizardAccountManager(this); @@ -1101,10 +1099,8 @@ void CAdvancedFrame::OnProjectsAttachToAccountManager(wxCommandEvent& WXUNUSED(e CreateMenu(); FireRefreshView(); - m_pRefreshStateTimer->Start(); - m_pFrameRenderTimer->Start(); - m_pFrameListPanelRenderTimer->Start(); - m_pDocumentPollTimer->Start(); + // Restart timers to continue normal operations. + StartTimers(); } else { ShowNotCurrentlyConnectedAlert(); } @@ -1125,10 +1121,8 @@ void CAdvancedFrame::OnAccountManagerUpdate(wxCommandEvent& WXUNUSED(event)) { return; if (pDoc->IsConnected()) { - m_pRefreshStateTimer->Stop(); - m_pFrameRenderTimer->Stop(); - m_pFrameListPanelRenderTimer->Stop(); - m_pDocumentPollTimer->Stop(); + // Stop all timers so that the wizard is the only thing doing anything + StopTimers(); CWizardAccountManager* pWizard = new CWizardAccountManager(this); @@ -1142,10 +1136,8 @@ void CAdvancedFrame::OnAccountManagerUpdate(wxCommandEvent& WXUNUSED(event)) { FireRefreshView(); ResetReminderTimers(); - m_pRefreshStateTimer->Start(); - m_pFrameRenderTimer->Start(); - m_pFrameListPanelRenderTimer->Start(); - m_pDocumentPollTimer->Start(); + // Restart timers to continue normal operations. + StartTimers(); } else { ShowNotCurrentlyConnectedAlert(); } @@ -1230,10 +1222,8 @@ void CAdvancedFrame::OnProjectsAttachToProject( wxCommandEvent& WXUNUSED(event) if (pDoc->IsConnected()) { UpdateStatusText(_("Attaching to project...")); - m_pRefreshStateTimer->Stop(); - m_pFrameRenderTimer->Stop(); - m_pFrameListPanelRenderTimer->Stop(); - m_pDocumentPollTimer->Stop(); + // Stop all timers so that the wizard is the only thing doing anything + StopTimers(); CWizardAttachProject* pWizard = new CWizardAttachProject(this); @@ -1247,10 +1237,8 @@ void CAdvancedFrame::OnProjectsAttachToProject( wxCommandEvent& WXUNUSED(event) DeleteMenu(); CreateMenu(); - m_pRefreshStateTimer->Start(); - m_pFrameRenderTimer->Start(); - m_pFrameListPanelRenderTimer->Start(); - m_pDocumentPollTimer->Start(); + // Restart timers to continue normal operations. + StartTimers(); UpdateStatusText(wxT("")); @@ -1542,11 +1530,8 @@ void CAdvancedFrame::OnConnect(CFrameEvent& WXUNUSED(event)) { DeleteMenu(); CreateMenu(); - // Only present one of the wizards if no projects are currently - // detected. - m_pRefreshStateTimer->Stop(); - m_pFrameRenderTimer->Stop(); - m_pFrameListPanelRenderTimer->Stop(); + // Stop all timers so that the wizard is the only thing doing anything + StopTimers(); // If we are connected to the localhost, run a really quick screensaver @@ -1617,9 +1602,9 @@ void CAdvancedFrame::OnConnect(CFrameEvent& WXUNUSED(event)) { } } - m_pRefreshStateTimer->Start(); - m_pFrameRenderTimer->Start(); - m_pFrameListPanelRenderTimer->Start(); + + // Restart timers to continue normal operations. + StartTimers(); if (pAMWizard) pAMWizard->Destroy(); @@ -1666,7 +1651,7 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent &event) { CMainDocument* pDoc = wxGetApp().GetDocument(); - if (!bAlreadyRunningLoop) { + if (!bAlreadyRunningLoop && m_pFrameRenderTimer->IsRunning()) { bAlreadyRunningLoop = true; if (IsShown()) { @@ -1741,9 +1726,8 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent &event) { } -void CAdvancedFrame::OnListPanelRender(wxTimerEvent&) { +void CAdvancedFrame::OnListPanelRender(wxTimerEvent& WXUNUSED(event)) { FireRefreshView(); - SetFrameListPanelRenderTimerRate(); // Set to refresh every 5 or 60 seconds } @@ -1753,7 +1737,8 @@ void CAdvancedFrame::OnNotebookSelectionChanged(wxNotebookEvent& event) { if ((-1 != event.GetSelection()) && IsShown()) { wxWindow* pwndNotebookPage = NULL; CBOINCBaseView* pView = NULL; - wxTimerEvent timerEvent; + CMainDocument* pDoc = wxGetApp().GetDocument(); + wxASSERT(m_pNotebook); @@ -1763,9 +1748,25 @@ void CAdvancedFrame::OnNotebookSelectionChanged(wxNotebookEvent& event) { pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); wxASSERT(pView); - FireRefreshView(); + if (m_pFrameListPanelRenderTimer->IsRunning()) { + m_pFrameListPanelRenderTimer->Stop(); - SetFrameListPanelRenderTimerRate(); + // View specific refresh rates only apply when a connection to the core + // client has been established, otherwise the refresh rate should be 1 + // second. + if (pDoc) { + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + if (pDoc->IsConnected()) { + // Set new view specific refresh rate + m_pFrameListPanelRenderTimer->Start(pView->GetViewRefreshRate() * 1000); + } else { + // Set view refresh rate to 1 second + m_pFrameListPanelRenderTimer->Start(1000); + } + } + } + + FireRefreshView(); } event.Skip(); @@ -1784,51 +1785,6 @@ void CAdvancedFrame::ResetReminderTimers() { } -void CAdvancedFrame::SetFrameListPanelRenderTimerRate() { - static wxWindowID previousPane = -1; - static int connectedCount = 0; - wxWindowID currentPane; - - CMainDocument* pDoc = wxGetApp().GetDocument(); - - wxASSERT(m_pNotebook); - wxASSERT(m_pFrameListPanelRenderTimer); - wxASSERT(pDoc); - wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - - // Keep timer at faster rate until we have been connected > 10 seconds - if (!pDoc->IsConnected()) - connectedCount = 0; - - if (connectedCount < 3) { - connectedCount++; - previousPane = -1; // Ensure an update when connectedCount reaches 3 - - if (m_pFrameListPanelRenderTimer->IsRunning()) - m_pFrameListPanelRenderTimer->Stop(); - m_pFrameListPanelRenderTimer->Start(1000); // Refresh every 1 seconds - return; - } - - currentPane = m_pNotebook->GetSelection() + ID_TASK_BASE; - if (currentPane == previousPane) - return; - - previousPane = currentPane; - if (m_pFrameListPanelRenderTimer->IsRunning()) - m_pFrameListPanelRenderTimer->Stop(); - - switch (currentPane) { - case ID_TASK_STATISTICSVIEW: - m_pFrameListPanelRenderTimer->Start(60000); // Refresh every 1 minute - break; - default: - m_pFrameListPanelRenderTimer->Start(1000); // Refresh every 1 seconds - break; - } -} - - void CAdvancedFrame::UpdateActivityModeControls( CC_STATUS& status ) { wxMenuBar* pMenuBar = GetMenuBar(); @@ -1883,4 +1839,26 @@ void CAdvancedFrame::UpdateNetworkModeControls( CC_STATUS& status ) { } +void CAdvancedFrame::StartTimers() { + wxASSERT(m_pRefreshStateTimer); + wxASSERT(m_pFrameRenderTimer); + wxASSERT(m_pFrameListPanelRenderTimer); + CBOINCBaseFrame::StartTimers(); + m_pRefreshStateTimer->Start(); + m_pFrameRenderTimer->Start(); + m_pFrameListPanelRenderTimer->Start(); +} + + +void CAdvancedFrame::StopTimers() { + wxASSERT(m_pRefreshStateTimer); + wxASSERT(m_pFrameRenderTimer); + wxASSERT(m_pFrameListPanelRenderTimer); + CBOINCBaseFrame::StopTimers(); + m_pRefreshStateTimer->Stop(); + m_pFrameRenderTimer->Stop(); + m_pFrameListPanelRenderTimer->Stop(); +} + + const char *BOINC_RCSID_d881a56dc5 = "$Id$"; diff --git a/clientgui/AdvancedFrame.h b/clientgui/AdvancedFrame.h index 2eb9e5a125..c6856ae95b 100644 --- a/clientgui/AdvancedFrame.h +++ b/clientgui/AdvancedFrame.h @@ -92,10 +92,6 @@ public: void ResetReminderTimers(); - void SetFrameListPanelRenderTimerRate(); // TODO: refactor out of the frame and put the - // relevent code in OnPageChanged function - // and the base/statistics view. - wxTimer* m_pRefreshStateTimer; wxTimer* m_pFrameRenderTimer; wxTimer* m_pFrameListPanelRenderTimer; @@ -128,6 +124,9 @@ private: void UpdateActivityModeControls( CC_STATUS& status ); void UpdateNetworkModeControls( CC_STATUS& status ); + void StartTimers(); + void StopTimers(); + #ifdef __WXMAC__ protected: diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp index 0b9619c571..eea94c0535 100644 --- a/clientgui/BOINCBaseFrame.cpp +++ b/clientgui/BOINCBaseFrame.cpp @@ -141,7 +141,7 @@ void CBOINCBaseFrame::OnDocumentPoll(wxTimerEvent& WXUNUSED(event)) { wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - if (!bAlreadyRunOnce) { + if (!bAlreadyRunOnce && m_pDocumentPollTimer->IsRunning()) { // Complete any remaining initialization that has to happen after we are up // and running FireInitialize(); @@ -156,7 +156,7 @@ void CBOINCBaseFrame::OnAlertPoll(wxTimerEvent& WXUNUSED(event)) { static bool bAlreadyRunningLoop = false; CMainDocument* pDoc = wxGetApp().GetDocument(); - if (!bAlreadyRunningLoop) { + if (!bAlreadyRunningLoop && m_pAlertPollTimer->IsRunning()) { bAlreadyRunningLoop = true; // Update idle detection if needed. @@ -166,7 +166,7 @@ void CBOINCBaseFrame::OnAlertPoll(wxTimerEvent& WXUNUSED(event)) { // dial up user perspective. if (pDoc && m_pDialupManager) { if (pDoc->IsConnected()) { - m_pDialupManager->poll(); + m_pDialupManager->OnPoll(); } } @@ -442,6 +442,18 @@ void CBOINCBaseFrame::ShowNotCurrentlyConnectedAlert() { } +void CBOINCBaseFrame::StartTimers() { + wxASSERT(m_pAlertPollTimer); + m_pAlertPollTimer->Start(); +} + + +void CBOINCBaseFrame::StopTimers() { + wxASSERT(m_pAlertPollTimer); + m_pAlertPollTimer->Stop(); +} + + void CBOINCBaseFrame::UpdateStatusText(const wxChar* szStatus) { CFrameEvent event(wxEVT_FRAME_UPDATESTATUS, this, szStatus); ProcessEvent(event); diff --git a/clientgui/BOINCBaseFrame.h b/clientgui/BOINCBaseFrame.h index a7c6b7a5e2..fd3f062cc4 100644 --- a/clientgui/BOINCBaseFrame.h +++ b/clientgui/BOINCBaseFrame.h @@ -72,6 +72,10 @@ public: void ShowConnectionBadPasswordAlert(); void ShowConnectionFailedAlert(); void ShowNotCurrentlyConnectedAlert(); + + virtual void StartTimers(); + virtual void StopTimers(); + void UpdateStatusText( const wxChar* szStatus ); void ShowAlert( diff --git a/clientgui/BOINCBaseView.cpp b/clientgui/BOINCBaseView.cpp index 317a0b7bd3..f817e3b7e2 100644 --- a/clientgui/BOINCBaseView.cpp +++ b/clientgui/BOINCBaseView.cpp @@ -122,6 +122,14 @@ const char** CBOINCBaseView::GetViewIcon() { } +// The rate at which the view is refreshed. +// If it has not been defined by the view 1 second is retrned. +// +const int CBOINCBaseView::GetViewRefreshRate() { + return 1; +} + + bool CBOINCBaseView::FireOnSaveState(wxConfigBase* pConfig) { return OnSaveState(pConfig); } diff --git a/clientgui/BOINCBaseView.h b/clientgui/BOINCBaseView.h index f316c093ae..214ea5d8b1 100644 --- a/clientgui/BOINCBaseView.h +++ b/clientgui/BOINCBaseView.h @@ -92,6 +92,7 @@ public: virtual wxString& GetViewName(); virtual const char** GetViewIcon(); + virtual const int GetViewRefreshRate(); bool FireOnSaveState( wxConfigBase* pConfig ); bool FireOnRestoreState( wxConfigBase* pConfig ); diff --git a/clientgui/BOINCDialupManager.cpp b/clientgui/BOINCDialupManager.cpp index fe091d3e21..7ffe16ec6c 100644 --- a/clientgui/BOINCDialupManager.cpp +++ b/clientgui/BOINCDialupManager.cpp @@ -92,7 +92,7 @@ size_t CBOINCDialUpManager::GetISPNames(wxArrayString& names) { } -void CBOINCDialUpManager::poll() { +void CBOINCDialUpManager::OnPoll() { CMainDocument* pDoc = wxGetApp().GetDocument(); CBOINCBaseFrame* pFrame = wxGetApp().GetFrame(); #if defined(__WXMSW__) diff --git a/clientgui/BOINCDialupManager.h b/clientgui/BOINCDialupManager.h index d01ef99afc..f77b78cb0c 100644 --- a/clientgui/BOINCDialupManager.h +++ b/clientgui/BOINCDialupManager.h @@ -35,7 +35,7 @@ public: bool IsOk(); size_t GetISPNames(wxArrayString& names); - void poll(); + void OnPoll(); int NotifyUserNeedConnection(bool bNotificationOnly); diff --git a/clientgui/ViewStatistics.cpp b/clientgui/ViewStatistics.cpp index df6926c3e9..c591cd5450 100644 --- a/clientgui/ViewStatistics.cpp +++ b/clientgui/ViewStatistics.cpp @@ -1635,20 +1635,28 @@ CViewStatistics::CViewStatistics(wxNotebook* pNotebook) : UpdateSelection(); } + CViewStatistics::~CViewStatistics() { EmptyTasks(); } + wxString& CViewStatistics::GetViewName() { static wxString strViewName(_("Statistics")); return strViewName; } + const char** CViewStatistics::GetViewIcon() { return stats_xpm; } +const int CViewStatistics::GetViewRefreshRate() { + return 60; +} + + void CViewStatistics::OnStatisticsUserTotal( wxCommandEvent& WXUNUSED(event) ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewStatistics::OnStatisticsUserTotal - Function Begin")); diff --git a/clientgui/ViewStatistics.h b/clientgui/ViewStatistics.h index 6482420efd..7933e4613e 100644 --- a/clientgui/ViewStatistics.h +++ b/clientgui/ViewStatistics.h @@ -198,6 +198,7 @@ public: virtual wxString& GetViewName(); virtual const char** GetViewIcon(); + virtual const int GetViewRefreshRate(); void OnStatisticsUserTotal( wxCommandEvent& event ); void OnStatisticsUserAverage( wxCommandEvent& event ); diff --git a/win_build/boincmgr_curl_2003.vcproj b/win_build/boincmgr_curl_2003.vcproj index dea67703bf..f5ac9fbdac 100644 --- a/win_build/boincmgr_curl_2003.vcproj +++ b/win_build/boincmgr_curl_2003.vcproj @@ -1217,6 +1217,12 @@ + + + + - - - -