Make the electron-based GUI work again.

RPC requests need to be enclosed in <boinc_gui_rpc_request>.
I'm not sure how it ever worked.

Also: improve GUI RPC error reporting in the client.
This commit is contained in:
David Anderson 2019-11-06 21:17:53 -08:00
parent 2ee3b24a98
commit 1858d1ed51
3 changed files with 32 additions and 5 deletions

View File

@ -1606,8 +1606,14 @@ GUI_RPC gui_rpcs[] = {
static int handle_rpc_aux(GUI_RPC_CONN& grc) {
int retval = 0;
grc.mfin.init_buf_read(grc.request_msg);
if (grc.xp.get_tag()) return ERR_XML_PARSE; // parse <boinc_gui_rpc_request>
if (grc.xp.get_tag()) return ERR_XML_PARSE; // parse the request tag
if (grc.xp.get_tag()) { // parse <boinc_gui_rpc_request>
grc.mfout.printf("<error>missing boing_gui_rpc_request tag</error>\n");
return 0;
}
if (grc.xp.get_tag()) { // parse the request tag
grc.mfout.printf("<error>missing request</error>\n");
return 0;
}
for (unsigned int i=0; i<sizeof(gui_rpcs)/sizeof(GUI_RPC); i++) {
GUI_RPC& gr = gui_rpcs[i];
if (!grc.xp.match_tag(gr.req_tag) && !grc.xp.match_tag(gr.alt_req_tag)) {

View File

@ -0,0 +1,19 @@
This is the beginning of an electron-based BOINC GUI.
Currently to use this you need to:
1) clone the electron "simple-samples" repo
2) copy these files to the "activity-monitor" directory
(overwrite the files that are there)
3) copy your BOINC client's gui_rpc_auth.cfg file to that directory
4) from a command prompt in that directory, do
npm install
nmp start
It should open a window with your host name, lists of projects and tasks,
and a "suspend" button.
Many things to do:
1) eliminate the need for the simple-samples repo
2) factor out the GUI RPC code into a separate file, in lib/
3) finish the GUI

View File

@ -40,10 +40,11 @@ function read_password() {
//
function gui_rpc(request) {
return new Promise(function(resolve, reject) {
request = "<boinc_gui_rpc_request>"+request+"</boinc_gui_rpc_request>"
http.onreadystatechange = function() {
if (http.readyState != 4) return;
if (http.status == 200) {
//console.log('got response: ' + http.responseText);
console.log('got response: ' + http.responseText);
resolve(http.responseText);
} else {
reject(http);
@ -86,8 +87,8 @@ function authorize() {
x = new DOMParser().parseFromString(reply, "text/xml");
auth_id = x.getElementsByTagName("auth_id")[0].childNodes[0].nodeValue;
auth_salt = x.getElementsByTagName("auth_salt")[0].childNodes[0].nodeValue;
//console.log("auth_id: "+auth_id);
//console.log("auth_salt: "+auth_salt);
console.log("auth_id: "+auth_id);
console.log("auth_salt: "+auth_salt);
});
}
@ -134,6 +135,7 @@ function show_state() {
$(() => { // shorthand for document ready
// get authorization ID
//
console.log('starting');
authorize().then(function() {
// then get state and show it
//