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
|
|
|
|
2004-04-11 04:37:10 +00:00
|
|
|
#include "stdwx.h"
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2005-02-01 00:54:06 +00:00
|
|
|
#include "diagnostics.h"
|
2004-04-11 04:12:44 +00:00
|
|
|
#include "MainFrame.h"
|
|
|
|
#include "MainDocument.h"
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
|
2004-12-14 20:15:06 +00:00
|
|
|
#ifdef __WXMSW__
|
2004-12-14 02:50:16 +00:00
|
|
|
typedef BOOL (CALLBACK* IdleTrackerInit)();
|
|
|
|
typedef void (CALLBACK* IdleTrackerTerm)();
|
2005-01-07 07:32:23 +00:00
|
|
|
typedef DWORD (CALLBACK* IdleTrackerGetIdleTickCount)();
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
bool CBOINCGUIApp::OnInit()
|
|
|
|
{
|
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
|
|
|
|
|
2004-12-03 21:35:25 +00:00
|
|
|
// Setup application and company information
|
|
|
|
SetVendorName(wxT("Space Sciences Laboratory, U.C. Berkeley"));
|
|
|
|
SetAppName(wxT("BOINC Manager"));
|
|
|
|
|
2004-11-19 08:11:49 +00:00
|
|
|
// Setup variables with default values
|
2004-11-23 07:45:11 +00:00
|
|
|
m_bBOINCStartedByManager = false;
|
2004-11-19 08:11:49 +00:00
|
|
|
m_bFrameVisible = true;
|
2005-01-06 22:25:53 +00:00
|
|
|
m_lBOINCCoreProcessId = 0;
|
2005-01-07 17:05:21 +00:00
|
|
|
#ifdef __WXMSW__
|
2005-01-06 22:25:53 +00:00
|
|
|
m_hBOINCCoreProcess = NULL;
|
2005-01-07 17:05:21 +00:00
|
|
|
m_hIdleDetectionDll = NULL;
|
|
|
|
#endif
|
2005-02-07 04:47:18 +00:00
|
|
|
m_strDefaultWindowStation.Clear();
|
|
|
|
m_strDefaultDesktop.Clear();
|
|
|
|
|
2004-05-21 06:27:15 +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 |
|
|
|
|
BOINC_DIAG_REDIRECTSTDERR |
|
|
|
|
BOINC_DIAG_REDIRECTSTDOUT |
|
|
|
|
BOINC_DIAG_TRACETOSTDOUT;
|
|
|
|
|
|
|
|
diagnostics_init(
|
|
|
|
dwDiagnosticsFlags,
|
|
|
|
"stdoutgui",
|
|
|
|
"stderrgui"
|
|
|
|
);
|
2004-12-04 05:42:22 +00:00
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Initialize the configuration storage module
|
|
|
|
m_pConfig = new wxConfig(GetAppName());
|
|
|
|
wxConfigBase::Set(m_pConfig);
|
|
|
|
wxASSERT(NULL != m_pConfig);
|
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
m_pConfig->SetPath(wxT("/"));
|
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Enable Logging and Trace Masks
|
|
|
|
m_pLog = new wxLogBOINC();
|
|
|
|
wxLog::SetActiveTarget(m_pLog);
|
|
|
|
|
|
|
|
m_pLog->AddTraceMask( wxT("Function Start/End") );
|
2005-02-09 01:14:14 +00:00
|
|
|
m_pLog->AddTraceMask( wxT("Function Status") );
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-09-21 01:30:29 +00:00
|
|
|
// Enable the in memory virtual file system for
|
|
|
|
// storing images
|
|
|
|
wxFileSystem::AddHandler(new wxMemoryFSHandler);
|
|
|
|
|
2004-10-21 23:07:13 +00:00
|
|
|
// Enable known image types
|
|
|
|
wxImage::AddHandler(new wxXPMHandler);
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
// Initialize the internationalization module
|
|
|
|
m_pLocale = new wxLocale();
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != m_pLocale);
|
|
|
|
|
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"));
|
2004-04-10 09:11:03 +00:00
|
|
|
m_pLocale->AddCatalog(GetAppName());
|
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
InitSupportedLanguages();
|
|
|
|
|
2005-02-01 00:54:06 +00:00
|
|
|
// Commandline parsing is done in wxApp::OnInit()
|
|
|
|
if (!wxApp::OnInit())
|
|
|
|
return false;
|
2004-05-21 06:27:15 +00:00
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
// Initialize the main document
|
|
|
|
m_pDocument = new CMainDocument();
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != m_pDocument);
|
2004-04-10 09:11:03 +00:00
|
|
|
|
2004-10-23 23:40:11 +00:00
|
|
|
m_pDocument->OnInit();
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
// Initialize the main gui window
|
|
|
|
m_pFrame = new CMainFrame(GetAppName());
|
2004-05-21 06:27:15 +00:00
|
|
|
wxASSERT(NULL != m_pFrame);
|
|
|
|
|
2004-10-25 21:42:47 +00:00
|
|
|
#ifndef NOTASKBAR
|
2004-10-23 07:13:18 +00:00
|
|
|
// Initialize the task bar icon
|
|
|
|
m_pTaskBarIcon = new CTaskBarIcon();
|
|
|
|
wxASSERT(NULL != m_pTaskBarIcon);
|
2004-10-25 21:42:47 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
// Detect the default Window Station and Desktop and store the
|
|
|
|
// information for later use.
|
|
|
|
DetectDefaultWindowStation();
|
|
|
|
DetectDefaultDesktop();
|
|
|
|
|
2004-12-14 02:50:16 +00:00
|
|
|
// Startup the System Idle Detection code
|
|
|
|
StartupSystemIdleDetection();
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
// Detect if we need to start the BOINC Core Client due to configuration
|
|
|
|
StartupBOINCCore();
|
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
// Show the UI
|
2004-04-10 09:11:03 +00:00
|
|
|
SetTopWindow(m_pFrame);
|
2004-11-19 08:11:49 +00:00
|
|
|
if (m_bFrameVisible)
|
|
|
|
m_pFrame->Show();
|
2005-02-11 00:08:01 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pFrame->Show();
|
|
|
|
m_pFrame->Show(false);
|
|
|
|
}
|
|
|
|
|
2004-04-10 09:11:03 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
ShutdownSystemIdleDetection();
|
|
|
|
|
2004-10-25 21:42:47 +00:00
|
|
|
#ifndef NOTASKBAR
|
2004-10-23 07:13:18 +00:00
|
|
|
if (m_pTaskBarIcon)
|
|
|
|
delete m_pTaskBarIcon;
|
2004-10-25 21:42:47 +00:00
|
|
|
#endif
|
2004-10-23 07:13:18 +00:00
|
|
|
|
2004-04-10 09:11:03 +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
|
|
|
|
|
|
|
if (m_pLocale)
|
|
|
|
delete m_pLocale;
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
return wxApp::OnExit();
|
2004-04-10 09:11:03 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CBOINCGUIApp::OnCmdLineParsed(wxCmdLineParser &parser)
|
|
|
|
{
|
|
|
|
// Give default processing (-?, --help and --verbose) the chance to do something.
|
2004-11-23 07:45:11 +00:00
|
|
|
wxApp::OnCmdLineParsed(parser);
|
2004-11-19 08:11:49 +00:00
|
|
|
if (parser.Found(wxT("systray")))
|
|
|
|
{
|
|
|
|
m_bFrameVisible = false;
|
2004-04-10 09:11:03 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-11-17 09:27:06 +00:00
|
|
|
|
|
|
|
void CBOINCGUIApp::DetectDefaultWindowStation()
|
|
|
|
{
|
|
|
|
wxChar szWindowStation[256];
|
2004-11-24 00:25:54 +00:00
|
|
|
memset(szWindowStation, 0, sizeof(szWindowStation)/sizeof(wxChar));
|
2004-11-17 09:27:06 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
if ( wxWIN95 != wxGetOsVersion( NULL, NULL ) )
|
2004-11-17 09:27:06 +00:00
|
|
|
{
|
|
|
|
// Retrieve the current window station and desktop names
|
|
|
|
GetUserObjectInformation(
|
|
|
|
GetProcessWindowStation(),
|
|
|
|
UOI_NAME,
|
|
|
|
szWindowStation,
|
|
|
|
(sizeof(szWindowStation) / sizeof(wxChar)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_strDefaultWindowStation = szWindowStation;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCGUIApp::DetectDefaultDesktop()
|
|
|
|
{
|
|
|
|
wxChar szDesktop[256];
|
2004-11-24 00:25:54 +00:00
|
|
|
memset(szDesktop, 0, sizeof(szDesktop)/sizeof(wxChar));
|
2004-11-17 09:27:06 +00:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
if ( wxWIN95 != wxGetOsVersion( NULL, NULL ) )
|
2004-11-17 09:27:06 +00:00
|
|
|
{
|
|
|
|
GetUserObjectInformation(
|
|
|
|
GetThreadDesktop(GetCurrentThreadId()),
|
|
|
|
UOI_NAME,
|
|
|
|
szDesktop,
|
|
|
|
(sizeof(szDesktop) / sizeof(wxChar)),
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_strDefaultDesktop = szDesktop;
|
|
|
|
}
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
|
2005-02-07 04:47:18 +00:00
|
|
|
void CBOINCGUIApp::InitSupportedLanguages()
|
|
|
|
{
|
|
|
|
wxInt32 iIndex = 0;
|
|
|
|
const wxLanguageInfo* liLanguage = NULL;
|
|
|
|
|
|
|
|
// These are just special tags so deal with them in a special way
|
|
|
|
m_strLanguages[wxLANGUAGE_DEFAULT] = _("(Automatic Detection)");
|
|
|
|
m_strLanguages[wxLANGUAGE_UNKNOWN] = _("(Unknown)");
|
|
|
|
m_strLanguages[wxLANGUAGE_USER_DEFINED] = _("(User Defined)");
|
|
|
|
|
|
|
|
for ( iIndex = 0; iIndex <= wxLANGUAGE_USER_DEFINED; iIndex++ )
|
|
|
|
{
|
|
|
|
liLanguage = wxLocale::GetLanguageInfo( iIndex );
|
|
|
|
if ( NULL != liLanguage )
|
|
|
|
{
|
|
|
|
m_strLanguages[iIndex] = liLanguage->Description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
bool CBOINCGUIApp::IsBOINCCoreRunning()
|
|
|
|
{
|
2005-02-01 06:16:13 +00:00
|
|
|
wxInt32 iMode = -1;
|
|
|
|
wxString strMachine = wxEmptyString;
|
|
|
|
|
|
|
|
m_pDocument->GetConnectedComputerName( strMachine );
|
|
|
|
|
|
|
|
return ( 0 == m_pDocument->Connect(strMachine, FALSE));
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CBOINCGUIApp::StartupBOINCCore()
|
|
|
|
{
|
|
|
|
if ( !IsBOINCCoreRunning() )
|
|
|
|
{
|
2005-02-01 06:16:13 +00:00
|
|
|
wxString strDirectory = wxEmptyString;
|
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.
|
|
|
|
GetModuleFileName(
|
|
|
|
NULL,
|
|
|
|
szExecutableDirectory,
|
|
|
|
(sizeof(szExecutableDirectory) / sizeof(wxChar) )
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// We are only interested in the path component of the fully qualified path.
|
2005-02-01 06:16:13 +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-02-01 06:16:13 +00:00
|
|
|
::wxSetWorkingDirectory( strDirectory );
|
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
|
|
|
|
);
|
|
|
|
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
|
|
|
|
|
|
|
|
// Append boinc.exe to the end of the strExecute string and get ready to rock
|
|
|
|
strExecute += wxT("/boinc");
|
2005-01-07 20:31:03 +00:00
|
|
|
m_lBOINCCoreProcessId = ::wxExecute( strExecute );
|
2004-11-23 07:45:11 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-01-06 22:25:53 +00:00
|
|
|
if ( 0 != m_lBOINCCoreProcessId )
|
2004-11-23 07:45:11 +00:00
|
|
|
m_bBOINCStartedByManager = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-07 20:47:40 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
|
2004-11-23 07:45:11 +00:00
|
|
|
void CBOINCGUIApp::ShutdownBOINCCore()
|
|
|
|
{
|
|
|
|
wxInt32 iCount = 0;
|
|
|
|
bool bClientQuit = false;
|
|
|
|
|
|
|
|
if ( m_bBOINCStartedByManager )
|
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
DWORD dwExitCode;
|
|
|
|
if ( GetExitCodeProcess( m_hBOINCCoreProcess, &dwExitCode ) )
|
2004-11-23 07:45:11 +00:00
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
if ( STILL_ACTIVE == dwExitCode )
|
2004-11-23 07:45:11 +00:00
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
m_pDocument->CoreClientQuit();
|
|
|
|
for ( iCount = 0; iCount <= 10; iCount++ )
|
2004-11-23 07:45:11 +00:00
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
if ( !bClientQuit && GetExitCodeProcess( m_hBOINCCoreProcess, &dwExitCode ) )
|
2005-01-06 22:25:53 +00:00
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
if ( STILL_ACTIVE != dwExitCode )
|
|
|
|
{
|
|
|
|
bClientQuit = true;
|
|
|
|
continue;
|
|
|
|
}
|
2005-01-06 22:25:53 +00:00
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
::wxSleep(1);
|
|
|
|
}
|
2004-11-23 07:45:11 +00:00
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2005-01-07 20:47:40 +00:00
|
|
|
|
|
|
|
if ( !bClientQuit )
|
|
|
|
::wxKill( m_lBOINCCoreProcessId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-07 07:32:23 +00:00
|
|
|
#else
|
2005-01-07 20:47:40 +00:00
|
|
|
|
|
|
|
void CBOINCGUIApp::ShutdownBOINCCore()
|
|
|
|
{
|
|
|
|
wxInt32 iCount = 0;
|
|
|
|
bool bClientQuit = false;
|
|
|
|
|
|
|
|
if ( m_bBOINCStartedByManager )
|
|
|
|
{
|
|
|
|
if ( wxProcess::Exists( m_lBOINCCoreProcessId ) )
|
|
|
|
{
|
|
|
|
m_pDocument->CoreClientQuit();
|
|
|
|
for ( iCount = 0; iCount <= 10; iCount++ )
|
|
|
|
{
|
|
|
|
if ( !bClientQuit && !wxProcess::Exists( m_lBOINCCoreProcessId ) )
|
|
|
|
{
|
|
|
|
bClientQuit = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
::wxSleep(1);
|
|
|
|
}
|
2005-01-07 07:32:23 +00:00
|
|
|
}
|
2005-01-07 20:47:40 +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
|
|
|
|
2004-12-14 02:50:16 +00:00
|
|
|
wxInt32 CBOINCGUIApp::StartupSystemIdleDetection()
|
|
|
|
{
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
// load dll and start idle detection
|
2005-01-07 07:32:23 +00:00
|
|
|
m_hIdleDetectionDll = LoadLibrary("boinc.dll");
|
|
|
|
if(m_hIdleDetectionDll)
|
2004-12-14 02:50:16 +00:00
|
|
|
{
|
|
|
|
IdleTrackerInit fn;
|
2005-01-07 07:32:23 +00:00
|
|
|
fn = (IdleTrackerInit)GetProcAddress(m_hIdleDetectionDll, wxT("IdleTrackerInit"));
|
2004-12-14 02:50:16 +00:00
|
|
|
if(!fn)
|
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
FreeLibrary(m_hIdleDetectionDll);
|
|
|
|
m_hIdleDetectionDll = NULL;
|
2004-12-14 02:50:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!fn())
|
|
|
|
{
|
2005-01-07 07:32:23 +00:00
|
|
|
FreeLibrary(m_hIdleDetectionDll);
|
|
|
|
m_hIdleDetectionDll = NULL;
|
2004-12-14 02:50:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCGUIApp::ShutdownSystemIdleDetection()
|
|
|
|
{
|
|
|
|
#ifdef __WXMSW__
|
2005-01-07 07:32:23 +00:00
|
|
|
if(m_hIdleDetectionDll) {
|
2004-12-14 02:50:16 +00:00
|
|
|
IdleTrackerTerm fn;
|
2005-01-07 07:32:23 +00:00
|
|
|
fn = (IdleTrackerTerm)GetProcAddress(m_hIdleDetectionDll, wxT("IdleTrackerTerm"));
|
|
|
|
if(fn)
|
|
|
|
{
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
FreeLibrary(m_hIdleDetectionDll);
|
|
|
|
m_hIdleDetectionDll = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxInt32 CBOINCGUIApp::UpdateSystemIdleDetection()
|
|
|
|
{
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
if (m_hIdleDetectionDll)
|
|
|
|
{
|
|
|
|
IdleTrackerGetIdleTickCount fn;
|
|
|
|
fn = (IdleTrackerGetIdleTickCount)GetProcAddress(m_hIdleDetectionDll, wxT("IdleTrackerGetIdleTickCount"));
|
2004-12-14 02:50:16 +00:00
|
|
|
if(fn)
|
|
|
|
{
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_487cbf3018 = "$Id$";
|