Added operating system identification log message for debugging

purposes.
This commit is contained in:
crs 2004-11-01 22:25:39 +00:00
parent 5717460221
commit 4d427a091d
11 changed files with 233 additions and 7 deletions

View File

@ -480,6 +480,9 @@ run(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup)
// through the task bar. // through the task bar.
s_taskBarReceiver = createTaskBarReceiver(&logBuffer); s_taskBarReceiver = createTaskBarReceiver(&logBuffer);
// identify system
LOG((CLOG_INFO "Synergy client on %s", ARCH->getOSName().c_str()));
// run // run
int result = startup(argc, argv); int result = startup(argc, argv);

View File

@ -150,6 +150,7 @@ static CPrimaryClient* s_primaryClient = NULL;
static CClientListener* s_listener = NULL; static CClientListener* s_listener = NULL;
static CServerTaskBarReceiver* s_taskBarReceiver = NULL; static CServerTaskBarReceiver* s_taskBarReceiver = NULL;
static CEvent::Type s_reloadConfigEvent = CEvent::kUnknown; static CEvent::Type s_reloadConfigEvent = CEvent::kUnknown;
static CEvent::Type s_forceReconnectEvent = CEvent::kUnknown;
CEvent::Type CEvent::Type
getReloadConfigEvent() getReloadConfigEvent()
@ -157,6 +158,12 @@ getReloadConfigEvent()
return CEvent::registerTypeOnce(s_reloadConfigEvent, "reloadConfig"); return CEvent::registerTypeOnce(s_reloadConfigEvent, "reloadConfig");
} }
CEvent::Type
getForceReconnectEvent()
{
return CEvent::registerTypeOnce(s_forceReconnectEvent, "forceReconnect");
}
static static
void void
updateStatus() updateStatus()
@ -425,6 +432,15 @@ reloadConfig(const CEvent&, void*)
} }
} }
static
void
forceReconnect(const CEvent&, void*)
{
if (s_server != NULL) {
s_server->disconnect();
}
}
static static
int int
mainLoop() mainLoop()
@ -472,6 +488,12 @@ mainLoop()
IEventQueue::getSystemTarget(), IEventQueue::getSystemTarget(),
new CFunctionEventJob(&reloadConfig)); new CFunctionEventJob(&reloadConfig));
// handle force reconnect event by disconnecting clients. they'll
// reconnect automatically.
EVENTQUEUE->adoptHandler(getForceReconnectEvent(),
IEventQueue::getSystemTarget(),
new CFunctionEventJob(&forceReconnect));
// run event loop. if startServer() failed we're supposed to retry // run event loop. if startServer() failed we're supposed to retry
// later. the timer installed by startServer() will take care of // later. the timer installed by startServer() will take care of
// that. // that.
@ -487,6 +509,8 @@ mainLoop()
// close down // close down
LOG((CLOG_DEBUG1 "stopping server")); LOG((CLOG_DEBUG1 "stopping server"));
EVENTQUEUE->removeHandler(getForceReconnectEvent(),
IEventQueue::getSystemTarget());
EVENTQUEUE->removeHandler(getReloadConfigEvent(), EVENTQUEUE->removeHandler(getReloadConfigEvent(),
IEventQueue::getSystemTarget()); IEventQueue::getSystemTarget());
stopServer(); stopServer();
@ -545,6 +569,9 @@ run(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup)
// through the task bar. // through the task bar.
s_taskBarReceiver = createTaskBarReceiver(&logBuffer); s_taskBarReceiver = createTaskBarReceiver(&logBuffer);
// identify system
LOG((CLOG_INFO "Synergy server on %s", ARCH->getOSName().c_str()));
// run // run
int result = startup(argc, argv); int result = startup(argc, argv);

View File

