diff --git a/client/client_state.h b/client/client_state.h index 4619d39c81..cac2e9d87f 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -70,7 +70,7 @@ public: vector app_versions; vector workunits; vector results; - vector venues; + std::deque venues; PERS_FILE_XFER_SET* pers_file_xfers; HTTP_OP_SET* http_ops; diff --git a/client/cs_prefs.C b/client/cs_prefs.C index dfba502174..e9221f1380 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -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::iterator i = venues.begin(); + std::deque::iterator i = venues.begin(); while (i != venues.end()) { if (!strcmp(venue, (*i)->venue_name)) { diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 2f160c43b1..0bc59eaab3 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -803,7 +803,7 @@ static void handle_get_venue(MIOFILE& fout) { if (!strcmp(gstate.main_host_venue, gstate.global_prefs.venue_name)) { fout.printf(" %s\n", gstate.global_prefs.venue_name); - fout.printf(" %s\n", gstate.global_prefs.get_venue_description()); + fout.printf(" %s\n", gstate.global_prefs.venue_description); } else { fout.printf(" %s\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("\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("\n"); - std::vector::iterator i = gstate.venues.begin(); + std::deque::iterator i = gstate.venues.begin(); while (i != gstate.venues.end()) { fout.printf(" \n"); fout.printf(" %s\n", (*i)->venue_name); - fout.printf(" %s\n", (*i)->get_venue_description()); + fout.printf(" %s\n", (*i)->venue_description); fout.printf(" \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 diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index ccd459dbcc..a42b481e74 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -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 { diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index a1d796641f..b3eb72d9bb 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -157,7 +157,7 @@ public: CC_STATE state; CC_STATUS status; HOST_INFO host; - std::string venue; + VENUE venue; wxDateTime m_dtCachedStateTimestamp; diff --git a/clientgui/PrefFrame.cpp b/clientgui/PrefFrame.cpp index 92ee3c209d..79fefa69b3 100644 --- a/clientgui/PrefFrame.cpp +++ b/clientgui/PrefFrame.cpp @@ -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::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...")); diff --git a/clientgui/PrefFrame.h b/clientgui/PrefFrame.h index 718761d235..6d8a7d9f66 100644 --- a/clientgui/PrefFrame.h +++ b/clientgui/PrefFrame.h @@ -56,6 +56,8 @@ private: wxButton* m_buttonOkay; wxButton* m_buttonCancel; wxButton* m_buttonHelp; + + std::vector m_venues; }; #endif // _PREFFRAME_H_ diff --git a/clientgui/PrefLocationManager.cpp b/clientgui/PrefLocationManager.cpp index 3b12b7d610..698f7783d0 100644 --- a/clientgui/PrefLocationManager.cpp +++ b/clientgui/PrefLocationManager.cpp @@ -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 m_venues; + CMainDocument* pDoc = wxGetApp().GetDocument(); + wxASSERT(pDoc); + pDoc->rpc.get_venue_list(m_venues); + + std::vector::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")); diff --git a/lib/boinc_cmd.C b/lib/boinc_cmd.C index e2fed4ace4..88e4cc4f44 100644 --- a/lib/boinc_cmd.C +++ b/lib/boinc_cmd.C @@ -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); diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index b543b11203..3ea50b0cd9 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -35,6 +35,7 @@ #include "prefs.h" #include "hostinfo.h" #include "common_defs.h" +#include 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& 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); \ No newline at end of file diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 22c4d254ae..bb9f3ba247 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -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; imaster_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; iproject->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; iproject != 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; iproject->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; iproject != 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; iproject->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; iproject != project) continue; @@ -1107,7 +1106,6 @@ int RPC_CLIENT::get_state(CC_STATE& state) { continue; } if (match_tag(buf, "")) { - 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, "\n" " %s\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, "\n" " %s\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("\n"); if (!retval) { - while (rpc.fin.fgets(buf, 256)) { - parse_str(buf, "", venue); - } + XML_PARSER xp(&rpc.fin); + return venue.parse(xp); } return retval; } +int RPC_CLIENT::get_venue_list(std::vector& venues) { + int retval; + SET_LOCALE sl; + RPC rpc(this); + + venues.clear(); + retval = rpc.do_rpc("\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, + "\n" + "%s\n" + "\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, + "\n" + "%s\n" + "\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("\n") + + "" + venue + "\n" + + buf + + "\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, + "\n" + "%s\n" + "\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(""); } -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 projects) { +int RPC_CLIENT::set_debts(std::vector projects) { int retval; SET_LOCALE sl; char buf[1024]; RPC rpc(this); - string s; + std::string s; s = "\n"; for (unsigned int i=0; i projects) { p.short_term_debt, p.long_term_debt ); - s += string(buf); + s += std::string(buf); } s += "\n"; retval = rpc.do_rpc(s.c_str()); diff --git a/lib/gui_rpc_client_print.C b/lib/gui_rpc_client_print.C index 4fd7850845..6d9ff3b1be 100644 --- a/lib/gui_rpc_client_print.C +++ b/lib/gui_rpc_client_print.C @@ -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$"; diff --git a/lib/prefs.C b/lib/prefs.C index cca94ecfae..4d9a5c1170 100644 --- a/lib/prefs.C +++ b/lib/prefs.C @@ -178,12 +178,12 @@ void WEEK_PREFS::unset(int day) { } } -int GLOBAL_PREFS::parse_file(const char* filename, std::vector& venues) { +int GLOBAL_PREFS::parse_file(const char* filename, std::deque& venues) { FILE* f; int retval; // Clear out previous venues - std::vector::iterator i = venues.begin(); + std::deque::iterator i = venues.begin(); while (i != venues.end()) { delete *i; @@ -203,7 +203,7 @@ int GLOBAL_PREFS::parse_file(const char* filename, std::vector& 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& venues) { +int GLOBAL_PREFS::parse_venues(XML_PARSER& xp, std::deque& venues) { char tag[256]; bool is_tag; @@ -213,7 +213,7 @@ int GLOBAL_PREFS::parse_venues(XML_PARSER& xp, std::vector& 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* venues) { +int GLOBAL_PREFS::recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::deque* 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( "\n" " %f\n" - " %s\n" + " %s\n" "%s%s" " %f\n" " %f\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$"; diff --git a/lib/prefs.h b/lib/prefs.h index f30a5c701e..1404421d94 100644 --- a/lib/prefs.h +++ b/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& venues); - static int parse_venues(XML_PARSER& xp, std::vector& venues); + static int parse_file(const char* filename, std::deque& venues); + static int parse_venues(XML_PARSER& xp, std::deque& venues); private: - static int recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::vector* venues); + static int recursive_parse_venue(XML_PARSER& xp, GLOBAL_PREFS* const prefs, std::deque* venues); }; #endif diff --git a/win_build/boinc_cli_curl.vcproj b/win_build/boinc_cli_curl.vcproj index d3a1ac41b0..c4e8e0361a 100644 --- a/win_build/boinc_cli_curl.vcproj +++ b/win_build/boinc_cli_curl.vcproj @@ -126,115 +126,6 @@ CommandLine="boinc_post_bld_rules.cmd "$(SolutionDir)" "$(OutDir)" "$(PlatformName)" "$(ConfigurationName)"" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -721,17 +743,6 @@ CompileAs="2" /> - - - @@ -743,17 +754,6 @@ CompileAs="2" /> - - - @@ -806,6 +806,28 @@ CompileAs="2" /> + + + + + + @@ -819,17 +841,6 @@ CompileAs="2" /> - - - @@ -841,17 +852,6 @@ CompileAs="2" /> - - - @@ -880,6 +880,28 @@ CompileAs="2" /> + + + + + + @@ -893,17 +915,6 @@ CompileAs="2" /> - - - @@ -915,17 +926,6 @@ CompileAs="2" /> - - - @@ -958,6 +958,28 @@ CompileAs="2" /> + + + + + + @@ -971,17 +993,6 @@ CompileAs="2" /> - - - @@ -993,17 +1004,6 @@ CompileAs="2" /> - - - @@ -1032,6 +1032,28 @@ CompileAs="2" /> + + + + + + @@ -1045,17 +1067,6 @@ CompileAs="2" /> - - - @@ -1067,17 +1078,6 @@ CompileAs="2" /> - - - @@ -1106,6 +1106,28 @@ CompileAs="2" /> + + + + + + @@ -1119,17 +1141,6 @@ CompileAs="2" /> - - - @@ -1141,17 +1152,6 @@ CompileAs="2" /> - - - @@ -1180,6 +1180,28 @@ CompileAs="2" /> + + + + + + @@ -1193,17 +1215,6 @@ CompileAs="2" /> - - - @@ -1215,17 +1226,6 @@ CompileAs="2" /> - - - @@ -1254,6 +1254,28 @@ CompileAs="2" /> + + + + + + @@ -1267,17 +1289,6 @@ CompileAs="2" /> - - - @@ -1289,17 +1300,6 @@ CompileAs="2" /> - - - @@ -1332,6 +1332,28 @@ CompileAs="2" /> + + + + + + @@ -1345,17 +1367,6 @@ CompileAs="2" /> - - - @@ -1367,17 +1378,6 @@ CompileAs="2" /> - - - @@ -1406,6 +1406,28 @@ CompileAs="2" /> + + + + + + @@ -1419,17 +1441,6 @@ CompileAs="2" /> - - - @@ -1441,17 +1452,6 @@ CompileAs="2" /> - - - @@ -1480,6 +1480,28 @@ CompileAs="2" /> + + + + + + @@ -1493,17 +1515,6 @@ CompileAs="2" /> - - - @@ -1515,17 +1526,6 @@ CompileAs="2" /> - - - @@ -1566,6 +1566,28 @@ CompileAs="2" /> + + + + + + @@ -1579,17 +1601,6 @@ CompileAs="2" /> - - - @@ -1601,17 +1612,6 @@ CompileAs="2" /> - - - @@ -1640,6 +1640,28 @@ CompileAs="2" /> + + + + + + @@ -1653,17 +1675,6 @@ CompileAs="2" /> - - - @@ -1675,17 +1686,6 @@ CompileAs="2" /> - - - @@ -1738,6 +1738,28 @@ CompileAs="2" /> + + + + + + @@ -1751,17 +1773,6 @@ CompileAs="2" /> - - - @@ -1773,17 +1784,6 @@ CompileAs="2" /> - - - @@ -1812,6 +1812,28 @@ CompileAs="2" /> + + + + + + @@ -1825,17 +1847,6 @@ CompileAs="2" /> - - - @@ -1847,17 +1858,6 @@ CompileAs="2" /> - - - @@ -1890,6 +1890,28 @@ CompileAs="2" /> + + + + + + @@ -1903,17 +1925,6 @@ CompileAs="2" /> - - - @@ -1925,17 +1936,6 @@ CompileAs="2" /> - - - @@ -1964,6 +1964,28 @@ CompileAs="2" /> + + + + + + @@ -1977,17 +1999,6 @@ CompileAs="2" /> - - - @@ -1999,17 +2010,6 @@ CompileAs="2" /> - - - @@ -2046,6 +2046,28 @@ CompileAs="2" /> + + + + + + @@ -2059,17 +2081,6 @@ CompileAs="2" /> - - - @@ -2081,17 +2092,6 @@ CompileAs="2" /> - - - @@ -2120,6 +2120,28 @@ CompileAs="2" /> + + + + + + @@ -2133,17 +2155,6 @@ CompileAs="2" /> - - - @@ -2155,17 +2166,6 @@ CompileAs="2" /> - - -