From dd2d5bd63f6ff4ae5f312f96404219afbdaeea3b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 18 Oct 2010 20:31:27 +0000 Subject: [PATCH] - client: on startup, generate a message and notice about new client version if needed svn path=/trunk/boinc/; revision=22549 --- checkin_notes | 9 +++++ client/Makefile.am | 1 + client/acct_setup.cpp | 89 ----------------------------------------- client/acct_setup.h | 12 ------ client/client_state.cpp | 4 ++ client/client_state.h | 1 + 6 files changed, 15 insertions(+), 101 deletions(-) diff --git a/checkin_notes b/checkin_notes index fcf4623153..49757d1b22 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7472,3 +7472,12 @@ David 18 Oct 2010 gui_rpc_server.cpp log_flags.cpp main.cpp,h + +David 18 Oct 2010 + - client: on startup, generate a message and notice + about new client version if needed + + client/ + client_state.cpp,h + acct_setup.cpp,h + Makefile.am diff --git a/client/Makefile.am b/client/Makefile.am index 9f78dc2b91..84eaa0cf41 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -56,6 +56,7 @@ boinc_client_SOURCES = \ cs_scheduler.cpp \ cs_statefile.cpp \ cs_trickle.cpp \ + current_version.cpp \ dhrystone.cpp \ dhrystone2.cpp \ file_names.cpp \ diff --git a/client/acct_setup.cpp b/client/acct_setup.cpp index 851e3ff328..aa04824258 100644 --- a/client/acct_setup.cpp +++ b/client/acct_setup.cpp @@ -209,95 +209,6 @@ void CREATE_ACCOUNT_OP::handle_reply(int http_op_retval) { } } -int GET_CURRENT_VERSION_OP::do_rpc() { - int retval; - - retval = gui_http->do_rpc( - this, (char*)config.client_version_check_url.c_str(), - GET_CURRENT_VERSION_FILENAME, - true - ); - if (retval) { - error_num = retval; - } else { - error_num = ERR_IN_PROGRESS; - } - return retval; -} - -static bool is_version_newer(char* p) { - int maj=0, min=0, rel=0; - - sscanf(p, "%d.%d.%d", &maj, &min, &rel); - if (maj > gstate.core_client_version.major) return true; - if (maj < gstate.core_client_version.major) return false; - if (min > gstate.core_client_version.minor) return true; - if (min < gstate.core_client_version.minor) return false; - if (rel > gstate.core_client_version.release) return true; - return false; -} - -// Parse the output of download.php?xml=1. -// If there is a newer version for our primary platform, -// copy it to new_version and return true. -// -static bool parse_version(FILE* f, char* new_version) { - char buf[256], buf2[256]; - bool same_platform = false, newer_version = false; - while (fgets(buf, 256, f)) { - if (match_tag(buf, "")) { - return (same_platform && newer_version); - } - if (parse_str(buf, "", buf2, sizeof(buf2))) { - same_platform = (strcmp(buf2, gstate.get_primary_platform())==0); - } - if (parse_str(buf, "", buf2, sizeof(buf2))) { - newer_version = is_version_newer(buf2); - strcpy(new_version, buf2); - } - } - return false; -} - -void GET_CURRENT_VERSION_OP::handle_reply(int http_op_retval) { - char buf[256], new_version[256]; - if (http_op_retval) { - error_num = http_op_retval; - return; - } - gstate.new_version_check_time = gstate.now; - FILE* f = boinc_fopen(GET_CURRENT_VERSION_FILENAME, "r"); - if (!f) return; - while (fgets(buf, 256, f)) { - if (match_tag(buf, "")) { - if (parse_version(f, new_version)) { - msg_printf_notice(0, true, - "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=download", - "%s %s", - _("A new version of BOINC is available."), - config.client_download_url.c_str(), - _("Download it.") - ); - gstate.newer_version = string(new_version); - break; - } - } - } - fclose(f); -} - -#define NEW_VERSION_CHECK_PERIOD (14*86400) - -void CLIENT_STATE::new_version_check() { - if ((new_version_check_time == 0) || - (now - new_version_check_time > NEW_VERSION_CHECK_PERIOD)) { - // get_current_version_op.handle_reply() - // updates new_version_check_time - // - get_current_version_op.do_rpc(); - } -} - int GET_PROJECT_LIST_OP::do_rpc() { int retval; char buf[256]; diff --git a/client/acct_setup.h b/client/acct_setup.h index 1344e8c5de..533b0e5801 100644 --- a/client/acct_setup.h +++ b/client/acct_setup.h @@ -86,18 +86,6 @@ struct CREATE_ACCOUNT_OP: public GUI_HTTP_OP { virtual void handle_reply(int http_op_retval); }; -struct GET_CURRENT_VERSION_OP: public GUI_HTTP_OP { - int error_num; - - GET_CURRENT_VERSION_OP(GUI_HTTP* p){ - error_num = BOINC_SUCCESS; - gui_http = p; - } - virtual ~GET_CURRENT_VERSION_OP(){} - int do_rpc(); - virtual void handle_reply(int http_op_retval); -}; - struct GET_PROJECT_LIST_OP: public GUI_HTTP_OP { int error_num; diff --git a/client/client_state.cpp b/client/client_state.cpp index 3b93ae4348..098c4398f0 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -318,6 +318,10 @@ int CLIENT_STATE::init() { // parse_state_file(); + // inform the user if there's a newer version of client + // + newer_version_startup_check(); + // parse account files again, // now that we know the host's venue on each project // diff --git a/client/client_state.h b/client/client_state.h index b4330b0018..464f9b5fe5 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -33,6 +33,7 @@ using std::vector; #include "acct_setup.h" #include "app.h" #include "client_types.h" +#include "current_version.h" #include "file_xfer.h" #include "file_names.h" #include "gui_rpc_server.h"