Fixed backend mode. Now reports log messages and, if any are

serious, shows a message box before exiting.
This commit is contained in:
crs 2002-09-14 12:03:43 +00:00
parent 152eddc0c6
commit 06856e170d
6 changed files with 219 additions and 238 deletions

View File

@ -3,15 +3,13 @@
// Used by synergyc.rc // Used by synergyc.rc
// //
#define IDS_FAILED 1 #define IDS_FAILED 1
#define IDD_SYNERGY 101 #define IDI_SYNERGY 101
#define IDI_SYNERGY 103
#define IDC_LOG 1000
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104 #define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101

View File

@ -447,16 +447,26 @@ parse(int argc, const char** argv)
#include "CMSWindowsScreen.h" #include "CMSWindowsScreen.h"
static bool s_hasImportantLogMessages = false;
static static
bool bool
logMessageBox(int priority, const char* msg) logMessageBox(int priority, const char* msg)
{ {
if (priority <= (s_backend ? CLog::kERROR : CLog::kFATAL)) { // note any important messages the user may need to know about
if (priority <= CLog::kWARNING) {
s_hasImportantLogMessages = true;
}
// FATAL and PRINT messages get a dialog box if not running as
// backend. if we're running as a backend the user will have
// a chance to see the messages when we exit.
if (!s_backend && priority <= CLog::kFATAL) {
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING); MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
return true; return true;
} }
else { else {
return s_backend; return false;
} }
} }
@ -487,6 +497,9 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
// parse command line // parse command line
parse(argc, argv); parse(argc, argv);
// cannot run as backend if running as a service
s_backend = false;
// run as a service // run as a service
return platform->runDaemon(realMain, daemonStop); return platform->runDaemon(realMain, daemonStop);
} }
@ -560,6 +573,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
CNetwork::cleanup(); CNetwork::cleanup();
// let user examine any messages if we're running as a backend
// by putting up a dialog box before exiting.
if (s_backend && s_hasImportantLogMessages) {
char msg[1024];
msg[0] = '\0';
LoadString(instance, IDS_FAILED, msg, sizeof(msg) / sizeof(msg[0]));
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
}
return result; return result;
} }

View File

@ -1,106 +1,82 @@
//Microsoft Developer Studio generated resource script. //Microsoft Developer Studio generated resource script.
// //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
#include "afxres.h" #include "afxres.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources // English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32 #ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252) #pragma code_page(1252)
#endif //_WIN32 #endif //_WIN32
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE DISCARDABLE 1 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE DISCARDABLE 2 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"#include ""afxres.h""\r\n" "#include ""afxres.h""\r\n"
"\0" "\0"
END END
3 TEXTINCLUDE DISCARDABLE 3 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"\r\n" "\r\n"
"\0" "\0"
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog // Icon
// //
IDD_SYNERGY DIALOG DISCARDABLE 0, 0, 329, 158 // Icon with lowest ID value placed first to ensure application icon
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU // remains consistent on all systems.
CAPTION "Synergy" IDI_SYNERGY ICON DISCARDABLE "synergyc.ico"
FONT 8, "MS Sans Serif" #endif // English (U.S.) resources
BEGIN /////////////////////////////////////////////////////////////////////////////
EDITTEXT IDC_LOG,7,7,315,144,ES_MULTILINE | ES_AUTOHSCROLL |
ES_READONLY | WS_VSCROLL | WS_HSCROLL /////////////////////////////////////////////////////////////////////////////
END //
// String Table
//
/////////////////////////////////////////////////////////////////////////////
// STRINGTABLE DISCARDABLE
// DESIGNINFO BEGIN
// IDS_FAILED "Synergy is about to quit with errors or warnings. Please check the log then click OK."
END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_SYNERGY, DIALOG #ifndef APSTUDIO_INVOKED
BEGIN /////////////////////////////////////////////////////////////////////////////
LEFTMARGIN, 7 //
RIGHTMARGIN, 322 // Generated from the TEXTINCLUDE 3 resource.
TOPMARGIN, 7 //
BOTTOMMARGIN, 151
END
END /////////////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED #endif // not APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SYNERGY ICON DISCARDABLE "synergyc.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,19 +1,17 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file. // Microsoft Developer Studio generated include file.
// Used by synergyd.rc // Used by synergys.rc
// //
#define IDS_FAILED 1 #define IDS_FAILED 1
#define IDD_SYNERGY 101 #define IDI_SYNERGY 101
#define IDI_SYNERGY 102
#define IDC_LOG 1000
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103 #define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002 #define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View File

