From 167da5c015102f83a1829acbb4b4f37120b33ae8 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 30 Jan 2008 02:47:06 +0000 Subject: [PATCH] API: Add executing_as_daemon bool to get_state rpc. SCR: When running V5 GFX applications as a service / daemon, display appropriate error message instead of trying to display graphics. svn path=/trunk/boinc/; revision=14641 --- checkin_notes | 17 +++++++++++++++++ client/cs_statefile.C | 2 ++ clientscr/Mac_Saver_Module.h | 3 ++- clientscr/boinc_ss.rc | 16 ++++++++++------ clientscr/mac_saver_module.cpp | 12 +++++++++--- clientscr/screensaver.cpp | 10 +++++++--- clientscr/screensaver_win.h | 1 + lib/gui_rpc_client.h | 1 + lib/gui_rpc_client_ops.C | 2 ++ 9 files changed, 51 insertions(+), 13 deletions(-) diff --git a/checkin_notes b/checkin_notes index a35be9cd8b..f1e6779456 100644 --- a/checkin_notes +++ b/checkin_notes @@ -907,3 +907,20 @@ David Jan 29 2008 clientgui/ DlgAdvPreferences.cpp DlgAdvPreferencesBase.cpp + +Charlie Jan 29 2008 + - SCR: When running V5 GFX applications as a service / daemon, display + appropriate error message instead of trying to display graphics. + - API: Add executing_as_daemon bool to get_state rpc. + + client/ + cs_statefile.C + clientscr/ + boinc_ss.rc + mac_saver_module.cpp,h + Mac_Saver_Module.h + screensaver.cpp + screensaver_win.h + lib/ + gui_rpc_client.h + gui_rpc_client_ops.C diff --git a/client/cs_statefile.C b/client/cs_statefile.C index 1ccfaa077c..f297f013ca 100644 --- a/client/cs_statefile.C +++ b/client/cs_statefile.C @@ -779,11 +779,13 @@ int CLIENT_STATE::write_state_gui(MIOFILE& f) { "%d\n" "%d\n" "%d\n" + "%s" "%s", get_primary_platform(), core_client_version.major, core_client_version.minor, core_client_version.release, + executing_as_daemon?"\n":"", work_fetch_no_new_work?"\n":"" ); diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index fe4ce23f22..d3ab402780 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -65,7 +65,7 @@ protected: pid_t FindProcessPID(char* name, pid_t thePID); OSErr GetpathToBOINCManagerApp(char* path, int maxLen); bool SetError( bool bErrorMode, unsigned int hrError ); - void UpdateProgressText(); + void UpdateProgressText(unsigned int hrError); void setBannerText(const char *msg, GrafPtr aPort); void updateBannerText(char *msg, GrafPtr aPort); void drawBanner(GrafPtr aPort); @@ -119,6 +119,7 @@ protected: bool m_bResetCoreState; bool m_QuitDataManagementProc; + bool m_bV5_GFX_app_is_running; // diff --git a/clientscr/boinc_ss.rc b/clientscr/boinc_ss.rc index 501174b64a..c6e1b78bd6 100644 --- a/clientscr/boinc_ss.rc +++ b/clientscr/boinc_ss.rc @@ -119,7 +119,7 @@ BEGIN VALUE "FileDescription", "BOINC Screensaver" VALUE "FileVersion", BOINC_VERSION_STRING "\0" VALUE "InternalName", "boinc_ss" - VALUE "LegalCopyright", "Copyright © 2003-2007 University of California" + VALUE "LegalCopyright", "Copyright � 2003-2007 University of California" VALUE "OriginalFilename", "boinc.scr" VALUE "ProductName", "BOINC client" VALUE "ProductVersion", BOINC_VERSION_STRING "\0" @@ -154,7 +154,7 @@ BEGIN VALUE "FileDescription", "BOINC Screensaver" VALUE "FileVersion", BOINC_VERSION_STRING "\0" VALUE "InternalName", "boinc_ss" - VALUE "LegalCopyright", "© 2003-2007 University of California" + VALUE "LegalCopyright", "� 2003-2007 University of California" VALUE "OriginalFilename", "boinc.scr" VALUE "ProductName", "BOINC client" VALUE "ProductVersion", BOINC_VERSION_STRING "\0" @@ -189,7 +189,7 @@ BEGIN VALUE "FileDescription", "BOINC Screensaver" VALUE "FileVersion", BOINC_VERSION_STRING "\0" VALUE "InternalName", "boinc_ss" - VALUE "LegalCopyright", "© 2003-2007 University of California" + VALUE "LegalCopyright", "� 2003-2007 University of California" VALUE "OriginalFilename", "boinc.scr" VALUE "ProductName", "BOINC client" VALUE "ProductVersion", BOINC_VERSION_STRING "\0" @@ -224,7 +224,7 @@ BEGIN VALUE "FileDescription", "BOINC Screensaver" VALUE "FileVersion", BOINC_VERSION_STRING "\0" VALUE "InternalName", "boinc_ss" - VALUE "LegalCopyright", "© 2003-2007 University of California" + VALUE "LegalCopyright", "� 2003-2007 University of California" VALUE "OriginalFilename", "boinc.scr" VALUE "ProductName", "BOINC client" VALUE "ProductVersion", BOINC_VERSION_STRING "\0" @@ -309,7 +309,7 @@ BEGIN IDS_ERR_BOINCSHUTDOWNEVENT "Gridrepublic screensaver shutting down." IDS_ERR_DAEMONALLOWSNOGRAPHICS - "Gridrepublic screensaver graphics\ndisabled.\n\nGraphics cannot be displayed when configured to run\nas a Windows service." + "Gridrepublic screensaver cannot display graphics \nfrom older applications when configured to \nrun as a Windows service." END #elif defined(_WCG) @@ -334,6 +334,8 @@ BEGIN "Application found, graphics loading...\n\nPlease wait..." IDS_ERR_BOINCSHUTDOWNEVENT "World Community Grid\nscreensaver shutting down." + IDS_ERR_DAEMONALLOWSNOGRAPHICS + "World Community Grid screensaver cannot display graphics \nfrom older applications when configured to \nrun as a Windows service." END #elif defined(_SEED) @@ -358,6 +360,8 @@ BEGIN "Application found, graphics loading...\n\nPlease wait..." IDS_ERR_BOINCSHUTDOWNEVENT "seedmagazine\nscreensaver shutting down." + IDS_ERR_DAEMONALLOWSNOGRAPHICS + "seedmagazine screensaver cannot display graphics \nfrom older applications when configured to \nrun as a Windows service." END #else @@ -383,7 +387,7 @@ BEGIN IDS_ERR_BOINCSHUTDOWNEVENT "BOINC screensaver shutting down." IDS_ERR_DAEMONALLOWSNOGRAPHICS - "BOINC screensaver graphics disabled.\n\nGraphics cannot be displayed when configured to run\nas a Windows service." + "BOINC screensaver cannot display graphics \nfrom older applications when configured to \nrun as a Windows service." END #endif diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 66ffd1bed0..6ee0247dcc 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -110,6 +110,8 @@ const char * BOINCNoProjectsDetectedMsg = "BOINC is not attached to any project const char * BOINCNoGraphicAppsExecutingMsg = "Project does not support screensaver graphics: "; const char * BOINCUnrecoverableErrorMsg = "Sorry, an unrecoverable error occurred"; const char * BOINCTestmodeMsg = "BOINC screensaver is running, but cannot display graphics in test mode."; +const char * BOINCV5GFXDaemonMsg = "BOINC can't display graphics from older applications when running as a daemon."; + //const char * BOINCExitedSaverMode = "BOINC is no longer in screensaver mode."; @@ -368,6 +370,7 @@ int CScreensaver::drawGraphics(GrafPtr aPort) { break; #endif case SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING: + case SCRAPPERR_DAEMONALLOWSNOGRAPHICS: if (m_StatusMessageUpdated) { setBannerText(m_MsgBuf, aPort); updateBannerText(m_MsgBuf, aPort); @@ -508,17 +511,18 @@ bool CScreensaver::SetError(bool bErrorMode, unsigned int hrError) { m_bErrorMode = bErrorMode; m_hrError = hrError; if ((hrError == SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING) + || (hrError == SCRAPPERR_DAEMONALLOWSNOGRAPHICS) #if ALWAYS_DISPLAY_PROGRESS_TEXT || (hrError == SCRAPPERR_SCREENSAVERRUNNING) #endif ) { - UpdateProgressText(); + UpdateProgressText(hrError); } return true; } -void CScreensaver::UpdateProgressText() { +void CScreensaver::UpdateProgressText(unsigned int hrError) { int iResultCount; int iIndex; unsigned int len; @@ -530,7 +534,9 @@ void CScreensaver::UpdateProgressText() { if ( (m_statusUpdateCounter >= (STATUSUPDATEINTERVAL * BANNERFREQUENCY) ) && !m_updating_results ) { if (! m_StatusMessageUpdated) { m_statusUpdateCounter = 0; - strcpy(m_MsgBuf, BOINCNoGraphicAppsExecutingMsg); + strcpy(m_MsgBuf, hrError == SCRAPPERR_DAEMONALLOWSNOGRAPHICS ? + BOINCV5GFXDaemonMsg : BOINCNoGraphicAppsExecutingMsg + ); iResultCount = results.results.size(); theResult = NULL; diff --git a/clientscr/screensaver.cpp b/clientscr/screensaver.cpp index 1f5b4c8de7..6707066afe 100644 --- a/clientscr/screensaver.cpp +++ b/clientscr/screensaver.cpp @@ -61,6 +61,7 @@ bool CScreensaver::is_same_task(RESULT* taska, RESULT* taskb) { int CScreensaver::count_active_graphic_apps(RESULTS& results, RESULT* exclude) { unsigned int i = 0; unsigned int graphics_app_count = 0; + m_bV5_GFX_app_is_running = false; // Count the number of active graphics-capable apps excluding the specified result. // If exclude is NULL, don't exclude any results. @@ -70,8 +71,9 @@ int CScreensaver::count_active_graphic_apps(RESULTS& results, RESULT* exclude) { _T("get_random_graphics_app -- name = '%s', path = '%s'\n"), results.results[i]->name.c_str(), results.results[i]->graphics_exec_path.c_str() ); + if (results.results[i]->supports_graphics) m_bV5_GFX_app_is_running = true; if ((results.results[i]->graphics_exec_path.size() == 0) - && (!(results.results[i]->supports_graphics))) continue; + && (state.executing_as_daemon || !(results.results[i]->supports_graphics))) continue; BOINCTRACE(_T("get_random_graphics_app -- active task detected w/graphics\n")); if (is_same_task(results.results[i], exclude)) continue; @@ -116,7 +118,7 @@ RESULT* CScreensaver::get_random_graphics_app(RESULTS& results, RESULT* exclude) // Lets find the chosen graphics application. for (i = 0; i < results.results.size(); i++) { if ((results.results[i]->graphics_exec_path.size() == 0) - && (!(results.results[i]->supports_graphics))) continue; + && (state.executing_as_daemon || !(results.results[i]->supports_graphics))) continue; if (is_same_task(results.results[i], avoid)) continue; current_counter++; @@ -474,7 +476,9 @@ void *CScreensaver::DataManagementProc() { SetError(TRUE, SCRAPPERR_BOINCNOAPPSEXECUTING); } else { // We currently do not have any graphics capable application - SetError(TRUE, SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING); + SetError(TRUE, m_bV5_GFX_app_is_running ? + SCRAPPERR_DAEMONALLOWSNOGRAPHICS : SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING + ); } } } else { // End if ((m_hGraphicsApplication == 0) && (graphics_app_result_ptr == NULL)) diff --git a/clientscr/screensaver_win.h b/clientscr/screensaver_win.h index 5d79a76448..1246c24f6f 100644 --- a/clientscr/screensaver_win.h +++ b/clientscr/screensaver_win.h @@ -184,6 +184,7 @@ protected: HANDLE m_hGraphicsApplication; BOOL m_bResetCoreState; bool m_QuitDataManagementProc; + bool m_bV5_GFX_app_is_running; int m_iLastResultShown; time_t m_tLastResultChangeTime; time_t m_tThreadCreateTime; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index bb143cfb24..28bc03cbb8 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -309,6 +309,7 @@ public: GLOBAL_PREFS global_prefs; // working prefs, i.e. network + override VERSION_INFO version_info; // populated only if talking to pre-5.6 CC + bool executing_as_daemon; // true if Client is running as a service / daemon CC_STATE(); ~CC_STATE(); diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 7b7e40ebed..4444630fe4 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -608,6 +608,7 @@ void CC_STATE::clear() { delete results[i]; } results.clear(); + executing_as_daemon = false; } PROJECT* CC_STATE::lookup_project(string& str) { @@ -1065,6 +1066,7 @@ int RPC_CLIENT::get_state(CC_STATE& state) { if (parse_int(buf, "", state.version_info.major)) continue; if (parse_int(buf, "", state.version_info.minor)) continue; if (parse_int(buf, "", state.version_info.release)) continue; + if (parse_bool(buf, "executing_as_daemon", state.executing_as_daemon)) continue; if (match_tag(buf, "")) { project = new PROJECT(); project->parse(rpc.fin);