2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-03-30 05:44:12 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2005-03-30 05:44:12 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2005-03-30 05:44:12 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-03-30 05:44:12 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-30 05:44:12 +00:00
|
|
|
//
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "DlgSelectComputer.h"
|
|
|
|
#endif
|
|
|
|
|
2005-07-06 09:14:43 +00:00
|
|
|
#include "stdwx.h"
|
2007-08-16 20:06:50 +00:00
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "LogBOINC.h"
|
2005-07-06 09:14:43 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2005-11-14 22:06:17 +00:00
|
|
|
#include "MainDocument.h"
|
2007-08-16 20:06:50 +00:00
|
|
|
#include "SkinManager.h"
|
2005-03-30 05:44:12 +00:00
|
|
|
|
|
|
|
////@begin includes
|
|
|
|
////@end includes
|
|
|
|
|
|
|
|
#include "DlgSelectComputer.h"
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CDlgSelectComputer type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CDlgSelectComputer, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CDlgSelectComputer event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CDlgSelectComputer, wxDialog )
|
|
|
|
|
|
|
|
////@begin CDlgSelectComputer event table entries
|
2005-11-14 22:06:17 +00:00
|
|
|
EVT_TEXT( ID_SELECTCOMPUTERNAME, CDlgSelectComputer::OnComputerNameUpdated )
|
2014-01-30 13:08:29 +00:00
|
|
|
EVT_COMBOBOX( ID_SELECTCOMPUTERNAME, CDlgSelectComputer::OnComputerNameUpdated )
|
2005-11-14 22:06:17 +00:00
|
|
|
|
2005-03-30 05:44:12 +00:00
|
|
|
////@end CDlgSelectComputer event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CDlgSelectComputer constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CDlgSelectComputer::CDlgSelectComputer( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-11 12:18:07 +00:00
|
|
|
CDlgSelectComputer::CDlgSelectComputer( wxWindow* parent, bool required, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
2005-03-30 05:44:12 +00:00
|
|
|
{
|
2010-08-11 12:18:07 +00:00
|
|
|
Create(parent, required, id, caption, pos, size, style);
|
2005-03-30 05:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CDlgSelectComputer creator
|
|
|
|
*/
|
|
|
|
|
2010-08-11 12:18:07 +00:00
|
|
|
bool CDlgSelectComputer::Create( wxWindow* parent, bool required, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
2005-03-30 05:44:12 +00:00
|
|
|
{
|
|
|
|
////@begin CDlgSelectComputer member initialisation
|
|
|
|
m_ComputerNameCtrl = NULL;
|
|
|
|
m_ComputerPasswordCtrl = NULL;
|
|
|
|
////@end CDlgSelectComputer member initialisation
|
|
|
|
|
2007-08-16 20:06:50 +00:00
|
|
|
wxString strCaption = caption;
|
|
|
|
if (strCaption.IsEmpty()) {
|
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
|
|
|
strCaption.Printf(_("%s - Select Computer"), pSkinAdvanced->GetApplicationName().c_str());
|
|
|
|
}
|
|
|
|
|
2005-03-30 05:44:12 +00:00
|
|
|
////@begin CDlgSelectComputer creation
|
|
|
|
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
|
2007-08-16 20:06:50 +00:00
|
|
|
wxDialog::Create( parent, id, strCaption, pos, size, style );
|
2005-03-30 05:44:12 +00:00
|
|
|
|
2010-08-11 12:18:07 +00:00
|
|
|
CreateControls(required);
|
2005-03-30 05:44:12 +00:00
|
|
|
GetSizer()->Fit(this);
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
Centre();
|
|
|
|
////@end CDlgSelectComputer creation
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for CDlgSelectComputer
|
|
|
|
*/
|
|
|
|
|
2010-08-11 12:18:07 +00:00
|
|
|
void CDlgSelectComputer::CreateControls(bool required)
|
2005-03-30 05:44:12 +00:00
|
|
|
{
|
|
|
|
////@begin CDlgSelectComputer content construction
|
|
|
|
CDlgSelectComputer* itemDialog1 = this;
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemDialog1->SetSizer(itemBoxSizer2);
|
|
|
|
|
2010-08-11 12:18:07 +00:00
|
|
|
if (required) {
|
2010-08-12 00:33:54 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
|
|
|
wxASSERT(pSkinAdvanced);
|
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
|
|
|
wxString strInfo = wxEmptyString;
|
|
|
|
strInfo.Printf(
|
|
|
|
_("Another instance of %s is already running \non this computer. Please select a client to monitor."),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
2010-08-11 12:18:07 +00:00
|
|
|
);
|
2010-08-12 00:33:54 +00:00
|
|
|
wxStaticText* itemStaticText1 = new wxStaticText;
|
|
|
|
itemStaticText1->Create( itemDialog1, wxID_STATIC, strInfo, wxDefaultPosition, wxDefaultSize, 0);
|
2010-08-11 12:18:07 +00:00
|
|
|
itemBoxSizer2->Add(itemStaticText1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
}
|
|
|
|
|
2005-03-30 05:44:12 +00:00
|
|
|
wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(1, 2, 0, 0);
|
|
|
|
itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemFlexGridSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(2, 2, 0, 0);
|
|
|
|
itemBoxSizer4->Add(itemFlexGridSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText6 = new wxStaticText;
|
|
|
|
itemStaticText6->Create( itemDialog1, wxID_STATIC, _("Host name:"), wxDefaultPosition, wxDefaultSize, 0 );
|
2005-07-21 23:06:02 +00:00
|
|
|
itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
2005-03-30 05:44:12 +00:00
|
|
|
|
|
|
|
wxString* m_ComputerNameCtrlStrings = NULL;
|
|
|
|
m_ComputerNameCtrl = new wxComboBox;
|
2005-03-30 09:24:31 +00:00
|
|
|
m_ComputerNameCtrl->Create( itemDialog1, ID_SELECTCOMPUTERNAME, _T(""), wxDefaultPosition, wxSize(250, -1), 0, m_ComputerNameCtrlStrings, wxCB_DROPDOWN );
|
2005-03-30 05:44:12 +00:00
|
|
|
itemFlexGridSizer5->Add(m_ComputerNameCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText8 = new wxStaticText;
|
|
|
|
itemStaticText8->Create( itemDialog1, wxID_STATIC, _("Password:"), wxDefaultPosition, wxDefaultSize, 0 );
|
2005-07-21 23:06:02 +00:00
|
|
|
itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
2005-03-30 05:44:12 +00:00
|
|
|
|
|
|
|
m_ComputerPasswordCtrl = new wxTextCtrl;
|
|
|
|
m_ComputerPasswordCtrl->Create( itemDialog1, ID_SELECTCOMPUTERPASSWORD, _T(""), wxDefaultPosition, wxSize(250, -1), wxTE_PASSWORD );
|
|
|
|
itemFlexGridSizer5->Add(m_ComputerPasswordCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
|
|
|
|
itemFlexGridSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP|wxALL, 5);
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton;
|
|
|
|
itemButton11->Create( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton11->SetDefault();
|
|
|
|
itemBoxSizer10->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
|
|
|
wxButton* itemButton12 = new wxButton;
|
|
|
|
itemButton12->Create( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
|
2005-04-01 22:17:44 +00:00
|
|
|
// Set validators
|
2014-01-30 13:08:29 +00:00
|
|
|
// Under wxCocoa 3.0, wxGenericValidator doesn't work right here
|
|
|
|
m_ComputerNameCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, & m_strComputerName) );
|
|
|
|
m_ComputerPasswordCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, & m_strComputerPassword) );
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Set keyboard shortcuts - why is this necessary?
|
|
|
|
m_Shortcuts[0].Set(wxACCEL_CTRL, 'x', wxID_CUT);
|
|
|
|
m_Shortcuts[1].Set(wxACCEL_CTRL, 'c', wxID_COPY);
|
|
|
|
m_Shortcuts[2].Set(wxACCEL_CTRL, 'v', wxID_PASTE);
|
|
|
|
m_pAccelTable = new wxAcceleratorTable(3, m_Shortcuts);
|
|
|
|
m_ComputerPasswordCtrl->SetAcceleratorTable(*m_pAccelTable);
|
2014-04-14 11:25:30 +00:00
|
|
|
|
|
|
|
// This does not work for m_ComputerNameCtrl under wxCocoa 3.0.0
|
|
|
|
// because of a known bug: http://trac.wxwidgets.org/ticket/14953
|
2014-01-30 13:08:29 +00:00
|
|
|
m_ComputerNameCtrl->SetAcceleratorTable(*m_pAccelTable);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-03-30 05:44:12 +00:00
|
|
|
////@end CDlgSelectComputer content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
2005-04-08 22:52:40 +00:00
|
|
|
bool CDlgSelectComputer::ShowToolTips(){
|
2005-03-30 05:44:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
2005-11-14 22:06:17 +00:00
|
|
|
wxBitmap CDlgSelectComputer::GetBitmapResource( const wxString& WXUNUSED(name) )
|
2005-03-30 05:44:12 +00:00
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin CDlgSelectComputer bitmap retrieval
|
|
|
|
return wxNullBitmap;
|
|
|
|
////@end CDlgSelectComputer bitmap retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
2005-11-14 22:06:17 +00:00
|
|
|
wxIcon CDlgSelectComputer::GetIconResource( const wxString& WXUNUSED(name) )
|
2005-03-30 05:44:12 +00:00
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin CDlgSelectComputer icon retrieval
|
|
|
|
return wxNullIcon;
|
|
|
|
////@end CDlgSelectComputer icon retrieval
|
|
|
|
}
|
2005-11-14 22:06:17 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SELECTCOMPUTERNAME
|
|
|
|
*/
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
void CDlgSelectComputer::OnComputerNameUpdated( wxCommandEvent& WXUNUSED(event) )
|
2005-11-14 22:06:17 +00:00
|
|
|
{
|
|
|
|
wxString strPassword = wxEmptyString;
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
|
|
|
|
2005-12-02 23:35:54 +00:00
|
|
|
wxString name = m_ComputerNameCtrl->GetValue();
|
|
|
|
if (pDoc->IsComputerNameLocal(name)) {
|
2017-02-14 08:12:15 +00:00
|
|
|
if (pDoc->m_pNetworkConnection->GetLocalPassword(strPassword) == 0) {
|
|
|
|
m_ComputerPasswordCtrl->SetValue(strPassword);
|
|
|
|
}
|
2005-11-14 22:06:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|