Skip to content

Commit

Permalink
MGR: Add command-line parameters for automatic connection to remote h…
Browse files Browse the repository at this point in the history
…ost; If currently connected host name is empty string, don't autorestart local client

svn path=/trunk/boinc/; revision=22161
  • Loading branch information
Charlie Fenton committed Aug 7, 2010
1 parent ede7c8c commit 8e5a291
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
26 changes: 26 additions & 0 deletions clientgui/BOINCGUIApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ bool CBOINCGUIApp::OnInit() {
#endif
m_strBOINCMGRRootDirectory = wxEmptyString;
m_strBOINCMGRDataDirectory = wxEmptyString;
m_strHostNameArg = wxEmptyString;
m_strPasswordArg = wxEmptyString;
m_iRPCPortArg = GUI_RPC_PORT;
m_strBOINCArguments = wxEmptyString;
m_bAccessibilityEnabled = false;
m_bGUIVisible = true;
Expand Down Expand Up @@ -518,6 +521,9 @@ void CBOINCGUIApp::OnInitCmdLine(wxCmdLineParser &parser) {
{ wxCMD_LINE_OPTION, wxT("e"), wxT("clientdir"), _("Directory containing the BOINC Client executable")},
{ wxCMD_LINE_OPTION, wxT("d"), wxT("datadir"), _("BOINC data directory")},
#endif
{ wxCMD_LINE_OPTION, wxT("n"), wxT("namehost"), _("Host name or IP address")},
{ wxCMD_LINE_OPTION, wxT("g"), wxT("gui_rpc_port"), _("GUI RPC port number")},
{ wxCMD_LINE_OPTION, wxT("p"), wxT("password"), _("Password")},
{ wxCMD_LINE_SWITCH, wxT("b"), wxT("boincargs"), _("Startup BOINC with these optional arguments")},
{ wxCMD_LINE_SWITCH, wxT("i"), wxT("insecure"), _("disable BOINC security users and permissions")},
{ wxCMD_LINE_SWITCH, wxT("c"), wxT("checkskins"), _("set skin debugging mode to enable skin manager error messages")},
Expand All @@ -533,6 +539,8 @@ void CBOINCGUIApp::OnInitCmdLine(wxCmdLineParser &parser) {
bool CBOINCGUIApp::OnCmdLineParsed(wxCmdLineParser &parser) {
// Give default processing (-?, --help and --verbose) the chance to do something.
wxApp::OnCmdLineParsed(parser);
wxString portNum = wxEmptyString;
long longPort;

parser.Found(wxT("boincargs"), &m_strBOINCArguments);
if (parser.Found(wxT("autostart"))) {
Expand Down Expand Up @@ -566,6 +574,24 @@ bool CBOINCGUIApp::OnCmdLineParsed(wxCmdLineParser &parser) {
}
#endif

if (!parser.Found(wxT("namehost"), &m_strHostNameArg)) {
m_strHostNameArg = wxT("localhost");
}

if (parser.Found(wxT("gui_rpc_port"), &portNum)) {
if (portNum.ToLong(&longPort)) {
m_iRPCPortArg = longPort;
} else {
m_iRPCPortArg = GUI_RPC_PORT; // conversion failed
}
} else {
m_iRPCPortArg = GUI_RPC_PORT;
}

if (!parser.Found(wxT("password"), &m_strPasswordArg)) {
m_strPasswordArg = wxEmptyString;
}

return true;
}

Expand Down
6 changes: 6 additions & 0 deletions clientgui/BOINCGUIApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class CBOINCGUIApp : public wxApp {

wxString m_strBOINCMGRRootDirectory;
wxString m_strBOINCMGRDataDirectory;
wxString m_strHostNameArg;
wxString m_strPasswordArg;
wxString m_strBOINCArguments;
int m_iRPCPortArg;

bool m_bAccessibilityEnabled;

Expand Down Expand Up @@ -125,7 +128,10 @@ class CBOINCGUIApp : public wxApp {
CMainDocument* GetDocument() { return m_pDocument; }
wxString GetRootDirectory() { return m_strBOINCMGRRootDirectory; }
wxString GetDataDirectory() { return m_strBOINCMGRDataDirectory; }
wxString GetClientHostNameArg() { return m_strHostNameArg; }
wxString GetClientPasswordArg() { return m_strPasswordArg; }
wxString GetArguments() { return m_strBOINCArguments; }
int GetClientRPCPortArg() { return m_iRPCPortArg; }
CDlgEventLog* GetEventLog() { return m_pEventLog; }
CTaskBarIcon* GetTaskBarIcon() { return m_pTaskBarIcon; }
void DeleteTaskBarIcon();
Expand Down
19 changes: 13 additions & 6 deletions clientgui/MainDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ bool CNetworkConnection::IsComputerNameLocal(const wxString& strMachine) {
}

if (strMachine.empty()) {
return true;
return false;
} else if (wxT("localhost") == strMachine.Lower()) {
return true;
} else if (wxT("localhost.localdomain") == strMachine.Lower()) {
Expand Down Expand Up @@ -550,7 +550,10 @@ int CMainDocument::OnExit() {

int CMainDocument::OnPoll() {
int iRetVal = 0;

wxString hostName = wxGetApp().GetClientHostNameArg();
int portNum = wxGetApp().GetClientRPCPortArg();
wxString password = wxGetApp().GetClientPasswordArg();

wxASSERT(wxDynamicCast(m_pClientManager, CBOINCClientManager));
wxASSERT(wxDynamicCast(m_pNetworkConnection, CNetworkConnection));

Expand All @@ -562,11 +565,15 @@ int CMainDocument::OnPoll() {

pFrame->UpdateStatusText(_("Starting client"));

if (m_pClientManager->StartupBOINCCore()) {
Connect(wxT("localhost"), GUI_RPC_PORT, wxEmptyString, TRUE, TRUE);
if (IsComputerNameLocal(hostName)) {
if (m_pClientManager->StartupBOINCCore()) {
Connect(wxT("localhost"), portNum, password, TRUE, TRUE);
} else {
m_pNetworkConnection->ForceDisconnect();
pFrame->ShowDaemonStartFailedAlert();
}
} else {
m_pNetworkConnection->ForceDisconnect();
pFrame->ShowDaemonStartFailedAlert();
Connect(hostName, portNum, password, TRUE, password.IsEmpty());
}

pFrame->UpdateStatusText(wxEmptyString);
Expand Down

0 comments on commit 8e5a291

Please sign in to comment.