diff --git a/checkin_notes b/checkin_notes index 78a053e09d..b12f2d8773 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5345,3 +5345,17 @@ David 24 May 2007 api/ texfont.C (changed c to C) Makefile.am + +David 26 May 2007 + - Add GUI RPC to set projects debts (short and long term). + Lets you set all of them at once, as suggested by Nicolas Alvarez. + fixes #131 + + client/ + gui_rpc_server_ops.C + html/user/ + sample_index.php + lib/ + boinc_cmd.C + gui_rpc_client.h + gui_rpc_client_ops.C diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 9915f7cb27..08f6fcf370 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -45,6 +45,7 @@ #endif #include "str_util.h" +#include "client_state.h" #include "util.h" #include "error_numbers.h" #include "parse.h" @@ -182,7 +183,7 @@ static void handle_result_show_graphics(char* buf, MIOFILE& fout) { GRAPHICS_MSG gm; ACTIVE_TASK* atp; - if (match_tag(buf, "")) { + if (match_tag(buf, "")) { gm.mode = MODE_FULLSCREEN; } else if (match_tag(buf, "")) { gm.mode = MODE_HIDE_GRAPHICS; @@ -518,13 +519,13 @@ static void handle_set_screensaver_mode(char* buf, MIOFILE& fout) { parse_str(buf, "", gm.window_station, sizeof(gm.window_station)); parse_str(buf, "", gm.display, sizeof(gm.display)); if (match_tag(buf, "au_mgr_state == AU_MGR_QUIT_REQ) { fout.printf( @@ -873,6 +874,58 @@ static void read_all_projects_list_file(MIOFILE& fout) { } } +static int set_debt(XML_PARSER& xp) { + bool is_tag; + char tag[256], url[256]; + double short_term_debt, long_term_debt; + bool got_std=false, got_ltd=false; + strcpy(url, ""); + while (!xp.get(tag, sizeof(tag), is_tag)) { + if (!strcmp(tag, "/project")) { + if (!strlen(url)) return ERR_XML_PARSE; + PROJECT* p = gstate.lookup_project(url); + if (!p) return ERR_NOT_FOUND; + if (got_std) p->short_term_debt = short_term_debt; + if (got_ltd) p->long_term_debt = long_term_debt; + return 0; + } + if (xp.parse_str(tag, "master_url", url, sizeof(url))) continue; + if (xp.parse_double(tag, "short_term_debt", short_term_debt)) { + got_std = true; + continue; + } + if (xp.parse_double(tag, "long_term_debt", long_term_debt)) { + got_ltd = true; + continue; + } + } +} + +static void handle_set_debts(char* buf, MIOFILE& fout) { + MIOFILE in; + XML_PARSER xp(&in); + bool is_tag; + char tag[256]; + int retval; + + in.init_buf_read(buf); + while (!xp.get(tag, sizeof(tag), is_tag)) { + if (!is_tag) continue; + if (!strcmp(tag, "/set_debts")) { + fout.printf("\n"); + gstate.set_client_state_dirty("set_debt RPC"); + break; + } + if (!strcmp(tag, "project")) { + retval = set_debt(xp); + if (retval) { + fout.printf("%d\n", retval); + return; + } + } + } +} + static void handle_set_cc_config(char* buf, MIOFILE& fout) { char *p, *q=0; int retval = ERR_XML_PARSE; @@ -1036,6 +1089,8 @@ int GUI_RPC_CONN::handle_rpc() { gstate.request_work_fetch("Core client configuration"); } else if (match_tag(request_msg, "")) { read_all_projects_list_file(mf); + } else if (match_tag(request_msg, "unrecognized op\n"); diff --git a/html/user/sample_index.php b/html/user/sample_index.php index 2f12e0e67d..25fffcfb77 100644 --- a/html/user/sample_index.php +++ b/html/user/sample_index.php @@ -22,12 +22,11 @@ function show_nav() { You can participate by downloading and running a free program on your computer.

- XXX is based at research lab of Professor XXX - at the University of XXX. + XXX is based at + [describe your institution, with link to web page]

