- client: Remove some more Win9x code.

- client: Add some messages while handling Windows power events.
    
    client/
        main.cpp

svn path=/trunk/boinc/; revision=18665
This commit is contained in:
Rom Walton 2009-07-23 17:01:01 +00:00
parent 98727ab31a
commit ed797510e4
2 changed files with 16 additions and 29 deletions

View File

@ -6417,3 +6417,10 @@ David 22 July 2009
work_fetch.cpp work_fetch.cpp
clientgui/ clientgui/
ViewTransfers.cpp ViewTransfers.cpp
Rom 23 July 2009
- client: Remove some more Win9x code.
- client: Add some messages while handling Windows power events.
client/
main.cpp

View File

@ -28,7 +28,6 @@
extern HINSTANCE g_hClientLibraryDll; extern HINSTANCE g_hClientLibraryDll;
static HANDLE g_hWindowsMonitorSystemThread = NULL; static HANDLE g_hWindowsMonitorSystemThread = NULL;
static DWORD g_WindowsMonitorSystemThreadID = NULL; static DWORD g_WindowsMonitorSystemThreadID = NULL;
static BOOL g_bIsWin9x = FALSE;
static bool requested_suspend = false; static bool requested_suspend = false;
static bool requested_resume = false; static bool requested_resume = false;
@ -83,10 +82,11 @@ typedef void (CALLBACK* ClientLibraryShutdown)();
int finalize(); int finalize();
// Determine when it is safe to leave the quit_client() handler
// and allow Windows to finish cleaning up.
static bool boinc_cleanup_completed = false; static bool boinc_cleanup_completed = false;
// Used on Windows 95/98/ME to determine when it is safe to leave
// the WM_ENDSESSION message handler and allow Windows to finish
// cleaning up.
// Display a message to the user. // Display a message to the user.
// Depending on the priority, the message may be more or less obtrusive // Depending on the priority, the message may be more or less obtrusive
@ -96,9 +96,6 @@ void show_message(PROJECT *p, char* msg, int priority) {
char message[1024]; char message[1024];
time_t now = time(0); time_t now = time(0);
char* time_string = time_to_string((double)now); char* time_string = time_to_string((double)now);
#if defined(WIN32) && defined(_CONSOLE)
char event_message[2048];
#endif
// Cycle the log files if we need to // Cycle the log files if we need to
diagnostics_cycle_logs(); diagnostics_cycle_logs();
@ -127,6 +124,7 @@ void show_message(PROJECT *p, char* msg, int priority) {
printf("%s [%s] %s\n", time_string, x, message); printf("%s [%s] %s\n", time_string, x, message);
if (gstate.executing_as_daemon) { if (gstate.executing_as_daemon) {
#if defined(WIN32) && defined(_CONSOLE) #if defined(WIN32) && defined(_CONSOLE)
char event_message[2048];
stprintf(event_message, TEXT("%s [%s] %s\n"), time_string, x, message); stprintf(event_message, TEXT("%s [%s] %s\n"), time_string, x, message);
::OutputDebugString(event_message); ::OutputDebugString(event_message);
#endif #endif
@ -161,26 +159,10 @@ void resume_client() {
} }
// Trap power events on Windows so we can clean ourselves up. // Trap power events on Windows so we can clean ourselves up.
// Trap logoff/shutdown events on Winows 95/98/ME so we can clean ourselves up.
LRESULT CALLBACK WindowsMonitorSystemWndProc( LRESULT CALLBACK WindowsMonitorSystemWndProc(
HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
) { ) {
switch(uMsg) { switch(uMsg) {
// Win95 is stupid, we really only need to wait until we have
// successfully shutdown the active tasks and cleaned everything
// up. Luckly WM_QUERYENDSESSION is sent before Win9x checks for any
// existing console and that gives us a chance to clean-up and
// then clear the console window. Win9x will not close down
// a console window if anything is displayed on it.
case WM_QUERYENDSESSION:
if (g_bIsWin9x) {
BOINCTRACE("***** Windows Monitor System Shutdown/Logoff Event Detected *****\n");
quit_client();
system("cls");
return TRUE;
}
break;
// On Windows power events are broadcast via the WM_POWERBROADCAST // On Windows power events are broadcast via the WM_POWERBROADCAST
// window message. It has the following parameters: // window message. It has the following parameters:
// PBT_APMQUERYSUSPEND // PBT_APMQUERYSUSPEND
@ -210,16 +192,19 @@ LRESULT CALLBACK WindowsMonitorSystemWndProc(
// System is critically low on battery power. This is // System is critically low on battery power. This is
// only valid on Windows versions older than Vista // only valid on Windows versions older than Vista
case PBT_APMBATTERYLOW: case PBT_APMBATTERYLOW:
msg_printf(NULL, MSG_INFO, "Critical battery alarm, Windows is suspending operations");
suspend_client(true); suspend_client(true);
break; break;
// System is suspending // System is suspending
case PBT_APMSUSPEND: case PBT_APMSUSPEND:
msg_printf(NULL, MSG_INFO, "Windows is suspending operations");
suspend_client(true); suspend_client(true);
break; break;
// System is resuming from a normal power event // System is resuming from a normal power event
case PBT_APMRESUMESUSPEND: case PBT_APMRESUMESUSPEND:
msg_printf(NULL, MSG_INFO, "Windows is resuming operations");
resume_client(); resume_client();
break; break;
} }
@ -601,6 +586,7 @@ int boinc_main_loop() {
DosSleep(0); DosSleep(0);
#endif #endif
} }
return finalize(); return finalize();
} }
@ -765,12 +751,6 @@ int main(int argc, char** argv) {
#ifdef _WIN32 #ifdef _WIN32
// Figure out if we're on Win9x
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
g_bIsWin9x = osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
// //
// Create a window to receive system events that are // Create a window to receive system events that are
// not taken care of by the console APIs. The console // not taken care of by the console APIs. The console