diff --git a/checkin_notes b/checkin_notes index 64966c3c2f..d2957d2b5c 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2675,3 +2675,17 @@ David 28 Apr 2011 client/ acct_mgr.cpp + +Charlie 29 Apr 2011 + - MGR: Continue adding Exclusive Apps pane to Computing Prefs dialog. + - lib: add missing items in CONFIG, PROXY_INFO struct initializers. + + client/ + log_flags.cpp,.h + clientgui/ + DlgAdvPreferences.cpp,.h + DlgAdvPreferencesBase.cpp + lib/ + cc_config.cpp,.h + gui_rpc_client_ops.cpp + proxy_info.cpp diff --git a/client/log_flags.cpp b/client/log_flags.cpp index b32a77b7a5..dab25d98a7 100644 --- a/client/log_flags.cpp +++ b/client/log_flags.cpp @@ -111,54 +111,6 @@ static void show_gpu_ignore(vector& devs, const char* name) { } } -// this is called first thing by client -// -void CONFIG::defaults() { - abort_jobs_on_exit = false; - allow_multiple_clients = false; - allow_remote_gui_rpc = false; - alt_platforms.clear(); - client_version_check_url = "http://boinc.berkeley.edu/download.php?xml=1"; - client_download_url = "http://boinc.berkeley.edu/download.php"; - disallow_attach = false; - dont_check_file_sizes = false; - dont_contact_ref_site = false; - exclusive_apps.clear(); - exclusive_gpu_apps.clear(); - exit_after_finish = false; - exit_when_idle = false; - fetch_minimal_work = false; - force_auth = "default"; - http_1_0 = false; - ignore_cuda_dev.clear(); - ignore_ati_dev.clear(); - max_file_xfers = MAX_FILE_XFERS; - max_file_xfers_per_project = MAX_FILE_XFERS_PER_PROJECT; - max_stderr_file_size = 0; - max_stdout_file_size = 0; - max_tasks_reported = 0; - ncpus = -1; - network_test_url = "http://www.google.com/"; - no_alt_platform = false; - no_gpus = false; - no_info_fetch = false; - no_priority_change = false; - os_random_only = false; - report_results_immediately = false; - run_apps_manually = false; - save_stats_days = 30; - simple_gui_only = false; - skip_cpu_benchmarks = false; - start_delay = 0; - stderr_head = false; - suppress_net_info = false; - unsigned_apps_ok = false; - use_all_gpus = false; - use_certs = false; - use_certs_only = false; - zero_debts = false; -} - // TODO: show other config options // void CONFIG::show() { diff --git a/client/log_flags.h b/client/log_flags.h index a9b5eebffb..83f3e771fc 100644 --- a/client/log_flags.h +++ b/client/log_flags.h @@ -34,10 +34,6 @@ #include "file_names.h" #include "cc_config.h" -#define MAX_FILE_XFERS_PER_PROJECT 2 -#define MAX_FILE_XFERS 8 - // kind of arbitrary - extern LOG_FLAGS log_flags; extern CONFIG config; extern int read_config_file(bool init, const char* fname=CONFIG_FILE); diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index d375ca9d82..2d42714b52 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -43,7 +43,11 @@ BEGIN_EVENT_TABLE(CDlgAdvPreferences, wxDialog) EVT_COMMAND_RANGE(20000,21000,wxEVT_COMMAND_CHECKBOX_CLICKED,CDlgAdvPreferences::OnHandleCommandEvent) EVT_COMMAND_RANGE(20000,21000,wxEVT_COMMAND_RADIOBUTTON_SELECTED,CDlgAdvPreferences::OnHandleCommandEvent) EVT_COMMAND_RANGE(20000,21000,wxEVT_COMMAND_TEXT_UPDATED,CDlgAdvPreferences::OnHandleCommandEvent) + // list box + EVT_COMMAND(ID_LISTBOX_EXCLAPPS,wxEVT_COMMAND_LISTBOX_SELECTED,CDlgAdvPreferences::OnExclusiveAppListEvent) //buttons + EVT_BUTTON(ID_ADDEXCLUSIVEAPPBUTTON,CDlgAdvPreferences::OnAddExclusiveApp) + EVT_BUTTON(ID_REMOVEEXCLUSIVEAPPBUTTON,CDlgAdvPreferences::OnRemoveExclusiveApp) EVT_BUTTON(wxID_OK,CDlgAdvPreferences::OnOK) EVT_BUTTON(ID_HELPBOINC,CDlgAdvPreferences::OnHelp) EVT_BUTTON(ID_BTN_CLEAR,CDlgAdvPreferences::OnClear) @@ -56,7 +60,8 @@ CDlgAdvPreferences::CDlgAdvPreferences(wxWindow* parent) : CDlgAdvPreferencesBas wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); m_bInInit=false; - m_bDataChanged=false; + m_bPrefsDataChanged=false; + m_bExclusiveAppsDataChanged=false; m_arrTabPageIds.Add(ID_TABPAGE_PROC); m_arrTabPageIds.Add(ID_TABPAGE_NET); m_arrTabPageIds.Add(ID_TABPAGE_DISK); @@ -84,6 +89,9 @@ CDlgAdvPreferences::CDlgAdvPreferences(wxWindow* parent) : CDlgAdvPreferencesBas //setting warning bitmap m_bmpWarning->SetBitmap(wxBitmap(warning_xpm)); + + m_removeExclusiveAppButton->Disable(); + // init special tooltips SetSpecialTooltips(); //setting the validators for correct input handling @@ -203,12 +211,12 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { wxASSERT(wxDynamicCast(pDoc, CMainDocument)); // Get current working preferences (including any overrides) from client - retval = pDoc->rpc.get_global_prefs_working_struct(prefs, mask); - if (retval == ERR_NOT_FOUND) { - // Older clients don't support get_global_prefs_working_struct RPC - prefs = pDoc->state.global_prefs; - pDoc->rpc.get_global_prefs_override_struct(prefs, mask); - } + retval = pDoc->rpc.get_global_prefs_working_struct(prefs, mask); + if (retval == ERR_NOT_FOUND) { + // Older clients don't support get_global_prefs_working_struct RPC + prefs = pDoc->state.global_prefs; + pDoc->rpc.get_global_prefs_override_struct(prefs, mask); + } // ######### proc usage page // do work between @@ -314,6 +322,18 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { *m_txtMemoryMaxOnIdle << buffer; // suspend to memory m_chkMemoryWhileSuspended->SetValue(prefs.leave_apps_in_memory); + + // Get cc_config.xml file flags + log_flags.init(); + config.defaults(); + retval = pDoc->rpc.get_cc_config(config, log_flags); + if (!retval) { + for (unsigned int i=0; iAppend(appName); + } + } + m_bInInit=false; //update control states this->UpdateControlStates(); @@ -478,6 +498,17 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { // prefs.leave_apps_in_memory = m_chkMemoryWhileSuspended->GetValue(); mask.leave_apps_in_memory=true; + + if (m_bExclusiveAppsDataChanged) { + wxArrayString appNames = m_exclusiveApsListBox->GetStrings(); + + config.exclusive_apps.clear(); + for (unsigned int i=0; iGetSelections(selections); + m_removeExclusiveAppButton->Enable(numSelected > 0); + } + ev.Skip(); +} + // ---- command buttons handlers +// handles Add button clicked +void CDlgAdvPreferences::OnAddExclusiveApp(wxCommandEvent& ev) { + wxString strMachineName; + unsigned int i; + int j, n; + bool isDuplicate; + wxArrayString appNames; + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + pDoc->GetConnectedComputerName(strMachineName); + if (pDoc->IsComputerNameLocal(strMachineName)) { +#ifdef __WXMAC__ + wxFileDialog picker(this, _("Application to add"), + wxT("/Applications"), wxT(""), wxT("*.app"), + wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR|wxFD_MULTIPLE|wxFD_CHANGE_DIR); +#elif defined(__WXMSW__) +//TODO: fill in the default directory for MSW + wxFileDialog picker(this, _("Application to add"), + wxT(""), wxT(""), wxT("*.exe"), + wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR|wxFD_MULTIPLE|wxFD_CHANGE_DIR)); +#else +//TODO: fill in the default directory and wildcard for Linux + wxFileDialog picker(this, _("Application to add"), + wxT(""), wxT(""), wxT("*.*"), + wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR|wxFD_MULTIPLE|wxFD_CHANGE_DIR)); +#endif + if (picker.ShowModal() == wxID_OK) { + picker.GetFilenames(appNames); + for (i=0; iGetCount(); + for (j=0; jGetString(j)).Cmp(appNames[i]) == 0) { + isDuplicate = true; + break; + } + } + if (isDuplicate) continue; + + m_exclusiveApsListBox->Append(appNames[i]); + m_bExclusiveAppsDataChanged = true; + } + } + } else { +//TODO: if remote computer, show a dialog with textedit field so user can type app name + } +} + +static int myCompareInts(int *first, int *second) { + return *first - *second; +} + +typedef int (*sortcomparefunc)(int*, int*); + +// handles Remove button clicked +void CDlgAdvPreferences::OnRemoveExclusiveApp(wxCommandEvent& ev) { + wxArrayInt selections; + int numSelected = m_exclusiveApsListBox->GetSelections(selections); + + // The selection indices are returned in random order. + // We must sort them to ensure deleting the correct items. + selections.Sort((sortcomparefunc)&myCompareInts); + for (int i=numSelected-1; i>=0; --i) { + m_exclusiveApsListBox->Delete(selections[i]); + m_bExclusiveAppsDataChanged = true; + } + ev.Skip(); +} + // handles OK button clicked void CDlgAdvPreferences::OnOK(wxCommandEvent& ev) { CMainDocument* pDoc = wxGetApp().GetDocument(); @@ -730,6 +852,13 @@ void CDlgAdvPreferences::OnOK(wxCommandEvent& ev) { pDoc->rpc.set_global_prefs_override_struct(prefs,mask); pDoc->rpc.read_global_prefs_override(); } + + if (m_bExclusiveAppsDataChanged) { + int retval = pDoc->rpc.set_cc_config(config, log_flags); + if (!retval) { + pDoc->rpc.read_cc_config(); + } + } ev.Skip(); } @@ -767,7 +896,8 @@ void CDlgAdvPreferences::OnClear(wxCommandEvent& ev) { } bool CDlgAdvPreferences::ConfirmClear() { - int res = wxGetApp().SafeMessageBox(_("Do you really want to clear all local preferences ?"), + int res = wxGetApp().SafeMessageBox(_("Do you really want to clear all local preferences ?\n" + "(This will not affect exclusive applications.)"), _("Confirmation"),wxCENTER | wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,this); return res==wxYES; diff --git a/clientgui/DlgAdvPreferences.h b/clientgui/DlgAdvPreferences.h index 1bbca22be3..5b13a12170 100644 --- a/clientgui/DlgAdvPreferences.h +++ b/clientgui/DlgAdvPreferences.h @@ -25,6 +25,7 @@ #include "DlgAdvPreferencesBase.h" #include "prefs.h" +#include "cc_config.h" #define TXT_PROC_TIME_TOOLTIP _("specify work start and stop hours in format HH:MM-HH:MM") #define TXT_NET_TIME_TOOLTIP _("specify network usage start and stop hours in format HH:MM-HH:MM") @@ -57,13 +58,20 @@ public: //generic event handler void OnHandleCommandEvent(wxCommandEvent& ev); // + void OnExclusiveAppListEvent(wxCommandEvent& event); + // + void OnAddExclusiveApp(wxCommandEvent& event); + void OnRemoveExclusiveApp(wxCommandEvent& event); void OnOK(wxCommandEvent& event); void OnHelp(wxCommandEvent& event); void OnClear(wxCommandEvent& event); private: GLOBAL_PREFS prefs; GLOBAL_PREFS_MASK mask; - bool m_bDataChanged; + LOG_FLAGS log_flags; + CONFIG config; + bool m_bExclusiveAppsDataChanged; + bool m_bPrefsDataChanged; bool m_bInInit; wxArrayInt m_arrTabPageIds; }; diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 949314ea62..e817a3d1af 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -59,7 +59,7 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri topControlsSizer->Add( m_bmpWarning, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 ); - m_staticText321 = new wxStaticText( this, ID_DEFAULT, _("This dialog controls preferences for this computer only.\nClick OK to set preferences.\nClick Clear to restore web-based settings."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText321 = new wxStaticText( this, ID_DEFAULT, _("This dialog controls preferences for this computer only.\nClick OK to set preferences.\nClick Clear to restore web-based settings (except exclusive apps)."), wxDefaultPosition, wxDefaultSize, 0 ); topControlsSizer->Add( m_staticText321, 1, wxALL, 1 ); m_btnClear = new wxButton( this, ID_BTN_CLEAR, _("Clear"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -694,18 +694,18 @@ wxPanel* CDlgAdvPreferencesBase::createExclusiveAppsTab(wxNotebook* notebook) wxBoxSizer* exclusiveAppsBoxSizer = new wxBoxSizer( wxVERTICAL ); - wxListBox* m_exclusiveApsListBox = new wxListBox(exclusiveAppsTab, ID_LISTBOX_EXCLAPPS, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB | wxLB_SORT); + m_exclusiveApsListBox = new wxListBox(exclusiveAppsTab, ID_LISTBOX_EXCLAPPS, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_NEEDED_SB|wxLB_SORT); exclusiveAppsBoxSizer->Add(m_exclusiveApsListBox, 1, wxALL|wxEXPAND, 5); wxBoxSizer* exclusiveAppsButtonSizer = new wxBoxSizer( wxHORIZONTAL ); - wxButton* m_addExclusiveAppButton = new wxButton( exclusiveAppsTab, ID_ADDEXCLUSIVEAPPBUTTON, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); + m_addExclusiveAppButton = new wxButton( exclusiveAppsTab, ID_ADDEXCLUSIVEAPPBUTTON, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); m_addExclusiveAppButton->SetToolTip( _("Add an application to this list")); exclusiveAppsButtonSizer->Add( m_addExclusiveAppButton, 0, wxRIGHT, 5 ); exclusiveAppsButtonSizer->AddStretchSpacer(); - wxButton* m_removeExclusiveAppButton = new wxButton( exclusiveAppsTab, ID_REMOVEEXCLUSIVEAPPBUTTON, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); + m_removeExclusiveAppButton = new wxButton( exclusiveAppsTab, ID_REMOVEEXCLUSIVEAPPBUTTON, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); m_removeExclusiveAppButton->SetToolTip( _("Remove an application from this list")); exclusiveAppsButtonSizer->Add( m_removeExclusiveAppButton, 0, wxLEFT, 5 ); diff --git a/lib/cc_config.cpp b/lib/cc_config.cpp index b21715afe8..8af90f2f3d 100644 --- a/lib/cc_config.cpp +++ b/lib/cc_config.cpp @@ -179,6 +179,56 @@ int LOG_FLAGS::write(MIOFILE& out) { CONFIG::CONFIG() { } +// this is called first thing by client +// +void CONFIG::defaults() { + abort_jobs_on_exit = false; + allow_multiple_clients = false; + allow_remote_gui_rpc = false; + alt_platforms.clear(); + client_version_check_url = "http://boinc.berkeley.edu/download.php?xml=1"; + client_download_url = "http://boinc.berkeley.edu/download.php"; + disallow_attach = false; + dont_check_file_sizes = false; + dont_contact_ref_site = false; + exclusive_apps.clear(); + exclusive_gpu_apps.clear(); + exit_after_finish = false; + exit_when_idle = false; + fetch_minimal_work = false; + force_auth = "default"; + http_1_0 = false; + ignore_cuda_dev.clear(); + ignore_ati_dev.clear(); + max_file_xfers = MAX_FILE_XFERS; + max_file_xfers_per_project = MAX_FILE_XFERS_PER_PROJECT; + max_stderr_file_size = 0; + max_stdout_file_size = 0; + max_tasks_reported = 0; + ncpus = -1; + network_test_url = "http://www.google.com/"; + no_alt_platform = false; + no_gpus = false; + no_info_fetch = false; + no_priority_change = false; + os_random_only = false; + proxy_info.clear(); + report_results_immediately = false; + run_apps_manually = false; + save_stats_days = 30; + simple_gui_only = false; + skip_cpu_benchmarks = false; + start_delay = 0; + stderr_head = false; + suppress_net_info = false; + unsigned_apps_ok = false; + use_all_gpus = false; + use_certs = false; + use_certs_only = false; + zero_debts = false; +} + + int CONFIG::parse_options(XML_PARSER& xp) { char tag[1024]; bool is_tag; @@ -310,9 +360,6 @@ int CONFIG::parse(MIOFILE& in, LOG_FLAGS& log_flags) { XML_PARSER xp(&in); bool is_tag; - if (!xp.parse_start("cc_config")) { - return ERR_XML_PARSE; - } while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) { continue; @@ -328,7 +375,6 @@ int CONFIG::parse(MIOFILE& in, LOG_FLAGS& log_flags) { } if (!strcmp(tag, "options/")) continue; if (!strcmp(tag, "log_flags/")) continue; - xp.skip_unexpected(tag, true, "CONFIG.parse"); } return ERR_XML_PARSE; } @@ -337,6 +383,7 @@ int CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) { unsigned int i; int j; + out.printf("\n"); out.printf("\n"); log_flags.write(out); @@ -498,6 +545,7 @@ int CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) { zero_debts ); - out.printf(" \n\n"); - return 0; + out.printf(" \n\n"); + out.printf("\n"); + return 0; } diff --git a/lib/cc_config.h b/lib/cc_config.h index 97e800fa51..48acdb5b2a 100644 --- a/lib/cc_config.h +++ b/lib/cc_config.h @@ -32,6 +32,10 @@ class XML_PARSER; +#define MAX_FILE_XFERS_PER_PROJECT 2 +#define MAX_FILE_XFERS 8 + // kind of arbitrary + struct LOG_FLAGS { // on by default; intended for all users // diff --git a/lib/gui_rpc_client_ops.cpp b/lib/gui_rpc_client_ops.cpp index 3184c8db14..0643e99ca4 100644 --- a/lib/gui_rpc_client_ops.cpp +++ b/lib/gui_rpc_client_ops.cpp @@ -2415,12 +2415,6 @@ int RPC_CLIENT::set_cc_config(CONFIG& config, LOG_FLAGS& log_flags) { mf.init_buf_write(buf, sizeof(buf)); config.write(mf, log_flags); - sprintf(buf, - "\n" - "%s\n" - "\n", - buf - ); retval = rpc.do_rpc(buf); return retval; } diff --git a/lib/proxy_info.cpp b/lib/proxy_info.cpp index e9051957c2..a15a3a5c0c 100644 --- a/lib/proxy_info.cpp +++ b/lib/proxy_info.cpp @@ -113,6 +113,7 @@ int PROXY_INFO::write(MIOFILE& out) { } void PROXY_INFO::clear() { + present = false; use_http_proxy = false; use_socks_proxy = false; use_http_auth = false;