mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4899
This commit is contained in:
parent
9ffae8040e
commit
ba1eb5dc5e
|
@ -21569,4 +21569,22 @@ Janus 18 Dec 2004
|
|||
html/user
|
||||
explain_state.php
|
||||
results.php
|
||||
filtered_post.png [new]
|
||||
filtered_post.png [new]
|
||||
|
||||
Rom 18 Dec 2004
|
||||
- Make the idle detection code work again on the Windows platform.
|
||||
|
||||
Thanks to Eric Toungdale for pointing out what needed to be done to
|
||||
fix it.
|
||||
|
||||
I claened up the orginal implementation a bit, reenabled some of the
|
||||
debugging code that was remarked out.
|
||||
|
||||
client/
|
||||
main.C
|
||||
client/win/
|
||||
hostinfo_win.cpp
|
||||
win_idle_tracker.cpp
|
||||
lib/
|
||||
hostinfo.h
|
||||
|
||||
|
|
|
@ -328,6 +328,17 @@ int main(int argc, char** argv) {
|
|||
return ERR_IO;
|
||||
}
|
||||
|
||||
g_hIdleDetectionDll = LoadLibrary("boinc.dll");
|
||||
if(!g_hIdleDetectionDll)
|
||||
{
|
||||
printf(
|
||||
"BOINC Core Client Error Message\n"
|
||||
"Failed to initialize the BOINC Idle Detection Interface\n"
|
||||
"BOINC will not be able to determine if the user is idle or not...\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
SERVICE_TABLE_ENTRY dispatchTable[] = {
|
||||
{ TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main },
|
||||
{ NULL, NULL }
|
||||
|
@ -353,6 +364,18 @@ int main(int argc, char** argv) {
|
|||
retval = boinc_main_loop(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
if(g_hIdleDetectionDll)
|
||||
{
|
||||
if(!FreeLibrary(g_hIdleDetectionDll))
|
||||
{
|
||||
printf(
|
||||
"BOINC Core Client Error Message\n"
|
||||
"Failed to cleanup the BOINC Idle Detection Interface\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( WinsockCleanup() != 0 ) {
|
||||
printf(
|
||||
"BOINC Core Client Error Message\n"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "hostinfo_network.h"
|
||||
#include "hostinfo.h"
|
||||
|
||||
HINSTANCE m_hIdleDll;
|
||||
HINSTANCE g_hIdleDetectionDll;
|
||||
|
||||
// Returns the number of seconds difference from UTC
|
||||
//
|
||||
|
@ -374,23 +374,15 @@ bool HOST_INFO::host_is_running_on_batteries() {
|
|||
}
|
||||
|
||||
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
|
||||
if (m_hIdleDll) {
|
||||
typedef DWORD (CALLBACK* GetFn)();
|
||||
GetFn fn;
|
||||
fn = (GetFn)GetProcAddress(m_hIdleDll, "IdleTrackerGetLastTickCount");
|
||||
typedef DWORD (CALLBACK* GetFn)();
|
||||
static GetFn fn = (GetFn)GetProcAddress(g_hIdleDetectionDll, "IdleTrackerGetLastTickCount");
|
||||
|
||||
if (g_hIdleDetectionDll) {
|
||||
if (fn) {
|
||||
return (GetTickCount() - fn()) / 1000 > 60 * idle_time_to_run;
|
||||
} else {
|
||||
typedef void (CALLBACK* TermFn)();
|
||||
TermFn tfn;
|
||||
tfn = (TermFn)GetProcAddress(m_hIdleDll, "IdleTrackerTerm");
|
||||
if(tfn) {
|
||||
tfn();
|
||||
}
|
||||
FreeLibrary(m_hIdleDll);
|
||||
m_hIdleDll = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
**/
|
||||
|
||||
#include <windows.h>
|
||||
//#include <crtdbg.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
/**
|
||||
* The following global data is SHARED among all instances of the DLL
|
||||
|
@ -82,8 +82,8 @@ __declspec(dllexport) BOOL IdleTrackerInit()
|
|||
g_hHkMouse = SetWindowsHookEx(WH_MOUSE, MouseTracker, g_hInstance, 0);
|
||||
}
|
||||
|
||||
//_ASSERT(g_hHkKeyboard);
|
||||
//_ASSERT(g_hHkMouse);
|
||||
_ASSERT(g_hHkKeyboard);
|
||||
_ASSERT(g_hHkMouse);
|
||||
|
||||
g_dwLastTick = GetTickCount(); // init count
|
||||
|
||||
|
@ -102,13 +102,13 @@ __declspec(dllexport) void IdleTrackerTerm()
|
|||
if (g_hHkKeyboard)
|
||||
{
|
||||
bResult = UnhookWindowsHookEx(g_hHkKeyboard);
|
||||
//_ASSERT(bResult);
|
||||
_ASSERT(bResult);
|
||||
g_hHkKeyboard = NULL;
|
||||
}
|
||||
if (g_hHkMouse)
|
||||
{
|
||||
bResult = UnhookWindowsHookEx(g_hHkMouse);
|
||||
//_ASSERT(bResult);
|
||||
_ASSERT(bResult);
|
||||
g_hHkMouse = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -123,24 +123,10 @@ int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
|||
DisableThreadLibraryCalls(hInstance);
|
||||
g_hInstance = hInstance;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
//we do an unhook here just in case the user has forgotten.
|
||||
//IdleTrackerTerm();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to prevent the CRT from loading, thus making this a smaller
|
||||
* and faster dll.
|
||||
**/
|
||||
/*extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||
return DllMain( hinstDLL, fdwReason, lpvReserved );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
static volatile const char __attribute__((unused)) *BOINCrcsid="$Id$";
|
||||
#else
|
||||
|
|
|
@ -69,7 +69,7 @@ struct HOST_INFO {
|
|||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
extern HINSTANCE m_hIdleDll; // handle to DLL for user idle
|
||||
extern HINSTANCE g_hIdleDetectionDll; // handle to DLL for user idle
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue