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.
This commit is contained in:
crs 2003-01-05 21:48:54 +00:00
parent f65921bc3f
commit e9cc0b434e
70 changed files with 672 additions and 156 deletions

57
PORTING
View File

@ -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.

View File

@ -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() { }

View File

@ -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() { }

View File

@ -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

View File

@ -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()
{

View File

@ -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();

View File

@ -19,6 +19,7 @@
#define ARCH_CONSOLE CArchConsoleUnix
//! Unix implementation of IArchConsole
class CArchConsoleUnix : public IArchConsole {
public:
CArchConsoleUnix();

View File

@ -23,6 +23,7 @@
#define ARCH_CONSOLE CArchConsoleWindows
//! Win32 implementation of IArchConsole
class CArchConsoleWindows : public IArchConsole {
public:
CArchConsoleWindows();

View File

@ -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();

View File

@ -20,6 +20,7 @@
#undef ARCH_DAEMON
#define ARCH_DAEMON CArchDaemonUnix
//! Unix implementation of IArchDaemon
class CArchDaemonUnix : public CArchDaemonNone {
public:
CArchDaemonUnix();

View File

@ -25,6 +25,7 @@
#define ARCH_DAEMON CArchDaemonWindows
//! Win32 implementation of IArchDaemon
class CArchDaemonWindows : public IArchDaemon {
public:
typedef int (*RunFunc)(void);

View File

@ -19,6 +19,7 @@
#define ARCH_FILE CArchFileUnix
//! Unix implementation of IArchFile
class CArchFileUnix : public IArchFile {
public:
CArchFileUnix();

View File

@ -19,6 +19,7 @@
#define ARCH_FILE CArchFileWindows
//! Win32 implementation of IArchFile
class CArchFileWindows : public IArchFile {
public:
CArchFileWindows();

View File

@ -19,6 +19,7 @@
#define ARCH_LOG CArchLogUnix
//! Unix implementation of IArchLog
class CArchLogUnix : public IArchLog {
public:
CArchLogUnix();

View File

@ -22,6 +22,7 @@
#define ARCH_LOG CArchLogWindows
//! Win32 implementation of IArchLog
class CArchLogWindows : public IArchLog {
public:
CArchLogWindows();

View File

@ -15,6 +15,7 @@
#ifndef CARCHMISCWINDOWS_H
#define CARCHMISCWINDOWS_H
//! Miscellaneous win32 functions.
class CArchMiscWindows {
public:
typedef int (*RunFunc)(void);

View File

@ -31,6 +31,7 @@ public:
pthread_mutex_t m_mutex;
};
//! Posix implementation of IArchMultithread
class CArchMultithreadPosix : public IArchMultithread {
public:
CArchMultithreadPosix();

View File

@ -575,7 +575,7 @@ CArchMultithreadWindows::refThread(CArchThreadImpl* thread)
}
void
CArchMultithreadWindows::testCancelThreadImpl(CArchThread thread)
CArchMultithreadWindows::testCancelThreadImpl(CArchThreadImpl* thread)
{
assert(thread != NULL);

View File

@ -37,6 +37,7 @@ public:
CRITICAL_SECTION m_mutex;
};
//! Win32 implementation of IArchMultithread
class CArchMultithreadWindows : public IArchMultithread {
public:
CArchMultithreadWindows();

View File

@ -50,6 +50,7 @@ public:
socklen_t m_len;
};
//! Berkeley (BSD) sockets implementation of IArchNetwork
class CArchNetworkBSD : public IArchNetwork {
public:
CArchNetworkBSD();

View File

@ -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))

View File

@ -44,6 +44,7 @@ public:
int m_len;
};
//! Win32 implementation of IArchNetwork
class CArchNetworkWinsock : public IArchNetwork {
public:
CArchNetworkWinsock();

View File

@ -19,6 +19,7 @@
#define ARCH_SLEEP CArchSleepUnix
//! Unix implementation of IArchSleep
class CArchSleepUnix : public IArchSleep {
public:
CArchSleepUnix();

View File

@ -19,6 +19,7 @@
#define ARCH_SLEEP CArchSleepWindows
//! Win32 implementation of IArchSleep
class CArchSleepWindows : public IArchSleep {
public:
CArchSleepWindows();

View File

@ -32,3 +32,9 @@ CArchStringUnix::~CArchStringUnix()
}
#include "vsnprintf.cpp"
IArchString::EWideCharEncoding
CArchStringUnix::getWideCharEncoding()
{
return kUCS4;
}

View File

@ -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

View File

@ -36,3 +36,9 @@ CArchStringWindows::~CArchStringWindows()
#define HAVE_VSNPRINTF 1
#define ARCH_VSNPRINTF _vsnprintf
#include "vsnprintf.cpp"
IArchString::EWideCharEncoding
CArchStringWindows::getWideCharEncoding()
{
return kUTF16;
}

View File

@ -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

View File

@ -19,6 +19,7 @@
#define ARCH_TIME CArchTimeUnix
//! Generic Unix implementation of IArchTime
class CArchTimeUnix : public IArchTime {
public:
CArchTimeUnix();

View File

@ -19,6 +19,7 @@
#define ARCH_TIME CArchTimeWindows
//! Win32 implementation of IArchTime
class CArchTimeWindows : public IArchTime {
public:
CArchTimeWindows();

View File

@ -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

View File

@ -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

View File

@ -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
//@{

View File

@ -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;
//@}
};

View File

@ -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;
//@}
};

View File

@ -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

View File

@ -18,11 +18,39 @@
#include "IInterface.h"
#include <stdarg.h>
/*!
\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;
//@}
};

View File

@ -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

View File

@ -61,7 +61,6 @@ libarch_a_SOURCES = \
IArchString.h \
IArchTime.h \
XArch.h \
XArchImpl.h \
$(NULL)
EXTRA_libarch_a_SOURCES = \
CArchConsoleUnix.cpp \

View File

@ -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

View File

@ -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

View File

@ -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); }

View File

@ -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);
CString tmp;
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
tmp = UTF8ToUCS2(src, errors);
size = tmp.size() >> 1;
#elif UNIX_LIKE
CString tmp = UTF8ToUCS4(src, errors);
break;
case IArchString::kUCS4:
tmp = UTF8ToUCS4(src, errors);
size = tmp.size() >> 2;
#endif
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<const UInt8*>(src), size, errors);
#elif UNIX_LIKE
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
return doUCS2ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
case IArchString::kUCS4:
return doUCS4ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
#endif
case IArchString::kUTF16:
return doUTF16ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
case IArchString::kUTF32:
return doUTF32ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
default:
assert(0 && "unknown wide character encoding");
return CString();
}
}
CString

View File

@ -17,30 +17,17 @@
#include <cerrno>
#include <cstdarg>
// win32 wants a const char* argument to std::exception c'tor
#if WINDOWS_LIKE
#include <windows.h>
#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

View File

@ -16,17 +16,12 @@
#define XBASE_H
#include "CString.h"
/*
#include "stdpre.h"
#include <exception>
#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:

View File

@ -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 \

View File

@ -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"

View File

@ -62,6 +62,7 @@ private:
CString m_reason;
};
//! HTTP exception indicating an unsupported method
class XHTTPAllow : public XHTTP {
public:
/*!

View File

@ -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*);

View File

@ -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*);

View File

@ -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 = \

View File

@ -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

View File

@ -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 \

View File

@ -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"

View File

@ -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 \

View File

@ -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