gui_rpc_client.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. // This file is part of BOINC.
  2. // https://boinc.berkeley.edu
  3. // Copyright (C) 2020 University of California
  4. //
  5. // BOINC is free software; you can redistribute it and/or modify it
  6. // under the terms of the GNU Lesser General Public License
  7. // as published by the Free Software Foundation,
  8. // either version 3 of the License, or (at your option) any later version.
  9. //
  10. // BOINC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. // See the GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with BOINC. If not, see <https://www.gnu.org/licenses/>.
  17. // a C++ interface to BOINC GUI RPC
  18. #ifndef BOINC_GUI_RPC_CLIENT_H
  19. #define BOINC_GUI_RPC_CLIENT_H
  20. #ifdef _WIN32
  21. #include "boinc_win.h"
  22. #endif
  23. #include "config.h"
  24. #if !defined(_WIN32) || defined (__CYGWIN__)
  25. #include <cstdio>
  26. #include <string>
  27. #include <vector>
  28. #include <sys/socket.h>
  29. #include <sys/param.h>
  30. #include <netinet/in.h>
  31. #include <netinet/tcp.h>
  32. #include <arpa/inet.h>
  33. #include <netdb.h>
  34. #endif
  35. #include <locale.h>
  36. #include <deque>
  37. #include "cc_config.h"
  38. #include "common_defs.h"
  39. #include "filesys.h"
  40. #include "hostinfo.h"
  41. #include "keyword.h"
  42. #include "miofile.h"
  43. #include "network.h"
  44. #include "notice.h"
  45. #include "prefs.h"
  46. struct GUI_URL {
  47. std::string name;
  48. std::string description;
  49. std::string url;
  50. int parse(XML_PARSER&);
  51. void print();
  52. };
  53. // statistics at a specific day
  54. //
  55. struct DAILY_STATS {
  56. double user_total_credit;
  57. double user_expavg_credit;
  58. double host_total_credit;
  59. double host_expavg_credit;
  60. double day;
  61. int parse(XML_PARSER&);
  62. };
  63. struct PROJECT_LIST_ENTRY {
  64. std::string name;
  65. std::string url;
  66. std::string web_url;
  67. std::string general_area;
  68. std::string specific_area;
  69. std::string description;
  70. std::string home; // sponsoring organization
  71. std::string image; // URL of logo
  72. std::vector<std::string> platforms;
  73. // platforms supported by project, or empty
  74. PROJECT_LIST_ENTRY();
  75. int parse(XML_PARSER&);
  76. void clear();
  77. };
  78. struct AM_LIST_ENTRY {
  79. std::string name;
  80. std::string url;
  81. std::string description;
  82. std::string image;
  83. AM_LIST_ENTRY();
  84. int parse(XML_PARSER&);
  85. void clear();
  86. };
  87. struct ALL_PROJECTS_LIST {
  88. std::vector<PROJECT_LIST_ENTRY*> projects;
  89. std::vector<AM_LIST_ENTRY*> account_managers;
  90. ALL_PROJECTS_LIST();
  91. void clear();
  92. void alpha_sort();
  93. };
  94. struct RSC_DESC {
  95. double backoff_time;
  96. double backoff_interval;
  97. bool no_rsc_ams;
  98. bool no_rsc_apps;
  99. bool no_rsc_pref;
  100. bool no_rsc_config;
  101. void clear();
  102. };
  103. struct PROJECT {
  104. char master_url[256];
  105. double resource_share;
  106. std::string project_name;
  107. std::string user_name;
  108. std::string team_name;
  109. int hostid;
  110. std::vector<GUI_URL> gui_urls;
  111. std::string project_dir;
  112. double user_total_credit;
  113. double user_expavg_credit;
  114. double host_total_credit; // as reported by server
  115. double host_expavg_credit; // as reported by server
  116. double disk_usage;
  117. int nrpc_failures; // # of consecutive times we've failed to
  118. // contact all scheduling servers
  119. int master_fetch_failures;
  120. double min_rpc_time; // earliest time to contact any server
  121. double download_backoff;
  122. double upload_backoff;
  123. RSC_DESC rsc_desc_cpu;
  124. RSC_DESC rsc_desc_nvidia;
  125. RSC_DESC rsc_desc_ati;
  126. RSC_DESC rsc_desc_intel_gpu;
  127. double sched_priority;
  128. double duration_correction_factor;
  129. bool anonymous_platform;
  130. bool master_url_fetch_pending; // need to fetch and parse the master URL
  131. int sched_rpc_pending; // need to contact scheduling server
  132. // encodes the reason for the request
  133. bool non_cpu_intensive;
  134. bool suspended_via_gui;
  135. bool dont_request_more_work;
  136. bool scheduler_rpc_in_progress;
  137. bool attached_via_acct_mgr;
  138. bool detach_when_done;
  139. bool ended;
  140. bool trickle_up_pending;
  141. double project_files_downloaded_time;
  142. // when the last project file download was finished
  143. // (i.e. the time when ALL project files were finished downloading)
  144. double last_rpc_time;
  145. // when the last successful scheduler RPC finished
  146. std::vector<DAILY_STATS> statistics; // credit data over the last x days
  147. char venue[256];
  148. int njobs_success;
  149. int njobs_error;
  150. double elapsed_time;
  151. char external_cpid[64];
  152. // NOTE: if you add any data items above,
  153. // update parse(), and clear() to include them!!
  154. PROJECT();
  155. int parse(XML_PARSER&);
  156. void print();
  157. void print_disk_usage();
  158. void clear();
  159. void get_name(std::string&);
  160. // temp - keep track of whether or not this record needs to be deleted
  161. bool flag_for_delete;
  162. };
  163. struct APP {
  164. char name[256];
  165. char user_friendly_name[256];
  166. PROJECT* project;
  167. APP();
  168. int parse(XML_PARSER&);
  169. void print();
  170. void clear();
  171. };
  172. struct APP_VERSION {
  173. char app_name[256];
  174. int version_num;
  175. char platform[64];
  176. char plan_class[64];
  177. double avg_ncpus;
  178. int gpu_type;
  179. // PROC_TYPE_xx
  180. double gpu_usage;
  181. double natis;
  182. double gpu_ram;
  183. double flops;
  184. char exec_filename[256];
  185. APP* app;
  186. PROJECT* project;
  187. APP_VERSION();
  188. int parse(XML_PARSER&);
  189. int parse_coproc(XML_PARSER&);
  190. int parse_file_ref(XML_PARSER&);
  191. void print();
  192. void clear();
  193. };
  194. struct WORKUNIT {
  195. char name[256];
  196. char app_name[256];
  197. int version_num; // backwards compat
  198. double rsc_fpops_est;
  199. double rsc_fpops_bound;
  200. double rsc_memory_bound;
  201. double rsc_disk_bound;
  202. PROJECT* project;
  203. APP* app;
  204. JOB_KEYWORDS job_keywords;
  205. WORKUNIT();
  206. int parse(XML_PARSER&);
  207. void print();
  208. void clear();
  209. };
  210. struct RESULT {
  211. char name[256];
  212. char wu_name[256];
  213. char project_url[256];
  214. char platform[256];
  215. int version_num;
  216. char plan_class[64];
  217. double report_deadline;
  218. double received_time;
  219. bool ready_to_report;
  220. bool got_server_ack;
  221. double final_cpu_time;
  222. double final_elapsed_time;
  223. int state;
  224. int scheduler_state;
  225. int exit_status;
  226. int signal;
  227. //std::string stderr_out;
  228. bool suspended_via_gui;
  229. bool project_suspended_via_gui;
  230. bool coproc_missing;
  231. bool scheduler_wait;
  232. char scheduler_wait_reason[256];
  233. bool network_wait;
  234. // the following defined if active
  235. bool active_task;
  236. int active_task_state;
  237. int app_version_num;
  238. int slot;
  239. int pid;
  240. double checkpoint_cpu_time;
  241. double current_cpu_time;
  242. double fraction_done;
  243. double elapsed_time;
  244. double progress_rate;
  245. // avg increase in fraction done per second
  246. double swap_size;
  247. double working_set_size_smoothed;
  248. double estimated_cpu_time_remaining;
  249. // actually, estimated elapsed time remaining
  250. double bytes_sent;
  251. double bytes_received;
  252. bool too_large;
  253. bool needs_shmem;
  254. bool edf_scheduled;
  255. char graphics_exec_path[MAXPATHLEN];
  256. char web_graphics_url[256];
  257. char remote_desktop_addr[256];
  258. char slot_path[MAXPATHLEN];
  259. // only present if graphics_exec_path is
  260. char resources[256];
  261. APP* app;
  262. WORKUNIT* wup;
  263. PROJECT* project;
  264. APP_VERSION* avp;
  265. RESULT();
  266. int parse(XML_PARSER&);
  267. void print();
  268. void clear();
  269. };
  270. struct FILE_TRANSFER {
  271. std::string name;
  272. std::string project_url;
  273. std::string project_name;
  274. double nbytes; // total # of bytes to be transferred
  275. bool uploaded;
  276. bool is_upload;
  277. bool generated_locally; // deprecated; for compatibility w/ old clients
  278. bool sticky;
  279. bool pers_xfer_active;
  280. bool xfer_active;
  281. int num_retries;
  282. double first_request_time;
  283. double next_request_time;
  284. int status;
  285. double time_so_far;
  286. double bytes_xferred;
  287. double file_offset;
  288. double xfer_speed;
  289. std::string hostname;
  290. double project_backoff;
  291. PROJECT* project;
  292. FILE_TRANSFER();
  293. int parse(XML_PARSER&);
  294. void print();
  295. void clear();
  296. };
  297. struct MESSAGE {
  298. std::string project;
  299. int priority;
  300. int seqno;
  301. int timestamp;
  302. std::string body;
  303. MESSAGE();
  304. int parse(XML_PARSER&);
  305. void print();
  306. void clear();
  307. };
  308. // should match up with PROXY_INFO in proxy_info.h
  309. //
  310. struct GR_PROXY_INFO {
  311. bool use_http_proxy;
  312. bool use_http_authentication;
  313. std::string http_server_name;
  314. int http_server_port;
  315. std::string http_user_name;
  316. std::string http_user_passwd;
  317. bool use_socks_proxy;
  318. std::string socks_server_name;
  319. int socks_server_port;
  320. std::string socks5_user_name;
  321. std::string socks5_user_passwd;
  322. bool socks5_remote_dns;
  323. std::string noproxy_hosts;
  324. GR_PROXY_INFO();
  325. int parse(XML_PARSER&);
  326. void print();
  327. void clear();
  328. };
  329. // Represents the entire client state.
  330. // Call get_state() infrequently.
  331. //
  332. struct CC_STATE {
  333. std::vector<PROJECT*> projects;
  334. std::vector<APP*> apps;
  335. std::vector<APP_VERSION*> app_versions;
  336. std::vector<WORKUNIT*> wus;
  337. std::vector<RESULT*> results;
  338. std::vector<std::string> platforms;
  339. // platforms supported by client
  340. GLOBAL_PREFS global_prefs; // working prefs, i.e. network + override
  341. VERSION_INFO version_info; // populated only if talking to pre-5.6 client
  342. bool executing_as_daemon; // true if client is running as a service / daemon
  343. HOST_INFO host_info;
  344. TIME_STATS time_stats;
  345. bool have_nvidia; // deprecated; include for compat (set by <have_cuda/>)
  346. bool have_ati; // deprecated; include for compat
  347. CC_STATE();
  348. PROJECT* lookup_project(const char* url);
  349. APP* lookup_app(PROJECT*, const char* name);
  350. APP_VERSION* lookup_app_version(PROJECT*, APP*,
  351. char* platform, int vnum, char* plan_class
  352. );
  353. APP_VERSION* lookup_app_version(PROJECT*, APP*,
  354. int vnum, char* plan_class
  355. );
  356. APP_VERSION* lookup_app_version(PROJECT*, APP*, int vnum);
  357. WORKUNIT* lookup_wu(PROJECT*, const char* name);
  358. RESULT* lookup_result(PROJECT*, const char* name);
  359. RESULT* lookup_result(const char* url, const char* name);
  360. void print();
  361. void clear();
  362. int parse(XML_PARSER&);
  363. inline bool have_gpu() {
  364. return !host_info.coprocs.none()
  365. || have_nvidia || have_ati // for old clients
  366. ;
  367. }
  368. };
  369. struct PROJECTS {
  370. std::vector<PROJECT*> projects;
  371. PROJECTS(){}
  372. void print();
  373. void print_urls();
  374. void clear();
  375. };
  376. struct DISK_USAGE {
  377. std::vector<PROJECT*> projects;
  378. double d_total;
  379. double d_free;
  380. double d_boinc; // amount used by BOINC itself, not projects
  381. double d_allowed; // amount BOINC is allowed to use, total
  382. DISK_USAGE(){clear();}
  383. void print();
  384. void clear();
  385. };
  386. struct RESULTS {
  387. std::vector<RESULT*> results;
  388. RESULTS(){}
  389. void print();
  390. void clear();
  391. };
  392. struct FILE_TRANSFERS {
  393. std::vector<FILE_TRANSFER*> file_transfers;
  394. FILE_TRANSFERS();
  395. void print();
  396. void clear();
  397. };
  398. struct MESSAGES {
  399. std::deque<MESSAGE*> messages;
  400. MESSAGES();
  401. void print();
  402. void clear();
  403. };
  404. struct NOTICES {
  405. bool complete;
  406. bool received;
  407. // whether vector contains all notices, or just new ones
  408. std::vector<NOTICE*> notices;
  409. NOTICES();
  410. void print();
  411. void clear();
  412. };
  413. struct ACCT_MGR_INFO {
  414. std::string acct_mgr_name;
  415. std::string acct_mgr_url;
  416. bool have_credentials;
  417. bool cookie_required;
  418. std::string cookie_failure_url;
  419. ACCT_MGR_INFO();
  420. int parse(XML_PARSER&);
  421. void print();
  422. void clear();
  423. };
  424. struct PROJECT_ATTACH_REPLY {
  425. int error_num;
  426. std::vector<std::string>messages;
  427. PROJECT_ATTACH_REPLY();
  428. int parse(XML_PARSER&);
  429. void clear();
  430. };
  431. struct ACCT_MGR_RPC_REPLY {
  432. int error_num;
  433. std::vector<std::string>messages;
  434. ACCT_MGR_RPC_REPLY();
  435. int parse(XML_PARSER&);
  436. void clear();
  437. };
  438. struct PROJECT_INIT_STATUS {
  439. std::string url;
  440. std::string name;
  441. std::string team_name;
  442. std::string setup_cookie;
  443. bool has_account_key;
  444. bool embedded;
  445. PROJECT_INIT_STATUS();
  446. int parse(XML_PARSER&);
  447. void clear();
  448. };
  449. struct PROJECT_CONFIG {
  450. int error_num;
  451. std::string name;
  452. std::string master_url;
  453. std::string web_rpc_url_base;
  454. // prefix for create_account, lookup_account web RPCs
  455. // If absent, use the master URL
  456. int local_revision; // SVN changeset# of server software
  457. int min_passwd_length;
  458. bool account_manager;
  459. bool uses_username; // true for WCG
  460. bool account_creation_disabled;
  461. bool client_account_creation_disabled; // must create account on web
  462. bool sched_stopped; // scheduler disabled
  463. bool web_stopped; // DB-driven web functions disabled
  464. int min_client_version;
  465. std::string error_msg;
  466. bool terms_of_use_is_html;
  467. std::string terms_of_use;
  468. // if present, show this text in an "accept terms of use?" dialog
  469. // before allowing attachment to continue.
  470. std::vector<std::string> platforms;
  471. // platforms supported by project, or empty
  472. bool ldap_auth;
  473. // project supports LDAP authentication
  474. PROJECT_CONFIG();
  475. int parse(XML_PARSER&);
  476. void clear();
  477. void print();
  478. };
  479. struct ACCOUNT_IN {
  480. std::string url;
  481. // URL prefix for web RPCs
  482. std::string email_addr;
  483. // the account identifier (email address, user name, or LDAP uid)
  484. std::string user_name;
  485. std::string passwd;
  486. std::string team_name;
  487. std::string server_cookie;
  488. bool ldap_auth;
  489. bool server_assigned_cookie;
  490. bool consented_to_terms;
  491. ACCOUNT_IN();
  492. void clear();
  493. };
  494. struct ACCOUNT_OUT {
  495. int error_num;
  496. std::string error_msg;
  497. std::string authenticator;
  498. ACCOUNT_OUT();
  499. int parse(XML_PARSER&);
  500. void clear();
  501. void print();
  502. };
  503. struct CC_STATUS {
  504. int network_status; // values: NETWORK_STATUS_*
  505. bool ams_password_error;
  506. bool manager_must_quit;
  507. int task_suspend_reason; // bitmap, see common_defs.h
  508. int task_mode; // always/auto/never; see common_defs.h
  509. int task_mode_perm; // same, but permanent version
  510. double task_mode_delay; // time until perm becomes actual
  511. int gpu_suspend_reason;
  512. int gpu_mode;
  513. int gpu_mode_perm;
  514. double gpu_mode_delay;
  515. int network_suspend_reason;
  516. int network_mode;
  517. int network_mode_perm;
  518. double network_mode_delay;
  519. bool disallow_attach;
  520. bool simple_gui_only;
  521. int max_event_log_lines;
  522. CC_STATUS();
  523. int parse(XML_PARSER&);
  524. void clear();
  525. void print();
  526. };
  527. struct SIMPLE_GUI_INFO {
  528. std::vector<PROJECT*> projects;
  529. std::vector<RESULT*> results;
  530. void print();
  531. };
  532. struct DAILY_XFER {
  533. int when;
  534. double up;
  535. double down;
  536. int parse(XML_PARSER&);
  537. };
  538. struct DAILY_XFER_HISTORY {
  539. std::vector <DAILY_XFER> daily_xfers;
  540. int parse(XML_PARSER&);
  541. void print();
  542. };
  543. // Keep this consistent with client/result.h
  544. //
  545. struct OLD_RESULT {
  546. char project_url[256];
  547. char result_name[256];
  548. char app_name[256];
  549. int exit_status;
  550. double elapsed_time;
  551. double cpu_time;
  552. double completed_time;
  553. double create_time;
  554. int parse(XML_PARSER&);
  555. void print();
  556. };
  557. struct RPC_CLIENT {
  558. int sock;
  559. double start_time;
  560. double timeout;
  561. bool retry;
  562. sockaddr_storage addr;
  563. int send_request(const char*);
  564. int get_reply(char*&);
  565. RPC_CLIENT();
  566. ~RPC_CLIENT();
  567. int get_ip_addr(const char* host, int port);
  568. int init(const char* host, int port=0);
  569. int init_asynch(
  570. const char* host, double timeout, bool retry, int port=GUI_RPC_PORT
  571. );
  572. // timeout == how long to wait until give up
  573. // If the caller (i.e. BOINC Manager) just launched the core client,
  574. // this should be large enough to allow the process to
  575. // run and open its listening socket (e.g. 60 sec)
  576. // If connecting to a remote client, it should be large enough
  577. // for the user to deal with a "personal firewall" popup
  578. // (e.g. 60 sec)
  579. // retry: if true, keep retrying until succeed or timeout.
  580. // Use this if just launched the core client.
  581. int init_poll();
  582. int init_unix_domain();
  583. void close();
  584. int authorize(const char* passwd);
  585. int exchange_versions(std::string client_name, VERSION_INFO& server);
  586. int get_state(CC_STATE&);
  587. int get_results(RESULTS&, bool active_only = false);
  588. int get_old_results(std::vector<OLD_RESULT>&);
  589. int get_file_transfers(FILE_TRANSFERS&);
  590. int get_simple_gui_info(SIMPLE_GUI_INFO&);
  591. int get_project_status(PROJECTS&);
  592. int get_all_projects_list(ALL_PROJECTS_LIST&);
  593. int get_disk_usage(DISK_USAGE&);
  594. int project_op(PROJECT&, const char* op);
  595. int set_run_mode(int mode, double duration);
  596. // if duration is zero, change is permanent.
  597. // otherwise, after duration expires,
  598. // restore last permanent mode
  599. int set_gpu_mode(int mode, double duration);
  600. int set_network_mode(int mode, double duration);
  601. int get_screensaver_tasks(int& suspend_reason, RESULTS&);
  602. int run_benchmarks();
  603. int run_graphics_app(const char *operation, int& operand, const char *screensaverLoginUser);
  604. int set_proxy_settings(GR_PROXY_INFO&);
  605. int get_proxy_settings(GR_PROXY_INFO&);
  606. int get_messages(int seqno, MESSAGES&, bool translatable=false);
  607. int get_message_count(int& seqno);
  608. int get_notices(int seqno, NOTICES&);
  609. int get_notices_public(int seqno, NOTICES&);
  610. int file_transfer_op(FILE_TRANSFER&, const char*);
  611. int result_op(RESULT&, const char*);
  612. int get_host_info(HOST_INFO&);
  613. int set_host_info(HOST_INFO&);
  614. int quit();
  615. int acct_mgr_info(ACCT_MGR_INFO&);
  616. const char* mode_name(int mode);
  617. int get_statistics(PROJECTS&);
  618. int network_available();
  619. int get_project_init_status(PROJECT_INIT_STATUS& pis);
  620. int report_device_status(DEVICE_STATUS&);
  621. // the following are asynch operations.
  622. // Make the first call to start the op,
  623. // call the second one periodically until it returns zero.
  624. // TODO: do project update
  625. //
  626. int get_project_config(std::string url);
  627. int get_project_config_poll(PROJECT_CONFIG&);
  628. int lookup_account(ACCOUNT_IN&);
  629. int lookup_account_poll(ACCOUNT_OUT&);
  630. int create_account(ACCOUNT_IN&);
  631. int create_account_poll(ACCOUNT_OUT&);
  632. int project_attach(
  633. const char* url, const char* auth, const char* project_name
  634. );
  635. int project_attach_from_file();
  636. int project_attach_poll(PROJECT_ATTACH_REPLY&);
  637. int acct_mgr_rpc(
  638. const char* url, const char* name, const char* passwd,
  639. bool use_config_file=false
  640. );
  641. int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY&);
  642. int get_newer_version(std::string&, std::string&);
  643. int read_global_prefs_override();
  644. int read_cc_config();
  645. int get_cc_status(CC_STATUS&);
  646. int get_global_prefs_file(std::string&);
  647. int get_global_prefs_working(std::string&);
  648. int get_global_prefs_working_struct(GLOBAL_PREFS&, GLOBAL_PREFS_MASK&);
  649. int get_global_prefs_override(std::string&);
  650. int set_global_prefs_override(std::string&);
  651. int get_global_prefs_override_struct(GLOBAL_PREFS&, GLOBAL_PREFS_MASK&);
  652. int set_global_prefs_override_struct(GLOBAL_PREFS&, GLOBAL_PREFS_MASK&);
  653. int get_cc_config(CC_CONFIG& config, LOG_FLAGS& log_flags);
  654. int set_cc_config(CC_CONFIG& config, LOG_FLAGS& log_flags);
  655. int get_app_config(const char* url, APP_CONFIGS& conf);
  656. int set_app_config(const char* url, APP_CONFIGS& conf);
  657. int get_daily_xfer_history(DAILY_XFER_HISTORY&);
  658. int set_language(const char*);
  659. };
  660. struct RPC {
  661. char* mbuf;
  662. MIOFILE fin;
  663. XML_PARSER xp;
  664. RPC_CLIENT* rpc_client;
  665. RPC(RPC_CLIENT*);
  666. ~RPC();
  667. int do_rpc(const char*);
  668. int parse_reply();
  669. };
  670. #if defined(HAVE__CONFIGTHREADLOCALE) || defined(HAVE_USELOCALE)
  671. // no-op, the calling thread is already set to use C locale
  672. struct SET_LOCALE {
  673. SET_LOCALE() {}
  674. ~SET_LOCALE() {}
  675. };
  676. #else
  677. struct SET_LOCALE {
  678. std::string old_locale;
  679. SET_LOCALE() {
  680. old_locale = setlocale(LC_ALL, NULL);
  681. setlocale(LC_ALL, "C");
  682. }
  683. ~SET_LOCALE() {
  684. setlocale(LC_ALL, old_locale.c_str());
  685. }
  686. };
  687. #endif
  688. extern int read_gui_rpc_password(char*, std::string&);
  689. #endif // BOINC_GUI_RPC_CLIENT_H