From 67c20e9fce340a3c2a8cdbe2812e9c9811a2eb77 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 9 Jul 2013 16:22:10 -0700 Subject: [PATCH] API: remove logic that makes new app graphics work with version 5 clients. --- api/boinc_api.cpp | 133 +--------------------------------------------- lib/app_ipc.cpp | 30 ----------- lib/app_ipc.h | 19 ++----- 3 files changed, 4 insertions(+), 178 deletions(-) diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp index 71238173ef..29637ef0d7 100644 --- a/api/boinc_api.cpp +++ b/api/boinc_api.cpp @@ -108,7 +108,7 @@ using std::vector; -//#define DEBUG_BOINC_API +#define DEBUG_BOINC_API #ifdef __APPLE__ #include "mac_backtrace.h" @@ -206,7 +206,6 @@ struct UPLOAD_FILE_STATUS { static bool have_new_upload_file; static std::vector upload_file_status; -static void graphics_cleanup(); static int resume_activities(); static void boinc_exit(int); static void block_sigalrm(); @@ -712,8 +711,6 @@ void boinc_exit(int status) { int retval; char buf[256]; - graphics_cleanup(); - if (options.main_program && file_lock.locked) { retval = file_lock.unlock(LOCKFILE); if (retval) { @@ -1084,122 +1081,6 @@ static void handle_process_control_msg() { } } -// The following is used by V6 apps so that graphics -// will work with pre-V6 clients. -// If we get a graphics message, run/kill the (separate) graphics app -// -// -struct GRAPHICS_APP { - bool fullscreen; -#ifdef _WIN32 - HANDLE pid; -#else - int pid; -#endif - GRAPHICS_APP(bool f) {fullscreen=f;} - void run(char* path) { - int argc; - char* argv[4]; - char abspath[MAXPATHLEN]; -#ifdef _WIN32 - GetFullPathName(path, MAXPATHLEN, abspath, NULL); -#else - strlcpy(abspath, path, sizeof(abspath)); -#endif - argv[0] = const_cast(GRAPHICS_APP_FILENAME); - if (fullscreen) { - argv[1] = const_cast("--fullscreen"); - argv[2] = 0; - argc = 2; - } else { - argv[1] = 0; - argc = 1; - } - int retval = run_program(0, abspath, argc, argv, 0, pid); - if (retval) { - pid = 0; - } - } - bool is_running() { - if (pid && process_exists(pid)) return true; - pid = 0; - return false; - } - void kill() { - if (pid) { - kill_program(pid); - pid = 0; - } - } -}; - -static GRAPHICS_APP ga_win(false), ga_full(true); -static bool have_graphics_app; - -// The following is for backwards compatibility with version 5 clients. -// -static inline void handle_graphics_messages() { - static char graphics_app_path[MAXPATHLEN]; - char buf[MSG_CHANNEL_SIZE]; - GRAPHICS_MSG m; - static bool first=true; - if (first) { - first = false; - boinc_resolve_filename( - GRAPHICS_APP_FILENAME, graphics_app_path, - sizeof(graphics_app_path) - ); - // if the above returns "graphics_app", there was no link file, - // so there's no graphics app - // - if (!strcmp(graphics_app_path, GRAPHICS_APP_FILENAME)) { - have_graphics_app = false; - } else { - have_graphics_app = true; - app_client_shm->shm->graphics_reply.send_msg( - xml_graphics_modes[MODE_HIDE_GRAPHICS] - ); - } - } - - if (!have_graphics_app) return; - - if (app_client_shm->shm->graphics_request.get_msg(buf)) { - app_client_shm->decode_graphics_msg(buf, m); - switch (m.mode) { - case MODE_HIDE_GRAPHICS: - if (ga_full.is_running()) { - ga_full.kill(); - } else if (ga_win.is_running()) { - ga_win.kill(); - } - break; - case MODE_WINDOW: - if (!ga_win.is_running()) ga_win.run(graphics_app_path); - break; - case MODE_FULLSCREEN: - if (!ga_full.is_running()) ga_full.run(graphics_app_path); - break; - case MODE_BLANKSCREEN: - // we can't actually blank the screen; just kill the app - // - if (ga_full.is_running()) { - ga_full.kill(); - } - break; - } - app_client_shm->shm->graphics_reply.send_msg( - xml_graphics_modes[m.mode] - ); - } -} - -static void graphics_cleanup() { - if (!have_graphics_app) return; - if (ga_full.is_running()) ga_full.kill(); - if (ga_win.is_running()) ga_win.kill(); -} - // timer handler; runs in the timer thread // static void timer_handler() { @@ -1238,7 +1119,6 @@ static void timer_handler() { if (options.handle_process_control) { handle_process_control_msg(); } - handle_graphics_messages(); } if (interrupt_count % TIMERS_PER_SEC) return; @@ -1278,17 +1158,6 @@ static void timer_handler() { update_app_progress(last_wu_cpu_time, last_checkpoint_cpu_time); } - // If running under V5 client, notify the client if the graphics app exits - // (e.g., if user clicked in the graphics window's close box.) - // - if (ga_win.pid) { - if (!ga_win.is_running()) { - app_client_shm->shm->graphics_reply.send_msg( - xml_graphics_modes[MODE_HIDE_GRAPHICS] - ); - } - } - if (options.handle_trickle_ups) { send_trickle_up_msg(); } diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp index 1e1162c054..631f3484f1 100644 --- a/lib/app_ipc.cpp +++ b/lib/app_ipc.cpp @@ -41,20 +41,6 @@ using std::string; -const char* xml_graphics_modes[NGRAPHICS_MSGS] = { - "", - "", - "", - "", - "", - "", - "" -}; - -GRAPHICS_MSG::GRAPHICS_MSG() { - memset(this, 0, sizeof(GRAPHICS_MSG)); -} - APP_INIT_DATA::APP_INIT_DATA() : project_preferences(NULL) { } @@ -430,22 +416,6 @@ void MSG_CHANNEL::send_msg_overwrite(const char* msg) { buf[0] = 1; } -int APP_CLIENT_SHM::decode_graphics_msg(char* msg, GRAPHICS_MSG& m) { - int i; - - parse_str(msg, "", m.window_station, sizeof(m.window_station)); - parse_str(msg, "", m.desktop, sizeof(m.desktop)); - parse_str(msg, "", m.display, sizeof(m.display)); - - m.mode = 0; - for (i=0; icore MSG_CHANNEL graphics_request; // core->app - // request a graphics mode: - // - // ... - // + // not currently used MSG_CHANNEL graphics_reply; // app->core - // same as above + // + // MSG_CHANNEL heartbeat; // core->app // sent every second, even while app is suspended @@ -120,20 +118,10 @@ struct MSG_QUEUE { #define SHM_PREFIX "shm_" #define QUIT_PREFIX "quit_" -struct GRAPHICS_MSG { - int mode; - char window_station[256]; - char desktop[256]; - char display[256]; - - GRAPHICS_MSG(); -}; - class APP_CLIENT_SHM { public: SHARED_MEM *shm; - int decode_graphics_msg(char*, GRAPHICS_MSG&); void reset_msgs(); // resets all messages and clears their flags APP_CLIENT_SHM(); @@ -252,7 +240,6 @@ int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi); // other filenames #define PROJECT_DIR "projects" -extern const char* xml_graphics_modes[NGRAPHICS_MSGS]; extern int boinc_link(const char* phys_name, const char* logical_name); extern int boinc_resolve_filename_s(const char*, std::string&); extern void url_to_project_dir(char* url, char* dir);