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.,
|
2007-10-09 11:35:47 +00:00
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
|
2007-10-09 00:34:38 +00:00
|
|
|
#include "sandbox.h"
|
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-10-20 15:00:14 +00:00
|
|
|
#include "util.h"
|
|
|
|
#include "mfile.h"
|
|
|
|
#include "miofile.h"
|
|
|
|
#include "parse.h"
|
2006-01-19 12:22:22 +00:00
|
|
|
#include "Events.h"
|
2007-01-09 19:03:20 +00:00
|
|
|
#include "common/wxFlatNotebook.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "LogBOINC.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "SkinManager.h"
|
|
|
|
#include "MainDocument.h"
|
2008-01-30 06:09:34 +00:00
|
|
|
#include "BOINCClientManager.h"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "BOINCTaskBar.h"
|
|
|
|
#include "BOINCBaseFrame.h"
|
2006-06-24 05:00:57 +00:00
|
|
|
#include "AdvancedFrame.h"
|
2006-06-23 08:20:08 +00:00
|
|
|
#include "sg_ImageLoader.h"
|
|
|
|
#include "sg_StatImageLoader.h"
|
|
|
|
#include "sg_BoincSimpleGUI.h"
|
2007-01-09 19:03:20 +00:00
|
|
|
#include "DlgGenericMessage.h"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2007-06-24 10:56:11 +00:00
|
|
|
static bool s_bSkipExitConfirmation = false;
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-12-14 20:15:06 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
EXTERN_C BOOL ClientLibraryStartup();
|
|
|
|
EXTERN_C void ClientLibraryShutdown();
|
|
|
|
EXTERN_C DWORD BOINCGetIdleTickCount();
|
2004-12-14 20:15:06 +00:00
|
|
|
#endif
|
2004-12-14 02:50:16 +00:00
|
|
|
|
2008-01-30 06:09:34 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
IMPLEMENT_APP(CBOINCGUIApp)
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CBOINCGUIApp, wxApp)
|
|
|
|
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
bool CBOINCGUIApp::OnInit() {
|
2005-12-28 12:33:18 +00:00
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
// Setup variables with default values
|
2007-01-19 23:45:19 +00:00
|
|
|
m_strBOINCArguments = wxEmptyString;
|
2007-05-07 20:50:08 +00:00
|
|
|
m_strBOINCMGRRootDirectory = wxEmptyString;
|
2006-10-25 21:38:06 +00:00
|
|
|
m_pLocale = NULL;
|
|
|
|
m_pSkinManager = NULL;
|
2006-10-20 15:00:14 +00:00
|
|
|
m_pFrame = NULL;
|
2006-10-25 21:38:06 +00:00
|
|
|
m_pDocument = NULL;
|
|
|
|
m_pTaskBarIcon = NULL;
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
m_pMacSystemMenu = NULL;
|
2007-02-21 08:31:28 +00:00
|
|
|
printf("Using %s.\n", wxVERSION_STRING); // For debugging
|
2006-10-25 21:38:06 +00:00
|
|
|
#endif
|
2006-10-20 15:00:14 +00:00
|
|
|
m_bGUIVisible = true;
|
2006-10-25 21:51:37 +00:00
|
|
|
m_strDefaultWindowStation = wxEmptyString;
|
|
|
|
m_strDefaultDesktop = wxEmptyString;
|
|
|
|
m_strDefaultDisplay = wxEmptyString;
|
2006-10-20 15:00:14 +00:00
|
|
|
m_iGUISelected = BOINC_SIMPLEGUI;
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
m_hClientLibraryDll = NULL;
|
2006-02-07 01:08:02 +00:00
|
|
|
#endif
|
2005-12-28 12:33:18 +00:00
|
|
|
|
2006-07-28 09:05:54 +00:00
|
|
|
#if (defined(SANDBOX) || defined(__WXMAC__))
|
|
|
|
int errCode = 0;
|
|
|
|
#endif
|
2006-01-23 08:47:05 +00:00
|
|
|
|
2006-08-01 12:36:19 +00:00
|
|
|
#ifdef SANDBOX
|
|
|
|
g_use_sandbox = true;
|
2006-08-01 13:13:49 +00:00
|
|
|
#else
|
|
|
|
g_use_sandbox = false;
|
|
|
|
#endif
|
|
|
|
|
2006-08-01 12:36:19 +00:00
|
|
|
// Commandline parsing is done in wxApp::OnInit()
|
2006-10-20 15:00:14 +00:00
|
|
|
if (!wxApp::OnInit()) {
|
2006-08-01 12:36:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2006-08-01 13:13:49 +00:00
|
|
|
|
2006-08-01 12:36:19 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
if (g_use_sandbox)
|
|
|
|
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-06-10 00:17:52 +00:00
|
|
|
|
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__
|
|
|
|
|
2007-11-30 18:52:41 +00:00
|
|
|
//
|
|
|
|
// Determine BOINCMgr Data Directory
|
|
|
|
//
|
2007-11-30 16:40:02 +00:00
|
|
|
LONG lReturnValue;
|
|
|
|
HKEY hkSetupHive;
|
|
|
|
LPTSTR lpszRegistryValue = NULL;
|
|
|
|
DWORD dwSize = 0;
|
|
|
|
|
|
|
|
// change the current directory to the boinc data directory if it exists
|
|
|
|
lReturnValue = RegOpenKeyEx(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
2007-12-12 15:13:14 +00:00
|
|
|
_T("SOFTWARE\\Space Sciences Laboratory, U.C. Berkeley\\BOINC Setup"),
|
2007-11-30 16:40:02 +00:00
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&hkSetupHive
|
|
|
|
);
|
|
|
|
if (lReturnValue == ERROR_SUCCESS) {
|
|
|
|
// How large does our buffer need to be?
|
|
|
|
lReturnValue = RegQueryValueEx(
|
|
|
|
hkSetupHive,
|
|
|
|
_T("DATADIR"),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
if (lReturnValue != ERROR_FILE_NOT_FOUND) {
|
|
|
|
// Allocate the buffer space.
|
|
|
|
lpszRegistryValue = (LPTSTR) malloc(dwSize);
|
|
|
|
(*lpszRegistryValue) = NULL;
|
|
|
|
|
|
|
|
// Now get the data
|
|
|
|
lReturnValue = RegQueryValueEx(
|
|
|
|
hkSetupHive,
|
|
|
|
_T("DATADIR"),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(LPBYTE)lpszRegistryValue,
|
|
|
|
&dwSize
|
|
|
|
);
|
|
|
|
|
|
|
|
SetCurrentDirectory(lpszRegistryValue);
|
|
|
|
|
|
|
|
// Store the root directory for later use.
|
2007-11-30 18:52:41 +00:00
|
|
|
m_strBOINCMGRDataDirectory = lpszRegistryValue;
|
2007-11-30 16:40:02 +00:00
|
|
|
}
|
2005-02-02 22:20:25 +00:00
|
|
|
}
|
|
|
|
|
2007-11-30 16:40:02 +00:00
|
|
|
// Cleanup
|
|
|
|
if (hkSetupHive) RegCloseKey(hkSetupHive);
|
|
|
|
if (lpszRegistryValue) free(lpszRegistryValue);
|
|
|
|
|
2007-05-07 20:50:08 +00:00
|
|
|
|
2007-11-30 18:52:41 +00:00
|
|
|
//
|
|
|
|
// Determine BOINCMgr Root Directory
|
|
|
|
//
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the root directory for later use.
|
|
|
|
m_strBOINCMGRRootDirectory = szPath;
|
|
|
|
|
2005-02-02 22:20:25 +00:00
|
|
|
#endif
|
2006-01-23 13:16:28 +00:00
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
2007-12-20 02:05:18 +00:00
|
|
|
#if wxCHECK_VERSION(2,8,0)
|
|
|
|
// In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work
|
|
|
|
// so use traditional generic implementation.
|
|
|
|
wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), 1);
|
|
|
|
#endif
|
|
|
|
|
2005-03-25 12:23:30 +00:00
|
|
|
wxString strDirectory = wxEmptyString;
|
|
|
|
bool success;
|
2008-03-28 10:11:15 +00:00
|
|
|
ProcessSerialNumber psn;
|
2005-03-25 12:23:30 +00:00
|
|
|
|
|
|
|
// Set the current directory ahead of the application launch so the core
|
|
|
|
// client can find its files
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2005-04-27 12:59:53 +00:00
|
|
|
// 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
|
|
|
|
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-08-01 12:36:19 +00:00
|
|
|
if (! g_use_sandbox) {
|
|
|
|
if (! wxDirExists(strDirectory))
|
|
|
|
success = wxMkdir(strDirectory, 0777); // Does nothing if dir exists
|
|
|
|
}
|
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-07-28 09:05:54 +00:00
|
|
|
if (!success) // wxSetWorkingDirectory("/Library/Application Support/BOINC Data") FAILED
|
|
|
|
errCode = -1016;
|
|
|
|
#endif // __WXMAC__
|
|
|
|
|
2006-06-14 10:45:42 +00:00
|
|
|
#ifdef SANDBOX
|
2006-08-01 12:36:19 +00:00
|
|
|
// Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox
|
2006-07-28 09:05:54 +00:00
|
|
|
if (!errCode) {
|
|
|
|
#if (defined(__WXMAC__) && defined(_DEBUG)) // TODO: implement this for other platforms
|
|
|
|
// GDB can't attach to applications which are running as a different user
|
|
|
|
// or group, so fix up data with current user and group during debugging
|
2006-08-01 12:36:19 +00:00
|
|
|
if (check_security(g_use_sandbox, true)) {
|
2006-07-28 09:05:54 +00:00
|
|
|
CreateBOINCUsersAndGroups();
|
|
|
|
SetBOINCDataOwnersGroupsAndPermissions();
|
|
|
|
SetBOINCAppOwnersGroupsAndPermissions(NULL);
|
|
|
|
}
|
|
|
|
#endif // __WXMAC__ && _DEBUG
|
2006-08-01 12:36:19 +00:00
|
|
|
errCode = check_security(g_use_sandbox, true);
|
2006-07-28 09:05:54 +00:00
|
|
|
}
|
|
|
|
|
2006-07-04 07:22:41 +00:00
|
|
|
if (errCode) {
|
2006-10-20 15:00:14 +00:00
|
|
|
wxString strDialogMessage = wxEmptyString;
|
2006-06-21 12:41:06 +00:00
|
|
|
strDialogMessage.Printf(
|
2006-10-20 15:00:14 +00:00
|
|
|
_("BOINC ownership or permissions are not set properly; please reinstall BOINC.\n(Error code %d)"),
|
|
|
|
errCode
|
|
|
|
);
|
|
|
|
wxMessageDialog* pDlg = new wxMessageDialog(NULL, strDialogMessage, wxT(""), wxOK);
|
2008-03-28 10:11:15 +00:00
|
|
|
GetCurrentProcess(&psn);
|
2008-03-28 11:18:35 +00:00
|
|
|
SetFrontProcess(&psn); // Shows process if hidden
|
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
|
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);
|
2006-09-28 01:34:59 +00:00
|
|
|
wxImage::AddHandler(new wxGIFHandler);
|
|
|
|
wxImage::AddHandler(new wxICOHandler);
|
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);
|
|
|
|
|
2007-05-07 20:50:08 +00:00
|
|
|
// Look for the localization files by absolute and relative locations.
|
|
|
|
// preference given to the absolute location.
|
2005-02-07 04:47:18 +00:00
|
|
|
m_pLocale->Init(iSelectedLanguage);
|
2007-05-07 20:50:08 +00:00
|
|
|
if (!m_strBOINCMGRRootDirectory.IsEmpty()) {
|
|
|
|
m_pLocale->AddCatalogLookupPathPrefix(
|
2007-05-07 22:18:49 +00:00
|
|
|
wxString(m_strBOINCMGRRootDirectory + wxT("locale"))
|
2007-05-07 20:50:08 +00:00
|
|
|
);
|
|
|
|
}
|
2004-10-31 23:16:09 +00:00
|
|
|
m_pLocale->AddCatalogLookupPathPrefix(wxT("locale"));
|
2008-05-28 00:58:53 +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());
|
|
|
|
|
2006-10-20 15:00:14 +00:00
|
|
|
// Initialize the skin manager
|
|
|
|
m_pSkinManager = new CSkinManager();
|
|
|
|
wxASSERT(m_pSkinManager);
|
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
m_pSkinManager->ReloadSkin(
|
|
|
|
m_pLocale,
|
|
|
|
m_pConfig->Read(wxT("Skin"), m_pSkinManager->GetDefaultSkinName())
|
|
|
|
);
|
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-23 08:20:08 +00:00
|
|
|
// Which GUI should be displayed?
|
|
|
|
m_iGUISelected = m_pConfig->Read(wxT("GUISelection"), BOINC_SIMPLEGUI);
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2007-06-12 18:28:53 +00:00
|
|
|
// Is there a condition in which the Simple GUI should not be used?
|
|
|
|
if (BOINC_SIMPLEGUI == m_iGUISelected) {
|
|
|
|
|
2007-08-18 00:22:21 +00:00
|
|
|
// Screen too small?
|
|
|
|
if (wxGetDisplaySize().GetHeight() < 600) {
|
2007-06-12 18:28:53 +00:00
|
|
|
m_iGUISelected = BOINC_ADVANCEDGUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Screen reader in use?
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
BOOL bScreenReaderEnabled = false;
|
|
|
|
SystemParametersInfo(SPI_GETSCREENREADER, NULL, &bScreenReaderEnabled, NULL);
|
|
|
|
if (bScreenReaderEnabled) {
|
|
|
|
m_iGUISelected = BOINC_ADVANCEDGUI;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-01-30 12:30:20 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
#if 0 // We may still need this code; don't remove it yet -- CAF 1/30/08
|
|
|
|
// When running BOINC Client as a daemon / service, the menubar icon is sometimes
|
|
|
|
// unresponsive to mouse clicks if we create it before connecting to the Client.
|
|
|
|
CBOINCClientManager* pcm = m_pDocument->m_pClientManager;
|
|
|
|
if (pcm->IsSystemBooting() && pcm->IsBOINCConfiguredAsDaemon()) {
|
|
|
|
pcm->StartupBOINCCore();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2004-10-23 07:13:18 +00:00
|
|
|
// Initialize the task bar icon
|
2006-08-10 21:51:56 +00:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
|
|
|
m_pTaskBarIcon = new CTaskBarIcon(
|
2006-10-20 15:00:14 +00:00
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationName(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
|
2005-12-28 12:33:18 +00:00
|
|
|
);
|
2005-04-27 06:55:28 +00:00
|
|
|
wxASSERT(m_pTaskBarIcon);
|
2006-08-10 21:51:56 +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
|
|
|
|
2005-04-26 15:03:51 +00:00
|
|
|
#ifdef __WXMAC__
|
2006-11-03 15:18:19 +00:00
|
|
|
s_bSkipExitConfirmation = false;
|
2006-10-30 05:49:58 +00:00
|
|
|
AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0, false );
|
|
|
|
|
2006-07-18 11:21:13 +00:00
|
|
|
m_pMacSystemMenu = new CMacSystemMenu(
|
2006-10-20 15:00:14 +00:00
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationName(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationIcon(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationDisconnectedIcon(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationSnoozeIcon()
|
2006-07-18 11:21:13 +00:00
|
|
|
);
|
|
|
|
wxASSERT(m_pMacSystemMenu);
|
|
|
|
|
2005-04-26 15:03:51 +00:00
|
|
|
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
|
2006-06-28 02:43:01 +00:00
|
|
|
m_bGUIVisible = 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-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-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-10-20 15:00:14 +00:00
|
|
|
if (m_pSkinManager) {
|
2006-10-25 14:09:47 +00:00
|
|
|
m_pConfig->Write(wxT("Skin"), m_pSkinManager->GetSelectedSkin());
|
2006-10-20 15:00:14 +00:00
|
|
|
delete m_pSkinManager;
|
2006-01-06 10:50:59 +00:00
|
|
|
}
|
|
|
|
|
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")},
|
2007-01-19 23:45:19 +00:00
|
|
|
{ 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")},
|
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);
|
2007-01-19 23:45:19 +00:00
|
|
|
parser.Found(wxT("boincargs"), &m_strBOINCArguments);
|
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
|
|
|
}
|
2006-08-01 12:36:19 +00:00
|
|
|
if (parser.Found(wxT("insecure"))) {
|
|
|
|
g_use_sandbox = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-30 06:09:34 +00:00
|
|
|
#ifdef __WXMAC__
|
2006-10-30 05:49:58 +00:00
|
|
|
|
2006-11-03 15:18:19 +00:00
|
|
|
// Set s_bSkipExitConfirmation to true if cancelled because of logging out or shutting down
|
2006-10-30 05:49:58 +00:00
|
|
|
OSErr CBOINCGUIApp::QuitAppleEventHandler( const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon ) {
|
2006-11-03 15:18:19 +00:00
|
|
|
DescType senderType;
|
|
|
|
Size actualSize;
|
|
|
|
ProcessSerialNumber SenderPSN, ourPSN;
|
|
|
|
Boolean isSame;
|
|
|
|
ProcessInfoRec pInfo;
|
|
|
|
FSSpec fileSpec;
|
|
|
|
OSStatus anErr;
|
|
|
|
|
2006-11-22 11:53:17 +00:00
|
|
|
// Refuse to quit if a modal dialog is open. Search for the dialog
|
|
|
|
// by ID since all of BOINC Manager's dialog IDs are 10000.
|
|
|
|
// Unfortunately, I know of no way to disable the Quit item in our Dock menu
|
|
|
|
if (wxDynamicCast(wxWindow::FindWindowById(ID_ANYDIALOG), wxDialog)) {
|
|
|
|
SysBeep(4);
|
|
|
|
return userCanceledErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
anErr = AEGetAttributePtr(appleEvt, keyAddressAttr, typeProcessSerialNumber,
|
2006-11-03 15:18:19 +00:00
|
|
|
&senderType, &SenderPSN, sizeof(SenderPSN), &actualSize);
|
|
|
|
|
|
|
|
if (anErr == noErr) {
|
|
|
|
|
|
|
|
GetCurrentProcess(&ourPSN);
|
|
|
|
|
|
|
|
anErr = SameProcess(&SenderPSN, &ourPSN, &isSame);
|
|
|
|
|
|
|
|
if (anErr == noErr) {
|
|
|
|
if (!isSame) {
|
|
|
|
|
|
|
|
pInfo.processInfoLength = sizeof( ProcessInfoRec );
|
|
|
|
pInfo.processName = NULL;
|
|
|
|
pInfo.processAppSpec = &fileSpec;
|
|
|
|
|
|
|
|
anErr = GetProcessInformation(&SenderPSN, &pInfo);
|
2006-11-19 13:20:04 +00:00
|
|
|
|
2006-11-03 15:18:19 +00:00
|
|
|
// Consider a Quit command from our Dock menu as coming from this application
|
|
|
|
if (pInfo.processSignature != 'dock') {
|
|
|
|
s_bSkipExitConfirmation = true; // Not from our app, our dock icon or our taskbar icon
|
|
|
|
wxGetApp().ExitMainLoop(); // Prevents wxMac from issuing events to closed frames
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-30 05:49:58 +00:00
|
|
|
return wxGetApp().MacHandleAEQuit((AppleEvent*)appleEvt, reply);
|
|
|
|
}
|
|
|
|
|
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 08:47:05 +00:00
|
|
|
int CBOINCGUIApp::UpdateSystemIdleDetection() {
|
2005-01-07 07:32:23 +00:00
|
|
|
#ifdef __WXMSW__
|
2006-03-02 19:30:39 +00:00
|
|
|
return BOINCGetIdleTickCount();
|
2006-07-21 08:23:26 +00:00
|
|
|
#else
|
|
|
|
return TRUE;
|
2004-12-14 02:50:16 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-10-30 03:41:32 +00:00
|
|
|
// The skin has changed and all UI elements need to reload their bitmaps.
|
|
|
|
//
|
|
|
|
void CBOINCGUIApp::FireReloadSkin() {
|
|
|
|
if (m_pFrame) {
|
|
|
|
m_pFrame->FireReloadSkin();
|
|
|
|
}
|
|
|
|
if (m_pTaskBarIcon) {
|
|
|
|
m_pTaskBarIcon->FireReloadSkin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-23 08:20:08 +00:00
|
|
|
bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) {
|
|
|
|
CBOINCBaseFrame* pNewFrame = NULL;
|
|
|
|
|
|
|
|
// Create the new window
|
2006-06-28 21:32:28 +00:00
|
|
|
if ((iGUISelection != m_iGUISelected) || !m_pFrame) {
|
2006-06-23 08:20:08 +00:00
|
|
|
switch(iGUISelection) {
|
|
|
|
case BOINC_SIMPLEGUI:
|
2007-01-09 19:03:20 +00:00
|
|
|
default:
|
2006-06-23 08:20:08 +00:00
|
|
|
// Initialize the simple gui window
|
|
|
|
pNewFrame = new CSimpleFrame(
|
2006-10-20 15:00:14 +00:00
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationName(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationIcon()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
case BOINC_ADVANCEDGUI:
|
|
|
|
// Initialize the advanced gui window
|
2006-06-24 05:00:57 +00:00
|
|
|
pNewFrame = new CAdvancedFrame(
|
2006-10-20 15:00:14 +00:00
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationName(),
|
|
|
|
m_pSkinManager->GetAdvanced()->GetApplicationIcon()
|
2006-06-23 08:20:08 +00:00
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-28 01:02:39 +00:00
|
|
|
wxASSERT(pNewFrame);
|
2006-06-23 08:20:08 +00:00
|
|
|
if (pNewFrame) {
|
|
|
|
SetTopWindow(pNewFrame);
|
|
|
|
|
2006-10-30 04:07:41 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// So closing old view doesn't hide application
|
2006-10-30 05:49:58 +00:00
|
|
|
pNewFrame->m_iWindowType = iGUISelection;
|
2006-10-30 04:07:41 +00:00
|
|
|
m_iGUISelected = iGUISelection;
|
|
|
|
#endif
|
2006-06-23 08:20:08 +00:00
|
|
|
// Delete the old one if it exists
|
|
|
|
if (m_pFrame) m_pFrame->Destroy();
|
|
|
|
|
|
|
|
// Store the new frame for future use
|
|
|
|
m_pFrame = pNewFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show the new frame if needed
|
2006-08-14 18:52:09 +00:00
|
|
|
if (m_pFrame && bShowWindow) m_pFrame->Show();
|
2006-06-23 08:20:08 +00:00
|
|
|
|
|
|
|
m_iGUISelected = iGUISelection;
|
|
|
|
m_pConfig->Write(wxT("GUISelection"), iGUISelection);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-03 15:18:19 +00:00
|
|
|
int CBOINCGUIApp::ConfirmExit() {
|
2006-11-22 09:51:59 +00:00
|
|
|
CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced();
|
2008-01-30 06:09:34 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2006-11-06 13:45:50 +00:00
|
|
|
wxString strTitle;
|
2008-01-30 06:09:34 +00:00
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
2006-11-22 09:51:59 +00:00
|
|
|
wxASSERT(pSkinAdvanced);
|
2008-01-30 06:09:34 +00:00
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2006-11-22 09:51:59 +00:00
|
|
|
wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced));
|
|
|
|
|
2008-01-30 12:30:20 +00:00
|
|
|
if (! (pDoc->m_pClientManager->WasBOINCStartedByManager()))
|
2006-11-03 15:18:19 +00:00
|
|
|
return 1; // Don't run dialog if exiting manager won't shut down Client or its tasks
|
|
|
|
|
2006-11-03 22:29:19 +00:00
|
|
|
if (!m_iDisplayExitWarning)
|
2006-11-03 15:18:19 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Don't run confirmation dialog if logging out or shutting down
|
|
|
|
if (s_bSkipExitConfirmation)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
|
|
|
|
GetCurrentProcess(&psn);
|
2007-06-24 10:56:11 +00:00
|
|
|
bool wasVisible = IsProcessVisible(&psn);
|
2006-11-03 15:18:19 +00:00
|
|
|
SetFrontProcess(&psn); // Shows process if hidden
|
|
|
|
#endif
|
|
|
|
|
2006-11-06 13:45:50 +00:00
|
|
|
strTitle.Printf(
|
2006-11-03 22:29:19 +00:00
|
|
|
_("%s - Exit Confirmation"),
|
|
|
|
pSkinAdvanced->GetApplicationName().c_str()
|
|
|
|
);
|
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
CDlgGenericMessage dlg(NULL);
|
2006-11-03 15:18:19 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
dlg.SetTitle(strTitle);
|
|
|
|
dlg.m_DialogMessage->SetLabel(pSkinAdvanced->GetExitMessage());
|
|
|
|
dlg.Fit();
|
|
|
|
dlg.Centre();
|
2006-11-03 22:29:19 +00:00
|
|
|
|
2006-11-22 09:51:59 +00:00
|
|
|
if (wxID_OK == dlg.ShowModal()) {
|
|
|
|
if (dlg.m_DialogDisableMessage->GetValue()) {
|
2006-11-03 22:29:19 +00:00
|
|
|
m_iDisplayExitWarning = 0;
|
2006-11-03 15:18:19 +00:00
|
|
|
}
|
2007-06-24 10:56:11 +00:00
|
|
|
s_bSkipExitConfirmation = true; // Don't ask twice (only affects Mac)
|
2006-11-03 22:29:19 +00:00
|
|
|
return 1;
|
2006-11-03 15:18:19 +00:00
|
|
|
}
|
2007-06-24 10:56:11 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
if (!wasVisible) {
|
|
|
|
ShowHideProcess(&psn, false);
|
|
|
|
}
|
|
|
|
#endif
|
2006-11-03 15:18:19 +00:00
|
|
|
return 0; // User cancelled exit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_487cbf3018 = "$Id$";
|