Skip to content

Commit

Permalink
[wip] boincmgr(client): update clientgui using RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
winkies committed Nov 17, 2020
1 parent b5bc5eb commit 3b9abdb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/acct_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int ACCT_MGR_OP::do_rpc(ACCT_MGR_INFO& _ami, bool _via_gui) {
//
if (ami.send_tasks_all || ami.send_tasks_active) {
mf.printf("<results>\n");
gstate.write_tasks_gui(mf, !ami.send_tasks_all);
gstate.write_tasks_gui(mf, !ami.send_tasks_all, "");
mf.printf("</results>\n");
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion client/client_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ struct CLIENT_STATE {
int parse_app_info(PROJECT*, FILE*);
int write_state_gui(MIOFILE&);
int write_file_transfers_gui(MIOFILE&);
int write_tasks_gui(MIOFILE&, bool);
int write_tasks_gui(MIOFILE&, bool, const std::string&);
void sort_results();
void sort_projects_by_name();

Expand Down
14 changes: 12 additions & 2 deletions client/cs_statefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,15 +1047,25 @@ int CLIENT_STATE::write_state_gui(MIOFILE& f) {
return 0;
}

int CLIENT_STATE::write_tasks_gui(MIOFILE& f, bool active_only) {
int CLIENT_STATE::write_tasks_gui(MIOFILE& f, bool active_only, const std::string& project_name) {
unsigned int i;

if (active_only) {
for (i=0; i<active_tasks.active_tasks.size(); i++) {
RESULT* rp = active_tasks.active_tasks[i]->result;
rp->write_gui(f);
}
} else {
}
else if (!project_name.empty()) {
for (i=0; i<results.size(); i++) {
RESULT *rp = results[i];

if (!project_name.compare(results[i]->project->get_project_name())) {
rp->write_gui(f);
}
}
}
else {
for (i=0; i<results.size(); i++) {
RESULT* rp = results[i];
rp->write_gui(f);
Expand Down
9 changes: 6 additions & 3 deletions client/gui_rpc_server_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void handle_get_simple_gui_info(GUI_RPC_CONN& grc) {
PROJECT* p = gstate.projects[i];
p->write_state(grc.mfout, true);
}
gstate.write_tasks_gui(grc.mfout, true);
gstate.write_tasks_gui(grc.mfout, true, "");
grc.mfout.printf("</simple_gui_info>\n");
}

Expand Down Expand Up @@ -1286,11 +1286,14 @@ static void handle_get_old_results(GUI_RPC_CONN& grc) {

static void handle_get_results(GUI_RPC_CONN& grc) {
bool active_only = false;
std::string project_name = "";

while (!grc.xp.get_tag()) {
if (grc.xp.parse_bool("active_only", active_only)) continue;
if (grc.xp.parse_bool("active_only", active_only)
&& grc.xp.parse_string("project_name", project_name)) continue;
}
grc.mfout.printf("<results>\n");
gstate.write_tasks_gui(grc.mfout, active_only);
gstate.write_tasks_gui(grc.mfout, active_only, project_name);
grc.mfout.printf("</results>\n");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/gui_rpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ struct RPC_CLIENT {
int authorize(const char* passwd);
int exchange_versions(std::string client_name, VERSION_INFO& server);
int get_state(CC_STATE&);
int get_results(RESULTS&, bool active_only = false);
int get_results(RESULTS&, bool active_only = false, const std::string& project_name = "");
int get_old_results(std::vector<OLD_RESULT>&);
int get_file_transfers(FILE_TRANSFERS&);
int get_simple_gui_info(SIMPLE_GUI_INFO&);
Expand Down
7 changes: 4 additions & 3 deletions lib/gui_rpc_client_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,16 +1486,17 @@ int RPC_CLIENT::get_state(CC_STATE& state) {
return state.parse(rpc.xp);
}

int RPC_CLIENT::get_results(RESULTS& t, bool active_only) {
int RPC_CLIENT::get_results(RESULTS& t, bool active_only, const std::string& project_name) {
int retval;
SET_LOCALE sl;
char buf[256];
RPC rpc(this);

t.clear();

sprintf(buf, "<get_results>\n<active_only>%d</active_only>\n</get_results>\n",
active_only?1:0
sprintf(buf, "<get_results>\n<active_only>%d</active_only>\n<project_name>%s</project_name>\n</get_results>\n",
active_only?1:0,
project_name
);
retval = rpc.do_rpc(buf);
if (!retval) {
Expand Down

0 comments on commit 3b9abdb

Please sign in to comment.