account manager RPC poll function

svn path=/trunk/boinc/; revision=8018
This commit is contained in:
David Anderson 2005-09-15 00:16:55 +00:00
parent 18aa349c00
commit f33a8479b3
8 changed files with 107 additions and 28 deletions

View File

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

View File

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

View File

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

View File

@ -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(
"<acct_mgr_rpc_reply>\n"
" <error_num>%d</error_num>\n",
gstate.acct_mgr_op.error_num
);
if (gstate.acct_mgr_op.error_str.size()) {
fout.printf(
" <error_msg>%s</error_msg>\n",
gstate.acct_mgr_op.error_str.c_str()
);
}
fout.printf(
"</acct_mgr_rpc_reply>\n"
);
} else {
fout.printf(
"<acct_mgr_rpc_reply>\n"
" <error_num>0</error_num>\n"
"</acct_mgr_rpc_reply>\n"
);
}
}
static void handle_get_project_config(char* buf, MIOFILE& fout) {
string url;

View File

@ -56,7 +56,7 @@ startup of BOINC on various versions of Unix:
<a href=gentoo.txt>Gentoo Linux</a> (from Gabor Nagy)
<li>
<a href=hpux.html>HPUX</a> (mostly relevant to UNIX in general)
<li> <a href=http://rigo.altervista.org/tools/boinc-suse-1.1.tar.gz>An init script for running BOINC under SuSE Linux 9.2</a>
<li> <a href=http://rigo.altervista.org/tools/>An init script for running BOINC under SuSE Linux (9.2 and 9.3)</a>
</ul>
";

View File

@ -5,40 +5,58 @@ page_head("Logos and graphics");
echo "
The BOINC logo uses the Planet Benson font from
<a href=http://www.larabiefonts.com>Larabie Fonts</a>.
<h2>The BOINC logo</h2>
<ul>
<li>
Hi-res versions of the logo:
<a href=logo.png>PNG</a>, <a href=logo.jpg>JPEG</a>,
<a href=logo.gif>GIFF</a>.
<li>
The BOINC logo uses the Planet Benson font from
<a href=http://www.larabiefonts.com>Larabie Fonts</a>.
<p>
<li>
We like the BOINC logo but not fanatically,
and we welcome alternative ideas.
For example, Michael Peele contributed
<a href=NewBOiNC.gif>this</a>,
<a href=BOiNC3.jpg>this</a>,
and <a href=BOiNC2.png>this</a>.
<li>
Yopi at sympatico.ca contributed
<a href=boincb6.png>this</a> and
<a href=boincb7.png>this</a>.
<li>
If you have an opinion, please contact
<a href=contact.php>David Anderson</a>.
</ul>
<h2>Banners for BOINC projects</h2>
<p>
Banners for BOINC projects from Anthony Hern:
<ul>
<li> from Anthony Hern:
<a href=images/hern_logo3.gif>with</a> and
<a href=images/hern_logo4.gif>without</a> the BOINC logo.
<li>
Other banners:
<a href=images/boincheading.jpg>here</a> and
<a href=images/boincprojectheading.jpg>here</a>.
<li>
A wacky <a href=hatfield.png>BOINC graphic</a>
by high school student Jared Hatfield.
</ul>
<h2>BOINC Icons</h2>
<p>
The 'B in a circle' icon was designed by Tim Lan.
The Mac variant was contributed by Juho Viitasalo.
<p>
Check out this imaginative
<a href=hatfield.png>BOINC graphic</a>
by high school student Jared Hatfield.
<h2>Wallpaper</h2>
<ul>
<li> A submission from <a href=images/wallpaper.png>Landi Paolo</a>.
</ul>
";

View File

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

View File

@ -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, "</project_config>")) return 0;
else if (parse_int(buf, "<error_num>", 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("<acct_mgr_rpc_poll/>\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);