From f33a8479b30c45b2319aa20eb65502577876022e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 15 Sep 2005 00:16:55 +0000 Subject: [PATCH] account manager RPC poll function svn path=/trunk/boinc/; revision=8018 --- checkin_notes | 18 ++++++++++++++++++ client/acct_mgr.C | 29 ++++++++++------------------- client/acct_mgr.h | 3 ++- client/gui_rpc_server_ops.C | 25 +++++++++++++++++++++++++ doc/bare_core.php | 2 +- doc/logo.php | 32 +++++++++++++++++++++++++------- lib/gui_rpc_client.h | 7 +++++++ lib/gui_rpc_client_ops.C | 19 +++++++++++++++++++ 8 files changed, 107 insertions(+), 28 deletions(-) diff --git a/checkin_notes b/checkin_notes index 429cc65c67..b9955002d4 100755 --- a/checkin_notes +++ b/checkin_notes @@ -11787,3 +11787,21 @@ Rom 14 Sept 2005 lib/ gui_rpc_client.h gui_rpc_client_ops.C + +David 14 Sept 2005 + - The acct_mgr_rpc() GUI RPC now has a corresponding + acct_mgr_rpc_poll() GUI RPC. + The BOINC manager should use this + to find out when the RPC has finished, + and whether it succeeded. + + NOTE: this eliminates the use of MSG_ALERT_ERROR and + MSG_ALERT_INFO message types. + We can take this code out of the Manager now. + + client/ + acct_mgr.C,h + gui_rpc_server_ops.C + lib/ + gui_rpc_client.h + gui_rpc_client_ops.C diff --git a/client/acct_mgr.C b/client/acct_mgr.C index 83e04f61fd..d41bfa6591 100644 --- a/client/acct_mgr.C +++ b/client/acct_mgr.C @@ -38,17 +38,20 @@ int ACCT_MGR_OP::do_rpc(std::string url, std::string name, std::string password) strcpy(buf, url.c_str()); + error_num = ERR_IN_PROGRESS; + if (!strlen(buf) && strlen(gstate.acct_mgr_info.acct_mgr_url)) { - msg_printf(NULL, MSG_ALERT_INFO, "Removing account manager info"); + msg_printf(NULL, MSG_INFO, "Removing account manager info"); gstate.acct_mgr_info.clear(); boinc_delete_file(ACCT_MGR_URL_FILENAME); boinc_delete_file(ACCT_MGR_LOGIN_FILENAME); + error_num = 0; return 0; } canonicalize_master_url(buf); if (!valid_master_url(buf)) { - msg_printf(NULL, MSG_ALERT_ERROR, "Can't contact account manager:\n'%s' is not a valid URL", url.c_str()); + error_num = ERR_INVALID_URL; return 0; } strcpy(ami.acct_mgr_url, url.c_str()); @@ -59,10 +62,7 @@ int ACCT_MGR_OP::do_rpc(std::string url, std::string name, std::string password) sprintf(buf, "%s?name=%s&password=%s", url.c_str(), name.c_str(), password.c_str()); retval = gstate.gui_http.do_rpc(this, buf, ACCT_MGR_REPLY_FILENAME); if (retval) { - msg_printf(NULL, MSG_ALERT_ERROR, - "Can't contact account manager at '%s'.\nPlease check the URL and try again", - url.c_str() - ); + error_num = retval; return retval; } msg_printf(NULL, MSG_INFO, "Doing account manager RPC to %s", url.c_str()); @@ -118,22 +118,13 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) { } else { retval = ERR_FOPEN; } + } else if (error_str.size()) { + retval = ERR_XML_PARSE; // ?? what should we use here ?? } else { retval = http_op_retval; } - if (retval) { - msg_printf(NULL, MSG_ALERT_ERROR, - "Account manager update failed:\n%s", boincerror(retval) - ); - return; - } - - msg_printf(NULL, MSG_INFO, "Handling account manager RPC reply"); - if (error_str.size()) { - msg_printf(NULL, MSG_ALERT_ERROR, "Account manager update failed:\n%s", error_str.c_str()); - return; - } - msg_printf(NULL, MSG_ALERT_INFO, "Account manager update succeeded.\nSee Messages for more info."); + error_num = retval; + if (retval) return; gstate.acct_mgr_info = ami; gstate.acct_mgr_info.write_info(); diff --git a/client/acct_mgr.h b/client/acct_mgr.h index 89457c4fc3..c7b1c830d9 100644 --- a/client/acct_mgr.h +++ b/client/acct_mgr.h @@ -57,6 +57,7 @@ struct ACCOUNT { }; struct ACCT_MGR_OP: public GUI_HTTP_OP { + int error_num; ACCT_MGR_INFO ami; // a temporary copy while doing RPC. // CLIENT_STATE::acct_mgr_info is authoratative @@ -67,7 +68,7 @@ struct ACCT_MGR_OP: public GUI_HTTP_OP { virtual void handle_reply(int http_op_retval); ACCT_MGR_OP(){} - ~ACCT_MGR_OP(){} + virtual ~ACCT_MGR_OP(){} }; #endif diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 5dfbe90964..34c0b68a64 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -538,6 +538,31 @@ static void handle_network_available(char*, MIOFILE&) { gstate.network_available(); } +static void handle_acct_mgr_rpc_poll(char*, MIOFILE& fout) { + if (gstate.acct_mgr_op.error_num) { + fout.printf( + "\n" + " %d\n", + gstate.acct_mgr_op.error_num + ); + if (gstate.acct_mgr_op.error_str.size()) { + fout.printf( + " %s\n", + gstate.acct_mgr_op.error_str.c_str() + ); + } + fout.printf( + "\n" + ); + } else { + fout.printf( + "\n" + " 0\n" + "\n" + ); + } +} + static void handle_get_project_config(char* buf, MIOFILE& fout) { string url; diff --git a/doc/bare_core.php b/doc/bare_core.php index 710dedfa2b..e38ddbaae3 100644 --- a/doc/bare_core.php +++ b/doc/bare_core.php @@ -56,7 +56,7 @@ startup of BOINC on various versions of Unix: Gentoo Linux (from Gabor Nagy)
  • HPUX (mostly relevant to UNIX in general) -
  • An init script for running BOINC under SuSE Linux 9.2 +
  • An init script for running BOINC under SuSE Linux (9.2 and 9.3) "; diff --git a/doc/logo.php b/doc/logo.php index 20465659d1..3a8f621c5e 100644 --- a/doc/logo.php +++ b/doc/logo.php @@ -5,40 +5,58 @@ page_head("Logos and graphics"); echo " -The BOINC logo uses the Planet Benson font from -Larabie Fonts. +

    The BOINC logo

    + +

    Banners for BOINC projects

    -Banners for BOINC projects from Anthony Hern: +

    + +

    BOINC Icons

    The 'B in a circle' icon was designed by Tim Lan. The Mac variant was contributed by Juho Viitasalo.

    -Check out this imaginative -BOINC graphic -by high school student Jared Hatfield. +

    Wallpaper

    + "; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 68979f47b0..b350026c96 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -437,6 +437,12 @@ struct ACCT_MGR_INFO { int parse(MIOFILE&); }; +struct ACCT_MGR_RPC_REPLY { + int error_num; + + int parse(MIOFILE&); +}; + struct PROJECT_CONFIG { int error_num; std::string name; @@ -548,6 +554,7 @@ public: int get_host_info(HOST_INFO&); int quit(); int acct_mgr_rpc(const char* url, const char* name, const char* passwd); + int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY&); int acct_mgr_info(ACCT_MGR_INFO&); const char* mode_name(int mode); int get_statistics(PROJECTS&); diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 2171a3b2a9..7e09cbd7b5 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -778,6 +778,16 @@ int ACCT_MGR_INFO::parse(MIOFILE& in) { return ERR_XML_PARSE; } +int ACCT_MGR_RPC_REPLY::parse(MIOFILE& in) { + char buf[256]; + error_num = ERR_XML_PARSE; + while (in.fgets(buf, 256)) { + if (match_tag(buf, "")) return 0; + else if (parse_int(buf, "", error_num)) return error_num; + } + return ERR_XML_PARSE; +} + int PROJECT_CONFIG::parse(MIOFILE& in) { char buf[256]; clear(); @@ -1463,6 +1473,15 @@ int RPC_CLIENT::acct_mgr_rpc(const char* url, const char* name, const char* pass return rpc.do_rpc(buf); } +int RPC_CLIENT::acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY& r) { + RPC rpc(this); + int retval; + + retval = rpc.do_rpc("\n"); + if (retval) return retval; + return r.parse(rpc.fin); +} + int RPC_CLIENT::acct_mgr_info(ACCT_MGR_INFO& ami) { int retval; RPC rpc(this);