@ -90,6 +90,7 @@ dnl checks for header files
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h wchar.h alloca.h]) AC_CHECK_HEADERS([unistd.h sys/time.h sys/types.h wchar.h alloca.h])
AC_CHECK_HEADERS([sys/socket.h sys/select.h]) AC_CHECK_HEADERS([sys/socket.h sys/select.h])
AC_CHECK_HEADERS([sys/utsname.h])
AC_CHECK_HEADERS([istream ostream sstream]) AC_CHECK_HEADERS([istream ostream sstream])
AC_HEADER_TIME AC_HEADER_TIME
if test x"$acx_host_winapi" = xXWINDOWS; then if test x"$acx_host_winapi" = xXWINDOWS; then

View File

@ -23,6 +23,7 @@
#undef ARCH_NETWORK #undef ARCH_NETWORK
#undef ARCH_SLEEP #undef ARCH_SLEEP
#undef ARCH_STRING #undef ARCH_STRING
#undef ARCH_SYSTEM
#undef ARCH_TASKBAR #undef ARCH_TASKBAR
#undef ARCH_TIME #undef ARCH_TIME
@ -37,6 +38,7 @@
# include "CArchNetworkWinsock.h" # include "CArchNetworkWinsock.h"
# include "CArchSleepWindows.h" # include "CArchSleepWindows.h"
# include "CArchStringWindows.h" # include "CArchStringWindows.h"
# include "CArchSystemWindows.h"
# include "CArchTaskBarWindows.h" # include "CArchTaskBarWindows.h"
# include "CArchTimeWindows.h" # include "CArchTimeWindows.h"
#elif SYSAPI_UNIX #elif SYSAPI_UNIX
@ -50,6 +52,7 @@
# include "CArchNetworkBSD.h" # include "CArchNetworkBSD.h"
# include "CArchSleepUnix.h" # include "CArchSleepUnix.h"
# include "CArchStringUnix.h" # include "CArchStringUnix.h"
# include "CArchSystemUnix.h"
# include "CArchTaskBarXWindows.h" # include "CArchTaskBarXWindows.h"
# include "CArchTimeUnix.h" # include "CArchTimeUnix.h"
#endif #endif
@ -86,6 +89,10 @@
# error unsupported platform for string # error unsupported platform for string
#endif #endif
#if !defined(ARCH_SYSTEM)
# error unsupported platform for system
#endif
#if !defined(ARCH_TASKBAR) #if !defined(ARCH_TASKBAR)
# error unsupported platform for taskbar # error unsupported platform for taskbar
#endif #endif
@ -108,6 +115,7 @@ CArch::CArch(ARCH_ARGS* args)
// create architecture implementation objects // create architecture implementation objects
m_mt = new ARCH_MULTITHREAD; m_mt = new ARCH_MULTITHREAD;
m_system = new ARCH_SYSTEM;
m_file = new ARCH_FILE; m_file = new ARCH_FILE;
m_log = new ARCH_LOG; m_log = new ARCH_LOG;
m_net = new ARCH_NETWORK; m_net = new ARCH_NETWORK;
@ -135,6 +143,7 @@ CArch::~CArch()
delete m_net; delete m_net;
delete m_log; delete m_log;
delete m_file; delete m_file;
delete m_system;
delete m_mt; delete m_mt;
// no instance // no instance
@ -581,6 +590,12 @@ CArch::getWideCharEncoding()
return m_string->getWideCharEncoding(); return m_string->getWideCharEncoding();
} }
std::string
CArch::getOSName() const
{
return m_system->getOSName();
}
void void
CArch::addReceiver(IArchTaskBarReceiver* receiver) CArch::addReceiver(IArchTaskBarReceiver* receiver)
{ {

View File

@ -23,6 +23,7 @@
#include "IArchNetwork.h" #include "IArchNetwork.h"
#include "IArchSleep.h" #include "IArchSleep.h"
#include "IArchString.h" #include "IArchString.h"
#include "IArchSystem.h"
#include "IArchTaskBar.h" #include "IArchTaskBar.h"
#include "IArchTime.h" #include "IArchTime.h"
@ -52,6 +53,7 @@ class CArch : public IArchConsole,
public IArchNetwork, public IArchNetwork,
public IArchSleep, public IArchSleep,
public IArchString, public IArchString,
public IArchSystem,
public IArchTaskBar, public IArchTaskBar,
public IArchTime { public IArchTime {
public: public:
@ -167,6 +169,9 @@ public:
virtual EWideCharEncoding virtual EWideCharEncoding
getWideCharEncoding(); getWideCharEncoding();
// IArchSystem overrides
virtual std::string getOSName() const;
// IArchTaskBar // IArchTaskBar
virtual void addReceiver(IArchTaskBarReceiver*); virtual void addReceiver(IArchTaskBarReceiver*);
virtual void removeReceiver(IArchTaskBarReceiver*); virtual void removeReceiver(IArchTaskBarReceiver*);
@ -186,6 +191,7 @@ private:
IArchNetwork* m_net; IArchNetwork* m_net;
IArchSleep* m_sleep; IArchSleep* m_sleep;
IArchString* m_string; IArchString* m_string;
IArchSystem* m_system;
IArchTaskBar* m_taskbar; IArchTaskBar* m_taskbar;
IArchTime* m_time; IArchTime* m_time;
}; };

View File

@ -16,7 +16,7 @@
#include <windows.h> #include <windows.h>
#include <shlobj.h> #include <shlobj.h>
#include <tchar.h> #include <tchar.h>
#include <cstring> #include <string.h>
// //
// CArchFileWindows // CArchFileWindows

View File

@ -0,0 +1,86 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package 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 General Public License for more details.
*/
#define WIN32_LEAN_AND_MEAN
#include "CArchSystemWindows.h"
#include <windows.h>
//
// CArchSystemWindows
//
CArchSystemWindows::CArchSystemWindows()
{
// do nothing
}
CArchSystemWindows::~CArchSystemWindows()
{
// do nothing
}
std::string
CArchSystemWindows::getOSName() const
{
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info);
if (GetVersionEx(&info)) {
switch (info.dwPlatformId) {
case VER_PLATFORM_WIN32_NT:
if (info.dwMajorVersion == 5 && info.dwMinorVersion == 2) {
return "Microsoft Windows Server 2003";
}
if (info.dwMajorVersion == 5 && info.dwMinorVersion == 1) {
return "Microsoft Windows Server XP";
}
if (info.dwMajorVersion == 5 && info.dwMinorVersion == 0) {
return "Microsoft Windows Server 2000";
}
if (info.dwMajorVersion <= 4) {
return "Microsoft Windows NT";
}
char buffer[100];
sprintf(buffer, "Microsoft Windows %d.%d",
info.dwMajorVersion, info.dwMinorVersion);
return buffer;
case VER_PLATFORM_WIN32_WINDOWS:
if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
if (info.szCSDVersion[1] == 'C' ||
info.szCSDVersion[1] == 'B') {
return "Microsoft Windows 95 OSR2";
}
return "Microsoft Windows 95";
}
if (info.dwMajorVersion == 4 && info.dwMinorVersion == 10) {
if (info.szCSDVersion[1] == 'A') {
return "Microsoft Windows 98 SE";
}
return "Microsoft Windows 98";
}
if (info.dwMajorVersion == 4 && info.dwMinorVersion == 90) {
return "Microsoft Windows ME";
}
if (info.dwMajorVersion == 4) {
return "Microsoft Windows unknown 95 family";
}
break;
default:
break;
}
}
return "Microsoft Windows <unknown>";
}

