- made unit testing easier by (mostly) removing the event queue singleton.
- fixed code style in many places (mostly indentation).
This commit is contained in:
parent
13b2649fa0
commit
608074c041
|
@ -26,6 +26,7 @@
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "CMSWindowsScreen.h"
|
#include "CMSWindowsScreen.h"
|
||||||
|
#include "CEventQueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CMSWindowsClientTaskBarReceiver
|
// CMSWindowsClientTaskBarReceiver
|
||||||
|
@ -41,8 +42,8 @@ const UINT CMSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||||
};
|
};
|
||||||
|
|
||||||
CMSWindowsClientTaskBarReceiver::CMSWindowsClientTaskBarReceiver(
|
CMSWindowsClientTaskBarReceiver::CMSWindowsClientTaskBarReceiver(
|
||||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer) :
|
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||||
CClientTaskBarReceiver(),
|
CClientTaskBarReceiver(events),
|
||||||
m_appInstance(appInstance),
|
m_appInstance(appInstance),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
m_logBuffer(logBuffer)
|
m_logBuffer(logBuffer)
|
||||||
|
@ -357,7 +358,7 @@ CMSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
CArchMiscWindows::setIcons(
|
CArchMiscWindows::setIcons(
|
||||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||||
|
@ -370,5 +371,5 @@ createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
||||||
16, 16, LR_SHARED));
|
16, 16, LR_SHARED));
|
||||||
|
|
||||||
return new CMSWindowsClientTaskBarReceiver(
|
return new CMSWindowsClientTaskBarReceiver(
|
||||||
CMSWindowsScreen::getWindowInstance(), logBuffer);
|
CMSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class CBufferedLogOutputter;
|
class CBufferedLogOutputter;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Implementation of CClientTaskBarReceiver for Microsoft Windows
|
//! Implementation of CClientTaskBarReceiver for Microsoft Windows
|
||||||
class CMSWindowsClientTaskBarReceiver : public CClientTaskBarReceiver {
|
class CMSWindowsClientTaskBarReceiver : public CClientTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
CMSWindowsClientTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*);
|
CMSWindowsClientTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~CMSWindowsClientTaskBarReceiver();
|
virtual ~CMSWindowsClientTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
|
@ -63,6 +64,7 @@ private:
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
HICON m_icon[kMaxState];
|
HICON m_icon[kMaxState];
|
||||||
const CBufferedLogOutputter* m_logBuffer;
|
const CBufferedLogOutputter* m_logBuffer;
|
||||||
|
|
||||||
static const UINT s_stateToIconID[];
|
static const UINT s_stateToIconID[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,6 @@ main(int argc, char** argv)
|
||||||
CLog log;
|
CLog log;
|
||||||
CEventQueue events;
|
CEventQueue events;
|
||||||
|
|
||||||
CClientApp app(createTaskBarReceiver);
|
CClientApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
#include "CMSWindowsScreen.h"
|
#include "CMSWindowsScreen.h"
|
||||||
|
#include "CEventQueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CMSWindowsPortableTaskBarReceiver
|
// CMSWindowsPortableTaskBarReceiver
|
||||||
|
@ -40,8 +41,9 @@ const UINT CMSWindowsPortableTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||||
};
|
};
|
||||||
|
|
||||||
CMSWindowsPortableTaskBarReceiver::CMSWindowsPortableTaskBarReceiver(
|
CMSWindowsPortableTaskBarReceiver::CMSWindowsPortableTaskBarReceiver(
|
||||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer) :
|
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||||
CPortableTaskBarReceiver(),
|
CPortableTaskBarReceiver(events),
|
||||||
|
m_events(events),
|
||||||
m_appInstance(appInstance),
|
m_appInstance(appInstance),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
m_logBuffer(logBuffer)
|
m_logBuffer(logBuffer)
|
||||||
|
@ -178,18 +180,18 @@ CMSWindowsPortableTaskBarReceiver::runMenu(int x, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_RELOAD_CONFIG:
|
case IDC_RELOAD_CONFIG:
|
||||||
EVENTQUEUE->addEvent(CEvent(getReloadConfigEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().reloadConfig(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_FORCE_RECONNECT:
|
case IDC_FORCE_RECONNECT:
|
||||||
EVENTQUEUE->addEvent(CEvent(getForceReconnectEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().forceReconnect(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SYNERGY_RESETSERVER:
|
case ID_SYNERGY_RESETSERVER:
|
||||||
EVENTQUEUE->addEvent(CEvent(getResetServerEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().resetServer(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
|
@ -374,7 +376,7 @@ CMSWindowsPortableTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
CArchMiscWindows::setIcons(
|
CArchMiscWindows::setIcons(
|
||||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||||
|
@ -387,5 +389,5 @@ createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
||||||
16, 16, LR_SHARED));
|
16, 16, LR_SHARED));
|
||||||
|
|
||||||
return new CMSWindowsPortableTaskBarReceiver(
|
return new CMSWindowsPortableTaskBarReceiver(
|
||||||
CMSWindowsScreen::getWindowInstance(), logBuffer);
|
CMSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class CBufferedLogOutputter;
|
class CBufferedLogOutputter;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Implementation of CPortableTaskBarReceiver for Microsoft Windows
|
//! Implementation of CPortableTaskBarReceiver for Microsoft Windows
|
||||||
class CMSWindowsPortableTaskBarReceiver : public CPortableTaskBarReceiver {
|
class CMSWindowsPortableTaskBarReceiver : public CPortableTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
CMSWindowsPortableTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*);
|
CMSWindowsPortableTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~CMSWindowsPortableTaskBarReceiver();
|
virtual ~CMSWindowsPortableTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
|
@ -62,5 +63,7 @@ private:
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
HICON m_icon[kMaxState];
|
HICON m_icon[kMaxState];
|
||||||
const CBufferedLogOutputter* m_logBuffer;
|
const CBufferedLogOutputter* m_logBuffer;
|
||||||
|
IEventQueue* m_events;
|
||||||
|
|
||||||
static const UINT s_stateToIconID[];
|
static const UINT s_stateToIconID[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,11 +79,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdSh
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server) {
|
if (server) {
|
||||||
CServerApp app(createTaskBarReceiver);
|
CServerApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
else if (client) {
|
else if (client) {
|
||||||
CClientApp app(createTaskBarReceiver);
|
CClientApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "CArchMiscWindows.h"
|
#include "CArchMiscWindows.h"
|
||||||
#include "CMSWindowsScreen.h"
|
#include "CMSWindowsScreen.h"
|
||||||
|
#include "CEventQueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CMSWindowsServerTaskBarReceiver
|
// CMSWindowsServerTaskBarReceiver
|
||||||
|
@ -41,8 +42,9 @@ const UINT CMSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||||
};
|
};
|
||||||
|
|
||||||
CMSWindowsServerTaskBarReceiver::CMSWindowsServerTaskBarReceiver(
|
CMSWindowsServerTaskBarReceiver::CMSWindowsServerTaskBarReceiver(
|
||||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer) :
|
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||||
CServerTaskBarReceiver(),
|
CServerTaskBarReceiver(events),
|
||||||
|
m_events(events),
|
||||||
m_appInstance(appInstance),
|
m_appInstance(appInstance),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
m_logBuffer(logBuffer)
|
m_logBuffer(logBuffer)
|
||||||
|
@ -192,18 +194,18 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_RELOAD_CONFIG:
|
case IDC_RELOAD_CONFIG:
|
||||||
EVENTQUEUE->addEvent(CEvent(getReloadConfigEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().reloadConfig(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_FORCE_RECONNECT:
|
case IDC_FORCE_RECONNECT:
|
||||||
EVENTQUEUE->addEvent(CEvent(getForceReconnectEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().forceReconnect(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SYNERGY_RESETSERVER:
|
case ID_SYNERGY_RESETSERVER:
|
||||||
EVENTQUEUE->addEvent(CEvent(getResetServerEvent(),
|
m_events->addEvent(CEvent(m_events->forCServerApp().resetServer(),
|
||||||
IEventQueue::getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
|
@ -388,7 +390,7 @@ CMSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
CArchMiscWindows::setIcons(
|
CArchMiscWindows::setIcons(
|
||||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||||
|
@ -401,5 +403,5 @@ createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
||||||
16, 16, LR_SHARED));
|
16, 16, LR_SHARED));
|
||||||
|
|
||||||
return new CMSWindowsServerTaskBarReceiver(
|
return new CMSWindowsServerTaskBarReceiver(
|
||||||
CMSWindowsScreen::getWindowInstance(), logBuffer);
|
CMSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class CBufferedLogOutputter;
|
class CBufferedLogOutputter;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Implementation of CServerTaskBarReceiver for Microsoft Windows
|
//! Implementation of CServerTaskBarReceiver for Microsoft Windows
|
||||||
class CMSWindowsServerTaskBarReceiver : public CServerTaskBarReceiver {
|
class CMSWindowsServerTaskBarReceiver : public CServerTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
CMSWindowsServerTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*);
|
CMSWindowsServerTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~CMSWindowsServerTaskBarReceiver();
|
virtual ~CMSWindowsServerTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
|
@ -63,6 +64,8 @@ private:
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
HICON m_icon[kMaxState];
|
HICON m_icon[kMaxState];
|
||||||
const CBufferedLogOutputter* m_logBuffer;
|
const CBufferedLogOutputter* m_logBuffer;
|
||||||
|
IEventQueue* m_events;
|
||||||
|
|
||||||
static const UINT s_stateToIconID[];
|
static const UINT s_stateToIconID[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,6 @@ main(int argc, char** argv)
|
||||||
CLog log;
|
CLog log;
|
||||||
CEventQueue events;
|
CEventQueue events;
|
||||||
|
|
||||||
CServerApp app(createTaskBarReceiver);
|
CServerApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,6 @@ CArchPluginUnix::~CArchPluginUnix()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CArchPluginUnix::init(void* eventTarget)
|
CArchPluginUnix::init(void* eventTarget, IEventQueue* events)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#define ARCH_PLUGIN CArchPluginUnix
|
#define ARCH_PLUGIN CArchPluginUnix
|
||||||
|
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Unix implementation of IArchPlugin
|
//! Unix implementation of IArchPlugin
|
||||||
class CArchPluginUnix : public IArchPlugin {
|
class CArchPluginUnix : public IArchPlugin {
|
||||||
public:
|
public:
|
||||||
|
@ -29,5 +31,5 @@ public:
|
||||||
virtual ~CArchPluginUnix();
|
virtual ~CArchPluginUnix();
|
||||||
|
|
||||||
// IArchPlugin overrides
|
// IArchPlugin overrides
|
||||||
void init(void* eventTarget);
|
void init(void* eventTarget, IEventQueue* events);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "IEventQueue.h"
|
#include "IEventQueue.h"
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
#include "CScreen.h"
|
#include "CScreen.h"
|
||||||
#include "IPlatformScreen.h" // temp
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -30,7 +29,8 @@
|
||||||
|
|
||||||
typedef int (*initFunc)(void (*sendEvent)(const char*, void*), void (*log)(const char*));
|
typedef int (*initFunc)(void (*sendEvent)(const char*, void*), void (*log)(const char*));
|
||||||
|
|
||||||
void* CArchPluginWindows::m_eventTarget = NULL;
|
void* g_eventTarget = NULL;
|
||||||
|
IEventQueue* g_events = NULL;
|
||||||
|
|
||||||
CArchPluginWindows::CArchPluginWindows()
|
CArchPluginWindows::CArchPluginWindows()
|
||||||
{
|
{
|
||||||
|
@ -41,9 +41,10 @@ CArchPluginWindows::~CArchPluginWindows()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CArchPluginWindows::init(void* eventTarget)
|
CArchPluginWindows::init(void* eventTarget, IEventQueue* events)
|
||||||
{
|
{
|
||||||
m_eventTarget = eventTarget;
|
g_eventTarget = eventTarget;
|
||||||
|
g_events = events;
|
||||||
|
|
||||||
CString dir = getPluginsDir();
|
CString dir = getPluginsDir();
|
||||||
LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str()));
|
LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str()));
|
||||||
|
@ -115,8 +116,8 @@ void
|
||||||
sendEvent(const char* eventName, void* data)
|
sendEvent(const char* eventName, void* data)
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG5 "plugin sending event"));
|
LOG((CLOG_DEBUG5 "plugin sending event"));
|
||||||
CEvent::Type type = EVENTQUEUE->getRegisteredType(eventName);
|
CEvent::Type type = g_events->getRegisteredType(eventName);
|
||||||
EVENTQUEUE->addEvent(CEvent(type, CArchPluginWindows::m_eventTarget, data));
|
g_events->addEvent(CEvent(type, g_eventTarget, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#define ARCH_PLUGIN CArchPluginWindows
|
#define ARCH_PLUGIN CArchPluginWindows
|
||||||
|
|
||||||
class CScreen;
|
class CScreen;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Windows implementation of IArchPlugin
|
//! Windows implementation of IArchPlugin
|
||||||
class CArchPluginWindows : public IArchPlugin {
|
class CArchPluginWindows : public IArchPlugin {
|
||||||
|
@ -33,9 +34,7 @@ public:
|
||||||
virtual ~CArchPluginWindows();
|
virtual ~CArchPluginWindows();
|
||||||
|
|
||||||
// IArchPlugin overrides
|
// IArchPlugin overrides
|
||||||
void init(void* eventTarget);
|
void init(void* eventTarget, IEventQueue* events);
|
||||||
|
|
||||||
static void* m_eventTarget;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CString getModuleDir();
|
CString getModuleDir();
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
|
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Interface for plugin manager.
|
//! Interface for plugin manager.
|
||||||
/*!
|
/*!
|
||||||
A plugin manager should load all 3rd party plugins from the plugins dir,
|
A plugin manager should load all 3rd party plugins from the plugins dir,
|
||||||
|
@ -36,7 +38,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Scan the plugins dir and load plugins.
|
Scan the plugins dir and load plugins.
|
||||||
*/
|
*/
|
||||||
virtual void init(void* eventTarget) = 0;
|
virtual void init(void* eventTarget, IEventQueue* events) = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,6 @@ public:
|
||||||
|
|
||||||
//! Create \c CEvent with data (POD)
|
//! Create \c CEvent with data (POD)
|
||||||
/*!
|
/*!
|
||||||
The \p type must have been registered using \c registerType().
|
|
||||||
The \p data must be POD (plain old data) allocated by malloc(),
|
The \p data must be POD (plain old data) allocated by malloc(),
|
||||||
which means it cannot have a constructor, destructor or be
|
which means it cannot have a constructor, destructor or be
|
||||||
composed of any types that do. For non-POD (normal C++ objects
|
composed of any types that do. For non-POD (normal C++ objects
|
||||||
|
|
|
@ -22,13 +22,35 @@
|
||||||
#include "CStopwatch.h"
|
#include "CStopwatch.h"
|
||||||
#include "IEventJob.h"
|
#include "IEventJob.h"
|
||||||
#include "CArch.h"
|
#include "CArch.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
|
EVENT_TYPE_ACCESSOR(CClient)
|
||||||
|
EVENT_TYPE_ACCESSOR(IStream)
|
||||||
|
EVENT_TYPE_ACCESSOR(CIpcClient)
|
||||||
|
EVENT_TYPE_ACCESSOR(CIpcClientProxy)
|
||||||
|
EVENT_TYPE_ACCESSOR(CIpcServer)
|
||||||
|
EVENT_TYPE_ACCESSOR(CIpcServerProxy)
|
||||||
|
EVENT_TYPE_ACCESSOR(IDataSocket)
|
||||||
|
EVENT_TYPE_ACCESSOR(IListenSocket)
|
||||||
|
EVENT_TYPE_ACCESSOR(ISocket)
|
||||||
|
EVENT_TYPE_ACCESSOR(COSXScreen)
|
||||||
|
EVENT_TYPE_ACCESSOR(CClientListener)
|
||||||
|
EVENT_TYPE_ACCESSOR(CClientProxy)
|
||||||
|
EVENT_TYPE_ACCESSOR(CClientProxyUnknown)
|
||||||
|
EVENT_TYPE_ACCESSOR(CServer)
|
||||||
|
EVENT_TYPE_ACCESSOR(CServerApp)
|
||||||
|
EVENT_TYPE_ACCESSOR(IKeyState)
|
||||||
|
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
||||||
|
EVENT_TYPE_ACCESSOR(IScreen)
|
||||||
|
EVENT_TYPE_ACCESSOR(ISecondaryScreen)
|
||||||
|
|
||||||
// interrupt handler. this just adds a quit event to the queue.
|
// interrupt handler. this just adds a quit event to the queue.
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
interrupt(CArch::ESignal, void*)
|
interrupt(CArch::ESignal, void* data)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
|
CEventQueue* events = reinterpret_cast<CEventQueue*>(data);
|
||||||
|
events->addEvent(CEvent(CEvent::kQuit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,12 +59,30 @@ interrupt(CArch::ESignal, void*)
|
||||||
//
|
//
|
||||||
|
|
||||||
CEventQueue::CEventQueue() :
|
CEventQueue::CEventQueue() :
|
||||||
m_nextType(CEvent::kLast)
|
m_systemTarget(0),
|
||||||
|
m_nextType(CEvent::kLast),
|
||||||
|
m_typesForIStream(NULL),
|
||||||
|
m_typesForCIpcClient(NULL),
|
||||||
|
m_typesForCIpcClientProxy(NULL),
|
||||||
|
m_typesForCIpcServer(NULL),
|
||||||
|
m_typesForCIpcServerProxy(NULL),
|
||||||
|
m_typesForIDataSocket(NULL),
|
||||||
|
m_typesForIListenSocket(NULL),
|
||||||
|
m_typesForISocket(NULL),
|
||||||
|
m_typesForCOSXScreen(NULL),
|
||||||
|
m_typesForCClientListener(NULL),
|
||||||
|
m_typesForCClientProxy(NULL),
|
||||||
|
m_typesForCClientProxyUnknown(NULL),
|
||||||
|
m_typesForCServer(NULL),
|
||||||
|
m_typesForCServerApp(NULL),
|
||||||
|
m_typesForIKeyState(NULL),
|
||||||
|
m_typesForIPrimaryScreen(NULL),
|
||||||
|
m_typesForIScreen(NULL),
|
||||||
|
m_typesForISecondaryScreen(NULL)
|
||||||
{
|
{
|
||||||
setInstance(this);
|
|
||||||
m_mutex = ARCH->newMutex();
|
m_mutex = ARCH->newMutex();
|
||||||
ARCH->setSignalHandler(CArch::kINTERRUPT, &interrupt, NULL);
|
ARCH->setSignalHandler(CArch::kINTERRUPT, &interrupt, this);
|
||||||
ARCH->setSignalHandler(CArch::kTERMINATE, &interrupt, NULL);
|
ARCH->setSignalHandler(CArch::kTERMINATE, &interrupt, this);
|
||||||
m_buffer = new CSimpleEventQueueBuffer;
|
m_buffer = new CSimpleEventQueueBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +92,6 @@ CEventQueue::~CEventQueue()
|
||||||
ARCH->setSignalHandler(CArch::kINTERRUPT, NULL, NULL);
|
ARCH->setSignalHandler(CArch::kINTERRUPT, NULL, NULL);
|
||||||
ARCH->setSignalHandler(CArch::kTERMINATE, NULL, NULL);
|
ARCH->setSignalHandler(CArch::kTERMINATE, NULL, NULL);
|
||||||
ARCH->closeMutex(m_mutex);
|
ARCH->closeMutex(m_mutex);
|
||||||
setInstance(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -67,16 +106,6 @@ CEventQueue::loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CEventQueue::registerType(const char* name)
|
|
||||||
{
|
|
||||||
CArchMutexLock lock(m_mutex);
|
|
||||||
m_typeMap.insert(std::make_pair(m_nextType, name));
|
|
||||||
m_nameMap.insert(std::make_pair(name, m_nextType));
|
|
||||||
LOG((CLOG_DEBUG1 "registered event type %s as %d", name, m_nextType));
|
|
||||||
return m_nextType++;
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
CEvent::Type
|
||||||
CEventQueue::registerTypeOnce(CEvent::Type& type, const char* name)
|
CEventQueue::registerTypeOnce(CEvent::Type& type, const char* name)
|
||||||
{
|
{
|
||||||
|
@ -488,6 +517,12 @@ CEventQueue::getRegisteredType(const CString& name) const
|
||||||
return CEvent::kUnknown;
|
return CEvent::kUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void*
|
||||||
|
CEventQueue::getSystemTarget()
|
||||||
|
{
|
||||||
|
// any unique arbitrary pointer will do
|
||||||
|
return &m_systemTarget;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// CEventQueue::CTimer
|
// CEventQueue::CTimer
|
||||||
|
|
|
@ -52,8 +52,6 @@ public:
|
||||||
void* target, IEventJob* handler);
|
void* target, IEventJob* handler);
|
||||||
virtual void removeHandler(CEvent::Type type, void* target);
|
virtual void removeHandler(CEvent::Type type, void* target);
|
||||||
virtual void removeHandlers(void* target);
|
virtual void removeHandlers(void* target);
|
||||||
virtual CEvent::Type
|
|
||||||
registerType(const char* name);
|
|
||||||
virtual CEvent::Type
|
virtual CEvent::Type
|
||||||
registerTypeOnce(CEvent::Type& type, const char* name);
|
registerTypeOnce(CEvent::Type& type, const char* name);
|
||||||
virtual bool isEmpty() const;
|
virtual bool isEmpty() const;
|
||||||
|
@ -61,6 +59,7 @@ public:
|
||||||
virtual const char* getTypeName(CEvent::Type type);
|
virtual const char* getTypeName(CEvent::Type type);
|
||||||
virtual CEvent::Type
|
virtual CEvent::Type
|
||||||
getRegisteredType(const CString& name) const;
|
getRegisteredType(const CString& name) const;
|
||||||
|
void* getSystemTarget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 saveEvent(const CEvent& event);
|
UInt32 saveEvent(const CEvent& event);
|
||||||
|
@ -96,6 +95,7 @@ private:
|
||||||
bool m_oneShot;
|
bool m_oneShot;
|
||||||
double m_time;
|
double m_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::set<CEventQueueTimer*> CTimers;
|
typedef std::set<CEventQueueTimer*> CTimers;
|
||||||
typedef CPriorityQueue<CTimer> CTimerQueue;
|
typedef CPriorityQueue<CTimer> CTimerQueue;
|
||||||
typedef std::map<UInt32, CEvent> CEventTable;
|
typedef std::map<UInt32, CEvent> CEventTable;
|
||||||
|
@ -105,6 +105,7 @@ private:
|
||||||
typedef std::map<CEvent::Type, IEventJob*> CTypeHandlerTable;
|
typedef std::map<CEvent::Type, IEventJob*> CTypeHandlerTable;
|
||||||
typedef std::map<void*, CTypeHandlerTable> CHandlerTable;
|
typedef std::map<void*, CTypeHandlerTable> CHandlerTable;
|
||||||
|
|
||||||
|
int m_systemTarget;
|
||||||
CArchMutex m_mutex;
|
CArchMutex m_mutex;
|
||||||
|
|
||||||
// registered events
|
// registered events
|
||||||
|
@ -127,6 +128,61 @@ private:
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
CHandlerTable m_handlers;
|
CHandlerTable m_handlers;
|
||||||
|
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Event type providers.
|
||||||
|
//
|
||||||
|
CClientEvents& forCClient();
|
||||||
|
IStreamEvents& forIStream();
|
||||||
|
CIpcClientEvents& forCIpcClient();
|
||||||
|
CIpcClientProxyEvents& forCIpcClientProxy();
|
||||||
|
CIpcServerEvents& forCIpcServer();
|
||||||
|
CIpcServerProxyEvents& forCIpcServerProxy();
|
||||||
|
IDataSocketEvents& forIDataSocket();
|
||||||
|
IListenSocketEvents& forIListenSocket();
|
||||||
|
ISocketEvents& forISocket();
|
||||||
|
COSXScreenEvents& forCOSXScreen();
|
||||||
|
CClientListenerEvents& forCClientListener();
|
||||||
|
CClientProxyEvents& forCClientProxy();
|
||||||
|
CClientProxyUnknownEvents& forCClientProxyUnknown();
|
||||||
|
CServerEvents& forCServer();
|
||||||
|
CServerAppEvents& forCServerApp();
|
||||||
|
IKeyStateEvents& forIKeyState();
|
||||||
|
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||||
|
IScreenEvents& forIScreen();
|
||||||
|
ISecondaryScreenEvents& forISecondaryScreen();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CClientEvents* m_typesForCClient;
|
||||||
|
IStreamEvents* m_typesForIStream;
|
||||||
|
CIpcClientEvents* m_typesForCIpcClient;
|
||||||
|
CIpcClientProxyEvents* m_typesForCIpcClientProxy;
|
||||||
|
CIpcServerEvents* m_typesForCIpcServer;
|
||||||
|
CIpcServerProxyEvents* m_typesForCIpcServerProxy;
|
||||||
|
IDataSocketEvents* m_typesForIDataSocket;
|
||||||
|
IListenSocketEvents* m_typesForIListenSocket;
|
||||||
|
ISocketEvents* m_typesForISocket;
|
||||||
|
COSXScreenEvents* m_typesForCOSXScreen;
|
||||||
|
CClientListenerEvents* m_typesForCClientListener;
|
||||||
|
CClientProxyEvents* m_typesForCClientProxy;
|
||||||
|
CClientProxyUnknownEvents* m_typesForCClientProxyUnknown;
|
||||||
|
CServerEvents* m_typesForCServer;
|
||||||
|
CServerAppEvents* m_typesForCServerApp;
|
||||||
|
IKeyStateEvents* m_typesForIKeyState;
|
||||||
|
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||||
|
IScreenEvents* m_typesForIScreen;
|
||||||
|
ISecondaryScreenEvents* m_typesForISecondaryScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EVENT_TYPE_ACCESSOR(type_) \
|
||||||
|
type_##Events& \
|
||||||
|
CEventQueue::for##type_##() { \
|
||||||
|
if (m_typesFor##type_ == NULL) { \
|
||||||
|
m_typesFor##type_ = new type_##Events(); \
|
||||||
|
m_typesFor##type_->setEvents(dynamic_cast<IEventQueue*>(this)); \
|
||||||
|
} \
|
||||||
|
return *m_typesFor##type_; \
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2013 Bolton Software Ltd.
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file COPYING that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
#include "IEventQueue.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
CEventTypes::CEventTypes() :
|
||||||
|
m_events(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IEventQueue*
|
||||||
|
CEventTypes::events() const
|
||||||
|
{
|
||||||
|
assert(m_events != NULL);
|
||||||
|
return m_events;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CEventTypes::setEvents(IEventQueue* events)
|
||||||
|
{
|
||||||
|
m_events = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// CClient
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CClient, connected)
|
||||||
|
REGISTER_EVENT(CClient, connectionFailed)
|
||||||
|
REGISTER_EVENT(CClient, disconnected)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IStream
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IStream, inputReady)
|
||||||
|
REGISTER_EVENT(IStream, outputFlushed)
|
||||||
|
REGISTER_EVENT(IStream, outputError)
|
||||||
|
REGISTER_EVENT(IStream, inputShutdown)
|
||||||
|
REGISTER_EVENT(IStream, outputShutdown)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CIpcClient
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CIpcClient, connected)
|
||||||
|
REGISTER_EVENT(CIpcClient, messageReceived)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CIpcClientProxy
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CIpcClientProxy, messageReceived)
|
||||||
|
REGISTER_EVENT(CIpcClientProxy, disconnected)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CIpcServerProxy
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CIpcServerProxy, messageReceived)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IDataSocket
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IDataSocket, connected)
|
||||||
|
REGISTER_EVENT(IDataSocket, connectionFailed)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IListenSocket
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IListenSocket, connecting)
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISocket
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(ISocket, disconnected)
|
||||||
|
|
||||||
|
//
|
||||||
|
// COSXScreen
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(COSXScreen, confirmSleep)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CClientListener
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CClientListener, connected)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CClientProxy
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CClientProxy, ready)
|
||||||
|
REGISTER_EVENT(CClientProxy, disconnected)
|
||||||
|
REGISTER_EVENT(CClientProxy, clipboardChanged)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CClientProxyUnknown
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CClientProxyUnknown, success)
|
||||||
|
REGISTER_EVENT(CClientProxyUnknown, failure)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CServer
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CServer, error)
|
||||||
|
REGISTER_EVENT(CServer, connected)
|
||||||
|
REGISTER_EVENT(CServer, disconnected)
|
||||||
|
REGISTER_EVENT(CServer, switchToScreen)
|
||||||
|
REGISTER_EVENT(CServer, switchInDirection)
|
||||||
|
REGISTER_EVENT(CServer, keyboardBroadcast)
|
||||||
|
REGISTER_EVENT(CServer, lockCursorToScreen)
|
||||||
|
REGISTER_EVENT(CServer, screenSwitched)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CServerApp
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CServerApp, reloadConfig)
|
||||||
|
REGISTER_EVENT(CServerApp, forceReconnect)
|
||||||
|
REGISTER_EVENT(CServerApp, resetServer)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IKeyState
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IKeyState, keyDown)
|
||||||
|
REGISTER_EVENT(IKeyState, keyUp)
|
||||||
|
REGISTER_EVENT(IKeyState, keyRepeat)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IPrimaryScreen
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, buttonDown)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, buttonUp)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, motionOnPrimary)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, motionOnSecondary)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, wheel)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, screensaverActivated)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, screensaverDeactivated)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, hotKeyDown)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, hotKeyUp)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, fakeInputBegin)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, fakeInputEnd)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, gameDeviceButtons)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, gameDeviceSticks)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, gameDeviceTriggers)
|
||||||
|
REGISTER_EVENT(IPrimaryScreen, gameDeviceTimingReq)
|
||||||
|
|
||||||
|
//
|
||||||
|
// IScreen
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(IScreen, error)
|
||||||
|
REGISTER_EVENT(IScreen, shapeChanged)
|
||||||
|
REGISTER_EVENT(IScreen, clipboardGrabbed)
|
||||||
|
REGISTER_EVENT(IScreen, suspend)
|
||||||
|
REGISTER_EVENT(IScreen, resume)
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISecondaryScreen
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(ISecondaryScreen, gameDeviceTimingResp)
|
||||||
|
REGISTER_EVENT(ISecondaryScreen, gameDeviceFeedback)
|
||||||
|
|
||||||
|
//
|
||||||
|
// CIpcServer
|
||||||
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(CIpcServer, clientConnected)
|
||||||
|
REGISTER_EVENT(CIpcServer, messageReceived)
|
|
@ -0,0 +1,721 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2013 Bolton Software Ltd.
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file COPYING that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CEvent.h"
|
||||||
|
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
|
class CEventTypes {
|
||||||
|
public:
|
||||||
|
CEventTypes();
|
||||||
|
void setEvents(IEventQueue* events);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
IEventQueue* events() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IEventQueue* m_events;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define REGISTER_EVENT(type_, name_) \
|
||||||
|
CEvent::Type \
|
||||||
|
type_##Events::name_() \
|
||||||
|
{ \
|
||||||
|
return events()->registerTypeOnce(m_##name_, __FUNCTION__); \
|
||||||
|
}
|
||||||
|
|
||||||
|
class CClientEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CClientEvents() :
|
||||||
|
m_connected(CEvent::kUnknown),
|
||||||
|
m_connectionFailed(CEvent::kUnknown),
|
||||||
|
m_disconnected(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get connected event type
|
||||||
|
/*!
|
||||||
|
Returns the connected event type. This is sent when the client has
|
||||||
|
successfully connected to the server.
|
||||||
|
*/
|
||||||
|
CEvent::Type connected();
|
||||||
|
|
||||||
|
//! Get connection failed event type
|
||||||
|
/*!
|
||||||
|
Returns the connection failed event type. This is sent when the
|
||||||
|
server fails for some reason. The event data is a CFailInfo*.
|
||||||
|
*/
|
||||||
|
CEvent::Type connectionFailed();
|
||||||
|
|
||||||
|
//! Get disconnected event type
|
||||||
|
/*!
|
||||||
|
Returns the disconnected event type. This is sent when the client
|
||||||
|
has disconnected from the server (and only after having successfully
|
||||||
|
connected).
|
||||||
|
*/
|
||||||
|
CEvent::Type disconnected();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_connected;
|
||||||
|
CEvent::Type m_connectionFailed;
|
||||||
|
CEvent::Type m_disconnected;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IStreamEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IStreamEvents() :
|
||||||
|
m_inputReady(CEvent::kUnknown),
|
||||||
|
m_outputFlushed(CEvent::kUnknown),
|
||||||
|
m_outputError(CEvent::kUnknown),
|
||||||
|
m_inputShutdown(CEvent::kUnknown),
|
||||||
|
m_outputShutdown(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get input ready event type
|
||||||
|
/*!
|
||||||
|
Returns the input ready event type. A stream sends this event
|
||||||
|
when \c read() will return with data.
|
||||||
|
*/
|
||||||
|
CEvent::Type inputReady();
|
||||||
|
|
||||||
|
//! Get output flushed event type
|
||||||
|
/*!
|
||||||
|
Returns the output flushed event type. A stream sends this event
|
||||||
|
when the output buffer has been flushed. If there have been no
|
||||||
|
writes since the event was posted, calling \c shutdownOutput() or
|
||||||
|
\c close() will not discard any data and \c flush() will return
|
||||||
|
immediately.
|
||||||
|
*/
|
||||||
|
CEvent::Type outputFlushed();
|
||||||
|
|
||||||
|
//! Get output error event type
|
||||||
|
/*!
|
||||||
|
Returns the output error event type. A stream sends this event
|
||||||
|
when a write has failed.
|
||||||
|
*/
|
||||||
|
CEvent::Type outputError();
|
||||||
|
|
||||||
|
//! Get input shutdown event type
|
||||||
|
/*!
|
||||||
|
Returns the input shutdown event type. This is sent when the
|
||||||
|
input side of the stream has shutdown. When the input has
|
||||||
|
shutdown, no more data will ever be available to read.
|
||||||
|
*/
|
||||||
|
CEvent::Type inputShutdown();
|
||||||
|
|
||||||
|
//! Get output shutdown event type
|
||||||
|
/*!
|
||||||
|
Returns the output shutdown event type. This is sent when the
|
||||||
|
output side of the stream has shutdown. When the output has
|
||||||
|
shutdown, no more data can ever be written to the stream. Any
|
||||||
|
attempt to do so will generate a output error event.
|
||||||
|
*/
|
||||||
|
CEvent::Type outputShutdown();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_inputReady;
|
||||||
|
CEvent::Type m_outputFlushed;
|
||||||
|
CEvent::Type m_outputError;
|
||||||
|
CEvent::Type m_inputShutdown;
|
||||||
|
CEvent::Type m_outputShutdown;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CIpcClientEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CIpcClientEvents() :
|
||||||
|
m_connected(CEvent::kUnknown),
|
||||||
|
m_messageReceived(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Raised when the socket is connected.
|
||||||
|
CEvent::Type connected();
|
||||||
|
|
||||||
|
//! Raised when a message is received.
|
||||||
|
CEvent::Type messageReceived();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_connected;
|
||||||
|
CEvent::Type m_messageReceived;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CIpcClientProxyEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CIpcClientProxyEvents() :
|
||||||
|
m_messageReceived(CEvent::kUnknown),
|
||||||
|
m_disconnected(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Raised when the server receives a message from a client.
|
||||||
|
CEvent::Type messageReceived();
|
||||||
|
|
||||||
|
//! Raised when the client disconnects from the server.
|
||||||
|
CEvent::Type disconnected();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_messageReceived;
|
||||||
|
CEvent::Type m_disconnected;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CIpcServerEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CIpcServerEvents() :
|
||||||
|
m_clientConnected(CEvent::kUnknown),
|
||||||
|
m_messageReceived(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Raised when we have created the client proxy.
|
||||||
|
CEvent::Type clientConnected();
|
||||||
|
|
||||||
|
//! Raised when a message is received through a client proxy.
|
||||||
|
CEvent::Type messageReceived();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_clientConnected;
|
||||||
|
CEvent::Type m_messageReceived;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CIpcServerProxyEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CIpcServerProxyEvents() :
|
||||||
|
m_messageReceived(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Raised when the client receives a message from the server.
|
||||||
|
CEvent::Type messageReceived();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_messageReceived;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IDataSocketEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IDataSocketEvents() :
|
||||||
|
m_connected(CEvent::kUnknown),
|
||||||
|
m_connectionFailed(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get connected event type
|
||||||
|
/*!
|
||||||
|
Returns the socket connected event type. A socket sends this
|
||||||
|
event when a remote connection has been established.
|
||||||
|
*/
|
||||||
|
CEvent::Type connected();
|
||||||
|
|
||||||
|
//! Get connection failed event type
|
||||||
|
/*!
|
||||||
|
Returns the socket connection failed event type. A socket sends
|
||||||
|
this event when an attempt to connect to a remote port has failed.
|
||||||
|
The data is a pointer to a CConnectionFailedInfo.
|
||||||
|
*/
|
||||||
|
CEvent::Type connectionFailed();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_connected;
|
||||||
|
CEvent::Type m_connectionFailed;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IListenSocketEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IListenSocketEvents() :
|
||||||
|
m_connecting(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get connecting event type
|
||||||
|
/*!
|
||||||
|
Returns the socket connecting event type. A socket sends this
|
||||||
|
event when a remote connection is waiting to be accepted.
|
||||||
|
*/
|
||||||
|
CEvent::Type connecting();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_connecting;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ISocketEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
ISocketEvents() :
|
||||||
|
m_disconnected(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get disconnected event type
|
||||||
|
/*!
|
||||||
|
Returns the socket disconnected event type. A socket sends this
|
||||||
|
event when the remote side of the socket has disconnected or
|
||||||
|
shutdown both input and output.
|
||||||
|
*/
|
||||||
|
CEvent::Type disconnected();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_disconnected;
|
||||||
|
};
|
||||||
|
|
||||||
|
class COSXScreenEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
COSXScreenEvents() :
|
||||||
|
m_confirmSleep(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
CEvent::Type confirmSleep();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_confirmSleep;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CClientListenerEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CClientListenerEvents() :
|
||||||
|
m_connected(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get connected event type
|
||||||
|
/*!
|
||||||
|
Returns the connected event type. This is sent whenever a
|
||||||
|
a client connects.
|
||||||
|
*/
|
||||||
|
CEvent::Type connected();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_connected;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CClientProxyEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CClientProxyEvents() :
|
||||||
|
m_ready(CEvent::kUnknown),
|
||||||
|
m_disconnected(CEvent::kUnknown),
|
||||||
|
m_clipboardChanged(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get ready event type
|
||||||
|
/*!
|
||||||
|
Returns the ready event type. This is sent when the client has
|
||||||
|
completed the initial handshake. Until it is sent, the client is
|
||||||
|
not fully connected.
|
||||||
|
*/
|
||||||
|
CEvent::Type ready();
|
||||||
|
|
||||||
|
//! Get disconnect event type
|
||||||
|
/*!
|
||||||
|
Returns the disconnect event type. This is sent when the client
|
||||||
|
disconnects or is disconnected. The target is getEventTarget().
|
||||||
|
*/
|
||||||
|
CEvent::Type disconnected();
|
||||||
|
|
||||||
|
//! Get clipboard changed event type
|
||||||
|
/*!
|
||||||
|
Returns the clipboard changed event type. This is sent whenever the
|
||||||
|
contents of the clipboard has changed. The data is a pointer to a
|
||||||
|
IScreen::CClipboardInfo.
|
||||||
|
*/
|
||||||
|
CEvent::Type clipboardChanged();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_ready;
|
||||||
|
CEvent::Type m_disconnected;
|
||||||
|
CEvent::Type m_clipboardChanged;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CClientProxyUnknownEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CClientProxyUnknownEvents() :
|
||||||
|
m_success(CEvent::kUnknown),
|
||||||
|
m_failure(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get success event type
|
||||||
|
/*!
|
||||||
|
Returns the success event type. This is sent when the client has
|
||||||
|
correctly responded to the hello message. The target is this.
|
||||||
|
*/
|
||||||
|
CEvent::Type success();
|
||||||
|
|
||||||
|
//! Get failure event type
|
||||||
|
/*!
|
||||||
|
Returns the failure event type. This is sent when a client fails
|
||||||
|
to correctly respond to the hello message. The target is this.
|
||||||
|
*/
|
||||||
|
CEvent::Type failure();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_success;
|
||||||
|
CEvent::Type m_failure;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CServerEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CServerEvents() :
|
||||||
|
m_error(CEvent::kUnknown),
|
||||||
|
m_connected(CEvent::kUnknown),
|
||||||
|
m_disconnected(CEvent::kUnknown),
|
||||||
|
m_switchToScreen(CEvent::kUnknown),
|
||||||
|
m_switchInDirection(CEvent::kUnknown),
|
||||||
|
m_keyboardBroadcast(CEvent::kUnknown),
|
||||||
|
m_lockCursorToScreen(CEvent::kUnknown),
|
||||||
|
m_screenSwitched(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get error event type
|
||||||
|
/*!
|
||||||
|
Returns the error event type. This is sent when the server fails
|
||||||
|
for some reason.
|
||||||
|
*/
|
||||||
|
CEvent::Type error();
|
||||||
|
|
||||||
|
//! Get connected event type
|
||||||
|
/*!
|
||||||
|
Returns the connected event type. This is sent when a client screen
|
||||||
|
has connected. The event data is a \c CScreenConnectedInfo* that
|
||||||
|
indicates the connected screen.
|
||||||
|
*/
|
||||||
|
CEvent::Type connected();
|
||||||
|
|
||||||
|
//! Get disconnected event type
|
||||||
|
/*!
|
||||||
|
Returns the disconnected event type. This is sent when all the
|
||||||
|
clients have disconnected.
|
||||||
|
*/
|
||||||
|
CEvent::Type disconnected();
|
||||||
|
|
||||||
|
//! Get switch to screen event type
|
||||||
|
/*!
|
||||||
|
Returns the switch to screen event type. The server responds to this
|
||||||
|
by switching screens. The event data is a \c CSwitchToScreenInfo*
|
||||||
|
that indicates the target screen.
|
||||||
|
*/
|
||||||
|
CEvent::Type switchToScreen();
|
||||||
|
|
||||||
|
//! Get switch in direction event type
|
||||||
|
/*!
|
||||||
|
Returns the switch in direction event type. The server responds to this
|
||||||
|
by switching screens. The event data is a \c CSwitchInDirectionInfo*
|
||||||
|
that indicates the target direction.
|
||||||
|
*/
|
||||||
|
CEvent::Type switchInDirection();
|
||||||
|
|
||||||
|
//! Get keyboard broadcast event type
|
||||||
|
/*!
|
||||||
|
Returns the keyboard broadcast event type. The server responds
|
||||||
|
to this by turning on keyboard broadcasting or turning it off. The
|
||||||
|
event data is a \c CKeyboardBroadcastInfo*.
|
||||||
|
*/
|
||||||
|
CEvent::Type keyboardBroadcast();
|
||||||
|
|
||||||
|
//! Get lock cursor event type
|
||||||
|
/*!
|
||||||
|
Returns the lock cursor event type. The server responds to this
|
||||||
|
by locking the cursor to the active screen or unlocking it. The
|
||||||
|
event data is a \c CLockCursorToScreenInfo*.
|
||||||
|
*/
|
||||||
|
CEvent::Type lockCursorToScreen();
|
||||||
|
|
||||||
|
//! Get screen switched event type
|
||||||
|
/*!
|
||||||
|
Returns the screen switched event type. This is raised when the
|
||||||
|
screen has been switched to a client.
|
||||||
|
*/
|
||||||
|
CEvent::Type screenSwitched();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_error;
|
||||||
|
CEvent::Type m_connected;
|
||||||
|
CEvent::Type m_disconnected;
|
||||||
|
CEvent::Type m_switchToScreen;
|
||||||
|
CEvent::Type m_switchInDirection;
|
||||||
|
CEvent::Type m_keyboardBroadcast;
|
||||||
|
CEvent::Type m_lockCursorToScreen;
|
||||||
|
CEvent::Type m_screenSwitched;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CServerAppEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
CServerAppEvents() :
|
||||||
|
m_reloadConfig(CEvent::kUnknown),
|
||||||
|
m_forceReconnect(CEvent::kUnknown),
|
||||||
|
m_resetServer(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
CEvent::Type reloadConfig();
|
||||||
|
CEvent::Type forceReconnect();
|
||||||
|
CEvent::Type resetServer();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_reloadConfig;
|
||||||
|
CEvent::Type m_forceReconnect;
|
||||||
|
CEvent::Type m_resetServer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IKeyStateEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IKeyStateEvents() :
|
||||||
|
m_keyDown(CEvent::kUnknown),
|
||||||
|
m_keyUp(CEvent::kUnknown),
|
||||||
|
m_keyRepeat(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get key down event type. Event data is CKeyInfo*, count == 1.
|
||||||
|
CEvent::Type keyDown();
|
||||||
|
|
||||||
|
//! Get key up event type. Event data is CKeyInfo*, count == 1.
|
||||||
|
CEvent::Type keyUp();
|
||||||
|
|
||||||
|
//! Get key repeat event type. Event data is CKeyInfo*.
|
||||||
|
CEvent::Type keyRepeat();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_keyDown;
|
||||||
|
CEvent::Type m_keyUp;
|
||||||
|
CEvent::Type m_keyRepeat;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IPrimaryScreenEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IPrimaryScreenEvents() :
|
||||||
|
m_buttonDown(CEvent::kUnknown),
|
||||||
|
m_buttonUp(CEvent::kUnknown),
|
||||||
|
m_motionOnPrimary(CEvent::kUnknown),
|
||||||
|
m_motionOnSecondary(CEvent::kUnknown),
|
||||||
|
m_wheel(CEvent::kUnknown),
|
||||||
|
m_screensaverActivated(CEvent::kUnknown),
|
||||||
|
m_screensaverDeactivated(CEvent::kUnknown),
|
||||||
|
m_hotKeyDown(CEvent::kUnknown),
|
||||||
|
m_hotKeyUp(CEvent::kUnknown),
|
||||||
|
m_fakeInputBegin(CEvent::kUnknown),
|
||||||
|
m_fakeInputEnd(CEvent::kUnknown),
|
||||||
|
m_gameDeviceButtons(CEvent::kUnknown),
|
||||||
|
m_gameDeviceSticks(CEvent::kUnknown),
|
||||||
|
m_gameDeviceTriggers(CEvent::kUnknown),
|
||||||
|
m_gameDeviceTimingReq(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! button down event type. Event data is CButtonInfo*.
|
||||||
|
CEvent::Type buttonDown();
|
||||||
|
|
||||||
|
//! button up event type. Event data is CButtonInfo*.
|
||||||
|
CEvent::Type buttonUp();
|
||||||
|
|
||||||
|
//! mouse motion on the primary screen event type
|
||||||
|
/*!
|
||||||
|
Event data is CMotionInfo* and the values are an absolute position.
|
||||||
|
*/
|
||||||
|
CEvent::Type motionOnPrimary();
|
||||||
|
|
||||||
|
//! mouse motion on a secondary screen event type
|
||||||
|
/*!
|
||||||
|
Event data is CMotionInfo* and the values are motion deltas not
|
||||||
|
absolute coordinates.
|
||||||
|
*/
|
||||||
|
CEvent::Type motionOnSecondary();
|
||||||
|
|
||||||
|
//! mouse wheel event type. Event data is CWheelInfo*.
|
||||||
|
CEvent::Type wheel();
|
||||||
|
|
||||||
|
//! screensaver activated event type
|
||||||
|
CEvent::Type screensaverActivated();
|
||||||
|
|
||||||
|
//! screensaver deactivated event type
|
||||||
|
CEvent::Type screensaverDeactivated();
|
||||||
|
|
||||||
|
//! hot key down event type. Event data is CHotKeyInfo*.
|
||||||
|
CEvent::Type hotKeyDown();
|
||||||
|
|
||||||
|
//! hot key up event type. Event data is CHotKeyInfo*.
|
||||||
|
CEvent::Type hotKeyUp();
|
||||||
|
|
||||||
|
//! start of fake input event type
|
||||||
|
CEvent::Type fakeInputBegin();
|
||||||
|
|
||||||
|
//! end of fake input event type
|
||||||
|
CEvent::Type fakeInputEnd();
|
||||||
|
|
||||||
|
//! game device buttons event type.
|
||||||
|
CEvent::Type gameDeviceButtons();
|
||||||
|
|
||||||
|
//! game device sticks event type.
|
||||||
|
CEvent::Type gameDeviceSticks();
|
||||||
|
|
||||||
|
//! game device triggers event type.
|
||||||
|
CEvent::Type gameDeviceTriggers();
|
||||||
|
|
||||||
|
//! game device timing request event type.
|
||||||
|
CEvent::Type gameDeviceTimingReq();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_buttonDown;
|
||||||
|
CEvent::Type m_buttonUp;
|
||||||
|
CEvent::Type m_motionOnPrimary;
|
||||||
|
CEvent::Type m_motionOnSecondary;
|
||||||
|
CEvent::Type m_wheel;
|
||||||
|
CEvent::Type m_screensaverActivated;
|
||||||
|
CEvent::Type m_screensaverDeactivated;
|
||||||
|
CEvent::Type m_hotKeyDown;
|
||||||
|
CEvent::Type m_hotKeyUp;
|
||||||
|
CEvent::Type m_fakeInputBegin;
|
||||||
|
CEvent::Type m_fakeInputEnd;
|
||||||
|
CEvent::Type m_gameDeviceButtons;
|
||||||
|
CEvent::Type m_gameDeviceSticks;
|
||||||
|
CEvent::Type m_gameDeviceTriggers;
|
||||||
|
CEvent::Type m_gameDeviceTimingReq;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IScreenEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
IScreenEvents() :
|
||||||
|
m_error(CEvent::kUnknown),
|
||||||
|
m_shapeChanged(CEvent::kUnknown),
|
||||||
|
m_clipboardGrabbed(CEvent::kUnknown),
|
||||||
|
m_suspend(CEvent::kUnknown),
|
||||||
|
m_resume(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get error event type
|
||||||
|
/*!
|
||||||
|
Returns the error event type. This is sent whenever the screen has
|
||||||
|
failed for some reason (e.g. the X Windows server died).
|
||||||
|
*/
|
||||||
|
CEvent::Type error();
|
||||||
|
|
||||||
|
//! Get shape changed event type
|
||||||
|
/*!
|
||||||
|
Returns the shape changed event type. This is sent whenever the
|
||||||
|
screen's shape changes.
|
||||||
|
*/
|
||||||
|
CEvent::Type shapeChanged();
|
||||||
|
|
||||||
|
//! Get clipboard grabbed event type
|
||||||
|
/*!
|
||||||
|
Returns the clipboard grabbed event type. This is sent whenever the
|
||||||
|
clipboard is grabbed by some other application so we don't own it
|
||||||
|
anymore. The data is a pointer to a CClipboardInfo.
|
||||||
|
*/
|
||||||
|
CEvent::Type clipboardGrabbed();
|
||||||
|
|
||||||
|
//! Get suspend event type
|
||||||
|
/*!
|
||||||
|
Returns the suspend event type. This is sent whenever the system goes
|
||||||
|
to sleep or a user session is deactivated (fast user switching).
|
||||||
|
*/
|
||||||
|
CEvent::Type suspend();
|
||||||
|
|
||||||
|
//! Get resume event type
|
||||||
|
/*!
|
||||||
|
Returns the suspend event type. This is sent whenever the system wakes
|
||||||
|
up or a user session is activated (fast user switching).
|
||||||
|
*/
|
||||||
|
CEvent::Type resume();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_error;
|
||||||
|
CEvent::Type m_shapeChanged;
|
||||||
|
CEvent::Type m_clipboardGrabbed;
|
||||||
|
CEvent::Type m_suspend;
|
||||||
|
CEvent::Type m_resume;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ISecondaryScreenEvents : public CEventTypes {
|
||||||
|
public:
|
||||||
|
ISecondaryScreenEvents() :
|
||||||
|
m_gameDeviceTimingResp(CEvent::kUnknown),
|
||||||
|
m_gameDeviceFeedback(CEvent::kUnknown) { }
|
||||||
|
|
||||||
|
//! @name accessors
|
||||||
|
//@{
|
||||||
|
|
||||||
|
//! Get game device timing response event type.
|
||||||
|
CEvent::Type gameDeviceTimingResp();
|
||||||
|
|
||||||
|
//! Get game device feedback event type.
|
||||||
|
CEvent::Type gameDeviceFeedback();
|
||||||
|
|
||||||
|
//@}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEvent::Type m_gameDeviceTimingResp;
|
||||||
|
CEvent::Type m_gameDeviceFeedback;
|
||||||
|
};
|
|
@ -17,6 +17,7 @@
|
||||||
set(inc
|
set(inc
|
||||||
CEvent.h
|
CEvent.h
|
||||||
CEventQueue.h
|
CEventQueue.h
|
||||||
|
CEventTypes.h
|
||||||
CFunctionEventJob.h
|
CFunctionEventJob.h
|
||||||
CFunctionJob.h
|
CFunctionJob.h
|
||||||
CLog.h
|
CLog.h
|
||||||
|
@ -41,6 +42,7 @@ set(inc
|
||||||
set(src
|
set(src
|
||||||
CEvent.cpp
|
CEvent.cpp
|
||||||
CEventQueue.cpp
|
CEventQueue.cpp
|
||||||
|
CEventTypes.cpp
|
||||||
CFunctionEventJob.cpp
|
CFunctionEventJob.cpp
|
||||||
CFunctionJob.cpp
|
CFunctionJob.cpp
|
||||||
CLog.cpp
|
CLog.cpp
|
||||||
|
@ -48,7 +50,6 @@ set(src
|
||||||
CStopwatch.cpp
|
CStopwatch.cpp
|
||||||
CStringUtil.cpp
|
CStringUtil.cpp
|
||||||
CUnicode.cpp
|
CUnicode.cpp
|
||||||
IEventQueue.cpp
|
|
||||||
LogOutputters.cpp
|
LogOutputters.cpp
|
||||||
XBase.cpp
|
XBase.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* synergy -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2012 Bolton Software Ltd.
|
|
||||||
* Copyright (C) 2004 Chris Schoeneman
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file COPYING that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "IEventQueue.h"
|
|
||||||
#include "CLog.h"
|
|
||||||
|
|
||||||
#if WINAPI_CARBON
|
|
||||||
#include <execinfo.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// IEventQueue
|
|
||||||
//
|
|
||||||
|
|
||||||
static int g_systemTarget = 0;
|
|
||||||
IEventQueue* IEventQueue::s_instance = NULL;
|
|
||||||
|
|
||||||
void*
|
|
||||||
IEventQueue::getSystemTarget()
|
|
||||||
{
|
|
||||||
// any unique arbitrary pointer will do
|
|
||||||
return &g_systemTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEventQueue*
|
|
||||||
IEventQueue::getInstance()
|
|
||||||
{
|
|
||||||
if (s_instance == NULL) {
|
|
||||||
LOG((CLOG_ERR "null event queue"));
|
|
||||||
#if WINAPI_CARBON
|
|
||||||
void* callstack[128];
|
|
||||||
int i, frames = backtrace(callstack, 128);
|
|
||||||
char** strs = backtrace_symbols(callstack, frames);
|
|
||||||
for (i = 0; i < frames; ++i) {
|
|
||||||
printf("%s\n", strs[i]);
|
|
||||||
}
|
|
||||||
free(strs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
assert(s_instance != NULL);
|
|
||||||
return s_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
IEventQueue::setInstance(IEventQueue* instance)
|
|
||||||
{
|
|
||||||
assert(s_instance == NULL || instance == NULL);
|
|
||||||
s_instance = instance;
|
|
||||||
}
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
#include "CString.h"
|
#include "CString.h"
|
||||||
|
|
||||||
#define EVENTQUEUE IEventQueue::getInstance()
|
|
||||||
|
|
||||||
class IEventJob;
|
class IEventJob;
|
||||||
class IEventQueueBuffer;
|
class IEventQueueBuffer;
|
||||||
|
|
||||||
|
@ -32,6 +30,27 @@ class IEventQueueBuffer;
|
||||||
// IEventQueueBuffer.
|
// IEventQueueBuffer.
|
||||||
class CEventQueueTimer;
|
class CEventQueueTimer;
|
||||||
|
|
||||||
|
// Event type registration classes.
|
||||||
|
class CClientEvents;
|
||||||
|
class IStreamEvents;
|
||||||
|
class CIpcClientEvents;
|
||||||
|
class CIpcClientProxyEvents;
|
||||||
|
class CIpcServerEvents;
|
||||||
|
class CIpcServerProxyEvents;
|
||||||
|
class IDataSocketEvents;
|
||||||
|
class IListenSocketEvents;
|
||||||
|
class ISocketEvents;
|
||||||
|
class COSXScreenEvents;
|
||||||
|
class CClientListenerEvents;
|
||||||
|
class CClientProxyEvents;
|
||||||
|
class CClientProxyUnknownEvents;
|
||||||
|
class CServerEvents;
|
||||||
|
class CServerAppEvents;
|
||||||
|
class IKeyStateEvents;
|
||||||
|
class IPrimaryScreenEvents;
|
||||||
|
class IScreenEvents;
|
||||||
|
class ISecondaryScreenEvents;
|
||||||
|
|
||||||
//! Event queue interface
|
//! Event queue interface
|
||||||
/*!
|
/*!
|
||||||
An event queue provides a queue of CEvents. Clients can block waiting
|
An event queue provides a queue of CEvents. Clients can block waiting
|
||||||
|
@ -149,13 +168,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void removeHandlers(void* target) = 0;
|
virtual void removeHandlers(void* target) = 0;
|
||||||
|
|
||||||
//! Creates a new event type
|
|
||||||
/*!
|
|
||||||
Returns a unique event type id.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type
|
|
||||||
registerType(const char* name) = 0;
|
|
||||||
|
|
||||||
//! Creates a new event type
|
//! Creates a new event type
|
||||||
/*!
|
/*!
|
||||||
If \p type contains \c kUnknown then it is set to a unique event
|
If \p type contains \c kUnknown then it is set to a unique event
|
||||||
|
@ -201,30 +213,33 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Returns the target to use for dispatching \c CEvent::kSystem events.
|
Returns the target to use for dispatching \c CEvent::kSystem events.
|
||||||
*/
|
*/
|
||||||
static void* getSystemTarget();
|
virtual void* getSystemTarget() = 0;
|
||||||
|
|
||||||
//! Get the singleton instance
|
|
||||||
/*!
|
|
||||||
Returns the singleton instance of the event queue
|
|
||||||
*/
|
|
||||||
static IEventQueue* getInstance();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event type providers.
|
||||||
|
//
|
||||||
|
|
||||||
protected:
|
virtual CClientEvents& forCClient() = 0;
|
||||||
//! @name manipulators
|
virtual IStreamEvents& forIStream() = 0;
|
||||||
//@{
|
virtual CIpcClientEvents& forCIpcClient() = 0;
|
||||||
|
virtual CIpcClientProxyEvents& forCIpcClientProxy() = 0;
|
||||||
//! Set the singleton instance
|
virtual CIpcServerEvents& forCIpcServer() = 0;
|
||||||
/*!
|
virtual CIpcServerProxyEvents& forCIpcServerProxy() = 0;
|
||||||
Sets the singleton instance of the event queue
|
virtual IDataSocketEvents& forIDataSocket() = 0;
|
||||||
*/
|
virtual IListenSocketEvents& forIListenSocket() = 0;
|
||||||
static void setInstance(IEventQueue*);
|
virtual ISocketEvents& forISocket() = 0;
|
||||||
|
virtual COSXScreenEvents& forCOSXScreen() = 0;
|
||||||
//@}
|
virtual CClientListenerEvents& forCClientListener() = 0;
|
||||||
|
virtual CClientProxyEvents& forCClientProxy() = 0;
|
||||||
private:
|
virtual CClientProxyUnknownEvents& forCClientProxyUnknown() = 0;
|
||||||
static IEventQueue* s_instance;
|
virtual CServerEvents& forCServer() = 0;
|
||||||
|
virtual CServerAppEvents& forCServerApp() = 0;
|
||||||
|
virtual IKeyStateEvents& forIKeyState() = 0;
|
||||||
|
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||||
|
virtual IScreenEvents& forIScreen() = 0;
|
||||||
|
virtual ISecondaryScreenEvents& forISecondaryScreen() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,11 +40,7 @@
|
||||||
// CClient
|
// CClient
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type CClient::s_connectedEvent = CEvent::kUnknown;
|
CClient::CClient(IEventQueue* events,
|
||||||
CEvent::Type CClient::s_connectionFailedEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type CClient::s_disconnectedEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CClient::CClient(IEventQueue* eventQueue,
|
|
||||||
const CString& name, const CNetworkAddress& address,
|
const CString& name, const CNetworkAddress& address,
|
||||||
ISocketFactory* socketFactory,
|
ISocketFactory* socketFactory,
|
||||||
IStreamFilterFactory* streamFilterFactory,
|
IStreamFilterFactory* streamFilterFactory,
|
||||||
|
@ -63,7 +59,7 @@ CClient::CClient(IEventQueue* eventQueue,
|
||||||
m_active(false),
|
m_active(false),
|
||||||
m_suspended(false),
|
m_suspended(false),
|
||||||
m_connectOnResume(false),
|
m_connectOnResume(false),
|
||||||
m_eventQueue(eventQueue),
|
m_events(events),
|
||||||
m_cryptoStream(NULL),
|
m_cryptoStream(NULL),
|
||||||
m_crypto(crypto)
|
m_crypto(crypto)
|
||||||
{
|
{
|
||||||
|
@ -71,19 +67,19 @@ CClient::CClient(IEventQueue* eventQueue,
|
||||||
assert(m_screen != NULL);
|
assert(m_screen != NULL);
|
||||||
|
|
||||||
// register suspend/resume event handlers
|
// register suspend/resume event handlers
|
||||||
m_eventQueue->adoptHandler(IScreen::getSuspendEvent(),
|
m_events->adoptHandler(m_events->forIScreen().suspend(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleSuspend));
|
&CClient::handleSuspend));
|
||||||
m_eventQueue->adoptHandler(IScreen::getResumeEvent(),
|
m_events->adoptHandler(m_events->forIScreen().resume(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleResume));
|
&CClient::handleResume));
|
||||||
m_eventQueue->adoptHandler(IPlatformScreen::getGameDeviceTimingRespEvent(),
|
m_events->adoptHandler(m_events->forISecondaryScreen().gameDeviceTimingResp(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleGameDeviceTimingResp));
|
&CClient::handleGameDeviceTimingResp));
|
||||||
m_eventQueue->adoptHandler(IPlatformScreen::getGameDeviceFeedbackEvent(),
|
m_events->adoptHandler(m_events->forISecondaryScreen().gameDeviceFeedback(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleGameDeviceFeedback));
|
&CClient::handleGameDeviceFeedback));
|
||||||
|
@ -95,9 +91,9 @@ CClient::~CClient()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_eventQueue->removeHandler(IScreen::getSuspendEvent(),
|
m_events->removeHandler(m_events->forIScreen().suspend(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
m_eventQueue->removeHandler(IScreen::getResumeEvent(),
|
m_events->removeHandler(m_events->forIScreen().resume(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
|
|
||||||
cleanupTimer();
|
cleanupTimer();
|
||||||
|
@ -144,11 +140,11 @@ CClient::connect()
|
||||||
if (m_streamFilterFactory != NULL) {
|
if (m_streamFilterFactory != NULL) {
|
||||||
m_stream = m_streamFilterFactory->create(m_stream, true);
|
m_stream = m_streamFilterFactory->create(m_stream, true);
|
||||||
}
|
}
|
||||||
m_stream = new CPacketStreamFilter(m_stream, true);
|
m_stream = new CPacketStreamFilter(m_events, m_stream, true);
|
||||||
|
|
||||||
if (m_crypto.m_mode != kDisabled) {
|
if (m_crypto.m_mode != kDisabled) {
|
||||||
m_cryptoStream = new CCryptoStream(
|
m_cryptoStream = new CCryptoStream(
|
||||||
EVENTQUEUE, m_stream, m_crypto, true);
|
m_events, m_stream, m_crypto, true);
|
||||||
m_stream = m_cryptoStream;
|
m_stream = m_cryptoStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +177,7 @@ CClient::disconnect(const char* msg)
|
||||||
sendConnectionFailedEvent(msg);
|
sendConnectionFailedEvent(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sendEvent(getDisconnectedEvent(), NULL);
|
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +186,7 @@ CClient::handshakeComplete()
|
||||||
{
|
{
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
m_screen->enable();
|
m_screen->enable();
|
||||||
sendEvent(getConnectedEvent(), NULL);
|
sendEvent(m_events->forCClient().connected(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -219,27 +215,6 @@ CClient::getServerAddress() const
|
||||||
return m_serverAddress;
|
return m_serverAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClient::getConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
|
||||||
"CClient::connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClient::getConnectionFailedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectionFailedEvent,
|
|
||||||
"CClient::failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClient::getDisconnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
|
||||||
"CClient::disconnected");
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
CClient::getEventTarget() const
|
CClient::getEventTarget() const
|
||||||
{
|
{
|
||||||
|
@ -446,7 +421,7 @@ CClient::sendClipboard(ClipboardID id)
|
||||||
void
|
void
|
||||||
CClient::sendEvent(CEvent::Type type, void* data)
|
CClient::sendEvent(CEvent::Type type, void* data)
|
||||||
{
|
{
|
||||||
m_eventQueue->addEvent(CEvent(type, getEventTarget(), data));
|
m_events->addEvent(CEvent(type, getEventTarget(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -454,8 +429,8 @@ CClient::sendConnectionFailedEvent(const char* msg)
|
||||||
{
|
{
|
||||||
CFailInfo* info = new CFailInfo(msg);
|
CFailInfo* info = new CFailInfo(msg);
|
||||||
info->m_retry = true;
|
info->m_retry = true;
|
||||||
CEvent event(getConnectionFailedEvent(), getEventTarget(), info, CEvent::kDontFreeData);
|
CEvent event(m_events->forCClient().connectionFailed(), getEventTarget(), info, CEvent::kDontFreeData);
|
||||||
m_eventQueue->addEvent(event);
|
m_events->addEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -463,11 +438,11 @@ CClient::setupConnecting()
|
||||||
{
|
{
|
||||||
assert(m_stream != NULL);
|
assert(m_stream != NULL);
|
||||||
|
|
||||||
m_eventQueue->adoptHandler(IDataSocket::getConnectedEvent(),
|
m_events->adoptHandler(m_events->forIDataSocket().connected(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleConnected));
|
&CClient::handleConnected));
|
||||||
m_eventQueue->adoptHandler(IDataSocket::getConnectionFailedEvent(),
|
m_events->adoptHandler(m_events->forIDataSocket().connectionFailed(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleConnectionFailed));
|
&CClient::handleConnectionFailed));
|
||||||
|
@ -478,23 +453,23 @@ CClient::setupConnection()
|
||||||
{
|
{
|
||||||
assert(m_stream != NULL);
|
assert(m_stream != NULL);
|
||||||
|
|
||||||
m_eventQueue->adoptHandler(ISocket::getDisconnectedEvent(),
|
m_events->adoptHandler(m_events->forISocket().disconnected(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleDisconnected));
|
&CClient::handleDisconnected));
|
||||||
m_eventQueue->adoptHandler(m_stream->getInputReadyEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleHello));
|
&CClient::handleHello));
|
||||||
m_eventQueue->adoptHandler(m_stream->getOutputErrorEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputError(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleOutputError));
|
&CClient::handleOutputError));
|
||||||
m_eventQueue->adoptHandler(m_stream->getInputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputShutdown(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleDisconnected));
|
&CClient::handleDisconnected));
|
||||||
m_eventQueue->adoptHandler(m_stream->getOutputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputShutdown(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleDisconnected));
|
&CClient::handleDisconnected));
|
||||||
|
@ -506,12 +481,12 @@ CClient::setupScreen()
|
||||||
assert(m_server == NULL);
|
assert(m_server == NULL);
|
||||||
|
|
||||||
m_ready = false;
|
m_ready = false;
|
||||||
m_server = new CServerProxy(this, m_stream, m_eventQueue);
|
m_server = new CServerProxy(this, m_stream, m_events);
|
||||||
m_eventQueue->adoptHandler(IScreen::getShapeChangedEvent(),
|
m_events->adoptHandler(m_events->forIScreen().shapeChanged(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleShapeChanged));
|
&CClient::handleShapeChanged));
|
||||||
m_eventQueue->adoptHandler(IScreen::getClipboardGrabbedEvent(),
|
m_events->adoptHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleClipboardGrabbed));
|
&CClient::handleClipboardGrabbed));
|
||||||
|
@ -522,8 +497,8 @@ CClient::setupTimer()
|
||||||
{
|
{
|
||||||
assert(m_timer == NULL);
|
assert(m_timer == NULL);
|
||||||
|
|
||||||
m_timer = m_eventQueue->newOneShotTimer(15.0, NULL);
|
m_timer = m_events->newOneShotTimer(15.0, NULL);
|
||||||
m_eventQueue->adoptHandler(CEvent::kTimer, m_timer,
|
m_events->adoptHandler(CEvent::kTimer, m_timer,
|
||||||
new TMethodEventJob<CClient>(this,
|
new TMethodEventJob<CClient>(this,
|
||||||
&CClient::handleConnectTimeout));
|
&CClient::handleConnectTimeout));
|
||||||
}
|
}
|
||||||
|
@ -532,9 +507,9 @@ void
|
||||||
CClient::cleanupConnecting()
|
CClient::cleanupConnecting()
|
||||||
{
|
{
|
||||||
if (m_stream != NULL) {
|
if (m_stream != NULL) {
|
||||||
m_eventQueue->removeHandler(IDataSocket::getConnectedEvent(),
|
m_events->removeHandler(m_events->forIDataSocket().connected(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
m_eventQueue->removeHandler(IDataSocket::getConnectionFailedEvent(),
|
m_events->removeHandler(m_events->forIDataSocket().connectionFailed(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,15 +518,15 @@ void
|
||||||
CClient::cleanupConnection()
|
CClient::cleanupConnection()
|
||||||
{
|
{
|
||||||
if (m_stream != NULL) {
|
if (m_stream != NULL) {
|
||||||
m_eventQueue->removeHandler(m_stream->getInputReadyEvent(),
|
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
m_eventQueue->removeHandler(m_stream->getOutputErrorEvent(),
|
m_events->removeHandler(m_events->forIStream().outputError(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
m_eventQueue->removeHandler(m_stream->getInputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().inputShutdown(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
m_eventQueue->removeHandler(m_stream->getOutputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().outputShutdown(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
m_eventQueue->removeHandler(ISocket::getDisconnectedEvent(),
|
m_events->removeHandler(m_events->forISocket().disconnected(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
delete m_stream;
|
delete m_stream;
|
||||||
m_stream = NULL;
|
m_stream = NULL;
|
||||||
|
@ -566,9 +541,9 @@ CClient::cleanupScreen()
|
||||||
m_screen->disable();
|
m_screen->disable();
|
||||||
m_ready = false;
|
m_ready = false;
|
||||||
}
|
}
|
||||||
m_eventQueue->removeHandler(IScreen::getShapeChangedEvent(),
|
m_events->removeHandler(m_events->forIScreen().shapeChanged(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
m_eventQueue->removeHandler(IScreen::getClipboardGrabbedEvent(),
|
m_events->removeHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
delete m_server;
|
delete m_server;
|
||||||
m_server = NULL;
|
m_server = NULL;
|
||||||
|
@ -579,8 +554,8 @@ void
|
||||||
CClient::cleanupTimer()
|
CClient::cleanupTimer()
|
||||||
{
|
{
|
||||||
if (m_timer != NULL) {
|
if (m_timer != NULL) {
|
||||||
m_eventQueue->removeHandler(CEvent::kTimer, m_timer);
|
m_events->removeHandler(CEvent::kTimer, m_timer);
|
||||||
m_eventQueue->deleteTimer(m_timer);
|
m_events->deleteTimer(m_timer);
|
||||||
m_timer = NULL;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +609,7 @@ CClient::handleOutputError(const CEvent&, void*)
|
||||||
cleanupScreen();
|
cleanupScreen();
|
||||||
cleanupConnection();
|
cleanupConnection();
|
||||||
LOG((CLOG_WARN "error sending to server"));
|
LOG((CLOG_WARN "error sending to server"));
|
||||||
sendEvent(getDisconnectedEvent(), NULL);
|
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -644,7 +619,7 @@ CClient::handleDisconnected(const CEvent&, void*)
|
||||||
cleanupScreen();
|
cleanupScreen();
|
||||||
cleanupConnection();
|
cleanupConnection();
|
||||||
LOG((CLOG_DEBUG1 "disconnected"));
|
LOG((CLOG_DEBUG1 "disconnected"));
|
||||||
sendEvent(getDisconnectedEvent(), NULL);
|
sendEvent(m_events->forCClient().disconnected(), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -710,7 +685,7 @@ CClient::handleHello(const CEvent&, void*)
|
||||||
// receive another event for already pending messages so we fake
|
// receive another event for already pending messages so we fake
|
||||||
// one.
|
// one.
|
||||||
if (m_stream->isReady()) {
|
if (m_stream->isReady()) {
|
||||||
m_eventQueue->addEvent(CEvent(m_stream->getInputReadyEvent(),
|
m_events->addEvent(CEvent(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget()));
|
m_stream->getEventTarget()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "CNetworkAddress.h"
|
#include "CNetworkAddress.h"
|
||||||
#include "INode.h"
|
#include "INode.h"
|
||||||
#include "CCryptoOptions.h"
|
#include "CCryptoOptions.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CEventQueueTimer;
|
class CEventQueueTimer;
|
||||||
class CScreen;
|
class CScreen;
|
||||||
|
@ -54,7 +55,7 @@ public:
|
||||||
as its name and \p address as the server's address and \p factory
|
as its name and \p address as the server's address and \p factory
|
||||||
to create the socket. \p screen is the local screen.
|
to create the socket. \p screen is the local screen.
|
||||||
*/
|
*/
|
||||||
CClient(IEventQueue* eventQueue,
|
CClient(IEventQueue* events,
|
||||||
const CString& name, const CNetworkAddress& address,
|
const CString& name, const CNetworkAddress& address,
|
||||||
ISocketFactory* socketFactory,
|
ISocketFactory* socketFactory,
|
||||||
IStreamFilterFactory* streamFilterFactory,
|
IStreamFilterFactory* streamFilterFactory,
|
||||||
|
@ -63,7 +64,7 @@ public:
|
||||||
~CClient();
|
~CClient();
|
||||||
|
|
||||||
#ifdef TEST_ENV
|
#ifdef TEST_ENV
|
||||||
CClient() { }
|
CClient() : m_mock(true), m_events(NULL) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -114,29 +115,7 @@ public:
|
||||||
to connect) to.
|
to connect) to.
|
||||||
*/
|
*/
|
||||||
CNetworkAddress getServerAddress() const;
|
CNetworkAddress getServerAddress() const;
|
||||||
|
|
||||||
//! Get connected event type
|
|
||||||
/*!
|
|
||||||
Returns the connected event type. This is sent when the client has
|
|
||||||
successfully connected to the server.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectedEvent();
|
|
||||||
|
|
||||||
//! Get connection failed event type
|
|
||||||
/*!
|
|
||||||
Returns the connection failed event type. This is sent when the
|
|
||||||
server fails for some reason. The event data is a CFailInfo*.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectionFailedEvent();
|
|
||||||
|
|
||||||
//! Get disconnected event type
|
|
||||||
/*!
|
|
||||||
Returns the disconnected event type. This is sent when the client
|
|
||||||
has disconnected from the server (and only after having successfully
|
|
||||||
connected).
|
|
||||||
*/
|
|
||||||
static CEvent::Type getDisconnectedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
// IScreen overrides
|
// IScreen overrides
|
||||||
|
@ -217,13 +196,9 @@ private:
|
||||||
bool m_sentClipboard[kClipboardEnd];
|
bool m_sentClipboard[kClipboardEnd];
|
||||||
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
||||||
CString m_dataClipboard[kClipboardEnd];
|
CString m_dataClipboard[kClipboardEnd];
|
||||||
IEventQueue* m_eventQueue;
|
IEventQueue* m_events;
|
||||||
CCryptoStream* m_cryptoStream;
|
CCryptoStream* m_cryptoStream;
|
||||||
CCryptoOptions m_crypto;
|
CCryptoOptions m_crypto;
|
||||||
|
|
||||||
static CEvent::Type s_connectedEvent;
|
|
||||||
static CEvent::Type s_connectionFailedEvent;
|
|
||||||
static CEvent::Type s_disconnectedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
// CServerProxy
|
// CServerProxy
|
||||||
//
|
//
|
||||||
|
|
||||||
CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* eventQueue) :
|
CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* events) :
|
||||||
m_client(client),
|
m_client(client),
|
||||||
m_stream(stream),
|
m_stream(stream),
|
||||||
m_seqNum(0),
|
m_seqNum(0),
|
||||||
|
@ -49,7 +49,7 @@ CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueu
|
||||||
m_keepAliveAlarm(0.0),
|
m_keepAliveAlarm(0.0),
|
||||||
m_keepAliveAlarmTimer(NULL),
|
m_keepAliveAlarmTimer(NULL),
|
||||||
m_parser(&CServerProxy::parseHandshakeMessage),
|
m_parser(&CServerProxy::parseHandshakeMessage),
|
||||||
m_eventQueue(eventQueue)
|
m_events(events)
|
||||||
{
|
{
|
||||||
assert(m_client != NULL);
|
assert(m_client != NULL);
|
||||||
assert(m_stream != NULL);
|
assert(m_stream != NULL);
|
||||||
|
@ -59,7 +59,7 @@ CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueu
|
||||||
m_modifierTranslationTable[id] = id;
|
m_modifierTranslationTable[id] = id;
|
||||||
|
|
||||||
// handle data on stream
|
// handle data on stream
|
||||||
m_eventQueue->adoptHandler(m_stream->getInputReadyEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CServerProxy>(this,
|
new TMethodEventJob<CServerProxy>(this,
|
||||||
&CServerProxy::handleData));
|
&CServerProxy::handleData));
|
||||||
|
@ -71,7 +71,7 @@ CServerProxy::CServerProxy(CClient* client, synergy::IStream* stream, IEventQueu
|
||||||
CServerProxy::~CServerProxy()
|
CServerProxy::~CServerProxy()
|
||||||
{
|
{
|
||||||
setKeepAliveRate(-1.0);
|
setKeepAliveRate(-1.0);
|
||||||
m_eventQueue->removeHandler(m_stream->getInputReadyEvent(),
|
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ void
|
||||||
CServerProxy::resetKeepAliveAlarm()
|
CServerProxy::resetKeepAliveAlarm()
|
||||||
{
|
{
|
||||||
if (m_keepAliveAlarmTimer != NULL) {
|
if (m_keepAliveAlarmTimer != NULL) {
|
||||||
m_eventQueue->removeHandler(CEvent::kTimer, m_keepAliveAlarmTimer);
|
m_events->removeHandler(CEvent::kTimer, m_keepAliveAlarmTimer);
|
||||||
m_eventQueue->deleteTimer(m_keepAliveAlarmTimer);
|
m_events->deleteTimer(m_keepAliveAlarmTimer);
|
||||||
m_keepAliveAlarmTimer = NULL;
|
m_keepAliveAlarmTimer = NULL;
|
||||||
}
|
}
|
||||||
if (m_keepAliveAlarm > 0.0) {
|
if (m_keepAliveAlarm > 0.0) {
|
||||||
m_keepAliveAlarmTimer =
|
m_keepAliveAlarmTimer =
|
||||||
m_eventQueue->newOneShotTimer(m_keepAliveAlarm, NULL);
|
m_events->newOneShotTimer(m_keepAliveAlarm, NULL);
|
||||||
m_eventQueue->adoptHandler(CEvent::kTimer, m_keepAliveAlarmTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_keepAliveAlarmTimer,
|
||||||
new TMethodEventJob<CServerProxy>(this,
|
new TMethodEventJob<CServerProxy>(this,
|
||||||
&CServerProxy::handleKeepAliveAlarm));
|
&CServerProxy::handleKeepAliveAlarm));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
Process messages from the server on \p stream and forward to
|
Process messages from the server on \p stream and forward to
|
||||||
\p client.
|
\p client.
|
||||||
*/
|
*/
|
||||||
CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* eventQueue);
|
CServerProxy(CClient* client, synergy::IStream* stream, IEventQueue* events);
|
||||||
~CServerProxy();
|
~CServerProxy();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -110,7 +110,7 @@ private:
|
||||||
typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
|
typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
|
||||||
|
|
||||||
CClient* m_client;
|
CClient* m_client;
|
||||||
synergy::IStream* m_stream;
|
synergy::IStream* m_stream;
|
||||||
|
|
||||||
UInt32 m_seqNum;
|
UInt32 m_seqNum;
|
||||||
|
|
||||||
|
@ -121,13 +121,13 @@ private:
|
||||||
|
|
||||||
bool m_ignoreMouse;
|
bool m_ignoreMouse;
|
||||||
|
|
||||||
KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
|
KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
|
||||||
|
|
||||||
double m_keepAliveAlarm;
|
double m_keepAliveAlarm;
|
||||||
CEventQueueTimer* m_keepAliveAlarmTimer;
|
CEventQueueTimer* m_keepAliveAlarmTimer;
|
||||||
|
|
||||||
MessageParser m_parser;
|
MessageParser m_parser;
|
||||||
IEventQueue* m_eventQueue;
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,11 +26,11 @@ using namespace CryptoPP;
|
||||||
using namespace synergy::crypto;
|
using namespace synergy::crypto;
|
||||||
|
|
||||||
CCryptoStream::CCryptoStream(
|
CCryptoStream::CCryptoStream(
|
||||||
IEventQueue* eventQueue,
|
IEventQueue* events,
|
||||||
synergy::IStream* stream,
|
synergy::IStream* stream,
|
||||||
const CCryptoOptions& options,
|
const CCryptoOptions& options,
|
||||||
bool adoptStream) :
|
bool adoptStream) :
|
||||||
CStreamFilter(eventQueue, stream, adoptStream),
|
CStreamFilter(events, stream, adoptStream),
|
||||||
m_key(NULL),
|
m_key(NULL),
|
||||||
m_encryption(options.m_mode, true),
|
m_encryption(options.m_mode, true),
|
||||||
m_decryption(options.m_mode, false)
|
m_decryption(options.m_mode, false)
|
||||||
|
|
|
@ -33,7 +33,7 @@ Encrypts (on write) and decrypts (on read) to and from an underlying stream.
|
||||||
*/
|
*/
|
||||||
class CCryptoStream : public CStreamFilter {
|
class CCryptoStream : public CStreamFilter {
|
||||||
public:
|
public:
|
||||||
CCryptoStream(IEventQueue* eventQueue, synergy::IStream* stream, const CCryptoOptions& options, bool adoptStream = true);
|
CCryptoStream(IEventQueue* events, synergy::IStream* stream, const CCryptoOptions& options, bool adoptStream = true);
|
||||||
virtual ~CCryptoStream();
|
virtual ~CCryptoStream();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
|
@ -29,7 +29,6 @@ set(inc
|
||||||
set(src
|
set(src
|
||||||
CStreamBuffer.cpp
|
CStreamBuffer.cpp
|
||||||
CStreamFilter.cpp
|
CStreamFilter.cpp
|
||||||
IStream.cpp
|
|
||||||
XIO.cpp
|
XIO.cpp
|
||||||
CCryptoStream.cpp
|
CCryptoStream.cpp
|
||||||
CCryptoMode.cpp
|
CCryptoMode.cpp
|
||||||
|
|
|
@ -24,21 +24,22 @@
|
||||||
// CStreamFilter
|
// CStreamFilter
|
||||||
//
|
//
|
||||||
|
|
||||||
CStreamFilter::CStreamFilter(IEventQueue* eventQueue, synergy::IStream* stream, bool adoptStream) :
|
CStreamFilter::CStreamFilter(IEventQueue* events, synergy::IStream* stream, bool adoptStream) :
|
||||||
IStream(eventQueue),
|
IStream(events),
|
||||||
|
m_events(events),
|
||||||
m_stream(stream),
|
m_stream(stream),
|
||||||
m_adopted(adoptStream)
|
m_adopted(adoptStream)
|
||||||
{
|
{
|
||||||
// replace handlers for m_stream
|
// replace handlers for m_stream
|
||||||
getEventQueue().removeHandlers(m_stream->getEventTarget());
|
m_events->removeHandlers(m_stream->getEventTarget());
|
||||||
getEventQueue().adoptHandler(CEvent::kUnknown, m_stream->getEventTarget(),
|
m_events->adoptHandler(CEvent::kUnknown, m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CStreamFilter>(this,
|
new TMethodEventJob<CStreamFilter>(this,
|
||||||
&CStreamFilter::handleUpstreamEvent));
|
&CStreamFilter::handleUpstreamEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
CStreamFilter::~CStreamFilter()
|
CStreamFilter::~CStreamFilter()
|
||||||
{
|
{
|
||||||
getEventQueue().removeHandler(CEvent::kUnknown, m_stream->getEventTarget());
|
m_events->removeHandler(CEvent::kUnknown, m_stream->getEventTarget());
|
||||||
if (m_adopted) {
|
if (m_adopted) {
|
||||||
delete m_stream;
|
delete m_stream;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +108,7 @@ CStreamFilter::getStream() const
|
||||||
void
|
void
|
||||||
CStreamFilter::filterEvent(const CEvent& event)
|
CStreamFilter::filterEvent(const CEvent& event)
|
||||||
{
|
{
|
||||||
getEventQueue().dispatchEvent(CEvent(event.getType(),
|
m_events->dispatchEvent(CEvent(event.getType(),
|
||||||
getEventTarget(), event.getData()));
|
getEventTarget(), event.getData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
this object takes ownership of the stream and will delete it in the
|
this object takes ownership of the stream and will delete it in the
|
||||||
d'tor.
|
d'tor.
|
||||||
*/
|
*/
|
||||||
CStreamFilter(IEventQueue* eventQueue, synergy::IStream* stream, bool adoptStream = true);
|
CStreamFilter(IEventQueue* events, synergy::IStream* stream, bool adoptStream = true);
|
||||||
virtual ~CStreamFilter();
|
virtual ~CStreamFilter();
|
||||||
|
|
||||||
// IStream overrides
|
// IStream overrides
|
||||||
|
@ -70,6 +70,7 @@ private:
|
||||||
private:
|
private:
|
||||||
synergy::IStream* m_stream;
|
synergy::IStream* m_stream;
|
||||||
bool m_adopted;
|
bool m_adopted;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* synergy -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2012 Bolton Software Ltd.
|
|
||||||
* Copyright (C) 2004 Chris Schoeneman
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file COPYING that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "IStream.h"
|
|
||||||
#include "CEventQueue.h"
|
|
||||||
|
|
||||||
using namespace synergy;
|
|
||||||
|
|
||||||
//
|
|
||||||
// IStream
|
|
||||||
//
|
|
||||||
|
|
||||||
CEvent::Type IStream::s_inputReadyEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type IStream::s_outputFlushedEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type IStream::s_outputErrorEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type IStream::s_inputShutdownEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type IStream::s_outputShutdownEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IStream::getInputReadyEvent()
|
|
||||||
{
|
|
||||||
return m_eventQueue->registerTypeOnce(s_inputReadyEvent,
|
|
||||||
"IStream::inputReady");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IStream::getOutputFlushedEvent()
|
|
||||||
{
|
|
||||||
return m_eventQueue->registerTypeOnce(s_outputFlushedEvent,
|
|
||||||
"IStream::outputFlushed");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IStream::getOutputErrorEvent()
|
|
||||||
{
|
|
||||||
return m_eventQueue->registerTypeOnce(s_outputErrorEvent,
|
|
||||||
"IStream::outputError");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IStream::getInputShutdownEvent()
|
|
||||||
{
|
|
||||||
return m_eventQueue->registerTypeOnce(s_inputShutdownEvent,
|
|
||||||
"IStream::inputShutdown");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IStream::getOutputShutdownEvent()
|
|
||||||
{
|
|
||||||
return m_eventQueue->registerTypeOnce(s_outputShutdownEvent,
|
|
||||||
"IStream::outputShutdown");
|
|
||||||
}
|
|
||||||
|
|
||||||
IEventQueue&
|
|
||||||
IStream::getEventQueue() const
|
|
||||||
{
|
|
||||||
assert(m_eventQueue != NULL);
|
|
||||||
return *m_eventQueue;
|
|
||||||
}
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
#include "IEventQueue.h"
|
#include "IEventQueue.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class IEventQueue;
|
class IEventQueue;
|
||||||
|
|
||||||
|
@ -33,8 +34,7 @@ Defines the interface for all streams.
|
||||||
*/
|
*/
|
||||||
class IStream : public IInterface {
|
class IStream : public IInterface {
|
||||||
public:
|
public:
|
||||||
IStream() : m_eventQueue(EVENTQUEUE) { }
|
IStream(IEventQueue* events) : m_events(events) { }
|
||||||
IStream(IEventQueue* eventQueue) : m_eventQueue(eventQueue) { }
|
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
//@{
|
//@{
|
||||||
|
@ -115,60 +115,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual UInt32 getSize() const = 0;
|
virtual UInt32 getSize() const = 0;
|
||||||
|
|
||||||
//! Get input ready event type
|
|
||||||
/*!
|
|
||||||
Returns the input ready event type. A stream sends this event
|
|
||||||
when \c read() will return with data.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type getInputReadyEvent();
|
|
||||||
|
|
||||||
//! Get output flushed event type
|
|
||||||
/*!
|
|
||||||
Returns the output flushed event type. A stream sends this event
|
|
||||||
when the output buffer has been flushed. If there have been no
|
|
||||||
writes since the event was posted, calling \c shutdownOutput() or
|
|
||||||
\c close() will not discard any data and \c flush() will return
|
|
||||||
immediately.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type getOutputFlushedEvent();
|
|
||||||
|
|
||||||
//! Get output error event type
|
|
||||||
/*!
|
|
||||||
Returns the output error event type. A stream sends this event
|
|
||||||
when a write has failed.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type getOutputErrorEvent();
|
|
||||||
|
|
||||||
//! Get input shutdown event type
|
|
||||||
/*!
|
|
||||||
Returns the input shutdown event type. This is sent when the
|
|
||||||
input side of the stream has shutdown. When the input has
|
|
||||||
shutdown, no more data will ever be available to read.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type getInputShutdownEvent();
|
|
||||||
|
|
||||||
//! Get output shutdown event type
|
|
||||||
/*!
|
|
||||||
Returns the output shutdown event type. This is sent when the
|
|
||||||
output side of the stream has shutdown. When the output has
|
|
||||||
shutdown, no more data can ever be written to the stream. Any
|
|
||||||
attempt to do so will generate a output error event.
|
|
||||||
*/
|
|
||||||
virtual CEvent::Type getOutputShutdownEvent();
|
|
||||||
|
|
||||||
//! Get the event queue
|
|
||||||
IEventQueue& getEventQueue() const;
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CEvent::Type s_inputReadyEvent;
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_outputFlushedEvent;
|
|
||||||
static CEvent::Type s_outputErrorEvent;
|
|
||||||
static CEvent::Type s_inputShutdownEvent;
|
|
||||||
static CEvent::Type s_outputShutdownEvent;
|
|
||||||
|
|
||||||
IEventQueue* m_eventQueue;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,24 @@
|
||||||
#include "TMethodEventJob.h"
|
#include "TMethodEventJob.h"
|
||||||
#include "CIpcMessage.h"
|
#include "CIpcMessage.h"
|
||||||
|
|
||||||
CEvent::Type CIpcClient::s_connectedEvent = CEvent::kUnknown;
|
//
|
||||||
CEvent::Type CIpcClient::s_messageReceivedEvent = CEvent::kUnknown;
|
// CIpcClient
|
||||||
|
//
|
||||||
|
|
||||||
CIpcClient::CIpcClient() :
|
CIpcClient::CIpcClient(IEventQueue* events) :
|
||||||
m_serverAddress(CNetworkAddress(IPC_HOST, IPC_PORT)),
|
m_serverAddress(CNetworkAddress(IPC_HOST, IPC_PORT)),
|
||||||
m_server(nullptr)
|
m_server(nullptr),
|
||||||
|
m_socket(events),
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CIpcClient::CIpcClient(int port) :
|
CIpcClient::CIpcClient(IEventQueue* events, int port) :
|
||||||
m_serverAddress(CNetworkAddress(IPC_HOST, port)),
|
m_serverAddress(CNetworkAddress(IPC_HOST, port)),
|
||||||
m_server(nullptr)
|
m_server(nullptr),
|
||||||
|
m_socket(events),
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -52,16 +57,16 @@ CIpcClient::~CIpcClient()
|
||||||
void
|
void
|
||||||
CIpcClient::connect()
|
CIpcClient::connect()
|
||||||
{
|
{
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
IDataSocket::getConnectedEvent(), m_socket.getEventTarget(),
|
m_events->forIDataSocket().connected(), m_socket.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcClient>(
|
new TMethodEventJob<CIpcClient>(
|
||||||
this, &CIpcClient::handleConnected));
|
this, &CIpcClient::handleConnected));
|
||||||
|
|
||||||
m_socket.connect(m_serverAddress);
|
m_socket.connect(m_serverAddress);
|
||||||
m_server = new CIpcServerProxy(m_socket);
|
m_server = new CIpcServerProxy(m_socket, m_events);
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
CIpcServerProxy::getMessageReceivedEvent(), m_server,
|
m_events->forCIpcServerProxy().messageReceived(), m_server,
|
||||||
new TMethodEventJob<CIpcClient>(
|
new TMethodEventJob<CIpcClient>(
|
||||||
this, &CIpcClient::handleMessageReceived));
|
this, &CIpcClient::handleMessageReceived));
|
||||||
}
|
}
|
||||||
|
@ -69,8 +74,8 @@ CIpcClient::connect()
|
||||||
void
|
void
|
||||||
CIpcClient::disconnect()
|
CIpcClient::disconnect()
|
||||||
{
|
{
|
||||||
EVENTQUEUE->removeHandler(IDataSocket::getConnectedEvent(), m_socket.getEventTarget());
|
m_events->removeHandler(m_events->forIDataSocket().connected(), m_socket.getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(CIpcServerProxy::getMessageReceivedEvent(), m_server);
|
m_events->removeHandler(m_events->forCIpcServerProxy().messageReceived(), m_server);
|
||||||
|
|
||||||
m_server->disconnect();
|
m_server->disconnect();
|
||||||
delete m_server;
|
delete m_server;
|
||||||
|
@ -84,25 +89,11 @@ CIpcClient::send(const CIpcMessage& message)
|
||||||
m_server->send(message);
|
m_server->send(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcClient::getConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_connectedEvent, "CIpcClient::connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcClient::getMessageReceivedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_messageReceivedEvent, "CIpcClient::messageReceived");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CIpcClient::handleConnected(const CEvent&, void*)
|
CIpcClient::handleConnected(const CEvent&, void*)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->addEvent(CEvent(
|
m_events->addEvent(CEvent(
|
||||||
getConnectedEvent(), this, m_server, CEvent::kDontFreeData));
|
m_events->forCIpcClient().connected(), this, m_server, CEvent::kDontFreeData));
|
||||||
|
|
||||||
CIpcHelloMessage message(kIpcClientNode);
|
CIpcHelloMessage message(kIpcClientNode);
|
||||||
send(message);
|
send(message);
|
||||||
|
@ -111,7 +102,7 @@ CIpcClient::handleConnected(const CEvent&, void*)
|
||||||
void
|
void
|
||||||
CIpcClient::handleMessageReceived(const CEvent& e, void*)
|
CIpcClient::handleMessageReceived(const CEvent& e, void*)
|
||||||
{
|
{
|
||||||
CEvent event(getMessageReceivedEvent(), this);
|
CEvent event(m_events->forCIpcClient().messageReceived(), this);
|
||||||
event.setDataObject(e.getDataObject());
|
event.setDataObject(e.getDataObject());
|
||||||
EVENTQUEUE->addEvent(event);
|
m_events->addEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,11 @@
|
||||||
|
|
||||||
#include "CNetworkAddress.h"
|
#include "CNetworkAddress.h"
|
||||||
#include "CTCPSocket.h"
|
#include "CTCPSocket.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CIpcServerProxy;
|
class CIpcServerProxy;
|
||||||
class CIpcMessage;
|
class CIpcMessage;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! IPC client for communication between daemon and GUI.
|
//! IPC client for communication between daemon and GUI.
|
||||||
/*!
|
/*!
|
||||||
|
@ -30,8 +32,8 @@ class CIpcMessage;
|
||||||
*/
|
*/
|
||||||
class CIpcClient {
|
class CIpcClient {
|
||||||
public:
|
public:
|
||||||
CIpcClient();
|
CIpcClient(IEventQueue* events);
|
||||||
CIpcClient(int port);
|
CIpcClient(IEventQueue* events, int port);
|
||||||
virtual ~CIpcClient();
|
virtual ~CIpcClient();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -47,14 +49,6 @@ public:
|
||||||
void send(const CIpcMessage& message);
|
void send(const CIpcMessage& message);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
|
||||||
//@{
|
|
||||||
|
|
||||||
//! Raised when the socket is connected.
|
|
||||||
static CEvent::Type getConnectedEvent();
|
|
||||||
static CEvent::Type getMessageReceivedEvent();
|
|
||||||
|
|
||||||
//@}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
@ -65,7 +59,5 @@ private:
|
||||||
CNetworkAddress m_serverAddress;
|
CNetworkAddress m_serverAddress;
|
||||||
CTCPSocket m_socket;
|
CTCPSocket m_socket;
|
||||||
CIpcServerProxy* m_server;
|
CIpcServerProxy* m_server;
|
||||||
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_connectedEvent;
|
|
||||||
static CEvent::Type s_messageReceivedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,47 +25,49 @@
|
||||||
#include "CProtocolUtil.h"
|
#include "CProtocolUtil.h"
|
||||||
#include "CArch.h"
|
#include "CArch.h"
|
||||||
|
|
||||||
CEvent::Type CIpcClientProxy::s_messageReceivedEvent = CEvent::kUnknown;
|
//
|
||||||
CEvent::Type CIpcClientProxy::s_disconnectedEvent = CEvent::kUnknown;
|
// CIpcClientProxy
|
||||||
|
//
|
||||||
|
|
||||||
CIpcClientProxy::CIpcClientProxy(synergy::IStream& stream) :
|
CIpcClientProxy::CIpcClientProxy(synergy::IStream& stream, IEventQueue* events) :
|
||||||
m_stream(stream),
|
m_stream(stream),
|
||||||
m_clientType(kIpcClientUnknown),
|
m_clientType(kIpcClientUnknown),
|
||||||
m_disconnecting(false),
|
m_disconnecting(false),
|
||||||
m_readMutex(ARCH->newMutex()),
|
m_readMutex(ARCH->newMutex()),
|
||||||
m_writeMutex(ARCH->newMutex())
|
m_writeMutex(ARCH->newMutex()),
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
m_stream.getInputReadyEvent(), stream.getEventTarget(),
|
m_events->forIStream().inputReady(), stream.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcClientProxy>(
|
new TMethodEventJob<CIpcClientProxy>(
|
||||||
this, &CIpcClientProxy::handleData));
|
this, &CIpcClientProxy::handleData));
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
m_stream.getOutputErrorEvent(), stream.getEventTarget(),
|
m_events->forIStream().outputError(), stream.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcClientProxy>(
|
new TMethodEventJob<CIpcClientProxy>(
|
||||||
this, &CIpcClientProxy::handleWriteError));
|
this, &CIpcClientProxy::handleWriteError));
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
m_stream.getInputShutdownEvent(), stream.getEventTarget(),
|
m_events->forIStream().inputShutdown(), stream.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcClientProxy>(
|
new TMethodEventJob<CIpcClientProxy>(
|
||||||
this, &CIpcClientProxy::handleDisconnect));
|
this, &CIpcClientProxy::handleDisconnect));
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
m_stream.getOutputShutdownEvent(), stream.getEventTarget(),
|
m_events->forIStream().outputShutdown(), stream.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcClientProxy>(
|
new TMethodEventJob<CIpcClientProxy>(
|
||||||
this, &CIpcClientProxy::handleWriteError));
|
this, &CIpcClientProxy::handleWriteError));
|
||||||
}
|
}
|
||||||
|
|
||||||
CIpcClientProxy::~CIpcClientProxy()
|
CIpcClientProxy::~CIpcClientProxy()
|
||||||
{
|
{
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
m_stream.getInputReadyEvent(), m_stream.getEventTarget());
|
m_events->forIStream().inputReady(), m_stream.getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
m_stream.getOutputErrorEvent(), m_stream.getEventTarget());
|
m_events->forIStream().outputError(), m_stream.getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
m_stream.getInputShutdownEvent(), m_stream.getEventTarget());
|
m_events->forIStream().inputShutdown(), m_stream.getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
m_stream.getOutputShutdownEvent(), m_stream.getEventTarget());
|
m_events->forIStream().outputShutdown(), m_stream.getEventTarget());
|
||||||
|
|
||||||
// don't delete the stream while it's being used.
|
// don't delete the stream while it's being used.
|
||||||
ARCH->lockMutex(m_readMutex);
|
ARCH->lockMutex(m_readMutex);
|
||||||
|
@ -120,9 +122,9 @@ CIpcClientProxy::handleData(const CEvent&, void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't delete with this event; the data is passed to a new event.
|
// don't delete with this event; the data is passed to a new event.
|
||||||
CEvent e(getMessageReceivedEvent(), this, NULL, CEvent::kDontFreeData);
|
CEvent e(m_events->forCIpcClientProxy().messageReceived(), this, NULL, CEvent::kDontFreeData);
|
||||||
e.setDataObject(m);
|
e.setDataObject(m);
|
||||||
EVENTQUEUE->addEvent(e);
|
m_events->addEvent(e);
|
||||||
|
|
||||||
n = m_stream.read(code, 4);
|
n = m_stream.read(code, 4);
|
||||||
}
|
}
|
||||||
|
@ -187,19 +189,5 @@ CIpcClientProxy::disconnect()
|
||||||
LOG((CLOG_DEBUG "ipc disconnect, closing stream"));
|
LOG((CLOG_DEBUG "ipc disconnect, closing stream"));
|
||||||
m_disconnecting = true;
|
m_disconnecting = true;
|
||||||
m_stream.close();
|
m_stream.close();
|
||||||
EVENTQUEUE->addEvent(CEvent(getDisconnectedEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCIpcClientProxy().disconnected(), this));
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcClientProxy::getMessageReceivedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_messageReceivedEvent, "CIpcClientProxy::messageReceived");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcClientProxy::getDisconnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_disconnectedEvent, "CIpcClientProxy::disconnected");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,29 +21,23 @@
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
#include "Ipc.h"
|
#include "Ipc.h"
|
||||||
#include "IArchMultithread.h"
|
#include "IArchMultithread.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
namespace synergy { class IStream; }
|
namespace synergy { class IStream; }
|
||||||
class CIpcMessage;
|
class CIpcMessage;
|
||||||
class CIpcCommandMessage;
|
class CIpcCommandMessage;
|
||||||
class CIpcHelloMessage;
|
class CIpcHelloMessage;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
class CIpcClientProxy {
|
class CIpcClientProxy {
|
||||||
friend class CIpcServer;
|
friend class CIpcServer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CIpcClientProxy(synergy::IStream& stream);
|
CIpcClientProxy(synergy::IStream& stream, IEventQueue* events);
|
||||||
virtual ~CIpcClientProxy();
|
virtual ~CIpcClientProxy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Send a message to the client.
|
|
||||||
void send(const CIpcMessage& message);
|
void send(const CIpcMessage& message);
|
||||||
|
|
||||||
//! Raised when the server receives a message from a client.
|
|
||||||
static CEvent::Type getMessageReceivedEvent();
|
|
||||||
|
|
||||||
//! Raised when the client disconnects from the server.
|
|
||||||
static CEvent::Type getDisconnectedEvent();
|
|
||||||
|
|
||||||
void handleData(const CEvent&, void*);
|
void handleData(const CEvent&, void*);
|
||||||
void handleDisconnect(const CEvent&, void*);
|
void handleDisconnect(const CEvent&, void*);
|
||||||
void handleWriteError(const CEvent&, void*);
|
void handleWriteError(const CEvent&, void*);
|
||||||
|
@ -57,7 +51,5 @@ private:
|
||||||
bool m_disconnecting;
|
bool m_disconnecting;
|
||||||
CArchMutex m_readMutex;
|
CArchMutex m_readMutex;
|
||||||
CArchMutex m_writeMutex;
|
CArchMutex m_writeMutex;
|
||||||
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_messageReceivedEvent;
|
|
||||||
static CEvent::Type s_disconnectedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,17 +27,22 @@
|
||||||
#include "IDataSocket.h"
|
#include "IDataSocket.h"
|
||||||
#include "CIpcMessage.h"
|
#include "CIpcMessage.h"
|
||||||
|
|
||||||
CEvent::Type CIpcServer::s_clientConnectedEvent = CEvent::kUnknown;
|
//
|
||||||
CEvent::Type CIpcServer::s_messageReceivedEvent = CEvent::kUnknown;
|
// CIpcServer
|
||||||
|
//
|
||||||
|
|
||||||
CIpcServer::CIpcServer() :
|
CIpcServer::CIpcServer(IEventQueue* events) :
|
||||||
m_address(CNetworkAddress(IPC_HOST, IPC_PORT))
|
m_events(events),
|
||||||
|
m_socket(events),
|
||||||
|
m_address(CNetworkAddress(IPC_HOST, IPC_PORT))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CIpcServer::CIpcServer(int port) :
|
CIpcServer::CIpcServer(IEventQueue* events, int port) :
|
||||||
m_address(CNetworkAddress(IPC_HOST, port))
|
m_events(events),
|
||||||
|
m_socket(events),
|
||||||
|
m_address(CNetworkAddress(IPC_HOST, port))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -48,8 +53,8 @@ CIpcServer::init()
|
||||||
m_clientsMutex = ARCH->newMutex();
|
m_clientsMutex = ARCH->newMutex();
|
||||||
m_address.resolve();
|
m_address.resolve();
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
IListenSocket::getConnectingEvent(), &m_socket,
|
m_events->forIListenSocket().connecting(), &m_socket,
|
||||||
new TMethodEventJob<CIpcServer>(
|
new TMethodEventJob<CIpcServer>(
|
||||||
this, &CIpcServer::handleClientConnecting));
|
this, &CIpcServer::handleClientConnecting));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +70,7 @@ CIpcServer::~CIpcServer()
|
||||||
ARCH->unlockMutex(m_clientsMutex);
|
ARCH->unlockMutex(m_clientsMutex);
|
||||||
ARCH->closeMutex(m_clientsMutex);
|
ARCH->closeMutex(m_clientsMutex);
|
||||||
|
|
||||||
EVENTQUEUE->removeHandler(m_socket.getConnectingEvent(), &m_socket);
|
m_events->removeHandler(m_events->forIListenSocket().connecting(), &m_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -85,22 +90,22 @@ CIpcServer::handleClientConnecting(const CEvent&, void*)
|
||||||
LOG((CLOG_DEBUG "accepted ipc client connection"));
|
LOG((CLOG_DEBUG "accepted ipc client connection"));
|
||||||
|
|
||||||
ARCH->lockMutex(m_clientsMutex);
|
ARCH->lockMutex(m_clientsMutex);
|
||||||
CIpcClientProxy* proxy = new CIpcClientProxy(*stream);
|
CIpcClientProxy* proxy = new CIpcClientProxy(*stream, m_events);
|
||||||
m_clients.push_back(proxy);
|
m_clients.push_back(proxy);
|
||||||
ARCH->unlockMutex(m_clientsMutex);
|
ARCH->unlockMutex(m_clientsMutex);
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
CIpcClientProxy::getDisconnectedEvent(), proxy,
|
m_events->forCIpcClientProxy().disconnected(), proxy,
|
||||||
new TMethodEventJob<CIpcServer>(
|
new TMethodEventJob<CIpcServer>(
|
||||||
this, &CIpcServer::handleClientDisconnected));
|
this, &CIpcServer::handleClientDisconnected));
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
CIpcClientProxy::getMessageReceivedEvent(), proxy,
|
m_events->forCIpcClientProxy().messageReceived(), proxy,
|
||||||
new TMethodEventJob<CIpcServer>(
|
new TMethodEventJob<CIpcServer>(
|
||||||
this, &CIpcServer::handleMessageReceived));
|
this, &CIpcServer::handleMessageReceived));
|
||||||
|
|
||||||
EVENTQUEUE->addEvent(CEvent(
|
m_events->addEvent(CEvent(
|
||||||
getClientConnectedEvent(), this, proxy, CEvent::kDontFreeData));
|
m_events->forCIpcServer().clientConnected(), this, proxy, CEvent::kDontFreeData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -118,16 +123,16 @@ CIpcServer::handleClientDisconnected(const CEvent& e, void*)
|
||||||
void
|
void
|
||||||
CIpcServer::handleMessageReceived(const CEvent& e, void*)
|
CIpcServer::handleMessageReceived(const CEvent& e, void*)
|
||||||
{
|
{
|
||||||
CEvent event(getMessageReceivedEvent(), this);
|
CEvent event(m_events->forCIpcServer().messageReceived(), this);
|
||||||
event.setDataObject(e.getDataObject());
|
event.setDataObject(e.getDataObject());
|
||||||
EVENTQUEUE->addEvent(event);
|
m_events->addEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CIpcServer::deleteClient(CIpcClientProxy* proxy)
|
CIpcServer::deleteClient(CIpcClientProxy* proxy)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->removeHandler(CIpcClientProxy::getMessageReceivedEvent(), proxy);
|
m_events->removeHandler(m_events->forCIpcClientProxy().messageReceived(), proxy);
|
||||||
EVENTQUEUE->removeHandler(CIpcClientProxy::getDisconnectedEvent(), proxy);
|
m_events->removeHandler(m_events->forCIpcClientProxy().disconnected(), proxy);
|
||||||
delete proxy;
|
delete proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,20 +158,6 @@ CIpcServer::hasClients(EIpcClientType clientType) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcServer::getClientConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_clientConnectedEvent, "CIpcServer::clientConnected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcServer::getMessageReceivedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_messageReceivedEvent, "CIpcServer::messageReceived");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CIpcServer::send(const CIpcMessage& message, EIpcClientType filterType)
|
CIpcServer::send(const CIpcMessage& message, EIpcClientType filterType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,10 +23,12 @@
|
||||||
#include "Ipc.h"
|
#include "Ipc.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "CArch.h"
|
#include "CArch.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CEvent;
|
class CEvent;
|
||||||
class CIpcClientProxy;
|
class CIpcClientProxy;
|
||||||
class CIpcMessage;
|
class CIpcMessage;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! IPC server for communication between daemon and GUI.
|
//! IPC server for communication between daemon and GUI.
|
||||||
/*!
|
/*!
|
||||||
|
@ -37,8 +39,8 @@ and allows the daemon and client/server to send log data to the GUI.
|
||||||
*/
|
*/
|
||||||
class CIpcServer {
|
class CIpcServer {
|
||||||
public:
|
public:
|
||||||
CIpcServer();
|
CIpcServer(IEventQueue* events);
|
||||||
CIpcServer(int port);
|
CIpcServer(IEventQueue* events, int port);
|
||||||
virtual ~CIpcServer();
|
virtual ~CIpcServer();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -57,12 +59,6 @@ public:
|
||||||
//! Returns true when there are clients of the specified type connected.
|
//! Returns true when there are clients of the specified type connected.
|
||||||
bool hasClients(EIpcClientType clientType) const;
|
bool hasClients(EIpcClientType clientType) const;
|
||||||
|
|
||||||
//! Raised when we have created the client proxy.
|
|
||||||
static CEvent::Type getClientConnectedEvent();
|
|
||||||
|
|
||||||
//! Raised when a message is received through a client proxy.
|
|
||||||
static CEvent::Type getMessageReceivedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -79,7 +75,5 @@ private:
|
||||||
CNetworkAddress m_address;
|
CNetworkAddress m_address;
|
||||||
CClientList m_clients;
|
CClientList m_clients;
|
||||||
CArchMutex m_clientsMutex;
|
CArchMutex m_clientsMutex;
|
||||||
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_clientConnectedEvent;
|
|
||||||
static CEvent::Type s_messageReceivedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,12 +24,15 @@
|
||||||
#include "Ipc.h"
|
#include "Ipc.h"
|
||||||
#include "CProtocolUtil.h"
|
#include "CProtocolUtil.h"
|
||||||
|
|
||||||
CEvent::Type CIpcServerProxy::s_messageReceivedEvent = CEvent::kUnknown;
|
//
|
||||||
|
// CIpcServerProxy
|
||||||
|
//
|
||||||
|
|
||||||
CIpcServerProxy::CIpcServerProxy(synergy::IStream& stream) :
|
CIpcServerProxy::CIpcServerProxy(synergy::IStream& stream, IEventQueue* events) :
|
||||||
m_stream(stream)
|
m_events(events),
|
||||||
|
m_stream(stream)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->adoptHandler(m_stream.getInputReadyEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||||
stream.getEventTarget(),
|
stream.getEventTarget(),
|
||||||
new TMethodEventJob<CIpcServerProxy>(
|
new TMethodEventJob<CIpcServerProxy>(
|
||||||
this, &CIpcServerProxy::handleData));
|
this, &CIpcServerProxy::handleData));
|
||||||
|
@ -37,7 +40,7 @@ m_stream(stream)
|
||||||
|
|
||||||
CIpcServerProxy::~CIpcServerProxy()
|
CIpcServerProxy::~CIpcServerProxy()
|
||||||
{
|
{
|
||||||
EVENTQUEUE->removeHandler(m_stream.getInputReadyEvent(),
|
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream.getEventTarget());
|
m_stream.getEventTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +69,9 @@ CIpcServerProxy::handleData(const CEvent&, void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't delete with this event; the data is passed to a new event.
|
// don't delete with this event; the data is passed to a new event.
|
||||||
CEvent e(getMessageReceivedEvent(), this, NULL, CEvent::kDontFreeData);
|
CEvent e(m_events->forCIpcServerProxy().messageReceived(), this, NULL, CEvent::kDontFreeData);
|
||||||
e.setDataObject(m);
|
e.setDataObject(m);
|
||||||
EVENTQUEUE->addEvent(e);
|
m_events->addEvent(e);
|
||||||
|
|
||||||
n = m_stream.read(code, 4);
|
n = m_stream.read(code, 4);
|
||||||
}
|
}
|
||||||
|
@ -117,10 +120,3 @@ CIpcServerProxy::disconnect()
|
||||||
LOG((CLOG_DEBUG "ipc disconnect, closing stream"));
|
LOG((CLOG_DEBUG "ipc disconnect, closing stream"));
|
||||||
m_stream.close();
|
m_stream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CIpcServerProxy::getMessageReceivedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(
|
|
||||||
s_messageReceivedEvent, "CIpcServerProxy::messageReceived");
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,16 +19,18 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
namespace synergy { class IStream; }
|
namespace synergy { class IStream; }
|
||||||
class CIpcMessage;
|
class CIpcMessage;
|
||||||
class CIpcLogLineMessage;
|
class CIpcLogLineMessage;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
class CIpcServerProxy {
|
class CIpcServerProxy {
|
||||||
friend class CIpcClient;
|
friend class CIpcClient;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CIpcServerProxy(synergy::IStream& stream);
|
CIpcServerProxy(synergy::IStream& stream, IEventQueue* events);
|
||||||
virtual ~CIpcServerProxy();
|
virtual ~CIpcServerProxy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -38,11 +40,7 @@ private:
|
||||||
CIpcLogLineMessage* parseLogLine();
|
CIpcLogLineMessage* parseLogLine();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
//! Raised when the client receives a message from the server.
|
|
||||||
static CEvent::Type getMessageReceivedEvent();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
synergy::IStream& m_stream;
|
synergy::IStream& m_stream;
|
||||||
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_messageReceivedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,8 +36,6 @@ set(src
|
||||||
CTCPSocket.cpp
|
CTCPSocket.cpp
|
||||||
CTCPSocketFactory.cpp
|
CTCPSocketFactory.cpp
|
||||||
IDataSocket.cpp
|
IDataSocket.cpp
|
||||||
IListenSocket.cpp
|
|
||||||
ISocket.cpp
|
|
||||||
XSocket.cpp
|
XSocket.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
// CTCPListenSocket
|
// CTCPListenSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
CTCPListenSocket::CTCPListenSocket()
|
CTCPListenSocket::CTCPListenSocket(IEventQueue* events) :
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
m_mutex = new CMutex;
|
m_mutex = new CMutex;
|
||||||
try {
|
try {
|
||||||
|
@ -107,7 +108,7 @@ CTCPListenSocket::accept()
|
||||||
{
|
{
|
||||||
IDataSocket* socket = NULL;
|
IDataSocket* socket = NULL;
|
||||||
try {
|
try {
|
||||||
socket = new CTCPSocket(ARCH->acceptSocket(m_socket, NULL));
|
socket = new CTCPSocket(m_events, ARCH->acceptSocket(m_socket, NULL));
|
||||||
if (socket != NULL) {
|
if (socket != NULL) {
|
||||||
CSocketMultiplexer::getInstance()->addSocket(this,
|
CSocketMultiplexer::getInstance()->addSocket(this,
|
||||||
new TSocketMultiplexerMethodJob<CTCPListenSocket>(
|
new TSocketMultiplexerMethodJob<CTCPListenSocket>(
|
||||||
|
@ -139,7 +140,7 @@ CTCPListenSocket::serviceListening(ISocketMultiplexerJob* job,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (read) {
|
if (read) {
|
||||||
EVENTQUEUE->addEvent(CEvent(getConnectingEvent(), this, NULL));
|
m_events->addEvent(CEvent(m_events->forIListenSocket().connecting(), this, NULL));
|
||||||
// stop polling on this socket until the client accepts
|
// stop polling on this socket until the client accepts
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
class CMutex;
|
class CMutex;
|
||||||
class ISocketMultiplexerJob;
|
class ISocketMultiplexerJob;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! TCP listen socket
|
//! TCP listen socket
|
||||||
/*!
|
/*!
|
||||||
|
@ -31,7 +32,7 @@ A listen socket using TCP.
|
||||||
*/
|
*/
|
||||||
class CTCPListenSocket : public IListenSocket {
|
class CTCPListenSocket : public IListenSocket {
|
||||||
public:
|
public:
|
||||||
CTCPListenSocket();
|
CTCPListenSocket(IEventQueue* events);
|
||||||
~CTCPListenSocket();
|
~CTCPListenSocket();
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
|
@ -50,6 +51,7 @@ private:
|
||||||
private:
|
private:
|
||||||
CArchSocket m_socket;
|
CArchSocket m_socket;
|
||||||
CMutex* m_mutex;
|
CMutex* m_mutex;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
// CTCPSocket
|
// CTCPSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
CTCPSocket::CTCPSocket() :
|
CTCPSocket::CTCPSocket(IEventQueue* events) :
|
||||||
|
IDataSocket(events),
|
||||||
|
m_events(events),
|
||||||
m_mutex(),
|
m_mutex(),
|
||||||
m_flushed(&m_mutex, true)
|
m_flushed(&m_mutex, true)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +51,9 @@ CTCPSocket::CTCPSocket() :
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CTCPSocket::CTCPSocket(CArchSocket socket) :
|
CTCPSocket::CTCPSocket(IEventQueue* events, CArchSocket socket) :
|
||||||
|
IDataSocket(events),
|
||||||
|
m_events(events),
|
||||||
m_mutex(),
|
m_mutex(),
|
||||||
m_socket(socket),
|
m_socket(socket),
|
||||||
m_flushed(&m_mutex, true)
|
m_flushed(&m_mutex, true)
|
||||||
|
@ -96,7 +100,7 @@ CTCPSocket::close()
|
||||||
|
|
||||||
// clear buffers and enter disconnected state
|
// clear buffers and enter disconnected state
|
||||||
if (m_connected) {
|
if (m_connected) {
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
}
|
}
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
|
|
||||||
|
@ -136,7 +140,7 @@ CTCPSocket::read(void* buffer, UInt32 n)
|
||||||
|
|
||||||
// if no more data and we cannot read or write then send disconnected
|
// if no more data and we cannot read or write then send disconnected
|
||||||
if (n > 0 && m_inputBuffer.getSize() == 0 && !m_readable && !m_writable) {
|
if (n > 0 && m_inputBuffer.getSize() == 0 && !m_readable && !m_writable) {
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +156,7 @@ CTCPSocket::write(const void* buffer, UInt32 n)
|
||||||
|
|
||||||
// must not have shutdown output
|
// must not have shutdown output
|
||||||
if (!m_writable) {
|
if (!m_writable) {
|
||||||
sendEvent(getOutputErrorEvent());
|
sendEvent(m_events->forIStream().outputError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +205,7 @@ CTCPSocket::shutdownInput()
|
||||||
|
|
||||||
// shutdown buffer for reading
|
// shutdown buffer for reading
|
||||||
if (m_readable) {
|
if (m_readable) {
|
||||||
sendEvent(getInputShutdownEvent());
|
sendEvent(m_events->forIStream().inputShutdown());
|
||||||
onInputShutdown();
|
onInputShutdown();
|
||||||
useNewJob = true;
|
useNewJob = true;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +232,7 @@ CTCPSocket::shutdownOutput()
|
||||||
|
|
||||||
// shutdown buffer for writing
|
// shutdown buffer for writing
|
||||||
if (m_writable) {
|
if (m_writable) {
|
||||||
sendEvent(getOutputShutdownEvent());
|
sendEvent(m_events->forIStream().outputShutdown());
|
||||||
onOutputShutdown();
|
onOutputShutdown();
|
||||||
useNewJob = true;
|
useNewJob = true;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +270,7 @@ CTCPSocket::connect(const CNetworkAddress& addr)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (ARCH->connectSocket(m_socket, addr.getAddress())) {
|
if (ARCH->connectSocket(m_socket, addr.getAddress())) {
|
||||||
sendEvent(getConnectedEvent());
|
sendEvent(m_events->forIDataSocket().connected());
|
||||||
onConnected();
|
onConnected();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -351,14 +355,14 @@ void
|
||||||
CTCPSocket::sendConnectionFailedEvent(const char* msg)
|
CTCPSocket::sendConnectionFailedEvent(const char* msg)
|
||||||
{
|
{
|
||||||
CConnectionFailedInfo* info = new CConnectionFailedInfo(msg);
|
CConnectionFailedInfo* info = new CConnectionFailedInfo(msg);
|
||||||
EVENTQUEUE->addEvent(CEvent(getConnectionFailedEvent(),
|
m_events->addEvent(CEvent(m_events->forIDataSocket().connectionFailed(),
|
||||||
getEventTarget(), info, CEvent::kDontFreeData));
|
getEventTarget(), info, CEvent::kDontFreeData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CTCPSocket::sendEvent(CEvent::Type type)
|
CTCPSocket::sendEvent(CEvent::Type type)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), NULL));
|
m_events->addEvent(CEvent(type, getEventTarget(), NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -432,7 +436,7 @@ CTCPSocket::serviceConnecting(ISocketMultiplexerJob* job,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write) {
|
if (write) {
|
||||||
sendEvent(getConnectedEvent());
|
sendEvent(m_events->forIDataSocket().connected());
|
||||||
onConnected();
|
onConnected();
|
||||||
return newJob();
|
return newJob();
|
||||||
}
|
}
|
||||||
|
@ -447,7 +451,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
CLock lock(&m_mutex);
|
CLock lock(&m_mutex);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
return newJob();
|
return newJob();
|
||||||
}
|
}
|
||||||
|
@ -465,7 +469,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
m_outputBuffer.pop(n);
|
m_outputBuffer.pop(n);
|
||||||
if (m_outputBuffer.getSize() == 0) {
|
if (m_outputBuffer.getSize() == 0) {
|
||||||
sendEvent(getOutputFlushedEvent());
|
sendEvent(m_events->forIStream().outputFlushed());
|
||||||
m_flushed = true;
|
m_flushed = true;
|
||||||
m_flushed.broadcast();
|
m_flushed.broadcast();
|
||||||
needNewJob = true;
|
needNewJob = true;
|
||||||
|
@ -476,9 +480,9 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
// remote read end of stream hungup. our output side
|
// remote read end of stream hungup. our output side
|
||||||
// has therefore shutdown.
|
// has therefore shutdown.
|
||||||
onOutputShutdown();
|
onOutputShutdown();
|
||||||
sendEvent(getOutputShutdownEvent());
|
sendEvent(m_events->forIStream().outputShutdown());
|
||||||
if (!m_readable && m_inputBuffer.getSize() == 0) {
|
if (!m_readable && m_inputBuffer.getSize() == 0) {
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
needNewJob = true;
|
needNewJob = true;
|
||||||
|
@ -486,15 +490,15 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
catch (XArchNetworkDisconnected&) {
|
catch (XArchNetworkDisconnected&) {
|
||||||
// stream hungup
|
// stream hungup
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
needNewJob = true;
|
needNewJob = true;
|
||||||
}
|
}
|
||||||
catch (XArchNetwork& e) {
|
catch (XArchNetwork& e) {
|
||||||
// other write error
|
// other write error
|
||||||
LOG((CLOG_WARN "error writing socket: %s", e.what().c_str()));
|
LOG((CLOG_WARN "error writing socket: %s", e.what().c_str()));
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
sendEvent(getOutputErrorEvent());
|
sendEvent(m_events->forIStream().outputError());
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
needNewJob = true;
|
needNewJob = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,16 +518,16 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
|
|
||||||
// send input ready if input buffer was empty
|
// send input ready if input buffer was empty
|
||||||
if (wasEmpty) {
|
if (wasEmpty) {
|
||||||
sendEvent(getInputReadyEvent());
|
sendEvent(m_events->forIStream().inputReady());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// remote write end of stream hungup. our input side
|
// remote write end of stream hungup. our input side
|
||||||
// has therefore shutdown but don't flush our buffer
|
// has therefore shutdown but don't flush our buffer
|
||||||
// since there's still data to be read.
|
// since there's still data to be read.
|
||||||
sendEvent(getInputShutdownEvent());
|
sendEvent(m_events->forIStream().inputShutdown());
|
||||||
if (!m_writable && m_inputBuffer.getSize() == 0) {
|
if (!m_writable && m_inputBuffer.getSize() == 0) {
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
m_readable = false;
|
m_readable = false;
|
||||||
|
@ -532,7 +536,7 @@ CTCPSocket::serviceConnected(ISocketMultiplexerJob* job,
|
||||||
}
|
}
|
||||||
catch (XArchNetworkDisconnected&) {
|
catch (XArchNetworkDisconnected&) {
|
||||||
// stream hungup
|
// stream hungup
|
||||||
sendEvent(getDisconnectedEvent());
|
sendEvent(m_events->forISocket().disconnected());
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
needNewJob = true;
|
needNewJob = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
class CMutex;
|
class CMutex;
|
||||||
class CThread;
|
class CThread;
|
||||||
class ISocketMultiplexerJob;
|
class ISocketMultiplexerJob;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! TCP data socket
|
//! TCP data socket
|
||||||
/*!
|
/*!
|
||||||
|
@ -35,8 +36,8 @@ A data socket using TCP.
|
||||||
*/
|
*/
|
||||||
class CTCPSocket : public IDataSocket {
|
class CTCPSocket : public IDataSocket {
|
||||||
public:
|
public:
|
||||||
CTCPSocket();
|
CTCPSocket(IEventQueue* events);
|
||||||
CTCPSocket(CArchSocket);
|
CTCPSocket(IEventQueue* events, CArchSocket socket);
|
||||||
~CTCPSocket();
|
~CTCPSocket();
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
|
@ -85,6 +86,7 @@ private:
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
bool m_readable;
|
bool m_readable;
|
||||||
bool m_writable;
|
bool m_writable;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
// CTCPSocketFactory
|
// CTCPSocketFactory
|
||||||
//
|
//
|
||||||
|
|
||||||
CTCPSocketFactory::CTCPSocketFactory()
|
CTCPSocketFactory::CTCPSocketFactory(IEventQueue* events) :
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -37,11 +38,11 @@ CTCPSocketFactory::~CTCPSocketFactory()
|
||||||
IDataSocket*
|
IDataSocket*
|
||||||
CTCPSocketFactory::create() const
|
CTCPSocketFactory::create() const
|
||||||
{
|
{
|
||||||
return new CTCPSocket;
|
return new CTCPSocket(m_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
IListenSocket*
|
IListenSocket*
|
||||||
CTCPSocketFactory::createListen() const
|
CTCPSocketFactory::createListen() const
|
||||||
{
|
{
|
||||||
return new CTCPListenSocket;
|
return new CTCPListenSocket(m_events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,20 @@
|
||||||
|
|
||||||
#include "ISocketFactory.h"
|
#include "ISocketFactory.h"
|
||||||
|
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Socket factory for TCP sockets
|
//! Socket factory for TCP sockets
|
||||||
class CTCPSocketFactory : public ISocketFactory {
|
class CTCPSocketFactory : public ISocketFactory {
|
||||||
public:
|
public:
|
||||||
CTCPSocketFactory();
|
CTCPSocketFactory(IEventQueue* events);
|
||||||
virtual ~CTCPSocketFactory();
|
virtual ~CTCPSocketFactory();
|
||||||
|
|
||||||
// ISocketFactory overrides
|
// ISocketFactory overrides
|
||||||
virtual IDataSocket* create() const;
|
virtual IDataSocket* create() const;
|
||||||
virtual IListenSocket* createListen() const;
|
virtual IListenSocket* createListen() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,23 +23,6 @@
|
||||||
// IDataSocket
|
// IDataSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type IDataSocket::s_connectedEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type IDataSocket::s_failedEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IDataSocket::getConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
|
||||||
"IDataSocket::connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IDataSocket::getConnectionFailedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_failedEvent,
|
|
||||||
"IDataSocket::failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IDataSocket::close()
|
IDataSocket::close()
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "ISocket.h"
|
#include "ISocket.h"
|
||||||
#include "IStream.h"
|
#include "IStream.h"
|
||||||
#include "CString.h"
|
#include "CString.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
//! Data stream socket interface
|
//! Data stream socket interface
|
||||||
/*!
|
/*!
|
||||||
|
@ -36,6 +37,8 @@ public:
|
||||||
CString m_what;
|
CString m_what;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDataSocket(IEventQueue* events) : IStream(events) { }
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
@ -48,25 +51,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void connect(const CNetworkAddress&) = 0;
|
virtual void connect(const CNetworkAddress&) = 0;
|
||||||
|
|
||||||
//@}
|
|
||||||
//! @name accessors
|
|
||||||
//@{
|
|
||||||
|
|
||||||
//! Get connected event type
|
|
||||||
/*!
|
|
||||||
Returns the socket connected event type. A socket sends this
|
|
||||||
event when a remote connection has been established.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectedEvent();
|
|
||||||
|
|
||||||
//! Get connection failed event type
|
|
||||||
/*!
|
|
||||||
Returns the socket connection failed event type. A socket sends
|
|
||||||
this event when an attempt to connect to a remote port has failed.
|
|
||||||
The data is a pointer to a CConnectionFailedInfo.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectionFailedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
|
@ -86,10 +70,6 @@ public:
|
||||||
virtual void shutdownOutput() = 0;
|
virtual void shutdownOutput() = 0;
|
||||||
virtual bool isReady() const = 0;
|
virtual bool isReady() const = 0;
|
||||||
virtual UInt32 getSize() const = 0;
|
virtual UInt32 getSize() const = 0;
|
||||||
|
|
||||||
private:
|
|
||||||
static CEvent::Type s_connectedEvent;
|
|
||||||
static CEvent::Type s_failedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* synergy -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2012 Bolton Software Ltd.
|
|
||||||
* Copyright (C) 2002 Chris Schoeneman
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file COPYING that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "IListenSocket.h"
|
|
||||||
#include "CEventQueue.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// IListenSocket
|
|
||||||
//
|
|
||||||
|
|
||||||
CEvent::Type IListenSocket::s_connectingEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
IListenSocket::getConnectingEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectingEvent,
|
|
||||||
"IListenSocket::connecting");
|
|
||||||
}
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define ILISTENSOCKET_H
|
#define ILISTENSOCKET_H
|
||||||
|
|
||||||
#include "ISocket.h"
|
#include "ISocket.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class IDataSocket;
|
class IDataSocket;
|
||||||
|
|
||||||
|
@ -41,26 +42,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual IDataSocket* accept() = 0;
|
virtual IDataSocket* accept() = 0;
|
||||||
|
|
||||||
//@}
|
|
||||||
//! @name accessors
|
|
||||||
//@{
|
|
||||||
|
|
||||||
//! Get connecting event type
|
|
||||||
/*!
|
|
||||||
Returns the socket connecting event type. A socket sends this
|
|
||||||
event when a remote connection is waiting to be accepted.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectingEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
virtual void bind(const CNetworkAddress&) = 0;
|
virtual void bind(const CNetworkAddress&) = 0;
|
||||||
virtual void close() = 0;
|
virtual void close() = 0;
|
||||||
virtual void* getEventTarget() const = 0;
|
virtual void* getEventTarget() const = 0;
|
||||||
|
|
||||||
private:
|
|
||||||
static CEvent::Type s_connectingEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* synergy -- mouse and keyboard sharing utility
|
|
||||||
* Copyright (C) 2012 Bolton Software Ltd.
|
|
||||||
* Copyright (C) 2002 Chris Schoeneman
|
|
||||||
*
|
|
||||||
* This package is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* found in the file COPYING that should have accompanied this file.
|
|
||||||
*
|
|
||||||
* This package is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "ISocket.h"
|
|
||||||
#include "CEventQueue.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// ISocket
|
|
||||||
//
|
|
||||||
|
|
||||||
CEvent::Type ISocket::s_disconnectedEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
ISocket::getDisconnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
|
||||||
"ISocket::disconnected");
|
|
||||||
}
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "IInterface.h"
|
#include "IInterface.h"
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CNetworkAddress;
|
class CNetworkAddress;
|
||||||
|
|
||||||
|
@ -56,18 +57,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void* getEventTarget() const = 0;
|
virtual void* getEventTarget() const = 0;
|
||||||
|
|
||||||
//! Get disconnected event type
|
|
||||||
/*!
|
|
||||||
Returns the socket disconnected event type. A socket sends this
|
|
||||||
event when the remote side of the socket has disconnected or
|
|
||||||
shutdown both input and output.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getDisconnectedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
|
||||||
static CEvent::Type s_disconnectedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
|
|
||||||
CMSWindowsDesks::CMSWindowsDesks(
|
CMSWindowsDesks::CMSWindowsDesks(
|
||||||
bool isPrimary, bool noHooks, HINSTANCE hookLibrary,
|
bool isPrimary, bool noHooks, HINSTANCE hookLibrary,
|
||||||
const IScreenSaver* screensaver, IEventQueue& eventQueue,
|
const IScreenSaver* screensaver, IEventQueue* events,
|
||||||
IJob* updateKeys, bool stopOnDeskSwitch) :
|
IJob* updateKeys, bool stopOnDeskSwitch) :
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_noHooks(noHooks),
|
m_noHooks(noHooks),
|
||||||
|
@ -111,7 +111,7 @@ CMSWindowsDesks::CMSWindowsDesks(
|
||||||
m_mutex(),
|
m_mutex(),
|
||||||
m_deskReady(&m_mutex, false),
|
m_deskReady(&m_mutex, false),
|
||||||
m_updateKeys(updateKeys),
|
m_updateKeys(updateKeys),
|
||||||
m_eventQueue(eventQueue),
|
m_events(events),
|
||||||
m_stopOnDeskSwitch(stopOnDeskSwitch)
|
m_stopOnDeskSwitch(stopOnDeskSwitch)
|
||||||
{
|
{
|
||||||
if (hookLibrary != NULL)
|
if (hookLibrary != NULL)
|
||||||
|
@ -143,8 +143,8 @@ CMSWindowsDesks::enable()
|
||||||
// which desk is active and reinstalls the hooks as necessary.
|
// which desk is active and reinstalls the hooks as necessary.
|
||||||
// we wouldn't need this if windows notified us of a desktop
|
// we wouldn't need this if windows notified us of a desktop
|
||||||
// change but as far as i can tell it doesn't.
|
// change but as far as i can tell it doesn't.
|
||||||
m_timer = m_eventQueue.newTimer(0.2, NULL);
|
m_timer = m_events->newTimer(0.2, NULL);
|
||||||
m_eventQueue.adoptHandler(CEvent::kTimer, m_timer,
|
m_events->adoptHandler(CEvent::kTimer, m_timer,
|
||||||
new TMethodEventJob<CMSWindowsDesks>(
|
new TMethodEventJob<CMSWindowsDesks>(
|
||||||
this, &CMSWindowsDesks::handleCheckDesk));
|
this, &CMSWindowsDesks::handleCheckDesk));
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ CMSWindowsDesks::disable()
|
||||||
{
|
{
|
||||||
// remove timer
|
// remove timer
|
||||||
if (m_timer != NULL) {
|
if (m_timer != NULL) {
|
||||||
m_eventQueue.removeHandler(CEvent::kTimer, m_timer);
|
m_events->removeHandler(CEvent::kTimer, m_timer);
|
||||||
m_eventQueue.deleteTimer(m_timer);
|
m_events->deleteTimer(m_timer);
|
||||||
m_timer = NULL;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ CMSWindowsDesks::checkDesk()
|
||||||
// first switch, then shut down.
|
// first switch, then shut down.
|
||||||
if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) {
|
if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) {
|
||||||
LOG((CLOG_DEBUG "shutting down because of desk switch to \"%s\"", name.c_str()));
|
LOG((CLOG_DEBUG "shutting down because of desk switch to \"%s\"", name.c_str()));
|
||||||
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
|
m_events->addEvent(CEvent(CEvent::kQuit));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
*/
|
*/
|
||||||
CMSWindowsDesks(
|
CMSWindowsDesks(
|
||||||
bool isPrimary, bool noHooks, HINSTANCE hookLibrary,
|
bool isPrimary, bool noHooks, HINSTANCE hookLibrary,
|
||||||
const IScreenSaver* screensaver, IEventQueue& eventQueue,
|
const IScreenSaver* screensaver, IEventQueue* events,
|
||||||
IJob* updateKeys, bool stopOnDeskSwitch);
|
IJob* updateKeys, bool stopOnDeskSwitch);
|
||||||
~CMSWindowsDesks();
|
~CMSWindowsDesks();
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ private:
|
||||||
// options
|
// options
|
||||||
bool m_leaveForegroundOption;
|
bool m_leaveForegroundOption;
|
||||||
|
|
||||||
IEventQueue& m_eventQueue;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
// true if program should stop on desk switch.
|
// true if program should stop on desk switch.
|
||||||
bool m_stopOnDeskSwitch;
|
bool m_stopOnDeskSwitch;
|
||||||
|
|
|
@ -32,7 +32,8 @@ class CEventQueueTimer { };
|
||||||
// CMSWindowsEventQueueBuffer
|
// CMSWindowsEventQueueBuffer
|
||||||
//
|
//
|
||||||
|
|
||||||
CMSWindowsEventQueueBuffer::CMSWindowsEventQueueBuffer()
|
CMSWindowsEventQueueBuffer::CMSWindowsEventQueueBuffer(IEventQueue* events) :
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
// remember thread. we'll be posting messages to it.
|
// remember thread. we'll be posting messages to it.
|
||||||
m_thread = GetCurrentThreadId();
|
m_thread = GetCurrentThreadId();
|
||||||
|
@ -111,7 +112,7 @@ CMSWindowsEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event = CEvent(CEvent::kSystem,
|
event = CEvent(CEvent::kSystem,
|
||||||
IEventQueue::getSystemTarget(), &m_event);
|
m_events->getSystemTarget(), &m_event);
|
||||||
return kSystem;
|
return kSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,12 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Event queue buffer for Win32
|
//! Event queue buffer for Win32
|
||||||
class CMSWindowsEventQueueBuffer : public IEventQueueBuffer {
|
class CMSWindowsEventQueueBuffer : public IEventQueueBuffer {
|
||||||
public:
|
public:
|
||||||
CMSWindowsEventQueueBuffer();
|
CMSWindowsEventQueueBuffer(IEventQueue* events);
|
||||||
virtual ~CMSWindowsEventQueueBuffer();
|
virtual ~CMSWindowsEventQueueBuffer();
|
||||||
|
|
||||||
// IEventQueueBuffer overrides
|
// IEventQueueBuffer overrides
|
||||||
|
@ -43,6 +45,7 @@ private:
|
||||||
UINT m_userEvent;
|
UINT m_userEvent;
|
||||||
MSG m_event;
|
MSG m_event;
|
||||||
UINT m_daemonQuit;
|
UINT m_daemonQuit;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -576,7 +576,8 @@ static const CWin32Modifiers s_modifiers[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
CMSWindowsKeyState::CMSWindowsKeyState(
|
CMSWindowsKeyState::CMSWindowsKeyState(
|
||||||
CMSWindowsDesks* desks, void* eventTarget) :
|
CMSWindowsDesks* desks, void* eventTarget, IEventQueue* events) :
|
||||||
|
CKeyState(events),
|
||||||
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
||||||
m_eventTarget(eventTarget),
|
m_eventTarget(eventTarget),
|
||||||
m_desks(desks),
|
m_desks(desks),
|
||||||
|
@ -586,14 +587,14 @@ CMSWindowsKeyState::CMSWindowsKeyState(
|
||||||
m_useSavedModifiers(false),
|
m_useSavedModifiers(false),
|
||||||
m_savedModifiers(0),
|
m_savedModifiers(0),
|
||||||
m_originalSavedModifiers(0),
|
m_originalSavedModifiers(0),
|
||||||
m_eventQueue(*EVENTQUEUE)
|
m_events(events)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMSWindowsKeyState::CMSWindowsKeyState(
|
CMSWindowsKeyState::CMSWindowsKeyState(
|
||||||
CMSWindowsDesks* desks, void* eventTarget, IEventQueue& eventQueue, CKeyMap& keyMap) :
|
CMSWindowsDesks* desks, void* eventTarget, IEventQueue* events, CKeyMap& keyMap) :
|
||||||
CKeyState(eventQueue, keyMap),
|
CKeyState(events, keyMap),
|
||||||
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
||||||
m_eventTarget(eventTarget),
|
m_eventTarget(eventTarget),
|
||||||
m_desks(desks),
|
m_desks(desks),
|
||||||
|
@ -603,7 +604,7 @@ CMSWindowsKeyState::CMSWindowsKeyState(
|
||||||
m_useSavedModifiers(false),
|
m_useSavedModifiers(false),
|
||||||
m_savedModifiers(0),
|
m_savedModifiers(0),
|
||||||
m_originalSavedModifiers(0),
|
m_originalSavedModifiers(0),
|
||||||
m_eventQueue(eventQueue)
|
m_events(events)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -625,8 +626,8 @@ void
|
||||||
CMSWindowsKeyState::disable()
|
CMSWindowsKeyState::disable()
|
||||||
{
|
{
|
||||||
if (m_fixTimer != NULL) {
|
if (m_fixTimer != NULL) {
|
||||||
getEventQueue().removeHandler(CEvent::kTimer, m_fixTimer);
|
m_events->removeHandler(CEvent::kTimer, m_fixTimer);
|
||||||
getEventQueue().deleteTimer(m_fixTimer);
|
m_events->deleteTimer(m_fixTimer);
|
||||||
m_fixTimer = NULL;
|
m_fixTimer = NULL;
|
||||||
}
|
}
|
||||||
m_lastDown = 0;
|
m_lastDown = 0;
|
||||||
|
@ -1401,15 +1402,15 @@ CMSWindowsKeyState::fixKeys()
|
||||||
|
|
||||||
if (fix && m_fixTimer == NULL) {
|
if (fix && m_fixTimer == NULL) {
|
||||||
// schedule check
|
// schedule check
|
||||||
m_fixTimer = EVENTQUEUE->newTimer(0.1, NULL);
|
m_fixTimer = m_events->newTimer(0.1, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_fixTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_fixTimer,
|
||||||
new TMethodEventJob<CMSWindowsKeyState>(
|
new TMethodEventJob<CMSWindowsKeyState>(
|
||||||
this, &CMSWindowsKeyState::handleFixKeys));
|
this, &CMSWindowsKeyState::handleFixKeys));
|
||||||
}
|
}
|
||||||
else if (!fix && m_fixTimer != NULL) {
|
else if (!fix && m_fixTimer != NULL) {
|
||||||
// remove scheduled check
|
// remove scheduled check
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, m_fixTimer);
|
m_events->removeHandler(CEvent::kTimer, m_fixTimer);
|
||||||
EVENTQUEUE->deleteTimer(m_fixTimer);
|
m_events->deleteTimer(m_fixTimer);
|
||||||
m_fixTimer = NULL;
|
m_fixTimer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ This class maps KeyIDs to keystrokes.
|
||||||
*/
|
*/
|
||||||
class CMSWindowsKeyState : public CKeyState {
|
class CMSWindowsKeyState : public CKeyState {
|
||||||
public:
|
public:
|
||||||
CMSWindowsKeyState(CMSWindowsDesks* desks, void* eventTarget);
|
CMSWindowsKeyState(CMSWindowsDesks* desks, void* eventTarget, IEventQueue* events);
|
||||||
CMSWindowsKeyState(CMSWindowsDesks* desks, void* eventTarget, IEventQueue& eventQueue, CKeyMap& keyMap);
|
CMSWindowsKeyState(CMSWindowsDesks* desks, void* eventTarget, IEventQueue* events, CKeyMap& keyMap);
|
||||||
virtual ~CMSWindowsKeyState();
|
virtual ~CMSWindowsKeyState();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -195,7 +195,7 @@ private:
|
||||||
UINT m_buttonToNumpadVK[512];
|
UINT m_buttonToNumpadVK[512];
|
||||||
KeyButton m_virtualKeyToButton[256];
|
KeyButton m_virtualKeyToButton[256];
|
||||||
KeyToVKMap m_keyToVKMap;
|
KeyToVKMap m_keyToVKMap;
|
||||||
IEventQueue& m_eventQueue;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
// the timer used to check for fixing key state
|
// the timer used to check for fixing key state
|
||||||
CEventQueueTimer* m_fixTimer;
|
CEventQueueTimer* m_fixTimer;
|
||||||
|
|
|
@ -85,7 +85,9 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
bool isPrimary,
|
bool isPrimary,
|
||||||
bool noHooks,
|
bool noHooks,
|
||||||
const CGameDeviceInfo& gameDeviceInfo,
|
const CGameDeviceInfo& gameDeviceInfo,
|
||||||
bool stopOnDeskSwitch) :
|
bool stopOnDeskSwitch,
|
||||||
|
IEventQueue* events) :
|
||||||
|
CPlatformScreen(events),
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_noHooks(noHooks),
|
m_noHooks(noHooks),
|
||||||
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
m_is95Family(CArchMiscWindows::isWindows95Family()),
|
||||||
|
@ -113,7 +115,8 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0),
|
||||||
m_showingMouse(false),
|
m_showingMouse(false),
|
||||||
m_gameDeviceInfo(gameDeviceInfo),
|
m_gameDeviceInfo(gameDeviceInfo),
|
||||||
m_gameDevice(NULL)
|
m_gameDevice(NULL),
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
assert(s_windowInstance != NULL);
|
assert(s_windowInstance != NULL);
|
||||||
assert(s_screen == NULL);
|
assert(s_screen == NULL);
|
||||||
|
@ -127,11 +130,11 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
m_desks = new CMSWindowsDesks(
|
m_desks = new CMSWindowsDesks(
|
||||||
m_isPrimary, m_noHooks,
|
m_isPrimary, m_noHooks,
|
||||||
m_hookLibrary, m_screensaver,
|
m_hookLibrary, m_screensaver,
|
||||||
*EVENTQUEUE,
|
m_events,
|
||||||
new TMethodJob<CMSWindowsScreen>(this,
|
new TMethodJob<CMSWindowsScreen>(this,
|
||||||
&CMSWindowsScreen::updateKeysCB),
|
&CMSWindowsScreen::updateKeysCB),
|
||||||
stopOnDeskSwitch);
|
stopOnDeskSwitch);
|
||||||
m_keyState = new CMSWindowsKeyState(m_desks, getEventTarget());
|
m_keyState = new CMSWindowsKeyState(m_desks, getEventTarget(), m_events);
|
||||||
updateScreenShape();
|
updateScreenShape();
|
||||||
m_class = createWindowClass();
|
m_class = createWindowClass();
|
||||||
m_window = createWindow(m_class, "Synergy");
|
m_window = createWindow(m_class, "Synergy");
|
||||||
|
@ -154,12 +157,12 @@ CMSWindowsScreen::CMSWindowsScreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
// install event handlers
|
// install event handlers
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kSystem, IEventQueue::getSystemTarget(),
|
m_events->adoptHandler(CEvent::kSystem, m_events->getSystemTarget(),
|
||||||
new TMethodEventJob<CMSWindowsScreen>(this,
|
new TMethodEventJob<CMSWindowsScreen>(this,
|
||||||
&CMSWindowsScreen::handleSystemEvent));
|
&CMSWindowsScreen::handleSystemEvent));
|
||||||
|
|
||||||
// install the platform event queue
|
// install the platform event queue
|
||||||
EVENTQUEUE->adoptBuffer(new CMSWindowsEventQueueBuffer);
|
m_events->adoptBuffer(new CMSWindowsEventQueueBuffer(m_events));
|
||||||
|
|
||||||
if ((gameDeviceInfo.m_mode == CGameDeviceInfo::kGameModeXInput) &&
|
if ((gameDeviceInfo.m_mode == CGameDeviceInfo::kGameModeXInput) &&
|
||||||
(gameDeviceInfo.m_poll != CGameDeviceInfo::kGamePollDynamic))
|
(gameDeviceInfo.m_poll != CGameDeviceInfo::kGamePollDynamic))
|
||||||
|
@ -186,8 +189,8 @@ CMSWindowsScreen::~CMSWindowsScreen()
|
||||||
assert(s_screen != NULL);
|
assert(s_screen != NULL);
|
||||||
|
|
||||||
disable();
|
disable();
|
||||||
EVENTQUEUE->adoptBuffer(NULL);
|
m_events->adoptBuffer(NULL);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kSystem, IEventQueue::getSystemTarget());
|
m_events->removeHandler(CEvent::kSystem, m_events->getSystemTarget());
|
||||||
delete m_keyState;
|
delete m_keyState;
|
||||||
delete m_desks;
|
delete m_desks;
|
||||||
delete m_screensaver;
|
delete m_screensaver;
|
||||||
|
@ -224,8 +227,8 @@ CMSWindowsScreen::enable()
|
||||||
assert(m_isOnScreen == m_isPrimary);
|
assert(m_isOnScreen == m_isPrimary);
|
||||||
|
|
||||||
// we need to poll some things to fix them
|
// we need to poll some things to fix them
|
||||||
m_fixTimer = EVENTQUEUE->newTimer(1.0, NULL);
|
m_fixTimer = m_events->newTimer(1.0, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_fixTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_fixTimer,
|
||||||
new TMethodEventJob<CMSWindowsScreen>(this,
|
new TMethodEventJob<CMSWindowsScreen>(this,
|
||||||
&CMSWindowsScreen::handleFixes));
|
&CMSWindowsScreen::handleFixes));
|
||||||
|
|
||||||
|
@ -282,8 +285,8 @@ CMSWindowsScreen::disable()
|
||||||
|
|
||||||
// uninstall fix timer
|
// uninstall fix timer
|
||||||
if (m_fixTimer != NULL) {
|
if (m_fixTimer != NULL) {
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, m_fixTimer);
|
m_events->removeHandler(CEvent::kTimer, m_fixTimer);
|
||||||
EVENTQUEUE->deleteTimer(m_fixTimer);
|
m_events->deleteTimer(m_fixTimer);
|
||||||
m_fixTimer = NULL;
|
m_fixTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,8 +406,8 @@ CMSWindowsScreen::checkClipboards()
|
||||||
if (m_ownClipboard && !CMSWindowsClipboard::isOwnedBySynergy()) {
|
if (m_ownClipboard && !CMSWindowsClipboard::isOwnedBySynergy()) {
|
||||||
LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received"));
|
LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received"));
|
||||||
m_ownClipboard = false;
|
m_ownClipboard = false;
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardClipboard);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardSelection);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,7 +908,7 @@ CMSWindowsScreen::destroyWindow(HWND hwnd) const
|
||||||
void
|
void
|
||||||
CMSWindowsScreen::sendEvent(CEvent::Type type, void* data)
|
CMSWindowsScreen::sendEvent(CEvent::Type type, void* data)
|
||||||
{
|
{
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), data));
|
m_events->addEvent(CEvent(type, getEventTarget(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1051,7 +1054,7 @@ CMSWindowsScreen::onEvent(HWND, UINT msg,
|
||||||
case WM_ENDSESSION:
|
case WM_ENDSESSION:
|
||||||
if (m_is95Family) {
|
if (m_is95Family) {
|
||||||
if (wParam == TRUE && lParam == 0) {
|
if (wParam == TRUE && lParam == 0) {
|
||||||
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
|
m_events->addEvent(CEvent(CEvent::kQuit));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1084,13 +1087,13 @@ CMSWindowsScreen::onEvent(HWND, UINT msg,
|
||||||
case PBT_APMRESUMEAUTOMATIC:
|
case PBT_APMRESUMEAUTOMATIC:
|
||||||
case PBT_APMRESUMECRITICAL:
|
case PBT_APMRESUMECRITICAL:
|
||||||
case PBT_APMRESUMESUSPEND:
|
case PBT_APMRESUMESUSPEND:
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getResumeEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().resume(),
|
||||||
getEventTarget(), NULL,
|
getEventTarget(), NULL,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PBT_APMSUSPEND:
|
case PBT_APMSUSPEND:
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getSuspendEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().suspend(),
|
||||||
getEventTarget(), NULL,
|
getEventTarget(), NULL,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
break;
|
break;
|
||||||
|
@ -1296,14 +1299,14 @@ CMSWindowsScreen::onHotKey(WPARAM wParam, LPARAM lParam)
|
||||||
// ignore key repeats but it counts as a hot key
|
// ignore key repeats but it counts as a hot key
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
type = getHotKeyDownEvent();
|
type = m_events->forIPrimaryScreen().hotKeyDown();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
type = getHotKeyUpEvent();
|
type = m_events->forIPrimaryScreen().hotKeyUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate event
|
// generate event
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(),
|
m_events->addEvent(CEvent(type, getEventTarget(),
|
||||||
CHotKeyInfo::alloc(i->second)));
|
CHotKeyInfo::alloc(i->second)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1332,14 +1335,14 @@ CMSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam)
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
sendEvent(getButtonDownEvent(),
|
sendEvent(m_events->forIPrimaryScreen().buttonDown(),
|
||||||
CButtonInfo::alloc(button, mask));
|
CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
sendEvent(getButtonUpEvent(),
|
sendEvent(m_events->forIPrimaryScreen().buttonUp(),
|
||||||
CButtonInfo::alloc(button, mask));
|
CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1384,7 @@ CMSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
|
||||||
|
|
||||||
// motion on primary screen
|
// motion on primary screen
|
||||||
sendEvent(
|
sendEvent(
|
||||||
getMotionOnPrimaryEvent(),
|
m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||||
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1408,7 +1411,7 @@ CMSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// send motion
|
// send motion
|
||||||
sendEvent(getMotionOnSecondaryEvent(), CMotionInfo::alloc(x, y));
|
sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), CMotionInfo::alloc(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,7 +1424,7 @@ CMSWindowsScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta)
|
||||||
// ignore message if posted prior to last mark change
|
// ignore message if posted prior to last mark change
|
||||||
if (!ignore()) {
|
if (!ignore()) {
|
||||||
LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta));
|
LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta));
|
||||||
sendEvent(getWheelEvent(), CWheelInfo::alloc(xDelta, yDelta));
|
sendEvent(m_events->forIPrimaryScreen().wheel(), CWheelInfo::alloc(xDelta, yDelta));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1447,7 +1450,7 @@ CMSWindowsScreen::onScreensaver(bool activated)
|
||||||
if (!m_screensaverActive &&
|
if (!m_screensaverActive &&
|
||||||
m_screensaver->checkStarted(SYNERGY_MSG_SCREEN_SAVER, FALSE, 0)) {
|
m_screensaver->checkStarted(SYNERGY_MSG_SCREEN_SAVER, FALSE, 0)) {
|
||||||
m_screensaverActive = true;
|
m_screensaverActive = true;
|
||||||
sendEvent(getScreensaverActivatedEvent());
|
sendEvent(m_events->forIPrimaryScreen().screensaverActivated());
|
||||||
|
|
||||||
// enable display power down
|
// enable display power down
|
||||||
CArchMiscWindows::removeBusyState(CArchMiscWindows::kDISPLAY);
|
CArchMiscWindows::removeBusyState(CArchMiscWindows::kDISPLAY);
|
||||||
|
@ -1456,7 +1459,7 @@ CMSWindowsScreen::onScreensaver(bool activated)
|
||||||
else {
|
else {
|
||||||
if (m_screensaverActive) {
|
if (m_screensaverActive) {
|
||||||
m_screensaverActive = false;
|
m_screensaverActive = false;
|
||||||
sendEvent(getScreensaverDeactivatedEvent());
|
sendEvent(m_events->forIPrimaryScreen().screensaverDeactivated());
|
||||||
|
|
||||||
// disable display power down
|
// disable display power down
|
||||||
CArchMiscWindows::addBusyState(CArchMiscWindows::kDISPLAY);
|
CArchMiscWindows::addBusyState(CArchMiscWindows::kDISPLAY);
|
||||||
|
@ -1492,7 +1495,7 @@ CMSWindowsScreen::onDisplayChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
// send new screen info
|
// send new screen info
|
||||||
sendEvent(getShapeChangedEvent());
|
sendEvent(m_events->forIScreen().shapeChanged());
|
||||||
|
|
||||||
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : ""));
|
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : ""));
|
||||||
}
|
}
|
||||||
|
@ -1509,8 +1512,8 @@ CMSWindowsScreen::onClipboardChange()
|
||||||
if (m_ownClipboard) {
|
if (m_ownClipboard) {
|
||||||
LOG((CLOG_DEBUG "clipboard changed: lost ownership"));
|
LOG((CLOG_DEBUG "clipboard changed: lost ownership"));
|
||||||
m_ownClipboard = false;
|
m_ownClipboard = false;
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardClipboard);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardSelection);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!m_ownClipboard) {
|
else if (!m_ownClipboard) {
|
||||||
|
|
|
@ -45,7 +45,8 @@ public:
|
||||||
bool isPrimary,
|
bool isPrimary,
|
||||||
bool noHooks,
|
bool noHooks,
|
||||||
const CGameDeviceInfo &gameDevice,
|
const CGameDeviceInfo &gameDevice,
|
||||||
bool stopOnDeskSwitch);
|
bool stopOnDeskSwitch,
|
||||||
|
IEventQueue* events);
|
||||||
virtual ~CMSWindowsScreen();
|
virtual ~CMSWindowsScreen();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -214,6 +215,9 @@ private: // HACK
|
||||||
|
|
||||||
// our window proc
|
// our window proc
|
||||||
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
||||||
|
|
||||||
|
// save last position of mouse to compute next delta movement
|
||||||
|
void saveMousePosition(SInt32 x, SInt32 y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CHotKeyItem {
|
struct CHotKeyItem {
|
||||||
|
@ -329,9 +333,8 @@ private:
|
||||||
CGameDevice* m_gameDevice;
|
CGameDevice* m_gameDevice;
|
||||||
|
|
||||||
static CMSWindowsScreen* s_screen;
|
static CMSWindowsScreen* s_screen;
|
||||||
|
|
||||||
// save last position of mouse to compute next delta movement
|
IEventQueue* m_events;
|
||||||
void saveMousePosition(SInt32 x, SInt32 y);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -269,7 +269,7 @@ CMSWindowsXInput::xInputPollThread(void*)
|
||||||
LOG((CLOG_DEBUG "xinput buttons changed"));
|
LOG((CLOG_DEBUG "xinput buttons changed"));
|
||||||
|
|
||||||
// xinput buttons convert exactly to synergy buttons
|
// xinput buttons convert exactly to synergy buttons
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceButtonsEvent(),
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceButtons(),
|
||||||
new IPrimaryScreen::CGameDeviceButtonInfo(index, state.Gamepad.wButtons));
|
new IPrimaryScreen::CGameDeviceButtonInfo(index, state.Gamepad.wButtons));
|
||||||
|
|
||||||
eventSent = true;
|
eventSent = true;
|
||||||
|
@ -279,7 +279,7 @@ CMSWindowsXInput::xInputPollThread(void*)
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG "xinput sticks changed"));
|
LOG((CLOG_DEBUG "xinput sticks changed"));
|
||||||
|
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceSticksEvent(),
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceSticks(),
|
||||||
new IPrimaryScreen::CGameDeviceStickInfo(
|
new IPrimaryScreen::CGameDeviceStickInfo(
|
||||||
index,
|
index,
|
||||||
m_gameLeftStickXLast, m_gameLeftStickYLast,
|
m_gameLeftStickXLast, m_gameLeftStickYLast,
|
||||||
|
@ -293,7 +293,7 @@ CMSWindowsXInput::xInputPollThread(void*)
|
||||||
LOG((CLOG_DEBUG "xinput triggers changed"));
|
LOG((CLOG_DEBUG "xinput triggers changed"));
|
||||||
|
|
||||||
// @todo seems wrong re-using x/y for a single value...
|
// @todo seems wrong re-using x/y for a single value...
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceTriggersEvent(),
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceTriggers(),
|
||||||
new IPrimaryScreen::CGameDeviceTriggerInfo(
|
new IPrimaryScreen::CGameDeviceTriggerInfo(
|
||||||
index,
|
index,
|
||||||
state.Gamepad.bLeftTrigger,
|
state.Gamepad.bLeftTrigger,
|
||||||
|
@ -304,7 +304,7 @@ CMSWindowsXInput::xInputPollThread(void*)
|
||||||
|
|
||||||
if (/*eventSent && */!m_gameTimingWaiting && (ARCH->time() - m_gameLastTimingSent > .5))
|
if (/*eventSent && */!m_gameTimingWaiting && (ARCH->time() - m_gameLastTimingSent > .5))
|
||||||
{
|
{
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceTimingReqEvent(), NULL);
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceTimingReq(), NULL);
|
||||||
m_gameLastTimingSent = ARCH->time();
|
m_gameLastTimingSent = ARCH->time();
|
||||||
m_gameTimingWaiting = true;
|
m_gameTimingWaiting = true;
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ CMSWindowsXInput::xInputTimingThread(void*)
|
||||||
if (DequeueXInputTimingResp())
|
if (DequeueXInputTimingResp())
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG "dequeued game device timing response"));
|
LOG((CLOG_DEBUG "dequeued game device timing response"));
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceTimingRespEvent(),
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceTimingResp(),
|
||||||
new IPrimaryScreen::CGameDeviceTimingRespInfo(GetXInputFakeFreqMillis()));
|
new IPrimaryScreen::CGameDeviceTimingRespInfo(GetXInputFakeFreqMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ CMSWindowsXInput::xInputFeedbackThread(void*)
|
||||||
if (DequeueXInputFeedback(&leftMotor, &rightMotor))
|
if (DequeueXInputFeedback(&leftMotor, &rightMotor))
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG "dequeued game device feedback"));
|
LOG((CLOG_DEBUG "dequeued game device feedback"));
|
||||||
m_screen->sendEvent(m_screen->getGameDeviceFeedbackEvent(),
|
m_screen->sendEvent(m_events->forIScreen().gameDeviceFeedback(),
|
||||||
new IPrimaryScreen::CGameDeviceFeedbackInfo(index, leftMotor, rightMotor));
|
new IPrimaryScreen::CGameDeviceFeedbackInfo(index, leftMotor, rightMotor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ COSXEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
event = CEvent(CEvent::kSystem,
|
event = CEvent(CEvent::kSystem,
|
||||||
IEventQueue::getSystemTarget(), &m_event);
|
m_events->getSystemTarget(), &m_event);
|
||||||
return kSystem;
|
return kSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,14 +180,14 @@ static const CKeyEntry s_controlKeys[] = {
|
||||||
// COSXKeyState
|
// COSXKeyState
|
||||||
//
|
//
|
||||||
|
|
||||||
COSXKeyState::COSXKeyState() :
|
COSXKeyState::COSXKeyState(IEventQueue* events) :
|
||||||
m_deadKeyState(0)
|
m_deadKeyState(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
COSXKeyState::COSXKeyState(IEventQueue& eventQueue, CKeyMap& keyMap) :
|
COSXKeyState::COSXKeyState(IEventQueue* events, CKeyMap& keyMap) :
|
||||||
CKeyState(eventQueue, keyMap),
|
CKeyState(events, keyMap),
|
||||||
m_deadKeyState(0)
|
m_deadKeyState(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
|
@ -39,8 +39,8 @@ class COSXKeyState : public CKeyState {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<KeyID> CKeyIDs;
|
typedef std::vector<KeyID> CKeyIDs;
|
||||||
|
|
||||||
COSXKeyState();
|
COSXKeyState(IEventQueue* events);
|
||||||
COSXKeyState(IEventQueue& eventQueue, CKeyMap& keyMap);
|
COSXKeyState(IEventQueue* events, CKeyMap& keyMap);
|
||||||
virtual ~COSXKeyState();
|
virtual ~COSXKeyState();
|
||||||
|
|
||||||
//! @name modifiers
|
//! @name modifiers
|
||||||
|
|
|
@ -61,11 +61,8 @@ enum {
|
||||||
// COSXScreen
|
// COSXScreen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool COSXScreen::s_testedForGHOM = false;
|
bool COSXScreen::s_testedForGHOM = false;
|
||||||
bool COSXScreen::s_hasGHOM = false;
|
bool COSXScreen::s_hasGHOM = false;
|
||||||
CEvent::Type COSXScreen::s_confirmSleepEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) :
|
COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) :
|
||||||
MouseButtonEventMap(NumButtonIDs),
|
MouseButtonEventMap(NumButtonIDs),
|
||||||
|
@ -134,7 +131,7 @@ COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) :
|
||||||
constructMouseButtonEventMap();
|
constructMouseButtonEventMap();
|
||||||
|
|
||||||
// watch for requests to sleep
|
// watch for requests to sleep
|
||||||
EVENTQUEUE->adoptHandler(COSXScreen::getConfirmSleepEvent(),
|
m_events->adoptHandler(m_events->forCOSXScreen().confirmSleep(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
new TMethodEventJob<COSXScreen>(this,
|
new TMethodEventJob<COSXScreen>(this,
|
||||||
&COSXScreen::handleConfirmSleep));
|
&COSXScreen::handleConfirmSleep));
|
||||||
|
@ -146,7 +143,7 @@ COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) :
|
||||||
(this, &COSXScreen::watchSystemPowerThread));
|
(this, &COSXScreen::watchSystemPowerThread));
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
EVENTQUEUE->removeHandler(COSXScreen::getConfirmSleepEvent(),
|
m_events->removeHandler(m_events->forCOSXScreen().confirmSleep(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
if (m_switchEventHandlerRef != 0) {
|
if (m_switchEventHandlerRef != 0) {
|
||||||
RemoveEventHandler(m_switchEventHandlerRef);
|
RemoveEventHandler(m_switchEventHandlerRef);
|
||||||
|
@ -176,19 +173,19 @@ COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// install event handlers
|
// install event handlers
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kSystem, IEventQueue::getSystemTarget(),
|
m_events->adoptHandler(CEvent::kSystem, m_events->getSystemTarget(),
|
||||||
new TMethodEventJob<COSXScreen>(this,
|
new TMethodEventJob<COSXScreen>(this,
|
||||||
&COSXScreen::handleSystemEvent));
|
&COSXScreen::handleSystemEvent));
|
||||||
|
|
||||||
// install the platform event queue
|
// install the platform event queue
|
||||||
EVENTQUEUE->adoptBuffer(new COSXEventQueueBuffer);
|
m_events->adoptBuffer(new COSXEventQueueBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
COSXScreen::~COSXScreen()
|
COSXScreen::~COSXScreen()
|
||||||
{
|
{
|
||||||
disable();
|
disable();
|
||||||
EVENTQUEUE->adoptBuffer(NULL);
|
m_events->adoptBuffer(NULL);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kSystem, IEventQueue::getSystemTarget());
|
m_events->removeHandler(CEvent::kSystem, m_events->getSystemTarget());
|
||||||
|
|
||||||
if (m_pmWatchThread) {
|
if (m_pmWatchThread) {
|
||||||
// make sure the thread has setup the runloop.
|
// make sure the thread has setup the runloop.
|
||||||
|
@ -209,7 +206,7 @@ COSXScreen::~COSXScreen()
|
||||||
delete m_pmThreadReady;
|
delete m_pmThreadReady;
|
||||||
delete m_pmMutex;
|
delete m_pmMutex;
|
||||||
|
|
||||||
EVENTQUEUE->removeHandler(COSXScreen::getConfirmSleepEvent(),
|
m_events->removeHandler(m_events->forCOSXScreen().confirmSleep(),
|
||||||
getEventTarget());
|
getEventTarget());
|
||||||
|
|
||||||
RemoveEventHandler(m_switchEventHandlerRef);
|
RemoveEventHandler(m_switchEventHandlerRef);
|
||||||
|
@ -707,8 +704,8 @@ void
|
||||||
COSXScreen::enable()
|
COSXScreen::enable()
|
||||||
{
|
{
|
||||||
// watch the clipboard
|
// watch the clipboard
|
||||||
m_clipboardTimer = EVENTQUEUE->newTimer(1.0, NULL);
|
m_clipboardTimer = m_events->newTimer(1.0, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_clipboardTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_clipboardTimer,
|
||||||
new TMethodEventJob<COSXScreen>(this,
|
new TMethodEventJob<COSXScreen>(this,
|
||||||
&COSXScreen::handleClipboardCheck));
|
&COSXScreen::handleClipboardCheck));
|
||||||
|
|
||||||
|
@ -778,8 +775,8 @@ COSXScreen::disable()
|
||||||
|
|
||||||
// uninstall clipboard timer
|
// uninstall clipboard timer
|
||||||
if (m_clipboardTimer != NULL) {
|
if (m_clipboardTimer != NULL) {
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, m_clipboardTimer);
|
m_events->removeHandler(CEvent::kTimer, m_clipboardTimer);
|
||||||
EVENTQUEUE->deleteTimer(m_clipboardTimer);
|
m_events->deleteTimer(m_clipboardTimer);
|
||||||
m_clipboardTimer = NULL;
|
m_clipboardTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,8 +862,8 @@ COSXScreen::checkClipboards()
|
||||||
LOG((CLOG_DEBUG2 "checking clipboard"));
|
LOG((CLOG_DEBUG2 "checking clipboard"));
|
||||||
if (m_pasteboard.synchronize()) {
|
if (m_pasteboard.synchronize()) {
|
||||||
LOG((CLOG_DEBUG "clipboard changed"));
|
LOG((CLOG_DEBUG "clipboard changed"));
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardClipboard);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardClipboard);
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), kClipboardSelection);
|
sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), kClipboardSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +922,7 @@ COSXScreen::isPrimary() const
|
||||||
void
|
void
|
||||||
COSXScreen::sendEvent(CEvent::Type type, void* data) const
|
COSXScreen::sendEvent(CEvent::Type type, void* data) const
|
||||||
{
|
{
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), data));
|
m_events->addEvent(CEvent(type, getEventTarget(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1039,7 +1036,7 @@ COSXScreen::onMouseMove(SInt32 mx, SInt32 my)
|
||||||
|
|
||||||
if (m_isOnScreen) {
|
if (m_isOnScreen) {
|
||||||
// motion on primary screen
|
// motion on primary screen
|
||||||
sendEvent(getMotionOnPrimaryEvent(),
|
sendEvent(m_events->forIScreen().motionOnPrimary(),
|
||||||
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1061,7 +1058,7 @@ COSXScreen::onMouseMove(SInt32 mx, SInt32 my)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// send motion
|
// send motion
|
||||||
sendEvent(getMotionOnSecondaryEvent(), CMotionInfo::alloc(x, y));
|
sendEvent(m_events->forIScreen().motionOnSecondary(), CMotionInfo::alloc(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,14 +1075,14 @@ COSXScreen::onMouseButton(bool pressed, UInt16 macButton)
|
||||||
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button press button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
KeyModifierMask mask = m_keyState->getActiveModifiers();
|
KeyModifierMask mask = m_keyState->getActiveModifiers();
|
||||||
sendEvent(getButtonDownEvent(), CButtonInfo::alloc(button, mask));
|
sendEvent(m_events->forIPrimaryScreen().buttonDown(), CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
LOG((CLOG_DEBUG1 "event: button release button=%d", button));
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
KeyModifierMask mask = m_keyState->getActiveModifiers();
|
KeyModifierMask mask = m_keyState->getActiveModifiers();
|
||||||
sendEvent(getButtonUpEvent(), CButtonInfo::alloc(button, mask));
|
sendEvent(m_events->forIPrimaryScreen().buttonUp(), CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1112,7 +1109,7 @@ bool
|
||||||
COSXScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
COSXScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta) const
|
||||||
{
|
{
|
||||||
LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta));
|
LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta));
|
||||||
sendEvent(getWheelEvent(), CWheelInfo::alloc(xDelta, yDelta));
|
sendEvent(m_events->forIPrimaryScreen().wheel(), CWheelInfo::alloc(xDelta, yDelta));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1152,7 +1149,7 @@ COSXScreen::onDisplayChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
// send new screen info
|
// send new screen info
|
||||||
sendEvent(getShapeChangedEvent());
|
sendEvent(m_events->forIPrimaryScreen().shapeChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1204,7 +1201,7 @@ COSXScreen::onKey(CGEventRef event)
|
||||||
if (m_modifierHotKeys.count(newMask) > 0) {
|
if (m_modifierHotKeys.count(newMask) > 0) {
|
||||||
m_activeModifierHotKey = m_modifierHotKeys[newMask];
|
m_activeModifierHotKey = m_modifierHotKeys[newMask];
|
||||||
m_activeModifierHotKeyMask = newMask;
|
m_activeModifierHotKeyMask = newMask;
|
||||||
EVENTQUEUE->addEvent(CEvent(getHotKeyDownEvent(),
|
m_events->addEvent(CEvent(m_events->forIPrimaryScreen().hotKeyDown(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
CHotKeyInfo::alloc(m_activeModifierHotKey)));
|
CHotKeyInfo::alloc(m_activeModifierHotKey)));
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1212,7 @@ COSXScreen::onKey(CGEventRef event)
|
||||||
else if (m_activeModifierHotKey != 0) {
|
else if (m_activeModifierHotKey != 0) {
|
||||||
KeyModifierMask mask = (newMask & m_activeModifierHotKeyMask);
|
KeyModifierMask mask = (newMask & m_activeModifierHotKeyMask);
|
||||||
if (mask != m_activeModifierHotKeyMask) {
|
if (mask != m_activeModifierHotKeyMask) {
|
||||||
EVENTQUEUE->addEvent(CEvent(getHotKeyUpEvent(),
|
m_events->addEvent(CEvent(m_events->forIPrimaryScreen().hotKeyUp(),
|
||||||
getEventTarget(),
|
getEventTarget(),
|
||||||
CHotKeyInfo::alloc(m_activeModifierHotKey)));
|
CHotKeyInfo::alloc(m_activeModifierHotKey)));
|
||||||
m_activeModifierHotKey = 0;
|
m_activeModifierHotKey = 0;
|
||||||
|
@ -1242,16 +1239,16 @@ COSXScreen::onKey(CGEventRef event)
|
||||||
CEvent::Type type;
|
CEvent::Type type;
|
||||||
//UInt32 eventKind = GetEventKind(event);
|
//UInt32 eventKind = GetEventKind(event);
|
||||||
if (eventKind == kCGEventKeyDown) {
|
if (eventKind == kCGEventKeyDown) {
|
||||||
type = getHotKeyDownEvent();
|
type = m_events->forIPrimaryScreen().hotKeyDown();
|
||||||
}
|
}
|
||||||
else if (eventKind == kCGEventKeyUp) {
|
else if (eventKind == kCGEventKeyUp) {
|
||||||
type = getHotKeyUpEvent();
|
type = m_events->forIPrimaryScreen().hotKeyUp();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(),
|
m_events->addEvent(CEvent(type, getEventTarget(),
|
||||||
CHotKeyInfo::alloc(id)));
|
CHotKeyInfo::alloc(id)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1315,16 +1312,16 @@ COSXScreen::onHotKey(EventRef event) const
|
||||||
CEvent::Type type;
|
CEvent::Type type;
|
||||||
UInt32 eventKind = GetEventKind(event);
|
UInt32 eventKind = GetEventKind(event);
|
||||||
if (eventKind == kEventHotKeyPressed) {
|
if (eventKind == kEventHotKeyPressed) {
|
||||||
type = getHotKeyDownEvent();
|
type = m_events->forIPrimaryScreen().hotKeyDown();
|
||||||
}
|
}
|
||||||
else if (eventKind == kEventHotKeyReleased) {
|
else if (eventKind == kEventHotKeyReleased) {
|
||||||
type = getHotKeyUpEvent();
|
type = m_events->forIPrimaryScreen().hotKeyUp();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTQUEUE->addEvent(CEvent(type, getEventTarget(),
|
m_events->addEvent(CEvent(type, getEventTarget(),
|
||||||
CHotKeyInfo::alloc(id)));
|
CHotKeyInfo::alloc(id)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1403,15 +1400,15 @@ COSXScreen::enableDragTimer(bool enable)
|
||||||
MouseTrackingResult res;
|
MouseTrackingResult res;
|
||||||
|
|
||||||
if (enable && m_dragTimer == NULL) {
|
if (enable && m_dragTimer == NULL) {
|
||||||
m_dragTimer = EVENTQUEUE->newTimer(0.01, NULL);
|
m_dragTimer = m_events->newTimer(0.01, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_dragTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_dragTimer,
|
||||||
new TMethodEventJob<COSXScreen>(this,
|
new TMethodEventJob<COSXScreen>(this,
|
||||||
&COSXScreen::handleDrag));
|
&COSXScreen::handleDrag));
|
||||||
TrackMouseLocationWithOptions(NULL, 0, 0, &m_dragLastPoint, &modifiers, &res);
|
TrackMouseLocationWithOptions(NULL, 0, 0, &m_dragLastPoint, &modifiers, &res);
|
||||||
}
|
}
|
||||||
else if (!enable && m_dragTimer != NULL) {
|
else if (!enable && m_dragTimer != NULL) {
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, m_dragTimer);
|
m_events->removeHandler(CEvent::kTimer, m_dragTimer);
|
||||||
EVENTQUEUE->deleteTimer(m_dragTimer);
|
m_events->deleteTimer(m_dragTimer);
|
||||||
m_dragTimer = NULL;
|
m_dragTimer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1497,7 +1494,7 @@ COSXScreen::updateScreenShape()
|
||||||
|
|
||||||
delete[] displays;
|
delete[] displays;
|
||||||
// We want to notify the peer screen whether we are primary screen or not
|
// We want to notify the peer screen whether we are primary screen or not
|
||||||
sendEvent(getShapeChangedEvent());
|
sendEvent(m_events->forIPrimaryScreen().shapeChanged());
|
||||||
|
|
||||||
LOG((CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s",
|
LOG((CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s",
|
||||||
m_x, m_y, m_w, m_h, displayCount,
|
m_x, m_y, m_w, m_h, displayCount,
|
||||||
|
@ -1524,12 +1521,12 @@ COSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler,
|
||||||
|
|
||||||
if (kind == kEventSystemUserSessionDeactivated) {
|
if (kind == kEventSystemUserSessionDeactivated) {
|
||||||
LOG((CLOG_DEBUG "user session deactivated"));
|
LOG((CLOG_DEBUG "user session deactivated"));
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getSuspendEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().suspend(),
|
||||||
screen->getEventTarget()));
|
screen->getEventTarget()));
|
||||||
}
|
}
|
||||||
else if (kind == kEventSystemUserSessionActivated) {
|
else if (kind == kEventSystemUserSessionActivated) {
|
||||||
LOG((CLOG_DEBUG "user session activated"));
|
LOG((CLOG_DEBUG "user session activated"));
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getResumeEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().resume(),
|
||||||
screen->getEventTarget()));
|
screen->getEventTarget()));
|
||||||
}
|
}
|
||||||
return (CallNextEventHandler(nextHandler, theEvent));
|
return (CallNextEventHandler(nextHandler, theEvent));
|
||||||
|
@ -1614,14 +1611,14 @@ COSXScreen::handlePowerChangeRequest(natural_t messageType, void* messageArg)
|
||||||
// COSXScreen has to handle this in the main thread so we have to
|
// COSXScreen has to handle this in the main thread so we have to
|
||||||
// queue a confirm sleep event here. we actually don't allow the
|
// queue a confirm sleep event here. we actually don't allow the
|
||||||
// system to sleep until the event is handled.
|
// system to sleep until the event is handled.
|
||||||
EVENTQUEUE->addEvent(CEvent(COSXScreen::getConfirmSleepEvent(),
|
m_events->addEvent(CEvent(m_events->forCOSXScreen().confirmSleep(),
|
||||||
getEventTarget(), messageArg,
|
getEventTarget(), messageArg,
|
||||||
CEvent::kDontFreeData));
|
CEvent::kDontFreeData));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case kIOMessageSystemHasPoweredOn:
|
case kIOMessageSystemHasPoweredOn:
|
||||||
LOG((CLOG_DEBUG "system wakeup"));
|
LOG((CLOG_DEBUG "system wakeup"));
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getResumeEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().resume(),
|
||||||
getEventTarget()));
|
getEventTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1635,13 +1632,6 @@ COSXScreen::handlePowerChangeRequest(natural_t messageType, void* messageArg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
COSXScreen::getConfirmSleepEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_confirmSleepEvent,
|
|
||||||
"COSXScreen::confirmSleep");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
COSXScreen::handleConfirmSleep(const CEvent& event, void*)
|
COSXScreen::handleConfirmSleep(const CEvent& event, void*)
|
||||||
{
|
{
|
||||||
|
@ -1650,7 +1640,7 @@ COSXScreen::handleConfirmSleep(const CEvent& event, void*)
|
||||||
CLock lock(m_pmMutex);
|
CLock lock(m_pmMutex);
|
||||||
if (m_pmRootPort != 0) {
|
if (m_pmRootPort != 0) {
|
||||||
// deliver suspend event immediately.
|
// deliver suspend event immediately.
|
||||||
EVENTQUEUE->addEvent(CEvent(IScreen::getSuspendEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().suspend(),
|
||||||
getEventTarget(), NULL,
|
getEventTarget(), NULL,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#include "COSXClipboard.h"
|
#include "COSXClipboard.h"
|
||||||
#include "CPlatformScreen.h"
|
#include "CPlatformScreen.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
#include <mach/mach_port.h>
|
#include <mach/mach_port.h>
|
||||||
#include <mach/mach_interface.h>
|
#include <mach/mach_interface.h>
|
||||||
|
@ -181,7 +182,6 @@ private:
|
||||||
void handlePowerChangeRequest(natural_t messageType,
|
void handlePowerChangeRequest(natural_t messageType,
|
||||||
void* messageArgument);
|
void* messageArgument);
|
||||||
|
|
||||||
static CEvent::Type getConfirmSleepEvent();
|
|
||||||
void handleConfirmSleep(const CEvent& event, void*);
|
void handleConfirmSleep(const CEvent& event, void*);
|
||||||
|
|
||||||
// global hotkey operating mode
|
// global hotkey operating mode
|
||||||
|
@ -322,9 +322,6 @@ private:
|
||||||
// global hotkey operating mode
|
// global hotkey operating mode
|
||||||
static bool s_testedForGHOM;
|
static bool s_testedForGHOM;
|
||||||
static bool s_hasGHOM;
|
static bool s_hasGHOM;
|
||||||
|
|
||||||
// events
|
|
||||||
static CEvent::Type s_confirmSleepEvent;
|
|
||||||
|
|
||||||
// Quartz input event support
|
// Quartz input event support
|
||||||
CFMachPortRef m_eventTapPort;
|
CFMachPortRef m_eventTapPort;
|
||||||
|
|
|
@ -125,8 +125,8 @@ COSXScreenSaver::processLaunched(ProcessSerialNumber psn)
|
||||||
m_screenSaverPSN = psn;
|
m_screenSaverPSN = psn;
|
||||||
LOG((CLOG_DEBUG1 "ScreenSaverEngine launched. Enabled=%d", m_enabled));
|
LOG((CLOG_DEBUG1 "ScreenSaverEngine launched. Enabled=%d", m_enabled));
|
||||||
if (m_enabled) {
|
if (m_enabled) {
|
||||||
EVENTQUEUE->addEvent(
|
m_events->addEvent(
|
||||||
CEvent(IPrimaryScreen::getScreensaverActivatedEvent(),
|
CEvent(m_events->forIPrimaryScreen().screensaverActivated(),
|
||||||
m_eventTarget));
|
m_eventTarget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,8 @@ COSXScreenSaver::processTerminated(ProcessSerialNumber psn)
|
||||||
m_screenSaverPSN.lowLongOfPSN == psn.lowLongOfPSN) {
|
m_screenSaverPSN.lowLongOfPSN == psn.lowLongOfPSN) {
|
||||||
LOG((CLOG_DEBUG1 "ScreenSaverEngine terminated. Enabled=%d", m_enabled));
|
LOG((CLOG_DEBUG1 "ScreenSaverEngine terminated. Enabled=%d", m_enabled));
|
||||||
if (m_enabled) {
|
if (m_enabled) {
|
||||||
EVENTQUEUE->addEvent(
|
m_events->addEvent(
|
||||||
CEvent(IPrimaryScreen::getScreensaverDeactivatedEvent(),
|
CEvent(m_events->forIPrimaryScreen().screensaverDeactivated(),
|
||||||
m_eventTarget));
|
m_eventTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ CXWindowsEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event = CEvent(CEvent::kSystem,
|
event = CEvent(CEvent::kSystem,
|
||||||
IEventQueue::getSystemTarget(), &m_event);
|
m_events->getSystemTarget(), &m_event);
|
||||||
return kSystem;
|
return kSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ CXWindowsKeyState::CXWindowsKeyState(Display* display, bool useXKB) :
|
||||||
|
|
||||||
CXWindowsKeyState::CXWindowsKeyState(
|
CXWindowsKeyState::CXWindowsKeyState(
|
||||||
Display* display, bool useXKB,
|
Display* display, bool useXKB,
|
||||||
IEventQueue& eventQueue, CKeyMap& keyMap) :
|
IEventQueue* events, CKeyMap& keyMap) :
|
||||||
CKeyState(eventQueue, keyMap),
|
CKeyState(events, keyMap),
|
||||||
m_display(display),
|
m_display(display),
|
||||||
m_modifierFromX(ModifiersFromXDefaultSize)
|
m_modifierFromX(ModifiersFromXDefaultSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
CXWindowsKeyState(Display*, bool useXKB);
|
CXWindowsKeyState(Display*, bool useXKB);
|
||||||
CXWindowsKeyState(Display*, bool useXKB,
|
CXWindowsKeyState(Display*, bool useXKB,
|
||||||
IEventQueue& eventQueue, CKeyMap& keyMap);
|
IEventQueue* events, CKeyMap& keyMap);
|
||||||
~CXWindowsKeyState();
|
~CXWindowsKeyState();
|
||||||
|
|
||||||
//! @name modifiers
|
//! @name modifiers
|
||||||
|
|
|
@ -88,7 +88,7 @@ static int xi_opcode;
|
||||||
|
|
||||||
CXWindowsScreen* CXWindowsScreen::s_screen = NULL;
|
CXWindowsScreen* CXWindowsScreen::s_screen = NULL;
|
||||||
|
|
||||||
CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue& eventQueue) :
|
CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue* events) :
|
||||||
m_isPrimary(isPrimary),
|
m_isPrimary(isPrimary),
|
||||||
m_mouseScrollDelta(mouseScrollDelta),
|
m_mouseScrollDelta(mouseScrollDelta),
|
||||||
m_display(NULL),
|
m_display(NULL),
|
||||||
|
@ -113,8 +113,8 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||||
m_xkb(false),
|
m_xkb(false),
|
||||||
m_xi2detected(false),
|
m_xi2detected(false),
|
||||||
m_xrandr(false),
|
m_xrandr(false),
|
||||||
m_eventQueue(eventQueue),
|
m_events(events),
|
||||||
CPlatformScreen(eventQueue)
|
CPlatformScreen(events)
|
||||||
{
|
{
|
||||||
assert(s_screen == NULL);
|
assert(s_screen == NULL);
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||||
saveShape();
|
saveShape();
|
||||||
m_window = openWindow();
|
m_window = openWindow();
|
||||||
m_screensaver = new CXWindowsScreenSaver(m_display,
|
m_screensaver = new CXWindowsScreenSaver(m_display,
|
||||||
m_window, getEventTarget(), eventQueue);
|
m_window, getEventTarget(), events);
|
||||||
m_keyState = new CXWindowsKeyState(m_display, m_xkb, eventQueue, m_keyMap);
|
m_keyState = new CXWindowsKeyState(m_display, m_xkb, events, m_keyMap);
|
||||||
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : ""));
|
LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : ""));
|
||||||
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||||
}
|
}
|
||||||
|
@ -154,15 +154,15 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// start watching for events on other windows
|
// start watching for events on other windows
|
||||||
selectEvents(m_root);
|
selectEvents(m_root);
|
||||||
m_xi2detected = detectXI2();
|
m_xi2detected = detectXI2();
|
||||||
|
|
||||||
if (m_xi2detected) {
|
if (m_xi2detected) {
|
||||||
#ifdef HAVE_XI2
|
#ifdef HAVE_XI2
|
||||||
selectXIRawMotion();
|
selectXIRawMotion();
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// start watching for events on other windows
|
// start watching for events on other windows
|
||||||
selectEvents(m_root);
|
selectEvents(m_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,12 +180,12 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||||
}
|
}
|
||||||
|
|
||||||
// install event handlers
|
// install event handlers
|
||||||
m_eventQueue.adoptHandler(CEvent::kSystem, IEventQueue::getSystemTarget(),
|
m_events->adoptHandler(CEvent::kSystem, m_events->getSystemTarget(),
|
||||||
new TMethodEventJob<CXWindowsScreen>(this,
|
new TMethodEventJob<CXWindowsScreen>(this,
|
||||||
&CXWindowsScreen::handleSystemEvent));
|
&CXWindowsScreen::handleSystemEvent));
|
||||||
|
|
||||||
// install the platform event queue
|
// install the platform event queue
|
||||||
m_eventQueue.adoptBuffer(new CXWindowsEventQueueBuffer(m_display, m_window));
|
m_events->adoptBuffer(new CXWindowsEventQueueBuffer(m_display, m_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsScreen::~CXWindowsScreen()
|
CXWindowsScreen::~CXWindowsScreen()
|
||||||
|
@ -193,8 +193,8 @@ CXWindowsScreen::~CXWindowsScreen()
|
||||||
assert(s_screen != NULL);
|
assert(s_screen != NULL);
|
||||||
assert(m_display != NULL);
|
assert(m_display != NULL);
|
||||||
|
|
||||||
m_eventQueue.adoptBuffer(NULL);
|
m_events->adoptBuffer(NULL);
|
||||||
m_eventQueue.removeHandler(CEvent::kSystem, IEventQueue::getSystemTarget());
|
m_events->removeHandler(CEvent::kSystem, m_events->getSystemTarget());
|
||||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||||
delete m_clipboard[id];
|
delete m_clipboard[id];
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ CXWindowsScreen::openIM()
|
||||||
void
|
void
|
||||||
CXWindowsScreen::sendEvent(CEvent::Type type, void* data)
|
CXWindowsScreen::sendEvent(CEvent::Type type, void* data)
|
||||||
{
|
{
|
||||||
m_eventQueue.addEvent(CEvent(type, getEventTarget(), data));
|
m_events->addEvent(CEvent(type, getEventTarget(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1229,13 +1229,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
else if (xevent->type == KeyRelease &&
|
else if (xevent->type == KeyRelease &&
|
||||||
xevent->xkey.keycode == m_lastKeycode) {
|
xevent->xkey.keycode == m_lastKeycode) {
|
||||||
m_lastKeycode = 0;
|
m_lastKeycode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now filter the event
|
// now filter the event
|
||||||
if (XFilterEvent(xevent, DefaultRootWindow(m_display))) {
|
if (XFilterEvent(xevent, DefaultRootWindow(m_display))) {
|
||||||
if (xevent->type == KeyPress) {
|
if (xevent->type == KeyPress) {
|
||||||
// add filtered presses to the filtered list
|
// add filtered presses to the filtered list
|
||||||
m_filtered.insert(m_lastKeycode);
|
m_filtered.insert(m_lastKeycode);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1252,13 +1252,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
// let screen saver have a go
|
// let screen saver have a go
|
||||||
if (m_screensaver->handleXEvent(xevent)) {
|
if (m_screensaver->handleXEvent(xevent)) {
|
||||||
// screen saver handled it
|
// screen saver handled it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XI2
|
#ifdef HAVE_XI2
|
||||||
if (m_xi2detected) {
|
if (m_xi2detected) {
|
||||||
// Process RawMotion
|
// Process RawMotion
|
||||||
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
||||||
if (XGetEventData(m_display, cookie) &&
|
if (XGetEventData(m_display, cookie) &&
|
||||||
cookie->type == GenericEvent &&
|
cookie->type == GenericEvent &&
|
||||||
cookie->extension == xi_opcode) {
|
cookie->extension == xi_opcode) {
|
||||||
|
@ -1283,13 +1283,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// handle the event ourself
|
// handle the event ourself
|
||||||
switch (xevent->type) {
|
switch (xevent->type) {
|
||||||
case CreateNotify:
|
case CreateNotify:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// select events on new window
|
// select events on new window
|
||||||
|
@ -1317,7 +1317,7 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
if (id != kClipboardEnd) {
|
if (id != kClipboardEnd) {
|
||||||
LOG((CLOG_DEBUG "lost clipboard %d ownership at time %d", id, xevent->xselectionclear.time));
|
LOG((CLOG_DEBUG "lost clipboard %d ownership at time %d", id, xevent->xselectionclear.time));
|
||||||
m_clipboard[id]->lost(xevent->xselectionclear.time);
|
m_clipboard[id]->lost(xevent->xselectionclear.time);
|
||||||
sendClipboardEvent(getClipboardGrabbedEvent(), id);
|
sendClipboardEvent(m_events->forIPrimaryScreen().clipboardGrabbed(), id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1531,10 +1531,10 @@ CXWindowsScreen::onHotKey(XKeyEvent& xkey, bool isRepeat)
|
||||||
// find what kind of event
|
// find what kind of event
|
||||||
CEvent::Type type;
|
CEvent::Type type;
|
||||||
if (xkey.type == KeyPress) {
|
if (xkey.type == KeyPress) {
|
||||||
type = getHotKeyDownEvent();
|
type = m_events->forIPrimaryScreen().hotKeyDown();
|
||||||
}
|
}
|
||||||
else if (xkey.type == KeyRelease) {
|
else if (xkey.type == KeyRelease) {
|
||||||
type = getHotKeyUpEvent();
|
type = m_events->forIPrimaryScreen().hotKeyUp();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1542,7 +1542,7 @@ CXWindowsScreen::onHotKey(XKeyEvent& xkey, bool isRepeat)
|
||||||
|
|
||||||
// generate event (ignore key repeats)
|
// generate event (ignore key repeats)
|
||||||
if (!isRepeat) {
|
if (!isRepeat) {
|
||||||
m_eventQueue.addEvent(CEvent(type, getEventTarget(),
|
m_events->addEvent(CEvent(type, getEventTarget(),
|
||||||
CHotKeyInfo::alloc(i->second)));
|
CHotKeyInfo::alloc(i->second)));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1555,7 +1555,7 @@ CXWindowsScreen::onMousePress(const XButtonEvent& xbutton)
|
||||||
ButtonID button = mapButtonFromX(&xbutton);
|
ButtonID button = mapButtonFromX(&xbutton);
|
||||||
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
|
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
sendEvent(getButtonDownEvent(), CButtonInfo::alloc(button, mask));
|
sendEvent(m_events->forIPrimaryScreen().buttonDown(), CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,15 +1566,15 @@ CXWindowsScreen::onMouseRelease(const XButtonEvent& xbutton)
|
||||||
ButtonID button = mapButtonFromX(&xbutton);
|
ButtonID button = mapButtonFromX(&xbutton);
|
||||||
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
|
KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state);
|
||||||
if (button != kButtonNone) {
|
if (button != kButtonNone) {
|
||||||
sendEvent(getButtonUpEvent(), CButtonInfo::alloc(button, mask));
|
sendEvent(m_events->forIPrimaryScreen().buttonUp(), CButtonInfo::alloc(button, mask));
|
||||||
}
|
}
|
||||||
else if (xbutton.button == 4) {
|
else if (xbutton.button == 4) {
|
||||||
// wheel forward (away from user)
|
// wheel forward (away from user)
|
||||||
sendEvent(getWheelEvent(), CWheelInfo::alloc(0, 120));
|
sendEvent(m_events->forIPrimaryScreen().wheel(), CWheelInfo::alloc(0, 120));
|
||||||
}
|
}
|
||||||
else if (xbutton.button == 5) {
|
else if (xbutton.button == 5) {
|
||||||
// wheel backward (toward user)
|
// wheel backward (toward user)
|
||||||
sendEvent(getWheelEvent(), CWheelInfo::alloc(0, -120));
|
sendEvent(m_events->forIPrimaryScreen().wheel(), CWheelInfo::alloc(0, -120));
|
||||||
}
|
}
|
||||||
// XXX -- support x-axis scrolling
|
// XXX -- support x-axis scrolling
|
||||||
}
|
}
|
||||||
|
@ -1612,7 +1612,7 @@ CXWindowsScreen::onMouseMove(const XMotionEvent& xmotion)
|
||||||
}
|
}
|
||||||
else if (m_isOnScreen) {
|
else if (m_isOnScreen) {
|
||||||
// motion on primary screen
|
// motion on primary screen
|
||||||
sendEvent(getMotionOnPrimaryEvent(),
|
sendEvent(m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||||
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
CMotionInfo::alloc(m_xCursor, m_yCursor));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1643,7 +1643,7 @@ CXWindowsScreen::onMouseMove(const XMotionEvent& xmotion)
|
||||||
// warping to the primary screen's enter position,
|
// warping to the primary screen's enter position,
|
||||||
// effectively overriding it.
|
// effectively overriding it.
|
||||||
if (x != 0 || y != 0) {
|
if (x != 0 || y != 0) {
|
||||||
sendEvent(getMotionOnSecondaryEvent(), CMotionInfo::alloc(x, y));
|
sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), CMotionInfo::alloc(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1725,13 +1725,13 @@ void
|
||||||
CXWindowsScreen::onError()
|
CXWindowsScreen::onError()
|
||||||
{
|
{
|
||||||
// prevent further access to the X display
|
// prevent further access to the X display
|
||||||
m_eventQueue.adoptBuffer(NULL);
|
m_events->adoptBuffer(NULL);
|
||||||
m_screensaver->destroy();
|
m_screensaver->destroy();
|
||||||
m_screensaver = NULL;
|
m_screensaver = NULL;
|
||||||
m_display = NULL;
|
m_display = NULL;
|
||||||
|
|
||||||
// notify of failure
|
// notify of failure
|
||||||
sendEvent(getErrorEvent(), NULL);
|
sendEvent(m_events->forIPrimaryScreen().error(), NULL);
|
||||||
|
|
||||||
// FIXME -- should ensure that we ignore operations that involve
|
// FIXME -- should ensure that we ignore operations that involve
|
||||||
// m_display from now on. however, Xlib will simply exit the
|
// m_display from now on. however, Xlib will simply exit the
|
||||||
|
@ -2066,17 +2066,17 @@ CXWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CXWindowsScreen::detectXI2()
|
CXWindowsScreen::detectXI2()
|
||||||
{
|
{
|
||||||
int event, error;
|
int event, error;
|
||||||
return XQueryExtension(m_display,
|
return XQueryExtension(m_display,
|
||||||
"XInputExtension", &xi_opcode, &event, &error);
|
"XInputExtension", &xi_opcode, &event, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XI2
|
#ifdef HAVE_XI2
|
||||||
void
|
void
|
||||||
CXWindowsScreen::selectXIRawMotion()
|
CXWindowsScreen::selectXIRawMotion()
|
||||||
{
|
{
|
||||||
XIEventMask mask;
|
XIEventMask mask;
|
||||||
|
|
||||||
mask.deviceid = XIAllDevices;
|
mask.deviceid = XIAllDevices;
|
||||||
|
@ -2086,7 +2086,7 @@ CXWindowsScreen::selectXIRawMotion()
|
||||||
memset(mask.mask, 0, 2);
|
memset(mask.mask, 0, 2);
|
||||||
XISetMask(mask.mask, XI_RawKeyRelease);
|
XISetMask(mask.mask, XI_RawKeyRelease);
|
||||||
XISetMask(mask.mask, XI_RawMotion);
|
XISetMask(mask.mask, XI_RawMotion);
|
||||||
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
||||||
free(mask.mask);
|
free(mask.mask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ class CXWindowsScreenSaver;
|
||||||
//! Implementation of IPlatformScreen for X11
|
//! Implementation of IPlatformScreen for X11
|
||||||
class CXWindowsScreen : public CPlatformScreen {
|
class CXWindowsScreen : public CPlatformScreen {
|
||||||
public:
|
public:
|
||||||
CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue& eventQueue);
|
CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue* events);
|
||||||
virtual ~CXWindowsScreen();
|
virtual ~CXWindowsScreen();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -138,15 +138,15 @@ private:
|
||||||
bool onHotKey(XKeyEvent&, bool isRepeat);
|
bool onHotKey(XKeyEvent&, bool isRepeat);
|
||||||
void onMousePress(const XButtonEvent&);
|
void onMousePress(const XButtonEvent&);
|
||||||
void onMouseRelease(const XButtonEvent&);
|
void onMouseRelease(const XButtonEvent&);
|
||||||
void onMouseMove(const XMotionEvent&);
|
void onMouseMove(const XMotionEvent&);
|
||||||
|
|
||||||
bool detectXI2();
|
bool detectXI2();
|
||||||
#ifdef HAVE_XI2
|
#ifdef HAVE_XI2
|
||||||
void selectXIRawMotion();
|
void selectXIRawMotion();
|
||||||
#endif
|
#endif
|
||||||
void selectEvents(Window) const;
|
void selectEvents(Window) const;
|
||||||
void doSelectEvents(Window) const;
|
void doSelectEvents(Window) const;
|
||||||
|
|
||||||
KeyID mapKeyFromX(XKeyEvent*) const;
|
KeyID mapKeyFromX(XKeyEvent*) const;
|
||||||
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
||||||
unsigned int mapButtonToX(ButtonID id) const;
|
unsigned int mapButtonToX(ButtonID id) const;
|
||||||
|
@ -247,7 +247,7 @@ private:
|
||||||
bool m_xrandr;
|
bool m_xrandr;
|
||||||
int m_xrandrEventBase;
|
int m_xrandrEventBase;
|
||||||
|
|
||||||
IEventQueue& m_eventQueue;
|
IEventQueue* m_events;
|
||||||
CKeyMap m_keyMap;
|
CKeyMap m_keyMap;
|
||||||
|
|
||||||
// pointer to (singleton) screen. this is only needed by
|
// pointer to (singleton) screen. this is only needed by
|
||||||
|
|
|
@ -57,7 +57,7 @@ extern Status DPMSInfo(Display *, CARD16 *, BOOL *);
|
||||||
//
|
//
|
||||||
|
|
||||||
CXWindowsScreenSaver::CXWindowsScreenSaver(
|
CXWindowsScreenSaver::CXWindowsScreenSaver(
|
||||||
Display* display, Window window, void* eventTarget, IEventQueue& eventQueue) :
|
Display* display, Window window, void* eventTarget, IEventQueue* events) :
|
||||||
m_display(display),
|
m_display(display),
|
||||||
m_xscreensaverSink(window),
|
m_xscreensaverSink(window),
|
||||||
m_eventTarget(eventTarget),
|
m_eventTarget(eventTarget),
|
||||||
|
@ -68,7 +68,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(
|
||||||
m_suppressDisable(false),
|
m_suppressDisable(false),
|
||||||
m_disableTimer(NULL),
|
m_disableTimer(NULL),
|
||||||
m_disablePos(0),
|
m_disablePos(0),
|
||||||
m_eventQueue(eventQueue)
|
m_events(events)
|
||||||
{
|
{
|
||||||
// get atoms
|
// get atoms
|
||||||
m_atomScreenSaver = XInternAtom(m_display,
|
m_atomScreenSaver = XInternAtom(m_display,
|
||||||
|
@ -120,7 +120,7 @@ CXWindowsScreenSaver::CXWindowsScreenSaver(
|
||||||
}
|
}
|
||||||
|
|
||||||
// install disable timer event handler
|
// install disable timer event handler
|
||||||
m_eventQueue.adoptHandler(CEvent::kTimer, this,
|
m_events->adoptHandler(CEvent::kTimer, this,
|
||||||
new TMethodEventJob<CXWindowsScreenSaver>(this,
|
new TMethodEventJob<CXWindowsScreenSaver>(this,
|
||||||
&CXWindowsScreenSaver::handleDisableTimer));
|
&CXWindowsScreenSaver::handleDisableTimer));
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,9 @@ CXWindowsScreenSaver::~CXWindowsScreenSaver()
|
||||||
{
|
{
|
||||||
// done with disable job
|
// done with disable job
|
||||||
if (m_disableTimer != NULL) {
|
if (m_disableTimer != NULL) {
|
||||||
m_eventQueue.deleteTimer(m_disableTimer);
|
m_events->deleteTimer(m_disableTimer);
|
||||||
}
|
}
|
||||||
m_eventQueue.removeHandler(CEvent::kTimer, this);
|
m_events->removeHandler(CEvent::kTimer, this);
|
||||||
|
|
||||||
if (m_display != NULL) {
|
if (m_display != NULL) {
|
||||||
enableDPMS(m_dpmsEnabled);
|
enableDPMS(m_dpmsEnabled);
|
||||||
|
@ -397,13 +397,13 @@ CXWindowsScreenSaver::setXScreenSaverActive(bool activated)
|
||||||
updateDisableTimer();
|
updateDisableTimer();
|
||||||
|
|
||||||
if (activated) {
|
if (activated) {
|
||||||
m_eventQueue.addEvent(CEvent(
|
m_events->addEvent(CEvent(
|
||||||
IPlatformScreen::getScreensaverActivatedEvent(),
|
m_events->forIPlatformScreen().screensaverActivated(),
|
||||||
m_eventTarget));
|
m_eventTarget));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_eventQueue.addEvent(CEvent(
|
m_events->addEvent(CEvent(
|
||||||
IPlatformScreen::getScreensaverDeactivatedEvent(),
|
m_events->forIPlatformScreen().screensaverDeactivated(),
|
||||||
m_eventTarget));
|
m_eventTarget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,10 +504,10 @@ CXWindowsScreenSaver::updateDisableTimer()
|
||||||
{
|
{
|
||||||
if (m_disabled && !m_suppressDisable && m_disableTimer == NULL) {
|
if (m_disabled && !m_suppressDisable && m_disableTimer == NULL) {
|
||||||
// 5 seconds should be plenty often to suppress the screen saver
|
// 5 seconds should be plenty often to suppress the screen saver
|
||||||
m_disableTimer = m_eventQueue.newTimer(5.0, this);
|
m_disableTimer = m_events->newTimer(5.0, this);
|
||||||
}
|
}
|
||||||
else if ((!m_disabled || m_suppressDisable) && m_disableTimer != NULL) {
|
else if ((!m_disabled || m_suppressDisable) && m_disableTimer != NULL) {
|
||||||
m_eventQueue.deleteTimer(m_disableTimer);
|
m_events->deleteTimer(m_disableTimer);
|
||||||
m_disableTimer = NULL;
|
m_disableTimer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CEventQueueTimer;
|
||||||
//! X11 screen saver implementation
|
//! X11 screen saver implementation
|
||||||
class CXWindowsScreenSaver : public IScreenSaver {
|
class CXWindowsScreenSaver : public IScreenSaver {
|
||||||
public:
|
public:
|
||||||
CXWindowsScreenSaver(Display*, Window, void* eventTarget, IEventQueue& eventQueue);
|
CXWindowsScreenSaver(Display*, Window, void* eventTarget, IEventQueue* events);
|
||||||
virtual ~CXWindowsScreenSaver();
|
virtual ~CXWindowsScreenSaver();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
// pixels to be considered significant.
|
// pixels to be considered significant.
|
||||||
SInt32 m_disablePos;
|
SInt32 m_disablePos;
|
||||||
|
|
||||||
IEventQueue& m_eventQueue;
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,24 +31,20 @@
|
||||||
#include "CCryptoStream.h"
|
#include "CCryptoStream.h"
|
||||||
#include "CCryptoOptions.h"
|
#include "CCryptoOptions.h"
|
||||||
|
|
||||||
// TODO: these are just for testing -- make sure they're gone by release!
|
|
||||||
const byte g_key[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
||||||
const byte g_iv[] = "aaaaaaaaaaaaaaa";
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// CClientListener
|
// CClientListener
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type CClientListener::s_connectedEvent = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CClientListener::CClientListener(const CNetworkAddress& address,
|
CClientListener::CClientListener(const CNetworkAddress& address,
|
||||||
ISocketFactory* socketFactory,
|
ISocketFactory* socketFactory,
|
||||||
IStreamFilterFactory* streamFilterFactory,
|
IStreamFilterFactory* streamFilterFactory,
|
||||||
const CCryptoOptions& crypto) :
|
const CCryptoOptions& crypto,
|
||||||
|
IEventQueue* events) :
|
||||||
m_socketFactory(socketFactory),
|
m_socketFactory(socketFactory),
|
||||||
m_streamFilterFactory(streamFilterFactory),
|
m_streamFilterFactory(streamFilterFactory),
|
||||||
m_server(NULL),
|
m_server(NULL),
|
||||||
m_crypto(crypto)
|
m_crypto(crypto),
|
||||||
|
m_events(events)
|
||||||
{
|
{
|
||||||
assert(m_socketFactory != NULL);
|
assert(m_socketFactory != NULL);
|
||||||
|
|
||||||
|
@ -75,7 +71,7 @@ CClientListener::CClientListener(const CNetworkAddress& address,
|
||||||
LOG((CLOG_DEBUG1 "listening for clients"));
|
LOG((CLOG_DEBUG1 "listening for clients"));
|
||||||
|
|
||||||
// setup event handler
|
// setup event handler
|
||||||
EVENTQUEUE->adoptHandler(m_listen->getConnectingEvent(), m_listen,
|
m_events->adoptHandler(m_events->forIListenSocket().connecting(), m_listen,
|
||||||
new TMethodEventJob<CClientListener>(this,
|
new TMethodEventJob<CClientListener>(this,
|
||||||
&CClientListener::handleClientConnecting));
|
&CClientListener::handleClientConnecting));
|
||||||
}
|
}
|
||||||
|
@ -88,12 +84,12 @@ CClientListener::~CClientListener()
|
||||||
for (CNewClients::iterator index = m_newClients.begin();
|
for (CNewClients::iterator index = m_newClients.begin();
|
||||||
index != m_newClients.end(); ++index) {
|
index != m_newClients.end(); ++index) {
|
||||||
CClientProxyUnknown* client = *index;
|
CClientProxyUnknown* client = *index;
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
CClientProxyUnknown::getSuccessEvent(), client);
|
m_events->forCClientProxyUnknown().success(), client);
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
CClientProxyUnknown::getFailureEvent(), client);
|
m_events->forCClientProxyUnknown().failure(), client);
|
||||||
EVENTQUEUE->removeHandler(
|
m_events->removeHandler(
|
||||||
CClientProxy::getDisconnectedEvent(), client);
|
m_events->forCClientProxy().disconnected(), client);
|
||||||
delete client;
|
delete client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +100,7 @@ CClientListener::~CClientListener()
|
||||||
client = getNextClient();
|
client = getNextClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTQUEUE->removeHandler(m_listen->getConnectingEvent(), m_listen);
|
m_events->removeHandler(m_events->forIListenSocket().connecting(), m_listen);
|
||||||
delete m_listen;
|
delete m_listen;
|
||||||
delete m_socketFactory;
|
delete m_socketFactory;
|
||||||
delete m_streamFilterFactory;
|
delete m_streamFilterFactory;
|
||||||
|
@ -124,18 +120,11 @@ CClientListener::getNextClient()
|
||||||
if (!m_waitingClients.empty()) {
|
if (!m_waitingClients.empty()) {
|
||||||
client = m_waitingClients.front();
|
client = m_waitingClients.front();
|
||||||
m_waitingClients.pop_front();
|
m_waitingClients.pop_front();
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(), client);
|
||||||
}
|
}
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientListener::getConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
|
||||||
"CClientListener::connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientListener::handleClientConnecting(const CEvent&, void*)
|
CClientListener::handleClientConnecting(const CEvent&, void*)
|
||||||
{
|
{
|
||||||
|
@ -150,25 +139,25 @@ CClientListener::handleClientConnecting(const CEvent&, void*)
|
||||||
if (m_streamFilterFactory != NULL) {
|
if (m_streamFilterFactory != NULL) {
|
||||||
stream = m_streamFilterFactory->create(stream, true);
|
stream = m_streamFilterFactory->create(stream, true);
|
||||||
}
|
}
|
||||||
stream = new CPacketStreamFilter(stream, true);
|
stream = new CPacketStreamFilter(m_events, stream, true);
|
||||||
|
|
||||||
if (m_crypto.m_mode != kDisabled) {
|
if (m_crypto.m_mode != kDisabled) {
|
||||||
CCryptoStream* cryptoStream = new CCryptoStream(
|
CCryptoStream* cryptoStream = new CCryptoStream(
|
||||||
EVENTQUEUE, stream, m_crypto, true);
|
m_events, stream, m_crypto, true);
|
||||||
stream = cryptoStream;
|
stream = cryptoStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
// create proxy for unknown client
|
// create proxy for unknown client
|
||||||
CClientProxyUnknown* client = new CClientProxyUnknown(stream, 30.0, m_server);
|
CClientProxyUnknown* client = new CClientProxyUnknown(stream, 30.0, m_server, m_events);
|
||||||
m_newClients.insert(client);
|
m_newClients.insert(client);
|
||||||
|
|
||||||
// watch for events from unknown client
|
// watch for events from unknown client
|
||||||
EVENTQUEUE->adoptHandler(CClientProxyUnknown::getSuccessEvent(), client,
|
m_events->adoptHandler(m_events->forCClientProxyUnknown().success(), client,
|
||||||
new TMethodEventJob<CClientListener>(this,
|
new TMethodEventJob<CClientListener>(this,
|
||||||
&CClientListener::handleUnknownClient, client));
|
&CClientListener::handleUnknownClient, client));
|
||||||
EVENTQUEUE->adoptHandler(CClientProxyUnknown::getFailureEvent(), client,
|
m_events->adoptHandler(m_events->forCClientProxyUnknown().failure(), client,
|
||||||
new TMethodEventJob<CClientListener>(this,
|
new TMethodEventJob<CClientListener>(this,
|
||||||
&CClientListener::handleUnknownClient, client));
|
&CClientListener::handleUnknownClient, client));
|
||||||
}
|
}
|
||||||
|
@ -187,18 +176,18 @@ CClientListener::handleUnknownClient(const CEvent&, void* vclient)
|
||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
// handshake was successful
|
// handshake was successful
|
||||||
m_waitingClients.push_back(client);
|
m_waitingClients.push_back(client);
|
||||||
EVENTQUEUE->addEvent(CEvent(getConnectedEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCClientListener().connected(), this));
|
||||||
|
|
||||||
// watch for client to disconnect while it's in our queue
|
// watch for client to disconnect while it's in our queue
|
||||||
EVENTQUEUE->adoptHandler(CClientProxy::getDisconnectedEvent(), client,
|
m_events->adoptHandler(m_events->forCClientProxy().disconnected(), client,
|
||||||
new TMethodEventJob<CClientListener>(this,
|
new TMethodEventJob<CClientListener>(this,
|
||||||
&CClientListener::handleClientDisconnected,
|
&CClientListener::handleClientDisconnected,
|
||||||
client));
|
client));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now finished with unknown client
|
// now finished with unknown client
|
||||||
EVENTQUEUE->removeHandler(CClientProxyUnknown::getSuccessEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxyUnknown().success(), client);
|
||||||
EVENTQUEUE->removeHandler(CClientProxyUnknown::getFailureEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxyUnknown().failure(), client);
|
||||||
m_newClients.erase(unknownClient);
|
m_newClients.erase(unknownClient);
|
||||||
delete unknownClient;
|
delete unknownClient;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +202,7 @@ CClientListener::handleClientDisconnected(const CEvent&, void* vclient)
|
||||||
n = m_waitingClients.end(); i != n; ++i) {
|
n = m_waitingClients.end(); i != n; ++i) {
|
||||||
if (*i == client) {
|
if (*i == client) {
|
||||||
m_waitingClients.erase(i);
|
m_waitingClients.erase(i);
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(),
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(),
|
||||||
client);
|
client);
|
||||||
delete client;
|
delete client;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "stddeque.h"
|
#include "stddeque.h"
|
||||||
#include "stdset.h"
|
#include "stdset.h"
|
||||||
#include "CCryptoOptions.h"
|
#include "CCryptoOptions.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CClientProxy;
|
class CClientProxy;
|
||||||
class CClientProxyUnknown;
|
class CClientProxyUnknown;
|
||||||
|
@ -32,6 +33,7 @@ class IListenSocket;
|
||||||
class ISocketFactory;
|
class ISocketFactory;
|
||||||
class IStreamFilterFactory;
|
class IStreamFilterFactory;
|
||||||
class CServer;
|
class CServer;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
class CClientListener {
|
class CClientListener {
|
||||||
public:
|
public:
|
||||||
|
@ -39,7 +41,8 @@ public:
|
||||||
CClientListener(const CNetworkAddress&,
|
CClientListener(const CNetworkAddress&,
|
||||||
ISocketFactory*,
|
ISocketFactory*,
|
||||||
IStreamFilterFactory*,
|
IStreamFilterFactory*,
|
||||||
const CCryptoOptions& crypto);
|
const CCryptoOptions& crypto,
|
||||||
|
IEventQueue* events);
|
||||||
~CClientListener();
|
~CClientListener();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -60,13 +63,6 @@ public:
|
||||||
*/
|
*/
|
||||||
CClientProxy* getNextClient();
|
CClientProxy* getNextClient();
|
||||||
|
|
||||||
//! Get connected event type
|
|
||||||
/*!
|
|
||||||
Returns the connected event type. This is sent whenever a
|
|
||||||
a client connects.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -79,15 +75,14 @@ private:
|
||||||
typedef std::set<CClientProxyUnknown*> CNewClients;
|
typedef std::set<CClientProxyUnknown*> CNewClients;
|
||||||
typedef std::deque<CClientProxy*> CWaitingClients;
|
typedef std::deque<CClientProxy*> CWaitingClients;
|
||||||
|
|
||||||
IListenSocket* m_listen;
|
IListenSocket* m_listen;
|
||||||
ISocketFactory* m_socketFactory;
|
ISocketFactory* m_socketFactory;
|
||||||
IStreamFilterFactory* m_streamFilterFactory;
|
IStreamFilterFactory* m_streamFilterFactory;
|
||||||
CNewClients m_newClients;
|
CNewClients m_newClients;
|
||||||
CWaitingClients m_waitingClients;
|
CWaitingClients m_waitingClients;
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
CCryptoOptions m_crypto;
|
CCryptoOptions m_crypto;
|
||||||
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_connectedEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,11 +26,6 @@
|
||||||
// CClientProxy
|
// CClientProxy
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type CClientProxy::s_readyEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type CClientProxy::s_disconnectedEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type CClientProxy::s_clipboardChangedEvent= CEvent::kUnknown;
|
|
||||||
CEvent::Type CClientProxy::s_gameDeviceTimingRecvEvent= CEvent::kUnknown;
|
|
||||||
|
|
||||||
CClientProxy::CClientProxy(const CString& name, synergy::IStream* stream) :
|
CClientProxy::CClientProxy(const CString& name, synergy::IStream* stream) :
|
||||||
CBaseClientProxy(name),
|
CBaseClientProxy(name),
|
||||||
m_stream(stream)
|
m_stream(stream)
|
||||||
|
@ -58,34 +53,6 @@ CClientProxy::getStream() const
|
||||||
return m_stream;
|
return m_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxy::getReadyEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_readyEvent,
|
|
||||||
"CClientProxy::ready");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxy::getDisconnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
|
||||||
"CClientProxy::disconnected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxy::getClipboardChangedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_clipboardChangedEvent,
|
|
||||||
"CClientProxy::clipboardChanged");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxy::getGameDeviceTimingRespEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_gameDeviceTimingRecvEvent,
|
|
||||||
"CClientProxy::gameDeviceTimingRecv");
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
CClientProxy::getEventTarget() const
|
CClientProxy::getEventTarget() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "CBaseClientProxy.h"
|
#include "CBaseClientProxy.h"
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
#include "CString.h"
|
#include "CString.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
namespace synergy { class IStream; }
|
namespace synergy { class IStream; }
|
||||||
|
|
||||||
|
@ -54,36 +55,6 @@ public:
|
||||||
*/
|
*/
|
||||||
synergy::IStream* getStream() const;
|
synergy::IStream* getStream() const;
|
||||||
|
|
||||||
//! Get ready event type
|
|
||||||
/*!
|
|
||||||
Returns the ready event type. This is sent when the client has
|
|
||||||
completed the initial handshake. Until it is sent, the client is
|
|
||||||
not fully connected.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getReadyEvent();
|
|
||||||
|
|
||||||
//! Get disconnect event type
|
|
||||||
/*!
|
|
||||||
Returns the disconnect event type. This is sent when the client
|
|
||||||
disconnects or is disconnected. The target is getEventTarget().
|
|
||||||
*/
|
|
||||||
static CEvent::Type getDisconnectedEvent();
|
|
||||||
|
|
||||||
//! Get clipboard changed event type
|
|
||||||
/*!
|
|
||||||
Returns the clipboard changed event type. This is sent whenever the
|
|
||||||
contents of the clipboard has changed. The data is a pointer to a
|
|
||||||
IScreen::CClipboardInfo.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getClipboardChangedEvent();
|
|
||||||
|
|
||||||
//! Get game device timing receive event type
|
|
||||||
/*!
|
|
||||||
Returns the game device timing receive event type. This is set
|
|
||||||
whenever the server receives to a timing event response from a client.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getGameDeviceTimingRespEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
// IScreen
|
// IScreen
|
||||||
|
@ -121,11 +92,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
synergy::IStream* m_stream;
|
synergy::IStream* m_stream;
|
||||||
|
|
||||||
static CEvent::Type s_readyEvent;
|
|
||||||
static CEvent::Type s_disconnectedEvent;
|
|
||||||
static CEvent::Type s_clipboardChangedEvent;
|
|
||||||
static CEvent::Type s_gameDeviceTimingRecvEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,30 +29,30 @@
|
||||||
// CClientProxy1_0
|
// CClientProxy1_0
|
||||||
//
|
//
|
||||||
|
|
||||||
CClientProxy1_0::CClientProxy1_0(const CString& name, synergy::IStream* stream, IEventQueue* eventQueue) :
|
CClientProxy1_0::CClientProxy1_0(const CString& name, synergy::IStream* stream, IEventQueue* events) :
|
||||||
CClientProxy(name, stream),
|
CClientProxy(name, stream),
|
||||||
m_heartbeatTimer(NULL),
|
m_heartbeatTimer(NULL),
|
||||||
m_parser(&CClientProxy1_0::parseHandshakeMessage),
|
m_parser(&CClientProxy1_0::parseHandshakeMessage),
|
||||||
m_eventQueue(eventQueue)
|
m_events(events)
|
||||||
{
|
{
|
||||||
// install event handlers
|
// install event handlers
|
||||||
m_eventQueue->adoptHandler(stream->getInputReadyEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||||
stream->getEventTarget(),
|
stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxy1_0>(this,
|
new TMethodEventJob<CClientProxy1_0>(this,
|
||||||
&CClientProxy1_0::handleData, NULL));
|
&CClientProxy1_0::handleData, NULL));
|
||||||
m_eventQueue->adoptHandler(stream->getOutputErrorEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputError(),
|
||||||
stream->getEventTarget(),
|
stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxy1_0>(this,
|
new TMethodEventJob<CClientProxy1_0>(this,
|
||||||
&CClientProxy1_0::handleWriteError, NULL));
|
&CClientProxy1_0::handleWriteError, NULL));
|
||||||
m_eventQueue->adoptHandler(stream->getInputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputShutdown(),
|
||||||
stream->getEventTarget(),
|
stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxy1_0>(this,
|
new TMethodEventJob<CClientProxy1_0>(this,
|
||||||
&CClientProxy1_0::handleDisconnect, NULL));
|
&CClientProxy1_0::handleDisconnect, NULL));
|
||||||
m_eventQueue->adoptHandler(stream->getOutputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputShutdown(),
|
||||||
stream->getEventTarget(),
|
stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxy1_0>(this,
|
new TMethodEventJob<CClientProxy1_0>(this,
|
||||||
&CClientProxy1_0::handleWriteError, NULL));
|
&CClientProxy1_0::handleWriteError, NULL));
|
||||||
m_eventQueue->adoptHandler(CEvent::kTimer, this,
|
m_events->adoptHandler(CEvent::kTimer, this,
|
||||||
new TMethodEventJob<CClientProxy1_0>(this,
|
new TMethodEventJob<CClientProxy1_0>(this,
|
||||||
&CClientProxy1_0::handleFlatline, NULL));
|
&CClientProxy1_0::handleFlatline, NULL));
|
||||||
|
|
||||||
|
@ -72,22 +72,22 @@ CClientProxy1_0::disconnect()
|
||||||
{
|
{
|
||||||
removeHandlers();
|
removeHandlers();
|
||||||
getStream()->close();
|
getStream()->close();
|
||||||
m_eventQueue->addEvent(CEvent(getDisconnectedEvent(), getEventTarget()));
|
m_events->addEvent(CEvent(m_events->forCClientProxy().disconnected(), getEventTarget()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxy1_0::removeHandlers()
|
CClientProxy1_0::removeHandlers()
|
||||||
{
|
{
|
||||||
// uninstall event handlers
|
// uninstall event handlers
|
||||||
m_eventQueue->removeHandler(getStream()->getInputReadyEvent(),
|
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||||
getStream()->getEventTarget());
|
getStream()->getEventTarget());
|
||||||
m_eventQueue->removeHandler(getStream()->getOutputErrorEvent(),
|
m_events->removeHandler(m_events->forIStream().outputError(),
|
||||||
getStream()->getEventTarget());
|
getStream()->getEventTarget());
|
||||||
m_eventQueue->removeHandler(getStream()->getInputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().inputShutdown(),
|
||||||
getStream()->getEventTarget());
|
getStream()->getEventTarget());
|
||||||
m_eventQueue->removeHandler(getStream()->getOutputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().outputShutdown(),
|
||||||
getStream()->getEventTarget());
|
getStream()->getEventTarget());
|
||||||
m_eventQueue->removeHandler(CEvent::kTimer, this);
|
m_events->removeHandler(CEvent::kTimer, this);
|
||||||
|
|
||||||
// remove timer
|
// remove timer
|
||||||
removeHeartbeatTimer();
|
removeHeartbeatTimer();
|
||||||
|
@ -97,7 +97,7 @@ void
|
||||||
CClientProxy1_0::addHeartbeatTimer()
|
CClientProxy1_0::addHeartbeatTimer()
|
||||||
{
|
{
|
||||||
if (m_heartbeatAlarm > 0.0) {
|
if (m_heartbeatAlarm > 0.0) {
|
||||||
m_heartbeatTimer = m_eventQueue->newOneShotTimer(m_heartbeatAlarm, this);
|
m_heartbeatTimer = m_events->newOneShotTimer(m_heartbeatAlarm, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void
|
||||||
CClientProxy1_0::removeHeartbeatTimer()
|
CClientProxy1_0::removeHeartbeatTimer()
|
||||||
{
|
{
|
||||||
if (m_heartbeatTimer != NULL) {
|
if (m_heartbeatTimer != NULL) {
|
||||||
m_eventQueue->deleteTimer(m_heartbeatTimer);
|
m_events->deleteTimer(m_heartbeatTimer);
|
||||||
m_heartbeatTimer = NULL;
|
m_heartbeatTimer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ CClientProxy1_0::parseHandshakeMessage(const UInt8* code)
|
||||||
// future messages get parsed by parseMessage
|
// future messages get parsed by parseMessage
|
||||||
m_parser = &CClientProxy1_0::parseMessage;
|
m_parser = &CClientProxy1_0::parseMessage;
|
||||||
if (recvInfo()) {
|
if (recvInfo()) {
|
||||||
m_eventQueue->addEvent(CEvent(getReadyEvent(), getEventTarget()));
|
m_events->addEvent(CEvent(m_events->forCClientProxy().ready(), getEventTarget()));
|
||||||
addHeartbeatTimer();
|
addHeartbeatTimer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,8 @@ CClientProxy1_0::parseMessage(const UInt8* code)
|
||||||
{
|
{
|
||||||
if (memcmp(code, kMsgDInfo, 4) == 0) {
|
if (memcmp(code, kMsgDInfo, 4) == 0) {
|
||||||
if (recvInfo()) {
|
if (recvInfo()) {
|
||||||
m_eventQueue->addEvent(
|
m_events->addEvent(
|
||||||
CEvent(getShapeChangedEvent(), getEventTarget()));
|
CEvent(m_events->forIScreen().shapeChanged(), getEventTarget()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -492,7 +492,7 @@ CClientProxy1_0::recvClipboard()
|
||||||
CClipboardInfo* info = new CClipboardInfo;
|
CClipboardInfo* info = new CClipboardInfo;
|
||||||
info->m_id = id;
|
info->m_id = id;
|
||||||
info->m_sequenceNumber = seqNum;
|
info->m_sequenceNumber = seqNum;
|
||||||
m_eventQueue->addEvent(CEvent(getClipboardChangedEvent(),
|
m_events->addEvent(CEvent(m_events->forCClientProxy().clipboardChanged(),
|
||||||
getEventTarget(), info));
|
getEventTarget(), info));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -518,7 +518,7 @@ CClientProxy1_0::recvGrabClipboard()
|
||||||
CClipboardInfo* info = new CClipboardInfo;
|
CClipboardInfo* info = new CClipboardInfo;
|
||||||
info->m_id = id;
|
info->m_id = id;
|
||||||
info->m_sequenceNumber = seqNum;
|
info->m_sequenceNumber = seqNum;
|
||||||
m_eventQueue->addEvent(CEvent(getClipboardGrabbedEvent(),
|
m_events->addEvent(CEvent(m_events->forIScreen().clipboardGrabbed(),
|
||||||
getEventTarget(), info));
|
getEventTarget(), info));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class IEventQueue;
|
||||||
//! Proxy for client implementing protocol version 1.0
|
//! Proxy for client implementing protocol version 1.0
|
||||||
class CClientProxy1_0 : public CClientProxy {
|
class CClientProxy1_0 : public CClientProxy {
|
||||||
public:
|
public:
|
||||||
CClientProxy1_0(const CString& name, synergy::IStream* adoptedStream, IEventQueue* eventQueue);
|
CClientProxy1_0(const CString& name, synergy::IStream* adoptedStream, IEventQueue* events);
|
||||||
~CClientProxy1_0();
|
~CClientProxy1_0();
|
||||||
|
|
||||||
// IScreen
|
// IScreen
|
||||||
|
@ -105,7 +105,7 @@ private:
|
||||||
double m_heartbeatAlarm;
|
double m_heartbeatAlarm;
|
||||||
CEventQueueTimer* m_heartbeatTimer;
|
CEventQueueTimer* m_heartbeatTimer;
|
||||||
MessageParser m_parser;
|
MessageParser m_parser;
|
||||||
IEventQueue* m_eventQueue;
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
// CClientProxy1_1
|
// CClientProxy1_1
|
||||||
//
|
//
|
||||||
|
|
||||||
CClientProxy1_1::CClientProxy1_1(const CString& name, synergy::IStream* stream, IEventQueue* eventQueue) :
|
CClientProxy1_1::CClientProxy1_1(const CString& name, synergy::IStream* stream, IEventQueue* events) :
|
||||||
CClientProxy1_0(name, stream, eventQueue)
|
CClientProxy1_0(name, stream, events)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
//! Proxy for client implementing protocol version 1.1
|
//! Proxy for client implementing protocol version 1.1
|
||||||
class CClientProxy1_1 : public CClientProxy1_0 {
|
class CClientProxy1_1 : public CClientProxy1_0 {
|
||||||
public:
|
public:
|
||||||
CClientProxy1_1(const CString& name, synergy::IStream* adoptedStream, IEventQueue* eventQueue);
|
CClientProxy1_1(const CString& name, synergy::IStream* adoptedStream, IEventQueue* events);
|
||||||
~CClientProxy1_1();
|
~CClientProxy1_1();
|
||||||
|
|
||||||
// IClient overrides
|
// IClient overrides
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
// CClientProxy1_1
|
// CClientProxy1_1
|
||||||
//
|
//
|
||||||
|
|
||||||
CClientProxy1_2::CClientProxy1_2(const CString& name, synergy::IStream* stream, IEventQueue* eventQueue) :
|
CClientProxy1_2::CClientProxy1_2(const CString& name, synergy::IStream* stream, IEventQueue* events) :
|
||||||
CClientProxy1_1(name, stream, eventQueue)
|
CClientProxy1_1(name, stream, events)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class IEventQueue;
|
||||||
//! Proxy for client implementing protocol version 1.2
|
//! Proxy for client implementing protocol version 1.2
|
||||||
class CClientProxy1_2 : public CClientProxy1_1 {
|
class CClientProxy1_2 : public CClientProxy1_1 {
|
||||||
public:
|
public:
|
||||||
CClientProxy1_2(const CString& name, synergy::IStream* adoptedStream, IEventQueue* eventQueue);
|
CClientProxy1_2(const CString& name, synergy::IStream* adoptedStream, IEventQueue* events);
|
||||||
~CClientProxy1_2();
|
~CClientProxy1_2();
|
||||||
|
|
||||||
// IClient overrides
|
// IClient overrides
|
||||||
|
|
|
@ -28,8 +28,9 @@
|
||||||
// CClientProxy1_3
|
// CClientProxy1_3
|
||||||
//
|
//
|
||||||
|
|
||||||
CClientProxy1_3::CClientProxy1_3(const CString& name, synergy::IStream* stream, IEventQueue* eventQueue) :
|
CClientProxy1_3::CClientProxy1_3(const CString& name, synergy::IStream* stream, IEventQueue* events) :
|
||||||
CClientProxy1_2(name, stream, eventQueue),
|
CClientProxy1_2(name, stream, events),
|
||||||
|
m_events(events),
|
||||||
m_keepAliveRate(kKeepAliveRate),
|
m_keepAliveRate(kKeepAliveRate),
|
||||||
m_keepAliveTimer(NULL)
|
m_keepAliveTimer(NULL)
|
||||||
{
|
{
|
||||||
|
@ -89,8 +90,8 @@ CClientProxy1_3::addHeartbeatTimer()
|
||||||
{
|
{
|
||||||
// create and install a timer to periodically send keep alives
|
// create and install a timer to periodically send keep alives
|
||||||
if (m_keepAliveRate > 0.0) {
|
if (m_keepAliveRate > 0.0) {
|
||||||
m_keepAliveTimer = EVENTQUEUE->newTimer(m_keepAliveRate, NULL);
|
m_keepAliveTimer = m_events->newTimer(m_keepAliveRate, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, m_keepAliveTimer,
|
m_events->adoptHandler(CEvent::kTimer, m_keepAliveTimer,
|
||||||
new TMethodEventJob<CClientProxy1_3>(this,
|
new TMethodEventJob<CClientProxy1_3>(this,
|
||||||
&CClientProxy1_3::handleKeepAlive, NULL));
|
&CClientProxy1_3::handleKeepAlive, NULL));
|
||||||
}
|
}
|
||||||
|
@ -104,8 +105,8 @@ CClientProxy1_3::removeHeartbeatTimer()
|
||||||
{
|
{
|
||||||
// remove the timer that sends keep alives periodically
|
// remove the timer that sends keep alives periodically
|
||||||
if (m_keepAliveTimer != NULL) {
|
if (m_keepAliveTimer != NULL) {
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, m_keepAliveTimer);
|
m_events->removeHandler(CEvent::kTimer, m_keepAliveTimer);
|
||||||
EVENTQUEUE->deleteTimer(m_keepAliveTimer);
|
m_events->deleteTimer(m_keepAliveTimer);
|
||||||
m_keepAliveTimer = NULL;
|
m_keepAliveTimer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
//! Proxy for client implementing protocol version 1.3
|
//! Proxy for client implementing protocol version 1.3
|
||||||
class CClientProxy1_3 : public CClientProxy1_2 {
|
class CClientProxy1_3 : public CClientProxy1_2 {
|
||||||
public:
|
public:
|
||||||
CClientProxy1_3(const CString& name, synergy::IStream* adoptedStream, IEventQueue* eventQueue);
|
CClientProxy1_3(const CString& name, synergy::IStream* adoptedStream, IEventQueue* events);
|
||||||
~CClientProxy1_3();
|
~CClientProxy1_3();
|
||||||
|
|
||||||
// IClient overrides
|
// IClient overrides
|
||||||
|
@ -46,6 +46,7 @@ private:
|
||||||
private:
|
private:
|
||||||
double m_keepAliveRate;
|
double m_keepAliveRate;
|
||||||
CEventQueueTimer* m_keepAliveTimer;
|
CEventQueueTimer* m_keepAliveTimer;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
// CClientProxy1_4
|
// CClientProxy1_4
|
||||||
//
|
//
|
||||||
|
|
||||||
CClientProxy1_4::CClientProxy1_4(const CString& name, synergy::IStream* stream, CServer* server, IEventQueue* eventQueue) :
|
CClientProxy1_4::CClientProxy1_4(const CString& name, synergy::IStream* stream, CServer* server, IEventQueue* events) :
|
||||||
CClientProxy1_3(name, stream, eventQueue), m_server(server)
|
CClientProxy1_3(name, stream, events), m_server(server)
|
||||||
{
|
{
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class CServer;
|
||||||
//! Proxy for client implementing protocol version 1.4
|
//! Proxy for client implementing protocol version 1.4
|
||||||
class CClientProxy1_4 : public CClientProxy1_3 {
|
class CClientProxy1_4 : public CClientProxy1_3 {
|
||||||
public:
|
public:
|
||||||
CClientProxy1_4(const CString& name, synergy::IStream* adoptedStream, CServer* server, IEventQueue* eventQueue);
|
CClientProxy1_4(const CString& name, synergy::IStream* adoptedStream, CServer* server, IEventQueue* events);
|
||||||
~CClientProxy1_4();
|
~CClientProxy1_4();
|
||||||
|
|
||||||
// IClient overrides
|
// IClient overrides
|
||||||
|
|
|
@ -37,10 +37,8 @@
|
||||||
// CClientProxyUnknown
|
// CClientProxyUnknown
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type CClientProxyUnknown::s_successEvent = CEvent::kUnknown;
|
CClientProxyUnknown::CClientProxyUnknown(synergy::IStream* stream, double timeout, CServer* server, IEventQueue* events) :
|
||||||
CEvent::Type CClientProxyUnknown::s_failureEvent = CEvent::kUnknown;
|
m_events(events),
|
||||||
|
|
||||||
CClientProxyUnknown::CClientProxyUnknown(synergy::IStream* stream, double timeout, CServer* server) :
|
|
||||||
m_stream(stream),
|
m_stream(stream),
|
||||||
m_proxy(NULL),
|
m_proxy(NULL),
|
||||||
m_ready(false),
|
m_ready(false),
|
||||||
|
@ -48,10 +46,10 @@ CClientProxyUnknown::CClientProxyUnknown(synergy::IStream* stream, double timeou
|
||||||
{
|
{
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, this,
|
m_events->adoptHandler(CEvent::kTimer, this,
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleTimeout, NULL));
|
&CClientProxyUnknown::handleTimeout, NULL));
|
||||||
m_timer = EVENTQUEUE->newOneShotTimer(timeout, this);
|
m_timer = m_events->newOneShotTimer(timeout, this);
|
||||||
addStreamHandlers();
|
addStreamHandlers();
|
||||||
|
|
||||||
LOG((CLOG_DEBUG1 "saying hello"));
|
LOG((CLOG_DEBUG1 "saying hello"));
|
||||||
|
@ -82,26 +80,12 @@ CClientProxyUnknown::orphanClientProxy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxyUnknown::getSuccessEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_successEvent,
|
|
||||||
"CClientProxy::success");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CClientProxyUnknown::getFailureEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_failureEvent,
|
|
||||||
"CClientProxy::failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CClientProxyUnknown::sendSuccess()
|
CClientProxyUnknown::sendSuccess()
|
||||||
{
|
{
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
removeTimer();
|
removeTimer();
|
||||||
EVENTQUEUE->addEvent(CEvent(getSuccessEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCClientProxyUnknown().success(), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -112,7 +96,7 @@ CClientProxyUnknown::sendFailure()
|
||||||
m_ready = false;
|
m_ready = false;
|
||||||
removeHandlers();
|
removeHandlers();
|
||||||
removeTimer();
|
removeTimer();
|
||||||
EVENTQUEUE->addEvent(CEvent(getFailureEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCClientProxyUnknown().failure(), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -120,19 +104,19 @@ CClientProxyUnknown::addStreamHandlers()
|
||||||
{
|
{
|
||||||
assert(m_stream != NULL);
|
assert(m_stream != NULL);
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(m_stream->getInputReadyEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleData));
|
&CClientProxyUnknown::handleData));
|
||||||
EVENTQUEUE->adoptHandler(m_stream->getOutputErrorEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputError(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleWriteError));
|
&CClientProxyUnknown::handleWriteError));
|
||||||
EVENTQUEUE->adoptHandler(m_stream->getInputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().inputShutdown(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleDisconnect));
|
&CClientProxyUnknown::handleDisconnect));
|
||||||
EVENTQUEUE->adoptHandler(m_stream->getOutputShutdownEvent(),
|
m_events->adoptHandler(m_events->forIStream().outputShutdown(),
|
||||||
m_stream->getEventTarget(),
|
m_stream->getEventTarget(),
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleWriteError));
|
&CClientProxyUnknown::handleWriteError));
|
||||||
|
@ -143,11 +127,11 @@ CClientProxyUnknown::addProxyHandlers()
|
||||||
{
|
{
|
||||||
assert(m_proxy != NULL);
|
assert(m_proxy != NULL);
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(CClientProxy::getReadyEvent(),
|
m_events->adoptHandler(m_events->forCClientProxy().ready(),
|
||||||
m_proxy,
|
m_proxy,
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleReady));
|
&CClientProxyUnknown::handleReady));
|
||||||
EVENTQUEUE->adoptHandler(CClientProxy::getDisconnectedEvent(),
|
m_events->adoptHandler(m_events->forCClientProxy().disconnected(),
|
||||||
m_proxy,
|
m_proxy,
|
||||||
new TMethodEventJob<CClientProxyUnknown>(this,
|
new TMethodEventJob<CClientProxyUnknown>(this,
|
||||||
&CClientProxyUnknown::handleDisconnect));
|
&CClientProxyUnknown::handleDisconnect));
|
||||||
|
@ -157,19 +141,19 @@ void
|
||||||
CClientProxyUnknown::removeHandlers()
|
CClientProxyUnknown::removeHandlers()
|
||||||
{
|
{
|
||||||
if (m_stream != NULL) {
|
if (m_stream != NULL) {
|
||||||
EVENTQUEUE->removeHandler(m_stream->getInputReadyEvent(),
|
m_events->removeHandler(m_events->forIStream().inputReady(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(m_stream->getOutputErrorEvent(),
|
m_events->removeHandler(m_events->forIStream().outputError(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(m_stream->getInputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().inputShutdown(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(m_stream->getOutputShutdownEvent(),
|
m_events->removeHandler(m_events->forIStream().outputShutdown(),
|
||||||
m_stream->getEventTarget());
|
m_stream->getEventTarget());
|
||||||
}
|
}
|
||||||
if (m_proxy != NULL) {
|
if (m_proxy != NULL) {
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getReadyEvent(),
|
m_events->removeHandler(m_events->forCClientProxy().ready(),
|
||||||
m_proxy);
|
m_proxy);
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(),
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(),
|
||||||
m_proxy);
|
m_proxy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,8 +162,8 @@ void
|
||||||
CClientProxyUnknown::removeTimer()
|
CClientProxyUnknown::removeTimer()
|
||||||
{
|
{
|
||||||
if (m_timer != NULL) {
|
if (m_timer != NULL) {
|
||||||
EVENTQUEUE->deleteTimer(m_timer);
|
m_events->deleteTimer(m_timer);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, this);
|
m_events->removeHandler(CEvent::kTimer, this);
|
||||||
m_timer = NULL;
|
m_timer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,23 +203,23 @@ CClientProxyUnknown::handleData(const CEvent&, void*)
|
||||||
if (major == 1) {
|
if (major == 1) {
|
||||||
switch (minor) {
|
switch (minor) {
|
||||||
case 0:
|
case 0:
|
||||||
m_proxy = new CClientProxy1_0(name, m_stream, EVENTQUEUE);
|
m_proxy = new CClientProxy1_0(name, m_stream, m_events);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
m_proxy = new CClientProxy1_1(name, m_stream, EVENTQUEUE);
|
m_proxy = new CClientProxy1_1(name, m_stream, m_events);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
m_proxy = new CClientProxy1_2(name, m_stream, EVENTQUEUE);
|
m_proxy = new CClientProxy1_2(name, m_stream, m_events);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
m_proxy = new CClientProxy1_3(name, m_stream, EVENTQUEUE);
|
m_proxy = new CClientProxy1_3(name, m_stream, m_events);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
m_proxy = new CClientProxy1_4(name, m_stream, m_server, EVENTQUEUE);
|
m_proxy = new CClientProxy1_4(name, m_stream, m_server, m_events);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,17 @@
|
||||||
#define CCLIENTPROXYUNKNOWN_H
|
#define CCLIENTPROXYUNKNOWN_H
|
||||||
|
|
||||||
#include "CEvent.h"
|
#include "CEvent.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CClientProxy;
|
class CClientProxy;
|
||||||
class CEventQueueTimer;
|
class CEventQueueTimer;
|
||||||
namespace synergy { class IStream; }
|
namespace synergy { class IStream; }
|
||||||
class CServer;
|
class CServer;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
class CClientProxyUnknown {
|
class CClientProxyUnknown {
|
||||||
public:
|
public:
|
||||||
CClientProxyUnknown(synergy::IStream* stream, double timeout, CServer* server);
|
CClientProxyUnknown(synergy::IStream* stream, double timeout, CServer* server, IEventQueue* events);
|
||||||
~CClientProxyUnknown();
|
~CClientProxyUnknown();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -43,24 +45,6 @@ public:
|
||||||
CClientProxy* orphanClientProxy();
|
CClientProxy* orphanClientProxy();
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
|
||||||
//@{
|
|
||||||
|
|
||||||
//! Get success event type
|
|
||||||
/*!
|
|
||||||
Returns the success event type. This is sent when the client has
|
|
||||||
correctly responded to the hello message. The target is this.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getSuccessEvent();
|
|
||||||
|
|
||||||
//! Get failure event type
|
|
||||||
/*!
|
|
||||||
Returns the failure event type. This is sent when a client fails
|
|
||||||
to correctly respond to the hello message. The target is this.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getFailureEvent();
|
|
||||||
|
|
||||||
//@}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendSuccess();
|
void sendSuccess();
|
||||||
|
@ -80,10 +64,8 @@ private:
|
||||||
CEventQueueTimer* m_timer;
|
CEventQueueTimer* m_timer;
|
||||||
CClientProxy* m_proxy;
|
CClientProxy* m_proxy;
|
||||||
bool m_ready;
|
bool m_ready;
|
||||||
|
|
||||||
static CEvent::Type s_successEvent;
|
|
||||||
static CEvent::Type s_failureEvent;
|
|
||||||
CServer* m_server;
|
CServer* m_server;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,12 +24,16 @@
|
||||||
#include "stdistream.h"
|
#include "stdistream.h"
|
||||||
#include "stdostream.h"
|
#include "stdostream.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include "IEventQueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CConfig
|
// CConfig
|
||||||
//
|
//
|
||||||
|
|
||||||
CConfig::CConfig() : m_hasLockToScreenAction(false)
|
CConfig::CConfig(IEventQueue* events) :
|
||||||
|
m_events(events),
|
||||||
|
m_hasLockToScreenAction(false),
|
||||||
|
m_inputFilter(events)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -610,7 +614,7 @@ CConfig::operator!=(const CConfig& x) const
|
||||||
void
|
void
|
||||||
CConfig::read(CConfigReadContext& context)
|
CConfig::read(CConfigReadContext& context)
|
||||||
{
|
{
|
||||||
CConfig tmp;
|
CConfig tmp(m_events);
|
||||||
while (context) {
|
while (context) {
|
||||||
tmp.readSection(context);
|
tmp.readSection(context);
|
||||||
}
|
}
|
||||||
|
@ -1048,7 +1052,7 @@ CConfig::parseCondition(CConfigReadContext& s,
|
||||||
|
|
||||||
IPlatformScreen::CKeyInfo* keyInfo = s.parseKeystroke(args[0]);
|
IPlatformScreen::CKeyInfo* keyInfo = s.parseKeystroke(args[0]);
|
||||||
|
|
||||||
return new CInputFilter::CKeystrokeCondition(keyInfo);
|
return new CInputFilter::CKeystrokeCondition(m_events, keyInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == "mousebutton") {
|
if (name == "mousebutton") {
|
||||||
|
@ -1058,7 +1062,7 @@ CConfig::parseCondition(CConfigReadContext& s,
|
||||||
|
|
||||||
IPlatformScreen::CButtonInfo* mouseInfo = s.parseMouse(args[0]);
|
IPlatformScreen::CButtonInfo* mouseInfo = s.parseMouse(args[0]);
|
||||||
|
|
||||||
return new CInputFilter::CMouseButtonCondition(mouseInfo);
|
return new CInputFilter::CMouseButtonCondition(m_events, mouseInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == "connect") {
|
if (name == "connect") {
|
||||||
|
@ -1074,7 +1078,7 @@ CConfig::parseCondition(CConfigReadContext& s,
|
||||||
throw XConfigRead(s, "unknown screen name \"%{1}\" in connect", screen);
|
throw XConfigRead(s, "unknown screen name \"%{1}\" in connect", screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CInputFilter::CScreenConnectedCondition(screen);
|
return new CInputFilter::CScreenConnectedCondition(m_events, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw XConfigRead(s, "unknown argument \"%{1}\"", name);
|
throw XConfigRead(s, "unknown argument \"%{1}\"", name);
|
||||||
|
@ -1105,16 +1109,16 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
if (name == "keystroke") {
|
if (name == "keystroke") {
|
||||||
IPlatformScreen::CKeyInfo* keyInfo2 =
|
IPlatformScreen::CKeyInfo* keyInfo2 =
|
||||||
IKeyState::CKeyInfo::alloc(*keyInfo);
|
IKeyState::CKeyInfo::alloc(*keyInfo);
|
||||||
action = new CInputFilter::CKeystrokeAction(keyInfo2, true);
|
action = new CInputFilter::CKeystrokeAction(m_events, keyInfo2, true);
|
||||||
rule.adoptAction(action, true);
|
rule.adoptAction(action, true);
|
||||||
action = new CInputFilter::CKeystrokeAction(keyInfo, false);
|
action = new CInputFilter::CKeystrokeAction(m_events, keyInfo, false);
|
||||||
activate = false;
|
activate = false;
|
||||||
}
|
}
|
||||||
else if (name == "keyDown") {
|
else if (name == "keyDown") {
|
||||||
action = new CInputFilter::CKeystrokeAction(keyInfo, true);
|
action = new CInputFilter::CKeystrokeAction(m_events, keyInfo, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = new CInputFilter::CKeystrokeAction(keyInfo, false);
|
action = new CInputFilter::CKeystrokeAction(m_events, keyInfo, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,16 +1133,16 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
if (name == "mousebutton") {
|
if (name == "mousebutton") {
|
||||||
IPlatformScreen::CButtonInfo* mouseInfo2 =
|
IPlatformScreen::CButtonInfo* mouseInfo2 =
|
||||||
IPlatformScreen::CButtonInfo::alloc(*mouseInfo);
|
IPlatformScreen::CButtonInfo::alloc(*mouseInfo);
|
||||||
action = new CInputFilter::CMouseButtonAction(mouseInfo2, true);
|
action = new CInputFilter::CMouseButtonAction(m_events, mouseInfo2, true);
|
||||||
rule.adoptAction(action, true);
|
rule.adoptAction(action, true);
|
||||||
action = new CInputFilter::CMouseButtonAction(mouseInfo, false);
|
action = new CInputFilter::CMouseButtonAction(m_events, mouseInfo, false);
|
||||||
activate = false;
|
activate = false;
|
||||||
}
|
}
|
||||||
else if (name == "mouseDown") {
|
else if (name == "mouseDown") {
|
||||||
action = new CInputFilter::CMouseButtonAction(mouseInfo, true);
|
action = new CInputFilter::CMouseButtonAction(m_events, mouseInfo, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = new CInputFilter::CMouseButtonAction(mouseInfo, false);
|
action = new CInputFilter::CMouseButtonAction(m_events, mouseInfo, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,7 +1171,7 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
throw XConfigRead(s, "unknown screen name in switchToScreen");
|
throw XConfigRead(s, "unknown screen name in switchToScreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
action = new CInputFilter::CSwitchToScreenAction(screen);
|
action = new CInputFilter::CSwitchToScreenAction(m_events, screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "switchInDirection") {
|
else if (name == "switchInDirection") {
|
||||||
|
@ -1192,7 +1196,7 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
throw XConfigRead(s, "unknown direction \"%{1}\" in switchToScreen", args[0]);
|
throw XConfigRead(s, "unknown direction \"%{1}\" in switchToScreen", args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
action = new CInputFilter::CSwitchInDirectionAction(direction);
|
action = new CInputFilter::CSwitchInDirectionAction(m_events, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "lockCursorToScreen") {
|
else if (name == "lockCursorToScreen") {
|
||||||
|
@ -1221,7 +1225,7 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
m_hasLockToScreenAction = true;
|
m_hasLockToScreenAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = new CInputFilter::CLockCursorToScreenAction(mode);
|
action = new CInputFilter::CLockCursorToScreenAction(m_events, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "keyboardBroadcast") {
|
else if (name == "keyboardBroadcast") {
|
||||||
|
@ -1251,7 +1255,7 @@ CConfig::parseAction(CConfigReadContext& s,
|
||||||
parseScreens(s, args[1], screens);
|
parseScreens(s, args[1], screens);
|
||||||
}
|
}
|
||||||
|
|
||||||
action = new CInputFilter::CKeyboardBroadcastAction(mode, screens);
|
action = new CInputFilter::CKeyboardBroadcastAction(m_events, mode, screens);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
class CConfig;
|
class CConfig;
|
||||||
class CConfigReadContext;
|
class CConfigReadContext;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <>
|
template <>
|
||||||
|
@ -172,7 +173,7 @@ public:
|
||||||
internal_const_iterator m_i;
|
internal_const_iterator m_i;
|
||||||
};
|
};
|
||||||
|
|
||||||
CConfig();
|
CConfig(IEventQueue* events);
|
||||||
virtual ~CConfig();
|
virtual ~CConfig();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -468,6 +469,7 @@ private:
|
||||||
CScreenOptions m_globalOptions;
|
CScreenOptions m_globalOptions;
|
||||||
CInputFilter m_inputFilter;
|
CInputFilter m_inputFilter;
|
||||||
bool m_hasLockToScreenAction;
|
bool m_hasLockToScreenAction;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Configuration read context
|
//! Configuration read context
|
||||||
|
|
|
@ -52,7 +52,8 @@ CInputFilter::CCondition::disablePrimary(CPrimaryClient*)
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
|
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
|
||||||
IPlatformScreen::CKeyInfo* info) :
|
IEventQueue* events, IPlatformScreen::CKeyInfo* info) :
|
||||||
|
m_events(events),
|
||||||
m_id(0),
|
m_id(0),
|
||||||
m_key(info->m_key),
|
m_key(info->m_key),
|
||||||
m_mask(info->m_mask)
|
m_mask(info->m_mask)
|
||||||
|
@ -61,7 +62,8 @@ CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
|
CInputFilter::CKeystrokeCondition::CKeystrokeCondition(
|
||||||
KeyID key, KeyModifierMask mask) :
|
IEventQueue* events, KeyID key, KeyModifierMask mask) :
|
||||||
|
m_events(events),
|
||||||
m_id(0),
|
m_id(0),
|
||||||
m_key(key),
|
m_key(key),
|
||||||
m_mask(mask)
|
m_mask(mask)
|
||||||
|
@ -89,7 +91,7 @@ CInputFilter::CKeystrokeCondition::getMask() const
|
||||||
CInputFilter::CCondition*
|
CInputFilter::CCondition*
|
||||||
CInputFilter::CKeystrokeCondition::clone() const
|
CInputFilter::CKeystrokeCondition::clone() const
|
||||||
{
|
{
|
||||||
return new CKeystrokeCondition(m_key, m_mask);
|
return new CKeystrokeCondition(m_events, m_key, m_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
CString
|
||||||
|
@ -106,10 +108,10 @@ CInputFilter::CKeystrokeCondition::match(const CEvent& event)
|
||||||
|
|
||||||
// check for hotkey events
|
// check for hotkey events
|
||||||
CEvent::Type type = event.getType();
|
CEvent::Type type = event.getType();
|
||||||
if (type == IPrimaryScreen::getHotKeyDownEvent()) {
|
if (type == m_events->forIPrimaryScreen().hotKeyDown()) {
|
||||||
status = kActivate;
|
status = kActivate;
|
||||||
}
|
}
|
||||||
else if (type == IPrimaryScreen::getHotKeyUpEvent()) {
|
else if (type == m_events->forIPrimaryScreen().hotKeyUp()) {
|
||||||
status = kDeactivate;
|
status = kDeactivate;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -140,7 +142,8 @@ CInputFilter::CKeystrokeCondition::disablePrimary(CPrimaryClient* primary)
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
|
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
|
||||||
IPlatformScreen::CButtonInfo* info) :
|
IEventQueue* events, IPlatformScreen::CButtonInfo* info) :
|
||||||
|
m_events(events),
|
||||||
m_button(info->m_button),
|
m_button(info->m_button),
|
||||||
m_mask(info->m_mask)
|
m_mask(info->m_mask)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +151,8 @@ CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
|
CInputFilter::CMouseButtonCondition::CMouseButtonCondition(
|
||||||
ButtonID button, KeyModifierMask mask) :
|
IEventQueue* events, ButtonID button, KeyModifierMask mask) :
|
||||||
|
m_events(events),
|
||||||
m_button(button),
|
m_button(button),
|
||||||
m_mask(mask)
|
m_mask(mask)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +179,7 @@ CInputFilter::CMouseButtonCondition::getMask() const
|
||||||
CInputFilter::CCondition*
|
CInputFilter::CCondition*
|
||||||
CInputFilter::CMouseButtonCondition::clone() const
|
CInputFilter::CMouseButtonCondition::clone() const
|
||||||
{
|
{
|
||||||
return new CMouseButtonCondition(m_button, m_mask);
|
return new CMouseButtonCondition(m_events, m_button, m_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
CString
|
||||||
|
@ -199,10 +203,10 @@ CInputFilter::CMouseButtonCondition::match(const CEvent& event)
|
||||||
|
|
||||||
// check for hotkey events
|
// check for hotkey events
|
||||||
CEvent::Type type = event.getType();
|
CEvent::Type type = event.getType();
|
||||||
if (type == IPrimaryScreen::getButtonDownEvent()) {
|
if (type == m_events->forIPrimaryScreen().buttonDown()) {
|
||||||
status = kActivate;
|
status = kActivate;
|
||||||
}
|
}
|
||||||
else if (type == IPrimaryScreen::getButtonUpEvent()) {
|
else if (type == m_events->forIPrimaryScreen().buttonUp()) {
|
||||||
status = kDeactivate;
|
status = kDeactivate;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -222,7 +226,8 @@ CInputFilter::CMouseButtonCondition::match(const CEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CScreenConnectedCondition::CScreenConnectedCondition(
|
CInputFilter::CScreenConnectedCondition::CScreenConnectedCondition(
|
||||||
const CString& screen) :
|
IEventQueue* events, const CString& screen) :
|
||||||
|
m_events(events),
|
||||||
m_screen(screen)
|
m_screen(screen)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -236,7 +241,7 @@ CInputFilter::CScreenConnectedCondition::~CScreenConnectedCondition()
|
||||||
CInputFilter::CCondition*
|
CInputFilter::CCondition*
|
||||||
CInputFilter::CScreenConnectedCondition::clone() const
|
CInputFilter::CScreenConnectedCondition::clone() const
|
||||||
{
|
{
|
||||||
return new CScreenConnectedCondition(m_screen);
|
return new CScreenConnectedCondition(m_events, m_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
CString
|
||||||
|
@ -248,7 +253,7 @@ CInputFilter::CScreenConnectedCondition::format() const
|
||||||
CInputFilter::EFilterStatus
|
CInputFilter::EFilterStatus
|
||||||
CInputFilter::CScreenConnectedCondition::match(const CEvent& event)
|
CInputFilter::CScreenConnectedCondition::match(const CEvent& event)
|
||||||
{
|
{
|
||||||
if (event.getType() == CServer::getConnectedEvent()) {
|
if (event.getType() == m_events->forCServer().connected()) {
|
||||||
CServer::CScreenConnectedInfo* info =
|
CServer::CScreenConnectedInfo* info =
|
||||||
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
|
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
|
||||||
if (m_screen == info->m_screen || m_screen.empty()) {
|
if (m_screen == info->m_screen || m_screen.empty()) {
|
||||||
|
@ -272,7 +277,9 @@ CInputFilter::CAction::~CAction()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CLockCursorToScreenAction::CLockCursorToScreenAction(Mode mode) :
|
CInputFilter::CLockCursorToScreenAction::CLockCursorToScreenAction(
|
||||||
|
IEventQueue* events, Mode mode) :
|
||||||
|
m_events(events),
|
||||||
m_mode(mode)
|
m_mode(mode)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -310,13 +317,14 @@ CInputFilter::CLockCursorToScreenAction::perform(const CEvent& event)
|
||||||
// send event
|
// send event
|
||||||
CServer::CLockCursorToScreenInfo* info =
|
CServer::CLockCursorToScreenInfo* info =
|
||||||
CServer::CLockCursorToScreenInfo::alloc(s_state[m_mode]);
|
CServer::CLockCursorToScreenInfo::alloc(s_state[m_mode]);
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getLockCursorToScreenEvent(),
|
m_events->addEvent(CEvent(m_events->forCServer().lockCursorToScreen(),
|
||||||
event.getTarget(), info,
|
event.getTarget(), info,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CSwitchToScreenAction::CSwitchToScreenAction(
|
CInputFilter::CSwitchToScreenAction::CSwitchToScreenAction(
|
||||||
const CString& screen) :
|
IEventQueue* events, const CString& screen) :
|
||||||
|
m_events(events),
|
||||||
m_screen(screen)
|
m_screen(screen)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -346,7 +354,7 @@ CInputFilter::CSwitchToScreenAction::perform(const CEvent& event)
|
||||||
// pick screen name. if m_screen is empty then use the screen from
|
// pick screen name. if m_screen is empty then use the screen from
|
||||||
// event if it has one.
|
// event if it has one.
|
||||||
CString screen = m_screen;
|
CString screen = m_screen;
|
||||||
if (screen.empty() && event.getType() == CServer::getConnectedEvent()) {
|
if (screen.empty() && event.getType() == m_events->forCServer().connected()) {
|
||||||
CServer::CScreenConnectedInfo* info =
|
CServer::CScreenConnectedInfo* info =
|
||||||
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
|
reinterpret_cast<CServer::CScreenConnectedInfo*>(event.getData());
|
||||||
screen = info->m_screen;
|
screen = info->m_screen;
|
||||||
|
@ -355,13 +363,14 @@ CInputFilter::CSwitchToScreenAction::perform(const CEvent& event)
|
||||||
// send event
|
// send event
|
||||||
CServer::CSwitchToScreenInfo* info =
|
CServer::CSwitchToScreenInfo* info =
|
||||||
CServer::CSwitchToScreenInfo::alloc(screen);
|
CServer::CSwitchToScreenInfo::alloc(screen);
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getSwitchToScreenEvent(),
|
m_events->addEvent(CEvent(m_events->forCServer().switchToScreen(),
|
||||||
event.getTarget(), info,
|
event.getTarget(), info,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CSwitchInDirectionAction::CSwitchInDirectionAction(
|
CInputFilter::CSwitchInDirectionAction::CSwitchInDirectionAction(
|
||||||
EDirection direction) :
|
IEventQueue* events, EDirection direction) :
|
||||||
|
m_events(events),
|
||||||
m_direction(direction)
|
m_direction(direction)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -398,20 +407,24 @@ CInputFilter::CSwitchInDirectionAction::perform(const CEvent& event)
|
||||||
{
|
{
|
||||||
CServer::CSwitchInDirectionInfo* info =
|
CServer::CSwitchInDirectionInfo* info =
|
||||||
CServer::CSwitchInDirectionInfo::alloc(m_direction);
|
CServer::CSwitchInDirectionInfo::alloc(m_direction);
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getSwitchInDirectionEvent(),
|
m_events->addEvent(CEvent(m_events->forCServer().switchInDirection(),
|
||||||
event.getTarget(), info,
|
event.getTarget(), info,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CKeyboardBroadcastAction::CKeyboardBroadcastAction(Mode mode) :
|
CInputFilter::CKeyboardBroadcastAction::CKeyboardBroadcastAction(
|
||||||
|
IEventQueue* events, Mode mode) :
|
||||||
|
m_events(events),
|
||||||
m_mode(mode)
|
m_mode(mode)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CKeyboardBroadcastAction::CKeyboardBroadcastAction(
|
CInputFilter::CKeyboardBroadcastAction::CKeyboardBroadcastAction(
|
||||||
|
IEventQueue* events,
|
||||||
Mode mode,
|
Mode mode,
|
||||||
const std::set<CString>& screens) :
|
const std::set<CString>& screens) :
|
||||||
|
m_events(events),
|
||||||
m_mode(mode),
|
m_mode(mode),
|
||||||
m_screens(IKeyState::CKeyInfo::join(screens))
|
m_screens(IKeyState::CKeyInfo::join(screens))
|
||||||
{
|
{
|
||||||
|
@ -466,13 +479,14 @@ CInputFilter::CKeyboardBroadcastAction::perform(const CEvent& event)
|
||||||
// send event
|
// send event
|
||||||
CServer::CKeyboardBroadcastInfo* info =
|
CServer::CKeyboardBroadcastInfo* info =
|
||||||
CServer::CKeyboardBroadcastInfo::alloc(s_state[m_mode], m_screens);
|
CServer::CKeyboardBroadcastInfo::alloc(s_state[m_mode], m_screens);
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getKeyboardBroadcastEvent(),
|
m_events->addEvent(CEvent(m_events->forCServer().keyboardBroadcast(),
|
||||||
event.getTarget(), info,
|
event.getTarget(), info,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CKeystrokeAction::CKeystrokeAction(
|
CInputFilter::CKeystrokeAction::CKeystrokeAction(
|
||||||
IPlatformScreen::CKeyInfo* info, bool press) :
|
IEventQueue* events, IPlatformScreen::CKeyInfo* info, bool press) :
|
||||||
|
m_events(events),
|
||||||
m_keyInfo(info),
|
m_keyInfo(info),
|
||||||
m_press(press)
|
m_press(press)
|
||||||
{
|
{
|
||||||
|
@ -507,7 +521,7 @@ CInputFilter::CAction*
|
||||||
CInputFilter::CKeystrokeAction::clone() const
|
CInputFilter::CKeystrokeAction::clone() const
|
||||||
{
|
{
|
||||||
IKeyState::CKeyInfo* info = IKeyState::CKeyInfo::alloc(*m_keyInfo);
|
IKeyState::CKeyInfo* info = IKeyState::CKeyInfo::alloc(*m_keyInfo);
|
||||||
return new CKeystrokeAction(info, m_press);
|
return new CKeystrokeAction(m_events, info, m_press);
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
CString
|
||||||
|
@ -537,15 +551,17 @@ CInputFilter::CKeystrokeAction::format() const
|
||||||
void
|
void
|
||||||
CInputFilter::CKeystrokeAction::perform(const CEvent& event)
|
CInputFilter::CKeystrokeAction::perform(const CEvent& event)
|
||||||
{
|
{
|
||||||
CEvent::Type type = m_press ? IPlatformScreen::getKeyDownEvent(*EVENTQUEUE) :
|
CEvent::Type type = m_press ?
|
||||||
IPlatformScreen::getKeyUpEvent(*EVENTQUEUE);
|
m_events->forIKeyState().keyDown() :
|
||||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getFakeInputBeginEvent(),
|
m_events->forIKeyState().keyUp();
|
||||||
|
|
||||||
|
m_events->addEvent(CEvent(m_events->forIPrimaryScreen().fakeInputBegin(),
|
||||||
event.getTarget(), NULL,
|
event.getTarget(), NULL,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
EVENTQUEUE->addEvent(CEvent(type, event.getTarget(), m_keyInfo,
|
m_events->addEvent(CEvent(type, event.getTarget(), m_keyInfo,
|
||||||
CEvent::kDeliverImmediately |
|
CEvent::kDeliverImmediately |
|
||||||
CEvent::kDontFreeData));
|
CEvent::kDontFreeData));
|
||||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getFakeInputEndEvent(),
|
m_events->addEvent(CEvent(m_events->forIPrimaryScreen().fakeInputEnd(),
|
||||||
event.getTarget(), NULL,
|
event.getTarget(), NULL,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
@ -557,7 +573,8 @@ CInputFilter::CKeystrokeAction::formatName() const
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CMouseButtonAction::CMouseButtonAction(
|
CInputFilter::CMouseButtonAction::CMouseButtonAction(
|
||||||
IPlatformScreen::CButtonInfo* info, bool press) :
|
IEventQueue* events, IPlatformScreen::CButtonInfo* info, bool press) :
|
||||||
|
m_events(events),
|
||||||
m_buttonInfo(info),
|
m_buttonInfo(info),
|
||||||
m_press(press)
|
m_press(press)
|
||||||
{
|
{
|
||||||
|
@ -586,7 +603,7 @@ CInputFilter::CMouseButtonAction::clone() const
|
||||||
{
|
{
|
||||||
IPlatformScreen::CButtonInfo* info =
|
IPlatformScreen::CButtonInfo* info =
|
||||||
IPrimaryScreen::CButtonInfo::alloc(*m_buttonInfo);
|
IPrimaryScreen::CButtonInfo::alloc(*m_buttonInfo);
|
||||||
return new CMouseButtonAction(info, m_press);
|
return new CMouseButtonAction(m_events, info, m_press);
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
CString
|
||||||
|
@ -610,15 +627,15 @@ CInputFilter::CMouseButtonAction::perform(const CEvent& event)
|
||||||
KeyID key = m_press ? kKeySetModifiers : kKeyClearModifiers;
|
KeyID key = m_press ? kKeySetModifiers : kKeyClearModifiers;
|
||||||
modifierInfo =
|
modifierInfo =
|
||||||
IKeyState::CKeyInfo::alloc(key, m_buttonInfo->m_mask, 0, 1);
|
IKeyState::CKeyInfo::alloc(key, m_buttonInfo->m_mask, 0, 1);
|
||||||
EVENTQUEUE->addEvent(CEvent(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
m_events->addEvent(CEvent(m_events->forIKeyState().keyDown(),
|
||||||
event.getTarget(), modifierInfo,
|
event.getTarget(), modifierInfo,
|
||||||
CEvent::kDeliverImmediately));
|
CEvent::kDeliverImmediately));
|
||||||
}
|
}
|
||||||
|
|
||||||
// send button
|
// send button
|
||||||
CEvent::Type type = m_press ? IPlatformScreen::getButtonDownEvent() :
|
CEvent::Type type = m_press ? m_events->forIPrimaryScreen().buttonDown() :
|
||||||
IPlatformScreen::getButtonUpEvent();
|
m_events->forIPrimaryScreen().buttonUp();
|
||||||
EVENTQUEUE->addEvent(CEvent(type, event.getTarget(), m_buttonInfo,
|
m_events->addEvent(CEvent(type, event.getTarget(), m_buttonInfo,
|
||||||
CEvent::kDeliverImmediately |
|
CEvent::kDeliverImmediately |
|
||||||
CEvent::kDontFreeData));
|
CEvent::kDontFreeData));
|
||||||
}
|
}
|
||||||
|
@ -869,13 +886,15 @@ CInputFilter::CRule::getAction(bool onActivation, UInt32 index) const
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Input Filter Class
|
// Input Filter Class
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
CInputFilter::CInputFilter() :
|
CInputFilter::CInputFilter(IEventQueue* events) :
|
||||||
|
m_events(events),
|
||||||
m_primaryClient(NULL)
|
m_primaryClient(NULL)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
CInputFilter::CInputFilter(const CInputFilter& x) :
|
CInputFilter::CInputFilter(const CInputFilter& x) :
|
||||||
|
m_events(x.m_events),
|
||||||
m_ruleList(x.m_ruleList),
|
m_ruleList(x.m_ruleList),
|
||||||
m_primaryClient(NULL)
|
m_primaryClient(NULL)
|
||||||
{
|
{
|
||||||
|
@ -938,56 +957,56 @@ CInputFilter::setPrimaryClient(CPrimaryClient* client)
|
||||||
rule->disable(m_primaryClient);
|
rule->disable(m_primaryClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyDown(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyUp(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyRepeat(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonDownEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().buttonDown(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonUpEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().buttonUp(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getHotKeyDownEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().hotKeyDown(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getHotKeyUpEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().hotKeyUp(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(CServer::getConnectedEvent(),
|
m_events->removeHandler(m_events->forCServer().connected(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_primaryClient = client;
|
m_primaryClient = client;
|
||||||
|
|
||||||
if (m_primaryClient != NULL) {
|
if (m_primaryClient != NULL) {
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyDown(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyUp(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyRepeat(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonDownEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().buttonDown(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonUpEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().buttonUp(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getHotKeyDownEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().hotKeyDown(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getHotKeyUpEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().hotKeyUp(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
EVENTQUEUE->adoptHandler(CServer::getConnectedEvent(),
|
m_events->adoptHandler(m_events->forCServer().connected(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CInputFilter>(this,
|
new TMethodEventJob<CInputFilter>(this,
|
||||||
&CInputFilter::handleEvent));
|
&CInputFilter::handleEvent));
|
||||||
|
@ -1066,5 +1085,5 @@ CInputFilter::handleEvent(const CEvent& event, void*)
|
||||||
}
|
}
|
||||||
|
|
||||||
// not handled so pass through
|
// not handled so pass through
|
||||||
EVENTQUEUE->addEvent(myEvent);
|
m_events->addEvent(myEvent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
class CPrimaryClient;
|
class CPrimaryClient;
|
||||||
class CEvent;
|
class CEvent;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
class CInputFilter {
|
class CInputFilter {
|
||||||
public:
|
public:
|
||||||
|
@ -58,8 +59,8 @@ public:
|
||||||
// CKeystrokeCondition
|
// CKeystrokeCondition
|
||||||
class CKeystrokeCondition : public CCondition {
|
class CKeystrokeCondition : public CCondition {
|
||||||
public:
|
public:
|
||||||
CKeystrokeCondition(IPlatformScreen::CKeyInfo*);
|
CKeystrokeCondition(IEventQueue* events, IPlatformScreen::CKeyInfo*);
|
||||||
CKeystrokeCondition(KeyID key, KeyModifierMask mask);
|
CKeystrokeCondition(IEventQueue* events, KeyID key, KeyModifierMask mask);
|
||||||
virtual ~CKeystrokeCondition();
|
virtual ~CKeystrokeCondition();
|
||||||
|
|
||||||
KeyID getKey() const;
|
KeyID getKey() const;
|
||||||
|
@ -76,13 +77,14 @@ public:
|
||||||
UInt32 m_id;
|
UInt32 m_id;
|
||||||
KeyID m_key;
|
KeyID m_key;
|
||||||
KeyModifierMask m_mask;
|
KeyModifierMask m_mask;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CMouseButtonCondition
|
// CMouseButtonCondition
|
||||||
class CMouseButtonCondition : public CCondition {
|
class CMouseButtonCondition : public CCondition {
|
||||||
public:
|
public:
|
||||||
CMouseButtonCondition(IPlatformScreen::CButtonInfo*);
|
CMouseButtonCondition(IEventQueue* events, IPlatformScreen::CButtonInfo*);
|
||||||
CMouseButtonCondition(ButtonID, KeyModifierMask mask);
|
CMouseButtonCondition(IEventQueue* events, ButtonID, KeyModifierMask mask);
|
||||||
virtual ~CMouseButtonCondition();
|
virtual ~CMouseButtonCondition();
|
||||||
|
|
||||||
ButtonID getButton() const;
|
ButtonID getButton() const;
|
||||||
|
@ -96,12 +98,13 @@ public:
|
||||||
private:
|
private:
|
||||||
ButtonID m_button;
|
ButtonID m_button;
|
||||||
KeyModifierMask m_mask;
|
KeyModifierMask m_mask;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CScreenConnectedCondition
|
// CScreenConnectedCondition
|
||||||
class CScreenConnectedCondition : public CCondition {
|
class CScreenConnectedCondition : public CCondition {
|
||||||
public:
|
public:
|
||||||
CScreenConnectedCondition(const CString& screen);
|
CScreenConnectedCondition(IEventQueue* events, const CString& screen);
|
||||||
virtual ~CScreenConnectedCondition();
|
virtual ~CScreenConnectedCondition();
|
||||||
|
|
||||||
// CCondition overrides
|
// CCondition overrides
|
||||||
|
@ -111,6 +114,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CString m_screen;
|
CString m_screen;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
@ -133,7 +137,7 @@ public:
|
||||||
public:
|
public:
|
||||||
enum Mode { kOff, kOn, kToggle };
|
enum Mode { kOff, kOn, kToggle };
|
||||||
|
|
||||||
CLockCursorToScreenAction(Mode = kToggle);
|
CLockCursorToScreenAction(IEventQueue* events, Mode = kToggle);
|
||||||
|
|
||||||
Mode getMode() const;
|
Mode getMode() const;
|
||||||
|
|
||||||
|
@ -144,12 +148,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mode m_mode;
|
Mode m_mode;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CSwitchToScreenAction
|
// CSwitchToScreenAction
|
||||||
class CSwitchToScreenAction : public CAction {
|
class CSwitchToScreenAction : public CAction {
|
||||||
public:
|
public:
|
||||||
CSwitchToScreenAction(const CString& screen);
|
CSwitchToScreenAction(IEventQueue* events, const CString& screen);
|
||||||
|
|
||||||
CString getScreen() const;
|
CString getScreen() const;
|
||||||
|
|
||||||
|
@ -160,12 +165,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CString m_screen;
|
CString m_screen;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CSwitchInDirectionAction
|
// CSwitchInDirectionAction
|
||||||
class CSwitchInDirectionAction : public CAction {
|
class CSwitchInDirectionAction : public CAction {
|
||||||
public:
|
public:
|
||||||
CSwitchInDirectionAction(EDirection);
|
CSwitchInDirectionAction(IEventQueue* events, EDirection);
|
||||||
|
|
||||||
EDirection getDirection() const;
|
EDirection getDirection() const;
|
||||||
|
|
||||||
|
@ -176,6 +182,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EDirection m_direction;
|
EDirection m_direction;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CKeyboardBroadcastAction
|
// CKeyboardBroadcastAction
|
||||||
|
@ -183,8 +190,8 @@ public:
|
||||||
public:
|
public:
|
||||||
enum Mode { kOff, kOn, kToggle };
|
enum Mode { kOff, kOn, kToggle };
|
||||||
|
|
||||||
CKeyboardBroadcastAction(Mode = kToggle);
|
CKeyboardBroadcastAction(IEventQueue* events, Mode = kToggle);
|
||||||
CKeyboardBroadcastAction(Mode, const std::set<CString>& screens);
|
CKeyboardBroadcastAction(IEventQueue* events, Mode, const std::set<CString>& screens);
|
||||||
|
|
||||||
Mode getMode() const;
|
Mode getMode() const;
|
||||||
std::set<CString> getScreens() const;
|
std::set<CString> getScreens() const;
|
||||||
|
@ -197,12 +204,13 @@ public:
|
||||||
private:
|
private:
|
||||||
Mode m_mode;
|
Mode m_mode;
|
||||||
CString m_screens;
|
CString m_screens;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CKeystrokeAction
|
// CKeystrokeAction
|
||||||
class CKeystrokeAction : public CAction {
|
class CKeystrokeAction : public CAction {
|
||||||
public:
|
public:
|
||||||
CKeystrokeAction(IPlatformScreen::CKeyInfo* adoptedInfo, bool press);
|
CKeystrokeAction(IEventQueue* events, IPlatformScreen::CKeyInfo* adoptedInfo, bool press);
|
||||||
~CKeystrokeAction();
|
~CKeystrokeAction();
|
||||||
|
|
||||||
void adoptInfo(IPlatformScreen::CKeyInfo*);
|
void adoptInfo(IPlatformScreen::CKeyInfo*);
|
||||||
|
@ -220,13 +228,15 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IPlatformScreen::CKeyInfo* m_keyInfo;
|
IPlatformScreen::CKeyInfo* m_keyInfo;
|
||||||
bool m_press;
|
bool m_press;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CMouseButtonAction -- modifier combinations not implemented yet
|
// CMouseButtonAction -- modifier combinations not implemented yet
|
||||||
class CMouseButtonAction : public CAction {
|
class CMouseButtonAction : public CAction {
|
||||||
public:
|
public:
|
||||||
CMouseButtonAction(IPlatformScreen::CButtonInfo* adoptedInfo,
|
CMouseButtonAction(IEventQueue* events,
|
||||||
|
IPlatformScreen::CButtonInfo* adoptedInfo,
|
||||||
bool press);
|
bool press);
|
||||||
~CMouseButtonAction();
|
~CMouseButtonAction();
|
||||||
|
|
||||||
|
@ -244,7 +254,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IPlatformScreen::CButtonInfo* m_buttonInfo;
|
IPlatformScreen::CButtonInfo* m_buttonInfo;
|
||||||
bool m_press;
|
bool m_press;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CRule {
|
class CRule {
|
||||||
|
@ -306,7 +317,7 @@ public:
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
typedef std::vector<CRule> CRuleList;
|
typedef std::vector<CRule> CRuleList;
|
||||||
|
|
||||||
CInputFilter();
|
CInputFilter(IEventQueue* events);
|
||||||
CInputFilter(const CInputFilter&);
|
CInputFilter(const CInputFilter&);
|
||||||
virtual ~CInputFilter();
|
virtual ~CInputFilter();
|
||||||
|
|
||||||
|
@ -343,6 +354,7 @@ private:
|
||||||
private:
|
private:
|
||||||
CRuleList m_ruleList;
|
CRuleList m_ruleList;
|
||||||
CPrimaryClient* m_primaryClient;
|
CPrimaryClient* m_primaryClient;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,16 +41,8 @@
|
||||||
// CServer
|
// CServer
|
||||||
//
|
//
|
||||||
|
|
||||||
CEvent::Type CServer::s_errorEvent = CEvent::kUnknown;
|
CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen* screen, IEventQueue* events) :
|
||||||
CEvent::Type CServer::s_connectedEvent = CEvent::kUnknown;
|
m_events(events),
|
||||||
CEvent::Type CServer::s_disconnectedEvent = CEvent::kUnknown;
|
|
||||||
CEvent::Type CServer::s_switchToScreen = CEvent::kUnknown;
|
|
||||||
CEvent::Type CServer::s_switchInDirection = CEvent::kUnknown;
|
|
||||||
CEvent::Type CServer::s_keyboardBroadcast = CEvent::kUnknown;
|
|
||||||
CEvent::Type CServer::s_lockCursorToScreen = CEvent::kUnknown;
|
|
||||||
CEvent::Type CServer::s_screenSwitched = CEvent::kUnknown;
|
|
||||||
|
|
||||||
CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen* screen) :
|
|
||||||
m_mock(false),
|
m_mock(false),
|
||||||
m_primaryClient(primaryClient),
|
m_primaryClient(primaryClient),
|
||||||
m_active(primaryClient),
|
m_active(primaryClient),
|
||||||
|
@ -59,7 +51,7 @@ CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen*
|
||||||
m_yDelta(0),
|
m_yDelta(0),
|
||||||
m_xDelta2(0),
|
m_xDelta2(0),
|
||||||
m_yDelta2(0),
|
m_yDelta2(0),
|
||||||
m_config(),
|
m_config(events),
|
||||||
m_inputFilter(m_config.getInputFilter()),
|
m_inputFilter(m_config.getInputFilter()),
|
||||||
m_activeSaver(NULL),
|
m_activeSaver(NULL),
|
||||||
m_switchDir(kNoDirection),
|
m_switchDir(kNoDirection),
|
||||||
|
@ -98,86 +90,86 @@ CServer::CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen*
|
||||||
}
|
}
|
||||||
|
|
||||||
// install event handlers
|
// install event handlers
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, this,
|
m_events->adoptHandler(CEvent::kTimer, this,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleSwitchWaitTimeout));
|
&CServer::handleSwitchWaitTimeout));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyDown(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleKeyDownEvent));
|
&CServer::handleKeyDownEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyUp(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleKeyUpEvent));
|
&CServer::handleKeyUpEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getKeyRepeatEvent(* EVENTQUEUE),
|
m_events->adoptHandler(m_events->forIKeyState().keyRepeat(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleKeyRepeatEvent));
|
&CServer::handleKeyRepeatEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonDownEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().buttonDown(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleButtonDownEvent));
|
&CServer::handleButtonDownEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getButtonUpEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().buttonUp(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleButtonUpEvent));
|
&CServer::handleButtonUpEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getMotionOnPrimaryEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleMotionPrimaryEvent));
|
&CServer::handleMotionPrimaryEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getMotionOnSecondaryEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().motionOnSecondary(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleMotionSecondaryEvent));
|
&CServer::handleMotionSecondaryEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getWheelEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().wheel(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleWheelEvent));
|
&CServer::handleWheelEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getGameDeviceButtonsEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceButtons(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleGameDeviceButtons));
|
&CServer::handleGameDeviceButtons));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getGameDeviceSticksEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceSticks(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleGameDeviceSticks));
|
&CServer::handleGameDeviceSticks));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getGameDeviceTriggersEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceTriggers(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleGameDeviceTriggers));
|
&CServer::handleGameDeviceTriggers));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getGameDeviceTimingReqEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().gameDeviceTimingReq(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleGameDeviceTimingReq));
|
&CServer::handleGameDeviceTimingReq));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getScreensaverActivatedEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().screensaverActivated(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleScreensaverActivatedEvent));
|
&CServer::handleScreensaverActivatedEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getScreensaverDeactivatedEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().screensaverDeactivated(),
|
||||||
m_primaryClient->getEventTarget(),
|
m_primaryClient->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleScreensaverDeactivatedEvent));
|
&CServer::handleScreensaverDeactivatedEvent));
|
||||||
EVENTQUEUE->adoptHandler(getSwitchToScreenEvent(),
|
m_events->adoptHandler(m_events->forCServer().switchToScreen(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleSwitchToScreenEvent));
|
&CServer::handleSwitchToScreenEvent));
|
||||||
EVENTQUEUE->adoptHandler(getSwitchInDirectionEvent(),
|
m_events->adoptHandler(m_events->forCServer().switchInDirection(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleSwitchInDirectionEvent));
|
&CServer::handleSwitchInDirectionEvent));
|
||||||
EVENTQUEUE->adoptHandler(getKeyboardBroadcastEvent(),
|
m_events->adoptHandler(m_events->forCServer().keyboardBroadcast(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleKeyboardBroadcastEvent));
|
&CServer::handleKeyboardBroadcastEvent));
|
||||||
EVENTQUEUE->adoptHandler(getLockCursorToScreenEvent(),
|
m_events->adoptHandler(m_events->forCServer().lockCursorToScreen(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleLockCursorToScreenEvent));
|
&CServer::handleLockCursorToScreenEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getFakeInputBeginEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().fakeInputBegin(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleFakeInputBeginEvent));
|
&CServer::handleFakeInputBeginEvent));
|
||||||
EVENTQUEUE->adoptHandler(IPlatformScreen::getFakeInputEndEvent(),
|
m_events->adoptHandler(m_events->forIPrimaryScreen().fakeInputEnd(),
|
||||||
m_inputFilter,
|
m_inputFilter,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleFakeInputEndEvent));
|
&CServer::handleFakeInputEndEvent));
|
||||||
|
@ -208,31 +200,31 @@ CServer::~CServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove event handlers and timers
|
// remove event handlers and timers
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyDownEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyDown(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyUpEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyUp(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getKeyRepeatEvent(*EVENTQUEUE),
|
m_events->removeHandler(m_events->forIKeyState().keyRepeat(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonDownEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().buttonDown(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getButtonUpEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().buttonUp(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getMotionOnPrimaryEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().motionOnPrimary(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getMotionOnSecondaryEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().motionOnSecondary(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getWheelEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().wheel(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getScreensaverActivatedEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().screensaverActivated(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getScreensaverDeactivatedEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().screensaverDeactivated(),
|
||||||
m_primaryClient->getEventTarget());
|
m_primaryClient->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getFakeInputBeginEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().fakeInputBegin(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(IPlatformScreen::getFakeInputEndEvent(),
|
m_events->removeHandler(m_events->forIPrimaryScreen().fakeInputEnd(),
|
||||||
m_inputFilter);
|
m_inputFilter);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, this);
|
m_events->removeHandler(CEvent::kTimer, this);
|
||||||
stopSwitch();
|
stopSwitch();
|
||||||
|
|
||||||
// force immediate disconnection of secondary clients
|
// force immediate disconnection of secondary clients
|
||||||
|
@ -240,9 +232,9 @@ CServer::~CServer()
|
||||||
for (COldClients::iterator index = m_oldClients.begin();
|
for (COldClients::iterator index = m_oldClients.begin();
|
||||||
index != m_oldClients.begin(); ++index) {
|
index != m_oldClients.begin(); ++index) {
|
||||||
CBaseClientProxy* client = index->first;
|
CBaseClientProxy* client = index->first;
|
||||||
EVENTQUEUE->deleteTimer(index->second);
|
m_events->deleteTimer(index->second);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, client);
|
m_events->removeHandler(CEvent::kTimer, client);
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(), client);
|
||||||
delete client;
|
delete client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,8 +272,8 @@ CServer::setConfig(const CConfig& config)
|
||||||
if (!m_config.hasLockToScreenAction()) {
|
if (!m_config.hasLockToScreenAction()) {
|
||||||
IPlatformScreen::CKeyInfo* key =
|
IPlatformScreen::CKeyInfo* key =
|
||||||
IPlatformScreen::CKeyInfo::alloc(kKeyScrollLock, 0, 0, 0);
|
IPlatformScreen::CKeyInfo::alloc(kKeyScrollLock, 0, 0, 0);
|
||||||
CInputFilter::CRule rule(new CInputFilter::CKeystrokeCondition(key));
|
CInputFilter::CRule rule(new CInputFilter::CKeystrokeCondition(m_events, key));
|
||||||
rule.adoptAction(new CInputFilter::CLockCursorToScreenAction, true);
|
rule.adoptAction(new CInputFilter::CLockCursorToScreenAction(m_events), true);
|
||||||
m_inputFilter->addFilterRule(rule);
|
m_inputFilter->addFilterRule(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +296,7 @@ CServer::adoptClient(CBaseClientProxy* client)
|
||||||
assert(client != NULL);
|
assert(client != NULL);
|
||||||
|
|
||||||
// watch for client disconnection
|
// watch for client disconnection
|
||||||
EVENTQUEUE->adoptHandler(CClientProxy::getDisconnectedEvent(), client,
|
m_events->adoptHandler(m_events->forCClientProxy().disconnected(), client,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleClientDisconnected, client));
|
&CServer::handleClientDisconnected, client));
|
||||||
|
|
||||||
|
@ -335,7 +327,7 @@ CServer::adoptClient(CBaseClientProxy* client)
|
||||||
// send notification
|
// send notification
|
||||||
CServer::CScreenConnectedInfo* info =
|
CServer::CScreenConnectedInfo* info =
|
||||||
new CServer::CScreenConnectedInfo(getName(client));
|
new CServer::CScreenConnectedInfo(getName(client));
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getConnectedEvent(),
|
m_events->addEvent(CEvent(m_events->forCServer().connected(),
|
||||||
m_primaryClient->getEventTarget(), info));
|
m_primaryClient->getEventTarget(), info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,11 +336,11 @@ CServer::disconnect()
|
||||||
{
|
{
|
||||||
// close all secondary clients
|
// close all secondary clients
|
||||||
if (m_clients.size() > 1 || !m_oldClients.empty()) {
|
if (m_clients.size() > 1 || !m_oldClients.empty()) {
|
||||||
CConfig emptyConfig;
|
CConfig emptyConfig(m_events);
|
||||||
closeClients(emptyConfig);
|
closeClients(emptyConfig);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EVENTQUEUE->addEvent(CEvent(getDisconnectedEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCServer().disconnected(), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,62 +372,6 @@ CServer::getClients(std::vector<CString>& list) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getErrorEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_errorEvent,
|
|
||||||
"CServer::error");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getConnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_connectedEvent,
|
|
||||||
"CServer::connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getDisconnectedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_disconnectedEvent,
|
|
||||||
"CServer::disconnected");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getSwitchToScreenEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_switchToScreen,
|
|
||||||
"CServer::switchToScreen");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getSwitchInDirectionEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_switchInDirection,
|
|
||||||
"CServer::switchInDirection");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getKeyboardBroadcastEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_keyboardBroadcast,
|
|
||||||
"CServer:keyboardBroadcast");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getLockCursorToScreenEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_lockCursorToScreen,
|
|
||||||
"CServer::lockCursorToScreen");
|
|
||||||
}
|
|
||||||
|
|
||||||
CEvent::Type
|
|
||||||
CServer::getScreenSwitchedEvent()
|
|
||||||
{
|
|
||||||
return EVENTQUEUE->registerTypeOnce(s_screenSwitched,
|
|
||||||
"CServer::screenSwitched");
|
|
||||||
}
|
|
||||||
|
|
||||||
CString
|
CString
|
||||||
CServer::getName(const CBaseClientProxy* client) const
|
CServer::getName(const CBaseClientProxy* client) const
|
||||||
{
|
{
|
||||||
|
@ -571,7 +507,7 @@ CServer::switchScreen(CBaseClientProxy* dst,
|
||||||
|
|
||||||
CServer::CSwitchToScreenInfo* info =
|
CServer::CSwitchToScreenInfo* info =
|
||||||
CServer::CSwitchToScreenInfo::alloc(m_active->getName());
|
CServer::CSwitchToScreenInfo::alloc(m_active->getName());
|
||||||
EVENTQUEUE->addEvent(CEvent(CServer::getScreenSwitchedEvent(), this, info));
|
m_events->addEvent(CEvent(m_events->forCServer().screenSwitched(), this, info));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_active->mouseMove(x, y);
|
m_active->mouseMove(x, y);
|
||||||
|
@ -1052,7 +988,7 @@ CServer::startSwitchWait(SInt32 x, SInt32 y)
|
||||||
stopSwitchWait();
|
stopSwitchWait();
|
||||||
m_switchWaitX = x;
|
m_switchWaitX = x;
|
||||||
m_switchWaitY = y;
|
m_switchWaitY = y;
|
||||||
m_switchWaitTimer = EVENTQUEUE->newOneShotTimer(m_switchWaitDelay, this);
|
m_switchWaitTimer = m_events->newOneShotTimer(m_switchWaitDelay, this);
|
||||||
LOG((CLOG_DEBUG1 "waiting to switch"));
|
LOG((CLOG_DEBUG1 "waiting to switch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1060,7 +996,7 @@ void
|
||||||
CServer::stopSwitchWait()
|
CServer::stopSwitchWait()
|
||||||
{
|
{
|
||||||
if (m_switchWaitTimer != NULL) {
|
if (m_switchWaitTimer != NULL) {
|
||||||
EVENTQUEUE->deleteTimer(m_switchWaitTimer);
|
m_events->deleteTimer(m_switchWaitTimer);
|
||||||
m_switchWaitTimer = NULL;
|
m_switchWaitTimer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2043,15 +1979,15 @@ CServer::addClient(CBaseClientProxy* client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add event handlers
|
// add event handlers
|
||||||
EVENTQUEUE->adoptHandler(IScreen::getShapeChangedEvent(),
|
m_events->adoptHandler(m_events->forIScreen().shapeChanged(),
|
||||||
client->getEventTarget(),
|
client->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleShapeChanged, client));
|
&CServer::handleShapeChanged, client));
|
||||||
EVENTQUEUE->adoptHandler(IScreen::getClipboardGrabbedEvent(),
|
m_events->adoptHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||||
client->getEventTarget(),
|
client->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleClipboardGrabbed, client));
|
&CServer::handleClipboardGrabbed, client));
|
||||||
EVENTQUEUE->adoptHandler(CClientProxy::getClipboardChangedEvent(),
|
m_events->adoptHandler(m_events->forCClientProxy().clipboardChanged(),
|
||||||
client->getEventTarget(),
|
client->getEventTarget(),
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleClipboardChanged, client));
|
&CServer::handleClipboardChanged, client));
|
||||||
|
@ -2081,11 +2017,11 @@ CServer::removeClient(CBaseClientProxy* client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove event handlers
|
// remove event handlers
|
||||||
EVENTQUEUE->removeHandler(IScreen::getShapeChangedEvent(),
|
m_events->removeHandler(m_events->forIScreen().shapeChanged(),
|
||||||
client->getEventTarget());
|
client->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(IScreen::getClipboardGrabbedEvent(),
|
m_events->removeHandler(m_events->forIScreen().clipboardGrabbed(),
|
||||||
client->getEventTarget());
|
client->getEventTarget());
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getClipboardChangedEvent(),
|
m_events->removeHandler(m_events->forCClientProxy().clipboardChanged(),
|
||||||
client->getEventTarget());
|
client->getEventTarget());
|
||||||
|
|
||||||
// remove from list
|
// remove from list
|
||||||
|
@ -2117,8 +2053,8 @@ CServer::closeClient(CBaseClientProxy* client, const char* msg)
|
||||||
|
|
||||||
// install timer. wait timeout seconds for client to close.
|
// install timer. wait timeout seconds for client to close.
|
||||||
double timeout = 5.0;
|
double timeout = 5.0;
|
||||||
CEventQueueTimer* timer = EVENTQUEUE->newOneShotTimer(timeout, NULL);
|
CEventQueueTimer* timer = m_events->newOneShotTimer(timeout, NULL);
|
||||||
EVENTQUEUE->adoptHandler(CEvent::kTimer, timer,
|
m_events->adoptHandler(CEvent::kTimer, timer,
|
||||||
new TMethodEventJob<CServer>(this,
|
new TMethodEventJob<CServer>(this,
|
||||||
&CServer::handleClientCloseTimeout, client));
|
&CServer::handleClientCloseTimeout, client));
|
||||||
|
|
||||||
|
@ -2161,9 +2097,9 @@ CServer::removeActiveClient(CBaseClientProxy* client)
|
||||||
{
|
{
|
||||||
if (removeClient(client)) {
|
if (removeClient(client)) {
|
||||||
forceLeaveClient(client);
|
forceLeaveClient(client);
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(), client);
|
||||||
if (m_clients.size() == 1 && m_oldClients.empty()) {
|
if (m_clients.size() == 1 && m_oldClients.empty()) {
|
||||||
EVENTQUEUE->addEvent(CEvent(getDisconnectedEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCServer().disconnected(), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2173,12 +2109,12 @@ CServer::removeOldClient(CBaseClientProxy* client)
|
||||||
{
|
{
|
||||||
COldClients::iterator i = m_oldClients.find(client);
|
COldClients::iterator i = m_oldClients.find(client);
|
||||||
if (i != m_oldClients.end()) {
|
if (i != m_oldClients.end()) {
|
||||||
EVENTQUEUE->removeHandler(CClientProxy::getDisconnectedEvent(), client);
|
m_events->removeHandler(m_events->forCClientProxy().disconnected(), client);
|
||||||
EVENTQUEUE->removeHandler(CEvent::kTimer, i->second);
|
m_events->removeHandler(CEvent::kTimer, i->second);
|
||||||
EVENTQUEUE->deleteTimer(i->second);
|
m_events->deleteTimer(i->second);
|
||||||
m_oldClients.erase(i);
|
m_oldClients.erase(i);
|
||||||
if (m_clients.size() == 1 && m_oldClients.empty()) {
|
if (m_clients.size() == 1 && m_oldClients.empty()) {
|
||||||
EVENTQUEUE->addEvent(CEvent(getDisconnectedEvent(), this));
|
m_events->addEvent(CEvent(m_events->forCServer().disconnected(), this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,18 +30,20 @@
|
||||||
#include "stdset.h"
|
#include "stdset.h"
|
||||||
#include "stdvector.h"
|
#include "stdvector.h"
|
||||||
#include "INode.h"
|
#include "INode.h"
|
||||||
|
#include "CEventTypes.h"
|
||||||
|
|
||||||
class CBaseClientProxy;
|
class CBaseClientProxy;
|
||||||
class CEventQueueTimer;
|
class CEventQueueTimer;
|
||||||
class CPrimaryClient;
|
class CPrimaryClient;
|
||||||
class CInputFilter;
|
class CInputFilter;
|
||||||
class CScreen;
|
class CScreen;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
//! Synergy server
|
//! Synergy server
|
||||||
/*!
|
/*!
|
||||||
This class implements the top-level server algorithms for synergy.
|
This class implements the top-level server algorithms for synergy.
|
||||||
*/
|
*/
|
||||||
class CServer : public INode {
|
class CServer : public INode {
|
||||||
public:
|
public:
|
||||||
//! Lock cursor to screen data
|
//! Lock cursor to screen data
|
||||||
class CLockCursorToScreenInfo {
|
class CLockCursorToScreenInfo {
|
||||||
|
@ -101,11 +103,11 @@ public:
|
||||||
client (local screen) \p primaryClient. The client retains
|
client (local screen) \p primaryClient. The client retains
|
||||||
ownership of \p primaryClient.
|
ownership of \p primaryClient.
|
||||||
*/
|
*/
|
||||||
CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen* screen);
|
CServer(const CConfig& config, CPrimaryClient* primaryClient, CScreen* screen, IEventQueue* events);
|
||||||
~CServer();
|
~CServer();
|
||||||
|
|
||||||
#ifdef TEST_ENV
|
#ifdef TEST_ENV
|
||||||
CServer() { }
|
CServer() : m_mock(true), m_events(NULL), m_config(NULL) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
@ -157,67 +159,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void getClients(std::vector<CString>& list) const;
|
void getClients(std::vector<CString>& list) const;
|
||||||
|
|
||||||
//! Get error event type
|
|
||||||
/*!
|
|
||||||
Returns the error event type. This is sent when the server fails
|
|
||||||
for some reason.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getErrorEvent();
|
|
||||||
|
|
||||||
//! Get connected event type
|
|
||||||
/*!
|
|
||||||
Returns the connected event type. This is sent when a client screen
|
|
||||||
has connected. The event data is a \c CScreenConnectedInfo* that
|
|
||||||
indicates the connected screen.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getConnectedEvent();
|
|
||||||
|
|
||||||
//! Get disconnected event type
|
|
||||||
/*!
|
|
||||||
Returns the disconnected event type. This is sent when all the
|
|
||||||
clients have disconnected.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getDisconnectedEvent();
|
|
||||||
|
|
||||||
//! Get switch to screen event type
|
|
||||||
/*!
|
|
||||||
Returns the switch to screen event type. The server responds to this
|
|
||||||
by switching screens. The event data is a \c CSwitchToScreenInfo*
|
|
||||||
that indicates the target screen.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getSwitchToScreenEvent();
|
|
||||||
|
|
||||||
//! Get switch in direction event type
|
|
||||||
/*!
|
|
||||||
Returns the switch in direction event type. The server responds to this
|
|
||||||
by switching screens. The event data is a \c CSwitchInDirectionInfo*
|
|
||||||
that indicates the target direction.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getSwitchInDirectionEvent();
|
|
||||||
|
|
||||||
//! Get keyboard broadcast event type
|
|
||||||
/*!
|
|
||||||
Returns the keyboard broadcast event type. The server responds
|
|
||||||
to this by turning on keyboard broadcasting or turning it off. The
|
|
||||||
event data is a \c CKeyboardBroadcastInfo*.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getKeyboardBroadcastEvent();
|
|
||||||
|
|
||||||
//! Get lock cursor event type
|
|
||||||
/*!
|
|
||||||
Returns the lock cursor event type. The server responds to this
|
|
||||||
by locking the cursor to the active screen or unlocking it. The
|
|
||||||
event data is a \c CLockCursorToScreenInfo*.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getLockCursorToScreenEvent();
|
|
||||||
|
|
||||||
//! Get screen switched event type
|
|
||||||
/*!
|
|
||||||
Returns the screen switched event type. This is raised when the
|
|
||||||
screen has been switched to a client.
|
|
||||||
*/
|
|
||||||
static CEvent::Type getScreenSwitchedEvent();
|
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -493,14 +434,7 @@ private:
|
||||||
// server screen
|
// server screen
|
||||||
CScreen* m_screen;
|
CScreen* m_screen;
|
||||||
|
|
||||||
static CEvent::Type s_errorEvent;
|
IEventQueue* m_events;
|
||||||
static CEvent::Type s_connectedEvent;
|
|
||||||
static CEvent::Type s_disconnectedEvent;
|
|
||||||
static CEvent::Type s_switchToScreen;
|
|
||||||
static CEvent::Type s_switchInDirection;
|
|
||||||
static CEvent::Type s_keyboardBroadcast;
|
|
||||||
static CEvent::Type s_lockCursorToScreen;
|
|
||||||
static CEvent::Type s_screenSwitched;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,13 +47,15 @@
|
||||||
|
|
||||||
CApp* CApp::s_instance = nullptr;
|
CApp* CApp::s_instance = nullptr;
|
||||||
|
|
||||||
CApp::CApp(CreateTaskBarReceiverFunc createTaskBarReceiver, CArgsBase* args) :
|
CApp::CApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, CArgsBase* args) :
|
||||||
m_createTaskBarReceiver(createTaskBarReceiver),
|
m_events(events),
|
||||||
m_args(args),
|
m_createTaskBarReceiver(createTaskBarReceiver),
|
||||||
m_bye(&exit),
|
m_args(args),
|
||||||
m_taskBarReceiver(NULL),
|
m_bye(&exit),
|
||||||
m_suspended(false),
|
m_taskBarReceiver(NULL),
|
||||||
m_ipcClient(nullptr)
|
m_suspended(false),
|
||||||
|
m_ipcClient(nullptr),
|
||||||
|
m_appUtil(events)
|
||||||
{
|
{
|
||||||
assert(s_instance == nullptr);
|
assert(s_instance == nullptr);
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
@ -348,18 +350,18 @@ CApp::initApp(int argc, const char** argv)
|
||||||
|
|
||||||
// make the task bar receiver. the user can control this app
|
// make the task bar receiver. the user can control this app
|
||||||
// through the task bar.
|
// through the task bar.
|
||||||
m_taskBarReceiver = m_createTaskBarReceiver(logBuffer);
|
m_taskBarReceiver = m_createTaskBarReceiver(logBuffer, m_events);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CApp::initIpcClient()
|
CApp::initIpcClient()
|
||||||
{
|
{
|
||||||
m_ipcClient = new CIpcClient();
|
m_ipcClient = new CIpcClient(m_events);
|
||||||
m_ipcClient->connect();
|
m_ipcClient->connect();
|
||||||
|
|
||||||
EVENTQUEUE->adoptHandler(
|
m_events->adoptHandler(
|
||||||
CIpcClient::getMessageReceivedEvent(), m_ipcClient,
|
m_events->forCIpcClient().messageReceived(), m_ipcClient,
|
||||||
new TMethodEventJob<CApp>(this, &CApp::handleIpcMessage));
|
new TMethodEventJob<CApp>(this, &CApp::handleIpcMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +369,7 @@ void
|
||||||
CApp::cleanupIpcClient()
|
CApp::cleanupIpcClient()
|
||||||
{
|
{
|
||||||
m_ipcClient->disconnect();
|
m_ipcClient->disconnect();
|
||||||
EVENTQUEUE->removeHandler(CIpcClient::getMessageReceivedEvent(), m_ipcClient);
|
m_events->removeHandler(m_events->forCIpcClient().messageReceived(), m_ipcClient);
|
||||||
delete m_ipcClient;
|
delete m_ipcClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,6 +379,6 @@ CApp::handleIpcMessage(const CEvent& e, void*)
|
||||||
CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
|
CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
|
||||||
if (m->type() == kIpcShutdown) {
|
if (m->type() == kIpcShutdown) {
|
||||||
LOG((CLOG_INFO "got ipc shutdown message"));
|
LOG((CLOG_INFO "got ipc shutdown message"));
|
||||||
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
|
m_events->addEvent(CEvent(CEvent::kQuit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,13 @@ class CBufferedLogOutputter;
|
||||||
class ILogOutputter;
|
class ILogOutputter;
|
||||||
class CFileLogOutputter;
|
class CFileLogOutputter;
|
||||||
class CScreen;
|
class CScreen;
|
||||||
|
class IEventQueue;
|
||||||
|
|
||||||
typedef IArchTaskBarReceiver* (*CreateTaskBarReceiverFunc)(const CBufferedLogOutputter*);
|
typedef IArchTaskBarReceiver* (*CreateTaskBarReceiverFunc)(const CBufferedLogOutputter*, IEventQueue* events);
|
||||||
|
|
||||||
class CApp : public IApp {
|
class CApp : public IApp {
|
||||||
public:
|
public:
|
||||||
CApp(CreateTaskBarReceiverFunc createTaskBarReceiver, CArgsBase* args);
|
CApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, CArgsBase* args);
|
||||||
virtual ~CApp();
|
virtual ~CApp();
|
||||||
|
|
||||||
// Returns args that are common between server and client.
|
// Returns args that are common between server and client.
|
||||||
|
@ -93,6 +94,8 @@ public:
|
||||||
|
|
||||||
virtual void setByeFunc(void(*bye)(int)) { m_bye = bye; }
|
virtual void setByeFunc(void(*bye)(int)) { m_bye = bye; }
|
||||||
virtual void bye(int error) { m_bye(error); }
|
virtual void bye(int error) { m_bye(error); }
|
||||||
|
|
||||||
|
virtual IEventQueue* events() const { return m_events; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleIpcMessage(const CEvent&, void*);
|
void handleIpcMessage(const CEvent&, void*);
|
||||||
|
@ -113,6 +116,7 @@ private:
|
||||||
CreateTaskBarReceiverFunc m_createTaskBarReceiver;
|
CreateTaskBarReceiverFunc m_createTaskBarReceiver;
|
||||||
ARCH_APP_UTIL m_appUtil;
|
ARCH_APP_UTIL m_appUtil;
|
||||||
CIpcClient* m_ipcClient;
|
CIpcClient* m_ipcClient;
|
||||||
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BYE "\nTry `%s --help' for more information."
|
#define BYE "\nTry `%s --help' for more information."
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue