2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-05-17 22:15:10 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2004-04-10 09:11:03 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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.
|
2004-05-17 22:15:10 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-04-11 04:37:10 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "BOINCGUIApp.h"
|
|
|
|
#endif
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2005-07-05 00:06:47 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
#include <Carbon/Carbon.h>
|
2006-06-13 09:08:00 +00:00
|
|
|
#include "filesys.h"
|
|
|
|
#include "util.h"
|
2006-06-15 11:11:41 +00:00
|
|
|
#if (defined(SANDBOX) && defined(_DEBUG))
|
|
|
|
#include "SetupSecurity.h"
|
|
|
|
#endif
|
2005-07-05 00:06:47 +00:00
|
|
|
#endif
|
|
|
|
|
2004-04-11 04:37:10 +00:00
|
|
|
#include "stdwx.h"
|
2005-02-01 00:54:06 +00:00
|
|
|
#include "diagnostics.h"
|
2006-01-23 08:47:05 +00:00
|
|
|
#include "network.h"
|
2006-01-19 12:22:22 +00:00
|
|
|
#include "Events.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-06-24 05:00:57 +00:00
|
|
|
#include "AdvancedFrame.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
|
2006-06-28 01:02:39 +00:00
|
|
|
#ifdef SIMPLEGUI
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "common/wxAnimate.h"
|
|
|
|
#include "common/wxFlatNotebook.h"
|
|
|
|
#include "sg_ImageLoader.h"
|
|
|
|
#include "sg_StatImageLoader.h"
|
|
|
|
#include "sg_BoincSimpleGUI.h"
|
2006-06-28 01:02:39 +00:00
|
|
|
#endif
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
|
2005-12-28 12:33:18 +00:00
|
|
|
////@begin XPM images
|
2006-01-12 01:42:55 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include "res/boinc_mac.xpm"
|
|
|
|
#include "res/gridrepublic_mac.xpm"
|
2006-04-14 11:27:37 +00:00
|
|
|
#else
|
2005-12-28 12:33:18 +00:00
|
|
|
#include "res/boinc.xpm"
|
2006-02-02 19:31:42 +00:00
|
|
|
#include "res/gridrepublic16.xpm"
|
|
|
|
#include "res/gridrepublic32.xpm"
|
2006-01-24 11:27:26 +00:00
|
|
|
#include "res/cpdnbbc16.xpm"
|
|
|
|
#include "res/cpdnbbc32.xpm"
|
2006-01-25 02:33:01 +00:00
|
|
|
#include "res/cpdnbbcapwizard.xpm"
|
2006-04-12 08:37:08 +00:00
|
|
|
#include "res/seed16.xpm"
|
|
|
|
#include "res/seed32.xpm"
|
|
|
|
#include "res/seedamwizard.xpm"
|
|
|
|
#include "res/seedapwizard.xpm"
|
2006-04-14 11:27:37 +00:00
|
|
|
#endif
|
|
|
|
#include "res/boincsm.xpm"
|
|
|
|
#include "res/gridrepublicamwizard.xpm"
|
2005-12-28 12:33:18 +00:00
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
|
2004-12-14 20:15:06 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
EXTERN_C BOOL IsBOINCServiceInstalled();
|
|
|
|
EXTERN_C BOOL IsBOINCServiceStarting();
|
|
|
|
EXTERN_C BOOL IsBOINCServiceRunning();
|
|
|
|
EXTERN_C BOOL IsBOINCServiceStopping();
|
|
|
|
EXTERN_C BOOL IsBOINCServiceStopped();
|
|
|
|
EXTERN_C BOOL StartBOINCService();
|
|
|
|
EXTERN_C BOOL StopBOINCService();
|
|
|
|
EXTERN_C BOOL ClientLibraryStartup();
|
|
|
|
EXTERN_C void ClientLibraryShutdown();
|
|
|
|
EXTERN_C int BOINCIsNetworkAlive(long* lpdwFlags);
|
|
|
|
EXTERN_C int BOINCIsNetworkAlwaysOnline();
|
|
|
|
EXTERN_C DWORD BOINCGetIdleTickCount();
|
2004-12-14 20:15:06 +00:00
|
|
|
#endif
|
2004-12-14 02:50:16 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
IMPLEMENT_APP(CBOINCGUIApp)
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCGUIApp, wxApp)
|
|
|
|
|
|
|
|
|
2005-12-28 12:33:18 +00:00
|
|
|
bool CBrandingScheme::OnInit( wxConfigBase *pConfig ) {
|
|
|
|
wxString strBaseConfigLocation = wxEmptyString;
|
|
|
|
wxInt32 iBrandId = 0;
|
|
|
|
|
|
|
|
wxASSERT(pConfig);
|
|
|
|
|
2006-01-11 13:35:35 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxChar buf[1024];
|
|
|
|
ProcessSerialNumber ourPSN;
|
|
|
|
FSRef ourFSRef;
|
|
|
|
OSErr err;
|
|
|
|
|
|
|
|
iBrandId = 0; // Default value
|
|
|
|
// Get the full path to core client inside this application's bundle
|
|
|
|
err = GetCurrentProcess (&ourPSN);
|
|
|
|
if (err == noErr) {
|
|
|
|
err = GetProcessBundleLocation(&ourPSN, &ourFSRef);
|
|
|
|
}
|
|
|
|
if (err == noErr) {
|
|
|
|
err = FSRefMakePath (&ourFSRef, (UInt8*)buf, sizeof(buf));
|
|
|
|
}
|
|
|
|
if (err == noErr) {
|
|
|
|
strcat(buf, "/Contents/Resources/Branding");
|
|
|
|
FILE *f = fopen(buf, "r");
|
|
|
|
if (f) {
|
|
|
|
fscanf(f, "BrandId=%d\n", &iBrandId);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2005-12-28 12:33:18 +00:00
|
|
|
strBaseConfigLocation = pConfig->GetPath();
|
|
|
|
pConfig->SetPath(strBaseConfigLocation + wxT("Branding"));
|
|
|
|
pConfig->Read(wxT("BrandId"), &iBrandId, 0);
|
|
|
|
pConfig->SetPath(strBaseConfigLocation);
|
2006-01-11 13:35:35 +00:00
|
|
|
#endif
|
2005-12-28 12:33:18 +00:00
|
|
|
|
|
|
|
// If the BrandId is greater than 0 then we are running in
|
|
|
|
// branded mode
|
|
|
|
if (iBrandId) {
|
|
|
|
m_bIsBranded = true;
|
|
|
|
} else {
|
|
|
|
m_bIsBranded = false; // wxWidgets automatically sets bools to
|
|
|
|
// true by default.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now determine which resources are needed for each BrandId
|
|
|
|
switch (iBrandId) {
|
|
|
|
case 1:
|
|
|
|
// Running as a GridRepublic client.
|
2006-02-02 12:32:21 +00:00
|
|
|
m_strApplicationName = wxT("GridRepublic Desktop");
|
2006-02-07 01:08:02 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
m_iconApplicationIcon = wxIcon(gridrepublic_xpm);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(gridrepublic_xpm);
|
|
|
|
#else
|
2006-02-02 19:31:42 +00:00
|
|
|
m_iconApplicationIcon = wxIcon(gridrepublic16_xpm);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(gridrepublic32_xpm);
|
2006-02-07 01:08:02 +00:00
|
|
|
#endif
|
2005-12-28 12:33:18 +00:00
|
|
|
m_strCompanyName = wxT("GridRepublic");
|
2006-02-02 12:32:21 +00:00
|
|
|
m_strCompanyWebsite = wxT("http://www.gridrepublic.org/");
|
2005-12-28 12:33:18 +00:00
|
|
|
m_strProjectName = wxT("GridRepublic");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardTitle = wxEmptyString;
|
2006-01-19 12:22:22 +00:00
|
|
|
m_bDefaultTabSpecified = false;
|
|
|
|
m_iDefaultTab = 0;
|
2006-01-04 13:14:14 +00:00
|
|
|
m_bitmapAPWizardLogo = wxBitmap(gridrepublicamwizard_xpm);
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardAccountInfoText = wxEmptyString;
|
|
|
|
m_strAPWizardCompletionTitle = wxEmptyString;
|
2006-01-19 12:22:22 +00:00
|
|
|
m_strAPWizardCompletionBrandedMessage = wxEmptyString;
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardCompletionMessage = wxEmptyString;
|
|
|
|
m_strAMWizardTitle = wxEmptyString;
|
2006-01-04 13:14:14 +00:00
|
|
|
m_bitmapAMWizardLogo = wxBitmap(gridrepublicamwizard_xpm);
|
2006-02-01 12:18:10 +00:00
|
|
|
m_strAMWizardAccountInfoText =
|
|
|
|
_("Please provide the email address and password you used to register\n"
|
|
|
|
"at GridRepublic. (if you have not yet created an account at\n"
|
2006-03-09 18:11:49 +00:00
|
|
|
"GridRepublic, please do so at http://www.gridrepublic.org)");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAMWizardAttachMessage = wxEmptyString;
|
2006-01-23 11:30:25 +00:00
|
|
|
m_strExitMessage = wxEmptyString;
|
2005-12-28 12:33:18 +00:00
|
|
|
break;
|
2006-01-25 01:29:23 +00:00
|
|
|
#ifndef __APPLE__
|
2006-01-09 14:03:13 +00:00
|
|
|
case 2:
|
|
|
|
// Running as a CPDNBBC client.
|
2006-01-19 12:22:22 +00:00
|
|
|
m_strApplicationName = wxT("The BOINC Manager for the BBC Climate Change Experiment");
|
2006-01-24 11:27:26 +00:00
|
|
|
m_iconApplicationIcon = wxIcon(cpdnbbc16_xpm);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(cpdnbbc32_xpm);
|
2006-01-09 14:03:13 +00:00
|
|
|
m_strCompanyName = wxT("ClimatePrediction.net");
|
2006-01-27 01:06:03 +00:00
|
|
|
m_strCompanyWebsite = wxT("http://bbc.cpdn.org/");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strProjectName = wxT("BBC Climate Change Experiment");
|
2006-01-19 12:22:22 +00:00
|
|
|
m_bDefaultTabSpecified = true;
|
|
|
|
m_iDefaultTab = ID_LIST_WORKVIEW - ID_LIST_BASE;
|
|
|
|
m_strAPWizardTitle = _("Start Project");
|
2006-01-24 11:27:26 +00:00
|
|
|
m_bitmapAPWizardLogo = wxBitmap(cpdnbbcapwizard_xpm);
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardAccountInfoText =
|
2006-01-27 01:06:03 +00:00
|
|
|
_("Please enter an email address and password. You will need your email\n"
|
|
|
|
"address if you want to change your account options or use our message\n"
|
|
|
|
"boards.\n"
|
2006-01-24 11:27:26 +00:00
|
|
|
"\n"
|
2006-01-25 11:58:02 +00:00
|
|
|
"We will send you occasional emails. You can stop these at any time.\n"
|
2006-01-27 01:06:03 +00:00
|
|
|
"We will not pass your email address on to others.");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardCompletionTitle =
|
2006-01-19 12:22:22 +00:00
|
|
|
_("Project Started");
|
|
|
|
m_strAPWizardCompletionBrandedMessage =
|
|
|
|
_("Congratulations, you have now successfully started your Climate\n"
|
2006-01-27 01:06:03 +00:00
|
|
|
"Change Experiment.");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardCompletionMessage =
|
2006-01-24 11:27:26 +00:00
|
|
|
_("Click finish to exit. You will be taken to a web page which tells\n"
|
2006-01-27 01:06:03 +00:00
|
|
|
"you more about your model.");
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAMWizardTitle = wxEmptyString;
|
2006-01-24 11:27:26 +00:00
|
|
|
m_bitmapAMWizardLogo = wxBitmap(cpdnbbcapwizard_xpm);
|
2006-02-01 12:18:10 +00:00
|
|
|
m_strAMWizardAccountInfoText = wxEmptyString;
|
2006-01-09 14:03:13 +00:00
|
|
|
m_strAMWizardAttachMessage = wxEmptyString;
|
2006-01-23 11:30:25 +00:00
|
|
|
m_strExitMessage =
|
|
|
|
_("This will shut down your experiment until it restarts automatically\n"
|
|
|
|
"following your user preferences. Close window to close the manager\n"
|
|
|
|
"without stopping the experiment.");
|
2006-01-09 14:03:13 +00:00
|
|
|
break;
|
2006-04-12 08:37:08 +00:00
|
|
|
case 3:
|
|
|
|
// Running as a Seed client.
|
|
|
|
m_strApplicationName = wxT("seed@home Client");
|
|
|
|
m_iconApplicationIcon = wxIcon(seed16_xpm);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(seed32_xpm);
|
|
|
|
m_strCompanyName = wxT("Seed");
|
|
|
|
m_strCompanyWebsite = wxT("http://www.seedmagazine.com/");
|
|
|
|
m_strProjectName = wxT("seed@home");
|
|
|
|
m_bDefaultTabSpecified = false;
|
|
|
|
m_iDefaultTab = 0;
|
|
|
|
m_strAPWizardTitle = wxEmptyString;
|
|
|
|
m_bitmapAPWizardLogo = wxBitmap(seedapwizard_xpm);
|
|
|
|
m_strAPWizardCompletionTitle = wxEmptyString;
|
|
|
|
m_strAPWizardCompletionBrandedMessage = wxEmptyString;
|
|
|
|
m_strAPWizardCompletionMessage = wxEmptyString;
|
|
|
|
m_strAMWizardTitle = wxEmptyString;
|
|
|
|
m_strAPWizardAccountInfoText = wxEmptyString;
|
|
|
|
m_bitmapAMWizardLogo = wxBitmap(seedamwizard_xpm);
|
|
|
|
m_strAMWizardAccountInfoText = wxEmptyString;
|
|
|
|
m_strAMWizardAttachMessage = wxEmptyString;
|
|
|
|
m_strExitMessage = wxEmptyString;
|
|
|
|
break;
|
2006-03-28 07:42:28 +00:00
|
|
|
#endif // __APPLE__
|
2005-12-28 12:33:18 +00:00
|
|
|
default:
|
|
|
|
// Running in native mode without any branding
|
|
|
|
m_strApplicationName = wxT("BOINC Manager");
|
|
|
|
m_iconApplicationIcon = wxIcon(boinc_xpm);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(boincsm_xpm);
|
|
|
|
m_strCompanyName = wxT("Space Sciences Laboratory, U.C. Berkeley");
|
|
|
|
m_strCompanyWebsite = wxT("http://boinc.berkeley.edu/");
|
|
|
|
m_strProjectName = wxT("BOINC");
|
2006-01-19 12:22:22 +00:00
|
|
|
m_bDefaultTabSpecified = false;
|
|
|
|
m_iDefaultTab = 0;
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardTitle = wxEmptyString;
|
2006-01-25 11:58:02 +00:00
|
|
|
m_bitmapAPWizardLogo = wxNullBitmap;
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardCompletionTitle = wxEmptyString;
|
2006-01-19 12:22:22 +00:00
|
|
|
m_strAPWizardCompletionBrandedMessage = wxEmptyString;
|
2006-01-15 12:10:42 +00:00
|
|
|
m_strAPWizardCompletionMessage = wxEmptyString;
|
|
|
|
m_strAMWizardTitle = wxEmptyString;
|
|
|
|
m_strAPWizardAccountInfoText = wxEmptyString;
|
2006-01-25 11:58:02 +00:00
|
|
|
m_bitmapAMWizardLogo = wxNullBitmap;
|
2006-02-01 12:18:10 +00:00
|
|
|
m_strAMWizardAccountInfoText = wxEmptyString;
|
2006-01-06 10:50:59 +00:00
|
|
|
m_strAMWizardAttachMessage = wxEmptyString;
|
2006-01-23 11:30:25 +00:00
|
|
|
m_strExitMessage = wxEmptyString;
|
2005-12-28 12:33:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCGUIApp::OnInit() {
|
2006-01-23 08:47:05 +00:00
|
|
|
|
2006-06-15 11:11:41 +00:00
|
|
|
#if (defined(SANDBOX) && !defined(_WIN32))
|
2006-06-10 00:17:52 +00:00
|
|
|
umask (2); // Set file creation mask to be writable by both user and group
|
|
|
|
// Our umask will be inherited by all our child processes
|
|
|
|
#endif
|
|
|
|
|
2006-01-23 08:47:05 +00:00
|
|
|
// Setup variables with default values
|
|
|
|
m_bBOINCStartedByManager = false;
|
2006-06-23 08:20:08 +00:00
|
|
|
m_pFrame = NULL;
|
|
|
|
m_bGUIVisible = true;
|
2006-06-28 01:02:39 +00:00
|
|
|
#ifdef SIMPLEGUI
|
2006-06-23 08:20:08 +00:00
|
|
|
m_iGUISelected = BOINC_SIMPLEGUI;
|
2006-06-28 01:02:39 +00:00
|
|
|
#else
|
|
|
|
m_iGUISelected = BOINC_ADVANCEDGUI;
|
|
|
|
#endif
|
2006-01-23 08:47:05 +00:00
|
|
|
m_lBOINCCoreProcessId = 0;
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
m_hBOINCCoreProcess = NULL;
|
|
|
|
m_hClientLibraryDll = NULL;
|
|
|
|
#endif
|
2006-06-10 00:17:52 +00:00
|
|
|
m_strDefaultWindowStation = wxT("");
|
2006-01-23 08:47:05 +00:00
|
|
|
m_strDefaultDesktop = wxT("");
|
|
|
|
m_strDefaultDisplay = wxT("");
|
|
|
|
|
2006-01-23 13:31:57 +00:00
|
|
|
// Setup application and company information
|
|
|
|
SetAppName(wxT("BOINC Manager"));
|
|
|
|
SetVendorName(wxT("Space Sciences Laboratory, U.C. Berkeley"));
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize the configuration storage module
|
|
|
|
m_pConfig = new wxConfig(GetAppName());
|
|
|
|
wxConfigBase::Set(m_pConfig);
|
|
|
|
wxASSERT(m_pConfig);
|
|
|
|
|
|
|
|
m_pConfig->SetPath(wxT("/"));
|
|
|
|
|
2005-02-02 22:20:25 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
|
|
|
TCHAR szPath[MAX_PATH-1];
|
|
|
|
|
|
|
|
// change the current directory to the boinc install directory
|
|
|
|
GetModuleFileName(NULL, szPath, (sizeof(szPath)/sizeof(TCHAR)));
|
|
|
|
|
|
|
|
TCHAR *pszProg = strrchr(szPath, '\\');
|
|
|
|
if (pszProg) {
|
|
|
|
szPath[pszProg - szPath + 1] = 0;
|
|
|
|
SetCurrentDirectory(szPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2006-01-23 13:16:28 +00:00
|
|
|
|
|
|
|
// Setup the branding scheme
|
2006-01-23 13:31:57 +00:00
|
|
|
// NOTE: SetAppName(), SetVendorName(), and the creation of the m_pConfig
|
|
|
|
// variable need to be done before the branding object can be used on
|
|
|
|
// any platform other than the Mac.
|
2006-01-23 13:16:28 +00:00
|
|
|
m_pBranding = new CBrandingScheme;
|
|
|
|
wxASSERT(m_pBranding);
|
|
|
|
|
|
|
|
m_pBranding->OnInit(m_pConfig);
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
|
|
|
wxString strDirectory = wxEmptyString;
|
|
|
|
bool success;
|
|
|
|
|
|
|
|
// Set the current directory ahead of the application launch so the core
|
|
|
|
// client can find its files
|
2005-04-27 12:59:53 +00:00
|
|
|
#if 0 // Code for separate data in each user's private directory
|
2005-03-25 12:23:30 +00:00
|
|
|
wxChar buf[1024];
|
|
|
|
wxExpandPath(buf, "~/Library/Application Support");
|
|
|
|
strDirectory = wxT(buf);
|
2005-04-27 12:59:53 +00:00
|
|
|
#else // All users share the same data
|
|
|
|
// The mac installer sets the "setuid & setgid" bits for the
|
|
|
|
// BOINC Manager and core client so any user can run them and
|
|
|
|
// they can operate on shared data.
|
2006-01-21 12:42:04 +00:00
|
|
|
strDirectory = wxT("/Library/Application Support/");
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
success = ::wxSetWorkingDirectory(strDirectory);
|
|
|
|
if (success) {
|
|
|
|
// If SetWD failed, don't create a directory in wrong place
|
2006-04-17 07:58:19 +00:00
|
|
|
strDirectory += wxT("BOINC Data"); // We don't customize BOINC Data directory name for branding
|
2006-06-13 09:08:00 +00:00
|
|
|
if (! wxDirExists(strDirectory)) {
|
|
|
|
#ifdef SANDBOX
|
2006-06-14 07:36:44 +00:00
|
|
|
// Create BOINC Data directory writable by group boinc_master only
|
|
|
|
success = wxMkdir(strDirectory, 0575);
|
2006-06-15 11:11:41 +00:00
|
|
|
#ifndef _DEBUG
|
|
|
|
gid_t gid;
|
2006-06-14 07:36:44 +00:00
|
|
|
lookup_group("boinc_master", gid);
|
2006-06-13 09:08:00 +00:00
|
|
|
boinc_chown("BOINC Data", gid);
|
2006-06-15 11:11:41 +00:00
|
|
|
#endif // ! _DEBUG
|
|
|
|
#else // SANDBOX
|
2006-04-28 07:45:43 +00:00
|
|
|
success = wxMkdir(strDirectory, 0777); // Does nothing if dir exists
|
2006-06-15 11:11:41 +00:00
|
|
|
#endif // ! SANDBOX
|
2006-06-13 09:08:00 +00:00
|
|
|
}
|
2005-04-07 07:04:50 +00:00
|
|
|
success = ::wxSetWorkingDirectory(strDirectory);
|
2005-03-25 12:23:30 +00:00
|
|
|
// wxChar *wd = wxGetWorkingDirectory(buf, 1000); // For debugging
|
|
|
|
}
|
|
|
|
|
2006-06-14 10:45:42 +00:00
|
|
|
#ifdef SANDBOX
|
2006-06-15 11:11:41 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
// GDB can't attach to applications which are running as a diferent user
|
|
|
|
// or group, so fix up data with current user and group during debugging
|
2006-06-16 13:40:30 +00:00
|
|
|
if (check_security()) {
|
2006-06-17 23:59:04 +00:00
|
|
|
CreateBOINCUsersAndGroups();
|
2006-06-15 11:11:41 +00:00
|
|
|
SetBOINCDataOwnersGroupsAndPermissions();
|
2006-06-16 13:40:30 +00:00
|
|
|
SetBOINCAppOwnersGroupsAndPermissions(NULL);
|
|
|
|
}
|
2006-06-15 11:11:41 +00:00
|
|
|
#endif // _DEBUG
|
|
|
|
|
2006-06-21 12:41:06 +00:00
|
|
|
int i = check_security();
|
|
|
|
if (i) {
|
|
|
|
wxString strDialogMessage = wxEmptyString;
|
|
|
|
strDialogMessage.Printf(
|
|
|
|
_("BOINC ownership or permissions are not set properly; please reinstall BOINC.\n(Error code %d)"), i);
|
2006-06-14 10:45:42 +00:00
|
|
|
wxMessageDialog* pDlg =
|
2006-06-21 12:41:06 +00:00
|
|
|
new wxMessageDialog(m_pFrame, strDialogMessage, wxT(""), wxOK);
|
2006-06-14 10:45:42 +00:00
|
|
|
pDlg->ShowModal();
|
|
|
|
if (pDlg)
|
|
|
|
pDlg->Destroy();
|
|
|
|
return false;
|
|
|
|
}
|
2006-06-15 11:11:41 +00:00
|
|
|
#endif // SANDBOX
|
|
|
|
#endif // __WXMAC__
|
2006-01-23 08:47:05 +00:00
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Initialize the BOINC Diagnostics Framework
|
|
|
|
int dwDiagnosticsFlags =
|
|
|
|
BOINC_DIAG_DUMPCALLSTACKENABLED |
|
|
|
|
BOINC_DIAG_HEAPCHECKENABLED |
|
|
|
|
BOINC_DIAG_MEMORYLEAKCHECKENABLED |
|
2005-05-25 19:48:01 +00:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2005-02-01 00:54:06 +00:00
|
|
|
BOINC_DIAG_REDIRECTSTDERR |
|
|
|
|
BOINC_DIAG_REDIRECTSTDOUT |
|
2005-05-05 18:59:55 +00:00
|
|
|
#endif
|
2005-02-01 00:54:06 +00:00
|
|
|
BOINC_DIAG_TRACETOSTDOUT;
|
|
|
|
|
|
|
|
diagnostics_init(
|
|
|
|
dwDiagnosticsFlags,
|
|
|
|
"stdoutgui",
|
|
|
|
"stderrgui"
|
2005-04-08 16:58:55 +00:00
|
|
|
);
|
2004-12-04 05:42:22 +00:00
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Enable Logging and Trace Masks
|
|
|
|
m_pLog = new wxLogBOINC();
|
|
|
|
wxLog::SetActiveTarget(m_pLog);
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
m_pLog->AddTraceMask(wxT("Function Start/End"));
|
|
|
|
m_pLog->AddTraceMask(wxT("Function Status"));
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-10-21 23:07:13 +00:00
|
|
|
// Enable known image types
|
|
|
|
wxImage::AddHandler(new wxXPMHandler);
|
2006-06-23 08:20:08 +00:00
|
|
|
wxImage::AddHandler(new wxPNGHandler);
|
2004-10-21 23:07:13 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
// Initialize the internationalization module
|
|
|
|
m_pLocale = new wxLocale();
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pLocale);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
wxInt32 iSelectedLanguage = m_pConfig->Read(wxT("Language"), 0L);
|
|
|
|
|
|
|
|
// Locale information is stored relative to the executable.
|
|
|
|
m_pLocale->Init(iSelectedLanguage);
|
2004-10-31 23:16:09 +00:00
|
|
|
m_pLocale->AddCatalogLookupPathPrefix(wxT("locale"));
|
2005-12-28 12:33:18 +00:00
|
|
|
m_pLocale->AddCatalog(wxT("BOINC Manager"));
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
InitSupportedLanguages();
|
|
|
|
|
2005-07-21 09:43:40 +00:00
|
|
|
// Note: JAWS for Windows will only speak the context-sensitive
|
|
|
|
// help if you use this help provider:
|
|
|
|
wxHelpProvider::Set(new wxHelpControllerHelpProvider());
|
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Commandline parsing is done in wxApp::OnInit()
|
2005-04-08 16:58:55 +00:00
|
|
|
if (!wxApp::OnInit()) {
|
2005-02-01 00:54:06 +00:00
|
|
|
return false;
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
// Initialize the main document
|
|
|
|
m_pDocument = new CMainDocument();
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pDocument);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-10-23 23:40:11 +00:00
|
|
|
m_pDocument->OnInit();
|
|
|
|
|
2006-06-28 01:02:39 +00:00
|
|
|
#ifdef SIMPLEGUI
|
2006-06-23 08:20:08 +00:00
|
|
|
// Which GUI should be displayed?
|
|
|
|
m_iGUISelected = m_pConfig->Read(wxT("GUISelection"), BOINC_SIMPLEGUI);
|
2006-06-28 01:02:39 +00:00
|
|
|
#endif
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-10-23 07:13:18 +00:00
|
|
|
// Initialize the task bar icon
|
2005-12-28 12:33:18 +00:00
|
|
|
m_pTaskBarIcon = new CTaskBarIcon(
|
|
|
|
m_pBranding->GetApplicationName(),
|
|
|
|
m_pBranding->GetApplicationIcon()
|
|
|
|
);
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pTaskBarIcon);
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
2006-01-10 13:09:24 +00:00
|
|
|
m_pMacSystemMenu = new CMacSystemMenu(
|
|
|
|
m_pBranding->GetApplicationName(),
|
|
|
|
m_pBranding->GetApplicationIcon()
|
|
|
|
);
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pMacSystemMenu);
|
2004-10-25 21:42:47 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2005-02-15 06:32:43 +00:00
|
|
|
// Detect the display info and store for later use.
|
|
|
|
DetectDisplayInfo();
|
2004-11-17 09:27:06 +00:00
|
|
|
|
2004-12-14 02:50:16 +00:00
|
|
|
// Startup the System Idle Detection code
|
2006-01-23 08:47:05 +00:00
|
|
|
ClientLibraryStartup();
|
2004-12-14 02:50:16 +00:00
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
// Detect if we need to start the BOINC Core Client due to configuration
|
|
|
|
StartupBOINCCore();
|
|
|
|
|
2005-04-26 15:03:51 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
ProcessInfoRec pInfo;
|
|
|
|
OSStatus err;
|
|
|
|
|
|
|
|
GetCurrentProcess(&psn);
|
|
|
|
memset(&pInfo, 0, sizeof(pInfo));
|
|
|
|
pInfo.processInfoLength = sizeof( ProcessInfoRec );
|
|
|
|
err = GetProcessInformation(&psn, &pInfo);
|
|
|
|
if (!err) {
|
|
|
|
psn = pInfo.processLauncher;
|
|
|
|
memset(&pInfo, 0, sizeof(pInfo));
|
|
|
|
pInfo.processInfoLength = sizeof( ProcessInfoRec );
|
|
|
|
err = GetProcessInformation(&psn, &pInfo);
|
|
|
|
}
|
|
|
|
// Don't open main window if we were started automatically at login
|
2005-04-27 12:59:53 +00:00
|
|
|
if (pInfo.processSignature == 'lgnw') { // Login Window app
|
2005-04-26 15:03:51 +00:00
|
|
|
m_bFrameVisible = false;
|
2005-04-27 12:59:53 +00:00
|
|
|
|
|
|
|
// If the system was just started, we usually get a "Connection
|
|
|
|
// failed" error if we try to connect too soon, so delay a bit.
|
|
|
|
sleep(10);
|
|
|
|
}
|
2005-04-26 15:03:51 +00:00
|
|
|
#endif
|
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
// Show the UI
|
2006-06-23 08:20:08 +00:00
|
|
|
SetActiveGUI(m_iGUISelected, false);
|
|
|
|
if (m_bGUIVisible) {
|
|
|
|
SetActiveGUI(m_iGUISelected);
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
2005-07-06 05:16:53 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
GetCurrentProcess(&psn);
|
|
|
|
ShowHideProcess(&psn, false);
|
2005-05-07 12:37:01 +00:00
|
|
|
#endif
|
2005-02-11 00:08:01 +00:00
|
|
|
}
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
int CBOINCGUIApp::OnExit() {
|
2004-11-23 07:45:11 +00:00
|
|
|
// Detect if we need to stop the BOINC Core Client due to configuration
|
|
|
|
ShutdownBOINCCore();
|
|
|
|
|
2004-12-14 02:50:16 +00:00
|
|
|
// Shutdown the System Idle Detection code
|
2006-01-23 08:47:05 +00:00
|
|
|
ClientLibraryShutdown();
|
2004-12-14 02:50:16 +00:00
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
if (m_pTaskBarIcon) {
|
2004-10-23 07:13:18 +00:00
|
|
|
delete m_pTaskBarIcon;
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
2005-04-08 16:58:55 +00:00
|
|
|
if (m_pMacSystemMenu) {
|
2005-03-25 12:23:30 +00:00
|
|
|
delete m_pMacSystemMenu;
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-10-25 21:42:47 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (m_pDocument) {
|
2004-10-23 23:40:11 +00:00
|
|
|
m_pDocument->OnExit();
|
2004-04-10 09:11:03 +00:00
|
|
|
delete m_pDocument;
|
2004-10-23 23:40:11 +00:00
|
|
|
}
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2006-01-06 10:50:59 +00:00
|
|
|
if (m_pBranding) {
|
|
|
|
delete m_pBranding;
|
|
|
|
}
|
|
|
|
|
2005-04-08 16:58:55 +00:00
|
|
|
if (m_pLocale) {
|
2004-04-10 09:11:03 +00:00
|
|
|
delete m_pLocale;
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
return wxApp::OnExit();
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCGUIApp::OnInitCmdLine(wxCmdLineParser &parser) {
|
2004-11-23 07:45:11 +00:00
|
|
|
wxApp::OnInitCmdLine(parser);
|
2004-04-10 09:11:03 +00:00
|
|
|
static const wxCmdLineEntryDesc cmdLineDesc[] = {
|
2004-11-19 08:11:49 +00:00
|
|
|
{ wxCMD_LINE_SWITCH, wxT("s"), wxT("systray"), _("Startup BOINC so only the system tray icon is visible")},
|
2004-04-10 09:11:03 +00:00
|
|
|
{ wxCMD_LINE_NONE} //DON'T forget this line!!
|
|
|
|
};
|
|
|
|
parser.SetDesc(cmdLineDesc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCGUIApp::OnCmdLineParsed(wxCmdLineParser &parser) {
|
2004-04-10 09:11:03 +00:00
|
|
|
// Give default processing (-?, --help and --verbose) the chance to do something.
|
2004-11-23 07:45:11 +00:00
|
|
|
wxApp::OnCmdLineParsed(parser);
|
2005-04-07 07:04:50 +00:00
|
|
|
if (parser.Found(wxT("systray"))) {
|
2006-06-23 08:20:08 +00:00
|
|
|
m_bGUIVisible = false;
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
|
2005-02-15 06:32:43 +00:00
|
|
|
void CBOINCGUIApp::DetectDisplayInfo() {
|
|
|
|
#ifdef __WXMSW__
|
2004-11-17 09:27:06 +00:00
|
|
|
wxChar szWindowStation[256];
|
2004-11-24 00:25:54 +00:00
|
|
|
memset(szWindowStation, 0, sizeof(szWindowStation)/sizeof(wxChar));
|
2005-02-15 06:46:42 +00:00
|
|
|
wxChar szDesktop[256];
|
2005-02-15 06:32:43 +00:00
|
|
|
memset(szDesktop, 0, sizeof(szDesktop)/sizeof(wxChar));
|
2004-11-17 09:27:06 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (wxWIN95 != wxGetOsVersion(NULL, NULL)) {
|
2004-11-17 09:27:06 +00:00
|
|
|
// Retrieve the current window station and desktop names
|
2005-04-07 07:04:50 +00:00
|
|
|
GetUserObjectInformation(
|
2004-11-17 09:27:06 +00:00
|
|
|
GetProcessWindowStation(),
|
|
|
|
UOI_NAME,
|
|
|
|
szWindowStation,
|
|
|
|
(sizeof(szWindowStation) / sizeof(wxChar)),
|
|
|
|
NULL
|
|
|
|
);
|
2005-04-07 07:04:50 +00:00
|
|
|
GetUserObjectInformation(
|
2004-11-17 09:27:06 +00:00
|
|
|
GetThreadDesktop(GetCurrentThreadId()),
|
|
|
|
UOI_NAME,
|
|
|
|
szDesktop,
|
|
|
|
(sizeof(szDesktop) / sizeof(wxChar)),
|
|
|
|
NULL
|
|
|
|
);
|
2005-02-15 06:32:43 +00:00
|
|
|
m_strDefaultWindowStation = szWindowStation;
|
|
|
|
m_strDefaultDesktop = szDesktop;
|
2004-11-17 09:27:06 +00:00
|
|
|
}
|
|
|
|
|
2005-02-15 06:32:43 +00:00
|
|
|
#else
|
2006-03-23 01:17:07 +00:00
|
|
|
wxString p = wxString(getenv("DISPLAY"), wxConvUTF8);
|
2005-02-15 06:32:43 +00:00
|
|
|
if (p) m_strDefaultDisplay = p;
|
2004-11-17 09:27:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCGUIApp::InitSupportedLanguages() {
|
2005-02-07 04:47:18 +00:00
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
const wxLanguageInfo* liLanguage = NULL;
|
|
|
|
|
2005-06-28 15:55:59 +00:00
|
|
|
// Prepare the array
|
|
|
|
m_astrLanguages.Insert(wxEmptyString, 0, wxLANGUAGE_USER_DEFINED+1);
|
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
// These are just special tags so deal with them in a special way
|
2005-06-28 15:55:59 +00:00
|
|
|
m_astrLanguages[wxLANGUAGE_DEFAULT] = _("(Automatic Detection)");
|
|
|
|
m_astrLanguages[wxLANGUAGE_UNKNOWN] = _("(Unknown)");
|
|
|
|
m_astrLanguages[wxLANGUAGE_USER_DEFINED] = _("(User Defined)");
|
2005-02-07 04:47:18 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
for (iIndex = 0; iIndex <= wxLANGUAGE_USER_DEFINED; iIndex++) {
|
|
|
|
liLanguage = wxLocale::GetLanguageInfo(iIndex);
|
2005-04-27 06:55:28 +00:00
|
|
|
if (liLanguage) {
|
2005-06-28 15:55:59 +00:00
|
|
|
m_astrLanguages[iIndex] = liLanguage->Description;
|
2005-02-07 04:47:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
bool CBOINCGUIApp::IsBOINCCoreRunning() {
|
2005-04-15 20:49:23 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCGUIApp::IsBOINCCoreRunning - Function Begin"));
|
2005-04-15 18:45:06 +00:00
|
|
|
|
2005-05-05 18:59:55 +00:00
|
|
|
int retval;
|
|
|
|
bool running;
|
2005-04-08 04:23:37 +00:00
|
|
|
RPC_CLIENT rpc;
|
2006-03-02 19:30:39 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
|
|
|
if (IsBOINCServiceInstalled()) {
|
|
|
|
running = (FALSE != IsBOINCServiceStarting()) || (FALSE != IsBOINCServiceRunning());
|
|
|
|
} else {
|
|
|
|
retval = rpc.init("localhost"); // synchronous is OK since local
|
|
|
|
running = (retval == 0);
|
|
|
|
rpc.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2005-05-25 19:26:37 +00:00
|
|
|
retval = rpc.init("localhost"); // synchronous is OK since local
|
2005-05-05 18:59:55 +00:00
|
|
|
running = (retval == 0);
|
|
|
|
rpc.close();
|
2006-03-02 19:30:39 +00:00
|
|
|
#endif
|
2005-04-15 18:45:06 +00:00
|
|
|
|
2005-04-15 20:49:23 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCGUIApp::IsBOINCCoreRunning - Function End"));
|
2005-05-05 18:59:55 +00:00
|
|
|
return running;
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCGUIApp::StartupBOINCCore() {
|
|
|
|
if (!IsBOINCCoreRunning()) {
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifndef __WXMAC__
|
2005-02-01 06:16:13 +00:00
|
|
|
wxString strDirectory = wxEmptyString;
|
2005-03-25 12:23:30 +00:00
|
|
|
#endif // ! __WXMAC__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
wxString strExecute = wxEmptyString;
|
|
|
|
wxChar szExecutableDirectory[4096];
|
|
|
|
|
|
|
|
memset(szExecutableDirectory, 0, sizeof(szExecutableDirectory));
|
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
|
|
|
// On the surface it would seem that GetCurrentDirectory would be a better choice
|
|
|
|
// for determing which directory we should prepend to the execution string before
|
|
|
|
// starting BOINC, except that we cannot depend on any shortcuts being configured
|
|
|
|
// to startup in the correct directory, since the user may have created the
|
|
|
|
// shortcut themselves. So determine where boinc.exe is based off of our
|
|
|
|
// current execution location and then execute it.
|
2005-04-07 07:04:50 +00:00
|
|
|
GetModuleFileName(
|
2004-11-23 07:45:11 +00:00
|
|
|
NULL,
|
|
|
|
szExecutableDirectory,
|
2005-04-07 07:04:50 +00:00
|
|
|
(sizeof(szExecutableDirectory) / sizeof(wxChar))
|
2004-11-23 07:45:11 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-03-11 13:08:52 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
|
|
|
{
|
|
|
|
wxChar buf[1024];
|
2005-12-06 11:39:00 +00:00
|
|
|
wxChar *argv[3];
|
2005-03-11 13:08:52 +00:00
|
|
|
ProcessSerialNumber ourPSN;
|
|
|
|
FSRef ourFSRef;
|
|
|
|
OSErr err;
|
|
|
|
|
|
|
|
// Get the full path to core client inside this application's bundle
|
|
|
|
err = GetCurrentProcess (&ourPSN);
|
2005-04-08 16:58:55 +00:00
|
|
|
if (err == noErr) {
|
2005-03-11 13:08:52 +00:00
|
|
|
err = GetProcessBundleLocation(&ourPSN, &ourFSRef);
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
|
|
|
if (err == noErr) {
|
2005-03-11 13:08:52 +00:00
|
|
|
err = FSRefMakePath (&ourFSRef, (UInt8*)buf, sizeof(buf));
|
2005-04-08 16:58:55 +00:00
|
|
|
}
|
2005-04-07 07:04:50 +00:00
|
|
|
if (err == noErr) {
|
2005-12-06 11:39:00 +00:00
|
|
|
#if 0 // The Mac version of wxExecute(wxString& ...) crashes if there is a space in the path
|
2005-03-11 13:08:52 +00:00
|
|
|
strExecute = wxT("\"");
|
|
|
|
strExecute += wxT(buf);
|
2005-04-23 15:14:52 +00:00
|
|
|
strExecute += wxT("/Contents/Resources/boinc\" -redirectio");
|
2005-12-06 11:39:00 +00:00
|
|
|
m_lBOINCCoreProcessId = ::wxExecute(strExecute);
|
|
|
|
#else // Use wxExecute(wxChar **argv ...) instead of wxExecute(wxString& ...)
|
|
|
|
strcat(buf, "/Contents/Resources/boinc");
|
|
|
|
argv[0] = buf;
|
|
|
|
argv[1] = "-redirectio";
|
|
|
|
argv[2] = NULL;
|
|
|
|
m_lBOINCCoreProcessId = ::wxExecute(argv);
|
|
|
|
#endif
|
2005-04-07 07:04:50 +00:00
|
|
|
} else {
|
2005-03-11 13:08:52 +00:00
|
|
|
buf[0] = '\0';
|
2005-04-07 07:04:50 +00:00
|
|
|
}
|
2005-03-11 13:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else // ! __WXMAC__
|
|
|
|
|
2005-07-07 20:32:28 +00:00
|
|
|
#ifndef __WXMSW__
|
|
|
|
// copy the path to the boinmgr from argv[0]
|
2006-03-23 01:17:07 +00:00
|
|
|
strncpy((char*)szExecutableDirectory, (const char*)wxGetApp().argv[0], sizeof(szExecutableDirectory));
|
2005-07-07 20:32:28 +00:00
|
|
|
#endif
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
// We are only interested in the path component of the fully qualified path.
|
2005-04-07 07:04:50 +00:00
|
|
|
wxFileName::SplitPath(szExecutableDirectory, &strDirectory, NULL, NULL);
|
2004-11-23 07:45:11 +00:00
|
|
|
|
|
|
|
// Set the current directory ahead of the application launch so the core
|
|
|
|
// client can find its files
|
2005-04-07 07:04:50 +00:00
|
|
|
::wxSetWorkingDirectory(strDirectory);
|
2004-11-23 07:45:11 +00:00
|
|
|
|
2005-03-11 13:08:52 +00:00
|
|
|
#endif // ! __WXMAC__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
|
|
|
// Append boinc.exe to the end of the strExecute string and get ready to rock
|
2005-02-01 06:16:13 +00:00
|
|
|
strExecute = wxT("\"") + strDirectory + wxT("\\boinc.exe\" -redirectio");
|
2004-11-23 07:45:11 +00:00
|
|
|
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFO si;
|
|
|
|
BOOL bProcessStarted;
|
|
|
|
|
|
|
|
memset(&pi, 0, sizeof(pi));
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
si.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
si.wShowWindow = SW_HIDE;
|
|
|
|
|
|
|
|
bProcessStarted = CreateProcess(
|
|
|
|
NULL,
|
|
|
|
(LPTSTR)strExecute.c_str(),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
CREATE_NEW_PROCESS_GROUP|CREATE_NO_WINDOW,
|
|
|
|
NULL,
|
2005-02-01 06:16:13 +00:00
|
|
|
(LPTSTR)strDirectory.c_str(),
|
2004-11-23 07:45:11 +00:00
|
|
|
&si,
|
|
|
|
&pi
|
|
|
|
);
|
2005-04-07 07:04:50 +00:00
|
|
|
if (bProcessStarted) {
|
2005-01-06 22:25:53 +00:00
|
|
|
m_lBOINCCoreProcessId = pi.dwProcessId;
|
|
|
|
m_hBOINCCoreProcess = pi.hProcess;
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2005-03-11 13:08:52 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
// Append boinc.exe to the end of the strExecute string and get ready to rock
|
2005-07-08 09:04:21 +00:00
|
|
|
strExecute = wxT("./boinc -redirectio");
|
2005-12-06 11:39:00 +00:00
|
|
|
m_lBOINCCoreProcessId = ::wxExecute(strExecute);
|
2005-03-11 13:08:52 +00:00
|
|
|
|
|
|
|
#endif // ! __WXMAC__
|
|
|
|
|
|
|
|
#endif // ! __WXMSW__
|
2004-11-23 07:45:11 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (0 != m_lBOINCCoreProcessId) {
|
2004-11-23 07:45:11 +00:00
|
|
|
m_bBOINCStartedByManager = true;
|
2005-04-07 07:04:50 +00:00
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-06 09:24:30 +00:00
|
|
|
#if defined(__WXMSW__)
|
2005-01-07 20:47:40 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCGUIApp::ShutdownBOINCCore() {
|
2006-04-14 03:53:03 +00:00
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCGUIApp::ShutdownBOINCCore - Function Begin"));
|
|
|
|
|
2006-03-29 02:12:24 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
DWORD dwExitCode = 0;
|
|
|
|
bool bClientQuit = false;
|
|
|
|
wxString strConnectedCompter = wxEmptyString;
|
2006-03-29 04:12:28 +00:00
|
|
|
wxString strPassword = wxEmptyString;
|
2004-11-23 07:45:11 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (m_bBOINCStartedByManager) {
|
2006-03-28 21:54:41 +00:00
|
|
|
m_pDocument->GetConnectedComputerName(strConnectedCompter);
|
|
|
|
if (!m_pDocument->IsComputerNameLocal(strConnectedCompter)) {
|
2006-03-29 02:12:24 +00:00
|
|
|
RPC_CLIENT rpc;
|
|
|
|
if (!rpc.init("localhost")) {
|
2006-03-29 04:12:28 +00:00
|
|
|
m_pDocument->m_pNetworkConnection->GetLocalPassword(strPassword);
|
2006-04-28 19:07:21 +00:00
|
|
|
rpc.authorize((const char*)strPassword.mb_str());
|
2006-03-29 02:12:24 +00:00
|
|
|
if (GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
|
|
|
|
if (STILL_ACTIVE == dwExitCode) {
|
|
|
|
rpc.quit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!bClientQuit && GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
|
|
|
|
if (STILL_ACTIVE != dwExitCode) {
|
2006-04-14 03:53:03 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCGUIApp::ShutdownBOINCCore - (localhost) Application Exit Detected"));
|
2006-03-29 02:12:24 +00:00
|
|
|
bClientQuit = true;
|
2006-04-14 03:53:03 +00:00
|
|
|
break;
|
2006-03-29 02:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-14 03:53:03 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCGUIApp::ShutdownBOINCCore - (localhost) Application Exit NOT Detected, Sleeping..."));
|
2006-03-29 02:12:24 +00:00
|
|
|
::wxSleep(1);
|
|
|
|
}
|
|
|
|
}
|
2006-03-28 21:54:41 +00:00
|
|
|
}
|
2006-03-27 07:55:04 +00:00
|
|
|
}
|
2006-03-29 02:12:24 +00:00
|
|
|
rpc.close();
|
|
|
|
} else {
|
2006-03-27 07:55:04 +00:00
|
|
|
if (GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
|
|
|
|
if (STILL_ACTIVE == dwExitCode) {
|
|
|
|
m_pDocument->CoreClientQuit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!bClientQuit && GetExitCodeProcess(m_hBOINCCoreProcess, &dwExitCode)) {
|
|
|
|
if (STILL_ACTIVE != dwExitCode) {
|
2006-04-14 03:53:03 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCGUIApp::ShutdownBOINCCore - Application Exit Detected"));
|
2006-03-27 07:55:04 +00:00
|
|
|
bClientQuit = true;
|
2006-04-14 03:53:03 +00:00
|
|
|
break;
|
2006-03-27 07:55:04 +00:00
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2006-04-14 03:53:03 +00:00
|
|
|
wxLogTrace(wxT("Function Status"), wxT("CBOINCGUIApp::ShutdownBOINCCore - Application Exit NOT Detected, Sleeping..."));
|
2006-03-28 07:41:32 +00:00
|
|
|
::wxSleep(1);
|
2005-01-06 22:25:53 +00:00
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2005-01-07 20:47:40 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!bClientQuit) {
|
|
|
|
::wxKill(m_lBOINCCoreProcessId);
|
|
|
|
}
|
2005-01-07 20:47:40 +00:00
|
|
|
}
|
2006-04-14 03:53:03 +00:00
|
|
|
|
|
|
|
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCGUIApp::ShutdownBOINCCore - Function End"));
|
2005-01-07 20:47:40 +00:00
|
|
|
}
|
|
|
|
|
2005-05-06 09:24:30 +00:00
|
|
|
#elif defined(__WXMAC__)
|
|
|
|
|
2005-09-20 00:45:00 +00:00
|
|
|
static char * PersistentFGets(char *buf, size_t buflen, FILE *f) {
|
|
|
|
char *p = buf;
|
|
|
|
size_t len = buflen;
|
|
|
|
size_t datalen = 0;
|
|
|
|
|
|
|
|
*buf = '\0';
|
|
|
|
while (datalen < (buflen - 1)) {
|
|
|
|
fgets(p, len, f);
|
|
|
|
if (feof(f)) break;
|
|
|
|
if (ferror(f) && (errno != EINTR)) break;
|
|
|
|
if (strchr(buf, '\n')) break;
|
|
|
|
datalen = strlen(buf);
|
|
|
|
p = buf + datalen;
|
|
|
|
len -= datalen;
|
|
|
|
}
|
|
|
|
return (buf[0] ? buf : NULL);
|
|
|
|
}
|
|
|
|
|
2005-05-06 09:24:30 +00:00
|
|
|
bool CBOINCGUIApp::ProcessExists(pid_t thePID)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[256];
|
|
|
|
pid_t aPID;
|
|
|
|
|
|
|
|
f = popen("ps -a -x -c -o pid,state", "r");
|
|
|
|
if (f == NULL)
|
|
|
|
return false;
|
|
|
|
|
2005-09-20 00:45:00 +00:00
|
|
|
while (PersistentFGets(buf, sizeof(buf), f)) {
|
2005-05-06 09:24:30 +00:00
|
|
|
aPID = atol(buf);
|
|
|
|
if (aPID == thePID) {
|
|
|
|
if (strchr(buf, 'Z')) // A 'zombie', stopped but waiting
|
|
|
|
break; // for us (its parent) to quit
|
|
|
|
pclose(f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pclose(f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// wxProcess::Exists and wxKill are unimplemented in WxMac-2.6.0
|
|
|
|
void CBOINCGUIApp::ShutdownBOINCCore() {
|
2006-03-29 04:12:28 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
wxString strConnectedCompter = wxEmptyString;
|
|
|
|
wxString strPassword = wxEmptyString;
|
2005-05-06 09:24:30 +00:00
|
|
|
|
|
|
|
if (m_bBOINCStartedByManager) {
|
2006-03-28 21:54:41 +00:00
|
|
|
m_pDocument->GetConnectedComputerName(strConnectedCompter);
|
|
|
|
if (!m_pDocument->IsComputerNameLocal(strConnectedCompter)) {
|
2006-03-29 02:12:24 +00:00
|
|
|
RPC_CLIENT rpc;
|
|
|
|
if (!rpc.init("localhost")) {
|
2006-03-29 04:12:28 +00:00
|
|
|
m_pDocument->m_pNetworkConnection->GetLocalPassword(strPassword);
|
2006-04-28 19:07:21 +00:00
|
|
|
rpc.authorize((const char*)strPassword.mb_str());
|
2006-03-29 02:12:24 +00:00
|
|
|
if (ProcessExists(m_lBOINCCoreProcessId)) {
|
|
|
|
rpc.quit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!ProcessExists(m_lBOINCCoreProcessId))
|
|
|
|
return;
|
|
|
|
::wxSleep(1);
|
|
|
|
}
|
2006-03-28 21:54:41 +00:00
|
|
|
}
|
2006-03-27 07:55:04 +00:00
|
|
|
}
|
2006-03-29 02:12:24 +00:00
|
|
|
rpc.close();
|
|
|
|
} else {
|
2006-03-27 07:55:04 +00:00
|
|
|
if (ProcessExists(m_lBOINCCoreProcessId)) {
|
|
|
|
m_pDocument->CoreClientQuit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!ProcessExists(m_lBOINCCoreProcessId))
|
|
|
|
return;
|
2005-05-06 09:24:30 +00:00
|
|
|
|
2006-03-27 07:55:04 +00:00
|
|
|
::wxSleep(1);
|
|
|
|
}
|
2005-05-06 09:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client did not quit after 10 seconds so kill it
|
|
|
|
kill(m_lBOINCCoreProcessId, SIGKILL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-07 07:32:23 +00:00
|
|
|
#else
|
2005-01-07 20:47:40 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
void CBOINCGUIApp::ShutdownBOINCCore() {
|
2006-03-29 04:12:28 +00:00
|
|
|
wxInt32 iCount = 0;
|
|
|
|
bool bClientQuit = false;
|
|
|
|
wxString strConnectedCompter = wxEmptyString;
|
|
|
|
wxString strPassword = wxEmptyString;
|
2005-01-07 20:47:40 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (m_bBOINCStartedByManager) {
|
2006-03-28 21:54:41 +00:00
|
|
|
m_pDocument->GetConnectedComputerName(strConnectedCompter);
|
|
|
|
if (!m_pDocument->IsComputerNameLocal(strConnectedCompter)) {
|
2006-03-29 02:12:24 +00:00
|
|
|
RPC_CLIENT rpc;
|
|
|
|
if (!rpc.init("localhost")) {
|
2006-03-29 04:12:28 +00:00
|
|
|
m_pDocument->m_pNetworkConnection->GetLocalPassword(strPassword);
|
2006-04-28 19:07:21 +00:00
|
|
|
rpc.authorize((const char*)strPassword.mb_str());
|
2006-03-29 02:12:24 +00:00
|
|
|
if (wxProcess::Exists(m_lBOINCCoreProcessId)) {
|
|
|
|
rpc.quit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!bClientQuit && !wxProcess::Exists(m_lBOINCCoreProcessId)) {
|
|
|
|
bClientQuit = true;
|
2006-04-14 03:53:03 +00:00
|
|
|
break;
|
2006-03-29 02:12:24 +00:00
|
|
|
}
|
|
|
|
::wxSleep(1);
|
|
|
|
}
|
2006-03-28 21:54:41 +00:00
|
|
|
}
|
2006-03-27 07:55:04 +00:00
|
|
|
}
|
2006-03-29 02:12:24 +00:00
|
|
|
rpc.close();
|
|
|
|
} else {
|
2006-03-27 07:55:04 +00:00
|
|
|
if (wxProcess::Exists(m_lBOINCCoreProcessId)) {
|
|
|
|
m_pDocument->CoreClientQuit();
|
|
|
|
for (iCount = 0; iCount <= 10; iCount++) {
|
|
|
|
if (!bClientQuit && !wxProcess::Exists(m_lBOINCCoreProcessId)) {
|
|
|
|
bClientQuit = true;
|
2006-04-14 03:53:03 +00:00
|
|
|
break;
|
2006-03-27 07:55:04 +00:00
|
|
|
}
|
|
|
|
::wxSleep(1);
|
2005-01-07 20:47:40 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2005-01-07 20:47:40 +00:00
|
|
|
|
2005-04-07 07:04:50 +00:00
|
|
|
if (!bClientQuit) {
|
|
|
|
::wxKill(m_lBOINCCoreProcessId);
|
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-07 20:47:40 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2006-01-23 08:47:05 +00:00
|
|
|
int CBOINCGUIApp::ClientLibraryStartup() {
|
2004-12-14 02:50:16 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
::ClientLibraryStartup();
|
2004-12-14 02:50:16 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-23 08:47:05 +00:00
|
|
|
int CBOINCGUIApp::ClientLibraryShutdown() {
|
2004-12-14 02:50:16 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
::ClientLibraryShutdown();
|
2005-01-07 07:32:23 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-23 21:48:45 +00:00
|
|
|
int CBOINCGUIApp::IsNetworkAlive(long* lpdwFlags) {
|
2006-01-23 08:47:05 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
return BOINCIsNetworkAlive(lpdwFlags);
|
2006-01-23 08:47:05 +00:00
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCGUIApp::IsNetworkAlwaysOnline() {
|
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
return BOINCIsNetworkAlwaysOnline();
|
2006-01-23 08:47:05 +00:00
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CBOINCGUIApp::UpdateSystemIdleDetection() {
|
2005-01-07 07:32:23 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
return BOINCGetIdleTickCount();
|
2004-12-14 02:50:16 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-02 09:31:04 +00:00
|
|
|
int CBOINCGUIApp::StartBOINCScreensaverTest() {
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
wxString strExecute = wxEmptyString;
|
|
|
|
wxChar szExecutableDirectory[4096];
|
|
|
|
memset(szExecutableDirectory, 0, sizeof(szExecutableDirectory));
|
|
|
|
|
|
|
|
// On Windows the screensaver is located in the Windows directory.
|
|
|
|
GetWindowsDirectory(
|
|
|
|
szExecutableDirectory,
|
|
|
|
(sizeof(szExecutableDirectory) / sizeof(wxChar))
|
|
|
|
);
|
|
|
|
|
2006-05-02 19:41:12 +00:00
|
|
|
// Append boinc.scr to the end of the strExecute string and get ready to rock
|
|
|
|
strExecute = wxT("\"") + wxString(szExecutableDirectory) + wxT("\\boinc.scr\" /t");
|
|
|
|
::wxExecute(strExecute);
|
2006-05-02 09:31:04 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) {
|
2006-06-28 01:02:39 +00:00
|
|
|
#ifdef SIMPLEGUI
|
2006-06-23 08:20:08 +00:00
|
|
|
CBOINCBaseFrame* pNewFrame = NULL;
|
|
|
|
|
|
|
|
// Create the new window
|
|
|
|
if ((iGUISelection != m_iGUISelected) || !pNewFrame) {
|
|
|
|
switch(iGUISelection) {
|
|
|
|
case BOINC_SIMPLEGUI:
|
|
|
|
// Initialize the simple gui window
|
|
|
|
pNewFrame = new CSimpleFrame(
|
|
|
|
m_pBranding->GetApplicationName(),
|
|
|
|
m_pBranding->GetApplicationIcon()
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case BOINC_ADVANCEDGUI:
|
|
|
|
default:
|
|
|
|
// Initialize the advanced gui window
|
2006-06-24 05:00:57 +00:00
|
|
|
pNewFrame = new CAdvancedFrame(
|
2006-06-23 08:20:08 +00:00
|
|
|
m_pBranding->GetApplicationName(),
|
|
|
|
m_pBranding->GetApplicationIcon()
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-28 01:02:39 +00:00
|
|
|
wxASSERT(pNewFrame);
|
2006-06-23 08:20:08 +00:00
|
|
|
if (pNewFrame) {
|
|
|
|
SetTopWindow(pNewFrame);
|
|
|
|
|
|
|
|
// Delete the old one if it exists
|
|
|
|
if (m_pFrame) m_pFrame->Destroy();
|
|
|
|
|
|
|
|
// Store the new frame for future use
|
|
|
|
m_pFrame = pNewFrame;
|
|
|
|
}
|
|
|
|
}
|
2006-06-28 01:02:39 +00:00
|
|
|
#else
|
|
|
|
if (!m_pFrame) {
|
|
|
|
// Initialize the advanced gui window
|
|
|
|
iGUISelection = BOINC_ADVANCEDGUI;
|
|
|
|
m_pFrame = new CAdvancedFrame(
|
|
|
|
m_pBranding->GetApplicationName(),
|
|
|
|
m_pBranding->GetApplicationIcon()
|
|
|
|
);
|
|
|
|
wxASSERT(m_pFrame);
|
|
|
|
SetTopWindow(m_pFrame);
|
|
|
|
}
|
|
|
|
#endif
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
// Show the new frame if needed
|
|
|
|
if (m_pFrame && bShowWindow) m_pFrame->Show();
|
|
|
|
|
|
|
|
m_iGUISelected = iGUISelection;
|
|
|
|
m_pConfig->Write(wxT("GUISelection"), iGUISelection);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_487cbf3018 = "$Id$";
|