From e9cc0b434e49bee180cfd609485d6164e06c90ce Mon Sep 17 00:00:00 2001 From: crs Date: Sun, 5 Jan 2003 21:48:54 +0000 Subject: [PATCH] Moved CPrimaryScreen and CSecondaryScreen to the lib/synergy and the platform specific implementations to lib/platform. Added an lib/arch method to query the platform's native wide character encoding and changed CUnicode to use it. All platform dependent code is now in lib/arch, lib/platform, and the programs under cmd. Also added more documentation. --- PORTING | 57 +++++- cmd/synergyc/synergyc.cpp | 5 + cmd/synergys/synergys.cpp | 5 + doc/doxygen.cfg.in | 2 +- lib/arch/CArch.cpp | 8 + lib/arch/CArch.h | 21 ++ lib/arch/CArchConsoleUnix.h | 1 + lib/arch/CArchConsoleWindows.h | 1 + lib/arch/CArchDaemonNone.h | 7 + lib/arch/CArchDaemonUnix.h | 1 + lib/arch/CArchDaemonWindows.h | 1 + lib/arch/CArchFileUnix.h | 1 + lib/arch/CArchFileWindows.h | 1 + lib/arch/CArchLogUnix.h | 1 + lib/arch/CArchLogWindows.h | 1 + lib/arch/CArchMiscWindows.h | 1 + lib/arch/CArchMultithreadPosix.h | 1 + lib/arch/CArchMultithreadWindows.cpp | 2 +- lib/arch/CArchMultithreadWindows.h | 1 + lib/arch/CArchNetworkBSD.h | 1 + lib/arch/CArchNetworkWinsock.cpp | 4 +- lib/arch/CArchNetworkWinsock.h | 1 + lib/arch/CArchSleepUnix.h | 1 + lib/arch/CArchSleepWindows.h | 1 + lib/arch/CArchStringUnix.cpp | 6 + lib/arch/CArchStringUnix.h | 3 + lib/arch/CArchStringWindows.cpp | 6 + lib/arch/CArchStringWindows.h | 3 + lib/arch/CArchTimeUnix.h | 1 + lib/arch/CArchTimeWindows.h | 1 + lib/arch/IArchConsole.h | 5 + lib/arch/IArchFile.h | 5 + lib/arch/IArchLog.h | 17 +- lib/arch/IArchMultithread.h | 190 +++++++++++++++++- lib/arch/IArchNetwork.h | 189 ++++++++++++++++- lib/arch/IArchSleep.h | 5 + lib/arch/IArchString.h | 32 +++ lib/arch/IArchTime.h | 5 + lib/arch/Makefile.am | 1 - lib/arch/XArchImpl.h | 25 --- lib/arch/arch.dsp | 4 - lib/base/CLog.cpp | 7 +- lib/base/CUnicode.cpp | 54 +++-- lib/base/XBase.cpp | 13 -- lib/base/XBase.h | 9 +- lib/client/Makefile.am | 7 - lib/client/client.dsp | 20 -- lib/http/XHTTP.h | 1 + .../CMSWindowsPrimaryScreen.cpp | 0 .../CMSWindowsPrimaryScreen.h | 0 lib/platform/CMSWindowsScreen.h | 2 +- .../CMSWindowsSecondaryScreen.cpp | 0 .../CMSWindowsSecondaryScreen.h | 0 .../CXWindowsPrimaryScreen.cpp | 0 .../CXWindowsPrimaryScreen.h | 0 lib/platform/CXWindowsScreen.h | 8 +- .../CXWindowsSecondaryScreen.cpp | 0 .../CXWindowsSecondaryScreen.h | 0 lib/platform/Makefile.am | 8 + lib/platform/platform.dsp | 16 ++ lib/server/Makefile.am | 7 - lib/server/server.dsp | 20 -- lib/{server => synergy}/CPrimaryScreen.cpp | 0 lib/{server => synergy}/CPrimaryScreen.h | 0 lib/{client => synergy}/CSecondaryScreen.cpp | 0 lib/{client => synergy}/CSecondaryScreen.h | 0 .../IPrimaryScreenFactory.h | 0 .../ISecondaryScreenFactory.h | 0 lib/synergy/Makefile.am | 8 +- lib/synergy/libsynergy.dsp | 24 +++ 70 files changed, 672 insertions(+), 156 deletions(-) delete mode 100644 lib/arch/XArchImpl.h rename lib/{server => platform}/CMSWindowsPrimaryScreen.cpp (100%) rename lib/{server => platform}/CMSWindowsPrimaryScreen.h (100%) rename lib/{client => platform}/CMSWindowsSecondaryScreen.cpp (100%) rename lib/{client => platform}/CMSWindowsSecondaryScreen.h (100%) rename lib/{server => platform}/CXWindowsPrimaryScreen.cpp (100%) rename lib/{server => platform}/CXWindowsPrimaryScreen.h (100%) rename lib/{client => platform}/CXWindowsSecondaryScreen.cpp (100%) rename lib/{client => platform}/CXWindowsSecondaryScreen.h (100%) rename lib/{server => synergy}/CPrimaryScreen.cpp (100%) rename lib/{server => synergy}/CPrimaryScreen.h (100%) rename lib/{client => synergy}/CSecondaryScreen.cpp (100%) rename lib/{client => synergy}/CSecondaryScreen.h (100%) rename lib/{server => synergy}/IPrimaryScreenFactory.h (100%) rename lib/{client => synergy}/ISecondaryScreenFactory.h (100%) diff --git a/PORTING b/PORTING index 95aad05d..8a61f141 100644 --- a/PORTING +++ b/PORTING @@ -301,14 +301,26 @@ FIXME -- high level overview of class relationships Portability ----------- +Synergy is mostly platform independent code but necessarily has +platform dependent parts. The mundane platform dependent parts +come from the usual suspects: networking, multithreading, file +system, high resolution clocks, system logging, etc. Porting +these parts is relatively straightforward. + +Synergy also has more esoteric platform dependent code. The +functions for low-level event interception and insertion, +warping the cursor position, character to keyboard event +translation, clipboard manipulation, and screen saver control +are often obscure and poorly documented. Unfortunately, these +are exactly the functions synergy requires to do its magic. + Porting synergy to a new platform requires the following steps: - Setting up the build - Adjusting lib/common/common.h - Implementing lib/arch - Implementing lib/platform -- Implementing primary and secondary screens for the platform -- Tweaking synergyc and synergys +- Tweaks Setting up the build: @@ -330,22 +342,49 @@ common.h. Implementing lib/arch: -Most platform dependent code lives in lib/arch. There are several +Much platform dependent code lives in lib/arch. There are several interface classes there and they must all be implemented for each platform. See the interface header files for more information. +Platforms requiring special functions should create a class named +CArchMiscXXX where XXX is the platform name. The class should have +only static methods. Clients can include the appropriate header +file and make calls directly, surrounded by a suitable #ifdef/#endif. + Implementing lib/platform: Most of the remaining platform dependent code lives in lib/platform. The code there implements platform dependent window, clipboard, and -screen saver handling. The following interfaces must be implemented: +screen saver handling. If a platform is named XXX then the following +classes should be derived and implemented: -FIXME + * CXXXClipboard : IClipboard + Provides clipboard operations. Typically, this class will + have helper classes for converting between various clipboard + data formats. -Implementing primary and secondary screens for the platform: + * CXXXScreen : IScreen + Provide screen operations common to the server and clients. + The CXXXPrimaryScreen and CXXXSecondaryScreen classes use a + CXXXScreen. -FIXME + * CXXXPrimaryScreen : CPrimaryScreen, IScreenEventHandler + Provides server screen operations. -Tweaking synergyc and synergys: + * CXXXSecondaryScreen : CSecondaryScreen, IScreenEventHandler + Provides client screen operations. -FIXME + * CXXXScreenSaver : IScreenSaver + Provides screen saver operations. + +Tweaks: + +Finally, each platform typically requires various adjustments here +and there. In particular, synergyc.cpp and synergys.cpp usually +require platform dependent code for the main entry point, parsing +arguments, and reporting errors. Also, some platforms may benefit +from a graphical user interface front end. These are generally +not portable and synergy doesn't provide any infrastructure for +the code common to any platform, though it may do so someday. +There is, however, an implementation of a GUI front end for Windows +that serves as an example. diff --git a/cmd/synergyc/synergyc.cpp b/cmd/synergyc/synergyc.cpp index a6c03c2a..2d1f89a2 100644 --- a/cmd/synergyc/synergyc.cpp +++ b/cmd/synergyc/synergyc.cpp @@ -86,6 +86,11 @@ CArgs* CArgs::s_instance = NULL; // platform dependent factories // +//! Factory for creating secondary screens +/*! +Objects of this type create secondary screens appropriate for the +platform. +*/ class CSecondaryScreenFactory : public ISecondaryScreenFactory { public: CSecondaryScreenFactory() { } diff --git a/cmd/synergys/synergys.cpp b/cmd/synergys/synergys.cpp index edc09560..285a7e58 100644 --- a/cmd/synergys/synergys.cpp +++ b/cmd/synergys/synergys.cpp @@ -96,6 +96,11 @@ CArgs* CArgs::s_instance = NULL; // platform dependent factories // +//! Factory for creating primary screens +/*! +Objects of this type create primary screens appropriate for the +platform. +*/ class CPrimaryScreenFactory : public IPrimaryScreenFactory { public: CPrimaryScreenFactory() { } diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index 30ce8fa3..4abf52f9 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -679,7 +679,7 @@ ENABLE_PREPROCESSING = YES # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the diff --git a/lib/arch/CArch.cpp b/lib/arch/CArch.cpp index e5e8f660..6eb99e0d 100644 --- a/lib/arch/CArch.cpp +++ b/lib/arch/CArch.cpp @@ -130,6 +130,8 @@ CArch::~CArch() CArch* CArch::getInstance() { + assert(s_instance != NULL); + return s_instance; } @@ -569,6 +571,12 @@ CArch::convWCToMB(char* dst, wchar_t src, CArchMBState state) return m_string->convWCToMB(dst, src, state); } +IArchString::EWideCharEncoding +CArch::getWideCharEncoding() +{ + return m_string->getWideCharEncoding(); +} + double CArch::time() { diff --git a/lib/arch/CArch.h b/lib/arch/CArch.h index e12e33af..e459658f 100644 --- a/lib/arch/CArch.h +++ b/lib/arch/CArch.h @@ -25,10 +25,24 @@ #include "IArchString.h" #include "IArchTime.h" +/*! +\def ARCH +This macro evaluates to the singleton CArch object. +*/ #define ARCH (CArch::getInstance()) #define ARCH_ARGS +//! Delegating mplementation of architecture dependent interfaces +/*! +This class is a centralized interface to all architecture dependent +interface implementations (except miscellaneous functions). It +instantiates an implementation of each interface and delegates calls +to each method to those implementations. Clients should use the +\c ARCH macro to access this object. Clients must also instantiate +exactly one of these objects before attempting to call any method, +typically at the beginning of \c main(). +*/ class CArch : public IArchConsole, public IArchDaemon, public IArchFile, @@ -46,6 +60,11 @@ public: // accessors // + //! Return the singleton instance + /*! + The client must have instantiated exactly once CArch object before + calling this function. + */ static CArch* getInstance(); // IArchConsole overrides @@ -142,6 +161,8 @@ public: virtual bool isInitMBState(CArchMBState); virtual int convMBToWC(wchar_t*, const char*, int, CArchMBState); virtual int convWCToMB(char*, wchar_t, CArchMBState); + virtual EWideCharEncoding + getWideCharEncoding(); // IArchTime overrides virtual double time(); diff --git a/lib/arch/CArchConsoleUnix.h b/lib/arch/CArchConsoleUnix.h index 5beb8799..5e560fec 100644 --- a/lib/arch/CArchConsoleUnix.h +++ b/lib/arch/CArchConsoleUnix.h @@ -19,6 +19,7 @@ #define ARCH_CONSOLE CArchConsoleUnix +//! Unix implementation of IArchConsole class CArchConsoleUnix : public IArchConsole { public: CArchConsoleUnix(); diff --git a/lib/arch/CArchConsoleWindows.h b/lib/arch/CArchConsoleWindows.h index d93555b4..e51f6616 100644 --- a/lib/arch/CArchConsoleWindows.h +++ b/lib/arch/CArchConsoleWindows.h @@ -23,6 +23,7 @@ #define ARCH_CONSOLE CArchConsoleWindows +//! Win32 implementation of IArchConsole class CArchConsoleWindows : public IArchConsole { public: CArchConsoleWindows(); diff --git a/lib/arch/CArchDaemonNone.h b/lib/arch/CArchDaemonNone.h index 8e017bdb..5b540607 100644 --- a/lib/arch/CArchDaemonNone.h +++ b/lib/arch/CArchDaemonNone.h @@ -19,6 +19,13 @@ #define ARCH_DAEMON CArchDaemonNone +//! Dummy implementation of IArchDaemon +/*! +This class implements IArchDaemon for a platform that does not have +daemons. The install and uninstall functions do nothing, the query +functions return false, and \c daemonize() simply calls the passed +function and returns its result. +*/ class CArchDaemonNone : public IArchDaemon { public: CArchDaemonNone(); diff --git a/lib/arch/CArchDaemonUnix.h b/lib/arch/CArchDaemonUnix.h index b4c82daa..923004e1 100644 --- a/lib/arch/CArchDaemonUnix.h +++ b/lib/arch/CArchDaemonUnix.h @@ -20,6 +20,7 @@ #undef ARCH_DAEMON #define ARCH_DAEMON CArchDaemonUnix +//! Unix implementation of IArchDaemon class CArchDaemonUnix : public CArchDaemonNone { public: CArchDaemonUnix(); diff --git a/lib/arch/CArchDaemonWindows.h b/lib/arch/CArchDaemonWindows.h index aeb3916f..0feef9ba 100644 --- a/lib/arch/CArchDaemonWindows.h +++ b/lib/arch/CArchDaemonWindows.h @@ -25,6 +25,7 @@ #define ARCH_DAEMON CArchDaemonWindows +//! Win32 implementation of IArchDaemon class CArchDaemonWindows : public IArchDaemon { public: typedef int (*RunFunc)(void); diff --git a/lib/arch/CArchFileUnix.h b/lib/arch/CArchFileUnix.h index c6257555..41d00e90 100644 --- a/lib/arch/CArchFileUnix.h +++ b/lib/arch/CArchFileUnix.h @@ -19,6 +19,7 @@ #define ARCH_FILE CArchFileUnix +//! Unix implementation of IArchFile class CArchFileUnix : public IArchFile { public: CArchFileUnix(); diff --git a/lib/arch/CArchFileWindows.h b/lib/arch/CArchFileWindows.h index 44263b38..617b1c40 100644 --- a/lib/arch/CArchFileWindows.h +++ b/lib/arch/CArchFileWindows.h @@ -19,6 +19,7 @@ #define ARCH_FILE CArchFileWindows +//! Win32 implementation of IArchFile class CArchFileWindows : public IArchFile { public: CArchFileWindows(); diff --git a/lib/arch/CArchLogUnix.h b/lib/arch/CArchLogUnix.h index 107d6891..b3717844 100644 --- a/lib/arch/CArchLogUnix.h +++ b/lib/arch/CArchLogUnix.h @@ -19,6 +19,7 @@ #define ARCH_LOG CArchLogUnix +//! Unix implementation of IArchLog class CArchLogUnix : public IArchLog { public: CArchLogUnix(); diff --git a/lib/arch/CArchLogWindows.h b/lib/arch/CArchLogWindows.h index 1c077643..d2385765 100644 --- a/lib/arch/CArchLogWindows.h +++ b/lib/arch/CArchLogWindows.h @@ -22,6 +22,7 @@ #define ARCH_LOG CArchLogWindows +//! Win32 implementation of IArchLog class CArchLogWindows : public IArchLog { public: CArchLogWindows(); diff --git a/lib/arch/CArchMiscWindows.h b/lib/arch/CArchMiscWindows.h index af1a2c78..cce90ea6 100644 --- a/lib/arch/CArchMiscWindows.h +++ b/lib/arch/CArchMiscWindows.h @@ -15,6 +15,7 @@ #ifndef CARCHMISCWINDOWS_H #define CARCHMISCWINDOWS_H +//! Miscellaneous win32 functions. class CArchMiscWindows { public: typedef int (*RunFunc)(void); diff --git a/lib/arch/CArchMultithreadPosix.h b/lib/arch/CArchMultithreadPosix.h index cc67a226..59d14155 100644 --- a/lib/arch/CArchMultithreadPosix.h +++ b/lib/arch/CArchMultithreadPosix.h @@ -31,6 +31,7 @@ public: pthread_mutex_t m_mutex; }; +//! Posix implementation of IArchMultithread class CArchMultithreadPosix : public IArchMultithread { public: CArchMultithreadPosix(); diff --git a/lib/arch/CArchMultithreadWindows.cpp b/lib/arch/CArchMultithreadWindows.cpp index 3a498135..fdeff0fc 100644 --- a/lib/arch/CArchMultithreadWindows.cpp +++ b/lib/arch/CArchMultithreadWindows.cpp @@ -575,7 +575,7 @@ CArchMultithreadWindows::refThread(CArchThreadImpl* thread) } void -CArchMultithreadWindows::testCancelThreadImpl(CArchThread thread) +CArchMultithreadWindows::testCancelThreadImpl(CArchThreadImpl* thread) { assert(thread != NULL); diff --git a/lib/arch/CArchMultithreadWindows.h b/lib/arch/CArchMultithreadWindows.h index 74b2d36b..f6940ca5 100644 --- a/lib/arch/CArchMultithreadWindows.h +++ b/lib/arch/CArchMultithreadWindows.h @@ -37,6 +37,7 @@ public: CRITICAL_SECTION m_mutex; }; +//! Win32 implementation of IArchMultithread class CArchMultithreadWindows : public IArchMultithread { public: CArchMultithreadWindows(); diff --git a/lib/arch/CArchNetworkBSD.h b/lib/arch/CArchNetworkBSD.h index 2d2eda76..23d971bc 100644 --- a/lib/arch/CArchNetworkBSD.h +++ b/lib/arch/CArchNetworkBSD.h @@ -50,6 +50,7 @@ public: socklen_t m_len; }; +//! Berkeley (BSD) sockets implementation of IArchNetwork class CArchNetworkBSD : public IArchNetwork { public: CArchNetworkBSD(); diff --git a/lib/arch/CArchNetworkWinsock.cpp b/lib/arch/CArchNetworkWinsock.cpp index 10e40188..1c10fb57 100644 --- a/lib/arch/CArchNetworkWinsock.cpp +++ b/lib/arch/CArchNetworkWinsock.cpp @@ -35,7 +35,7 @@ static int (PASCAL FAR *getsockopt_winsock)(SOCKET s, int level, int optname, vo static u_short (PASCAL FAR *htons_winsock)(u_short v); static char FAR * (PASCAL FAR *inet_ntoa_winsock)(struct in_addr in); static unsigned long (PASCAL FAR *inet_addr_winsock)(const char FAR * cp); -static int (PASCAL FAR *ioctl_winsock)(SOCKET s, int cmd, void FAR *); +static int (PASCAL FAR *ioctl_winsock)(SOCKET s, int cmd, void FAR * data); static int (PASCAL FAR *listen_winsock)(SOCKET s, int backlog); static u_short (PASCAL FAR *ntohs_winsock)(u_short v); static int (PASCAL FAR *recv_winsock)(SOCKET s, void FAR * buf, int len, int flags); @@ -47,7 +47,7 @@ static SOCKET (PASCAL FAR *socket_winsock)(int af, int type, int protocol); static struct hostent FAR * (PASCAL FAR *gethostbyaddr_winsock)(const char FAR * addr, int len, int type); static struct hostent FAR * (PASCAL FAR *gethostbyname_winsock)(const char FAR * name); static int (PASCAL FAR *WSACleanup_winsock)(void); -static int (PASCAL FAR *WSAFDIsSet_winsock)(SOCKET, fd_set FAR *); +static int (PASCAL FAR *WSAFDIsSet_winsock)(SOCKET, fd_set FAR * fdset); #undef FD_ISSET #define FD_ISSET(fd, set) WSAFDIsSet_winsock((SOCKET)(fd), (fd_set FAR *)(set)) diff --git a/lib/arch/CArchNetworkWinsock.h b/lib/arch/CArchNetworkWinsock.h index d16b7f48..58ce9cad 100644 --- a/lib/arch/CArchNetworkWinsock.h +++ b/lib/arch/CArchNetworkWinsock.h @@ -44,6 +44,7 @@ public: int m_len; }; +//! Win32 implementation of IArchNetwork class CArchNetworkWinsock : public IArchNetwork { public: CArchNetworkWinsock(); diff --git a/lib/arch/CArchSleepUnix.h b/lib/arch/CArchSleepUnix.h index deb33629..939ca401 100644 --- a/lib/arch/CArchSleepUnix.h +++ b/lib/arch/CArchSleepUnix.h @@ -19,6 +19,7 @@ #define ARCH_SLEEP CArchSleepUnix +//! Unix implementation of IArchSleep class CArchSleepUnix : public IArchSleep { public: CArchSleepUnix(); diff --git a/lib/arch/CArchSleepWindows.h b/lib/arch/CArchSleepWindows.h index a142d997..a5a5fa90 100644 --- a/lib/arch/CArchSleepWindows.h +++ b/lib/arch/CArchSleepWindows.h @@ -19,6 +19,7 @@ #define ARCH_SLEEP CArchSleepWindows +//! Win32 implementation of IArchSleep class CArchSleepWindows : public IArchSleep { public: CArchSleepWindows(); diff --git a/lib/arch/CArchStringUnix.cpp b/lib/arch/CArchStringUnix.cpp index 385bb0aa..32b2ad46 100644 --- a/lib/arch/CArchStringUnix.cpp +++ b/lib/arch/CArchStringUnix.cpp @@ -32,3 +32,9 @@ CArchStringUnix::~CArchStringUnix() } #include "vsnprintf.cpp" + +IArchString::EWideCharEncoding +CArchStringUnix::getWideCharEncoding() +{ + return kUCS4; +} diff --git a/lib/arch/CArchStringUnix.h b/lib/arch/CArchStringUnix.h index fcd114f9..b9fddcb3 100644 --- a/lib/arch/CArchStringUnix.h +++ b/lib/arch/CArchStringUnix.h @@ -19,6 +19,7 @@ #define ARCH_STRING CArchStringUnix +//! Unix implementation of IArchString class CArchStringUnix : public IArchString { public: CArchStringUnix(); @@ -33,6 +34,8 @@ public: virtual bool isInitMBState(CArchMBState); virtual int convMBToWC(wchar_t*, const char*, int, CArchMBState); virtual int convWCToMB(char*, wchar_t, CArchMBState); + virtual EWideCharEncoding + getWideCharEncoding(); }; #endif diff --git a/lib/arch/CArchStringWindows.cpp b/lib/arch/CArchStringWindows.cpp index a0d8727d..4aefda2e 100644 --- a/lib/arch/CArchStringWindows.cpp +++ b/lib/arch/CArchStringWindows.cpp @@ -36,3 +36,9 @@ CArchStringWindows::~CArchStringWindows() #define HAVE_VSNPRINTF 1 #define ARCH_VSNPRINTF _vsnprintf #include "vsnprintf.cpp" + +IArchString::EWideCharEncoding +CArchStringWindows::getWideCharEncoding() +{ + return kUTF16; +} diff --git a/lib/arch/CArchStringWindows.h b/lib/arch/CArchStringWindows.h index 54b77ca3..c1303522 100644 --- a/lib/arch/CArchStringWindows.h +++ b/lib/arch/CArchStringWindows.h @@ -19,6 +19,7 @@ #define ARCH_STRING CArchStringWindows +//! Win32 implementation of IArchString class CArchStringWindows : public IArchString { public: CArchStringWindows(); @@ -33,6 +34,8 @@ public: virtual bool isInitMBState(CArchMBState); virtual int convMBToWC(wchar_t*, const char*, int, CArchMBState); virtual int convWCToMB(char*, wchar_t, CArchMBState); + virtual EWideCharEncoding + getWideCharEncoding(); }; #endif diff --git a/lib/arch/CArchTimeUnix.h b/lib/arch/CArchTimeUnix.h index c9b99999..78c6ff6f 100644 --- a/lib/arch/CArchTimeUnix.h +++ b/lib/arch/CArchTimeUnix.h @@ -19,6 +19,7 @@ #define ARCH_TIME CArchTimeUnix +//! Generic Unix implementation of IArchTime class CArchTimeUnix : public IArchTime { public: CArchTimeUnix(); diff --git a/lib/arch/CArchTimeWindows.h b/lib/arch/CArchTimeWindows.h index 0672ad78..fb9b1e9f 100644 --- a/lib/arch/CArchTimeWindows.h +++ b/lib/arch/CArchTimeWindows.h @@ -19,6 +19,7 @@ #define ARCH_TIME CArchTimeWindows +//! Win32 implementation of IArchTime class CArchTimeWindows : public IArchTime { public: CArchTimeWindows(); diff --git a/lib/arch/IArchConsole.h b/lib/arch/IArchConsole.h index 29c3f7bd..c9da4100 100644 --- a/lib/arch/IArchConsole.h +++ b/lib/arch/IArchConsole.h @@ -17,6 +17,11 @@ #include "IInterface.h" +//! Interface for architecture dependent console output +/*! +This interface defines the console operations required by +synergy. Each architecture must implement this interface. +*/ class IArchConsole : public IInterface { public: //! @name manipulators diff --git a/lib/arch/IArchFile.h b/lib/arch/IArchFile.h index 90b93649..8594053d 100644 --- a/lib/arch/IArchFile.h +++ b/lib/arch/IArchFile.h @@ -18,6 +18,11 @@ #include "IInterface.h" #include "stdstring.h" +//! Interface for architecture dependent file system operations +/*! +This interface defines the file system operations required by +synergy. Each architecture must implement this interface. +*/ class IArchFile : public IInterface { public: //! @name manipulators diff --git a/lib/arch/IArchLog.h b/lib/arch/IArchLog.h index dc818ebb..0c259187 100644 --- a/lib/arch/IArchLog.h +++ b/lib/arch/IArchLog.h @@ -17,9 +17,24 @@ #include "IInterface.h" +//! Interface for architecture dependent logging +/*! +This interface defines the logging operations required by +synergy. Each architecture must implement this interface. +*/ class IArchLog : public IInterface { public: - enum ELevel { kERROR, kWARNING, kNOTE, kINFO, kDEBUG }; + //! Log levels + /*! + The logging priority levels in order of highest to lowest priority. + */ + enum ELevel { + kERROR, //!< For serious or fatal errors + kWARNING, //!< For minor errors and warnings + kNOTE, //!< For messages about notable events + kINFO, //!< For informational messages + kDEBUG //!< For debugging messages + }; //! @name manipulators //@{ diff --git a/lib/arch/IArchMultithread.h b/lib/arch/IArchMultithread.h index a3b2efd2..05abd6be 100644 --- a/lib/arch/IArchMultithread.h +++ b/lib/arch/IArchMultithread.h @@ -17,11 +17,47 @@ #include "IInterface.h" +/*! +\class CArchCondImpl +\brief Internal condition variable data. +An architecture dependent type holding the necessary data for a +condition variable. +*/ class CArchCondImpl; -class CArchMutexImpl; -class CArchThreadImpl; + +/*! +\var CArchCond +\brief Opaque condition variable type. +An opaque type representing a condition variable. +*/ typedef CArchCondImpl* CArchCond; + +/*! +\class CArchMutexImpl +\brief Internal mutex data. +An architecture dependent type holding the necessary data for a mutex. +*/ +class CArchMutexImpl; + +/*! +\var CArchMutex +\brief Opaque mutex type. +An opaque type representing a mutex. +*/ typedef CArchMutexImpl* CArchMutex; + +/*! +\class CArchThreadImpl +\brief Internal thread data. +An architecture dependent type holding the necessary data for a thread. +*/ +class CArchThreadImpl; + +/*! +\var CArchThread +\brief Opaque thread type. +An opaque type representing a thread. +*/ typedef CArchThreadImpl* CArchThread; //! Interface for architecture dependent multithreading @@ -31,7 +67,9 @@ synergy. Each architecture must implement this interface. */ class IArchMultithread : public IInterface { public: + //! Type of thread entry point typedef void* (*ThreadFunc)(void*); + //! Type of thread identifier typedef unsigned int ThreadID; //! @name manipulators @@ -41,38 +79,172 @@ public: // condition variable methods // + //! Create a condition variable + /*! + The condition variable is an opaque data type. + */ virtual CArchCond newCondVar() = 0; + + //! Destroy a condition variable virtual void closeCondVar(CArchCond) = 0; + + //! Signal a condition variable + /*! + Signalling a condition variable releases one waiting thread. + */ virtual void signalCondVar(CArchCond) = 0; + + //! Broadcast a condition variable + /*! + Broadcasting a condition variable releases all waiting threads. + */ virtual void broadcastCondVar(CArchCond) = 0; + + //! Wait on a condition variable + /*! + Waiting on a conditation variable for up to \c timeout seconds. + If \c timeout is < 0 then there is no timeout. The mutex must + be locked when this method is called. The mutex is unlocked + during the wait and locked again before returning. + + (Cancellation point) + */ virtual bool waitCondVar(CArchCond, CArchMutex, double timeout) = 0; // // mutex methods // + //! Create a non-recursive mutex + /*! + Creates a non-recursive mutex. A thread must not lock a + non-recursive mutex when it already holds a lock on that mutex. + If it does it will deadlock. The mutex is an opaque data type. + */ virtual CArchMutex newMutex() = 0; + + //! Destroy a mutex virtual void closeMutex(CArchMutex) = 0; + + //! Lock a mutex + /*! + (Cancellation point) + */ virtual void lockMutex(CArchMutex) = 0; + + //! Unlock a mutex virtual void unlockMutex(CArchMutex) = 0; // // thread methods // - virtual CArchThread newThread(ThreadFunc, void*) = 0; + //! Start a new thread + /*! + Creates and starts a new thread, using \c func as the entry point + and passing it \c userData. The thread is an opaque data type. + */ + virtual CArchThread newThread(ThreadFunc func, void* userData) = 0; + + //! Get a reference to the calling thread + /*! + Returns a thread representing the current (i.e. calling) thread. + */ virtual CArchThread newCurrentThread() = 0; - virtual CArchThread copyThread(CArchThread) = 0; + + //! Copy a thread object + /*! + Returns a reference to to thread referred to by \c thread. + */ + virtual CArchThread copyThread(CArchThread thread) = 0; + + //! Release a thread reference + /*! + Deletes the given thread object. This does not destroy the thread + the object referred to, even if there are no remaining references. + Use cancelThread() and waitThread() to stop a thread and wait for + it to exit. + */ virtual void closeThread(CArchThread) = 0; - virtual void cancelThread(CArchThread) = 0; + + //! Force a thread to exit + /*! + Causes \c thread to exit when it next calls a cancellation point. + A thread avoids cancellation as long as it nevers calls a + cancellation point. Once it begins the cancellation process it + must always let cancellation go to completion but may take as + long as necessary to clean up. + */ + virtual void cancelThread(CArchThread thread) = 0; + + //! Change thread priority + /*! + Changes the priority of \c thread by \c n. If \c n is positive + the thread has a lower priority and if negative a higher priority. + Some architectures may not support either or both directions. + */ virtual void setPriorityOfThread(CArchThread, int n) = 0; + + //! Cancellation point + /*! + This method does nothing but is a cancellation point. Clients + can make their own functions cancellation points by calling this + method at appropriate times. + */ virtual void testCancelThread() = 0; - virtual bool wait(CArchThread, double timeout) = 0; + + //! Wait for a thread to exit + /*! + Waits for up to \c timeout seconds for \c thread to exit (normally + or by cancellation). Waits forever if \c timeout < 0. Returns + true if the thread exited, false otherwise. Waiting on the current + thread returns immediately with false. + + (Cancellation point) + */ + virtual bool wait(CArchThread thread, double timeout) = 0; + + //! Wait for a user event + /*! + Waits for up to \c timeout seconds for a pending user event. + Returns true if an event occurred, false otherwise. + + This method is not required by all platforms. + + (Cancellation point) + */ virtual bool waitForEvent(double timeout) = 0; + + //! Compare threads + /*! + Returns true iff two thread objects refer to the same thread. + Note that comparing thread objects directly is meaningless. + */ virtual bool isSameThread(CArchThread, CArchThread) = 0; - virtual bool isExitedThread(CArchThread) = 0; - virtual void* getResultOfThread(CArchThread) = 0; - virtual ThreadID getIDOfThread(CArchThread) = 0; + + //! Test if thread exited + /*! + Returns true iff \c thread has exited. + */ + virtual bool isExitedThread(CArchThread thread) = 0; + + //! Returns the exit code of a thread + /*! + Waits indefinitely for \c thread to exit (if it hasn't yet) then + returns the thread's exit code. + + (Cancellation point) + */ + virtual void* getResultOfThread(CArchThread thread) = 0; + + //! Returns an ID for a thread + /*! + Returns some ID number for \c thread. This is for logging purposes. + All thread objects referring to the same thread return the same ID. + However, clients should us isSameThread() to compare thread objects + instead of comparing IDs. + */ + virtual ThreadID getIDOfThread(CArchThread thread) = 0; //@} }; diff --git a/lib/arch/IArchNetwork.h b/lib/arch/IArchNetwork.h index 9bdacc71..1af8cd74 100644 --- a/lib/arch/IArchNetwork.h +++ b/lib/arch/IArchNetwork.h @@ -18,9 +18,33 @@ #include "IInterface.h" #include "stdstring.h" +/*! +\class CArchSocketImpl +\brief Internal socket data. +An architecture dependent type holding the necessary data for a socket. +*/ class CArchSocketImpl; -class CArchNetAddressImpl; + +/*! +\var CArchSocket +\brief Opaque socket type. +An opaque type representing a socket. +*/ typedef CArchSocketImpl* CArchSocket; + +/*! +\class CArchNetAddressImpl +\brief Internal network address data. +An architecture dependent type holding the necessary data for a network +address. +*/ +class CArchNetAddressImpl; + +/*! +\var CArchNetAddress +\brief Opaque network address type. +An opaque type representing a network address. +*/ typedef CArchNetAddressImpl* CArchNetAddress; //! Interface for architecture dependent networking @@ -30,47 +54,171 @@ synergy. Each architecture must implement this interface. */ class IArchNetwork : public IInterface { public: + //! Supported address families enum EAddressFamily { kUNKNOWN, kINET, }; + //! Supported socket types enum ESocketType { kDGRAM, kSTREAM }; + //! Events for \c poll() + /*! + Events for \c poll() are bitmasks and can be combined using the + bitwise operators. + */ enum { - kPOLLIN = 1, - kPOLLOUT = 2, - kPOLLERR = 4, - kPOLLNVAL = 8 + kPOLLIN = 1, //!< Socket is readable + kPOLLOUT = 2, //!< Socket is writable + kPOLLERR = 4, //!< The socket is in an error state + kPOLLNVAL = 8 //!< The socket is invalid }; + //! A socket query for \c poll() class CPollEntry { public: + //! The socket to query CArchSocket m_socket; + + //! The events to query for + /*! + The events to query for can be any combination of kPOLLIN and + kPOLLOUT. + */ unsigned short m_events; + + //! The result events unsigned short m_revents; }; //! @name manipulators //@{ + //! Create a new socket + /*! + The socket is an opaque data type. + */ virtual CArchSocket newSocket(EAddressFamily, ESocketType) = 0; + + //! Copy a socket object + /*! + Returns a reference to to socket referred to by \c s. + */ virtual CArchSocket copySocket(CArchSocket s) = 0; + + //! Release a socket reference + /*! + Deletes the given socket object. This does not destroy the socket + the object referred to until there are no remaining references for + the socket. + */ virtual void closeSocket(CArchSocket s) = 0; + + //! Close socket for further reads + /*! + Calling this disallows future reads on socket \c s. + */ virtual void closeSocketForRead(CArchSocket s) = 0; + + //! Close socket for further writes + /*! + Calling this disallows future writes on socket \c s. + */ virtual void closeSocketForWrite(CArchSocket s) = 0; + + //! Bind socket to address + /*! + Binds socket \c s to the address \c addr. + */ virtual void bindSocket(CArchSocket s, CArchNetAddress addr) = 0; + + //! Listen for connections on socket + /*! + Causes the socket \c s to begin listening for incoming connections. + */ virtual void listenOnSocket(CArchSocket s) = 0; + + //! Accept connection on socket + /*! + Accepts a connection on socket \c s, returning a new socket for the + connection and filling in \c addr with the address of the remote + end. \c addr may be NULL if the remote address isn't required. + The original socket \c s is unaffected and remains in the listening + state. The new socket shares most of the properties of \c s except + it's not in the listening state, it's connected, and is not + non-blocking even is \c s is. + + This call blocks if \c s is not non-blocking and there are no + pending connection requests. + + (Cancellation point) + */ virtual CArchSocket acceptSocket(CArchSocket s, CArchNetAddress* addr) = 0; - virtual void connectSocket(CArchSocket s, CArchNetAddress name) = 0; + + //! Connect socket + /*! + Connects the socket \c s to the remote address \c addr. This call + blocks if \c s is not non-blocking. If \c s is non-blocking then + the client can \c poll() for writability to detect a connection. + + (Cancellation point) + */ + virtual void connectSocket(CArchSocket s, CArchNetAddress addr) = 0; + + //! Check socket state + /*! + Tests the state of \c num sockets for readability and/or writability. + Waits up to \c timeout seconds for some socket to become readable + and/or writable (or indefinitely if \c timeout < 0). Returns the + number of sockets that were readable (if readability was being + queried) or writable (if writablility was being queried) and sets + the \c m_revents members of the entries. \c kPOLLERR and \c kPOLLNVAL + are set in \c m_revents as appropriate. If a socket indicates + \c kPOLLERR then \c throwErrorOnSocket() can be used to determine + the type of error. + + (Cancellation point) + */ virtual int pollSocket(CPollEntry[], int num, double timeout) = 0; + + //! Read data from socket + /*! + Read up to \c len bytes from socket \c s in \c buf and return the + number of bytes read. The number of bytes can be less than \c len + if not enough data is available. Returns 0 if the remote end has + disconnected and there is no more queued received data. Blocks if + the socket is not non-blocking and there is no queued received data. + If non-blocking and there is no queued received data then throws + XArchNetworkWouldBlock. + + (Cancellation point) + */ virtual size_t readSocket(CArchSocket s, void* buf, size_t len) = 0; + + //! Write data from socket + /*! + Write up to \c len bytes to socket \c s from \c buf and return the + number of bytes written. The number of bytes can be less than + \c len if the remote end disconnected or the socket is non-blocking + and the internal buffers are full. If non-blocking and the internal + buffers are full before any data is written then throws + XArchNetworkWouldBlock. + + (Cancellation point) + */ virtual size_t writeSocket(CArchSocket s, const void* buf, size_t len) = 0; - virtual void throwErrorOnSocket(CArchSocket) = 0; + + //! Check error on socket + /*! + If the socket \c s is in an error state then throws an appropriate + XArchNetwork exception. + */ + virtual void throwErrorOnSocket(CArchSocket s) = 0; //! Set socket to (non-)blocking operation /*! @@ -87,17 +235,42 @@ public: */ virtual bool setNoDelayOnSocket(CArchSocket, bool noDelay) = 0; + //! Return local host's name virtual std::string getHostName() = 0; + + //! Create an "any" network address virtual CArchNetAddress newAnyAddr(EAddressFamily) = 0; + + //! Copy a network address virtual CArchNetAddress copyAddr(CArchNetAddress) = 0; + + //! Convert a name to a network address virtual CArchNetAddress nameToAddr(const std::string&) = 0; + + //! Destroy a network address virtual void closeAddr(CArchNetAddress) = 0; + + //! Convert an address to a host name virtual std::string addrToName(CArchNetAddress) = 0; + + //! Convert an address to a string virtual std::string addrToString(CArchNetAddress) = 0; + + //! Get an address's family virtual EAddressFamily getAddrFamily(CArchNetAddress) = 0; + + //! Set the port of an address virtual void setAddrPort(CArchNetAddress, int port) = 0; + + //! Get the port of an address virtual int getAddrPort(CArchNetAddress) = 0; - virtual bool isAnyAddr(CArchNetAddress) = 0; + + //! Test for the "any" address + /*! + Returns true if \c addr is the "any" address. \c newAnyAddr() + returns an "any" address. + */ + virtual bool isAnyAddr(CArchNetAddress addr) = 0; //@} }; diff --git a/lib/arch/IArchSleep.h b/lib/arch/IArchSleep.h index df6e88e8..95a2852c 100644 --- a/lib/arch/IArchSleep.h +++ b/lib/arch/IArchSleep.h @@ -17,6 +17,11 @@ #include "IInterface.h" +//! Interface for architecture dependent sleeping +/*! +This interface defines the sleep operations required by +synergy. Each architecture must implement this interface. +*/ class IArchSleep : public IInterface { public: //! @name manipulators diff --git a/lib/arch/IArchString.h b/lib/arch/IArchString.h index d8117c30..2d9a507d 100644 --- a/lib/arch/IArchString.h +++ b/lib/arch/IArchString.h @@ -18,11 +18,39 @@ #include "IInterface.h" #include +/*! +\class CArchMBStateImpl +\brief Internal multibyte conversion data. +An architecture dependent type holding the necessary data for a +multibyte to/from wide character conversion. +*/ class CArchMBStateImpl; + +/*! +\var CArchMBState +\brief Opaque multibyte conversion state type. +An opaque type representing multibyte conversion state. +*/ typedef CArchMBStateImpl* CArchMBState; +//! Interface for architecture dependent string operations +/*! +This interface defines the string operations required by +synergy. Each architecture must implement this interface. +*/ class IArchString : public IInterface { public: + //! Wide character encodings + /*! + The known wide character encodings + */ + enum EWideCharEncoding { + kUCS2, //!< The UCS-2 encoding + kUCS4, //!< The UCS-4 encoding + kUTF16, //!< The UTF-16 encoding + kUTF32 //!< The UTF-32 encoding + }; + //! @name manipulators //@{ @@ -55,6 +83,10 @@ public: //! Convert wide character to multibyte virtual int convWCToMB(char*, wchar_t, CArchMBState) = 0; + //! Return the architecture's native wide character encoding + virtual EWideCharEncoding + getWideCharEncoding() = 0; + //@} }; diff --git a/lib/arch/IArchTime.h b/lib/arch/IArchTime.h index b2b9a5cd..dade64bb 100644 --- a/lib/arch/IArchTime.h +++ b/lib/arch/IArchTime.h @@ -17,6 +17,11 @@ #include "IInterface.h" +//! Interface for architecture dependent time operations +/*! +This interface defines the time operations required by +synergy. Each architecture must implement this interface. +*/ class IArchTime : public IInterface { public: //! @name manipulators diff --git a/lib/arch/Makefile.am b/lib/arch/Makefile.am index e495adf8..008e2169 100644 --- a/lib/arch/Makefile.am +++ b/lib/arch/Makefile.am @@ -61,7 +61,6 @@ libarch_a_SOURCES = \ IArchString.h \ IArchTime.h \ XArch.h \ - XArchImpl.h \ $(NULL) EXTRA_libarch_a_SOURCES = \ CArchConsoleUnix.cpp \ diff --git a/lib/arch/XArchImpl.h b/lib/arch/XArchImpl.h deleted file mode 100644 index 28c79721..00000000 --- a/lib/arch/XArchImpl.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * synergy -- mouse and keyboard sharing utility - * Copyright (C) 2002 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 XARCHIMPL_H -#define XARCHIMPL_H - -// include appropriate architecture implementation -#if WINDOWS_LIKE -# include "XArchWindows.h" -#elif UNIX_LIKE -# include "XArchUnix.h" -#endif - -#endif diff --git a/lib/arch/arch.dsp b/lib/arch/arch.dsp index 1af4c4b7..cb82663a 100644 --- a/lib/arch/arch.dsp +++ b/lib/arch/arch.dsp @@ -179,10 +179,6 @@ SOURCE=.\XArch.h # End Source File # Begin Source File -SOURCE=.\XArchImpl.h -# End Source File -# Begin Source File - SOURCE=.\XArchWindows.h # End Source File # End Group diff --git a/lib/base/CLog.cpp b/lib/base/CLog.cpp index 84fe9994..6b504993 100644 --- a/lib/base/CLog.cpp +++ b/lib/base/CLog.cpp @@ -54,12 +54,7 @@ static const int g_prioritySuffixLength = 2; static const int g_priorityPad = g_maxPriorityLength + g_prioritySuffixLength; -// -// CLogLock -// -// Convenience object to lock/unlock a mutex. -// - +//! Convenience object to lock/unlock a mutex class CLogLock { public: CLogLock(CArchMutex mutex) : m_mutex(mutex) { ARCH->lockMutex(m_mutex); } diff --git a/lib/base/CUnicode.cpp b/lib/base/CUnicode.cpp index a0233d8d..5cac46d6 100644 --- a/lib/base/CUnicode.cpp +++ b/lib/base/CUnicode.cpp @@ -414,13 +414,31 @@ wchar_t* CUnicode::UTF8ToWideChar(const CString& src, UInt32& size, bool* errors) { // convert to platform's wide character encoding -#if WINDOWS_LIKE - CString tmp = UTF8ToUTF16(src, errors); - size = tmp.size() >> 1; -#elif UNIX_LIKE - CString tmp = UTF8ToUCS4(src, errors); - size = tmp.size() >> 2; -#endif + CString tmp; + switch (ARCH->getWideCharEncoding()) { + case IArchString::kUCS2: + tmp = UTF8ToUCS2(src, errors); + size = tmp.size() >> 1; + break; + + case IArchString::kUCS4: + tmp = UTF8ToUCS4(src, errors); + size = tmp.size() >> 2; + break; + + case IArchString::kUTF16: + tmp = UTF8ToUTF16(src, errors); + size = tmp.size() >> 1; + break; + + case IArchString::kUTF32: + tmp = UTF8ToUTF32(src, errors); + size = tmp.size() >> 2; + break; + + default: + assert(0 && "unknown wide character encoding"); + } // copy to a wchar_t array wchar_t* dst = new wchar_t[size]; @@ -434,11 +452,23 @@ CUnicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors) // convert from platform's wide character encoding. // note -- this must include a wide nul character (independent of // the CString's nul character). -#if WINDOWS_LIKE - return doUTF16ToUTF8(reinterpret_cast(src), size, errors); -#elif UNIX_LIKE - return doUCS4ToUTF8(reinterpret_cast(src), size, errors); -#endif + switch (ARCH->getWideCharEncoding()) { + case IArchString::kUCS2: + return doUCS2ToUTF8(reinterpret_cast(src), size, errors); + + case IArchString::kUCS4: + return doUCS4ToUTF8(reinterpret_cast(src), size, errors); + + case IArchString::kUTF16: + return doUTF16ToUTF8(reinterpret_cast(src), size, errors); + + case IArchString::kUTF32: + return doUTF32ToUTF8(reinterpret_cast(src), size, errors); + + default: + assert(0 && "unknown wide character encoding"); + return CString(); + } } CString diff --git a/lib/base/XBase.cpp b/lib/base/XBase.cpp index 20d5f464..022be306 100644 --- a/lib/base/XBase.cpp +++ b/lib/base/XBase.cpp @@ -17,30 +17,17 @@ #include #include -// win32 wants a const char* argument to std::exception c'tor -#if WINDOWS_LIKE -#include -#define STDEXCEPTARG "" -#endif - -// default to no argument -#ifndef STDEXCEPTARG -#define STDEXCEPTARG -#endif - // // XBase // XBase::XBase() : -// exception(STDEXCEPTARG), m_what() { // do nothing } XBase::XBase(const CString& msg) : -// exception(STDEXCEPTARG), m_what(msg) { // do nothing diff --git a/lib/base/XBase.h b/lib/base/XBase.h index fa93f94d..e9161d70 100644 --- a/lib/base/XBase.h +++ b/lib/base/XBase.h @@ -16,17 +16,12 @@ #define XBASE_H #include "CString.h" -/* -#include "stdpre.h" -#include -#include "stdpost.h" -*/ //! Exception base class /*! This is the base class of most exception types. */ -class XBase /*: public std::exception*/ { +class XBase { public: //! Use getWhat() as the result of what() XBase(); @@ -34,7 +29,7 @@ public: XBase(const CString& msg); virtual ~XBase(); - // std::exception overrides + //! Reason for exception virtual const char* what() const; protected: diff --git a/lib/client/Makefile.am b/lib/client/Makefile.am index 23c0e101..9d6ba463 100644 --- a/lib/client/Makefile.am +++ b/lib/client/Makefile.am @@ -17,8 +17,6 @@ VDEPTH = ./$(VPATH)/$(DEPTH) EXTRA_DIST = \ client.dsp \ - CMSWindowsSecondaryScreen.cpp \ - CMSWindowsSecondaryScreen.h \ $(NULL) MAINTAINERCLEANFILES = \ @@ -28,14 +26,9 @@ MAINTAINERCLEANFILES = \ noinst_LIBRARIES = libclient.a libclient_a_SOURCES = \ CClient.cpp \ - CSecondaryScreen.cpp \ CServerProxy.cpp \ - CXWindowsSecondaryScreen.cpp \ CClient.h \ - CSecondaryScreen.h \ CServerProxy.h \ - CXWindowsSecondaryScreen.h \ - ISecondaryScreenFactory.h \ $(NULL) INCLUDES = \ -I$(VDEPTH)/lib/common \ diff --git a/lib/client/client.dsp b/lib/client/client.dsp index a9b03625..9be31758 100644 --- a/lib/client/client.dsp +++ b/lib/client/client.dsp @@ -91,14 +91,6 @@ SOURCE=.\CClient.cpp # End Source File # Begin Source File -SOURCE=.\CMSWindowsSecondaryScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\CSecondaryScreen.cpp -# End Source File -# Begin Source File - SOURCE=.\CServerProxy.cpp # End Source File # End Group @@ -111,20 +103,8 @@ SOURCE=.\CClient.h # End Source File # Begin Source File -SOURCE=.\CMSWindowsSecondaryScreen.h -# End Source File -# Begin Source File - -SOURCE=.\CSecondaryScreen.h -# End Source File -# Begin Source File - SOURCE=.\CServerProxy.h # End Source File -# Begin Source File - -SOURCE=.\ISecondaryScreenFactory.h -# End Source File # End Group # Begin Group "Resource Files" diff --git a/lib/http/XHTTP.h b/lib/http/XHTTP.h index e601600a..2bd6ed73 100644 --- a/lib/http/XHTTP.h +++ b/lib/http/XHTTP.h @@ -62,6 +62,7 @@ private: CString m_reason; }; +//! HTTP exception indicating an unsupported method class XHTTPAllow : public XHTTP { public: /*! diff --git a/lib/server/CMSWindowsPrimaryScreen.cpp b/lib/platform/CMSWindowsPrimaryScreen.cpp similarity index 100% rename from lib/server/CMSWindowsPrimaryScreen.cpp rename to lib/platform/CMSWindowsPrimaryScreen.cpp diff --git a/lib/server/CMSWindowsPrimaryScreen.h b/lib/platform/CMSWindowsPrimaryScreen.h similarity index 100% rename from lib/server/CMSWindowsPrimaryScreen.h rename to lib/platform/CMSWindowsPrimaryScreen.h diff --git a/lib/platform/CMSWindowsScreen.h b/lib/platform/CMSWindowsScreen.h index 89565260..6183d50f 100644 --- a/lib/platform/CMSWindowsScreen.h +++ b/lib/platform/CMSWindowsScreen.h @@ -35,7 +35,7 @@ public: class IScreenReceiver; class IMSWindowsScreenEventHandler; -// Microsoft windows screen implementation +//! Implementation of IScreen for Microsoft Windows class CMSWindowsScreen : public IScreen { public: CMSWindowsScreen(IScreenReceiver*, IMSWindowsScreenEventHandler*); diff --git a/lib/client/CMSWindowsSecondaryScreen.cpp b/lib/platform/CMSWindowsSecondaryScreen.cpp similarity index 100% rename from lib/client/CMSWindowsSecondaryScreen.cpp rename to lib/platform/CMSWindowsSecondaryScreen.cpp diff --git a/lib/client/CMSWindowsSecondaryScreen.h b/lib/platform/CMSWindowsSecondaryScreen.h similarity index 100% rename from lib/client/CMSWindowsSecondaryScreen.h rename to lib/platform/CMSWindowsSecondaryScreen.h diff --git a/lib/server/CXWindowsPrimaryScreen.cpp b/lib/platform/CXWindowsPrimaryScreen.cpp similarity index 100% rename from lib/server/CXWindowsPrimaryScreen.cpp rename to lib/platform/CXWindowsPrimaryScreen.cpp diff --git a/lib/server/CXWindowsPrimaryScreen.h b/lib/platform/CXWindowsPrimaryScreen.h similarity index 100% rename from lib/server/CXWindowsPrimaryScreen.h rename to lib/platform/CXWindowsPrimaryScreen.h diff --git a/lib/platform/CXWindowsScreen.h b/lib/platform/CXWindowsScreen.h index f74b8389..a6451763 100644 --- a/lib/platform/CXWindowsScreen.h +++ b/lib/platform/CXWindowsScreen.h @@ -33,6 +33,11 @@ class IScreenReceiver; class CXWindowsClipboard; class CXWindowsScreenSaver; +/*! +\class CEvent +\brief User event data +An architecture dependent type holding user event data. +*/ // X11 event class CEvent { public: @@ -40,7 +45,7 @@ public: SInt32 m_result; }; -// X11 screen implementation +//! Implementation of IScreen for X11 class CXWindowsScreen : public IScreen { public: CXWindowsScreen(IScreenReceiver*, IScreenEventHandler*); @@ -279,6 +284,7 @@ private: static CXWindowsScreen* s_screen; }; +//! Convenience object to lock/unlock a CXWindowsScreen class CDisplayLock { public: CDisplayLock(const CXWindowsScreen*); diff --git a/lib/client/CXWindowsSecondaryScreen.cpp b/lib/platform/CXWindowsSecondaryScreen.cpp similarity index 100% rename from lib/client/CXWindowsSecondaryScreen.cpp rename to lib/platform/CXWindowsSecondaryScreen.cpp diff --git a/lib/client/CXWindowsSecondaryScreen.h b/lib/platform/CXWindowsSecondaryScreen.h similarity index 100% rename from lib/client/CXWindowsSecondaryScreen.h rename to lib/platform/CXWindowsSecondaryScreen.h diff --git a/lib/platform/Makefile.am b/lib/platform/Makefile.am index e6c6d6b6..ea082e15 100644 --- a/lib/platform/Makefile.am +++ b/lib/platform/Makefile.am @@ -23,15 +23,19 @@ EXTRA_DIST = \ CMSWindowsClipboardAnyTextConverter.cpp \ CMSWindowsClipboardTextConverter.cpp \ CMSWindowsClipboardUTF16Converter.cpp \ + CMSWindowsPrimaryScreen.cpp \ CMSWindowsScreen.cpp \ CMSWindowsScreenSaver.cpp \ + CMSWindowsSecondaryScreen.cpp \ CSynergyHook.cpp \ CMSWindowsClipboard.h \ CMSWindowsClipboardAnyTextConverter.h \ CMSWindowsClipboardTextConverter.h \ CMSWindowsClipboardUTF16Converter.h \ + CMSWindowsPrimaryScreen.h \ CMSWindowsScreen.h \ CMSWindowsScreenSaver.h \ + CMSWindowsSecondaryScreen.h \ CSynergyHook.h \ IMSWindowsScreenEventHandler.h \ $(NULL) @@ -46,15 +50,19 @@ libplatform_a_SOURCES = \ CXWindowsClipboardTextConverter.cpp \ CXWindowsClipboardUCS2Converter.cpp \ CXWindowsClipboardUTF8Converter.cpp \ + CXWindowsPrimaryScreen.cpp \ CXWindowsScreen.cpp \ CXWindowsScreenSaver.cpp \ + CXWindowsSecondaryScreen.cpp \ CXWindowsUtil.cpp \ CXWindowsClipboard.h \ CXWindowsClipboardTextConverter.h \ CXWindowsClipboardUCS2Converter.h \ CXWindowsClipboardUTF8Converter.h \ + CXWindowsPrimaryScreen.h \ CXWindowsScreen.h \ CXWindowsScreenSaver.h \ + CXWindowsSecondaryScreen.h \ CXWindowsUtil.h \ $(NULL) INCLUDES = \ diff --git a/lib/platform/platform.dsp b/lib/platform/platform.dsp index 300f12cb..ae599964 100644 --- a/lib/platform/platform.dsp +++ b/lib/platform/platform.dsp @@ -103,12 +103,20 @@ SOURCE=.\CMSWindowsClipboardUTF16Converter.cpp # End Source File # Begin Source File +SOURCE=.\CMSWindowsPrimaryScreen.cpp +# End Source File +# Begin Source File + SOURCE=.\CMSWindowsScreen.cpp # End Source File # Begin Source File SOURCE=.\CMSWindowsScreenSaver.cpp # End Source File +# Begin Source File + +SOURCE=.\CMSWindowsSecondaryScreen.cpp +# End Source File # End Group # Begin Group "Header Files" @@ -131,6 +139,10 @@ SOURCE=.\CMSWindowsClipboardUTF16Converter.h # End Source File # Begin Source File +SOURCE=.\CMSWindowsPrimaryScreen.h +# End Source File +# Begin Source File + SOURCE=.\CMSWindowsScreen.h # End Source File # Begin Source File @@ -139,6 +151,10 @@ SOURCE=.\CMSWindowsScreenSaver.h # End Source File # Begin Source File +SOURCE=.\CMSWindowsSecondaryScreen.h +# End Source File +# Begin Source File + SOURCE=.\IMSWindowsScreenEventHandler.h # End Source File # End Group diff --git a/lib/server/Makefile.am b/lib/server/Makefile.am index 5f4daf73..b1900797 100644 --- a/lib/server/Makefile.am +++ b/lib/server/Makefile.am @@ -17,8 +17,6 @@ VDEPTH = ./$(VPATH)/$(DEPTH) EXTRA_DIST = \ server.dsp \ - CMSWindowsPrimaryScreen.cpp \ - CMSWindowsPrimaryScreen.h \ $(NULL) MAINTAINERCLEANFILES = \ @@ -32,18 +30,13 @@ libserver_a_SOURCES = \ CConfig.cpp \ CHTTPServer.cpp \ CPrimaryClient.cpp \ - CPrimaryScreen.cpp \ CServer.cpp \ - CXWindowsPrimaryScreen.cpp \ CClientProxy.h \ CClientProxy1_0.h \ CConfig.h \ CHTTPServer.h \ CPrimaryClient.h \ - CPrimaryScreen.h \ CServer.h \ - CXWindowsPrimaryScreen.h \ - IPrimaryScreenFactory.h \ $(NULL) INCLUDES = \ -I$(VDEPTH)/lib/common \ diff --git a/lib/server/server.dsp b/lib/server/server.dsp index 26134e1c..29ee4b0a 100644 --- a/lib/server/server.dsp +++ b/lib/server/server.dsp @@ -103,18 +103,10 @@ SOURCE=.\CHTTPServer.cpp # End Source File # Begin Source File -SOURCE=.\CMSWindowsPrimaryScreen.cpp -# End Source File -# Begin Source File - SOURCE=.\CPrimaryClient.cpp # End Source File # Begin Source File -SOURCE=.\CPrimaryScreen.cpp -# End Source File -# Begin Source File - SOURCE=.\CServer.cpp # End Source File # End Group @@ -139,24 +131,12 @@ SOURCE=.\CHTTPServer.h # End Source File # Begin Source File -SOURCE=.\CMSWindowsPrimaryScreen.h -# End Source File -# Begin Source File - SOURCE=.\CPrimaryClient.h # End Source File # Begin Source File -SOURCE=.\CPrimaryScreen.h -# End Source File -# Begin Source File - SOURCE=.\CServer.h # End Source File -# Begin Source File - -SOURCE=.\IPrimaryScreenFactory.h -# End Source File # End Group # Begin Group "Resource Files" diff --git a/lib/server/CPrimaryScreen.cpp b/lib/synergy/CPrimaryScreen.cpp similarity index 100% rename from lib/server/CPrimaryScreen.cpp rename to lib/synergy/CPrimaryScreen.cpp diff --git a/lib/server/CPrimaryScreen.h b/lib/synergy/CPrimaryScreen.h similarity index 100% rename from lib/server/CPrimaryScreen.h rename to lib/synergy/CPrimaryScreen.h diff --git a/lib/client/CSecondaryScreen.cpp b/lib/synergy/CSecondaryScreen.cpp similarity index 100% rename from lib/client/CSecondaryScreen.cpp rename to lib/synergy/CSecondaryScreen.cpp diff --git a/lib/client/CSecondaryScreen.h b/lib/synergy/CSecondaryScreen.h similarity index 100% rename from lib/client/CSecondaryScreen.h rename to lib/synergy/CSecondaryScreen.h diff --git a/lib/server/IPrimaryScreenFactory.h b/lib/synergy/IPrimaryScreenFactory.h similarity index 100% rename from lib/server/IPrimaryScreenFactory.h rename to lib/synergy/IPrimaryScreenFactory.h diff --git a/lib/client/ISecondaryScreenFactory.h b/lib/synergy/ISecondaryScreenFactory.h similarity index 100% rename from lib/client/ISecondaryScreenFactory.h rename to lib/synergy/ISecondaryScreenFactory.h diff --git a/lib/synergy/Makefile.am b/lib/synergy/Makefile.am index c86a8b34..4f1f1353 100644 --- a/lib/synergy/Makefile.am +++ b/lib/synergy/Makefile.am @@ -25,24 +25,30 @@ MAINTAINERCLEANFILES = \ noinst_LIBRARIES = libsynergy.a libsynergy_a_SOURCES = \ + CClipboard.cpp \ CInputPacketStream.cpp \ COutputPacketStream.cpp \ + CPrimaryScreen.cpp \ CProtocolUtil.cpp \ - CClipboard.cpp \ + CSecondaryScreen.cpp \ XScreen.cpp \ XSynergy.cpp \ CClipboard.h \ CInputPacketStream.h \ COutputPacketStream.h \ + CPrimaryScreen.h \ CProtocolUtil.h \ + CSecondaryScreen.h \ ClipboardTypes.h \ IClient.h \ IClipboard.h \ + IPrimaryScreenFactory.h \ IPrimaryScreenReceiver.h \ IScreen.h \ IScreenEventHandler.h \ IScreenReceiver.h \ IScreenSaver.h \ + ISecondaryScreenFactory.h \ IServer.h \ KeyTypes.h \ MouseTypes.h \ diff --git a/lib/synergy/libsynergy.dsp b/lib/synergy/libsynergy.dsp index 3b121f79..583271c6 100644 --- a/lib/synergy/libsynergy.dsp +++ b/lib/synergy/libsynergy.dsp @@ -99,10 +99,18 @@ SOURCE=.\COutputPacketStream.cpp # End Source File # Begin Source File +SOURCE=.\CPrimaryScreen.cpp +# End Source File +# Begin Source File + SOURCE=.\CProtocolUtil.cpp # End Source File # Begin Source File +SOURCE=.\CSecondaryScreen.cpp +# End Source File +# Begin Source File + SOURCE=.\XScreen.cpp # End Source File # Begin Source File @@ -131,10 +139,18 @@ SOURCE=.\COutputPacketStream.h # End Source File # Begin Source File +SOURCE=.\CPrimaryScreen.h +# End Source File +# Begin Source File + SOURCE=.\CProtocolUtil.h # End Source File # Begin Source File +SOURCE=.\CSecondaryScreen.h +# End Source File +# Begin Source File + SOURCE=.\IClient.h # End Source File # Begin Source File @@ -143,6 +159,10 @@ SOURCE=.\IClipboard.h # End Source File # Begin Source File +SOURCE=.\IPrimaryScreenFactory.h +# End Source File +# Begin Source File + SOURCE=.\IPrimaryScreenReceiver.h # End Source File # Begin Source File @@ -163,6 +183,10 @@ SOURCE=.\IScreenSaver.h # End Source File # Begin Source File +SOURCE=.\ISecondaryScreenFactory.h +# End Source File +# Begin Source File + SOURCE=.\IServer.h # End Source File # Begin Source File