Changes between Initial Version and Version 1 of GuiRpc


Ignore:
Timestamp:
May 26, 2007, 2:06:36 PM (18 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GuiRpc

    v1 v1  
     1= Controlling the core client via RPC =
     2
     3The BOINC core client provides a set of RPCs (remote procedure calls) for control and state interrogation. This enables the development of GUI (graphical user interface) programs separately from the core client. These RPCs send XML request and reply messages over a TCP connection. The XML formats are not documented, but can be deduced from the source code.
     4
     5BOINC provides a C++ interface to these RPCs, consisting of the GUI_RPC class. The interface is in lib/gui_rpc_client.h, and the program boinc_cmd.C gives a usage example). All member functions return an integer error code. To create an RPC connection, call
     6{{{
     7init(char* host)
     8}}}
     9        Establish RPC connection to the given host
     10
     11== Dealing with versions ==
     12
     13The GUI RPC protocol changes over time. If you're writing a GUI program that needs to communicate with older versions of the BOINC core client, here's what to do:
     14
     15    * Create a GUI_RPC object and connect. Call exchange_versions() to get the client version.
     16    * If exchange_versions() fails (it's not suppored in pre-5.6 clients) do a get_state() RPC, and get the client version from CC_STATE::version_info.
     17    * Use the client version number to decide what subsequent RPCs to make (version info is included in the RPC list below).
     18
     19== Authorization ==
     20
     21GUI RPC authorization is described here. The RPC protocol allows the GUI program to authenticate itself using a password. Some of the RPC operations can be done without authentication; others can be done without authentication, but only by a GUI program running on the same machine.
     22{{{
     23authorize(char* password)
     24}}}
     25
     26        Do authorization sequence with the peer, using given password
     27
     28== RPC list ==
     29The following functions require authorization for remote clients, but not for local clients. Note: for core client versions 5.5.12 and earlier, all functions except get_state(), get_results(), get_screensaver_mode(), and set_screensaver_mode() require authorization.
     30{{{
     31get_state(CC_STATE&)
     32}}}
     33
     34        Get the core client's 'static' state, i.e. its projects, apps, app_versions, workunits and results. This call is relatively slow and should only be done initially, and when needed later (see below).
     35
     36{{{
     37exchange_versions(VERSION_INFO&)
     38}}}
     39
     40        Exchange version info with the core client. The core client's version info is returned.
     41
     42{{{
     43get_cc_status(CC_STATUS&);
     44struct CC_STATUS {
     45    int network_status;
     46    bool ams_password_error;
     47    int task_suspend_reason;
     48    int network_suspend_reason;
     49    int task_mode;
     50    int network_mode;
     51    int task_mode_perm;
     52    int network_mode_perm;
     53    double task_mode_delay;
     54    double network_mode_delay;
     55};
     56}}}
     57   
     58
     59        Return a structure containing the network status, a flag if there was an account manager password error, and data about task and network suspension.
     60
     61{{{
     62get_results(RESULTS&)
     63}}}
     64
     65        Get a list of results. Those that are in progress will have information such as CPU time and fraction done. Each result includes a name; use CC_STATE::lookup_result() to find this result in the current static state; if it's not there, call get_state() again.
     66
     67{{{
     68get_screensaver_mode(int& status)
     69}}}
     70
     71        Return screensaver mode (values listed in ss_logic.h)
     72
     73{{{
     74set_screensaver_mode(
     75    bool enabled, double blank_time, DISPLAY_INFO&
     76)
     77}}}
     78
     79        If enabled is true, the core client should try to get an application to provide screensaver graphics. Blank screen after blank_time seconds.
     80
     81{{{
     82get_file_transfers(FILE_TRANSFERS&)
     83}}}
     84
     85        Get a list of file transfers in progress. Each is linked by name to a project; use CC_STATE::lookup_project() to find this project in the current state; if it's not there, call get_state() again.
     86
     87{{{
     88get_simple_gui_info(SIMPLE_GUI_INFO&)
     89}}}
     90
     91        Return the list of projects and of active results.
     92
     93{{{
     94get_project_status(vector<PROJECT>&)
     95}}}
     96
     97        Get a list of projects, with only basic fields filled in.
     98
     99{{{
     100get_disk_usage(vector<PROJECT>&)
     101}}}
     102
     103        Get a list of projects, with disk usage fields filled in.
     104
     105{{{
     106get_proxy_settings(PROXY_INFO&)
     107}}}
     108
     109        Get proxy settings
     110
     111{{{
     112get_activity_state(ACTIVITY_STATE&)
     113}}}
     114
     115        Return bitmap of reasons why computation and network are suspended. Deprecated - for 5.5.13 and later, use cc_status() instead. In 5.5.10 and earlier, it returns bool (suspended) rather than bitmap.
     116
     117{{{
     118get_messages(int seqno, MESSAGES&)
     119}}}
     120
     121        Returns a list of messages to be displayed to the user. Each message has a sequence number (1, 2, ...), a priority (1=informational, 2=error) and a timestamp. The RPC requests the messages with sequence numbers greater than 'seqno', in order of increasing sequence number.
     122
     123{{{
     124get_host_info(HOST_INFO&)
     125}}}
     126
     127        Get information about host hardware and usage
     128
     129{{{
     130get_statistics(PROJECTS&)
     131}}}
     132
     133        Get information about project credit history (the PROJECT::statistics field is populated)
     134
     135{{{
     136network_status(int&)
     137}}}
     138
     139        Find whether the core client has, needs, or is done with a physical network connection. Deprecated - for 5.5.13 and later, use cc_status() instead.
     140
     141{{{
     142get_newer_versions(std::string&)
     143}}}
     144
     145        Get a string describing newer versions of the core client, if any.
     146
     147The following operations require authentication for both local and remote clients:
     148
     149{{{
     150show_graphics(char* result_name, bool full_screen)
     151}}}
     152
     153        Request that the application processing the given result create a graphics window
     154
     155{{{
     156project_op(PROJECT&, char* op)
     157}}}
     158
     159        Perform a control operation on the given project. op is one of "suspend", "resume", "reset", "detach", or "update".
     160
     161{{{
     162project_attach(
     163    char* url,
     164    char* account_id,
     165    bool use_config_file
     166)
     167}}}
     168
     169        Attach to the given project. If 'use_config_file' is true, use the project URL (and account key, if present) in the project_init.xml file.
     170
     171{{{
     172set_run_mode(int mode, double duration)
     173}}}
     174
     175        Set the run mode (never/auto/always). If duration is zero, mode is permanent. Otherwise revert to last permanent mode after duration seconds elapse.
     176
     177{{{
     178set_network_mode(int mode, double duration)
     179}}}
     180
     181        Set the network mode (never/auto/always).
     182
     183{{{
     184run_benchmarks()
     185}}}
     186
     187        Run benchmarks
     188
     189{{{
     190set_proxy_settings(PROXY_INFO&)
     191}}}
     192
     193        Set proxy settings
     194
     195{{{
     196network_available()
     197}}}
     198
     199        Tells the core client that a network connection is available, and that it should do as much network activity as it can.
     200
     201{{{
     202file_transfer_op(FILE_TRANSFER&, char* op)
     203}}}
     204
     205        Perform a control operation on a file transfer. op is one of "abort" or "retry".
     206
     207{{{
     208result_op(FILE_TRANSFER&, char* op)
     209}}}
     210
     211        Perform a control operation on an active result. op is one of "suspend", "resume", or "abort".
     212
     213{{{
     214quit()
     215}}}
     216
     217        Tell the core client to exit.
     218
     219{{{
     220acct_mgr_rpc(
     221    const char* url,
     222    const char* name,
     223    const char* passwd,
     224    bool use_cached_credentials
     225)
     226}}}
     227
     228        Do an Account Manager RPC to the given URL, passing the given name/password. If use_cached_credentials is true, then the existing url, username, and password are used and the core client updates the project information from the account manager. If the RPC is successful, save the account info on disk (it can be retrieved later using acct_mgr_info(), see below). If URL is the empty string, remove account manager info from disk.
     229
     230{{{
     231acct_mgr_info(ACCT_MGR_INFO&)
     232}}}
     233
     234        Return the URL/name of the current account manager (if any), and the user name and password.
     235
     236{{{
     237read_global_prefs_override()
     238}}}
     239
     240        Tells the core client to reread the 'global_prefs_override.xml' file, modifying the global preferences according to its contents.
     241
     242{{{
     243get_global_prefs_override(std::string&)
     244}}}
     245
     246        Reads the contents of the global preferences override file into the given string. Return an error code if the file is not present.
     247
     248{{{
     249set_global_prefs_override(std::string&)
     250}}}
     251
     252        Write the given contents to the global preferences override file. If the argment is an empty string, delete the file. Otherwise the argument must be a valid <global_preferences> element.
     253
     254{{{
     255get_global_prefs_override_struct(GLOBAL_PREFS&)
     256}}}
     257
     258        Return the contents of the global preferences override file, parsed into a structure. Default values are zero. Returns an error code if the file is not present.
     259
     260{{{
     261set_global_prefs_override_struct(GLOBAL_PREFS&)
     262}}}
     263        Convert the given structure to XML and write it to the global preferences override file.
     264
     265The RPC mechanism uses XML requests and replies. It should be easy fairly easy to generate client interfaces in languages other than C++. GUI programs connect to the core client by opening a TCP socket at port 31416. They can then do repeated RPCs over this connection. Each reply message ends with the character '\003.