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
//
#define IDS_FAILED 1
#define IDD_SYNERGY 101
#define IDI_SYNERGY 103
#define IDC_LOG 1000
#define IDI_SYNERGY 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#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_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101

View File

@ -447,16 +447,26 @@ parse(int argc, const char** argv)
#include "CMSWindowsScreen.h"
static bool s_hasImportantLogMessages = false;
static
bool
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);
return true;
}
else {
return s_backend;
return false;
}
}
@ -487,6 +497,9 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
// parse command line
parse(argc, argv);
// cannot run as backend if running as a service
s_backend = false;
// run as a service
return platform->runDaemon(realMain, daemonStop);
}
@ -560,6 +573,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
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;
}

View File

@ -47,40 +47,6 @@ END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_SYNERGY DIALOG DISCARDABLE 0, 0, 329, 158
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Synergy"
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_LOG,7,7,315,144,ES_MULTILINE | ES_AUTOHSCROLL |
ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_SYNERGY, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 322
TOPMARGIN, 7
BOTTOMMARGIN, 151
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
@ -92,6 +58,16 @@ IDI_SYNERGY ICON DISCARDABLE "synergyc.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_FAILED "Synergy is about to quit with errors or warnings. Please check the log then click OK."
END
#ifndef APSTUDIO_INVOKED

View File

@ -1,19 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by synergyd.rc
// Used by synergys.rc
//
#define IDS_FAILED 1
#define IDD_SYNERGY 101
#define IDI_SYNERGY 102
#define IDC_LOG 1000
#define IDI_SYNERGY 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#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_CONTROL_VALUE 1002
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -579,16 +579,26 @@ loadConfig()
#include "CMSWindowsScreen.h"
static bool s_hasImportantLogMessages = false;
static
bool
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);
return true;
}
else {
return s_backend;
return false;
}
}
@ -619,6 +629,9 @@ daemonStartup(IPlatform* iplatform, int argc, const char** argv)
// parse command line
parse(argc, argv);
// cannot run as backend if running as a service
s_backend = false;
// load configuration
loadConfig();
@ -698,6 +711,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
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;
}

View File

@ -47,41 +47,6 @@ END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_SYNERGY DIALOG DISCARDABLE 0, 0, 531, 159
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Synergy"
FONT 8, "MS Sans Serif"
BEGIN
LISTBOX IDC_LOG,7,7,517,145,NOT LBS_NOTIFY |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_SYNERGY, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 524
TOPMARGIN, 7
BOTTOMMARGIN, 152
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
@ -98,7 +63,7 @@ IDI_SYNERGY ICON DISCARDABLE "synergys.ico"
STRINGTABLE DISCARDABLE
BEGIN
IDS_FAILED "Synergy is about to quit with an error. Please check the log for error messages then click OK."
IDS_FAILED "Synergy is about to quit with errors or warnings. Please check the log then click OK."
END
#endif // English (U.S.) resources