View File

@ -0,0 +1,32 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package 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 General Public License for more details.
*/
#ifndef CARCHSYSTEMWINDOWS_H
#define CARCHSYSTEMWINDOWS_H
#include "IArchSystem.h"
#define ARCH_SYSTEM CArchSystemWindows
//! Win32 implementation of IArchString
class CArchSystemWindows : public IArchSystem {
public:
CArchSystemWindows();
virtual ~CArchSystemWindows();
// IArchSystem overrides
virtual std::string getOSName() const;
};
#endif

39
lib/arch/IArchSystem.h Normal file
View File

@ -0,0 +1,39 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package 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 General Public License for more details.
*/
#ifndef IARCHSYSTEM_H
#define IARCHSYSTEM_H
#include "IInterface.h"
#include "stdstring.h"
//! Interface for architecture dependent system queries
/*!
This interface defines operations for querying system info.
*/
class IArchSystem : public IInterface {
public:
//! @name accessors
//@{
//! Identify the OS
/*!
Returns a string identifying the operating system.
*/
virtual std::string getOSName() const = 0;
//@}
};
#endif

View File

@ -27,6 +27,7 @@ COMMON_SOURCE_FILES = \
IArchNetwork.h \ IArchNetwork.h \
IArchSleep.h \ IArchSleep.h \
IArchString.h \ IArchString.h \
IArchSystem.h \
IArchTaskBar.h \ IArchTaskBar.h \
IArchTaskBarReceiver.h \ IArchTaskBarReceiver.h \
IArchTime.h \ IArchTime.h \
@ -41,6 +42,7 @@ UNIX_SOURCE_FILES = \
CArchNetworkBSD.cpp \ CArchNetworkBSD.cpp \
CArchSleepUnix.cpp \ CArchSleepUnix.cpp \
CArchStringUnix.cpp \ CArchStringUnix.cpp \
CArchSystemUnix.cpp \
CArchTaskBarXWindows.cpp \ CArchTaskBarXWindows.cpp \
CArchTimeUnix.cpp \ CArchTimeUnix.cpp \
XArchUnix.cpp \ XArchUnix.cpp \
@ -52,6 +54,7 @@ UNIX_SOURCE_FILES = \
CArchNetworkBSD.h \ CArchNetworkBSD.h \
CArchSleepUnix.h \ CArchSleepUnix.h \
CArchStringUnix.h \ CArchStringUnix.h \
CArchSystemUnix.h \
CArchTaskBarXWindows.h \ CArchTaskBarXWindows.h \
CArchTimeUnix.h \ CArchTimeUnix.h \
XArchUnix.h \ XArchUnix.h \
@ -66,6 +69,7 @@ WIN32_SOURCE_FILES = \
CArchNetworkWinsock.cpp \ CArchNetworkWinsock.cpp \
CArchSleepWindows.cpp \ CArchSleepWindows.cpp \
CArchStringWindows.cpp \ CArchStringWindows.cpp \
CArchSystemWindows.cpp \
CArchTaskBarWindows.cpp \ CArchTaskBarWindows.cpp \
CArchTimeWindows.cpp \ CArchTimeWindows.cpp \
XArchWindows.cpp \ XArchWindows.cpp \
@ -78,6 +82,7 @@ WIN32_SOURCE_FILES = \
CArchNetworkWinsock.h \ CArchNetworkWinsock.h \
CArchSleepWindows.h \ CArchSleepWindows.h \
CArchStringWindows.h \ CArchStringWindows.h \
CArchSystemWindows.h \
CArchTaskBarWindows.h \ CArchTaskBarWindows.h \
CArchTimeWindows.h \ CArchTimeWindows.h \
XArchWindows.h \ XArchWindows.h \

View File

@ -127,6 +127,10 @@ SOURCE=.\CArchStringWindows.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CArchSystemWindows.cpp
# End Source File
# Begin Source File
SOURCE=.\CArchTaskBarWindows.cpp SOURCE=.\CArchTaskBarWindows.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -197,6 +201,10 @@ SOURCE=.\CArchStringWindows.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\CArchSystemWindows.h
# End Source File
# Begin Source File
SOURCE=.\CArchTaskBarWindows.h SOURCE=.\CArchTaskBarWindows.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -237,6 +245,10 @@ SOURCE=.\IArchString.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\IArchSystem.h
# End Source File
# Begin Source File
SOURCE=.\IArchTaskBar.h SOURCE=.\IArchTaskBar.h
# End Source File # End Source File
# Begin Source File # Begin Source File