Join ".PROJECT."

Community

    diff --git a/lib/boinc_cmd.C b/lib/boinc_cmd.C index 8ab029c70e..faceeb0d84 100644 --- a/lib/boinc_cmd.C +++ b/lib/boinc_cmd.C @@ -95,6 +95,7 @@ Commands:\n\ --read_cc_config\n\ --network_available\n\ --get_cc_status\n\ + --set_debts URL1 std1 ltd1 [URL2 std2 ltd2 ...]\n\ --quit\n" ); exit(1); @@ -498,40 +499,27 @@ int main(int argc, char** argv) { retval = rpc.read_global_prefs_override(); } else if (!strcmp(cmd, "--read_cc_config")) { retval = rpc.read_cc_config(); - } else if (!strcmp(cmd, "--test1")) { - string s; - retval = rpc.get_global_prefs_override(s); - printf("retval: %d\nprefs:\n%s\n", retval, s.c_str()); - } else if (!strcmp(cmd, "--test2")) { - string s = "foobar"; - retval = rpc.set_global_prefs_override(s); - printf("retval: %d\n", retval); - } else if (!strcmp(cmd, "--test3")) { - GLOBAL_PREFS gp; - GLOBAL_PREFS_MASK mask; - memset(&gp, 0, sizeof(gp)); - mask.clear(); - retval = rpc.get_global_prefs_override_struct(gp, mask); - printf("retval %d max %d\n", retval, gp.max_cpus); - } else if (!strcmp(cmd, "--test4")) { - GLOBAL_PREFS gp; - GLOBAL_PREFS_MASK m; - gp.max_cpus = 2; - m.max_cpus = true; - retval = rpc.set_global_prefs_override_struct(gp, m); printf("retval %d\n", retval); - } else if (!strcmp(cmd, "--quit")) { - retval = rpc.quit(); - } else if (!strcmp(cmd, "read_cc_config")) { - retval = rpc.read_cc_config(); - } else if (!strcmp(cmd, "network_available")) { + } else if (!strcmp(cmd, "--network_available")) { retval = rpc.network_available(); - } else if (!strcmp(cmd, "get_cc_status")) { + } else if (!strcmp(cmd, "--get_cc_status")) { CC_STATUS cs; retval = rpc.get_cc_status(cs); if (!retval) { retval = cs.network_status; } + } else if (!strcmp(cmd, "--set_debts")) { + vectorprojects; + while (i < argc) { + PROJECT p; + p.master_url = string(next_arg(argc, argv, i)); + p.short_term_debt = atoi(next_arg(argc, argv, i)); + p.long_term_debt = atoi(next_arg(argc, argv, i)); + projects.push_back(p); + } + retval = rpc.set_debts(projects); + } else if (!strcmp(cmd, "--quit")) { + retval = rpc.quit(); } else { fprintf(stderr, "unrecognized command %s\n", cmd); } diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index ca23d68666..0f2f0a4e47 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -612,6 +612,7 @@ public: int set_global_prefs_override(std::string&); int get_global_prefs_override_struct(GLOBAL_PREFS&, GLOBAL_PREFS_MASK&); int set_global_prefs_override_struct(GLOBAL_PREFS&, GLOBAL_PREFS_MASK&); + int set_debts(std::vector); }; struct RPC { diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 9811ec0332..d3f3e4fe09 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -2216,4 +2216,32 @@ int RPC_CLIENT::read_cc_config() { return retval; } +int RPC_CLIENT::set_debts(vector projects) { + int retval; + SET_LOCALE sl; + char buf[64000], buf2[1024]; + RPC rpc(this); + string s; + + s = "\n"; + for (unsigned int i=0; i\n" + " %s\n" + " %f\n" + " %f\n" + " \n", + p.master_url.c_str(), + p.short_term_debt, + p.long_term_debt + ); + s += string(buf2); + } + s += "\n"; + retval = rpc.do_rpc(s.c_str()); + return retval; +} + + const char *BOINC_RCSID_90e8b8d168="$Id$";