@ -579,16 +579,26 @@ loadConfig()
#include "CMSWindowsScreen.h" #include "CMSWindowsScreen.h"
static bool s_hasImportantLogMessages = false;
static static
bool bool
logMessageBox(int priority, const char* msg) logMessageBox(int priority, const char* msg)
{ {
if (priority <= (s_backend ? CLog::kERROR : CLog::kFATAL)) { // note any important messages the user may need to know about
if (priority <= CLog::kWARNING) {
s_hasImportantLogMessages = true;
}
// FATAL and PRINT messages get a dialog box if not running as
// backend. if we're running as a backend the user will have
// a chance to see the messages when we exit.
if (!s_backend && priority <= CLog::kFATAL) {
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING); MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
return true; return true;
} }
else { else {
return s_backend; return false;
} }
} }
@ -619,6 +629,9 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
// parse command line // parse command line
parse(argc, argv); parse(argc, argv);
// cannot run as backend if running as a service
s_backend = false;
// load configuration // load configuration
loadConfig(); loadConfig();
@ -698,6 +711,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
CNetwork::cleanup(); CNetwork::cleanup();
// let user examine any messages if we're running as a backend
// by putting up a dialog box before exiting.
if (s_backend && s_hasImportantLogMessages) {
char msg[1024];
msg[0] = '\0';
LoadString(instance, IDS_FAILED, msg, sizeof(msg) / sizeof(msg[0]));
MessageBox(NULL, msg, pname, MB_OK | MB_ICONWARNING);
}
return result; return result;
} }

View File

@ -1,118 +1,83 @@
//Microsoft Developer Studio generated resource script. //Microsoft Developer Studio generated resource script.
// //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
#include "afxres.h" #include "afxres.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources // English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32 #ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252) #pragma code_page(1252)
#endif //_WIN32 #endif //_WIN32
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE DISCARDABLE 1 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE DISCARDABLE 2 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"#include ""afxres.h""\r\n" "#include ""afxres.h""\r\n"
"\0" "\0"
END END
3 TEXTINCLUDE DISCARDABLE 3 TEXTINCLUDE DISCARDABLE
BEGIN BEGIN
"\r\n" "\r\n"
"\0" "\0"
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog // Icon
// //
IDD_SYNERGY DIALOG DISCARDABLE 0, 0, 531, 159 // Icon with lowest ID value placed first to ensure application icon
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU // remains consistent on all systems.
CAPTION "Synergy" IDI_SYNERGY ICON DISCARDABLE "synergys.ico"
FONT 8, "MS Sans Serif"
BEGIN /////////////////////////////////////////////////////////////////////////////
LISTBOX IDC_LOG,7,7,517,145,NOT LBS_NOTIFY | //
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | // String Table
WS_TABSTOP //
END
STRINGTABLE DISCARDABLE
BEGIN
///////////////////////////////////////////////////////////////////////////// IDS_FAILED "Synergy is about to quit with errors or warnings. Please check the log then click OK."
// END
// DESIGNINFO
// #endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_SYNERGY, DIALOG #ifndef APSTUDIO_INVOKED
BEGIN /////////////////////////////////////////////////////////////////////////////
LEFTMARGIN, 7 //
RIGHTMARGIN, 524 // Generated from the TEXTINCLUDE 3 resource.
TOPMARGIN, 7 //
BOTTOMMARGIN, 152
END
END /////////////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED #endif // not APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SYNERGY ICON DISCARDABLE "synergys.ico"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_FAILED "Synergy is about to quit with an error. Please check the log for error messages then click OK."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED