diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp index 2da4987866..65d747bc05 100644 --- a/client/boinc_cmd.cpp +++ b/client/boinc_cmd.cpp @@ -86,6 +86,7 @@ Commands:\n\ --run_benchmarks\n\ --set_gpu_mode mode duration set GPU run mode for given duration\n\ mode = always | auto | never\n\ + --set_host_info product_name\n\ --set_network_mode mode duration set network mode for given duration\n\ mode = always | auto | never\n\ --set_proxy_settings\n\ @@ -323,6 +324,12 @@ int main(int argc, char** argv) { } else { fprintf(stderr, "Unknown op %s\n", op); } + } else if (!strcmp(cmd, "--set_host_info")) { + HOST_INFO h; + memset(&h, 0, sizeof(h)); + char* pn = next_arg(argc, argv, i); + strcpy(h.product_name, pn); + retval = rpc.set_host_info(h); } else if (!strcmp(cmd, "--set_network_mode")) { char* op = next_arg(argc, argv, i); double duration; diff --git a/client/client_state.cpp b/client/client_state.cpp index 3d694c8452..0c6cb8a6aa 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -133,6 +133,7 @@ CLIENT_STATE::CLIENT_STATE() disable_graphics = false; cant_write_state_file = false; benchmarks_running = false; + device_status_time = 0; rec_interval_start = 0; retry_shmem_time = 0; diff --git a/client/client_state.h b/client/client_state.h index 6250bb2823..7d2af0708c 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -98,6 +98,10 @@ struct CLIENT_STATE { ACTIVE_TASK_SET active_tasks; HOST_INFO host_info; + // the following used only on Android + DEVICE_STATUS device_status; + double device_status_time; + VERSION_INFO core_client_version; string statefile_platform_name; int file_xfer_giveup_period; diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index c34b3f768d..1fa473e47b 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -373,6 +373,26 @@ static void handle_set_gpu_mode(GUI_RPC_CONN& grc) { grc.mfout.printf("\n"); } +static void handle_set_host_info(GUI_RPC_CONN& grc) { + while (!grc.xp.get_tag()) { + if (grc.xp.match_tag("host_info")) { + HOST_INFO hi; + int retval = hi.parse(grc.xp); + if (retval) { + grc.mfout.printf("host_info parse error\n"); + return; + } + if (strlen(hi.product_name)) { + strcpy(gstate.host_info.product_name, hi.product_name); + } + grc.mfout.printf("\n"); + gstate.set_client_state_dirty("set_host_info RPC"); + return; + } + } + grc.mfout.printf("Missing host_info\n"); +} + static void handle_set_network_mode(GUI_RPC_CONN& grc) { double duration = 0; bool btemp; @@ -1140,8 +1160,8 @@ static void handle_report_device_status(GUI_RPC_CONN& grc) { if (grc.xp.match_tag("device_status")) { int retval = d.parse(grc.xp); if (!retval) { - gstate.host_info.device_status = d; - gstate.host_info.device_status_time = gstate.now; + gstate.device_status = d; + gstate.device_status_time = gstate.now; grc.mfout.printf("\n"); return; } @@ -1257,6 +1277,7 @@ GUI_RPC gui_rpcs[] = { GUI_RPC("set_global_prefs_override", handle_set_global_prefs_override, true, false, false), GUI_RPC("set_gpu_mode", handle_set_gpu_mode, true, false, false), + GUI_RPC("set_host_info", handle_set_host_info, true, false, false), GUI_RPC("set_network_mode", handle_set_network_mode, true, false, false), GUI_RPC("set_proxy_settings", handle_set_proxy_settings, true, false, false), GUI_RPC("set_run_mode", handle_set_run_mode, true, false, false), diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index 432b38ba5b..12ba621b19 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -687,6 +687,7 @@ struct RPC_CLIENT { int file_transfer_op(FILE_TRANSFER&, const char*); int result_op(RESULT&, const char*); int get_host_info(HOST_INFO&); + int set_host_info(HOST_INFO&); int quit(); int acct_mgr_info(ACCT_MGR_INFO&); const char* mode_name(int mode); diff --git a/lib/gui_rpc_client_ops.cpp b/lib/gui_rpc_client_ops.cpp index b420cef1ab..d4d96a7114 100644 --- a/lib/gui_rpc_client_ops.cpp +++ b/lib/gui_rpc_client_ops.cpp @@ -2092,6 +2092,27 @@ int RPC_CLIENT::get_host_info(HOST_INFO& h) { return ERR_XML_PARSE; } +// set HOST_INFO fields that are easier to get in the GUI than in the client. +// Currently this is just the product name on Android, +// which uses a Java version of this function +// +int RPC_CLIENT::set_host_info(HOST_INFO& h) { + SET_LOCALE sl; + RPC rpc(this); + char buf[1024]; + + sprintf(buf, + "\n" + " \n" + " %s\n" + " \n" + "\n", + h.product_name + ); + int retval = rpc.do_rpc(buf); + if (retval) return retval; + return rpc.parse_reply(); +} int RPC_CLIENT::quit() { int retval; diff --git a/lib/hostinfo.cpp b/lib/hostinfo.cpp index 8b94653696..79245ac80c 100644 --- a/lib/hostinfo.cpp +++ b/lib/hostinfo.cpp @@ -68,11 +68,10 @@ void HOST_INFO::clear_host_info() { strcpy(os_name, ""); strcpy(os_version, ""); + strcpy(product_name, ""); strcpy(virtualbox_version, ""); have_cpu_opencl = false; - - device_status_time = 0; } int HOST_INFO::parse(XML_PARSER& xp, bool benchmarks_only) { @@ -94,6 +93,7 @@ int HOST_INFO::parse(XML_PARSER& xp, bool benchmarks_only) { } if (xp.parse_double("p_calculated", p_calculated)) continue; if (xp.parse_bool("p_vm_extensions_disabled", p_vm_extensions_disabled)) continue; + if (xp.parse_str("product_name", product_name, sizeof(product_name))) continue; if (benchmarks_only) continue; @@ -141,7 +141,7 @@ int HOST_INFO::parse(XML_PARSER& xp, bool benchmarks_only) { int HOST_INFO::write( MIOFILE& out, bool include_net_info, bool include_coprocs ) { - char pv[265], pm[256], pf[1024], osn[256], osv[256]; + char pv[265], pm[256], pf[1024], osn[256], osv[256], pn[256]; out.printf( "\n" " %d\n", @@ -196,6 +196,13 @@ int HOST_INFO::write( osn, osv ); + if (strlen(product_name)) { + xml_escape(product_name, pn, sizeof(pn)); + out.printf( + " %s\n", + pn + ); + } if (strlen(virtualbox_version)) { char buf[256]; xml_escape(virtualbox_version, buf, sizeof(buf)); diff --git a/lib/hostinfo.h b/lib/hostinfo.h index 8332dd43ad..a160c151ba 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -61,6 +61,8 @@ public: char os_name[256]; char os_version[256]; + char product_name[256]; // manufacturer and/or model of system + // currently used for Android devices // the following is non-empty if VBox is installed // @@ -71,10 +73,6 @@ public: bool have_cpu_opencl; OPENCL_DEVICE_PROP cpu_opencl_prop; - // the following used only on Android - DEVICE_STATUS device_status; - double device_status_time; - HOST_INFO(); int parse(XML_PARSER&, bool benchmarks_only = false); int write(MIOFILE&, bool include_net_info, bool include_coprocs);