diff --git a/cmd/synergyc/synergyc.cpp b/cmd/synergyc/synergyc.cpp index ed3b34e2..9127592a 100644 --- a/cmd/synergyc/synergyc.cpp +++ b/cmd/synergyc/synergyc.cpp @@ -480,6 +480,9 @@ run(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup) // through the task bar. s_taskBarReceiver = createTaskBarReceiver(&logBuffer); + // identify system + LOG((CLOG_INFO "Synergy client on %s", ARCH->getOSName().c_str())); + // run int result = startup(argc, argv); diff --git a/cmd/synergys/synergys.cpp b/cmd/synergys/synergys.cpp index b9464fb3..854f4e99 100644 --- a/cmd/synergys/synergys.cpp +++ b/cmd/synergys/synergys.cpp @@ -144,12 +144,13 @@ createTaskBarReceiver(const CBufferedLogOutputter* logBuffer) // platform independent main // -static CServer* s_server = NULL; -static CScreen* s_serverScreen = NULL; -static CPrimaryClient* s_primaryClient = NULL; -static CClientListener* s_listener = NULL; -static CServerTaskBarReceiver* s_taskBarReceiver = NULL; -static CEvent::Type s_reloadConfigEvent = CEvent::kUnknown; +static CServer* s_server = NULL; +static CScreen* s_serverScreen = NULL; +static CPrimaryClient* s_primaryClient = NULL; +static CClientListener* s_listener = NULL; +static CServerTaskBarReceiver* s_taskBarReceiver = NULL; +static CEvent::Type s_reloadConfigEvent = CEvent::kUnknown; +static CEvent::Type s_forceReconnectEvent = CEvent::kUnknown; CEvent::Type getReloadConfigEvent() @@ -157,6 +158,12 @@ getReloadConfigEvent() return CEvent::registerTypeOnce(s_reloadConfigEvent, "reloadConfig"); } +CEvent::Type +getForceReconnectEvent() +{ + return CEvent::registerTypeOnce(s_forceReconnectEvent, "forceReconnect"); +} + static void updateStatus() @@ -425,6 +432,15 @@ reloadConfig(const CEvent&, void*) } } +static +void +forceReconnect(const CEvent&, void*) +{ + if (s_server != NULL) { + s_server->disconnect(); + } +} + static int mainLoop() @@ -472,6 +488,12 @@ mainLoop() IEventQueue::getSystemTarget(), 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 // later. the timer installed by startServer() will take care of // that. @@ -487,6 +509,8 @@ mainLoop() // close down LOG((CLOG_DEBUG1 "stopping server")); + EVENTQUEUE->removeHandler(getForceReconnectEvent(), + IEventQueue::getSystemTarget()); EVENTQUEUE->removeHandler(getReloadConfigEvent(), IEventQueue::getSystemTarget()); stopServer(); @@ -545,6 +569,9 @@ run(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup) // through the task bar. s_taskBarReceiver = createTaskBarReceiver(&logBuffer); + // identify system + LOG((CLOG_INFO "Synergy server on %s", ARCH->getOSName().c_str())); + // run int result = startup(argc, argv); diff --git a/configure.in b/configure.in index 791acd83..41727153 100644 --- a/configure.in +++ b/configure.in @@ -90,6 +90,7 @@ dnl checks for header files AC_HEADER_STDC 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/utsname.h]) AC_CHECK_HEADERS([istream ostream sstream]) AC_HEADER_TIME if test x"$acx_host_winapi" = xXWINDOWS; then diff --git a/lib/arch/CArch.cpp b/lib/arch/CArch.cpp index 70b52236..37dee72b 100644 --- a/lib/arch/CArch.cpp +++ b/lib/arch/CArch.cpp @@ -23,6 +23,7 @@ #undef ARCH_NETWORK #undef ARCH_SLEEP #undef ARCH_STRING +#undef ARCH_SYSTEM #undef ARCH_TASKBAR #undef ARCH_TIME @@ -37,6 +38,7 @@ # include "CArchNetworkWinsock.h" # include "CArchSleepWindows.h" # include "CArchStringWindows.h" +# include "CArchSystemWindows.h" # include "CArchTaskBarWindows.h" # include "CArchTimeWindows.h" #elif SYSAPI_UNIX @@ -50,6 +52,7 @@ # include "CArchNetworkBSD.h" # include "CArchSleepUnix.h" # include "CArchStringUnix.h" +# include "CArchSystemUnix.h" # include "CArchTaskBarXWindows.h" # include "CArchTimeUnix.h" #endif @@ -86,6 +89,10 @@ # error unsupported platform for string #endif +#if !defined(ARCH_SYSTEM) +# error unsupported platform for system +#endif + #if !defined(ARCH_TASKBAR) # error unsupported platform for taskbar #endif @@ -108,6 +115,7 @@ CArch::CArch(ARCH_ARGS* args) // create architecture implementation objects m_mt = new ARCH_MULTITHREAD; + m_system = new ARCH_SYSTEM; m_file = new ARCH_FILE; m_log = new ARCH_LOG; m_net = new ARCH_NETWORK; @@ -135,6 +143,7 @@ CArch::~CArch() delete m_net; delete m_log; delete m_file; + delete m_system; delete m_mt; // no instance @@ -581,6 +590,12 @@ CArch::getWideCharEncoding() return m_string->getWideCharEncoding(); } +std::string +CArch::getOSName() const +{ + return m_system->getOSName(); +} + void CArch::addReceiver(IArchTaskBarReceiver* receiver) { diff --git a/lib/arch/CArch.h b/lib/arch/CArch.h index d7940955..8a42bd0c 100644 --- a/lib/arch/CArch.h +++ b/lib/arch/CArch.h @@ -23,6 +23,7 @@ #include "IArchNetwork.h" #include "IArchSleep.h" #include "IArchString.h" +#include "IArchSystem.h" #include "IArchTaskBar.h" #include "IArchTime.h" @@ -52,6 +53,7 @@ class CArch : public IArchConsole, public IArchNetwork, public IArchSleep, public IArchString, + public IArchSystem, public IArchTaskBar, public IArchTime { public: @@ -167,6 +169,9 @@ public: virtual EWideCharEncoding getWideCharEncoding(); + // IArchSystem overrides + virtual std::string getOSName() const; + // IArchTaskBar virtual void addReceiver(IArchTaskBarReceiver*); virtual void removeReceiver(IArchTaskBarReceiver*); @@ -186,6 +191,7 @@ private: IArchNetwork* m_net; IArchSleep* m_sleep; IArchString* m_string; + IArchSystem* m_system; IArchTaskBar* m_taskbar; IArchTime* m_time; }; diff --git a/lib/arch/CArchFileWindows.cpp b/lib/arch/CArchFileWindows.cpp index 7d9fd51b..5debb17b 100644 --- a/lib/arch/CArchFileWindows.cpp +++ b/lib/arch/CArchFileWindows.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include // // CArchFileWindows diff --git a/lib/arch/CArchSystemWindows.cpp b/lib/arch/CArchSystemWindows.cpp new file mode 100644 index 00000000..b634b4bc --- /dev/null +++ b/lib/arch/CArchSystemWindows.cpp @@ -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 + +// +// 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 "; +} diff --git a/lib/arch/CArchSystemWindows.h b/lib/arch/CArchSystemWindows.h new file mode 100644 index 00000000..e23913d0 --- /dev/null +++ b/lib/arch/CArchSystemWindows.h @@ -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 diff --git a/lib/arch/IArchSystem.h b/lib/arch/IArchSystem.h new file mode 100644 index 00000000..7a6c941b --- /dev/null +++ b/lib/arch/IArchSystem.h @@ -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 diff --git a/lib/arch/Makefile.am b/lib/arch/Makefile.am index 8a45369d..0e9aa158 100644 --- a/lib/arch/Makefile.am +++ b/lib/arch/Makefile.am @@ -27,6 +27,7 @@ COMMON_SOURCE_FILES = \ IArchNetwork.h \ IArchSleep.h \ IArchString.h \ + IArchSystem.h \ IArchTaskBar.h \ IArchTaskBarReceiver.h \ IArchTime.h \ @@ -41,6 +42,7 @@ UNIX_SOURCE_FILES = \ CArchNetworkBSD.cpp \ CArchSleepUnix.cpp \ CArchStringUnix.cpp \ + CArchSystemUnix.cpp \ CArchTaskBarXWindows.cpp \ CArchTimeUnix.cpp \ XArchUnix.cpp \ @@ -52,6 +54,7 @@ UNIX_SOURCE_FILES = \ CArchNetworkBSD.h \ CArchSleepUnix.h \ CArchStringUnix.h \ + CArchSystemUnix.h \ CArchTaskBarXWindows.h \ CArchTimeUnix.h \ XArchUnix.h \ @@ -66,6 +69,7 @@ WIN32_SOURCE_FILES = \ CArchNetworkWinsock.cpp \ CArchSleepWindows.cpp \ CArchStringWindows.cpp \ + CArchSystemWindows.cpp \ CArchTaskBarWindows.cpp \ CArchTimeWindows.cpp \ XArchWindows.cpp \ @@ -78,6 +82,7 @@ WIN32_SOURCE_FILES = \ CArchNetworkWinsock.h \ CArchSleepWindows.h \ CArchStringWindows.h \ + CArchSystemWindows.h \ CArchTaskBarWindows.h \ CArchTimeWindows.h \ XArchWindows.h \ diff --git a/lib/arch/arch.dsp b/lib/arch/arch.dsp index 17c05936..73575be9 100644 --- a/lib/arch/arch.dsp +++ b/lib/arch/arch.dsp @@ -127,6 +127,10 @@ SOURCE=.\CArchStringWindows.cpp # End Source File # Begin Source File +SOURCE=.\CArchSystemWindows.cpp +# End Source File +# Begin Source File + SOURCE=.\CArchTaskBarWindows.cpp # End Source File # Begin Source File @@ -197,6 +201,10 @@ SOURCE=.\CArchStringWindows.h # End Source File # Begin Source File +SOURCE=.\CArchSystemWindows.h +# End Source File +# Begin Source File + SOURCE=.\CArchTaskBarWindows.h # End Source File # Begin Source File @@ -237,6 +245,10 @@ SOURCE=.\IArchString.h # End Source File # Begin Source File +SOURCE=.\IArchSystem.h +# End Source File +# Begin Source File + SOURCE=.\IArchTaskBar.h # End Source File # Begin Source File