Indentation changes.
This commit is contained in:
parent
3ca72b35f3
commit
ea6b347b18
|
@ -4,13 +4,13 @@
|
||||||
#include "IJob.h"
|
#include "IJob.h"
|
||||||
|
|
||||||
class CFunctionJob : public IJob {
|
class CFunctionJob : public IJob {
|
||||||
public:
|
public:
|
||||||
CFunctionJob(void (*func)(void*), void* arg = NULL);
|
CFunctionJob(void (*func)(void*), void* arg = NULL);
|
||||||
|
|
||||||
// IJob overrides
|
// IJob overrides
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void (*m_func)(void*);
|
void (*m_func)(void*);
|
||||||
void* m_arg;
|
void* m_arg;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
class CLog {
|
class CLog {
|
||||||
public:
|
public:
|
||||||
typedef void (*Outputter)(const char*);
|
typedef void (*Outputter)(const char*);
|
||||||
|
|
||||||
static void print(const char*, ...);
|
static void print(const char*, ...);
|
||||||
static void printt(const char* file, int line, const char*, ...);
|
static void printt(const char* file, int line, const char*, ...);
|
||||||
static void setOutputter(Outputter);
|
static void setOutputter(Outputter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void output(int priority, char* msg);
|
static void output(int priority, char* msg);
|
||||||
static char* vsprint(int pad, char*, int len, const char*, va_list);
|
static char* vsprint(int pad, char*, int len, const char*, va_list);
|
||||||
static int nprint(const char*, va_list);
|
static int nprint(const char*, va_list);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Outputter s_outputter;
|
static Outputter s_outputter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ static PTimeGetTime s_tgt = NULL;
|
||||||
//
|
//
|
||||||
|
|
||||||
class CStopwatchInit {
|
class CStopwatchInit {
|
||||||
public:
|
public:
|
||||||
CStopwatchInit();
|
CStopwatchInit();
|
||||||
~CStopwatchInit();
|
~CStopwatchInit();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,54 +4,54 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
class CStopwatch {
|
class CStopwatch {
|
||||||
public:
|
public:
|
||||||
// the default constructor does an implicit reset() or setTrigger().
|
// the default constructor does an implicit reset() or setTrigger().
|
||||||
// if triggered == false then the clock starts ticking.
|
// if triggered == false then the clock starts ticking.
|
||||||
CStopwatch(bool triggered = false);
|
CStopwatch(bool triggered = false);
|
||||||
~CStopwatch();
|
~CStopwatch();
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// set the start time to the current time, returning the time since
|
// set the start time to the current time, returning the time since
|
||||||
// the last reset. this does not remove the trigger if it's set nor
|
// the last reset. this does not remove the trigger if it's set nor
|
||||||
// does it start a stopped clock. if the clock is stopped then
|
// does it start a stopped clock. if the clock is stopped then
|
||||||
// subsequent reset()'s will return 0.
|
// subsequent reset()'s will return 0.
|
||||||
double reset();
|
double reset();
|
||||||
|
|
||||||
// stop and start the stopwatch. while stopped, no time elapses.
|
// stop and start the stopwatch. while stopped, no time elapses.
|
||||||
// stop() does not remove the trigger but start() does, even if
|
// stop() does not remove the trigger but start() does, even if
|
||||||
// the clock was already started.
|
// the clock was already started.
|
||||||
void stop();
|
void stop();
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
// setTrigger() stops the clock like stop() except there's an
|
// setTrigger() stops the clock like stop() except there's an
|
||||||
// implicit start() the next time (non-const) getTime() is called.
|
// implicit start() the next time (non-const) getTime() is called.
|
||||||
// this is useful when you want the clock to start the first time
|
// this is useful when you want the clock to start the first time
|
||||||
// you check it.
|
// you check it.
|
||||||
void setTrigger();
|
void setTrigger();
|
||||||
|
|
||||||
// return the time since the last reset() (or call reset() and
|
// return the time since the last reset() (or call reset() and
|
||||||
// return zero if the trigger is set).
|
// return zero if the trigger is set).
|
||||||
double getTime();
|
double getTime();
|
||||||
operator double();
|
operator double();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// returns true if the watch is stopped
|
// returns true if the watch is stopped
|
||||||
bool isStopped() const;
|
bool isStopped() const;
|
||||||
|
|
||||||
// return the time since the last reset(). these cannot trigger
|
// return the time since the last reset(). these cannot trigger
|
||||||
// the clock to start so if the trigger is set it's as if it wasn't.
|
// the clock to start so if the trigger is set it's as if it wasn't.
|
||||||
double getTime() const;
|
double getTime() const;
|
||||||
operator double() const;
|
operator double() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double getClock() const;
|
double getClock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_mark;
|
double m_mark;
|
||||||
bool m_triggered;
|
bool m_triggered;
|
||||||
bool m_stopped;
|
bool m_stopped;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#define _CS(_x) _x
|
#define _CS(_x) _x
|
||||||
|
|
||||||
class CString : public std::string {
|
class CString : public std::string {
|
||||||
public:
|
public:
|
||||||
typedef char _e;
|
typedef char _e;
|
||||||
typedef _e CharT;
|
typedef _e CharT;
|
||||||
typedef std::allocator<_e> _a;
|
typedef std::allocator<_e> _a;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
class IInterface {
|
class IInterface {
|
||||||
public:
|
public:
|
||||||
virtual ~IInterface() { }
|
virtual ~IInterface() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
|
|
||||||
class IJob : public IInterface {
|
class IJob : public IInterface {
|
||||||
public:
|
public:
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class TMethodJob : public IJob {
|
class TMethodJob : public IJob {
|
||||||
public:
|
public:
|
||||||
TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
|
TMethodJob(T* object, void (T::*method)(void*), void* arg = NULL);
|
||||||
|
|
||||||
// IJob overrides
|
// IJob overrides
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_object;
|
T* m_object;
|
||||||
void (T::*m_method)(void*);
|
void (T::*m_method)(void*);
|
||||||
void* m_arg;
|
void* m_arg;
|
||||||
|
|
10
base/XBase.h
10
base/XBase.h
|
@ -5,7 +5,7 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
class XBase : public std::exception {
|
class XBase : public std::exception {
|
||||||
public:
|
public:
|
||||||
XBase();
|
XBase();
|
||||||
XBase(const CString& msg);
|
XBase(const CString& msg);
|
||||||
virtual ~XBase();
|
virtual ~XBase();
|
||||||
|
@ -13,7 +13,7 @@ class XBase : public std::exception {
|
||||||
// std::exception overrides
|
// std::exception overrides
|
||||||
virtual const char* what() const;
|
virtual const char* what() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// returns a human readable string describing the exception
|
// returns a human readable string describing the exception
|
||||||
virtual CString getWhat() const throw() = 0;
|
virtual CString getWhat() const throw() = 0;
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@ class XBase : public std::exception {
|
||||||
virtual CString format(const char* id,
|
virtual CString format(const char* id,
|
||||||
const char* defaultFormat, ...) const throw();
|
const char* defaultFormat, ...) const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable CString m_what;
|
mutable CString m_what;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MXErrno {
|
class MXErrno {
|
||||||
public:
|
public:
|
||||||
MXErrno();
|
MXErrno();
|
||||||
MXErrno(int);
|
MXErrno(int);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class MXErrno {
|
||||||
int getErrno() const;
|
int getErrno() const;
|
||||||
const char* getErrstr() const;
|
const char* getErrstr() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_errno;
|
int m_errno;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class IOutputStream;
|
||||||
class ISecondaryScreen;
|
class ISecondaryScreen;
|
||||||
|
|
||||||
class CClient {
|
class CClient {
|
||||||
public:
|
public:
|
||||||
CClient(const CString& clientName);
|
CClient(const CString& clientName);
|
||||||
~CClient();
|
~CClient();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class CClient {
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void runSession(void*);
|
void runSession(void*);
|
||||||
|
|
||||||
// open/close the primary screen
|
// open/close the primary screen
|
||||||
|
@ -49,7 +49,7 @@ class CClient {
|
||||||
void onMouseMove();
|
void onMouseMove();
|
||||||
void onMouseWheel();
|
void onMouseWheel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex m_mutex;
|
CMutex m_mutex;
|
||||||
CString m_name;
|
CString m_name;
|
||||||
IInputStream* m_input;
|
IInputStream* m_input;
|
||||||
|
|
|
@ -31,14 +31,14 @@ static DWORD s_thread = 0;
|
||||||
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_APP:
|
case WM_APP:
|
||||||
if (!s_logMore.empty()) {
|
if (!s_logMore.empty()) {
|
||||||
if (s_log.size() > 20000)
|
if (s_log.size() > 20000)
|
||||||
s_log = s_logMore;
|
s_log = s_logMore;
|
||||||
|
@ -194,19 +194,19 @@ void CMSWindowsSecondaryScreen::mouseDown(ButtonID button)
|
||||||
// map button id to button flag
|
// map button id to button flag
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case kButtonLeft:
|
case kButtonLeft:
|
||||||
flags = MOUSEEVENTF_LEFTDOWN;
|
flags = MOUSEEVENTF_LEFTDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kButtonMiddle:
|
case kButtonMiddle:
|
||||||
flags = MOUSEEVENTF_MIDDLEDOWN;
|
flags = MOUSEEVENTF_MIDDLEDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kButtonRight:
|
case kButtonRight:
|
||||||
flags = MOUSEEVENTF_RIGHTDOWN;
|
flags = MOUSEEVENTF_RIGHTDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,19 +219,19 @@ void CMSWindowsSecondaryScreen::mouseUp(ButtonID button)
|
||||||
// map button id to button flag
|
// map button id to button flag
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case kButtonLeft:
|
case kButtonLeft:
|
||||||
flags = MOUSEEVENTF_LEFTUP;
|
flags = MOUSEEVENTF_LEFTUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kButtonMiddle:
|
case kButtonMiddle:
|
||||||
flags = MOUSEEVENTF_MIDDLEUP;
|
flags = MOUSEEVENTF_MIDDLEUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kButtonRight:
|
case kButtonRight:
|
||||||
flags = MOUSEEVENTF_RIGHTUP;
|
flags = MOUSEEVENTF_RIGHTUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,12 +361,12 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
// FIXME -- handle display changes
|
// FIXME -- handle display changes
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
ValidateRect(hwnd, NULL);
|
ValidateRect(hwnd, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_ACTIVATEAPP:
|
case WM_ACTIVATEAPP:
|
||||||
if (wParam == FALSE) {
|
if (wParam == FALSE) {
|
||||||
// some other app activated. hide the hider window.
|
// some other app activated. hide the hider window.
|
||||||
log((CLOG_INFO "show cursor"));
|
log((CLOG_INFO "show cursor"));
|
||||||
|
@ -374,7 +374,7 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DRAWCLIPBOARD:
|
case WM_DRAWCLIPBOARD:
|
||||||
log((CLOG_DEBUG "clipboard was taken"));
|
log((CLOG_DEBUG "clipboard was taken"));
|
||||||
|
|
||||||
// first pass it on
|
// first pass it on
|
||||||
|
@ -389,7 +389,7 @@ LRESULT CMSWindowsSecondaryScreen::onEvent(
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_CHANGECBCHAIN:
|
case WM_CHANGECBCHAIN:
|
||||||
if (m_nextClipboardWindow == (HWND)wParam)
|
if (m_nextClipboardWindow == (HWND)wParam)
|
||||||
m_nextClipboardWindow = (HWND)lParam;
|
m_nextClipboardWindow = (HWND)lParam;
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "ISecondaryScreen.h"
|
#include "ISecondaryScreen.h"
|
||||||
|
|
||||||
class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen {
|
class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScreen {
|
||||||
public:
|
public:
|
||||||
CMSWindowsSecondaryScreen();
|
CMSWindowsSecondaryScreen();
|
||||||
virtual ~CMSWindowsSecondaryScreen();
|
virtual ~CMSWindowsSecondaryScreen();
|
||||||
|
|
||||||
|
@ -29,17 +29,17 @@ class CMSWindowsSecondaryScreen : public CMSWindowsScreen, public ISecondaryScre
|
||||||
virtual SInt32 getJumpZoneSize() const;
|
virtual SInt32 getJumpZoneSize() const;
|
||||||
virtual void getClipboard(IClipboard*) const;
|
virtual void getClipboard(IClipboard*) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// CMSWindowsScreen overrides
|
// CMSWindowsScreen overrides
|
||||||
virtual bool onPreTranslate(MSG*);
|
virtual bool onPreTranslate(MSG*);
|
||||||
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
|
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
|
||||||
virtual void onOpenDisplay();
|
virtual void onOpenDisplay();
|
||||||
virtual void onCloseDisplay();
|
virtual void onCloseDisplay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT mapKey(KeyID, KeyModifierMask) const;
|
UINT mapKey(KeyID, KeyModifierMask) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CClient* m_client;
|
CClient* m_client;
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
HWND m_nextClipboardWindow;
|
HWND m_nextClipboardWindow;
|
||||||
|
|
|
@ -38,7 +38,7 @@ void CXWindowsSecondaryScreen::run()
|
||||||
|
|
||||||
// handle event
|
// handle event
|
||||||
switch (xevent.type) {
|
switch (xevent.type) {
|
||||||
case MappingNotify: {
|
case MappingNotify: {
|
||||||
// keyboard mapping changed
|
// keyboard mapping changed
|
||||||
CDisplayLock display(this);
|
CDisplayLock display(this);
|
||||||
XRefreshKeyboardMapping(&xevent.xmapping);
|
XRefreshKeyboardMapping(&xevent.xmapping);
|
||||||
|
@ -47,17 +47,17 @@ void CXWindowsSecondaryScreen::run()
|
||||||
updateModifierMap(display);
|
updateModifierMap(display);
|
||||||
updateModifiers(display);
|
updateModifiers(display);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LeaveNotify: {
|
case LeaveNotify: {
|
||||||
// mouse moved out of hider window somehow. hide the window.
|
// mouse moved out of hider window somehow. hide the window.
|
||||||
assert(m_window != None);
|
assert(m_window != None);
|
||||||
CDisplayLock display(this);
|
CDisplayLock display(this);
|
||||||
XUnmapWindow(display, m_window);
|
XUnmapWindow(display, m_window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
// we just lost the selection. that means someone else
|
// we just lost the selection. that means someone else
|
||||||
// grabbed the selection so this screen is now the
|
// grabbed the selection so this screen is now the
|
||||||
// selection owner. report that to the server.
|
// selection owner. report that to the server.
|
||||||
|
@ -68,7 +68,7 @@ void CXWindowsSecondaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
// notification of selection transferred. we shouldn't
|
// notification of selection transferred. we shouldn't
|
||||||
// get this here because we handle them in the selection
|
// get this here because we handle them in the selection
|
||||||
// retrieval methods. we'll just delete the property
|
// retrieval methods. we'll just delete the property
|
||||||
|
@ -79,7 +79,7 @@ void CXWindowsSecondaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
// somebody is asking for clipboard data
|
// somebody is asking for clipboard data
|
||||||
if (xevent.xselectionrequest.owner == m_window) {
|
if (xevent.xselectionrequest.owner == m_window) {
|
||||||
addClipboardRequest(m_window,
|
addClipboardRequest(m_window,
|
||||||
|
@ -105,7 +105,7 @@ void CXWindowsSecondaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
// clipboard transfers involve property changes so forward
|
// clipboard transfers involve property changes so forward
|
||||||
// the event to the superclass. we only care about the
|
// the event to the superclass. we only care about the
|
||||||
// deletion of properties.
|
// deletion of properties.
|
||||||
|
@ -116,7 +116,7 @@ void CXWindowsSecondaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
// looks like one of the windows that requested a clipboard
|
// looks like one of the windows that requested a clipboard
|
||||||
// transfer has gone bye-bye.
|
// transfer has gone bye-bye.
|
||||||
destroyClipboardRequest(xevent.xdestroywindow.window);
|
destroyClipboardRequest(xevent.xdestroywindow.window);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen {
|
class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen {
|
||||||
public:
|
public:
|
||||||
CXWindowsSecondaryScreen();
|
CXWindowsSecondaryScreen();
|
||||||
virtual ~CXWindowsSecondaryScreen();
|
virtual ~CXWindowsSecondaryScreen();
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen
|
||||||
virtual SInt32 getJumpZoneSize() const;
|
virtual SInt32 getJumpZoneSize() const;
|
||||||
virtual void getClipboard(ClipboardID, IClipboard*) const;
|
virtual void getClipboard(ClipboardID, IClipboard*) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// CXWindowsScreen overrides
|
// CXWindowsScreen overrides
|
||||||
virtual void onOpenDisplay();
|
virtual void onOpenDisplay();
|
||||||
virtual void onCloseDisplay();
|
virtual void onCloseDisplay();
|
||||||
virtual long getEventMask(Window) const;
|
virtual long getEventMask(Window) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct KeyCodeMask {
|
struct KeyCodeMask {
|
||||||
public:
|
public:
|
||||||
KeyCode keycode;
|
KeyCode keycode;
|
||||||
|
@ -64,7 +64,7 @@ class CXWindowsSecondaryScreen : public CXWindowsScreen, public ISecondaryScreen
|
||||||
void updateModifierMap(Display* display);
|
void updateModifierMap(Display* display);
|
||||||
static bool isToggleKeysym(KeySym);
|
static bool isToggleKeysym(KeySym);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CClient* m_client;
|
CClient* m_client;
|
||||||
Window m_window;
|
Window m_window;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CMutex;
|
||||||
class IJob;
|
class IJob;
|
||||||
|
|
||||||
class CBufferedInputStream : public IInputStream {
|
class CBufferedInputStream : public IInputStream {
|
||||||
public:
|
public:
|
||||||
CBufferedInputStream(CMutex*, IJob* adoptedCloseCB);
|
CBufferedInputStream(CMutex*, IJob* adoptedCloseCB);
|
||||||
~CBufferedInputStream();
|
~CBufferedInputStream();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class CBufferedInputStream : public IInputStream {
|
||||||
virtual UInt32 read(void*, UInt32 count);
|
virtual UInt32 read(void*, UInt32 count);
|
||||||
virtual UInt32 getSize() const;
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
CCondVar<bool> m_empty;
|
CCondVar<bool> m_empty;
|
||||||
IJob* m_closeCB;
|
IJob* m_closeCB;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CMutex;
|
||||||
class IJob;
|
class IJob;
|
||||||
|
|
||||||
class CBufferedOutputStream : public IOutputStream {
|
class CBufferedOutputStream : public IOutputStream {
|
||||||
public:
|
public:
|
||||||
CBufferedOutputStream(CMutex*, IJob* adoptedCloseCB);
|
CBufferedOutputStream(CMutex*, IJob* adoptedCloseCB);
|
||||||
~CBufferedOutputStream();
|
~CBufferedOutputStream();
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ class CBufferedOutputStream : public IOutputStream {
|
||||||
virtual UInt32 write(const void*, UInt32 count);
|
virtual UInt32 write(const void*, UInt32 count);
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeWithLock() const;
|
UInt32 getSizeWithLock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
IJob* m_closeCB;
|
IJob* m_closeCB;
|
||||||
CStreamBuffer m_buffer;
|
CStreamBuffer m_buffer;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "IInputStream.h"
|
#include "IInputStream.h"
|
||||||
|
|
||||||
class CInputStreamFilter : public IInputStream {
|
class CInputStreamFilter : public IInputStream {
|
||||||
public:
|
public:
|
||||||
CInputStreamFilter(IInputStream*, bool adoptStream = true);
|
CInputStreamFilter(IInputStream*, bool adoptStream = true);
|
||||||
~CInputStreamFilter();
|
~CInputStreamFilter();
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ class CInputStreamFilter : public IInputStream {
|
||||||
virtual UInt32 read(void*, UInt32 maxCount) = 0;
|
virtual UInt32 read(void*, UInt32 maxCount) = 0;
|
||||||
virtual UInt32 getSize() const = 0;
|
virtual UInt32 getSize() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IInputStream* getStream() const;
|
IInputStream* getStream() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IInputStream* m_stream;
|
IInputStream* m_stream;
|
||||||
bool m_adopted;
|
bool m_adopted;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "IOutputStream.h"
|
#include "IOutputStream.h"
|
||||||
|
|
||||||
class COutputStreamFilter : public IOutputStream {
|
class COutputStreamFilter : public IOutputStream {
|
||||||
public:
|
public:
|
||||||
COutputStreamFilter(IOutputStream*, bool adoptStream = true);
|
COutputStreamFilter(IOutputStream*, bool adoptStream = true);
|
||||||
~COutputStreamFilter();
|
~COutputStreamFilter();
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ class COutputStreamFilter : public IOutputStream {
|
||||||
virtual UInt32 write(const void*, UInt32 count) = 0;
|
virtual UInt32 write(const void*, UInt32 count) = 0;
|
||||||
virtual void flush() = 0;
|
virtual void flush() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IOutputStream* getStream() const;
|
IOutputStream* getStream() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IOutputStream* m_stream;
|
IOutputStream* m_stream;
|
||||||
bool m_adopted;
|
bool m_adopted;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CStreamBuffer {
|
class CStreamBuffer {
|
||||||
public:
|
public:
|
||||||
CStreamBuffer();
|
CStreamBuffer();
|
||||||
~CStreamBuffer();
|
~CStreamBuffer();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class CStreamBuffer {
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const;
|
UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const UInt32 kChunkSize;
|
static const UInt32 kChunkSize;
|
||||||
|
|
||||||
typedef std::vector<UInt8> Chunk;
|
typedef std::vector<UInt8> Chunk;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "XIO.h"
|
#include "XIO.h"
|
||||||
|
|
||||||
class IInputStream : public IInterface {
|
class IInputStream : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// close the stream
|
// close the stream
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "XIO.h"
|
#include "XIO.h"
|
||||||
|
|
||||||
class IOutputStream : public IInterface {
|
class IOutputStream : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// close the stream
|
// close the stream
|
||||||
|
|
8
io/XIO.h
8
io/XIO.h
|
@ -7,25 +7,25 @@
|
||||||
class XIO : public XBase { };
|
class XIO : public XBase { };
|
||||||
|
|
||||||
class XIOErrno : public XIO, public MXErrno {
|
class XIOErrno : public XIO, public MXErrno {
|
||||||
public:
|
public:
|
||||||
XIOErrno();
|
XIOErrno();
|
||||||
XIOErrno(int);
|
XIOErrno(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
class XIOClose: public XIOErrno {
|
class XIOClose: public XIOErrno {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class XIOClosed : public XIO {
|
class XIOClosed : public XIO {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class XIOEndOfStream : public XIO {
|
class XIOEndOfStream : public XIO {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,14 +148,14 @@ bool CCondVarBase::wait(
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0:
|
case 0:
|
||||||
// success
|
// success
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case ETIMEDOUT:
|
case ETIMEDOUT:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "condition variable wait error");
|
assert(0 && "condition variable wait error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ void CCondVarBase::init()
|
||||||
{
|
{
|
||||||
// prepare events
|
// prepare events
|
||||||
HANDLE* events = new HANDLE[2];
|
HANDLE* events = new HANDLE[2];
|
||||||
events[kSignal] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
events[kSignal] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
events[kBroadcast] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
events[kBroadcast] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
// prepare members
|
// prepare members
|
||||||
m_cond = reinterpret_cast<void*>(events);
|
m_cond = reinterpret_cast<void*>(events);
|
||||||
|
@ -194,8 +194,8 @@ void CCondVarBase::init()
|
||||||
void CCondVarBase::fini()
|
void CCondVarBase::fini()
|
||||||
{
|
{
|
||||||
HANDLE* events = reinterpret_cast<HANDLE*>(m_cond);
|
HANDLE* events = reinterpret_cast<HANDLE*>(m_cond);
|
||||||
CloseHandle(events[kSignal]);
|
CloseHandle(events[kSignal]);
|
||||||
CloseHandle(events[kBroadcast]);
|
CloseHandle(events[kBroadcast]);
|
||||||
delete[] events;
|
delete[] events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ void CCondVarBase::signal()
|
||||||
|
|
||||||
// wake one thread if anybody is waiting
|
// wake one thread if anybody is waiting
|
||||||
if (hasWaiter)
|
if (hasWaiter)
|
||||||
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
|
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kSignal]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCondVarBase::broadcast()
|
void CCondVarBase::broadcast()
|
||||||
|
@ -224,7 +224,7 @@ void CCondVarBase::broadcast()
|
||||||
|
|
||||||
// wake all threads if anybody is waiting
|
// wake all threads if anybody is waiting
|
||||||
if (hasWaiter)
|
if (hasWaiter)
|
||||||
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kBroadcast]);
|
SetEvent(reinterpret_cast<HANDLE*>(m_cond)[kBroadcast]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCondVarBase::wait(
|
bool CCondVarBase::wait(
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
class CStopwatch;
|
class CStopwatch;
|
||||||
|
|
||||||
class CCondVarBase {
|
class CCondVarBase {
|
||||||
public:
|
public:
|
||||||
// mutex must be supplied. all condition variables have an
|
// mutex must be supplied. all condition variables have an
|
||||||
// associated mutex. the copy c'tor uses the same mutex as the
|
// associated mutex. the copy c'tor uses the same mutex as the
|
||||||
// argument and is otherwise like the default c'tor.
|
// argument and is otherwise like the default c'tor.
|
||||||
|
@ -45,7 +45,7 @@ class CCondVarBase {
|
||||||
// get the mutex passed to the c'tor
|
// get the mutex passed to the c'tor
|
||||||
CMutex* getMutex() const;
|
CMutex* getMutex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void fini();
|
void fini();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class CCondVarBase {
|
||||||
CCondVarBase(const CCondVarBase&);
|
CCondVarBase(const CCondVarBase&);
|
||||||
CCondVarBase& operator=(const CCondVarBase&);
|
CCondVarBase& operator=(const CCondVarBase&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
void* m_cond;
|
void* m_cond;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class CCondVarBase {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class CCondVar : public CCondVarBase {
|
class CCondVar : public CCondVarBase {
|
||||||
public:
|
public:
|
||||||
CCondVar(CMutex* mutex, const T&);
|
CCondVar(CMutex* mutex, const T&);
|
||||||
CCondVar(const CCondVar&);
|
CCondVar(const CCondVar&);
|
||||||
~CCondVar();
|
~CCondVar();
|
||||||
|
@ -85,7 +85,7 @@ class CCondVar : public CCondVarBase {
|
||||||
// calling this method.
|
// calling this method.
|
||||||
operator const T&() const;
|
operator const T&() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_data;
|
T m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,17 @@ class CMutex;
|
||||||
class CCondVarBase;
|
class CCondVarBase;
|
||||||
|
|
||||||
class CLock {
|
class CLock {
|
||||||
public:
|
public:
|
||||||
CLock(const CMutex* mutex);
|
CLock(const CMutex* mutex);
|
||||||
CLock(const CCondVarBase* cv);
|
CLock(const CCondVarBase* cv);
|
||||||
~CLock();
|
~CLock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// not implemented
|
// not implemented
|
||||||
CLock(const CLock&);
|
CLock(const CLock&);
|
||||||
CLock& operator=(const CLock&);
|
CLock& operator=(const CLock&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CMutex* m_mutex;
|
const CMutex* m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,19 +60,19 @@ void CMutex::lock() const
|
||||||
int status = pthread_mutex_lock(mutex);
|
int status = pthread_mutex_lock(mutex);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0:
|
case 0:
|
||||||
// success
|
// success
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EDEADLK:
|
case EDEADLK:
|
||||||
assert(0 && "lock already owned");
|
assert(0 && "lock already owned");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
assert(0 && "too many recursive locks");
|
assert(0 && "too many recursive locks");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log((CLOG_ERR "pthread_mutex_lock status %d", status));
|
log((CLOG_ERR "pthread_mutex_lock status %d", status));
|
||||||
assert(0 && "unexpected error");
|
assert(0 && "unexpected error");
|
||||||
}
|
}
|
||||||
|
@ -84,15 +84,15 @@ void CMutex::unlock() const
|
||||||
int status = pthread_mutex_unlock(mutex);
|
int status = pthread_mutex_unlock(mutex);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 0:
|
case 0:
|
||||||
// success
|
// success
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EPERM:
|
case EPERM:
|
||||||
assert(0 && "thread doesn't own a lock");
|
assert(0 && "thread doesn't own a lock");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log((CLOG_ERR "pthread_mutex_unlock status %d", status));
|
log((CLOG_ERR "pthread_mutex_unlock status %d", status));
|
||||||
assert(0 && "unexpected error");
|
assert(0 && "unexpected error");
|
||||||
}
|
}
|
||||||
|
|
12
mt/CMutex.h
12
mt/CMutex.h
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
// recursive mutex class
|
// recursive mutex class
|
||||||
class CMutex {
|
class CMutex {
|
||||||
public:
|
public:
|
||||||
// copy c'tor is equivalent to default c'tor. it's here to
|
// copy c'tor is equivalent to default c'tor. it's here to
|
||||||
// allow copying of objects that have mutexes.
|
// allow copying of objects that have mutexes.
|
||||||
CMutex();
|
CMutex();
|
||||||
|
@ -14,22 +14,22 @@ class CMutex {
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// this has no effect. it's only here to allow assignment of
|
// this has no effect. it's only here to allow assignment of
|
||||||
// objects that have mutexes.
|
// objects that have mutexes.
|
||||||
CMutex& operator=(const CMutex&);
|
CMutex& operator=(const CMutex&);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
void lock() const;
|
void lock() const;
|
||||||
void unlock() const;
|
void unlock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void fini();
|
void fini();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CCondVarBase;
|
friend class CCondVarBase;
|
||||||
void* m_mutex;
|
void* m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
84
mt/CThread.h
84
mt/CThread.h
|
@ -8,44 +8,44 @@ class CThreadRep;
|
||||||
|
|
||||||
// note -- do not derive from this class
|
// note -- do not derive from this class
|
||||||
class CThread {
|
class CThread {
|
||||||
public:
|
public:
|
||||||
// create and start a new thread executing the job.
|
// create and start a new thread executing the job.
|
||||||
// the user data can be retrieved with getUserData().
|
// the user data can be retrieved with getUserData().
|
||||||
CThread(IJob* adopted, void* userData = 0);
|
CThread(IJob* adopted, void* userData = 0);
|
||||||
|
|
||||||
// make a new thread object that refers to an existing thread.
|
// make a new thread object that refers to an existing thread.
|
||||||
// this does *not* start a new thread.
|
// this does *not* start a new thread.
|
||||||
CThread(const CThread&);
|
CThread(const CThread&);
|
||||||
|
|
||||||
// release thread. this does not terminate the thread. a thread
|
// release thread. this does not terminate the thread. a thread
|
||||||
// will keep running until the job completes or calls exit().
|
// will keep running until the job completes or calls exit().
|
||||||
~CThread();
|
~CThread();
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// assign thread. this has no effect on the threads. it simply
|
// assign thread. this has no effect on the threads. it simply
|
||||||
// makes this thread object refer to another thread. it does *not*
|
// makes this thread object refer to another thread. it does *not*
|
||||||
// start a new thread.
|
// start a new thread.
|
||||||
CThread& operator=(const CThread&);
|
CThread& operator=(const CThread&);
|
||||||
|
|
||||||
// initialize the thread library. this must be called before
|
// initialize the thread library. this must be called before
|
||||||
// any other thread methods or creating a thread object. it
|
// any other thread methods or creating a thread object. it
|
||||||
// is harmless to call init() multiple times.
|
// is harmless to call init() multiple times.
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
// the calling thread sleeps for the given number of seconds. if
|
// the calling thread sleeps for the given number of seconds. if
|
||||||
// timeout <= 0.0 then the call returns immediately. if timeout
|
// timeout <= 0.0 then the call returns immediately. if timeout
|
||||||
// == 0.0 then the calling thread yields the CPU.
|
// == 0.0 then the calling thread yields the CPU.
|
||||||
// (cancellation point)
|
// (cancellation point)
|
||||||
static void sleep(double timeout);
|
static void sleep(double timeout);
|
||||||
|
|
||||||
// terminate the calling thread. this function does not return but
|
// terminate the calling thread. this function does not return but
|
||||||
// the stack is unwound and automatic objects are destroyed, as if
|
// the stack is unwound and automatic objects are destroyed, as if
|
||||||
// exit() threw an exception (which is, in fact, what it does). the
|
// exit() threw an exception (which is, in fact, what it does). the
|
||||||
// argument is saved as the result returned by getResult(). if you
|
// argument is saved as the result returned by getResult(). if you
|
||||||
// have a catch(...) block then you should add the following before
|
// have a catch(...) block then you should add the following before
|
||||||
// it to avoid catching the exit: catch(CThreadExit&) { throw; }
|
// it to avoid catching the exit: catch(CThreadExit&) { throw; }
|
||||||
static void exit(void*);
|
static void exit(void*);
|
||||||
|
|
||||||
// enable/disable cancellation. default is enabled. this is not
|
// enable/disable cancellation. default is enabled. this is not
|
||||||
// a cancellation point so if you enabled cancellation and want to
|
// a cancellation point so if you enabled cancellation and want to
|
||||||
|
@ -76,26 +76,26 @@ class CThread {
|
||||||
// exception. clients that catch(...) must either rethrow the
|
// exception. clients that catch(...) must either rethrow the
|
||||||
// exception or include a catch (XThreadCancel) handler that
|
// exception or include a catch (XThreadCancel) handler that
|
||||||
// rethrows.
|
// rethrows.
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
// change the priority of the thread. normal priority is 0, 1 is
|
// change the priority of the thread. normal priority is 0, 1 is
|
||||||
// the next lower, etc. -1 is the next higher, etc. but boosting
|
// the next lower, etc. -1 is the next higher, etc. but boosting
|
||||||
// the priority may not be available.
|
// the priority may not be available.
|
||||||
void setPriority(int n);
|
void setPriority(int n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// return a thread object representing the calling thread
|
// return a thread object representing the calling thread
|
||||||
static CThread getCurrentThread();
|
static CThread getCurrentThread();
|
||||||
|
|
||||||
// get the user data passed to the constructor for the current
|
// get the user data passed to the constructor for the current
|
||||||
// thread.
|
// thread.
|
||||||
static void* getUserData();
|
static void* getUserData();
|
||||||
|
|
||||||
// testCancel() does nothing but is a cancellation point. call
|
// testCancel() does nothing but is a cancellation point. call
|
||||||
// this to make a function itself a cancellation point.
|
// this to make a function itself a cancellation point.
|
||||||
// (cancellation point)
|
// (cancellation point)
|
||||||
static void testCancel();
|
static void testCancel();
|
||||||
|
|
||||||
// waits for the thread to terminate (by exit() or cancel() or
|
// waits for the thread to terminate (by exit() or cancel() or
|
||||||
// by returning from the thread job). returns immediately if
|
// by returning from the thread job). returns immediately if
|
||||||
|
@ -105,30 +105,30 @@ class CThread {
|
||||||
// (cancellation point)
|
// (cancellation point)
|
||||||
bool wait(double timeout = -1.0) const;
|
bool wait(double timeout = -1.0) const;
|
||||||
|
|
||||||
// get the exit result. does an implicit wait(). returns NULL
|
// get the exit result. does an implicit wait(). returns NULL
|
||||||
// immediately if called by a thread on itself. returns NULL for
|
// immediately if called by a thread on itself. returns NULL for
|
||||||
// threads that were cancelled.
|
// threads that were cancelled.
|
||||||
// (cancellation point)
|
// (cancellation point)
|
||||||
void* getResult() const;
|
void* getResult() const;
|
||||||
|
|
||||||
// compare threads for (in)equality
|
// compare threads for (in)equality
|
||||||
bool operator==(const CThread&) const;
|
bool operator==(const CThread&) const;
|
||||||
bool operator!=(const CThread&) const;
|
bool operator!=(const CThread&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CThread(CThreadRep*);
|
CThread(CThreadRep*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CThreadRep* m_rep;
|
CThreadRep* m_rep;
|
||||||
};
|
};
|
||||||
|
|
||||||
// disables cancellation in the c'tor and enables it in the d'tor.
|
// disables cancellation in the c'tor and enables it in the d'tor.
|
||||||
class CThreadMaskCancel {
|
class CThreadMaskCancel {
|
||||||
public:
|
public:
|
||||||
CThreadMaskCancel() : m_old(CThread::enableCancel(false)) { }
|
CThreadMaskCancel() : m_old(CThread::enableCancel(false)) { }
|
||||||
~CThreadMaskCancel() { CThread::enableCancel(m_old); }
|
~CThreadMaskCancel() { CThread::enableCancel(m_old); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_old;
|
bool m_old;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -518,15 +518,15 @@ bool CThreadRep::wait(CThreadRep* target, double timeout)
|
||||||
|
|
||||||
// handle result
|
// handle result
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case WAIT_OBJECT_0 + 0:
|
case WAIT_OBJECT_0 + 0:
|
||||||
// target thread terminated
|
// target thread terminated
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
// this thread was cancelled. does not return.
|
// this thread was cancelled. does not return.
|
||||||
testCancel();
|
testCancel();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// error
|
// error
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -536,16 +536,16 @@ void CThreadRep::setPriority(int n)
|
||||||
{
|
{
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
switch (-n) {
|
switch (-n) {
|
||||||
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
|
case 1: n = THREAD_PRIORITY_ABOVE_NORMAL; break;
|
||||||
default: n = THREAD_PRIORITY_HIGHEST; break;
|
default: n = THREAD_PRIORITY_HIGHEST; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 0: n = THREAD_PRIORITY_NORMAL; break;
|
case 0: n = THREAD_PRIORITY_NORMAL; break;
|
||||||
case 1: n = THREAD_PRIORITY_BELOW_NORMAL; break;
|
case 1: n = THREAD_PRIORITY_BELOW_NORMAL; break;
|
||||||
case 2: n = THREAD_PRIORITY_LOWEST; break;
|
case 2: n = THREAD_PRIORITY_LOWEST; break;
|
||||||
default: n = THREAD_PRIORITY_IDLE; break;
|
default: n = THREAD_PRIORITY_IDLE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetThreadPriority(m_thread, n);
|
SetThreadPriority(m_thread, n);
|
||||||
|
|
|
@ -13,7 +13,7 @@ class CMutex;
|
||||||
class IJob;
|
class IJob;
|
||||||
|
|
||||||
class CThreadRep {
|
class CThreadRep {
|
||||||
public:
|
public:
|
||||||
CThreadRep(IJob*, void* userData);
|
CThreadRep(IJob*, void* userData);
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
@ -25,9 +25,9 @@ class CThreadRep {
|
||||||
void ref();
|
void ref();
|
||||||
void unref();
|
void unref();
|
||||||
|
|
||||||
// the calling thread sleeps for t seconds. if t == 0.0 then
|
// the calling thread sleeps for t seconds. if t == 0.0 then
|
||||||
// the thread yields the CPU.
|
// the thread yields the CPU.
|
||||||
void sleep(double timeout);
|
void sleep(double timeout);
|
||||||
|
|
||||||
// cancel the thread
|
// cancel the thread
|
||||||
void cancel();
|
void cancel();
|
||||||
|
@ -42,16 +42,16 @@ class CThreadRep {
|
||||||
// wait for thread to exit or for current thread to cancel
|
// wait for thread to exit or for current thread to cancel
|
||||||
bool wait(CThreadRep*, double timeout);
|
bool wait(CThreadRep*, double timeout);
|
||||||
|
|
||||||
// set the priority
|
// set the priority
|
||||||
void setPriority(int n);
|
void setPriority(int n);
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
// get the exit result for this thread. thread must be terminated.
|
// get the exit result for this thread. thread must be terminated.
|
||||||
void* getResult() const;
|
void* getResult() const;
|
||||||
|
|
||||||
// get the user data passed to the constructor
|
// get the user data passed to the constructor
|
||||||
void* getUserData() const;
|
void* getUserData() const;
|
||||||
|
|
||||||
// get the current cancellable state
|
// get the current cancellable state
|
||||||
bool isCancellable() const;
|
bool isCancellable() const;
|
||||||
|
@ -63,14 +63,14 @@ class CThreadRep {
|
||||||
HANDLE getCancelEvent() const;
|
HANDLE getCancelEvent() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// return the thread rep for the calling thread. the returned
|
// return the thread rep for the calling thread. the returned
|
||||||
// rep has been ref()'d.
|
// rep has been ref()'d.
|
||||||
static CThreadRep* getCurrentThreadRep();
|
static CThreadRep* getCurrentThreadRep();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~CThreadRep();
|
virtual ~CThreadRep();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal constructor
|
// internal constructor
|
||||||
CThreadRep();
|
CThreadRep();
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class CThreadRep {
|
||||||
CThreadRep(const CThreadRep&);
|
CThreadRep(const CThreadRep&);
|
||||||
CThreadRep& operator=(const CThreadRep&);
|
CThreadRep& operator=(const CThreadRep&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CMutex* s_mutex;
|
static CMutex* s_mutex;
|
||||||
static CThreadRep* s_head;
|
static CThreadRep* s_head;
|
||||||
|
|
||||||
|
@ -127,18 +127,18 @@ class CThreadRep {
|
||||||
//
|
//
|
||||||
|
|
||||||
class CThreadPtr {
|
class CThreadPtr {
|
||||||
public:
|
public:
|
||||||
CThreadPtr(CThreadRep* rep) : m_rep(rep) { }
|
CThreadPtr(CThreadRep* rep) : m_rep(rep) { }
|
||||||
~CThreadPtr() { m_rep->unref(); }
|
~CThreadPtr() { m_rep->unref(); }
|
||||||
|
|
||||||
CThreadRep* operator->() const { return m_rep; }
|
CThreadRep* operator->() const { return m_rep; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// not implemented
|
// not implemented
|
||||||
CThreadPtr(const CThreadPtr&);
|
CThreadPtr(const CThreadPtr&);
|
||||||
CThreadPtr& operator=(const CThreadPtr&);
|
CThreadPtr& operator=(const CThreadPtr&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CThreadRep* m_rep;
|
CThreadRep* m_rep;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
class CThread;
|
class CThread;
|
||||||
|
|
||||||
class CTimerThread {
|
class CTimerThread {
|
||||||
public:
|
public:
|
||||||
CTimerThread(double timeout);
|
CTimerThread(double timeout);
|
||||||
~CTimerThread();
|
~CTimerThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void timer(void*);
|
void timer(void*);
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
CTimerThread(const CTimerThread&);
|
CTimerThread(const CTimerThread&);
|
||||||
CTimerThread& operator=(const CTimerThread&);
|
CTimerThread& operator=(const CTimerThread&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_timeout;
|
double m_timeout;
|
||||||
CThread* m_callingThread;
|
CThread* m_callingThread;
|
||||||
CThread* m_timingThread;
|
CThread* m_timingThread;
|
||||||
|
|
10
mt/XThread.h
10
mt/XThread.h
|
@ -10,12 +10,12 @@ class XThread { };
|
||||||
// must not throw this type but must rethrow it if caught (by
|
// must not throw this type but must rethrow it if caught (by
|
||||||
// XThreadExit, XThread, or ...).
|
// XThreadExit, XThread, or ...).
|
||||||
class XThreadExit : public XThread {
|
class XThreadExit : public XThread {
|
||||||
public:
|
public:
|
||||||
XThreadExit(void* result) : m_result(result) { }
|
XThreadExit(void* result) : m_result(result) { }
|
||||||
~XThreadExit() { }
|
~XThreadExit() { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void* m_result;
|
void* m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// thrown to cancel a thread. clients must not throw this type, but
|
// thrown to cancel a thread. clients must not throw this type, but
|
||||||
|
|
|
@ -26,7 +26,7 @@ typedef int ssize_t;
|
||||||
// FIXME -- must handle htonl and ilk when defined as macros
|
// FIXME -- must handle htonl and ilk when defined as macros
|
||||||
|
|
||||||
class CNetwork {
|
class CNetwork {
|
||||||
public:
|
public:
|
||||||
#if defined(CONFIG_PLATFORM_WIN32)
|
#if defined(CONFIG_PLATFORM_WIN32)
|
||||||
typedef SOCKET Socket;
|
typedef SOCKET Socket;
|
||||||
typedef struct sockaddr Address;
|
typedef struct sockaddr Address;
|
||||||
|
@ -129,7 +129,7 @@ class CNetwork {
|
||||||
static int (PASCAL FAR *gethosterror)(void);
|
static int (PASCAL FAR *gethosterror)(void);
|
||||||
|
|
||||||
#if defined(CONFIG_PLATFORM_WIN32)
|
#if defined(CONFIG_PLATFORM_WIN32)
|
||||||
private:
|
private:
|
||||||
static void init2(HMODULE);
|
static void init2(HMODULE);
|
||||||
static int PASCAL FAR poll2(PollEntry[], int nfds, int timeout);
|
static int PASCAL FAR poll2(PollEntry[], int nfds, int timeout);
|
||||||
static ssize_t PASCAL FAR read2(Socket s, void FAR * buf, size_t len);
|
static ssize_t PASCAL FAR read2(Socket s, void FAR * buf, size_t len);
|
||||||
|
|
|
@ -24,15 +24,15 @@ CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
|
||||||
struct hostent* hent = CNetwork::gethostbyname(hostname.c_str());
|
struct hostent* hent = CNetwork::gethostbyname(hostname.c_str());
|
||||||
if (hent == NULL) {
|
if (hent == NULL) {
|
||||||
switch (CNetwork::gethosterror()) {
|
switch (CNetwork::gethosterror()) {
|
||||||
case CNetwork::kHOST_NOT_FOUND:
|
case CNetwork::kHOST_NOT_FOUND:
|
||||||
throw XSocketAddress(XSocketAddress::kNotFound, hostname, port);
|
throw XSocketAddress(XSocketAddress::kNotFound, hostname, port);
|
||||||
|
|
||||||
case CNetwork::kNO_DATA:
|
case CNetwork::kNO_DATA:
|
||||||
throw XSocketAddress(XSocketAddress::kNoAddress, hostname, port);
|
throw XSocketAddress(XSocketAddress::kNoAddress, hostname, port);
|
||||||
|
|
||||||
case CNetwork::kNO_RECOVERY:
|
case CNetwork::kNO_RECOVERY:
|
||||||
case CNetwork::kTRY_AGAIN:
|
case CNetwork::kTRY_AGAIN:
|
||||||
default:
|
default:
|
||||||
throw XSocketAddress(XSocketAddress::kUnknown, hostname, port);
|
throw XSocketAddress(XSocketAddress::kUnknown, hostname, port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class CString;
|
class CString;
|
||||||
|
|
||||||
class CNetworkAddress {
|
class CNetworkAddress {
|
||||||
public:
|
public:
|
||||||
CNetworkAddress(UInt16 port);
|
CNetworkAddress(UInt16 port);
|
||||||
CNetworkAddress(const CString& hostname, UInt16 port);
|
CNetworkAddress(const CString& hostname, UInt16 port);
|
||||||
~CNetworkAddress();
|
~CNetworkAddress();
|
||||||
|
@ -20,7 +20,7 @@ class CNetworkAddress {
|
||||||
const CNetwork::Address* getAddress() const;
|
const CNetwork::Address* getAddress() const;
|
||||||
CNetwork::AddressLength getAddressLength() const;
|
CNetwork::AddressLength getAddressLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CNetwork::Address m_address;
|
CNetwork::Address m_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CMutex;
|
||||||
class IJob;
|
class IJob;
|
||||||
|
|
||||||
class CSocketInputStream : public IInputStream {
|
class CSocketInputStream : public IInputStream {
|
||||||
public:
|
public:
|
||||||
CSocketInputStream(CMutex*, IJob* adoptedCloseCB);
|
CSocketInputStream(CMutex*, IJob* adoptedCloseCB);
|
||||||
~CSocketInputStream();
|
~CSocketInputStream();
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class CSocketInputStream : public IInputStream {
|
||||||
virtual UInt32 read(void*, UInt32 count);
|
virtual UInt32 read(void*, UInt32 count);
|
||||||
virtual UInt32 getSize() const;
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
CCondVar<bool> m_empty;
|
CCondVar<bool> m_empty;
|
||||||
IJob* m_closeCB;
|
IJob* m_closeCB;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CMutex;
|
||||||
class IJob;
|
class IJob;
|
||||||
|
|
||||||
class CSocketOutputStream : public IOutputStream {
|
class CSocketOutputStream : public IOutputStream {
|
||||||
public:
|
public:
|
||||||
CSocketOutputStream(CMutex*, IJob* adoptedCloseCB);
|
CSocketOutputStream(CMutex*, IJob* adoptedCloseCB);
|
||||||
~CSocketOutputStream();
|
~CSocketOutputStream();
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ class CSocketOutputStream : public IOutputStream {
|
||||||
virtual UInt32 write(const void*, UInt32 count);
|
virtual UInt32 write(const void*, UInt32 count);
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeWithLock() const;
|
UInt32 getSizeWithLock() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
IJob* m_closeCB;
|
IJob* m_closeCB;
|
||||||
CSocketStreamBuffer m_buffer;
|
CSocketStreamBuffer m_buffer;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CSocketStreamBuffer {
|
class CSocketStreamBuffer {
|
||||||
public:
|
public:
|
||||||
CSocketStreamBuffer();
|
CSocketStreamBuffer();
|
||||||
~CSocketStreamBuffer();
|
~CSocketStreamBuffer();
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class CSocketStreamBuffer {
|
||||||
// return the number of bytes in the buffer
|
// return the number of bytes in the buffer
|
||||||
UInt32 getSize() const;
|
UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const UInt32 kChunkSize;
|
static const UInt32 kChunkSize;
|
||||||
|
|
||||||
typedef std::vector<UInt8> Chunk;
|
typedef std::vector<UInt8> Chunk;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CNetwork.h"
|
#include "CNetwork.h"
|
||||||
|
|
||||||
class CTCPListenSocket : public IListenSocket {
|
class CTCPListenSocket : public IListenSocket {
|
||||||
public:
|
public:
|
||||||
CTCPListenSocket();
|
CTCPListenSocket();
|
||||||
~CTCPListenSocket();
|
~CTCPListenSocket();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class CTCPListenSocket : public IListenSocket {
|
||||||
virtual ISocket* accept();
|
virtual ISocket* accept();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CNetwork::Socket m_fd;
|
CNetwork::Socket m_fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class CBufferedInputStream;
|
||||||
class CBufferedOutputStream;
|
class CBufferedOutputStream;
|
||||||
|
|
||||||
class CTCPSocket : public ISocket {
|
class CTCPSocket : public ISocket {
|
||||||
public:
|
public:
|
||||||
CTCPSocket();
|
CTCPSocket();
|
||||||
CTCPSocket(CNetwork::Socket);
|
CTCPSocket(CNetwork::Socket);
|
||||||
~CTCPSocket();
|
~CTCPSocket();
|
||||||
|
@ -29,14 +29,14 @@ class CTCPSocket : public ISocket {
|
||||||
virtual IInputStream* getInputStream();
|
virtual IInputStream* getInputStream();
|
||||||
virtual IOutputStream* getOutputStream();
|
virtual IOutputStream* getOutputStream();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void ioThread(void*);
|
void ioThread(void*);
|
||||||
void ioService();
|
void ioService();
|
||||||
void closeInput(void*);
|
void closeInput(void*);
|
||||||
void closeOutput(void*);
|
void closeOutput(void*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
|
enum { kClosed = 0, kRead = 1, kWrite = 2, kReadWrite = 3 };
|
||||||
|
|
||||||
CNetwork::Socket m_fd;
|
CNetwork::Socket m_fd;
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CNetworkAddress;
|
||||||
class ISocket;
|
class ISocket;
|
||||||
|
|
||||||
class IListenSocket : public IInterface {
|
class IListenSocket : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// bind the socket to a particular address
|
// bind the socket to a particular address
|
||||||
|
|
|
@ -11,7 +11,7 @@ class IInputStream;
|
||||||
class IOutputStream;
|
class IOutputStream;
|
||||||
|
|
||||||
class ISocket : public IInterface {
|
class ISocket : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// bind the socket to a particular address
|
// bind the socket to a particular address
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
class XNetwork : public XBase { };
|
class XNetwork : public XBase { };
|
||||||
|
|
||||||
class XNetworkUnavailable : public XNetwork {
|
class XNetworkUnavailable : public XNetwork {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class XNetworkFailed : public XNetwork {
|
class XNetworkFailed : public XNetwork {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class XNetworkVersion : public XNetwork {
|
class XNetworkVersion : public XNetwork {
|
||||||
public:
|
public:
|
||||||
XNetworkVersion(int major, int minor) throw();
|
XNetworkVersion(int major, int minor) throw();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
@ -28,24 +28,24 @@ class XNetworkVersion : public XNetwork {
|
||||||
int getMajor() const throw();
|
int getMajor() const throw();
|
||||||
int getMinor() const throw();
|
int getMinor() const throw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_major;
|
int m_major;
|
||||||
int m_minor;
|
int m_minor;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XNetworkFunctionUnavailable : public XNetwork {
|
class XNetworkFunctionUnavailable : public XNetwork {
|
||||||
public:
|
public:
|
||||||
XNetworkFunctionUnavailable(const char* name) throw();
|
XNetworkFunctionUnavailable(const char* name) throw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CString m_name;
|
CString m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class XSocket : public XBase { };
|
class XSocket : public XBase { };
|
||||||
|
|
||||||
class XSocketAddress : public XSocket {
|
class XSocketAddress : public XSocket {
|
||||||
public:
|
public:
|
||||||
enum Error { kUnknown, kNotFound, kNoAddress, kBadPort };
|
enum Error { kUnknown, kNotFound, kNoAddress, kBadPort };
|
||||||
|
|
||||||
XSocketAddress(Error, const CString& hostname, SInt16 port) throw();
|
XSocketAddress(Error, const CString& hostname, SInt16 port) throw();
|
||||||
|
@ -19,24 +19,24 @@ class XSocketAddress : public XSocket {
|
||||||
virtual CString getHostname() const throw();
|
virtual CString getHostname() const throw();
|
||||||
virtual SInt16 getPort() const throw();
|
virtual SInt16 getPort() const throw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Error m_error;
|
Error m_error;
|
||||||
CString m_hostname;
|
CString m_hostname;
|
||||||
SInt16 m_port;
|
SInt16 m_port;
|
||||||
};
|
};
|
||||||
|
|
||||||
class XSocketErrno : public XSocket, public MXErrno {
|
class XSocketErrno : public XSocket, public MXErrno {
|
||||||
public:
|
public:
|
||||||
XSocketErrno();
|
XSocketErrno();
|
||||||
XSocketErrno(int);
|
XSocketErrno(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
class XSocketBind : public XSocketErrno {
|
class XSocketBind : public XSocketErrno {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
@ -44,13 +44,13 @@ class XSocketBind : public XSocketErrno {
|
||||||
class XSocketAddressInUse : public XSocketBind { };
|
class XSocketAddressInUse : public XSocketBind { };
|
||||||
|
|
||||||
class XSocketConnect : public XSocketErrno {
|
class XSocketConnect : public XSocketErrno {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
class XSocketCreate : public XSocketErrno {
|
class XSocketCreate : public XSocketErrno {
|
||||||
protected:
|
protected:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,14 +38,14 @@ static DWORD s_thread = 0;
|
||||||
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_APP:
|
case WM_APP:
|
||||||
if (!s_logMore.empty()) {
|
if (!s_logMore.empty()) {
|
||||||
if (s_log.size() > 20000)
|
if (s_log.size() > 20000)
|
||||||
s_log = s_logMore;
|
s_log = s_logMore;
|
||||||
|
@ -340,11 +340,11 @@ if (IsDialogMessage(s_debug, msg)) {
|
||||||
|
|
||||||
// handle event
|
// handle event
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
case SYNERGY_MSG_MARK:
|
case SYNERGY_MSG_MARK:
|
||||||
m_markReceived = msg->wParam;
|
m_markReceived = msg->wParam;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SYNERGY_MSG_KEY:
|
case SYNERGY_MSG_KEY:
|
||||||
// ignore if not at current mark
|
// ignore if not at current mark
|
||||||
if (m_mark == m_markReceived) {
|
if (m_mark == m_markReceived) {
|
||||||
KeyModifierMask mask;
|
KeyModifierMask mask;
|
||||||
|
@ -373,23 +373,23 @@ log((CLOG_DEBUG "event: key event vk=%d info=0x%08x", msg->wParam, msg->lParam))
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SYNERGY_MSG_MOUSE_BUTTON:
|
case SYNERGY_MSG_MOUSE_BUTTON:
|
||||||
// ignore if not at current mark
|
// ignore if not at current mark
|
||||||
if (m_mark == m_markReceived) {
|
if (m_mark == m_markReceived) {
|
||||||
const ButtonID button = mapButton(msg->wParam);
|
const ButtonID button = mapButton(msg->wParam);
|
||||||
switch (msg->wParam) {
|
switch (msg->wParam) {
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
log((CLOG_DEBUG "event: button press button=%d", button));
|
log((CLOG_DEBUG "event: button press button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_server->onMouseDown(button);
|
m_server->onMouseDown(button);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
log((CLOG_DEBUG "event: button release button=%d", button));
|
log((CLOG_DEBUG "event: button release button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_server->onMouseUp(button);
|
m_server->onMouseUp(button);
|
||||||
|
@ -399,7 +399,7 @@ log((CLOG_DEBUG "event: key event vk=%d info=0x%08x", msg->wParam, msg->lParam))
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SYNERGY_MSG_MOUSE_MOVE:
|
case SYNERGY_MSG_MOUSE_MOVE:
|
||||||
// ignore if not at current mark
|
// ignore if not at current mark
|
||||||
if (m_mark == m_markReceived) {
|
if (m_mark == m_markReceived) {
|
||||||
SInt32 x = (SInt32)msg->wParam;
|
SInt32 x = (SInt32)msg->wParam;
|
||||||
|
@ -445,12 +445,12 @@ LRESULT CMSWindowsPrimaryScreen::onEvent(
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
// FIXME -- handle display changes
|
// FIXME -- handle display changes
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
ValidateRect(hwnd, NULL);
|
ValidateRect(hwnd, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_DRAWCLIPBOARD:
|
case WM_DRAWCLIPBOARD:
|
||||||
log((CLOG_DEBUG "clipboard was taken"));
|
log((CLOG_DEBUG "clipboard was taken"));
|
||||||
|
|
||||||
// first pass it on
|
// first pass it on
|
||||||
|
@ -470,7 +470,7 @@ LRESULT CMSWindowsPrimaryScreen::onEvent(
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_CHANGECBCHAIN:
|
case WM_CHANGECBCHAIN:
|
||||||
if (m_nextClipboardWindow == (HWND)wParam)
|
if (m_nextClipboardWindow == (HWND)wParam)
|
||||||
m_nextClipboardWindow = (HWND)lParam;
|
m_nextClipboardWindow = (HWND)lParam;
|
||||||
else
|
else
|
||||||
|
@ -818,19 +818,19 @@ ButtonID CMSWindowsPrimaryScreen::mapButton(
|
||||||
WPARAM button) const
|
WPARAM button) const
|
||||||
{
|
{
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
return kButtonLeft;
|
return kButtonLeft;
|
||||||
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
return kButtonMiddle;
|
return kButtonMiddle;
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
return kButtonRight;
|
return kButtonRight;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return kButtonNone;
|
return kButtonNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "IPrimaryScreen.h"
|
#include "IPrimaryScreen.h"
|
||||||
|
|
||||||
class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
|
class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
|
||||||
public:
|
public:
|
||||||
typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM);
|
typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM);
|
||||||
|
|
||||||
CMSWindowsPrimaryScreen();
|
CMSWindowsPrimaryScreen();
|
||||||
|
@ -27,14 +27,14 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
|
||||||
virtual SInt32 getJumpZoneSize() const;
|
virtual SInt32 getJumpZoneSize() const;
|
||||||
virtual void getClipboard(IClipboard*) const;
|
virtual void getClipboard(IClipboard*) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// CMSWindowsScreen overrides
|
// CMSWindowsScreen overrides
|
||||||
virtual bool onPreTranslate(MSG*);
|
virtual bool onPreTranslate(MSG*);
|
||||||
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
|
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
|
||||||
virtual void onOpenDisplay();
|
virtual void onOpenDisplay();
|
||||||
virtual void onCloseDisplay();
|
virtual void onCloseDisplay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doEnter();
|
void doEnter();
|
||||||
|
|
||||||
void nextMark();
|
void nextMark();
|
||||||
|
@ -43,7 +43,7 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
|
||||||
KeyModifierMask* maskOut) const;
|
KeyModifierMask* maskOut) const;
|
||||||
ButtonID mapButton(WPARAM button) const;
|
ButtonID mapButton(WPARAM button) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class CScreenMap {
|
class CScreenMap {
|
||||||
public:
|
public:
|
||||||
enum EDirection { kLeft, kRight, kTop, kBottom,
|
enum EDirection { kLeft, kRight, kTop, kBottom,
|
||||||
kFirstDirection = kLeft, kLastDirection = kBottom };
|
kFirstDirection = kLeft, kLastDirection = kBottom };
|
||||||
enum EDirectionMask { kLeftMask = 1, kRightMask = 2,
|
enum EDirectionMask { kLeftMask = 1, kRightMask = 2,
|
||||||
|
@ -38,9 +38,9 @@ class CScreenMap {
|
||||||
// get the name of a direction (for debugging)
|
// get the name of a direction (for debugging)
|
||||||
static const char* dirName(EDirection);
|
static const char* dirName(EDirection);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CCell {
|
class CCell {
|
||||||
public:
|
public:
|
||||||
CString m_neighbor[kLastDirection - kFirstDirection + 1];
|
CString m_neighbor[kLastDirection - kFirstDirection + 1];
|
||||||
};
|
};
|
||||||
typedef std::map<CString, CCell> CCellMap;
|
typedef std::map<CString, CCell> CCellMap;
|
||||||
|
|
|
@ -606,7 +606,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||||
|
|
||||||
// find destination screen, adjusting x or y (but not both)
|
// find destination screen, adjusting x or y (but not both)
|
||||||
switch (srcSide) {
|
switch (srcSide) {
|
||||||
case CScreenMap::kLeft:
|
case CScreenMap::kLeft:
|
||||||
while (dst != NULL) {
|
while (dst != NULL) {
|
||||||
lastGoodScreen = dst;
|
lastGoodScreen = dst;
|
||||||
w = lastGoodScreen->m_width;
|
w = lastGoodScreen->m_width;
|
||||||
|
@ -620,7 +620,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kRight:
|
case CScreenMap::kRight:
|
||||||
while (dst != NULL) {
|
while (dst != NULL) {
|
||||||
lastGoodScreen = dst;
|
lastGoodScreen = dst;
|
||||||
x -= w;
|
x -= w;
|
||||||
|
@ -634,7 +634,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kTop:
|
case CScreenMap::kTop:
|
||||||
while (dst != NULL) {
|
while (dst != NULL) {
|
||||||
lastGoodScreen = dst;
|
lastGoodScreen = dst;
|
||||||
w = lastGoodScreen->m_width;
|
w = lastGoodScreen->m_width;
|
||||||
|
@ -648,7 +648,7 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kBottom:
|
case CScreenMap::kBottom:
|
||||||
while (dst != NULL) {
|
while (dst != NULL) {
|
||||||
lastGoodScreen = dst;
|
lastGoodScreen = dst;
|
||||||
y -= h;
|
y -= h;
|
||||||
|
@ -675,25 +675,25 @@ CServer::CScreenInfo* CServer::getNeighbor(CScreenInfo* src,
|
||||||
if (lastGoodScreen->m_protocol == NULL) {
|
if (lastGoodScreen->m_protocol == NULL) {
|
||||||
const CString dstName(lastGoodScreen->m_name);
|
const CString dstName(lastGoodScreen->m_name);
|
||||||
switch (srcSide) {
|
switch (srcSide) {
|
||||||
case CScreenMap::kLeft:
|
case CScreenMap::kLeft:
|
||||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kRight).empty() &&
|
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kRight).empty() &&
|
||||||
x > w - 1 - lastGoodScreen->m_zoneSize)
|
x > w - 1 - lastGoodScreen->m_zoneSize)
|
||||||
x = w - 1 - lastGoodScreen->m_zoneSize;
|
x = w - 1 - lastGoodScreen->m_zoneSize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kRight:
|
case CScreenMap::kRight:
|
||||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kLeft).empty() &&
|
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kLeft).empty() &&
|
||||||
x < lastGoodScreen->m_zoneSize)
|
x < lastGoodScreen->m_zoneSize)
|
||||||
x = lastGoodScreen->m_zoneSize;
|
x = lastGoodScreen->m_zoneSize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kTop:
|
case CScreenMap::kTop:
|
||||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kBottom).empty() &&
|
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kBottom).empty() &&
|
||||||
y > h - 1 - lastGoodScreen->m_zoneSize)
|
y > h - 1 - lastGoodScreen->m_zoneSize)
|
||||||
y = h - 1 - lastGoodScreen->m_zoneSize;
|
y = h - 1 - lastGoodScreen->m_zoneSize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kBottom:
|
case CScreenMap::kBottom:
|
||||||
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kTop).empty() &&
|
if (!m_screenMap.getNeighbor(dstName, CScreenMap::kTop).empty() &&
|
||||||
y < lastGoodScreen->m_zoneSize)
|
y < lastGoodScreen->m_zoneSize)
|
||||||
y = lastGoodScreen->m_zoneSize;
|
y = lastGoodScreen->m_zoneSize;
|
||||||
|
@ -715,8 +715,8 @@ void CServer::mapPosition(CScreenInfo* src,
|
||||||
srcSide <= CScreenMap::kLastDirection);
|
srcSide <= CScreenMap::kLastDirection);
|
||||||
|
|
||||||
switch (srcSide) {
|
switch (srcSide) {
|
||||||
case CScreenMap::kLeft:
|
case CScreenMap::kLeft:
|
||||||
case CScreenMap::kRight:
|
case CScreenMap::kRight:
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
else if (y >= src->m_height)
|
else if (y >= src->m_height)
|
||||||
|
@ -727,8 +727,8 @@ void CServer::mapPosition(CScreenInfo* src,
|
||||||
(src->m_height - 1));
|
(src->m_height - 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CScreenMap::kTop:
|
case CScreenMap::kTop:
|
||||||
case CScreenMap::kBottom:
|
case CScreenMap::kBottom:
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
else if (x >= src->m_width)
|
else if (x >= src->m_width)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ISecurityFactory;
|
||||||
class IPrimaryScreen;
|
class IPrimaryScreen;
|
||||||
|
|
||||||
class CServer {
|
class CServer {
|
||||||
public:
|
public:
|
||||||
CServer();
|
CServer();
|
||||||
~CServer();
|
~CServer();
|
||||||
|
|
||||||
|
@ -64,36 +64,36 @@ class CServer {
|
||||||
// get the sides of the primary screen that have neighbors
|
// get the sides of the primary screen that have neighbors
|
||||||
UInt32 getActivePrimarySides() const;
|
UInt32 getActivePrimarySides() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onCommandKey(KeyID, KeyModifierMask, bool down);
|
bool onCommandKey(KeyID, KeyModifierMask, bool down);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CCleanupNote {
|
class CCleanupNote {
|
||||||
public:
|
public:
|
||||||
CCleanupNote(CServer*);
|
CCleanupNote(CServer*);
|
||||||
~CCleanupNote();
|
~CCleanupNote();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CConnectionNote {
|
class CConnectionNote {
|
||||||
public:
|
public:
|
||||||
CConnectionNote(CServer*, const CString&, IServerProtocol*);
|
CConnectionNote(CServer*, const CString&, IServerProtocol*);
|
||||||
~CConnectionNote();
|
~CConnectionNote();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_pending;
|
bool m_pending;
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
CString m_name;
|
CString m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CScreenInfo {
|
class CScreenInfo {
|
||||||
public:
|
public:
|
||||||
CScreenInfo(const CString& name, IServerProtocol*);
|
CScreenInfo(const CString& name, IServerProtocol*);
|
||||||
~CScreenInfo();
|
~CScreenInfo();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CString m_name;
|
CString m_name;
|
||||||
IServerProtocol* m_protocol;
|
IServerProtocol* m_protocol;
|
||||||
SInt32 m_width, m_height;
|
SInt32 m_width, m_height;
|
||||||
|
@ -155,7 +155,7 @@ class CServer {
|
||||||
CScreenInfo* addConnection(const CString& name, IServerProtocol*);
|
CScreenInfo* addConnection(const CString& name, IServerProtocol*);
|
||||||
void removeConnection(const CString& name);
|
void removeConnection(const CString& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<CThread*> CThreadList;
|
typedef std::list<CThread*> CThreadList;
|
||||||
typedef std::map<CString, CScreenInfo*> CScreenList;
|
typedef std::map<CString, CScreenInfo*> CScreenList;
|
||||||
class CClipboardInfo {
|
class CClipboardInfo {
|
||||||
|
|
|
@ -9,7 +9,7 @@ class IInputStream;
|
||||||
class IOutputStream;
|
class IOutputStream;
|
||||||
|
|
||||||
class CServerProtocol : public IServerProtocol {
|
class CServerProtocol : public IServerProtocol {
|
||||||
public:
|
public:
|
||||||
CServerProtocol(CServer*, const CString& clientName,
|
CServerProtocol(CServer*, const CString& clientName,
|
||||||
IInputStream*, IOutputStream*);
|
IInputStream*, IOutputStream*);
|
||||||
~CServerProtocol();
|
~CServerProtocol();
|
||||||
|
@ -44,13 +44,13 @@ class CServerProtocol : public IServerProtocol {
|
||||||
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||||
virtual void sendMouseWheel(SInt32 delta) = 0;
|
virtual void sendMouseWheel(SInt32 delta) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//IServerProtocol overrides
|
//IServerProtocol overrides
|
||||||
virtual void recvInfo() = 0;
|
virtual void recvInfo() = 0;
|
||||||
virtual void recvClipboard() = 0;
|
virtual void recvClipboard() = 0;
|
||||||
virtual void recvGrabClipboard() = 0;
|
virtual void recvGrabClipboard() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
CString m_client;
|
CString m_client;
|
||||||
IInputStream* m_input;
|
IInputStream* m_input;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "CServerProtocol.h"
|
#include "CServerProtocol.h"
|
||||||
|
|
||||||
class CServerProtocol1_0 : public CServerProtocol {
|
class CServerProtocol1_0 : public CServerProtocol {
|
||||||
public:
|
public:
|
||||||
CServerProtocol1_0(CServer*, const CString&, IInputStream*, IOutputStream*);
|
CServerProtocol1_0(CServer*, const CString&, IInputStream*, IOutputStream*);
|
||||||
~CServerProtocol1_0();
|
~CServerProtocol1_0();
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class CServerProtocol1_0 : public CServerProtocol {
|
||||||
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs);
|
virtual void sendMouseMove(SInt32 xAbs, SInt32 yAbs);
|
||||||
virtual void sendMouseWheel(SInt32 delta);
|
virtual void sendMouseWheel(SInt32 delta);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// IServerProtocol overrides
|
// IServerProtocol overrides
|
||||||
virtual void recvInfo();
|
virtual void recvInfo();
|
||||||
virtual void recvClipboard();
|
virtual void recvClipboard();
|
||||||
|
|
|
@ -70,16 +70,16 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (g_relay) {
|
if (g_relay) {
|
||||||
switch (wParam) {
|
switch (wParam) {
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_BUTTON, wParam, 0);
|
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_BUTTON, wParam, 0);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case WM_MOUSEMOVE: {
|
case WM_MOUSEMOVE: {
|
||||||
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
|
const MOUSEHOOKSTRUCT* info = (const MOUSEHOOKSTRUCT*)lParam;
|
||||||
SInt32 x = (SInt32)info->pt.x;
|
SInt32 x = (SInt32)info->pt.x;
|
||||||
SInt32 y = (SInt32)info->pt.y;
|
SInt32 y = (SInt32)info->pt.y;
|
||||||
|
@ -100,7 +100,7 @@ static LRESULT CALLBACK mouseHook(int code, WPARAM wParam, LPARAM lParam)
|
||||||
// relay the motion
|
// relay the motion
|
||||||
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_MOVE, x, y);
|
PostMessage(g_hwnd, SYNERGY_MSG_MOUSE_MOVE, x, y);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -36,21 +36,21 @@ void CXWindowsPrimaryScreen::run()
|
||||||
|
|
||||||
// handle event
|
// handle event
|
||||||
switch (xevent.type) {
|
switch (xevent.type) {
|
||||||
case CreateNotify: {
|
case CreateNotify: {
|
||||||
// select events on new window
|
// select events on new window
|
||||||
CDisplayLock display(this);
|
CDisplayLock display(this);
|
||||||
selectEvents(display, xevent.xcreatewindow.window);
|
selectEvents(display, xevent.xcreatewindow.window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MappingNotify: {
|
case MappingNotify: {
|
||||||
// keyboard mapping changed
|
// keyboard mapping changed
|
||||||
CDisplayLock display(this);
|
CDisplayLock display(this);
|
||||||
XRefreshKeyboardMapping(&xevent.xmapping);
|
XRefreshKeyboardMapping(&xevent.xmapping);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case KeyPress: {
|
case KeyPress: {
|
||||||
log((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
log((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||||
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
||||||
const KeyID key = mapKey(&xevent.xkey);
|
const KeyID key = mapKey(&xevent.xkey);
|
||||||
|
@ -60,11 +60,11 @@ void CXWindowsPrimaryScreen::run()
|
||||||
m_server->onKeyUp(key, mask | KeyModifierCapsLock);
|
m_server->onKeyUp(key, mask | KeyModifierCapsLock);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME -- simulate key repeat. X sends press/release for
|
// FIXME -- simulate key repeat. X sends press/release for
|
||||||
// repeat. must detect auto repeat and use kKeyRepeat.
|
// repeat. must detect auto repeat and use kKeyRepeat.
|
||||||
case KeyRelease: {
|
case KeyRelease: {
|
||||||
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||||
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
||||||
const KeyID key = mapKey(&xevent.xkey);
|
const KeyID key = mapKey(&xevent.xkey);
|
||||||
|
@ -74,27 +74,27 @@ void CXWindowsPrimaryScreen::run()
|
||||||
m_server->onKeyUp(key, mask);
|
m_server->onKeyUp(key, mask);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ButtonPress: {
|
case ButtonPress: {
|
||||||
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
||||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_server->onMouseDown(button);
|
m_server->onMouseDown(button);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ButtonRelease: {
|
case ButtonRelease: {
|
||||||
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
||||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
m_server->onMouseUp(button);
|
m_server->onMouseUp(button);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MotionNotify: {
|
case MotionNotify: {
|
||||||
log((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
|
log((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
|
||||||
SInt32 x, y;
|
SInt32 x, y;
|
||||||
if (!m_active) {
|
if (!m_active) {
|
||||||
|
@ -129,9 +129,9 @@ void CXWindowsPrimaryScreen::run()
|
||||||
m_server->onMouseMoveSecondary(x, y);
|
m_server->onMouseMoveSecondary(x, y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
// we just lost the selection. that means someone else
|
// we just lost the selection. that means someone else
|
||||||
// grabbed the selection so this screen is now the
|
// grabbed the selection so this screen is now the
|
||||||
// selection owner. report that to the server.
|
// selection owner. report that to the server.
|
||||||
|
@ -142,7 +142,7 @@ void CXWindowsPrimaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
// notification of selection transferred. we shouldn't
|
// notification of selection transferred. we shouldn't
|
||||||
// get this here because we handle them in the selection
|
// get this here because we handle them in the selection
|
||||||
// retrieval methods. we'll just delete the property
|
// retrieval methods. we'll just delete the property
|
||||||
|
@ -153,7 +153,7 @@ void CXWindowsPrimaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
// somebody is asking for clipboard data
|
// somebody is asking for clipboard data
|
||||||
if (xevent.xselectionrequest.owner == m_window) {
|
if (xevent.xselectionrequest.owner == m_window) {
|
||||||
addClipboardRequest(m_window,
|
addClipboardRequest(m_window,
|
||||||
|
@ -179,7 +179,7 @@ void CXWindowsPrimaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
// clipboard transfers involve property changes so forward
|
// clipboard transfers involve property changes so forward
|
||||||
// the event to the superclass. we only care about the
|
// the event to the superclass. we only care about the
|
||||||
// deletion of properties.
|
// deletion of properties.
|
||||||
|
@ -190,7 +190,7 @@ void CXWindowsPrimaryScreen::run()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
// looks like one of the windows that requested a clipboard
|
// looks like one of the windows that requested a clipboard
|
||||||
// transfer has gone bye-bye.
|
// transfer has gone bye-bye.
|
||||||
destroyClipboardRequest(xevent.xdestroywindow.window);
|
destroyClipboardRequest(xevent.xdestroywindow.window);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "IPrimaryScreen.h"
|
#include "IPrimaryScreen.h"
|
||||||
|
|
||||||
class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
|
class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
|
||||||
public:
|
public:
|
||||||
CXWindowsPrimaryScreen();
|
CXWindowsPrimaryScreen();
|
||||||
virtual ~CXWindowsPrimaryScreen();
|
virtual ~CXWindowsPrimaryScreen();
|
||||||
|
|
||||||
|
@ -25,13 +25,13 @@ class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
|
||||||
virtual SInt32 getJumpZoneSize() const;
|
virtual SInt32 getJumpZoneSize() const;
|
||||||
virtual void getClipboard(ClipboardID, IClipboard*) const;
|
virtual void getClipboard(ClipboardID, IClipboard*) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// CXWindowsScreen overrides
|
// CXWindowsScreen overrides
|
||||||
virtual void onOpenDisplay();
|
virtual void onOpenDisplay();
|
||||||
virtual void onCloseDisplay();
|
virtual void onCloseDisplay();
|
||||||
virtual long getEventMask(Window) const;
|
virtual long getEventMask(Window) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void selectEvents(Display*, Window) const;
|
void selectEvents(Display*, Window) const;
|
||||||
void warpCursorNoLock(Display*,
|
void warpCursorNoLock(Display*,
|
||||||
SInt32 xAbsolute, SInt32 yAbsolute);
|
SInt32 xAbsolute, SInt32 yAbsolute);
|
||||||
|
@ -40,7 +40,7 @@ class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
|
||||||
KeyID mapKey(XKeyEvent*) const;
|
KeyID mapKey(XKeyEvent*) const;
|
||||||
ButtonID mapButton(unsigned int button) const;
|
ButtonID mapButton(unsigned int button) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
Window m_window;
|
Window m_window;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "CString.h"
|
#include "CString.h"
|
||||||
|
|
||||||
class CClipboard : public IClipboard {
|
class CClipboard : public IClipboard {
|
||||||
public:
|
public:
|
||||||
CClipboard();
|
CClipboard();
|
||||||
virtual ~CClipboard();
|
virtual ~CClipboard();
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ class CClipboard : public IClipboard {
|
||||||
static void copy(IClipboard* dst, const IClipboard* src);
|
static void copy(IClipboard* dst, const IClipboard* src);
|
||||||
static void copy(IClipboard* dst, const IClipboard* src, Time);
|
static void copy(IClipboard* dst, const IClipboard* src, Time);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 readUInt32(const char*) const;
|
UInt32 readUInt32(const char*) const;
|
||||||
void writeUInt32(CString*, UInt32) const;
|
void writeUInt32(CString*, UInt32) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Time m_time;
|
Time m_time;
|
||||||
bool m_added[kNumFormats];
|
bool m_added[kNumFormats];
|
||||||
CString m_data[kNumFormats];
|
CString m_data[kNumFormats];
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "CMutex.h"
|
#include "CMutex.h"
|
||||||
|
|
||||||
class CInputPacketStream : public CInputStreamFilter {
|
class CInputPacketStream : public CInputStreamFilter {
|
||||||
public:
|
public:
|
||||||
CInputPacketStream(IInputStream*, bool adoptStream = true);
|
CInputPacketStream(IInputStream*, bool adoptStream = true);
|
||||||
~CInputPacketStream();
|
~CInputPacketStream();
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ class CInputPacketStream : public CInputStreamFilter {
|
||||||
virtual UInt32 read(void*, UInt32 maxCount);
|
virtual UInt32 read(void*, UInt32 maxCount);
|
||||||
virtual UInt32 getSize() const;
|
virtual UInt32 getSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 getSizeNoLock() const;
|
UInt32 getSizeNoLock() const;
|
||||||
bool hasFullMessage() const;
|
bool hasFullMessage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMutex m_mutex;
|
CMutex m_mutex;
|
||||||
mutable UInt32 m_size;
|
mutable UInt32 m_size;
|
||||||
mutable CBufferedInputStream m_buffer;
|
mutable CBufferedInputStream m_buffer;
|
||||||
|
|
|
@ -53,11 +53,11 @@ void CMSWindowsClipboard::add(
|
||||||
const UINT win32Format = convertFormatToWin32(format);
|
const UINT win32Format = convertFormatToWin32(format);
|
||||||
HANDLE win32Data;
|
HANDLE win32Data;
|
||||||
switch (win32Format) {
|
switch (win32Format) {
|
||||||
case CF_TEXT:
|
case CF_TEXT:
|
||||||
win32Data = convertTextToWin32(data);
|
win32Data = convertTextToWin32(data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
win32Data = NULL;
|
win32Data = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ CString CMSWindowsClipboard::get(EFormat format) const
|
||||||
if (win32Data != NULL) {
|
if (win32Data != NULL) {
|
||||||
// convert the data
|
// convert the data
|
||||||
switch (win32Format) {
|
switch (win32Format) {
|
||||||
case CF_TEXT:
|
case CF_TEXT:
|
||||||
data = convertTextFromWin32(win32Data);
|
data = convertTextFromWin32(win32Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,10 +110,10 @@ UINT CMSWindowsClipboard::convertFormatToWin32(
|
||||||
EFormat format) const
|
EFormat format) const
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case kText:
|
case kText:
|
||||||
return CF_TEXT;
|
return CF_TEXT;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class CMSWindowsClipboard : public IClipboard {
|
class CMSWindowsClipboard : public IClipboard {
|
||||||
public:
|
public:
|
||||||
CMSWindowsClipboard(HWND window);
|
CMSWindowsClipboard(HWND window);
|
||||||
virtual ~CMSWindowsClipboard();
|
virtual ~CMSWindowsClipboard();
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ class CMSWindowsClipboard : public IClipboard {
|
||||||
virtual bool has(EFormat) const;
|
virtual bool has(EFormat) const;
|
||||||
virtual CString get(EFormat) const;
|
virtual CString get(EFormat) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UINT convertFormatToWin32(EFormat) const;
|
UINT convertFormatToWin32(EFormat) const;
|
||||||
HANDLE convertTextToWin32(const CString& data) const;
|
HANDLE convertTextToWin32(const CString& data) const;
|
||||||
CString convertTextFromWin32(HANDLE) const;
|
CString convertTextFromWin32(HANDLE) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class CString;
|
||||||
class CThread;
|
class CThread;
|
||||||
|
|
||||||
class CMSWindowsScreen {
|
class CMSWindowsScreen {
|
||||||
public:
|
public:
|
||||||
CMSWindowsScreen();
|
CMSWindowsScreen();
|
||||||
virtual ~CMSWindowsScreen();
|
virtual ~CMSWindowsScreen();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class CMSWindowsScreen {
|
||||||
|
|
||||||
static void init(HINSTANCE);
|
static void init(HINSTANCE);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// runs an event loop and returns when WM_QUIT is received
|
// runs an event loop and returns when WM_QUIT is received
|
||||||
void doRun();
|
void doRun();
|
||||||
|
|
||||||
|
@ -62,10 +62,10 @@ class CMSWindowsScreen {
|
||||||
// called by closeDisplay() to
|
// called by closeDisplay() to
|
||||||
virtual void onCloseDisplay() = 0;
|
virtual void onCloseDisplay() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HINSTANCE s_instance;
|
static HINSTANCE s_instance;
|
||||||
ATOM m_class;
|
ATOM m_class;
|
||||||
HICON m_icon;
|
HICON m_icon;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "COutputStreamFilter.h"
|
#include "COutputStreamFilter.h"
|
||||||
|
|
||||||
class COutputPacketStream : public COutputStreamFilter {
|
class COutputPacketStream : public COutputStreamFilter {
|
||||||
public:
|
public:
|
||||||
COutputPacketStream(IOutputStream*, bool adoptStream = true);
|
COutputPacketStream(IOutputStream*, bool adoptStream = true);
|
||||||
~COutputPacketStream();
|
~COutputPacketStream();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
++fmt;
|
++fmt;
|
||||||
UInt32 len = eatLength(&fmt);
|
UInt32 len = eatLength(&fmt);
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case 'i': {
|
case 'i': {
|
||||||
// check for valid length
|
// check for valid length
|
||||||
assert(len == 1 || len == 2 || len == 4);
|
assert(len == 1 || len == 2 || len == 4);
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
// convert it
|
// convert it
|
||||||
void* v = va_arg(args, void*);
|
void* v = va_arg(args, void*);
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 1:
|
case 1:
|
||||||
// 1 byte integer
|
// 1 byte integer
|
||||||
*reinterpret_cast<UInt8*>(v) = buffer[0];
|
*reinterpret_cast<UInt8*>(v) = buffer[0];
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
|
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt8*>(v), *reinterpret_cast<UInt8*>(v)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// 2 byte integer
|
// 2 byte integer
|
||||||
*reinterpret_cast<UInt16*>(v) =
|
*reinterpret_cast<UInt16*>(v) =
|
||||||
(static_cast<UInt16>(buffer[0]) << 8) |
|
(static_cast<UInt16>(buffer[0]) << 8) |
|
||||||
|
@ -89,7 +89,7 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
|
log((CLOG_DEBUG2 "readf: read %d byte integer: %d (0x%x)", len, *reinterpret_cast<UInt16*>(v), *reinterpret_cast<UInt16*>(v)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
// 4 byte integer
|
// 4 byte integer
|
||||||
*reinterpret_cast<UInt32*>(v) =
|
*reinterpret_cast<UInt32*>(v) =
|
||||||
(static_cast<UInt32>(buffer[0]) << 24) |
|
(static_cast<UInt32>(buffer[0]) << 24) |
|
||||||
|
@ -100,9 +100,9 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 's': {
|
case 's': {
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
|
|
||||||
// read the string length
|
// read the string length
|
||||||
|
@ -146,13 +146,13 @@ void CProtocolUtil::readf(IInputStream* stream,
|
||||||
delete[] sBuffer;
|
delete[] sBuffer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid format specifier");
|
assert(0 && "invalid format specifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,29 +188,29 @@ UInt32 CProtocolUtil::getLength(
|
||||||
++fmt;
|
++fmt;
|
||||||
UInt32 len = eatLength(&fmt);
|
UInt32 len = eatLength(&fmt);
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case 'i':
|
case 'i':
|
||||||
assert(len == 1 || len == 2 || len == 4);
|
assert(len == 1 || len == 2 || len == 4);
|
||||||
(void)va_arg(args, UInt32);
|
(void)va_arg(args, UInt32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
len = (va_arg(args, CString*))->size() + 4;
|
len = (va_arg(args, CString*))->size() + 4;
|
||||||
(void)va_arg(args, UInt8*);
|
(void)va_arg(args, UInt8*);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
len = va_arg(args, UInt32) + 4;
|
len = va_arg(args, UInt32) + 4;
|
||||||
(void)va_arg(args, UInt8*);
|
(void)va_arg(args, UInt8*);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
len = 1;
|
len = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid format specifier");
|
assert(0 && "invalid format specifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,21 +238,21 @@ void CProtocolUtil::writef(void* buffer,
|
||||||
++fmt;
|
++fmt;
|
||||||
UInt32 len = eatLength(&fmt);
|
UInt32 len = eatLength(&fmt);
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case 'i': {
|
case 'i': {
|
||||||
const UInt32 v = va_arg(args, UInt32);
|
const UInt32 v = va_arg(args, UInt32);
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 1:
|
case 1:
|
||||||
// 1 byte integer
|
// 1 byte integer
|
||||||
*dst++ = static_cast<UInt8>(v & 0xff);
|
*dst++ = static_cast<UInt8>(v & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
// 2 byte integer
|
// 2 byte integer
|
||||||
*dst++ = static_cast<UInt8>((v >> 8) & 0xff);
|
*dst++ = static_cast<UInt8>((v >> 8) & 0xff);
|
||||||
*dst++ = static_cast<UInt8>( v & 0xff);
|
*dst++ = static_cast<UInt8>( v & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
// 4 byte integer
|
// 4 byte integer
|
||||||
*dst++ = static_cast<UInt8>((v >> 24) & 0xff);
|
*dst++ = static_cast<UInt8>((v >> 24) & 0xff);
|
||||||
*dst++ = static_cast<UInt8>((v >> 16) & 0xff);
|
*dst++ = static_cast<UInt8>((v >> 16) & 0xff);
|
||||||
|
@ -260,14 +260,14 @@ void CProtocolUtil::writef(void* buffer,
|
||||||
*dst++ = static_cast<UInt8>( v & 0xff);
|
*dst++ = static_cast<UInt8>( v & 0xff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid integer format length");
|
assert(0 && "invalid integer format length");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 's': {
|
case 's': {
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
const CString* src = va_arg(args, CString*);
|
const CString* src = va_arg(args, CString*);
|
||||||
const UInt32 len = (src != NULL) ? src->size() : 0;
|
const UInt32 len = (src != NULL) ? src->size() : 0;
|
||||||
|
@ -280,9 +280,9 @@ void CProtocolUtil::writef(void* buffer,
|
||||||
dst += len;
|
dst += len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'S': {
|
case 'S': {
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
const UInt32 len = va_arg(args, UInt32);
|
const UInt32 len = va_arg(args, UInt32);
|
||||||
const UInt8* src = va_arg(args, UInt8*);
|
const UInt8* src = va_arg(args, UInt8*);
|
||||||
|
@ -293,14 +293,14 @@ void CProtocolUtil::writef(void* buffer,
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
dst += len;
|
dst += len;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
*dst++ = '%';
|
*dst++ = '%';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid format specifier");
|
assert(0 && "invalid format specifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,17 +321,17 @@ UInt32 CProtocolUtil::eatLength(const char** pfmt)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
UInt32 d;
|
UInt32 d;
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case '0': d = 0; break;
|
case '0': d = 0; break;
|
||||||
case '1': d = 1; break;
|
case '1': d = 1; break;
|
||||||
case '2': d = 2; break;
|
case '2': d = 2; break;
|
||||||
case '3': d = 3; break;
|
case '3': d = 3; break;
|
||||||
case '4': d = 4; break;
|
case '4': d = 4; break;
|
||||||
case '5': d = 5; break;
|
case '5': d = 5; break;
|
||||||
case '6': d = 6; break;
|
case '6': d = 6; break;
|
||||||
case '7': d = 7; break;
|
case '7': d = 7; break;
|
||||||
case '8': d = 8; break;
|
case '8': d = 8; break;
|
||||||
case '9': d = 9; break;
|
case '9': d = 9; break;
|
||||||
default: *pfmt = fmt; return n;
|
default: *pfmt = fmt; return n;
|
||||||
}
|
}
|
||||||
n = 10 * n + d;
|
n = 10 * n + d;
|
||||||
++fmt;
|
++fmt;
|
||||||
|
|
|
@ -9,7 +9,7 @@ class IInputStream;
|
||||||
class IOutputStream;
|
class IOutputStream;
|
||||||
|
|
||||||
class CProtocolUtil {
|
class CProtocolUtil {
|
||||||
public:
|
public:
|
||||||
// write formatted binary data to a stream. fmt consists of
|
// write formatted binary data to a stream. fmt consists of
|
||||||
// regular characters and format specifiers. format specifiers
|
// regular characters and format specifiers. format specifiers
|
||||||
// begin with %. all characters not part of a format specifier
|
// begin with %. all characters not part of a format specifier
|
||||||
|
@ -37,7 +37,7 @@ class CProtocolUtil {
|
||||||
static void readf(IInputStream*,
|
static void readf(IInputStream*,
|
||||||
const char* fmt, ...);
|
const char* fmt, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static UInt32 getLength(const char* fmt, va_list);
|
static UInt32 getLength(const char* fmt, va_list);
|
||||||
static void writef(void*, const char* fmt, va_list);
|
static void writef(void*, const char* fmt, va_list);
|
||||||
static UInt32 eatLength(const char** fmt);
|
static UInt32 eatLength(const char** fmt);
|
||||||
|
@ -45,7 +45,7 @@ class CProtocolUtil {
|
||||||
};
|
};
|
||||||
|
|
||||||
class XIOReadMismatch : public XIO {
|
class XIOReadMismatch : public XIO {
|
||||||
public:
|
public:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "ISocketFactory.h"
|
#include "ISocketFactory.h"
|
||||||
|
|
||||||
class CTCPSocketFactory : public ISocketFactory {
|
class CTCPSocketFactory : public ISocketFactory {
|
||||||
public:
|
public:
|
||||||
CTCPSocketFactory();
|
CTCPSocketFactory();
|
||||||
virtual ~CTCPSocketFactory();
|
virtual ~CTCPSocketFactory();
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "IClipboard.h"
|
#include "IClipboard.h"
|
||||||
|
|
||||||
class CXWindowsClipboard : public IClipboard {
|
class CXWindowsClipboard : public IClipboard {
|
||||||
public:
|
public:
|
||||||
CXWindowsClipboard();
|
CXWindowsClipboard();
|
||||||
virtual ~CXWindowsClipboard();
|
virtual ~CXWindowsClipboard();
|
||||||
|
|
||||||
|
|
|
@ -403,19 +403,19 @@ bool CXWindowsScreen::getDisplayClipboard(
|
||||||
// transferred. use it as a hint to size our buffer.
|
// transferred. use it as a hint to size our buffer.
|
||||||
UInt32 size;
|
UInt32 size;
|
||||||
switch (datumSize) {
|
switch (datumSize) {
|
||||||
case 8:
|
case 8:
|
||||||
size = *(reinterpret_cast<const UInt8*>(data.data()));
|
size = *(reinterpret_cast<const UInt8*>(data.data()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
size = *(reinterpret_cast<const UInt16*>(data.data()));
|
size = *(reinterpret_cast<const UInt16*>(data.data()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32:
|
case 32:
|
||||||
size = *(reinterpret_cast<const UInt32*>(data.data()));
|
size = *(reinterpret_cast<const UInt32*>(data.data()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "invalid datum size");
|
assert(0 && "invalid datum size");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,19 @@
|
||||||
class CString;
|
class CString;
|
||||||
|
|
||||||
class CXWindowsScreen {
|
class CXWindowsScreen {
|
||||||
public:
|
public:
|
||||||
CXWindowsScreen();
|
CXWindowsScreen();
|
||||||
virtual ~CXWindowsScreen();
|
virtual ~CXWindowsScreen();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class CDisplayLock {
|
class CDisplayLock {
|
||||||
public:
|
public:
|
||||||
CDisplayLock(const CXWindowsScreen*);
|
CDisplayLock(const CXWindowsScreen*);
|
||||||
~CDisplayLock();
|
~CDisplayLock();
|
||||||
|
|
||||||
operator Display*() const;
|
operator Display*() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CMutex* m_mutex;
|
const CMutex* m_mutex;
|
||||||
Display* m_display;
|
Display* m_display;
|
||||||
};
|
};
|
||||||
|
@ -104,14 +104,14 @@ class CXWindowsScreen {
|
||||||
// get the X event mask required by the subclass for the given window
|
// get the X event mask required by the subclass for the given window
|
||||||
virtual long getEventMask(Window) const = 0;
|
virtual long getEventMask(Window) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CPropertyNotifyInfo {
|
struct CPropertyNotifyInfo {
|
||||||
public:
|
public:
|
||||||
Window m_window;
|
Window m_window;
|
||||||
Atom m_property;
|
Atom m_property;
|
||||||
};
|
};
|
||||||
struct CClipboardRequest {
|
struct CClipboardRequest {
|
||||||
public:
|
public:
|
||||||
CString m_data;
|
CString m_data;
|
||||||
UInt32 m_sent;
|
UInt32 m_sent;
|
||||||
Window m_requestor;
|
Window m_requestor;
|
||||||
|
@ -147,7 +147,7 @@ class CXWindowsScreen {
|
||||||
bool wasOwnedAtTime(ClipboardID, Window, Time) const;
|
bool wasOwnedAtTime(ClipboardID, Window, Time) const;
|
||||||
Time getCurrentTimeNoLock(Window) const;
|
Time getCurrentTimeNoLock(Window) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class CClipboardInfo {
|
class CClipboardInfo {
|
||||||
public:
|
public:
|
||||||
CClipboardInfo();
|
CClipboardInfo();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
class CString;
|
class CString;
|
||||||
|
|
||||||
class IClipboard : public IInterface {
|
class IClipboard : public IInterface {
|
||||||
public:
|
public:
|
||||||
// timestamp type. timestamps are in milliseconds from some
|
// timestamp type. timestamps are in milliseconds from some
|
||||||
// arbitrary starting time. timestamps will wrap around to 0
|
// arbitrary starting time. timestamps will wrap around to 0
|
||||||
// after about 49 3/4 days.
|
// after about 49 3/4 days.
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CServer;
|
||||||
class IClipboard;
|
class IClipboard;
|
||||||
|
|
||||||
class IPrimaryScreen : public IInterface {
|
class IPrimaryScreen : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// enter the screen's message loop. this returns when it detects
|
// enter the screen's message loop. this returns when it detects
|
||||||
|
|
|
@ -11,7 +11,7 @@ class CClient;
|
||||||
class IClipboard;
|
class IClipboard;
|
||||||
|
|
||||||
class ISecondaryScreen : public IInterface {
|
class ISecondaryScreen : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// enter the screen's message loop. this returns when it detects
|
// enter the screen's message loop. this returns when it detects
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
class IClipboard;
|
class IClipboard;
|
||||||
|
|
||||||
class IServerProtocol : public IInterface {
|
class IServerProtocol : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// process messages from the client and insert the appropriate
|
// process messages from the client and insert the appropriate
|
||||||
|
@ -39,7 +39,7 @@ class IServerProtocol : public IInterface {
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
virtual void recvInfo() = 0;
|
virtual void recvInfo() = 0;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ISocket;
|
||||||
class IListenSocket;
|
class IListenSocket;
|
||||||
|
|
||||||
class ISocketFactory : public IInterface {
|
class ISocketFactory : public IInterface {
|
||||||
public:
|
public:
|
||||||
// manipulators
|
// manipulators
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
|
|
@ -7,13 +7,13 @@ class XSynergy : public XBase { };
|
||||||
|
|
||||||
// client is misbehaving
|
// client is misbehaving
|
||||||
class XBadClient : public XSynergy {
|
class XBadClient : public XSynergy {
|
||||||
protected:
|
protected:
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
// client has incompatible version
|
// client has incompatible version
|
||||||
class XIncompatibleClient : public XSynergy {
|
class XIncompatibleClient : public XSynergy {
|
||||||
public:
|
public:
|
||||||
XIncompatibleClient(int major, int minor);
|
XIncompatibleClient(int major, int minor);
|
||||||
|
|
||||||
// manipulators
|
// manipulators
|
||||||
|
@ -23,10 +23,10 @@ class XIncompatibleClient : public XSynergy {
|
||||||
int getMajor() const throw();
|
int getMajor() const throw();
|
||||||
int getMinor() const throw();
|
int getMinor() const throw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual CString getWhat() const throw();
|
virtual CString getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_major;
|
int m_major;
|
||||||
int m_minor;
|
int m_minor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue