Commit 329303b3 authored by Rom Walton's avatar Rom Walton

- Remove need for boinc.dll from the client.

    
    client/
        hostinfo_win.cpp
        main.cpp
    clientctrl/
        boincsvcctrl.cpp
    clientgui/
        BOINCClientManager.cpp
        BOINCGUIApp.cpp
        BOINCGUIApp.h
        stdwx.h
    clienttray/
        tray_win.cpp
        tray_win.h
    lib/
        boinc_win.h
        daemonmgt.cpp (Deleted)
        daemonmgt.h (Added)
        daemonmgt_win.cpp (Added)
        idlemon.h (Added)
        idlemon_win.cpp (Added)
        idlemon_win.h (Deleted)
    win_build/
        boinc.sln
        boinc_dll.vcproj
        boincmgr.vcproj
        boincsvcctrl.vcproj
        boinctray.vcproj
        libboinc.vcproj

svn path=/trunk/boinc/; revision=19576
parent 7f799360
......@@ -9180,3 +9180,35 @@ David 13 Nov 2009
cs_prefs.cpp
cpu_sched.cpp
log_flags.cpp,h
Rom 13 Nov 2009
- Remove need for boinc.dll from the client.
client/
hostinfo_win.cpp
main.cpp
clientctrl/
boincsvcctrl.cpp
clientgui/
BOINCClientManager.cpp
BOINCGUIApp.cpp
BOINCGUIApp.h
stdwx.h
clienttray/
tray_win.cpp
tray_win.h
lib/
boinc_win.h
daemonmgt.cpp (Deleted)
daemonmgt.h (Added)
daemonmgt_win.cpp (Added)
idlemon.h (Added)
idlemon_win.cpp (Added)
idlemon_win.h (Deleted)
win_build/
boinc.sln
boinc_dll.vcproj
boincmgr.vcproj
boincsvcctrl.vcproj
boinctray.vcproj
libboinc.vcproj
......@@ -15,7 +15,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_)
#include "boinc_win.h"
#endif
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
......@@ -31,8 +34,7 @@
#include "client_msgs.h"
#include "hostinfo_network.h"
#include "hostinfo.h"
HINSTANCE g_hClientLibraryDll;
#include "idlemon.h"
// Newer system metrics values
......@@ -798,15 +800,9 @@ bool HOST_INFO::host_is_running_on_batteries() {
}
bool HOST_INFO::users_idle(bool /*check_all_logins*/, double idle_time_to_run) {
typedef DWORD (CALLBACK* GetFn)();
static GetFn fn = (GetFn)GetProcAddress(g_hClientLibraryDll, "BOINCGetIdleTickCount");
if (g_hClientLibraryDll && fn) {
double seconds_idle = fn() / 1000;
double seconds_time_to_run = 60 * idle_time_to_run;
return seconds_idle > seconds_time_to_run;
}
double seconds_idle = get_idle_tick_count() / 1000;
double seconds_time_to_run = 60 * idle_time_to_run;
return seconds_idle > seconds_time_to_run;
return false;
}
......
......@@ -27,12 +27,6 @@
#define snprintf _snprintf
#endif
extern HINSTANCE g_hClientLibraryDll;
typedef BOOL (CALLBACK* ClientLibraryStartup)();
typedef BOOL (CALLBACK* IdleTrackerStartup)();
typedef void (CALLBACK* IdleTrackerShutdown)();
typedef void (CALLBACK* ClientLibraryShutdown)();
#else
#include "config.h"
#ifdef HAVE_SYS_SOCKET_H
......@@ -59,6 +53,7 @@ typedef void (CALLBACK* ClientLibraryShutdown)();
#include "prefs.h"
#include "filesys.h"
#include "network.h"
#include "idlemon.h"
#include "client_state.h"
#include "file_names.h"
#include "log_flags.h"
......@@ -275,13 +270,6 @@ static void init_core_client(int argc, char** argv) {
int initialize() {
int retval;
#ifdef _WIN32
g_hClientLibraryDll = LoadLibrary("boinc.dll");
if(!g_hClientLibraryDll) {
log_message_error("Failed to initialize the BOINC Client Library.");
}
#endif
if (!config.allow_multiple_clients) {
retval = wait_client_mutex(".", 10);
if (retval) {
......@@ -302,32 +290,14 @@ int initialize() {
curl_init();
#ifdef _WIN32
if(g_hClientLibraryDll) {
ClientLibraryStartup fnClientLibraryStartup;
IdleTrackerStartup fnIdleTrackerStartup;
fnClientLibraryStartup = (ClientLibraryStartup)GetProcAddress(g_hClientLibraryDll, "ClientLibraryStartup");
if(fnClientLibraryStartup) {
if(!fnClientLibraryStartup()) {
log_message_error(
"Failed to initialize the BOINC Client Library Interface."
"BOINC will not be able to determine if the user is idle or not...\n"
);
}
}
fnIdleTrackerStartup = (IdleTrackerStartup)GetProcAddress(g_hClientLibraryDll, "IdleTrackerStartup");
if(fnIdleTrackerStartup) {
if(!fnIdleTrackerStartup()) {
log_message_error(
"Failed to initialize the BOINC Client Library Interface."
"BOINC will not be able to determine if the user is idle or not...\n"
);
}
}
if(!startup_idle_monitor()) {
log_message_error(
"Failed to initialize the BOINC Client Library Interface."
"BOINC will not be able to determine if the user is idle or not...\n"
);
}
#endif
return 0;
}
......@@ -411,26 +381,7 @@ int finalize() {
gstate.quit_activities();
#ifdef _WIN32
if(g_hClientLibraryDll) {
IdleTrackerShutdown fnIdleTrackerShutdown;
ClientLibraryShutdown fnClientLibraryShutdown;
fnIdleTrackerShutdown = (IdleTrackerShutdown)GetProcAddress(g_hClientLibraryDll, "IdleTrackerShutdown");
if(fnIdleTrackerShutdown) {
fnIdleTrackerShutdown();
}
fnClientLibraryShutdown = (ClientLibraryShutdown)GetProcAddress(g_hClientLibraryDll, "ClientLibraryShutdown");
if(fnClientLibraryShutdown) {
fnClientLibraryShutdown();
}
if(!FreeLibrary(g_hClientLibraryDll)) {
log_message_error("Failed to cleanup the BOINC Idle Detection Interface");
}
g_hClientLibraryDll = NULL;
}
shutdown_idle_monitor();
#ifdef USE_WINSOCK
if (WinsockCleanup()) {
......
......@@ -20,13 +20,10 @@
#endif
#include "version.h"
EXTERN_C BOOL StartBOINCServiceEx();
EXTERN_C BOOL StopBOINCServiceEx();
#include "daemonmgt.h"
void version(){
printf("boincsvcctrl, built from %s \n", PACKAGE_STRING );
printf("boincsvcctrl, built from %s \n", PACKAGE_STRING );
exit(0);
}
......@@ -58,11 +55,11 @@ int main(int argc, char** argv) {
}
if (!strcmp(argv[i], "--start")) {
retval = !StartBOINCServiceEx();
retval = !start_daemon();
}
if (!strcmp(argv[i], "--stop")) {
retval = !StopBOINCServiceEx();
retval = !stop_daemon();
}
exit(retval);
......
......@@ -29,8 +29,8 @@
#include "BOINCClientManager.h"
#include "error_numbers.h"
#include "procinfo.h"
#include "filesys.h"
#include "daemonmgt.h"
#include "util.h"
#ifdef __WXMAC__
......@@ -45,13 +45,6 @@ enum {
#include "diagnostics_win.h"
extern int diagnostics_get_process_information(PVOID* ppBuffer, PULONG pcbBuffer);
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();
#else
#include <sys/wait.h>
......@@ -81,7 +74,7 @@ CBOINCClientManager::~CBOINCClientManager() {
bool CBOINCClientManager::AutoRestart() {
if (IsBOINCCoreRunning()) return true;
#ifndef __WXMAC__ // Mac can restart Client as a daemon
if (! m_bBOINCStartedByManager) return false;
if (!m_bBOINCStartedByManager) return false;
#endif
m_lBOINCCoreProcessId = 0;
StartupBOINCCore();
......@@ -103,7 +96,7 @@ bool CBOINCClientManager::IsSystemBooting() {
int CBOINCClientManager::IsBOINCConfiguredAsDaemon() {
bool bReturnValue = false;
#if defined(__WXMSW__)
if (IsBOINCServiceInstalled()) bReturnValue = 1;
if (is_daemon_installed()) bReturnValue = 1;
#elif defined(__WXMAC__)
if ( boinc_file_exists("/Library/LaunchDaemons/edu.berkeley.boinc.plist")) {
bReturnValue = NewStyleDaemon; // New-style daemon uses launchd
......@@ -123,8 +116,8 @@ bool CBOINCClientManager::IsBOINCCoreRunning() {
#ifdef __WXMSW__
char buf[MAX_PATH] = "";
if (IsBOINCServiceInstalled()) {
running = (FALSE != IsBOINCServiceStarting()) || (FALSE != IsBOINCServiceRunning());
if (is_daemon_installed()) {
running = (FALSE != is_daemon_starting()) || (FALSE != is_daemon_running());
} else {
// Global mutex on Win2k and later
//
......@@ -195,12 +188,12 @@ bool CBOINCClientManager::StartupBOINCCore() {
if (IsBOINCCoreRunning()) return true;
#if defined(__WXMSW__)
#if defined(__WXMSW__)
LPTSTR szExecute = NULL;
LPTSTR szDataDirectory = NULL;
if (IsBOINCConfiguredAsDaemon()) {
StartBOINCService();
start_daemon_via_daemonctrl();
m_bBOINCStartedByManager = true;
bReturnValue = IsBOINCCoreRunning();
......@@ -434,7 +427,7 @@ void CBOINCClientManager::ShutdownBOINCCore() {
if (m_bBOINCStartedByManager) {
#ifdef __WXMSW__
if (IsBOINCConfiguredAsDaemon()) {
StopBOINCService();
stop_daemon_via_daemonctrl();
bClientQuit = true;
} else
#endif
......
......@@ -36,6 +36,7 @@
#include "mfile.h"
#include "miofile.h"
#include "parse.h"
#include "idlemon.h"
#include "Events.h"
#include "common/wxFlatNotebook.h"
#include "LogBOINC.h"
......@@ -52,15 +53,6 @@
#include "DlgExitMessage.h"
#ifdef __WXMSW__
EXTERN_C BOOL ClientLibraryStartup();
EXTERN_C BOOL IdleTrackerAttach();
EXTERN_C void IdleTrackerDetach();
EXTERN_C void ClientLibraryShutdown();
EXTERN_C DWORD BOINCGetIdleTickCount();
#endif
DEFINE_EVENT_TYPE(wxEVT_RPC_FINISHED)
IMPLEMENT_APP(CBOINCGUIApp)
......@@ -456,7 +448,6 @@ bool CBOINCGUIApp::OnInit() {
// Startup the System Idle Detection code
ClientLibraryStartup();
IdleTrackerAttach();
#ifdef __WXMAC__
......@@ -499,7 +490,6 @@ bool CBOINCGUIApp::OnInit() {
int CBOINCGUIApp::OnExit() {
// Shutdown the System Idle Detection code
IdleTrackerDetach();
ClientLibraryShutdown();
if (m_pDocument) {
m_pDocument->OnExit();
......@@ -746,17 +736,9 @@ void CBOINCGUIApp::InitSupportedLanguages() {
}
int CBOINCGUIApp::ClientLibraryStartup() {
#ifdef __WXMSW__
::ClientLibraryStartup();
#endif
return 0;
}
int CBOINCGUIApp::IdleTrackerAttach() {
#ifdef __WXMSW__
::IdleTrackerAttach();
::attach_idle_monitor();
#endif
return 0;
}
......@@ -764,15 +746,7 @@ int CBOINCGUIApp::IdleTrackerAttach() {
int CBOINCGUIApp::IdleTrackerDetach() {
#ifdef __WXMSW__
::IdleTrackerDetach();
#endif
return 0;
}
int CBOINCGUIApp::ClientLibraryShutdown() {
#ifdef __WXMSW__
::ClientLibraryShutdown();
::detach_idle_monitor();
#endif
return 0;
}
......@@ -801,7 +775,7 @@ void CBOINCGUIApp::OnSystemShutDown( wxCloseEvent& event ) {
int CBOINCGUIApp::UpdateSystemIdleDetection() {
#ifdef __WXMSW__
return BOINCGetIdleTickCount();
return get_idle_tick_count();
#else
return TRUE;
#endif
......
......@@ -64,10 +64,8 @@ protected:
void InitSupportedLanguages();
int ClientLibraryStartup();
int IdleTrackerAttach();
int IdleTrackerDetach();
int ClientLibraryShutdown();
wxConfig* m_pConfig;
wxLocale* m_pLocale;
......
......@@ -21,22 +21,18 @@
#ifdef _WIN32
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
// Target Windows 2000 or better with Internet Explorer 5.01 or better
#ifndef WINVER
#define WINVER 0x0500
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0400 // Change this to the appropriate value to target Windows Me or later.
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0500
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 5.01 or later.
#define _WIN32_IE 0x0501 // Change this to the appropriate value to target IE 6.0 or later.
#ifndef _WIN32_IE
#define _WIN32_IE 0x0501
#endif
#endif
......
......@@ -20,13 +20,9 @@
#include "boinc_tray.h"
#include "tray_win.h"
#include "idlemon.h"
EXTERN_C BOOL ClientLibraryStartup();
EXTERN_C BOOL IdleTrackerAttach();
EXTERN_C void IdleTrackerDetach();
EXTERN_C void ClientLibraryShutdown();
EXTERN_C DWORD BOINCGetIdleTickCount();
HMODULE g_hModule = NULL;
static CBOINCTray* gspBOINCTray = NULL;
......@@ -42,14 +38,13 @@ INT WINAPI WinMain(
CBOINCTray::CBOINCTray() {
gspBOINCTray = this;
m_hDataManagementThread = NULL;
m_bClientLibraryInitialized = FALSE;
m_bIdleTrackerInitialized = FALSE;
}
// Starts main execution of BOINC Tray.
//
INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR /* lpCmdLine */ , int /* nCmdShow */ ) {
if (!hPrevInstance) {
// Register an appropriate window class for the primary window
......@@ -73,7 +68,7 @@ INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
hWnd = CreateWindow(
_T("BOINCTrayWndClass"),
_T("BOINC SystemTray Applet"),
_T("BOINC System Tray Applet"),
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL
);
......@@ -86,9 +81,8 @@ INT CBOINCTray::Run( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
}
// Cleanup and shutdown the BOINC client library idle tracking system.
IdleTrackerDetach();
ClientLibraryShutdown();
// Cleanup and shutdown the BOINC idle tracking system.
detach_idle_monitor();
return msg.wParam;
}
......@@ -133,20 +127,15 @@ BOOL CBOINCTray::DestroyDataManagementThread() {
//
DWORD WINAPI CBOINCTray::DataManagementProc() {
while (true) {
if (!m_bClientLibraryInitialized || !m_bIdleTrackerInitialized) {
// On Vista systems, only elevated processes can create shared memory
// area's across various user sessions. In this case we need to wait
// for BOINC to create the shared memory area and then boinctray can
// successfully attach to it. What a PITA.
if (!m_bClientLibraryInitialized) {
m_bClientLibraryInitialized = ClientLibraryStartup();
}
if (m_bClientLibraryInitialized && !m_bIdleTrackerInitialized) {
m_bIdleTrackerInitialized = IdleTrackerAttach();
}
// On Vista systems, only elevated processes can create shared memory
// area's across various user sessions. In this case we need to wait
// for BOINC to create the shared memory area and then boinctray can
// successfully attach to it. What a PITA.
if (!m_bIdleTrackerInitialized) {
m_bIdleTrackerInitialized = attach_idle_monitor();
}
BOINCGetIdleTickCount();
get_idle_tick_count();
Sleep(5000);
}
}
......@@ -194,6 +183,3 @@ LRESULT CALLBACK CBOINCTray::TrayProcStub(
) {
return gspBOINCTray->TrayProc(hWnd, uMsg, wParam, lParam);
}
const char *BOINC_RCSID_116269c72f = "$Id: screensaver_win.cpp 13819 2007-10-10 09:25:40Z fthomas $";
......@@ -41,7 +41,6 @@ protected:
static LRESULT CALLBACK TrayProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
HANDLE m_hDataManagementThread;
BOOL m_bClientLibraryInitialized;
BOOL m_bIdleTrackerInitialized;
};
......
......@@ -41,7 +41,7 @@
#endif
#endif
// Target Windows 2000 or better with Internet Explorer 5.0 or better
// Target Windows 2000 or better with Internet Explorer 5.01 or better
#ifndef WINVER
#define WINVER 0x0500
#endif
......@@ -52,7 +52,7 @@
#define _WIN32_WINDOWS 0x0500
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500
#define _WIN32_IE 0x0501
#endif
#include <windows.h>
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC 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.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#ifndef _BOINC_DAEMONMANAGEMENT_H_
#define _BOINC_DAEMONMANAGEMENT_H_
extern bool is_daemon_installed();
extern bool is_daemon_starting();
extern bool is_daemon_running();
extern bool is_daemon_stopping();
extern bool is_daemon_stopped();
extern bool start_daemon_via_daemonctrl();
extern bool start_daemon();
extern bool stop_daemon_via_daemonctrl();
extern bool stop_daemon();
#endif
\ No newline at end of file
......@@ -15,17 +15,18 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
#if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_)
#include "boinc_win.h"
#endif
/**
* Find out if BOINC has been installed as a service.
**/
EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled()
bool is_daemon_installed()
{
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
BOOL bRetVal = FALSE;
bool bRetVal = false;
schSCManager = OpenSCManager(
NULL, // local machine
......@@ -41,7 +42,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled()
if (schService)
{
bRetVal = TRUE;
bRetVal = true;
}
}
......@@ -58,12 +59,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceInstalled()
/**
* Find out if BOINC has been told to start.
**/
EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting()
bool is_daemon_starting()
{
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_STATUS ssStatus;
BOOL bRetVal = FALSE;
bool bRetVal = false;
schSCManager = OpenSCManager(
NULL, // local machine
......@@ -82,7 +83,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting()
if (QueryServiceStatus(schService, &ssStatus))
{
if (ssStatus.dwCurrentState == SERVICE_START_PENDING)
bRetVal = TRUE;
bRetVal = true;
}
}
}
......@@ -100,12 +101,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStarting()
/**
* Find out if BOINC is executing as a service.
**/
EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning()
bool is_daemon_running()
{
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_STATUS ssStatus;
BOOL bRetVal = FALSE;
bool bRetVal = false;
schSCManager = OpenSCManager(
NULL, // local machine
......@@ -124,7 +125,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning()
if (QueryServiceStatus(schService, &ssStatus))
{
if (ssStatus.dwCurrentState == SERVICE_RUNNING)
bRetVal = TRUE;
bRetVal = true;
}
}
}
......@@ -142,12 +143,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceRunning()
/**
* Find out if BOINC has been told to stop.
**/
EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping()
bool is_daemon_stopping()
{
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_STATUS ssStatus;
BOOL bRetVal = FALSE;
bool bRetVal = false;
schSCManager = OpenSCManager(
NULL, // local machine
......@@ -166,7 +167,7 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping()
if (QueryServiceStatus(schService, &ssStatus))
{
if (ssStatus.dwCurrentState == SERVICE_STOP_PENDING)
bRetVal = TRUE;
bRetVal = true;
}
}
}
......@@ -184,12 +185,12 @@ EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopping()
/**
* Find out if BOINC has stopped executing as a service.
**/
EXTERN_C __declspec(dllexport) BOOL IsBOINCServiceStopped()
bool is_daemon_stopped()
{
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
SERVICE_STATUS ssStatus;