MGR: Populate Simple and Advanced Preference dialogs with current values of preferences (including any overrides), not with defaults or old (possibly stale) values.

svn path=/trunk/boinc/; revision=13258
This commit is contained in:
Charlie Fenton 2007-08-02 02:15:43 +00:00
parent b4241eadd6
commit cf14e1ca00
4 changed files with 64 additions and 10 deletions

View File

@ -7617,3 +7617,14 @@ David 1 Aug 2007
client/
gui_rpc_server_ops.C
cs_prefs.C
Charlie 1 Aug 2007
- MGR: Populate Simple and Advanced Preference dialogs with current
values of preferences (including any overrides), not with
defaults or old (possibly stale) values.
lib/
gui_rpc_client_ops.C
clientgui/
DlgAdvPreferences.cpp
sg_DlgPreferences.cpp

View File

@ -33,6 +33,8 @@
#include "hyperlink.h"
#include "Events.h"
using std::string;
IMPLEMENT_DYNAMIC_CLASS(CDlgAdvPreferences, wxDialog)
BEGIN_EVENT_TABLE(CDlgAdvPreferences, wxDialog)
@ -186,16 +188,18 @@ void CDlgAdvPreferences::ReadPreferenceSettings() {
m_bInInit=true;//prevent dialog handlers from doing anything
CMainDocument* pDoc = wxGetApp().GetDocument();
wxString buffer;
string current_prefs;
MIOFILE mf;
bool found_venue;
XML_PARSER xp(&mf);
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
//init prefs with defaults
prefs.defaults();
//override the global prefs with values in global_prefs_override.xml, if this file exists
mask.clear();
pDoc->rpc.get_global_prefs_override_struct(prefs, mask);
// Get current working preferences (including any overrides) from client
pDoc->rpc.get_global_prefs_working(current_prefs);
mf.init_buf_read(current_prefs.c_str());
prefs.parse(xp, "", found_venue, mask);
// ######### proc usage page
// do work between

View File

@ -36,6 +36,8 @@
#include "sg_CustomControls.h"
#include "sg_DlgPreferences.h"
using std::string;
#ifdef __WXMAC__
#define TINY_FONT 12
#define SMALL_FONT 12
@ -708,14 +710,21 @@ bool CPanelPreferences::ReadPreferenceSettings() {
double dTempValue1 = 0.0;
double dTempValue2 = 0.0;
int retval;
unsigned int i;
unsigned int i;
string current_prefs;
MIOFILE mf;
bool found_venue;
XML_PARSER xp(&mf);
wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
// Populate values and arrays from preferences
global_preferences_override = pDoc->state.global_prefs;
// Get current working preferences (including any overrides) from client
pDoc->rpc.get_global_prefs_working(current_prefs);
mf.init_buf_read(current_prefs.c_str());
global_preferences_override.parse(xp, "", found_venue, global_preferences_mask);
retval = pDoc->rpc.get_global_prefs_override_struct(global_preferences_override, global_preferences_mask);
if (!retval && global_preferences_mask.are_simple_prefs_set()) {
m_bCustomizedPreferences = true;

View File

@ -2076,12 +2076,27 @@ int RPC_CLIENT::get_global_prefs_network(string& s) {
SET_LOCALE sl;
RPC rpc(this);
char buf[1024];
bool found = false;
bool in_prefs = false;
s = "";
retval = rpc.do_rpc("<get_global_prefs_network/>");
if (retval) return retval;
while (rpc.fin.fgets(buf, 256)) {
s += buf;
if (in_prefs) {
s += buf;
if (match_tag(buf, "</global_preferences>")) {
in_prefs = false;
}
} else {
if (match_tag(buf, "<global_preferences>")) {
s += buf;
in_prefs = true;
found = true;
}
}
}
if (!found) return ERR_NOT_FOUND;
return 0;
}
@ -2090,12 +2105,27 @@ int RPC_CLIENT::get_global_prefs_working(string& s) {
SET_LOCALE sl;
RPC rpc(this);
char buf[1024];
bool found = false;
bool in_prefs = false;
s = "";
retval = rpc.do_rpc("<get_global_prefs_working/>");
if (retval) return retval;
while (rpc.fin.fgets(buf, 256)) {
s += buf;
if (in_prefs) {
s += buf;
if (match_tag(buf, "</global_preferences>")) {
in_prefs = false;
}
} else {
if (match_tag(buf, "<global_preferences>")) {
s += buf;
in_prefs = true;
found = true;
}
}
}
if (!found) return ERR_NOT_FOUND;
return 0;
}