mirror of https://github.com/BOINC/boinc.git
Venue related GUI RPCs
svn path=/workspaces/didactylos/; revision=14784
This commit is contained in:
parent
e55f14fc41
commit
a5f3d833ad
|
@ -70,7 +70,7 @@ public:
|
|||
vector<APP_VERSION*> app_versions;
|
||||
vector<WORKUNIT*> workunits;
|
||||
vector<RESULT*> results;
|
||||
vector<GLOBAL_PREFS*> venues;
|
||||
std::deque<GLOBAL_PREFS*> venues;
|
||||
|
||||
PERS_FILE_XFER_SET* pers_file_xfers;
|
||||
HTTP_OP_SET* http_ops;
|
||||
|
|
|
@ -358,9 +358,9 @@ void CLIENT_STATE::change_global_prefs(const char* venue) {
|
|||
// copy assignment
|
||||
global_prefs = *(lookup_venue(venue));
|
||||
} else {
|
||||
// Use last venue - should be the "none" venue, but is
|
||||
// Use first venue - should be the "none" venue, but is
|
||||
// a safe fallback even if the prefs format is unexpected.
|
||||
global_prefs = **(venues.end());
|
||||
global_prefs = **(venues.begin());
|
||||
}
|
||||
|
||||
show_global_prefs_source(p_venue != 0);
|
||||
|
@ -429,7 +429,7 @@ int CLIENT_STATE::save_global_prefs(
|
|||
|
||||
GLOBAL_PREFS* CLIENT_STATE::lookup_venue(const char* venue) {
|
||||
|
||||
std::vector<GLOBAL_PREFS*>::iterator i = venues.begin();
|
||||
std::deque<GLOBAL_PREFS*>::iterator i = venues.begin();
|
||||
|
||||
while (i != venues.end()) {
|
||||
if (!strcmp(venue, (*i)->venue_name)) {
|
||||
|
|
|
@ -803,7 +803,7 @@ static void handle_get_venue(MIOFILE& fout) {
|
|||
|
||||
if (!strcmp(gstate.main_host_venue, gstate.global_prefs.venue_name)) {
|
||||
fout.printf(" <name>%s</name>\n", gstate.global_prefs.venue_name);
|
||||
fout.printf(" <description>%s</description>\n", gstate.global_prefs.get_venue_description());
|
||||
fout.printf(" <description>%s</description>\n", gstate.global_prefs.venue_description);
|
||||
} else {
|
||||
fout.printf(" <name>%s</name>\n", gstate.main_host_venue);
|
||||
}
|
||||
|
@ -814,14 +814,14 @@ static void handle_set_venue(char* buf, MIOFILE& fout) {
|
|||
MIOFILE in;
|
||||
XML_PARSER xp(&in);
|
||||
bool is_tag;
|
||||
char tag[256], venue[32];
|
||||
char tag[256], venue_name[32];
|
||||
|
||||
in.init_buf_read(buf);
|
||||
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
||||
if (!is_tag) continue;
|
||||
if (xp.parse_str(tag, "venue", venue, sizeof(venue))) {
|
||||
if (xp.parse_str(tag, "name", venue_name, sizeof(venue_name))) {
|
||||
|
||||
gstate.change_global_prefs(venue);
|
||||
gstate.change_global_prefs(venue_name);
|
||||
|
||||
fout.printf("<success/>\n");
|
||||
return;
|
||||
|
@ -833,12 +833,12 @@ static void handle_set_venue(char* buf, MIOFILE& fout) {
|
|||
static void handle_get_venue_list(MIOFILE& fout) {
|
||||
|
||||
fout.printf("<venue_list>\n");
|
||||
std::vector<GLOBAL_PREFS*>::iterator i = gstate.venues.begin();
|
||||
std::deque<GLOBAL_PREFS*>::iterator i = gstate.venues.begin();
|
||||
while (i != gstate.venues.end()) {
|
||||
|
||||
fout.printf(" <venue>\n");
|
||||
fout.printf(" <name>%s</name>\n", (*i)->venue_name);
|
||||
fout.printf(" <description>%s</description>\n", (*i)->get_venue_description());
|
||||
fout.printf(" <description>%s</description>\n", (*i)->venue_description);
|
||||
fout.printf(" </venue>\n");
|
||||
i++;
|
||||
}
|
||||
|
@ -849,14 +849,14 @@ static void handle_get_prefs_for_venue(char* buf, MIOFILE& fout) {
|
|||
MIOFILE in;
|
||||
XML_PARSER xp(&in);
|
||||
bool is_tag;
|
||||
char tag[256], venue[32];
|
||||
char tag[256], venue_name[32];
|
||||
|
||||
in.init_buf_read(buf);
|
||||
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
||||
if (!is_tag) continue;
|
||||
if (xp.parse_str(tag, "venue", venue, sizeof(venue))) {
|
||||
if (xp.parse_str(tag, "name", venue_name, sizeof(venue_name))) {
|
||||
|
||||
GLOBAL_PREFS* p_venue = gstate.lookup_venue(venue);
|
||||
GLOBAL_PREFS* p_venue = gstate.lookup_venue(venue_name);
|
||||
if (p_venue) {
|
||||
p_venue->write(fout);
|
||||
} else {
|
||||
|
@ -878,10 +878,8 @@ static void handle_set_prefs_for_venue(char* buf, MIOFILE& fout) {
|
|||
in.init_buf_read(buf);
|
||||
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
||||
if (!is_tag) continue;
|
||||
if (strstr(tag, "venue")) {
|
||||
|
||||
parse_attr(tag, "name", venue_name, sizeof(venue_name));
|
||||
|
||||
if (xp.parse_str(tag, "name", venue_name, sizeof(venue_name))) {
|
||||
|
||||
GLOBAL_PREFS venue;
|
||||
|
||||
strncpy(venue.venue_name, venue_name, sizeof(venue.venue_name));
|
||||
|
@ -918,7 +916,7 @@ static void handle_delete_prefs_for_venue(char* buf, MIOFILE& fout) {
|
|||
in.init_buf_read(buf);
|
||||
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
||||
if (!is_tag) continue;
|
||||
if (xp.parse_str(tag, "venue", venue_name, sizeof(venue_name))) {
|
||||
if (xp.parse_str(tag, "name", venue_name, sizeof(venue_name))) {
|
||||
|
||||
// TODO
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ CStatusBar::CStatusBar(wxWindow *parent) :
|
|||
const int widths[] = {-1, 150, 200, 20};
|
||||
SetFieldsCount(WXSIZEOF(widths), widths);
|
||||
|
||||
m_ptxtLocation = new wxStaticText(this, -1, _("Computer location: "), wxPoint(0, 0), wxDefaultSize, wxALIGN_LEFT);
|
||||
m_ptxtLocation = new wxStaticText(this, -1, _(""), wxPoint(0, 0), wxDefaultSize, wxALIGN_LEFT);
|
||||
wxASSERT(m_ptxtLocation);
|
||||
|
||||
m_pbmpConnected = new wxStaticBitmap(this, -1, wxIcon(connect_xpm));
|
||||
|
@ -2016,12 +2016,14 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent &event) {
|
|||
// Location status field
|
||||
m_pStatusbar->m_ptxtLocation->Show();
|
||||
|
||||
wxString strLocation = _("Computer location: ");
|
||||
strLocation << pDoc->venue;
|
||||
|
||||
if (strLocation != strCachedLocation) {
|
||||
strCachedLocation = strLocation;
|
||||
m_pStatusbar->m_ptxtLocation->SetLabel(strLocation);
|
||||
if (pDoc->IsConnected()) {
|
||||
wxString strLocation = _("Computer location: ");
|
||||
strLocation << pDoc->venue.get_venue_description();
|
||||
|
||||
if (strLocation != strCachedLocation) {
|
||||
strCachedLocation = strLocation;
|
||||
m_pStatusbar->m_ptxtLocation->SetLabel(strLocation);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
@ -157,7 +157,7 @@ public:
|
|||
CC_STATE state;
|
||||
CC_STATUS status;
|
||||
HOST_INFO host;
|
||||
std::string venue;
|
||||
VENUE venue;
|
||||
wxDateTime m_dtCachedStateTimestamp;
|
||||
|
||||
|
||||
|
|
|
@ -50,8 +50,18 @@ CPrefFrame::CPrefFrame(wxWindow* parent) : wxDialog(parent, ID_ANYDIALOG, _("Pre
|
|||
|
||||
wxStaticText* locationText = new wxStaticText(this, wxID_ANY, _("Location:"));
|
||||
|
||||
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
wxASSERT(pDoc);
|
||||
pDoc->rpc.get_venue_list(m_venues);
|
||||
|
||||
wxChoice* locationChoice = new wxChoice(this, wxID_ANY);
|
||||
locationChoice->AppendString(_("Default"));
|
||||
std::vector<VENUE>::iterator i = m_venues.begin();
|
||||
while (i != m_venues.end()) {
|
||||
locationChoice->AppendString((*i).get_venue_description());
|
||||
i++;
|
||||
}
|
||||
|
||||
locationChoice->SetSelection(0);
|
||||
|
||||
wxButton* locationManager = new wxButton(this, ID_LOCATIONMANAGER, _("Manage locations..."));
|
||||
|
|
|
@ -56,6 +56,8 @@ private:
|
|||
wxButton* m_buttonOkay;
|
||||
wxButton* m_buttonCancel;
|
||||
wxButton* m_buttonHelp;
|
||||
|
||||
std::vector<VENUE> m_venues;
|
||||
};
|
||||
|
||||
#endif // _PREFFRAME_H_
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
#include "stdwx.h"
|
||||
#include "PrefLocationManager.h"
|
||||
//#include "BOINCGUIApp.h"
|
||||
//#include "MainDocument.h"
|
||||
#include "BOINCGUIApp.h"
|
||||
#include "MainDocument.h"
|
||||
//#include "SkinManager.h"
|
||||
//#include "hyperlink.h"
|
||||
#include "Events.h"
|
||||
|
@ -45,10 +45,16 @@ CPrefLocationManager::CPrefLocationManager(wxWindow* parent) : wxDialog(parent,
|
|||
|
||||
wxListBox* list = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxSize(150, 200));
|
||||
|
||||
list->Append(_("Default"));
|
||||
list->Append(_("home"));
|
||||
list->Append(_("work"));
|
||||
list->Append(_("school"));
|
||||
std::vector<VENUE> m_venues;
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
wxASSERT(pDoc);
|
||||
pDoc->rpc.get_venue_list(m_venues);
|
||||
|
||||
std::vector<VENUE>::iterator i = m_venues.begin();
|
||||
while (i != m_venues.end()) {
|
||||
list->Append((*i).get_venue_description());
|
||||
i++;
|
||||
}
|
||||
|
||||
wxBoxSizer* tasks = new wxBoxSizer(wxVERTICAL);
|
||||
wxButton* add = new wxButton(this, wxID_ANY, _("Add"));
|
||||
|
|
|
@ -100,6 +100,8 @@ Commands:\n\
|
|||
--get_project_config_poll\n\
|
||||
--network_available\n\
|
||||
--get_cc_status\n\
|
||||
--get_venue\n\
|
||||
--set_venue [venue]\n\
|
||||
"
|
||||
);
|
||||
exit(1);
|
||||
|
@ -252,6 +254,18 @@ int main(int argc, char** argv) {
|
|||
DISK_USAGE du;
|
||||
retval = rpc.get_disk_usage(du);
|
||||
if (!retval) du.print();
|
||||
} else if (!strcmp(cmd, "--get_venue")) {
|
||||
VENUE venue;
|
||||
retval = rpc.get_venue(venue);
|
||||
if (!retval) print_venue(venue);
|
||||
} else if (!strcmp(cmd, "--set_venue")) {
|
||||
char venue[32];
|
||||
if (i < argc) {
|
||||
strncpy(venue, next_arg(argc, argv, i), sizeof(venue));
|
||||
} else {
|
||||
strcpy(venue, "");
|
||||
}
|
||||
retval = rpc.set_venue(venue);
|
||||
} else if (!strcmp(cmd, "--result")) {
|
||||
RESULT result;
|
||||
char* project_url = next_arg(argc, argv, i);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "prefs.h"
|
||||
#include "hostinfo.h"
|
||||
#include "common_defs.h"
|
||||
#include <string>
|
||||
|
||||
struct GUI_URL {
|
||||
std::string name;
|
||||
|
@ -610,7 +611,12 @@ public:
|
|||
int acct_mgr_rpc_poll(ACCT_MGR_RPC_REPLY&);
|
||||
|
||||
int get_newer_version(std::string&);
|
||||
int get_venue(std::string&);
|
||||
int get_venue(VENUE&);
|
||||
int get_venue_list(std::vector<VENUE>& venues);
|
||||
int get_prefs_for_venue(const std::string& venue, GLOBAL_PREFS& prefs);
|
||||
int set_venue(const std::string& venue);
|
||||
int set_prefs_for_venue(const std::string& venue, const GLOBAL_PREFS& prefs);
|
||||
int delete_prefs_for_venue(const std::string& venue);
|
||||
int read_global_prefs_override();
|
||||
int read_cc_config();
|
||||
int get_cc_status(CC_STATUS&);
|
||||
|
@ -645,3 +651,5 @@ struct SET_LOCALE {
|
|||
setlocale(LC_ALL, locale.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
extern void print_venue(const VENUE& venue);
|
|
@ -73,7 +73,6 @@
|
|||
#include "common_defs.h"
|
||||
#include "gui_rpc_client.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
DISPLAY_INFO::DISPLAY_INFO() {
|
||||
|
@ -611,7 +610,7 @@ void CC_STATE::clear() {
|
|||
executing_as_daemon = false;
|
||||
}
|
||||
|
||||
PROJECT* CC_STATE::lookup_project(string& str) {
|
||||
PROJECT* CC_STATE::lookup_project(std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<projects.size(); i++) {
|
||||
if (projects[i]->master_url == str) return projects[i];
|
||||
|
@ -620,7 +619,7 @@ PROJECT* CC_STATE::lookup_project(string& str) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
APP* CC_STATE::lookup_app(string& project_url, string& str) {
|
||||
APP* CC_STATE::lookup_app(std::string& project_url, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<apps.size(); i++) {
|
||||
if (apps[i]->project->master_url != project_url) continue;
|
||||
|
@ -630,7 +629,7 @@ APP* CC_STATE::lookup_app(string& project_url, string& str) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
APP* CC_STATE::lookup_app(PROJECT* project, string& str) {
|
||||
APP* CC_STATE::lookup_app(PROJECT* project, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<apps.size(); i++) {
|
||||
if (apps[i]->project != project) continue;
|
||||
|
@ -641,7 +640,7 @@ APP* CC_STATE::lookup_app(PROJECT* project, string& str) {
|
|||
}
|
||||
|
||||
APP_VERSION* CC_STATE::lookup_app_version(
|
||||
string& project_url, string& str, int version_num
|
||||
std::string& project_url, std::string& str, int version_num
|
||||
) {
|
||||
unsigned int i;
|
||||
for (i=0; i<app_versions.size(); i++) {
|
||||
|
@ -654,7 +653,7 @@ APP_VERSION* CC_STATE::lookup_app_version(
|
|||
}
|
||||
|
||||
APP_VERSION* CC_STATE::lookup_app_version(
|
||||
PROJECT* project, string& str, int version_num
|
||||
PROJECT* project, std::string& str, int version_num
|
||||
) {
|
||||
unsigned int i;
|
||||
for (i=0; i<app_versions.size(); i++) {
|
||||
|
@ -666,7 +665,7 @@ APP_VERSION* CC_STATE::lookup_app_version(
|
|||
return 0;
|
||||
}
|
||||
|
||||
WORKUNIT* CC_STATE::lookup_wu(string& project_url, string& str) {
|
||||
WORKUNIT* CC_STATE::lookup_wu(std::string& project_url, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<wus.size(); i++) {
|
||||
if (wus[i]->project->master_url != project_url) continue;
|
||||
|
@ -676,7 +675,7 @@ WORKUNIT* CC_STATE::lookup_wu(string& project_url, string& str) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
WORKUNIT* CC_STATE::lookup_wu(PROJECT* project, string& str) {
|
||||
WORKUNIT* CC_STATE::lookup_wu(PROJECT* project, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<wus.size(); i++) {
|
||||
if (wus[i]->project != project) continue;
|
||||
|
@ -686,7 +685,7 @@ WORKUNIT* CC_STATE::lookup_wu(PROJECT* project, string& str) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
RESULT* CC_STATE::lookup_result(string& project_url, string& str) {
|
||||
RESULT* CC_STATE::lookup_result(std::string& project_url, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<results.size(); i++) {
|
||||
if (results[i]->project->master_url != project_url) continue;
|
||||
|
@ -696,7 +695,7 @@ RESULT* CC_STATE::lookup_result(string& project_url, string& str) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
RESULT* CC_STATE::lookup_result(PROJECT* project, string& str) {
|
||||
RESULT* CC_STATE::lookup_result(PROJECT* project, std::string& str) {
|
||||
unsigned int i;
|
||||
for (i=0; i<results.size(); i++) {
|
||||
if (results[i]->project != project) continue;
|
||||
|
@ -1107,7 +1106,6 @@ int RPC_CLIENT::get_state(CC_STATE& state) {
|
|||
continue;
|
||||
}
|
||||
if (match_tag(buf, "<global_preferences>")) {
|
||||
bool flag = false;
|
||||
XML_PARSER xp(&rpc.fin);
|
||||
state.global_prefs.parse(xp);
|
||||
continue;
|
||||
|
@ -1953,7 +1951,7 @@ int RPC_CLIENT::get_project_config_poll(PROJECT_CONFIG& pc) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
static string get_passwd_hash(string passwd, string email_addr) {
|
||||
static std::string get_passwd_hash(std::string passwd, std::string email_addr) {
|
||||
return md5_string(passwd+email_addr);
|
||||
|
||||
}
|
||||
|
@ -1964,7 +1962,7 @@ int RPC_CLIENT::lookup_account(ACCOUNT_IN& ai) {
|
|||
RPC rpc(this);
|
||||
|
||||
downcase_string(ai.email_addr);
|
||||
string passwd_hash = get_passwd_hash(ai.passwd, ai.email_addr);
|
||||
std::string passwd_hash = get_passwd_hash(ai.passwd, ai.email_addr);
|
||||
sprintf(buf,
|
||||
"<lookup_account>\n"
|
||||
" <url>%s</url>\n"
|
||||
|
@ -2002,7 +2000,7 @@ int RPC_CLIENT::create_account(ACCOUNT_IN& ai) {
|
|||
RPC rpc(this);
|
||||
|
||||
downcase_string(ai.email_addr);
|
||||
string passwd_hash = get_passwd_hash(ai.passwd, ai.email_addr);
|
||||
std::string passwd_hash = get_passwd_hash(ai.passwd, ai.email_addr);
|
||||
sprintf(buf,
|
||||
"<create_account>\n"
|
||||
" <url>%s</url>\n"
|
||||
|
@ -2051,22 +2049,104 @@ int RPC_CLIENT::get_newer_version(std::string& version) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_venue(std::string& venue) {
|
||||
int RPC_CLIENT::get_venue(VENUE& venue) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
char buf[256];
|
||||
RPC rpc(this);
|
||||
|
||||
venue = "";
|
||||
retval = rpc.do_rpc("<get_venue/>\n");
|
||||
if (!retval) {
|
||||
while (rpc.fin.fgets(buf, 256)) {
|
||||
parse_str(buf, "<venue>", venue);
|
||||
}
|
||||
XML_PARSER xp(&rpc.fin);
|
||||
return venue.parse(xp);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_venue_list(std::vector<VENUE>& venues) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
RPC rpc(this);
|
||||
|
||||
venues.clear();
|
||||
retval = rpc.do_rpc("<get_venue_list/>\n");
|
||||
if (!retval) {
|
||||
XML_PARSER xp(&rpc.fin);
|
||||
while (!retval) {
|
||||
VENUE venue;
|
||||
retval = venue.parse(xp);
|
||||
if (!retval) {
|
||||
venues.push_back(venue);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_prefs_for_venue(const std::string& venue, GLOBAL_PREFS& prefs) {
|
||||
int retval;
|
||||
RPC rpc(this);
|
||||
char buf[256];
|
||||
|
||||
sprintf(buf,
|
||||
"<get_prefs_for_venue>\n"
|
||||
"<name>%s</name>\n"
|
||||
"</get_prefs_for_venue>\n",
|
||||
venue.c_str()
|
||||
);
|
||||
retval = rpc.do_rpc(buf);
|
||||
if (!retval) {
|
||||
XML_PARSER xp(&rpc.fin);
|
||||
return prefs.parse(xp);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::set_venue(const std::string& venue) {
|
||||
int retval;
|
||||
RPC rpc(this);
|
||||
char buf[256];
|
||||
|
||||
sprintf(buf,
|
||||
"<set_venue>\n"
|
||||
"<name>%s</name>\n"
|
||||
"</set_venue>\n",
|
||||
venue.c_str()
|
||||
);
|
||||
retval = rpc.do_rpc(buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::set_prefs_for_venue(const std::string& venue, const GLOBAL_PREFS& prefs) {
|
||||
SET_LOCALE sl;
|
||||
char buf[64000];
|
||||
MIOFILE mf;
|
||||
std::string s;
|
||||
RPC rpc(this);
|
||||
|
||||
mf.init_buf_write(buf, sizeof(buf));
|
||||
prefs.write(mf);
|
||||
|
||||
s = std::string("<set_prefs_for_venue>\n")
|
||||
+ "<name>" + venue + "</name>\n"
|
||||
+ buf
|
||||
+ "</set_prefs_for_venue>\n";
|
||||
|
||||
return rpc.do_rpc(s.c_str());
|
||||
}
|
||||
|
||||
int RPC_CLIENT::delete_prefs_for_venue(const std::string& venue) {
|
||||
RPC rpc(this);
|
||||
char buf[256];
|
||||
|
||||
sprintf(buf,
|
||||
"<delete_prefs_for_venue>\n"
|
||||
"<name>%s</name>\n"
|
||||
"</delete_prefs_for_venue>\n",
|
||||
venue.c_str()
|
||||
);
|
||||
return rpc.do_rpc(buf);
|
||||
}
|
||||
|
||||
int RPC_CLIENT::read_global_prefs_override() {
|
||||
SET_LOCALE sl;
|
||||
|
@ -2074,7 +2154,7 @@ int RPC_CLIENT::read_global_prefs_override() {
|
|||
return rpc.do_rpc("<read_global_prefs_override/>");
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_global_prefs_file(string& s) {
|
||||
int RPC_CLIENT::get_global_prefs_file(std::string& s) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
RPC rpc(this);
|
||||
|
@ -2103,7 +2183,7 @@ int RPC_CLIENT::get_global_prefs_file(string& s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_global_prefs_working(string& s) {
|
||||
int RPC_CLIENT::get_global_prefs_working(std::string& s) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
RPC rpc(this);
|
||||
|
@ -2132,13 +2212,11 @@ int RPC_CLIENT::get_global_prefs_working(string& s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int RPC_CLIENT::get_global_prefs_working_struct(GLOBAL_PREFS& prefs) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
string s;
|
||||
std::string s;
|
||||
MIOFILE mf;
|
||||
bool found_venue;
|
||||
|
||||
retval = get_global_prefs_working(s);
|
||||
if (retval) return retval;
|
||||
|
@ -2149,7 +2227,7 @@ int RPC_CLIENT::get_global_prefs_working_struct(GLOBAL_PREFS& prefs) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::get_global_prefs_override(string& s) {
|
||||
int RPC_CLIENT::get_global_prefs_override(std::string& s) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
RPC rpc(this);
|
||||
|
@ -2178,7 +2256,7 @@ int RPC_CLIENT::get_global_prefs_override(string& s) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::set_global_prefs_override(string& s) {
|
||||
int RPC_CLIENT::set_global_prefs_override(std::string& s) {
|
||||
int retval;
|
||||
RPC rpc(this);
|
||||
char buf[64000];
|
||||
|
@ -2196,9 +2274,8 @@ int RPC_CLIENT::set_global_prefs_override(string& s) {
|
|||
int RPC_CLIENT::get_global_prefs_override_struct(GLOBAL_PREFS& prefs) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
string s;
|
||||
std::string s;
|
||||
MIOFILE mf;
|
||||
bool found_venue;
|
||||
|
||||
retval = get_global_prefs_override(s);
|
||||
if (retval) return retval;
|
||||
|
@ -2213,7 +2290,7 @@ int RPC_CLIENT::set_global_prefs_override_struct(GLOBAL_PREFS& prefs) {
|
|||
SET_LOCALE sl;
|
||||
char buf[64000];
|
||||
MIOFILE mf;
|
||||
string s;
|
||||
std::string s;
|
||||
|
||||
mf.init_buf_write(buf, sizeof(buf));
|
||||
prefs.write(mf);
|
||||
|
@ -2230,12 +2307,12 @@ int RPC_CLIENT::read_cc_config() {
|
|||
return retval;
|
||||
}
|
||||
|
||||
int RPC_CLIENT::set_debts(vector<PROJECT> projects) {
|
||||
int RPC_CLIENT::set_debts(std::vector<PROJECT> projects) {
|
||||
int retval;
|
||||
SET_LOCALE sl;
|
||||
char buf[1024];
|
||||
RPC rpc(this);
|
||||
string s;
|
||||
std::string s;
|
||||
|
||||
s = "<set_debts>\n";
|
||||
for (unsigned int i=0; i<projects.size(); i++) {
|
||||
|
@ -2250,7 +2327,7 @@ int RPC_CLIENT::set_debts(vector<PROJECT> projects) {
|
|||
p.short_term_debt,
|
||||
p.long_term_debt
|
||||
);
|
||||
s += string(buf);
|
||||
s += std::string(buf);
|
||||
}
|
||||
s += "</set_debts>\n";
|
||||
retval = rpc.do_rpc(s.c_str());
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "md5_file.h"
|
||||
#include "network.h"
|
||||
#include "gui_rpc_client.h"
|
||||
#include "prefs.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
@ -284,4 +285,12 @@ void ACCOUNT_OUT::print() {
|
|||
}
|
||||
}
|
||||
|
||||
void print_venue(const VENUE& venue) {
|
||||
printf("Computer location: %s", venue.get_venue_description().c_str());
|
||||
if (strcmp(venue.venue_name, "")) {
|
||||
printf(" (%s)", venue.venue_name);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
const char *BOINC_RCSID_2bed1889d8="$Id$";
|
||||
|
|
41
lib/prefs.C
41
lib/prefs.C
|
@ -178,12 +178,12 @@ void WEEK_PREFS::unset(int day) {
|
|||
}
|
||||
}
|
||||
|
||||
int GLOBAL_PREFS::parse_file(const char* filename, std::vector<GLOBAL_PREFS*>& venues) {
|
||||
int GLOBAL_PREFS::parse_file(const char* filename, std::deque<GLOBAL_PREFS*>& venues) {
|
||||
FILE* f;
|
||||
int retval;
|
||||
|
||||
// Clear out previous venues
|
||||
std::vector<GLOBAL_PREFS*>::iterator i = venues.begin();
|
||||
std::deque<GLOBAL_PREFS*>::iterator i = venues.begin();
|
||||
|
||||
while (i != venues.end()) {
|
||||
delete *i;
|
||||
|
@ -203,7 +203,7 @@ int GLOBAL_PREFS::parse_file(const char* filename, std::vector<GLOBAL_PREFS*>& v
|
|||
|
||||
// Parses all venues (including the default nameless venue) into the supplied vector.
|
||||
// Also returns the requested venue, or the default venue if it isn't found.
|
||||
int GLOBAL_PREFS::parse_venues(XML_PARSER& xp, std::vector<GLOBAL_PREFS*>& venues) {
|
||||
int GLOBAL_PREFS::parse_venues(XML_PARSER& xp, std::deque<GLOBAL_PREFS*>& venues) {
|
||||
char tag[256];
|
||||
bool is_tag;
|
||||
|
||||
|
@ -213,7 +213,7 @@ int GLOBAL_PREFS::parse_venues(XML_PARSER& xp, std::vector<GLOBAL_PREFS*>& venue
|
|||
// parse default venue
|
||||
GLOBAL_PREFS* default_venue = new GLOBAL_PREFS();
|
||||
recursive_parse_venue(xp, default_venue, &venues);
|
||||
venues.push_back(default_venue);
|
||||
venues.push_front(default_venue);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ int GLOBAL_PREFS::parse_override(XML_PARSER& xp) {
|
|||
// xp must be positioned at the start of the structure to parse.
|
||||
// The opening tag is already consumed.
|
||||
//
|
||||
int GLOBAL_PREFS::recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::vector<GLOBAL_PREFS*>* venues) {
|
||||
int GLOBAL_PREFS::recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::deque<GLOBAL_PREFS*>* venues) {
|
||||
char tag[256];
|
||||
bool is_tag;
|
||||
double dtemp;
|
||||
|
@ -404,7 +404,7 @@ int GLOBAL_PREFS::recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const pref
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if (xp.parse_str(tag, "venue_description", prefs->venue_description, sizeof(prefs->venue_description))) continue;
|
||||
if (xp.parse_str(tag, "description", prefs->venue_description, sizeof(prefs->venue_description))) continue;
|
||||
if (xp.parse_str(tag, "source_project", prefs->source_project, sizeof(prefs->source_project))) continue;
|
||||
if (xp.parse_str(tag, "source_scheduler", prefs->source_scheduler, sizeof(prefs->source_scheduler))) {
|
||||
continue;
|
||||
|
@ -520,11 +520,11 @@ int GLOBAL_PREFS::parse_file(const char* filename) {
|
|||
// Not used for scheduler request; there, we just copy the
|
||||
// global_prefs.xml file (which includes all venues).
|
||||
//
|
||||
int GLOBAL_PREFS::write(MIOFILE& f) {
|
||||
int GLOBAL_PREFS::write(MIOFILE& f) const {
|
||||
f.printf(
|
||||
"<global_preferences>\n"
|
||||
" <mod_time>%f</mod_time>\n"
|
||||
" <venue_description>%s</venue_description>\n"
|
||||
" <description>%s</description>\n"
|
||||
"%s%s"
|
||||
" <suspend_if_no_recent_input>%f</suspend_if_no_recent_input>\n"
|
||||
" <start_hour>%f</start_hour>\n"
|
||||
|
@ -611,7 +611,7 @@ VENUE::VENUE(char* name, char* description) {
|
|||
// Get localised venue description, suitable for displaying to the user.
|
||||
// Note that this mechanism also allows venues to be renamed without affecting
|
||||
// the original name.
|
||||
std::string VENUE::get_venue_description() {
|
||||
std::string VENUE::get_venue_description() const {
|
||||
|
||||
if (strcmp(venue_description, "")) {
|
||||
return venue_description;
|
||||
|
@ -634,6 +634,29 @@ std::string VENUE::get_venue_description() {
|
|||
}
|
||||
|
||||
|
||||
int VENUE::parse(XML_PARSER& xp) {
|
||||
char tag[256];
|
||||
bool is_tag;
|
||||
bool in_venue = false;
|
||||
|
||||
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
||||
if (!is_tag) continue;
|
||||
if (!in_venue) {
|
||||
if (!strcmp(tag, "venue")) {
|
||||
in_venue = true;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(tag, "/venue")) {
|
||||
return 0;
|
||||
}
|
||||
if (xp.parse_str(tag, "name", venue_name, sizeof(venue_name))) continue;
|
||||
if (xp.parse_str(tag, "description", venue_description, sizeof(venue_description))) continue;
|
||||
}
|
||||
}
|
||||
return ERR_XML_PARSE;
|
||||
}
|
||||
|
||||
const char *BOINC_RCSID_3fb442bb02 = "$Id$";
|
||||
|
||||
|
||||
|
|
11
lib/prefs.h
11
lib/prefs.h
|
@ -97,7 +97,8 @@ public:
|
|||
char venue_name[32]; // immutable
|
||||
char venue_description[256]; // localisable, renamable, UTF-8?
|
||||
|
||||
std::string get_venue_description();
|
||||
int parse(XML_PARSER& xp);
|
||||
std::string get_venue_description() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -144,16 +145,16 @@ public:
|
|||
int parse_override(XML_PARSER&);
|
||||
int parse_file(const char* filename);
|
||||
int parse_preference_tags(XML_PARSER&);
|
||||
int write(MIOFILE&);
|
||||
int write(MIOFILE&) const;
|
||||
inline double cpu_scheduling_period() {
|
||||
return cpu_scheduling_period_minutes*60;
|
||||
}
|
||||
|
||||
static int parse_file(const char* filename, std::vector<GLOBAL_PREFS*>& venues);
|
||||
static int parse_venues(XML_PARSER& xp, std::vector<GLOBAL_PREFS*>& venues);
|
||||
static int parse_file(const char* filename, std::deque<GLOBAL_PREFS*>& venues);
|
||||
static int parse_venues(XML_PARSER& xp, std::deque<GLOBAL_PREFS*>& venues);
|
||||
|
||||
private:
|
||||
static int recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::vector<GLOBAL_PREFS*>* venues);
|
||||
static int recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::deque<GLOBAL_PREFS*>* venues);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue