diff --git a/checkin_notes b/checkin_notes index 384dff2382..6dcf535d99 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2741,3 +2741,10 @@ Rom 3 May 2011 samples/vboxwrapper/ vbox.cpp, .h vm.cpp, .h + +Charlie 4 May 2011 + - MGR: Continue adding Exclusive Apps pane to Computing Prefs dialog. + + clientgui/ + DlgAdvPreferences.cpp + DlgAdvPreferencesBase.cpp diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index e99a7d0ab4..20f5014dee 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -760,63 +760,119 @@ void CDlgAdvPreferences::OnExclusiveAppListEvent(wxCommandEvent& ev) { // ---- command buttons handlers // handles Add button clicked -void CDlgAdvPreferences::OnAddExclusiveApp(wxCommandEvent& ev) { +void CDlgAdvPreferences::OnAddExclusiveApp(wxCommandEvent&) { wxString strMachineName; unsigned int i; int j, n; + bool hostIsMac = false; + bool hostIsWin = false; bool isDuplicate; wxArrayString appNames; + wxChar *extension; + wxString errmsg; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + if (strstr(pDoc->host.os_name, "Darwin")) { + hostIsMac = true; + extension = wxT(".app"); + } else if (strstr(pDoc->host.os_name, "Microsoft")) { + hostIsWin = true; + extension = wxT(".exe"); + } + pDoc->GetConnectedComputerName(strMachineName); if (pDoc->IsComputerNameLocal(strMachineName)) { #ifdef __WXMAC__ - wxFileDialog picker(this, _("Application to add"), + wxFileDialog picker(this, _("Applications 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"), + wxFileDialog picker(this, _("Applications to add"), wxT("C:/Program Files"), 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("*.*"), + wxFileDialog picker(this, _("Applications 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; + wxString directory = picker.GetDirectory(); + wxFileName fn(directory, appNames[i]); + if (!fn.IsOk() || !fn.IsFileExecutable()) { + errmsg.Printf(_("'%s' is not an executable application."), appNames[i].c_str()); + wxGetApp().SafeMessageBox(errmsg, _("Add Exclusive App"), + wxOK | wxICON_EXCLAMATION, this); + continue; } } } else { -//TODO: if remote computer, show a dialog with textedit field so user can type app name + // We can't use file picker if connected to a remote computer, + // so show a dialog with textedit field so user can type app name + wxChar path_separator = wxT('/'); + + wxTextEntryDialog dlg(this, _("Name of application to add?"), _("Add exclusive app")); + if (hostIsMac) { + dlg.SetValue(extension); + } else if (hostIsWin) { + dlg.SetValue(extension); + path_separator = wxT('\\'); + } + if (dlg.ShowModal() != wxID_OK) return; + + wxString theAppName = dlg.GetValue(); + // Strip off path if present + appNames.Add(theAppName.AfterLast(path_separator)); + + // We can only perform minimal validation on remote hosts + if (hostIsMac || hostIsWin) { + if (!appNames[0].EndsWith(extension)) { + errmsg.Printf(_("Application names must end with '%s'"), extension); + wxGetApp().SafeMessageBox(errmsg, _("Add Exclusive App"), + wxOK | wxICON_EXCLAMATION, this); + return; + } + } + } + + for (i=0; iGetCount(); + for (j=0; jGetString(j)).Cmp(appNames[i]) == 0) { + isDuplicate = true; + break; + } + } + if (isDuplicate) { + errmsg.Printf(_("'%s' is already in the list."), appNames[i].c_str()); + wxGetApp().SafeMessageBox(errmsg, _("Add Exclusive App"), + wxOK | wxICON_EXCLAMATION, this); + continue; + } + + m_exclusiveApsListBox->Append(appNames[i]); + m_bExclusiveAppsDataChanged = true; } } diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 4841d3f899..9ec71f4e7d 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -711,6 +711,27 @@ wxPanel* CDlgAdvPreferencesBase::createExclusiveAppsTab(wxNotebook* notebook) exclusiveAppsBoxSizer->Add(exclusiveAppsButtonSizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 25 ); + wxBoxSizer* moreOptionsLinkSizer = new wxBoxSizer( wxHORIZONTAL ); + + moreOptionsLinkSizer->Add( + new wxStaticText( + exclusiveAppsTab, ID_DEFAULT, _("For advanced options, refer to "), + wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT + ), + 0, wxALL, 5 + ); + + moreOptionsLinkSizer->Add( + new wxHyperlinkCtrl( + exclusiveAppsTab, ID_DEFAULT, wxT("http://boinc.berkeley.edu/wiki/Client_configuration"), + wxT("http://boinc.berkeley.edu/wiki/Client_configuration"), + wxDefaultPosition, wxDefaultSize, wxHL_ALIGN_LEFT + ), + 0, wxALL, 5 + ); + + exclusiveAppsBoxSizer->Add(moreOptionsLinkSizer, 0, wxALL, 5); + exclusiveAppsListBoxSizer->Add(exclusiveAppsBoxSizer, 1, wxEXPAND, 5 ); exclusiveAppsTabBoxSizer->Add(exclusiveAppsListBoxSizer, 1, wxEXPAND, 5 );