- client: on startup, generate a message and notice

about new client version if needed

svn path=/trunk/boinc/; revision=22549
This commit is contained in:
David Anderson 2010-10-18 20:31:27 +00:00
parent 33713781d1
commit dd2d5bd63f
6 changed files with 15 additions and 101 deletions

View File

@ -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

View File

@ -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 \

View File

@ -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, "</version>")) {
return (same_platform && newer_version);
}
if (parse_str(buf, "<dbplatform>", buf2, sizeof(buf2))) {
same_platform = (strcmp(buf2, gstate.get_primary_platform())==0);
}
if (parse_str(buf, "<version_num>", 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, "<version>")) {
if (parse_version(f, new_version)) {
msg_printf_notice(0, true,
"http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=download",
"%s <a href=%s>%s</a>",
_("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];

View File

@ -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;

View File

@ -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
//

View File

@ -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"