dropped "c" prefix from class names
This commit is contained in:
parent
f6c05e7635
commit
e8e156f0e2
|
@ -43,8 +43,8 @@ const UINT CMSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] =
|
|||
};
|
||||
|
||||
CMSWindowsClientTaskBarReceiver::CMSWindowsClientTaskBarReceiver(
|
||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
CClientTaskBarReceiver(events),
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
m_logBuffer(logBuffer)
|
||||
|
@ -229,8 +229,8 @@ CMSWindowsClientTaskBarReceiver::copyLog() const
|
|||
{
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
CString data;
|
||||
for (CBufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
|
@ -297,14 +297,14 @@ CMSWindowsClientTaskBarReceiver::createWindow()
|
|||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
|
||||
// tell the task bar about this dialog
|
||||
CArchTaskBarWindows::addDialog(m_window);
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsClientTaskBarReceiver::destroyWindow()
|
||||
{
|
||||
if (m_window != NULL) {
|
||||
CArchTaskBarWindows::removeDialog(m_window);
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
|
@ -359,14 +359,14 @@ CMSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd,
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
CArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CClientTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsClientTaskBarReceiver : public CClientTaskBarReceiver {
|
||||
//! Implementation of ClientTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
CMSWindowsClientTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||
CMSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CMSWindowsClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
protected:
|
||||
void copyLog() const;
|
||||
|
||||
// CClientTaskBarReceiver overrides
|
||||
// ClientTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
|
||||
private:
|
||||
|
@ -62,7 +62,7 @@ private:
|
|||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const CBufferedLogOutputter* m_logBuffer;
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
|
||||
static const UINT s_stateToIconID[];
|
||||
};
|
||||
|
|
|
@ -20,50 +20,50 @@
|
|||
#include "arch/Arch.h"
|
||||
|
||||
//
|
||||
// COSXClientTaskBarReceiver
|
||||
// OSXClientTaskBarReceiver
|
||||
//
|
||||
|
||||
COSXClientTaskBarReceiver::COSXClientTaskBarReceiver(
|
||||
const CBufferedLogOutputter*,
|
||||
OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(
|
||||
const BufferedLogOutputter*,
|
||||
IEventQueue* events) :
|
||||
CClientTaskBarReceiver(events)
|
||||
ClientTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
COSXClientTaskBarReceiver::~COSXClientTaskBarReceiver()
|
||||
OSXClientTaskBarReceiver::~OSXClientTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
COSXClientTaskBarReceiver::showStatus()
|
||||
OSXClientTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXClientTaskBarReceiver::runMenu(int, int)
|
||||
OSXClientTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXClientTaskBarReceiver::primaryAction()
|
||||
OSXClientTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
COSXClientTaskBarReceiver::getIcon() const
|
||||
OSXClientTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
return new COSXClientTaskBarReceiver(logBuffer, events);
|
||||
return new OSXClientTaskBarReceiver(logBuffer, events);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
#include "synergy/ClientTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CClientTaskBarReceiver for OS X
|
||||
class COSXClientTaskBarReceiver : public CClientTaskBarReceiver {
|
||||
//! Implementation of ClientTaskBarReceiver for OS X
|
||||
class OSXClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
COSXClientTaskBarReceiver(const CBufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~COSXClientTaskBarReceiver();
|
||||
OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
//
|
||||
|
||||
CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver(
|
||||
const CBufferedLogOutputter*,
|
||||
const BufferedLogOutputter*,
|
||||
IEventQueue* events) :
|
||||
CClientTaskBarReceiver(events)
|
||||
ClientTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
|
@ -62,7 +62,7 @@ CXWindowsClientTaskBarReceiver::getIcon() const
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
return new CXWindowsClientTaskBarReceiver(logBuffer, events);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
#include "synergy/ClientTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CClientTaskBarReceiver for X Windows
|
||||
class CXWindowsClientTaskBarReceiver : public CClientTaskBarReceiver {
|
||||
//! Implementation of ClientTaskBarReceiver for X Windows
|
||||
class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
CXWindowsClientTaskBarReceiver(
|
||||
const CBufferedLogOutputter*, IEventQueue* events);
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
|
|
@ -36,15 +36,15 @@ main(int argc, char** argv)
|
|||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
CArch arch;
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
CLog log;
|
||||
CEventQueue events;
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
CClientApp app(&events, createTaskBarReceiver);
|
||||
ClientApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
CDaemonApp app;
|
||||
DaemonApp app;
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ main(int argc, char** argv)
|
|||
int WINAPI
|
||||
WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
{
|
||||
CDaemonApp app;
|
||||
DaemonApp app;
|
||||
return app.run(__argc, __argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ const UINT CMSWindowsPortableTaskBarReceiver::s_stateToIconID[kMaxState] =
|
|||
};
|
||||
|
||||
CMSWindowsPortableTaskBarReceiver::CMSWindowsPortableTaskBarReceiver(
|
||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
CPortableTaskBarReceiver(events),
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
PortableTaskBarReceiver(events),
|
||||
m_events(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
|
@ -181,17 +181,17 @@ CMSWindowsPortableTaskBarReceiver::runMenu(int x, int y)
|
|||
break;
|
||||
|
||||
case IDC_RELOAD_CONFIG:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().reloadConfig(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().reloadConfig(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case IDC_FORCE_RECONNECT:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().forceReconnect(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().forceReconnect(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case ID_SYNERGY_RESETSERVER:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().resetServer(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().resetServer(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
|
@ -246,8 +246,8 @@ CMSWindowsPortableTaskBarReceiver::copyLog() const
|
|||
{
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
CString data;
|
||||
for (CBufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
|
@ -314,14 +314,14 @@ CMSWindowsPortableTaskBarReceiver::createWindow()
|
|||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
|
||||
// tell the task bar about this dialog
|
||||
CArchTaskBarWindows::addDialog(m_window);
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsPortableTaskBarReceiver::destroyWindow()
|
||||
{
|
||||
if (m_window != NULL) {
|
||||
CArchTaskBarWindows::removeDialog(m_window);
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
|
@ -377,14 +377,14 @@ CMSWindowsPortableTaskBarReceiver::staticDlgProc(HWND hwnd,
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
CArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CPortableTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsPortableTaskBarReceiver : public CPortableTaskBarReceiver {
|
||||
//! Implementation of PortableTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsPortableTaskBarReceiver : public PortableTaskBarReceiver {
|
||||
public:
|
||||
CMSWindowsPortableTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||
CMSWindowsPortableTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CMSWindowsPortableTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
protected:
|
||||
void copyLog() const;
|
||||
|
||||
// CPortableTaskBarReceiver overrides
|
||||
// PortableTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
|
||||
private:
|
||||
|
@ -62,7 +62,7 @@ private:
|
|||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const CBufferedLogOutputter* m_logBuffer;
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
IEventQueue* m_events;
|
||||
|
||||
static const UINT s_stateToIconID[];
|
||||
|
|
|
@ -20,47 +20,47 @@
|
|||
#include "arch/Arch.h"
|
||||
|
||||
//
|
||||
// COSXServerTaskBarReceiver
|
||||
// OSXServerTaskBarReceiver
|
||||
//
|
||||
|
||||
COSXServerTaskBarReceiver::COSXServerTaskBarReceiver(
|
||||
const CBufferedLogOutputter*)
|
||||
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
COSXServerTaskBarReceiver::~COSXServerTaskBarReceiver()
|
||||
OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::showStatus()
|
||||
OSXServerTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::runMenu(int, int)
|
||||
OSXServerTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::primaryAction()
|
||||
OSXServerTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
COSXServerTaskBarReceiver::getIcon() const
|
||||
OSXServerTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer)
|
||||
{
|
||||
return new COSXServerTaskBarReceiver(logBuffer);
|
||||
return new OSXServerTaskBarReceiver(logBuffer);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "synergyp/PortableTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
|
||||
//! Implementation of CPortableTaskBarReceiver for OS X
|
||||
class COSXServerTaskBarReceiver : public CPortableTaskBarReceiver {
|
||||
//! Implementation of PortableTaskBarReceiver for OS X
|
||||
class OSXServerTaskBarReceiver : public PortableTaskBarReceiver {
|
||||
public:
|
||||
COSXServerTaskBarReceiver(const CBufferedLogOutputter*);
|
||||
virtual ~COSXServerTaskBarReceiver();
|
||||
OSXServerTaskBarReceiver(const BufferedLogOutputter*);
|
||||
virtual ~OSXServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
//
|
||||
|
||||
CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver(
|
||||
const CBufferedLogOutputter*)
|
||||
const BufferedLogOutputter*)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
|
@ -60,7 +60,7 @@ CXWindowsServerTaskBarReceiver::getIcon() const
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer)
|
||||
{
|
||||
return new CXWindowsServerTaskBarReceiver(logBuffer);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
|
||||
#include "synergyp/PortableTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
|
||||
//! Implementation of CPortableTaskBarReceiver for X Windows
|
||||
class CXWindowsServerTaskBarReceiver : public CPortableTaskBarReceiver {
|
||||
//! Implementation of PortableTaskBarReceiver for X Windows
|
||||
class CXWindowsServerTaskBarReceiver : public PortableTaskBarReceiver {
|
||||
public:
|
||||
CXWindowsServerTaskBarReceiver(const CBufferedLogOutputter*);
|
||||
CXWindowsServerTaskBarReceiver(const BufferedLogOutputter*);
|
||||
virtual ~CXWindowsServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
|
|
@ -39,16 +39,16 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdSh
|
|||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
CArch arch;
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
CLog log;
|
||||
CEventQueue events;
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
CLOG->insert(new CMesssageBoxLogOutputter());
|
||||
CLOG->insert(new MesssageBoxLogOutputter());
|
||||
|
||||
int argc = __argc;
|
||||
char** argv = __argv;
|
||||
|
@ -79,11 +79,11 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdSh
|
|||
}
|
||||
|
||||
if (server) {
|
||||
CServerApp app(&events, createTaskBarReceiver);
|
||||
ServerApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
else if (client) {
|
||||
CClientApp app(&events, createTaskBarReceiver);
|
||||
ClientApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ const UINT CMSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] =
|
|||
};
|
||||
|
||||
CMSWindowsServerTaskBarReceiver::CMSWindowsServerTaskBarReceiver(
|
||||
HINSTANCE appInstance, const CBufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
CServerTaskBarReceiver(events),
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events),
|
||||
m_events(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
|
@ -93,7 +93,7 @@ CMSWindowsServerTaskBarReceiver::showStatus()
|
|||
std::string status = getToolTip();
|
||||
|
||||
// get the connect clients, if any
|
||||
const CClients& clients = getClients();
|
||||
const Clients& clients = getClients();
|
||||
|
||||
// done getting status
|
||||
unlock();
|
||||
|
@ -103,7 +103,7 @@ CMSWindowsServerTaskBarReceiver::showStatus()
|
|||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
|
||||
SendMessage(child, LB_RESETCONTENT, 0, 0);
|
||||
for (CClients::const_iterator index = clients.begin();
|
||||
for (Clients::const_iterator index = clients.begin();
|
||||
index != clients.end(); ) {
|
||||
const char* client = index->c_str();
|
||||
if (++index == clients.end()) {
|
||||
|
@ -195,17 +195,17 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
|||
break;
|
||||
|
||||
case IDC_RELOAD_CONFIG:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().reloadConfig(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().reloadConfig(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case IDC_FORCE_RECONNECT:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().forceReconnect(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().forceReconnect(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case ID_SYNERGY_RESETSERVER:
|
||||
m_events->addEvent(CEvent(m_events->forCServerApp().resetServer(),
|
||||
m_events->addEvent(Event(m_events->forCServerApp().resetServer(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
|
@ -260,8 +260,8 @@ CMSWindowsServerTaskBarReceiver::copyLog() const
|
|||
{
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
CString data;
|
||||
for (CBufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
|
@ -328,14 +328,14 @@ CMSWindowsServerTaskBarReceiver::createWindow()
|
|||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
|
||||
// tell the task bar about this dialog
|
||||
CArchTaskBarWindows::addDialog(m_window);
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsServerTaskBarReceiver::destroyWindow()
|
||||
{
|
||||
if (m_window != NULL) {
|
||||
CArchTaskBarWindows::removeDialog(m_window);
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
|
@ -391,14 +391,14 @@ CMSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd,
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
CArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(CArchMiscWindows::instanceWin32(),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CServerTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsServerTaskBarReceiver : public CServerTaskBarReceiver {
|
||||
//! Implementation of ServerTaskBarReceiver for Microsoft Windows
|
||||
class CMSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
CMSWindowsServerTaskBarReceiver(HINSTANCE, const CBufferedLogOutputter*, IEventQueue* events);
|
||||
CMSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CMSWindowsServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
protected:
|
||||
void copyLog() const;
|
||||
|
||||
// CServerTaskBarReceiver overrides
|
||||
// ServerTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
|
||||
private:
|
||||
|
@ -62,7 +62,7 @@ private:
|
|||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const CBufferedLogOutputter* m_logBuffer;
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
IEventQueue* m_events;
|
||||
|
||||
static const UINT s_stateToIconID[];
|
||||
|
|
|
@ -20,48 +20,48 @@
|
|||
#include "arch/Arch.h"
|
||||
|
||||
//
|
||||
// COSXServerTaskBarReceiver
|
||||
// OSXServerTaskBarReceiver
|
||||
//
|
||||
|
||||
COSXServerTaskBarReceiver::COSXServerTaskBarReceiver(
|
||||
const CBufferedLogOutputter*, IEventQueue* events) :
|
||||
CServerTaskBarReceiver(events)
|
||||
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
COSXServerTaskBarReceiver::~COSXServerTaskBarReceiver()
|
||||
OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::showStatus()
|
||||
OSXServerTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::runMenu(int, int)
|
||||
OSXServerTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
COSXServerTaskBarReceiver::primaryAction()
|
||||
OSXServerTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
COSXServerTaskBarReceiver::getIcon() const
|
||||
OSXServerTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
return new COSXServerTaskBarReceiver(logBuffer, events);
|
||||
return new OSXServerTaskBarReceiver(logBuffer, events);
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "synergy/ServerTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
|
||||
//! Implementation of CServerTaskBarReceiver for OS X
|
||||
class COSXServerTaskBarReceiver : public CServerTaskBarReceiver {
|
||||
//! Implementation of ServerTaskBarReceiver for OS X
|
||||
class OSXServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
COSXServerTaskBarReceiver(const CBufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~COSXServerTaskBarReceiver();
|
||||
OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
//
|
||||
|
||||
CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver(
|
||||
const CBufferedLogOutputter*, IEventQueue* events) :
|
||||
CServerTaskBarReceiver(events)
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
|
@ -61,7 +61,7 @@ CXWindowsServerTaskBarReceiver::getIcon() const
|
|||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
return new CXWindowsServerTaskBarReceiver(logBuffer, events);
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
#include "synergy/ServerTaskBarReceiver.h"
|
||||
|
||||
class CBufferedLogOutputter;
|
||||
class BufferedLogOutputter;
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of CServerTaskBarReceiver for X Windows
|
||||
class CXWindowsServerTaskBarReceiver : public CServerTaskBarReceiver {
|
||||
//! Implementation of ServerTaskBarReceiver for X Windows
|
||||
class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
CXWindowsServerTaskBarReceiver(
|
||||
const CBufferedLogOutputter*, IEventQueue* events);
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
|
|
|
@ -36,15 +36,15 @@ main(int argc, char** argv)
|
|||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
CArch arch;
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
CLog log;
|
||||
CEventQueue events;
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
CServerApp app(&events, createTaskBarReceiver);
|
||||
ServerApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ main(int argc, char** argv)
|
|||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
CArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
CArch arch;
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
CToolApp app;
|
||||
ToolApp app;
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -19,36 +19,36 @@
|
|||
#include "arch/Arch.h"
|
||||
|
||||
//
|
||||
// CArch
|
||||
// Arch
|
||||
//
|
||||
|
||||
CArch* CArch::s_instance = NULL;
|
||||
Arch* Arch::s_instance = NULL;
|
||||
|
||||
CArch::CArch()
|
||||
Arch::Arch()
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
CArch::~CArch()
|
||||
Arch::~Arch()
|
||||
{
|
||||
#if SYSAPI_WIN32
|
||||
CArchMiscWindows::cleanup();
|
||||
ArchMiscWindows::cleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CArch::init()
|
||||
Arch::init()
|
||||
{
|
||||
ARCH_NETWORK::init();
|
||||
#if SYSAPI_WIN32
|
||||
ARCH_TASKBAR::init();
|
||||
CArchMiscWindows::init();
|
||||
ArchMiscWindows::init();
|
||||
#endif
|
||||
}
|
||||
|
||||
CArch*
|
||||
CArch::getInstance()
|
||||
Arch*
|
||||
Arch::getInstance()
|
||||
{
|
||||
assert(s_instance != NULL);
|
||||
return s_instance;
|
||||
|
|
|
@ -72,9 +72,9 @@
|
|||
|
||||
/*!
|
||||
\def ARCH
|
||||
This macro evaluates to the singleton CArch object.
|
||||
This macro evaluates to the singleton Arch object.
|
||||
*/
|
||||
#define ARCH (CArch::getInstance())
|
||||
#define ARCH (Arch::getInstance())
|
||||
|
||||
//! Delegating implementation of architecture dependent interfaces
|
||||
/*!
|
||||
|
@ -86,7 +86,7 @@ to each method to those implementations. Clients should use the
|
|||
exactly one of these objects before attempting to call any method,
|
||||
typically at the beginning of \c main().
|
||||
*/
|
||||
class CArch : public ARCH_CONSOLE,
|
||||
class Arch : public ARCH_CONSOLE,
|
||||
public ARCH_DAEMON,
|
||||
public ARCH_FILE,
|
||||
public ARCH_LOG,
|
||||
|
@ -98,8 +98,8 @@ class CArch : public ARCH_CONSOLE,
|
|||
public ARCH_TASKBAR,
|
||||
public ARCH_TIME {
|
||||
public:
|
||||
CArch();
|
||||
virtual ~CArch();
|
||||
Arch();
|
||||
virtual ~Arch();
|
||||
|
||||
//! Call init on other arch classes.
|
||||
/*!
|
||||
|
@ -114,32 +114,32 @@ public:
|
|||
|
||||
//! Return the singleton instance
|
||||
/*!
|
||||
The client must have instantiated exactly once CArch object before
|
||||
The client must have instantiated exactly once Arch object before
|
||||
calling this function.
|
||||
*/
|
||||
static CArch* getInstance();
|
||||
static Arch* getInstance();
|
||||
|
||||
ARCH_PLUGIN& plugin() const { return (ARCH_PLUGIN&)m_plugin; }
|
||||
ARCH_INTERNET& internet() const { return (ARCH_INTERNET&)m_internet; }
|
||||
|
||||
private:
|
||||
static CArch* s_instance;
|
||||
static Arch* s_instance;
|
||||
ARCH_PLUGIN m_plugin;
|
||||
ARCH_INTERNET m_internet;
|
||||
};
|
||||
|
||||
//! Convenience object to lock/unlock an arch mutex
|
||||
class CArchMutexLock {
|
||||
class ArchMutexLock {
|
||||
public:
|
||||
CArchMutexLock(CArchMutex mutex) : m_mutex(mutex)
|
||||
ArchMutexLock(ArchMutex mutex) : m_mutex(mutex)
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
}
|
||||
~CArchMutexLock()
|
||||
~ArchMutexLock()
|
||||
{
|
||||
ARCH->unlockMutex(m_mutex);
|
||||
}
|
||||
|
||||
private:
|
||||
CArchMutex m_mutex;
|
||||
ArchMutex m_mutex;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <iostream>
|
||||
|
||||
void
|
||||
CArchConsoleStd::writeConsole(ELevel level, const char* str)
|
||||
ArchConsoleStd::writeConsole(ELevel level, const char* str)
|
||||
{
|
||||
if ((level >= kFATAL) && (level <= kWARNING))
|
||||
std::cerr << str << std::endl;
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include "arch/IArchConsole.h"
|
||||
|
||||
//! Cross platform implementation of IArchConsole
|
||||
class CArchConsoleStd : public IArchConsole {
|
||||
class ArchConsoleStd : public IArchConsole {
|
||||
public:
|
||||
CArchConsoleStd() { }
|
||||
virtual ~CArchConsoleStd() { }
|
||||
ArchConsoleStd() { }
|
||||
virtual ~ArchConsoleStd() { }
|
||||
|
||||
// IArchConsole overrides
|
||||
virtual void openConsole(const char* title) { }
|
||||
|
|
|
@ -19,21 +19,21 @@
|
|||
#include "arch/ArchDaemonNone.h"
|
||||
|
||||
//
|
||||
// CArchDaemonNone
|
||||
// ArchDaemonNone
|
||||
//
|
||||
|
||||
CArchDaemonNone::CArchDaemonNone()
|
||||
ArchDaemonNone::ArchDaemonNone()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchDaemonNone::~CArchDaemonNone()
|
||||
ArchDaemonNone::~ArchDaemonNone()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonNone::installDaemon(const char*,
|
||||
ArchDaemonNone::installDaemon(const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
|
@ -43,13 +43,13 @@ CArchDaemonNone::installDaemon(const char*,
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonNone::uninstallDaemon(const char*)
|
||||
ArchDaemonNone::uninstallDaemon(const char*)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
int
|
||||
CArchDaemonNone::daemonize(const char* name, DaemonFunc func)
|
||||
ArchDaemonNone::daemonize(const char* name, DaemonFunc func)
|
||||
{
|
||||
// simply forward the call to func. obviously, this doesn't
|
||||
// do any daemonizing.
|
||||
|
@ -57,29 +57,29 @@ CArchDaemonNone::daemonize(const char* name, DaemonFunc func)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchDaemonNone::canInstallDaemon(const char*)
|
||||
ArchDaemonNone::canInstallDaemon(const char*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CArchDaemonNone::isDaemonInstalled(const char*)
|
||||
ArchDaemonNone::isDaemonInstalled(const char*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonNone::installDaemon()
|
||||
ArchDaemonNone::installDaemon()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonNone::uninstallDaemon()
|
||||
ArchDaemonNone::uninstallDaemon()
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchDaemonNone::commandLine() const
|
||||
ArchDaemonNone::commandLine() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "arch/IArchDaemon.h"
|
||||
|
||||
#define ARCH_DAEMON CArchDaemonNone
|
||||
#define ARCH_DAEMON ArchDaemonNone
|
||||
|
||||
//! Dummy implementation of IArchDaemon
|
||||
/*!
|
||||
|
@ -29,10 +29,10 @@ daemons. The install and uninstall functions do nothing, the query
|
|||
functions return false, and \c daemonize() simply calls the passed
|
||||
function and returns its result.
|
||||
*/
|
||||
class CArchDaemonNone : public IArchDaemon {
|
||||
class ArchDaemonNone : public IArchDaemon {
|
||||
public:
|
||||
CArchDaemonNone();
|
||||
virtual ~CArchDaemonNone();
|
||||
ArchDaemonNone();
|
||||
virtual ~ArchDaemonNone();
|
||||
|
||||
// IArchDaemon overrides
|
||||
virtual void installDaemon(const char* name,
|
||||
|
|
|
@ -86,16 +86,16 @@ public:
|
|||
Becomes a service. Argument 0 is the name of the service
|
||||
and the rest are the arguments passed to StartService().
|
||||
\c func is only called when the service is actually started.
|
||||
\c func must call \c CArchMiscWindows::runDaemon() to finally
|
||||
\c func must call \c ArchMiscWindows::runDaemon() to finally
|
||||
becoming a service. The \c runFunc function passed to \c runDaemon()
|
||||
must call \c CArchMiscWindows::daemonRunning(true) when it
|
||||
must call \c ArchMiscWindows::daemonRunning(true) when it
|
||||
enters the main loop (i.e. after initialization) and
|
||||
\c CArchMiscWindows::daemonRunning(false) when it leaves
|
||||
\c ArchMiscWindows::daemonRunning(false) when it leaves
|
||||
the main loop. The \c stopFunc function passed to \c runDaemon()
|
||||
is called when the daemon must exit the main loop and it must cause
|
||||
\c runFunc to return. \c func should return what \c runDaemon()
|
||||
returns. \c func or \c runFunc can call
|
||||
\c CArchMiscWindows::daemonFailed() to indicate startup failure.
|
||||
\c ArchMiscWindows::daemonFailed() to indicate startup failure.
|
||||
</ul>
|
||||
*/
|
||||
virtual int daemonize(const char* name, DaemonFunc func) = 0;
|
||||
|
|
|
@ -21,47 +21,47 @@
|
|||
#include "common/IInterface.h"
|
||||
|
||||
/*!
|
||||
\class CArchCondImpl
|
||||
\class ArchCondImpl
|
||||
\brief Internal condition variable data.
|
||||
An architecture dependent type holding the necessary data for a
|
||||
condition variable.
|
||||
*/
|
||||
class CArchCondImpl;
|
||||
class ArchCondImpl;
|
||||
|
||||
/*!
|
||||
\var CArchCond
|
||||
\var ArchCond
|
||||
\brief Opaque condition variable type.
|
||||
An opaque type representing a condition variable.
|
||||
*/
|
||||
typedef CArchCondImpl* CArchCond;
|
||||
typedef ArchCondImpl* ArchCond;
|
||||
|
||||
/*!
|
||||
\class CArchMutexImpl
|
||||
\class ArchMutexImpl
|
||||
\brief Internal mutex data.
|
||||
An architecture dependent type holding the necessary data for a mutex.
|
||||
*/
|
||||
class CArchMutexImpl;
|
||||
class ArchMutexImpl;
|
||||
|
||||
/*!
|
||||
\var CArchMutex
|
||||
\var ArchMutex
|
||||
\brief Opaque mutex type.
|
||||
An opaque type representing a mutex.
|
||||
*/
|
||||
typedef CArchMutexImpl* CArchMutex;
|
||||
typedef ArchMutexImpl* ArchMutex;
|
||||
|
||||
/*!
|
||||
\class CArchThreadImpl
|
||||
\class ArchThreadImpl
|
||||
\brief Internal thread data.
|
||||
An architecture dependent type holding the necessary data for a thread.
|
||||
*/
|
||||
class CArchThreadImpl;
|
||||
class ArchThreadImpl;
|
||||
|
||||
/*!
|
||||
\var CArchThread
|
||||
\var ArchThread
|
||||
\brief Opaque thread type.
|
||||
An opaque type representing a thread.
|
||||
*/
|
||||
typedef CArchThreadImpl* CArchThread;
|
||||
typedef ArchThreadImpl* ArchThread;
|
||||
|
||||
//! Interface for architecture dependent multithreading
|
||||
/*!
|
||||
|
@ -100,22 +100,22 @@ public:
|
|||
/*!
|
||||
The condition variable is an opaque data type.
|
||||
*/
|
||||
virtual CArchCond newCondVar() = 0;
|
||||
virtual ArchCond newCondVar() = 0;
|
||||
|
||||
//! Destroy a condition variable
|
||||
virtual void closeCondVar(CArchCond) = 0;
|
||||
virtual void closeCondVar(ArchCond) = 0;
|
||||
|
||||
//! Signal a condition variable
|
||||
/*!
|
||||
Signalling a condition variable releases one waiting thread.
|
||||
*/
|
||||
virtual void signalCondVar(CArchCond) = 0;
|
||||
virtual void signalCondVar(ArchCond) = 0;
|
||||
|
||||
//! Broadcast a condition variable
|
||||
/*!
|
||||
Broadcasting a condition variable releases all waiting threads.
|
||||
*/
|
||||
virtual void broadcastCondVar(CArchCond) = 0;
|
||||
virtual void broadcastCondVar(ArchCond) = 0;
|
||||
|
||||
//! Wait on a condition variable
|
||||
/*!
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
|
||||
(Cancellation point)
|
||||
*/
|
||||
virtual bool waitCondVar(CArchCond, CArchMutex, double timeout) = 0;
|
||||
virtual bool waitCondVar(ArchCond, ArchMutex, double timeout) = 0;
|
||||
|
||||
//
|
||||
// mutex methods
|
||||
|
@ -140,16 +140,16 @@ public:
|
|||
when it already holds a lock on that mutex. The mutex is an
|
||||
opaque data type.
|
||||
*/
|
||||
virtual CArchMutex newMutex() = 0;
|
||||
virtual ArchMutex newMutex() = 0;
|
||||
|
||||
//! Destroy a mutex
|
||||
virtual void closeMutex(CArchMutex) = 0;
|
||||
virtual void closeMutex(ArchMutex) = 0;
|
||||
|
||||
//! Lock a mutex
|
||||
virtual void lockMutex(CArchMutex) = 0;
|
||||
virtual void lockMutex(ArchMutex) = 0;
|
||||
|
||||
//! Unlock a mutex
|
||||
virtual void unlockMutex(CArchMutex) = 0;
|
||||
virtual void unlockMutex(ArchMutex) = 0;
|
||||
|
||||
//
|
||||
// thread methods
|
||||
|
@ -160,19 +160,19 @@ public:
|
|||
Creates and starts a new thread, using \c func as the entry point
|
||||
and passing it \c userData. The thread is an opaque data type.
|
||||
*/
|
||||
virtual CArchThread newThread(ThreadFunc func, void* userData) = 0;
|
||||
virtual ArchThread newThread(ThreadFunc func, void* userData) = 0;
|
||||
|
||||
//! Get a reference to the calling thread
|
||||
/*!
|
||||
Returns a thread representing the current (i.e. calling) thread.
|
||||
*/
|
||||
virtual CArchThread newCurrentThread() = 0;
|
||||
virtual ArchThread newCurrentThread() = 0;
|
||||
|
||||
//! Copy a thread object
|
||||
/*!
|
||||
Returns a reference to to thread referred to by \c thread.
|
||||
*/
|
||||
virtual CArchThread copyThread(CArchThread thread) = 0;
|
||||
virtual ArchThread copyThread(ArchThread thread) = 0;
|
||||
|
||||
//! Release a thread reference
|
||||
/*!
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
Use cancelThread() and waitThread() to stop a thread and wait for
|
||||
it to exit.
|
||||
*/
|
||||
virtual void closeThread(CArchThread) = 0;
|
||||
virtual void closeThread(ArchThread) = 0;
|
||||
|
||||
//! Force a thread to exit
|
||||
/*!
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
must always let cancellation go to completion but may take as
|
||||
long as necessary to clean up.
|
||||
*/
|
||||
virtual void cancelThread(CArchThread thread) = 0;
|
||||
virtual void cancelThread(ArchThread thread) = 0;
|
||||
|
||||
//! Change thread priority
|
||||
/*!
|
||||
|
@ -199,7 +199,7 @@ public:
|
|||
the thread has a lower priority and if negative a higher priority.
|
||||
Some architectures may not support either or both directions.
|
||||
*/
|
||||
virtual void setPriorityOfThread(CArchThread, int n) = 0;
|
||||
virtual void setPriorityOfThread(ArchThread, int n) = 0;
|
||||
|
||||
//! Cancellation point
|
||||
/*!
|
||||
|
@ -220,20 +220,20 @@ public:
|
|||
|
||||
(Cancellation point)
|
||||
*/
|
||||
virtual bool wait(CArchThread thread, double timeout) = 0;
|
||||
virtual bool wait(ArchThread thread, double timeout) = 0;
|
||||
|
||||
//! Compare threads
|
||||
/*!
|
||||
Returns true iff two thread objects refer to the same thread.
|
||||
Note that comparing thread objects directly is meaningless.
|
||||
*/
|
||||
virtual bool isSameThread(CArchThread, CArchThread) = 0;
|
||||
virtual bool isSameThread(ArchThread, ArchThread) = 0;
|
||||
|
||||
//! Test if thread exited
|
||||
/*!
|
||||
Returns true iff \c thread has exited.
|
||||
*/
|
||||
virtual bool isExitedThread(CArchThread thread) = 0;
|
||||
virtual bool isExitedThread(ArchThread thread) = 0;
|
||||
|
||||
//! Returns the exit code of a thread
|
||||
/*!
|
||||
|
@ -242,7 +242,7 @@ public:
|
|||
|
||||
(Cancellation point)
|
||||
*/
|
||||
virtual void* getResultOfThread(CArchThread thread) = 0;
|
||||
virtual void* getResultOfThread(ArchThread thread) = 0;
|
||||
|
||||
//! Returns an ID for a thread
|
||||
/*!
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
However, clients should us isSameThread() to compare thread objects
|
||||
instead of comparing IDs.
|
||||
*/
|
||||
virtual ThreadID getIDOfThread(CArchThread thread) = 0;
|
||||
virtual ThreadID getIDOfThread(ArchThread thread) = 0;
|
||||
|
||||
//! Set the interrupt handler
|
||||
/*!
|
||||
|
|
|
@ -21,37 +21,37 @@
|
|||
#include "common/IInterface.h"
|
||||
#include "common/stdstring.h"
|
||||
|
||||
class CArchThreadImpl;
|
||||
typedef CArchThreadImpl* CArchThread;
|
||||
class ArchThreadImpl;
|
||||
typedef ArchThreadImpl* ArchThread;
|
||||
|
||||
/*!
|
||||
\class CArchSocketImpl
|
||||
\class ArchSocketImpl
|
||||
\brief Internal socket data.
|
||||
An architecture dependent type holding the necessary data for a socket.
|
||||
*/
|
||||
class CArchSocketImpl;
|
||||
class ArchSocketImpl;
|
||||
|
||||
/*!
|
||||
\var CArchSocket
|
||||
\var ArchSocket
|
||||
\brief Opaque socket type.
|
||||
An opaque type representing a socket.
|
||||
*/
|
||||
typedef CArchSocketImpl* CArchSocket;
|
||||
typedef ArchSocketImpl* ArchSocket;
|
||||
|
||||
/*!
|
||||
\class CArchNetAddressImpl
|
||||
\class ArchNetAddressImpl
|
||||
\brief Internal network address data.
|
||||
An architecture dependent type holding the necessary data for a network
|
||||
address.
|
||||
*/
|
||||
class CArchNetAddressImpl;
|
||||
class ArchNetAddressImpl;
|
||||
|
||||
/*!
|
||||
\var CArchNetAddress
|
||||
\var ArchNetAddress
|
||||
\brief Opaque network address type.
|
||||
An opaque type representing a network address.
|
||||
*/
|
||||
typedef CArchNetAddressImpl* CArchNetAddress;
|
||||
typedef ArchNetAddressImpl* ArchNetAddress;
|
||||
|
||||
//! Interface for architecture dependent networking
|
||||
/*!
|
||||
|
@ -85,10 +85,10 @@ public:
|
|||
};
|
||||
|
||||
//! A socket query for \c poll()
|
||||
class CPollEntry {
|
||||
class PollEntry {
|
||||
public:
|
||||
//! The socket to query
|
||||
CArchSocket m_socket;
|
||||
ArchSocket m_socket;
|
||||
|
||||
//! The events to query for
|
||||
/*!
|
||||
|
@ -108,13 +108,13 @@ public:
|
|||
/*!
|
||||
The socket is an opaque data type.
|
||||
*/
|
||||
virtual CArchSocket newSocket(EAddressFamily, ESocketType) = 0;
|
||||
virtual ArchSocket newSocket(EAddressFamily, ESocketType) = 0;
|
||||
|
||||
//! Copy a socket object
|
||||
/*!
|
||||
Returns a reference to to socket referred to by \c s.
|
||||
*/
|
||||
virtual CArchSocket copySocket(CArchSocket s) = 0;
|
||||
virtual ArchSocket copySocket(ArchSocket s) = 0;
|
||||
|
||||
//! Release a socket reference
|
||||
/*!
|
||||
|
@ -122,31 +122,31 @@ public:
|
|||
the object referred to until there are no remaining references for
|
||||
the socket.
|
||||
*/
|
||||
virtual void closeSocket(CArchSocket s) = 0;
|
||||
virtual void closeSocket(ArchSocket s) = 0;
|
||||
|
||||
//! Close socket for further reads
|
||||
/*!
|
||||
Calling this disallows future reads on socket \c s.
|
||||
*/
|
||||
virtual void closeSocketForRead(CArchSocket s) = 0;
|
||||
virtual void closeSocketForRead(ArchSocket s) = 0;
|
||||
|
||||
//! Close socket for further writes
|
||||
/*!
|
||||
Calling this disallows future writes on socket \c s.
|
||||
*/
|
||||
virtual void closeSocketForWrite(CArchSocket s) = 0;
|
||||
virtual void closeSocketForWrite(ArchSocket s) = 0;
|
||||
|
||||
//! Bind socket to address
|
||||
/*!
|
||||
Binds socket \c s to the address \c addr.
|
||||
*/
|
||||
virtual void bindSocket(CArchSocket s, CArchNetAddress addr) = 0;
|
||||
virtual void bindSocket(ArchSocket s, ArchNetAddress addr) = 0;
|
||||
|
||||
//! Listen for connections on socket
|
||||
/*!
|
||||
Causes the socket \c s to begin listening for incoming connections.
|
||||
*/
|
||||
virtual void listenOnSocket(CArchSocket s) = 0;
|
||||
virtual void listenOnSocket(ArchSocket s) = 0;
|
||||
|
||||
//! Accept connection on socket
|
||||
/*!
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
it's not in the listening state and it's connected. Returns NULL
|
||||
if there are no pending connection requests.
|
||||
*/
|
||||
virtual CArchSocket acceptSocket(CArchSocket s, CArchNetAddress* addr) = 0;
|
||||
virtual ArchSocket acceptSocket(ArchSocket s, ArchNetAddress* addr) = 0;
|
||||
|
||||
//! Connect socket
|
||||
/*!
|
||||
|
@ -169,7 +169,7 @@ public:
|
|||
socket for writing to detect when the connection finally succeeds
|
||||
or fails.
|
||||
*/
|
||||
virtual bool connectSocket(CArchSocket s, CArchNetAddress addr) = 0;
|
||||
virtual bool connectSocket(ArchSocket s, ArchNetAddress addr) = 0;
|
||||
|
||||
//! Check socket state
|
||||
/*!
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
|
||||
(Cancellation point)
|
||||
*/
|
||||
virtual int pollSocket(CPollEntry[], int num, double timeout) = 0;
|
||||
virtual int pollSocket(PollEntry[], int num, double timeout) = 0;
|
||||
|
||||
//! Unblock thread in pollSocket()
|
||||
/*!
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
call may return before the thread is unblocked. If the thread is
|
||||
not in a pollSocket() call this call has no effect.
|
||||
*/
|
||||
virtual void unblockPollSocket(CArchThread thread) = 0;
|
||||
virtual void unblockPollSocket(ArchThread thread) = 0;
|
||||
|
||||
//! Read data from socket
|
||||
/*!
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
if not enough data is available. Returns 0 if the remote end has
|
||||
disconnected and/or there is no more queued received data.
|
||||
*/
|
||||
virtual size_t readSocket(CArchSocket s, void* buf, size_t len) = 0;
|
||||
virtual size_t readSocket(ArchSocket s, void* buf, size_t len) = 0;
|
||||
|
||||
//! Write data from socket
|
||||
/*!
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
\c len if the remote end disconnected or the internal buffers fill
|
||||
up.
|
||||
*/
|
||||
virtual size_t writeSocket(CArchSocket s,
|
||||
virtual size_t writeSocket(ArchSocket s,
|
||||
const void* buf, size_t len) = 0;
|
||||
|
||||
//! Check error on socket
|
||||
|
@ -220,61 +220,61 @@ public:
|
|||
If the socket \c s is in an error state then throws an appropriate
|
||||
XArchNetwork exception.
|
||||
*/
|
||||
virtual void throwErrorOnSocket(CArchSocket s) = 0;
|
||||
virtual void throwErrorOnSocket(ArchSocket s) = 0;
|
||||
|
||||
//! Turn Nagle algorithm on or off on socket
|
||||
/*!
|
||||
Set socket to send messages immediately (true) or to collect small
|
||||
messages into one packet (false). Returns the previous state.
|
||||
*/
|
||||
virtual bool setNoDelayOnSocket(CArchSocket, bool noDelay) = 0;
|
||||
virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay) = 0;
|
||||
|
||||
//! Turn address reuse on or off on socket
|
||||
/*!
|
||||
Allows the address this socket is bound to to be reused while in the
|
||||
TIME_WAIT state. Returns the previous state.
|
||||
*/
|
||||
virtual bool setReuseAddrOnSocket(CArchSocket, bool reuse) = 0;
|
||||
virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse) = 0;
|
||||
|
||||
//! Return local host's name
|
||||
virtual std::string getHostName() = 0;
|
||||
|
||||
//! Create an "any" network address
|
||||
virtual CArchNetAddress newAnyAddr(EAddressFamily) = 0;
|
||||
virtual ArchNetAddress newAnyAddr(EAddressFamily) = 0;
|
||||
|
||||
//! Copy a network address
|
||||
virtual CArchNetAddress copyAddr(CArchNetAddress) = 0;
|
||||
virtual ArchNetAddress copyAddr(ArchNetAddress) = 0;
|
||||
|
||||
//! Convert a name to a network address
|
||||
virtual CArchNetAddress nameToAddr(const std::string&) = 0;
|
||||
virtual ArchNetAddress nameToAddr(const std::string&) = 0;
|
||||
|
||||
//! Destroy a network address
|
||||
virtual void closeAddr(CArchNetAddress) = 0;
|
||||
virtual void closeAddr(ArchNetAddress) = 0;
|
||||
|
||||
//! Convert an address to a host name
|
||||
virtual std::string addrToName(CArchNetAddress) = 0;
|
||||
virtual std::string addrToName(ArchNetAddress) = 0;
|
||||
|
||||
//! Convert an address to a string
|
||||
virtual std::string addrToString(CArchNetAddress) = 0;
|
||||
virtual std::string addrToString(ArchNetAddress) = 0;
|
||||
|
||||
//! Get an address's family
|
||||
virtual EAddressFamily getAddrFamily(CArchNetAddress) = 0;
|
||||
virtual EAddressFamily getAddrFamily(ArchNetAddress) = 0;
|
||||
|
||||
//! Set the port of an address
|
||||
virtual void setAddrPort(CArchNetAddress, int port) = 0;
|
||||
virtual void setAddrPort(ArchNetAddress, int port) = 0;
|
||||
|
||||
//! Get the port of an address
|
||||
virtual int getAddrPort(CArchNetAddress) = 0;
|
||||
virtual int getAddrPort(ArchNetAddress) = 0;
|
||||
|
||||
//! Test addresses for equality
|
||||
virtual bool isEqualAddr(CArchNetAddress, CArchNetAddress) = 0;
|
||||
virtual bool isEqualAddr(ArchNetAddress, ArchNetAddress) = 0;
|
||||
|
||||
//! Test for the "any" address
|
||||
/*!
|
||||
Returns true if \c addr is the "any" address. \c newAnyAddr()
|
||||
returns an "any" address.
|
||||
*/
|
||||
virtual bool isAnyAddr(CArchNetAddress addr) = 0;
|
||||
virtual bool isAnyAddr(ArchNetAddress addr) = 0;
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
static CArchMutex s_mutex = NULL;
|
||||
static ArchMutex s_mutex = NULL;
|
||||
|
||||
//
|
||||
// use C library non-reentrant multibyte conversion with mutex
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
*/
|
||||
virtual std::string getToolTip() const = 0;
|
||||
|
||||
virtual void updateStatus(INode*, const CString& errorMsg) = 0;
|
||||
virtual void updateStatus(INode*, const String& errorMsg) = 0;
|
||||
|
||||
virtual void cleanup() {}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
|
||||
#include "arch/unix/ArchConsoleUnix.h"
|
||||
|
||||
CArchConsoleUnix::CArchConsoleUnix() { }
|
||||
ArchConsoleUnix::ArchConsoleUnix() { }
|
||||
|
||||
CArchConsoleUnix::~CArchConsoleUnix() { }
|
||||
ArchConsoleUnix::~ArchConsoleUnix() { }
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "arch/ArchConsoleStd.h"
|
||||
|
||||
#define ARCH_CONSOLE CArchConsoleUnix
|
||||
#define ARCH_CONSOLE ArchConsoleUnix
|
||||
|
||||
class CArchConsoleUnix : public CArchConsoleStd {
|
||||
class ArchConsoleUnix : public ArchConsoleStd {
|
||||
public:
|
||||
CArchConsoleUnix();
|
||||
virtual ~CArchConsoleUnix();
|
||||
ArchConsoleUnix();
|
||||
virtual ~ArchConsoleUnix();
|
||||
};
|
||||
|
|
|
@ -29,15 +29,15 @@
|
|||
#include <cstdlib>
|
||||
|
||||
//
|
||||
// CArchDaemonUnix
|
||||
// ArchDaemonUnix
|
||||
//
|
||||
|
||||
CArchDaemonUnix::CArchDaemonUnix()
|
||||
ArchDaemonUnix::ArchDaemonUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchDaemonUnix::~CArchDaemonUnix()
|
||||
ArchDaemonUnix::~ArchDaemonUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ bool alreadyDaemonized() {
|
|||
#endif
|
||||
|
||||
int
|
||||
CArchDaemonUnix::daemonize(const char* name, DaemonFunc func)
|
||||
ArchDaemonUnix::daemonize(const char* name, DaemonFunc func)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
if (alreadyDaemonized())
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
#include "arch/ArchDaemonNone.h"
|
||||
|
||||
#undef ARCH_DAEMON
|
||||
#define ARCH_DAEMON CArchDaemonUnix
|
||||
#define ARCH_DAEMON ArchDaemonUnix
|
||||
|
||||
//! Unix implementation of IArchDaemon
|
||||
class CArchDaemonUnix : public CArchDaemonNone {
|
||||
class ArchDaemonUnix : public ArchDaemonNone {
|
||||
public:
|
||||
CArchDaemonUnix();
|
||||
virtual ~CArchDaemonUnix();
|
||||
ArchDaemonUnix();
|
||||
virtual ~ArchDaemonUnix();
|
||||
|
||||
// IArchDaemon overrides
|
||||
virtual int daemonize(const char* name, DaemonFunc func);
|
||||
|
|
|
@ -25,21 +25,21 @@
|
|||
#include <cstring>
|
||||
|
||||
//
|
||||
// CArchFileUnix
|
||||
// ArchFileUnix
|
||||
//
|
||||
|
||||
CArchFileUnix::CArchFileUnix()
|
||||
ArchFileUnix::ArchFileUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchFileUnix::~CArchFileUnix()
|
||||
ArchFileUnix::~ArchFileUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const char*
|
||||
CArchFileUnix::getBasename(const char* pathname)
|
||||
ArchFileUnix::getBasename(const char* pathname)
|
||||
{
|
||||
if (pathname == NULL) {
|
||||
return NULL;
|
||||
|
@ -55,7 +55,7 @@ CArchFileUnix::getBasename(const char* pathname)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileUnix::getUserDirectory()
|
||||
ArchFileUnix::getUserDirectory()
|
||||
{
|
||||
char* buffer = NULL;
|
||||
std::string dir;
|
||||
|
@ -83,13 +83,12 @@ CArchFileUnix::getUserDirectory()
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileUnix::getSystemDirectory()
|
||||
ArchFileUnix::getSystemDirectory()
|
||||
{
|
||||
return "/etc";
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchFileUnix::getInstalledDirectory()
|
||||
ArchFileUnix::getInstalledDirectory()
|
||||
{
|
||||
#if WINAPI_XWINDOWS
|
||||
return "/bin";
|
||||
|
@ -99,13 +98,13 @@ CArchFileUnix::getInstalledDirectory()
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileUnix::getLogDirectory()
|
||||
ArchFileUnix::getLogDirectory()
|
||||
{
|
||||
return "/var/log";
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchFileUnix::concatPath(const std::string& prefix,
|
||||
ArchFileUnix::concatPath(const std::string& prefix,
|
||||
const std::string& suffix)
|
||||
{
|
||||
std::string path;
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchFile.h"
|
||||
|
||||
#define ARCH_FILE CArchFileUnix
|
||||
#define ARCH_FILE ArchFileUnix
|
||||
|
||||
//! Unix implementation of IArchFile
|
||||
class CArchFileUnix : public IArchFile {
|
||||
class ArchFileUnix : public IArchFile {
|
||||
public:
|
||||
CArchFileUnix();
|
||||
virtual ~CArchFileUnix();
|
||||
ArchFileUnix();
|
||||
virtual ~ArchFileUnix();
|
||||
|
||||
// IArchFile overrides
|
||||
virtual const char* getBasename(const char* pathname);
|
||||
|
|
|
@ -28,26 +28,26 @@ class CurlFacade {
|
|||
public:
|
||||
CurlFacade();
|
||||
~CurlFacade();
|
||||
CString get(const CString& url);
|
||||
CString urlEncode(const CString& url);
|
||||
String get(const String& url);
|
||||
String urlEncode(const String& url);
|
||||
|
||||
private:
|
||||
CURL* m_curl;
|
||||
};
|
||||
|
||||
//
|
||||
// CArchInternetUnix
|
||||
// ArchInternetUnix
|
||||
//
|
||||
|
||||
CString
|
||||
CArchInternetUnix::get(const CString& url)
|
||||
String
|
||||
ArchInternetUnix::get(const String& url)
|
||||
{
|
||||
CurlFacade curl;
|
||||
return curl.get(url);
|
||||
}
|
||||
|
||||
CString
|
||||
CArchInternetUnix::urlEncode(const CString& url)
|
||||
String
|
||||
ArchInternetUnix::urlEncode(const String& url)
|
||||
{
|
||||
CurlFacade curl;
|
||||
return curl.urlEncode(url);
|
||||
|
@ -87,8 +87,8 @@ CurlFacade::~CurlFacade()
|
|||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
CString
|
||||
CurlFacade::get(const CString& url)
|
||||
String
|
||||
CurlFacade::get(const String& url)
|
||||
{
|
||||
curl_easy_setopt(m_curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curlWriteCallback);
|
||||
|
@ -110,8 +110,8 @@ CurlFacade::get(const CString& url)
|
|||
return result;
|
||||
}
|
||||
|
||||
CString
|
||||
CurlFacade::urlEncode(const CString& url)
|
||||
String
|
||||
CurlFacade::urlEncode(const String& url)
|
||||
{
|
||||
char* resultCStr = curl_easy_escape(m_curl, url.c_str(), 0);
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define ARCH_INTERNET CArchInternetUnix
|
||||
#define ARCH_INTERNET ArchInternetUnix
|
||||
|
||||
#include "base/String.h"
|
||||
|
||||
class CArchInternetUnix {
|
||||
class ArchInternetUnix {
|
||||
public:
|
||||
CString get(const CString& url);
|
||||
CString urlEncode(const CString& url);
|
||||
String get(const String& url);
|
||||
String urlEncode(const String& url);
|
||||
};
|
||||
|
|
|
@ -21,39 +21,39 @@
|
|||
#include <syslog.h>
|
||||
|
||||
//
|
||||
// CArchLogUnix
|
||||
// ArchLogUnix
|
||||
//
|
||||
|
||||
CArchLogUnix::CArchLogUnix()
|
||||
ArchLogUnix::ArchLogUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchLogUnix::~CArchLogUnix()
|
||||
ArchLogUnix::~ArchLogUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogUnix::openLog(const char* name)
|
||||
ArchLogUnix::openLog(const char* name)
|
||||
{
|
||||
openlog(name, 0, LOG_DAEMON);
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogUnix::closeLog()
|
||||
ArchLogUnix::closeLog()
|
||||
{
|
||||
closelog();
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogUnix::showLog(bool)
|
||||
ArchLogUnix::showLog(bool)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogUnix::writeLog(ELevel level, const char* msg)
|
||||
ArchLogUnix::writeLog(ELevel level, const char* msg)
|
||||
{
|
||||
// convert level
|
||||
int priority;
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchLog.h"
|
||||
|
||||
#define ARCH_LOG CArchLogUnix
|
||||
#define ARCH_LOG ArchLogUnix
|
||||
|
||||
//! Unix implementation of IArchLog
|
||||
class CArchLogUnix : public IArchLog {
|
||||
class ArchLogUnix : public IArchLog {
|
||||
public:
|
||||
CArchLogUnix();
|
||||
virtual ~CArchLogUnix();
|
||||
ArchLogUnix();
|
||||
virtual ~ArchLogUnix();
|
||||
|
||||
// IArchLog overrides
|
||||
virtual void openLog(const char* name);
|
||||
|
|
|
@ -59,12 +59,12 @@ setSignalSet(sigset_t* sigset)
|
|||
}
|
||||
|
||||
//
|
||||
// CArchThreadImpl
|
||||
// ArchThreadImpl
|
||||
//
|
||||
|
||||
class CArchThreadImpl {
|
||||
class ArchThreadImpl {
|
||||
public:
|
||||
CArchThreadImpl();
|
||||
ArchThreadImpl();
|
||||
|
||||
public:
|
||||
int m_refCount;
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
void* m_networkData;
|
||||
};
|
||||
|
||||
CArchThreadImpl::CArchThreadImpl() :
|
||||
ArchThreadImpl::ArchThreadImpl() :
|
||||
m_refCount(1),
|
||||
m_id(0),
|
||||
m_func(NULL),
|
||||
|
@ -95,12 +95,12 @@ CArchThreadImpl::CArchThreadImpl() :
|
|||
|
||||
|
||||
//
|
||||
// CArchMultithreadPosix
|
||||
// ArchMultithreadPosix
|
||||
//
|
||||
|
||||
CArchMultithreadPosix* CArchMultithreadPosix::s_instance = NULL;
|
||||
ArchMultithreadPosix* ArchMultithreadPosix::s_instance = NULL;
|
||||
|
||||
CArchMultithreadPosix::CArchMultithreadPosix() :
|
||||
ArchMultithreadPosix::ArchMultithreadPosix() :
|
||||
m_newThreadCalled(false),
|
||||
m_nextID(0)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ CArchMultithreadPosix::CArchMultithreadPosix() :
|
|||
|
||||
// create thread for calling (main) thread and add it to our
|
||||
// list. no need to lock the mutex since we're the only thread.
|
||||
m_mainThread = new CArchThreadImpl;
|
||||
m_mainThread = new ArchThreadImpl;
|
||||
m_mainThread->m_thread = pthread_self();
|
||||
insert(m_mainThread);
|
||||
|
||||
|
@ -149,7 +149,7 @@ CArchMultithreadPosix::CArchMultithreadPosix() :
|
|||
pthread_sigmask(SIG_BLOCK, &sigset, NULL);
|
||||
}
|
||||
|
||||
CArchMultithreadPosix::~CArchMultithreadPosix()
|
||||
ArchMultithreadPosix::~ArchMultithreadPosix()
|
||||
{
|
||||
assert(s_instance != NULL);
|
||||
|
||||
|
@ -158,16 +158,16 @@ CArchMultithreadPosix::~CArchMultithreadPosix()
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::setNetworkDataForCurrentThread(void* data)
|
||||
ArchMultithreadPosix::setNetworkDataForCurrentThread(void* data)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = find(pthread_self());
|
||||
ArchThreadImpl* thread = find(pthread_self());
|
||||
thread->m_networkData = data;
|
||||
unlockMutex(m_threadMutex);
|
||||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadPosix::getNetworkDataForThread(CArchThread thread)
|
||||
ArchMultithreadPosix::getNetworkDataForThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
void* data = thread->m_networkData;
|
||||
|
@ -175,16 +175,16 @@ CArchMultithreadPosix::getNetworkDataForThread(CArchThread thread)
|
|||
return data;
|
||||
}
|
||||
|
||||
CArchMultithreadPosix*
|
||||
CArchMultithreadPosix::getInstance()
|
||||
ArchMultithreadPosix*
|
||||
ArchMultithreadPosix::getInstance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
CArchCond
|
||||
CArchMultithreadPosix::newCondVar()
|
||||
ArchCond
|
||||
ArchMultithreadPosix::newCondVar()
|
||||
{
|
||||
CArchCondImpl* cond = new CArchCondImpl;
|
||||
ArchCondImpl* cond = new ArchCondImpl;
|
||||
int status = pthread_cond_init(&cond->m_cond, NULL);
|
||||
(void)status;
|
||||
assert(status == 0);
|
||||
|
@ -192,7 +192,7 @@ CArchMultithreadPosix::newCondVar()
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::closeCondVar(CArchCond cond)
|
||||
ArchMultithreadPosix::closeCondVar(ArchCond cond)
|
||||
{
|
||||
int status = pthread_cond_destroy(&cond->m_cond);
|
||||
(void)status;
|
||||
|
@ -201,7 +201,7 @@ CArchMultithreadPosix::closeCondVar(CArchCond cond)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::signalCondVar(CArchCond cond)
|
||||
ArchMultithreadPosix::signalCondVar(ArchCond cond)
|
||||
{
|
||||
int status = pthread_cond_signal(&cond->m_cond);
|
||||
(void)status;
|
||||
|
@ -209,7 +209,7 @@ CArchMultithreadPosix::signalCondVar(CArchCond cond)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::broadcastCondVar(CArchCond cond)
|
||||
ArchMultithreadPosix::broadcastCondVar(ArchCond cond)
|
||||
{
|
||||
int status = pthread_cond_broadcast(&cond->m_cond);
|
||||
(void)status;
|
||||
|
@ -217,8 +217,8 @@ CArchMultithreadPosix::broadcastCondVar(CArchCond cond)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadPosix::waitCondVar(CArchCond cond,
|
||||
CArchMutex mutex, double timeout)
|
||||
ArchMultithreadPosix::waitCondVar(ArchCond cond,
|
||||
ArchMutex mutex, double timeout)
|
||||
{
|
||||
// we can't wait on a condition variable and also wake it up for
|
||||
// cancellation since we don't use posix cancellation. so we
|
||||
|
@ -272,20 +272,20 @@ CArchMultithreadPosix::waitCondVar(CArchCond cond,
|
|||
}
|
||||
}
|
||||
|
||||
CArchMutex
|
||||
CArchMultithreadPosix::newMutex()
|
||||
ArchMutex
|
||||
ArchMultithreadPosix::newMutex()
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int status = pthread_mutexattr_init(&attr);
|
||||
assert(status == 0);
|
||||
CArchMutexImpl* mutex = new CArchMutexImpl;
|
||||
ArchMutexImpl* mutex = new ArchMutexImpl;
|
||||
status = pthread_mutex_init(&mutex->m_mutex, &attr);
|
||||
assert(status == 0);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::closeMutex(CArchMutex mutex)
|
||||
ArchMultithreadPosix::closeMutex(ArchMutex mutex)
|
||||
{
|
||||
int status = pthread_mutex_destroy(&mutex->m_mutex);
|
||||
(void)status;
|
||||
|
@ -294,7 +294,7 @@ CArchMultithreadPosix::closeMutex(CArchMutex mutex)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::lockMutex(CArchMutex mutex)
|
||||
ArchMultithreadPosix::lockMutex(ArchMutex mutex)
|
||||
{
|
||||
int status = pthread_mutex_lock(&mutex->m_mutex);
|
||||
|
||||
|
@ -318,7 +318,7 @@ CArchMultithreadPosix::lockMutex(CArchMutex mutex)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::unlockMutex(CArchMutex mutex)
|
||||
ArchMultithreadPosix::unlockMutex(ArchMutex mutex)
|
||||
{
|
||||
int status = pthread_mutex_unlock(&mutex->m_mutex);
|
||||
|
||||
|
@ -337,8 +337,8 @@ CArchMultithreadPosix::unlockMutex(CArchMutex mutex)
|
|||
}
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
||||
ArchThread
|
||||
ArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
||||
{
|
||||
assert(func != NULL);
|
||||
|
||||
|
@ -359,7 +359,7 @@ CArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
|||
lockMutex(m_threadMutex);
|
||||
|
||||
// create thread impl for new thread
|
||||
CArchThreadImpl* thread = new CArchThreadImpl;
|
||||
ArchThreadImpl* thread = new ArchThreadImpl;
|
||||
thread->m_func = func;
|
||||
thread->m_userData = data;
|
||||
|
||||
|
@ -369,7 +369,7 @@ CArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
|||
int status = pthread_attr_init(&attr);
|
||||
if (status == 0) {
|
||||
status = pthread_create(&thread->m_thread, &attr,
|
||||
&CArchMultithreadPosix::threadFunc, thread);
|
||||
&ArchMultithreadPosix::threadFunc, thread);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
||||
|
@ -393,18 +393,18 @@ CArchMultithreadPosix::newThread(ThreadFunc func, void* data)
|
|||
return thread;
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadPosix::newCurrentThread()
|
||||
ArchThread
|
||||
ArchMultithreadPosix::newCurrentThread()
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = find(pthread_self());
|
||||
ArchThreadImpl* thread = find(pthread_self());
|
||||
unlockMutex(m_threadMutex);
|
||||
assert(thread != NULL);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::closeThread(CArchThread thread)
|
||||
ArchMultithreadPosix::closeThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -426,15 +426,15 @@ CArchMultithreadPosix::closeThread(CArchThread thread)
|
|||
}
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadPosix::copyThread(CArchThread thread)
|
||||
ArchThread
|
||||
ArchMultithreadPosix::copyThread(ArchThread thread)
|
||||
{
|
||||
refThread(thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::cancelThread(CArchThread thread)
|
||||
ArchMultithreadPosix::cancelThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -454,7 +454,7 @@ CArchMultithreadPosix::cancelThread(CArchThread thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::setPriorityOfThread(CArchThread thread, int /*n*/)
|
||||
ArchMultithreadPosix::setPriorityOfThread(ArchThread thread, int /*n*/)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -462,11 +462,11 @@ CArchMultithreadPosix::setPriorityOfThread(CArchThread thread, int /*n*/)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::testCancelThread()
|
||||
ArchMultithreadPosix::testCancelThread()
|
||||
{
|
||||
// find current thread
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = findNoRef(pthread_self());
|
||||
ArchThreadImpl* thread = findNoRef(pthread_self());
|
||||
unlockMutex(m_threadMutex);
|
||||
|
||||
// test cancel on thread
|
||||
|
@ -474,14 +474,14 @@ CArchMultithreadPosix::testCancelThread()
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadPosix::wait(CArchThread target, double timeout)
|
||||
ArchMultithreadPosix::wait(ArchThread target, double timeout)
|
||||
{
|
||||
assert(target != NULL);
|
||||
|
||||
lockMutex(m_threadMutex);
|
||||
|
||||
// find current thread
|
||||
CArchThreadImpl* self = findNoRef(pthread_self());
|
||||
ArchThreadImpl* self = findNoRef(pthread_self());
|
||||
|
||||
// ignore wait if trying to wait on ourself
|
||||
if (target == self) {
|
||||
|
@ -530,13 +530,13 @@ CArchMultithreadPosix::wait(CArchThread target, double timeout)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadPosix::isSameThread(CArchThread thread1, CArchThread thread2)
|
||||
ArchMultithreadPosix::isSameThread(ArchThread thread1, ArchThread thread2)
|
||||
{
|
||||
return (thread1 == thread2);
|
||||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadPosix::isExitedThread(CArchThread thread)
|
||||
ArchMultithreadPosix::isExitedThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
bool exited = thread->m_exited;
|
||||
|
@ -545,7 +545,7 @@ CArchMultithreadPosix::isExitedThread(CArchThread thread)
|
|||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadPosix::getResultOfThread(CArchThread thread)
|
||||
ArchMultithreadPosix::getResultOfThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
void* result = thread->m_result;
|
||||
|
@ -554,13 +554,13 @@ CArchMultithreadPosix::getResultOfThread(CArchThread thread)
|
|||
}
|
||||
|
||||
IArchMultithread::ThreadID
|
||||
CArchMultithreadPosix::getIDOfThread(CArchThread thread)
|
||||
ArchMultithreadPosix::getIDOfThread(ArchThread thread)
|
||||
{
|
||||
return thread->m_id;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::setSignalHandler(
|
||||
ArchMultithreadPosix::setSignalHandler(
|
||||
ESignal signal, SignalFunc func, void* userData)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
|
@ -570,7 +570,7 @@ CArchMultithreadPosix::setSignalHandler(
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::raiseSignal(ESignal signal)
|
||||
ArchMultithreadPosix::raiseSignal(ESignal signal)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
if (m_signalFunc[signal] != NULL) {
|
||||
|
@ -584,7 +584,7 @@ CArchMultithreadPosix::raiseSignal(ESignal signal)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::startSignalHandler()
|
||||
ArchMultithreadPosix::startSignalHandler()
|
||||
{
|
||||
// set signal mask. the main thread blocks these signals and
|
||||
// the signal handler thread will listen for them.
|
||||
|
@ -600,7 +600,7 @@ CArchMultithreadPosix::startSignalHandler()
|
|||
int status = pthread_attr_init(&attr);
|
||||
if (status == 0) {
|
||||
status = pthread_create(&m_signalThread, &attr,
|
||||
&CArchMultithreadPosix::threadSignalHandler,
|
||||
&ArchMultithreadPosix::threadSignalHandler,
|
||||
NULL);
|
||||
pthread_attr_destroy(&attr);
|
||||
}
|
||||
|
@ -611,21 +611,21 @@ CArchMultithreadPosix::startSignalHandler()
|
|||
}
|
||||
}
|
||||
|
||||
CArchThreadImpl*
|
||||
CArchMultithreadPosix::find(pthread_t thread)
|
||||
ArchThreadImpl*
|
||||
ArchMultithreadPosix::find(pthread_t thread)
|
||||
{
|
||||
CArchThreadImpl* impl = findNoRef(thread);
|
||||
ArchThreadImpl* impl = findNoRef(thread);
|
||||
if (impl != NULL) {
|
||||
refThread(impl);
|
||||
}
|
||||
return impl;
|
||||
}
|
||||
|
||||
CArchThreadImpl*
|
||||
CArchMultithreadPosix::findNoRef(pthread_t thread)
|
||||
ArchThreadImpl*
|
||||
ArchMultithreadPosix::findNoRef(pthread_t thread)
|
||||
{
|
||||
// linear search
|
||||
for (CThreadList::const_iterator index = m_threadList.begin();
|
||||
for (ThreadList::const_iterator index = m_threadList.begin();
|
||||
index != m_threadList.end(); ++index) {
|
||||
if ((*index)->m_thread == thread) {
|
||||
return *index;
|
||||
|
@ -635,7 +635,7 @@ CArchMultithreadPosix::findNoRef(pthread_t thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::insert(CArchThreadImpl* thread)
|
||||
ArchMultithreadPosix::insert(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -653,9 +653,9 @@ CArchMultithreadPosix::insert(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::erase(CArchThreadImpl* thread)
|
||||
ArchMultithreadPosix::erase(ArchThreadImpl* thread)
|
||||
{
|
||||
for (CThreadList::iterator index = m_threadList.begin();
|
||||
for (ThreadList::iterator index = m_threadList.begin();
|
||||
index != m_threadList.end(); ++index) {
|
||||
if (*index == thread) {
|
||||
m_threadList.erase(index);
|
||||
|
@ -665,7 +665,7 @@ CArchMultithreadPosix::erase(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::refThread(CArchThreadImpl* thread)
|
||||
ArchMultithreadPosix::refThread(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(findNoRef(thread->m_thread) != NULL);
|
||||
|
@ -673,7 +673,7 @@ CArchMultithreadPosix::refThread(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::testCancelThreadImpl(CArchThreadImpl* thread)
|
||||
ArchMultithreadPosix::testCancelThreadImpl(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -694,10 +694,10 @@ CArchMultithreadPosix::testCancelThreadImpl(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadPosix::threadFunc(void* vrep)
|
||||
ArchMultithreadPosix::threadFunc(void* vrep)
|
||||
{
|
||||
// get the thread
|
||||
CArchThreadImpl* thread = reinterpret_cast<CArchThreadImpl*>(vrep);
|
||||
ArchThreadImpl* thread = reinterpret_cast<ArchThreadImpl*>(vrep);
|
||||
|
||||
// setup pthreads
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
|
@ -711,7 +711,7 @@ CArchMultithreadPosix::threadFunc(void* vrep)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::doThreadFunc(CArchThread thread)
|
||||
ArchMultithreadPosix::doThreadFunc(ArchThread thread)
|
||||
{
|
||||
// default priority is slightly below normal
|
||||
setPriorityOfThread(thread, 1);
|
||||
|
@ -749,13 +749,13 @@ CArchMultithreadPosix::doThreadFunc(CArchThread thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadPosix::threadCancel(int)
|
||||
ArchMultithreadPosix::threadCancel(int)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadPosix::threadSignalHandler(void*)
|
||||
ArchMultithreadPosix::threadSignalHandler(void*)
|
||||
{
|
||||
// detach
|
||||
pthread_detach(pthread_self());
|
||||
|
|
|
@ -23,23 +23,23 @@
|
|||
|
||||
#include <pthread.h>
|
||||
|
||||
#define ARCH_MULTITHREAD CArchMultithreadPosix
|
||||
#define ARCH_MULTITHREAD ArchMultithreadPosix
|
||||
|
||||
class CArchCondImpl {
|
||||
class ArchCondImpl {
|
||||
public:
|
||||
pthread_cond_t m_cond;
|
||||
};
|
||||
|
||||
class CArchMutexImpl {
|
||||
class ArchMutexImpl {
|
||||
public:
|
||||
pthread_mutex_t m_mutex;
|
||||
};
|
||||
|
||||
//! Posix implementation of IArchMultithread
|
||||
class CArchMultithreadPosix : public IArchMultithread {
|
||||
class ArchMultithreadPosix : public IArchMultithread {
|
||||
public:
|
||||
CArchMultithreadPosix();
|
||||
virtual ~CArchMultithreadPosix();
|
||||
ArchMultithreadPosix();
|
||||
virtual ~ArchMultithreadPosix();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
@ -50,63 +50,63 @@ public:
|
|||
//! @name accessors
|
||||
//@{
|
||||
|
||||
void* getNetworkDataForThread(CArchThread);
|
||||
void* getNetworkDataForThread(ArchThread);
|
||||
|
||||
static CArchMultithreadPosix* getInstance();
|
||||
static ArchMultithreadPosix* getInstance();
|
||||
|
||||
//@}
|
||||
|
||||
// IArchMultithread overrides
|
||||
virtual CArchCond newCondVar();
|
||||
virtual void closeCondVar(CArchCond);
|
||||
virtual void signalCondVar(CArchCond);
|
||||
virtual void broadcastCondVar(CArchCond);
|
||||
virtual bool waitCondVar(CArchCond, CArchMutex, double timeout);
|
||||
virtual CArchMutex newMutex();
|
||||
virtual void closeMutex(CArchMutex);
|
||||
virtual void lockMutex(CArchMutex);
|
||||
virtual void unlockMutex(CArchMutex);
|
||||
virtual CArchThread newThread(ThreadFunc, void*);
|
||||
virtual CArchThread newCurrentThread();
|
||||
virtual CArchThread copyThread(CArchThread);
|
||||
virtual void closeThread(CArchThread);
|
||||
virtual void cancelThread(CArchThread);
|
||||
virtual void setPriorityOfThread(CArchThread, int n);
|
||||
virtual ArchCond newCondVar();
|
||||
virtual void closeCondVar(ArchCond);
|
||||
virtual void signalCondVar(ArchCond);
|
||||
virtual void broadcastCondVar(ArchCond);
|
||||
virtual bool waitCondVar(ArchCond, ArchMutex, double timeout);
|
||||
virtual ArchMutex newMutex();
|
||||
virtual void closeMutex(ArchMutex);
|
||||
virtual void lockMutex(ArchMutex);
|
||||
virtual void unlockMutex(ArchMutex);
|
||||
virtual ArchThread newThread(ThreadFunc, void*);
|
||||
virtual ArchThread newCurrentThread();
|
||||
virtual ArchThread copyThread(ArchThread);
|
||||
virtual void closeThread(ArchThread);
|
||||
virtual void cancelThread(ArchThread);
|
||||
virtual void setPriorityOfThread(ArchThread, int n);
|
||||
virtual void testCancelThread();
|
||||
virtual bool wait(CArchThread, double timeout);
|
||||
virtual bool isSameThread(CArchThread, CArchThread);
|
||||
virtual bool isExitedThread(CArchThread);
|
||||
virtual void* getResultOfThread(CArchThread);
|
||||
virtual ThreadID getIDOfThread(CArchThread);
|
||||
virtual bool wait(ArchThread, double timeout);
|
||||
virtual bool isSameThread(ArchThread, ArchThread);
|
||||
virtual bool isExitedThread(ArchThread);
|
||||
virtual void* getResultOfThread(ArchThread);
|
||||
virtual ThreadID getIDOfThread(ArchThread);
|
||||
virtual void setSignalHandler(ESignal, SignalFunc, void*);
|
||||
virtual void raiseSignal(ESignal);
|
||||
|
||||
private:
|
||||
void startSignalHandler();
|
||||
|
||||
CArchThreadImpl* find(pthread_t thread);
|
||||
CArchThreadImpl* findNoRef(pthread_t thread);
|
||||
void insert(CArchThreadImpl* thread);
|
||||
void erase(CArchThreadImpl* thread);
|
||||
ArchThreadImpl* find(pthread_t thread);
|
||||
ArchThreadImpl* findNoRef(pthread_t thread);
|
||||
void insert(ArchThreadImpl* thread);
|
||||
void erase(ArchThreadImpl* thread);
|
||||
|
||||
void refThread(CArchThreadImpl* rep);
|
||||
void testCancelThreadImpl(CArchThreadImpl* rep);
|
||||
void refThread(ArchThreadImpl* rep);
|
||||
void testCancelThreadImpl(ArchThreadImpl* rep);
|
||||
|
||||
void doThreadFunc(CArchThread thread);
|
||||
void doThreadFunc(ArchThread thread);
|
||||
static void* threadFunc(void* vrep);
|
||||
static void threadCancel(int);
|
||||
static void* threadSignalHandler(void* vrep);
|
||||
|
||||
private:
|
||||
typedef std::list<CArchThread> CThreadList;
|
||||
typedef std::list<ArchThread> ThreadList;
|
||||
|
||||
static CArchMultithreadPosix* s_instance;
|
||||
static ArchMultithreadPosix* s_instance;
|
||||
|
||||
bool m_newThreadCalled;
|
||||
|
||||
CArchMutex m_threadMutex;
|
||||
CArchThread m_mainThread;
|
||||
CThreadList m_threadList;
|
||||
ArchMutex m_threadMutex;
|
||||
ArchThread m_mainThread;
|
||||
ThreadList m_threadList;
|
||||
ThreadID m_nextID;
|
||||
|
||||
pthread_t m_signalThread;
|
||||
|
|
|
@ -83,27 +83,27 @@ inet_aton(const char* cp, struct in_addr* inp)
|
|||
#endif
|
||||
|
||||
//
|
||||
// CArchNetworkBSD
|
||||
// ArchNetworkBSD
|
||||
//
|
||||
|
||||
CArchNetworkBSD::CArchNetworkBSD()
|
||||
ArchNetworkBSD::ArchNetworkBSD()
|
||||
{
|
||||
}
|
||||
|
||||
CArchNetworkBSD::~CArchNetworkBSD()
|
||||
ArchNetworkBSD::~ArchNetworkBSD()
|
||||
{
|
||||
ARCH->closeMutex(m_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::init()
|
||||
ArchNetworkBSD::init()
|
||||
{
|
||||
// create mutex to make some calls thread safe
|
||||
m_mutex = ARCH->newMutex();
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkBSD::newSocket(EAddressFamily family, ESocketType type)
|
||||
ArchSocket
|
||||
ArchNetworkBSD::newSocket(EAddressFamily family, ESocketType type)
|
||||
{
|
||||
// create socket
|
||||
int fd = socket(s_family[family], s_type[type], 0);
|
||||
|
@ -119,14 +119,14 @@ CArchNetworkBSD::newSocket(EAddressFamily family, ESocketType type)
|
|||
}
|
||||
|
||||
// allocate socket object
|
||||
CArchSocketImpl* newSocket = new CArchSocketImpl;
|
||||
ArchSocketImpl* newSocket = new ArchSocketImpl;
|
||||
newSocket->m_fd = fd;
|
||||
newSocket->m_refCount = 1;
|
||||
return newSocket;
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkBSD::copySocket(CArchSocket s)
|
||||
ArchSocket
|
||||
ArchNetworkBSD::copySocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -138,7 +138,7 @@ CArchNetworkBSD::copySocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::closeSocket(CArchSocket s)
|
||||
ArchNetworkBSD::closeSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -162,7 +162,7 @@ CArchNetworkBSD::closeSocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::closeSocketForRead(CArchSocket s)
|
||||
ArchNetworkBSD::closeSocketForRead(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -174,7 +174,7 @@ CArchNetworkBSD::closeSocketForRead(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::closeSocketForWrite(CArchSocket s)
|
||||
ArchNetworkBSD::closeSocketForWrite(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -186,7 +186,7 @@ CArchNetworkBSD::closeSocketForWrite(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::bindSocket(CArchSocket s, CArchNetAddress addr)
|
||||
ArchNetworkBSD::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
|
@ -197,7 +197,7 @@ CArchNetworkBSD::bindSocket(CArchSocket s, CArchNetAddress addr)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::listenOnSocket(CArchSocket s)
|
||||
ArchNetworkBSD::listenOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -207,20 +207,20 @@ CArchNetworkBSD::listenOnSocket(CArchSocket s)
|
|||
}
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkBSD::acceptSocket(CArchSocket s, CArchNetAddress* addr)
|
||||
ArchSocket
|
||||
ArchNetworkBSD::acceptSocket(ArchSocket s, ArchNetAddress* addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
// if user passed NULL in addr then use scratch space
|
||||
CArchNetAddress dummy;
|
||||
ArchNetAddress dummy;
|
||||
if (addr == NULL) {
|
||||
addr = &dummy;
|
||||
}
|
||||
|
||||
// create new socket and address
|
||||
CArchSocketImpl* newSocket = new CArchSocketImpl;
|
||||
*addr = new CArchNetAddressImpl;
|
||||
ArchSocketImpl* newSocket = new ArchSocketImpl;
|
||||
*addr = new ArchNetAddressImpl;
|
||||
|
||||
// accept on socket
|
||||
ACCEPT_TYPE_ARG3 len = (ACCEPT_TYPE_ARG3)((*addr)->m_len);
|
||||
|
@ -261,7 +261,7 @@ CArchNetworkBSD::acceptSocket(CArchSocket s, CArchNetAddress* addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkBSD::connectSocket(CArchSocket s, CArchNetAddress addr)
|
||||
ArchNetworkBSD::connectSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
|
@ -281,7 +281,7 @@ CArchNetworkBSD::connectSocket(CArchSocket s, CArchNetAddress addr)
|
|||
#if HAVE_POLL
|
||||
|
||||
int
|
||||
CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
|
||||
ArchNetworkBSD::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
{
|
||||
assert(pe != NULL || num == 0);
|
||||
|
||||
|
@ -373,7 +373,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
|
|||
#else
|
||||
|
||||
int
|
||||
CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
|
||||
ArchNetworkBSD::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
|
@ -497,7 +497,7 @@ CArchNetworkBSD::pollSocket(CPollEntry pe[], int num, double timeout)
|
|||
#endif
|
||||
|
||||
void
|
||||
CArchNetworkBSD::unblockPollSocket(CArchThread thread)
|
||||
ArchNetworkBSD::unblockPollSocket(ArchThread thread)
|
||||
{
|
||||
const int* unblockPipe = getUnblockPipeForThread(thread);
|
||||
if (unblockPipe != NULL) {
|
||||
|
@ -509,7 +509,7 @@ CArchNetworkBSD::unblockPollSocket(CArchThread thread)
|
|||
}
|
||||
|
||||
size_t
|
||||
CArchNetworkBSD::readSocket(CArchSocket s, void* buf, size_t len)
|
||||
ArchNetworkBSD::readSocket(ArchSocket s, void* buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -524,7 +524,7 @@ CArchNetworkBSD::readSocket(CArchSocket s, void* buf, size_t len)
|
|||
}
|
||||
|
||||
size_t
|
||||
CArchNetworkBSD::writeSocket(CArchSocket s, const void* buf, size_t len)
|
||||
ArchNetworkBSD::writeSocket(ArchSocket s, const void* buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -539,7 +539,7 @@ CArchNetworkBSD::writeSocket(CArchSocket s, const void* buf, size_t len)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::throwErrorOnSocket(CArchSocket s)
|
||||
ArchNetworkBSD::throwErrorOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -558,7 +558,7 @@ CArchNetworkBSD::throwErrorOnSocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::setBlockingOnSocket(int fd, bool blocking)
|
||||
ArchNetworkBSD::setBlockingOnSocket(int fd, bool blocking)
|
||||
{
|
||||
assert(fd != -1);
|
||||
|
||||
|
@ -578,7 +578,7 @@ CArchNetworkBSD::setBlockingOnSocket(int fd, bool blocking)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkBSD::setNoDelayOnSocket(CArchSocket s, bool noDelay)
|
||||
ArchNetworkBSD::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -601,7 +601,7 @@ CArchNetworkBSD::setNoDelayOnSocket(CArchSocket s, bool noDelay)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkBSD::setReuseAddrOnSocket(CArchSocket s, bool reuse)
|
||||
ArchNetworkBSD::setReuseAddrOnSocket(ArchSocket s, bool reuse)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -624,7 +624,7 @@ CArchNetworkBSD::setReuseAddrOnSocket(CArchSocket s, bool reuse)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkBSD::getHostName()
|
||||
ArchNetworkBSD::getHostName()
|
||||
{
|
||||
char name[256];
|
||||
if (gethostname(name, sizeof(name)) == -1) {
|
||||
|
@ -636,11 +636,11 @@ CArchNetworkBSD::getHostName()
|
|||
return name;
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkBSD::newAnyAddr(EAddressFamily family)
|
||||
ArchNetAddress
|
||||
ArchNetworkBSD::newAnyAddr(EAddressFamily family)
|
||||
{
|
||||
// allocate address
|
||||
CArchNetAddressImpl* addr = new CArchNetAddressImpl;
|
||||
ArchNetAddressImpl* addr = new ArchNetAddressImpl;
|
||||
|
||||
// fill it in
|
||||
switch (family) {
|
||||
|
@ -662,20 +662,20 @@ CArchNetworkBSD::newAnyAddr(EAddressFamily family)
|
|||
return addr;
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkBSD::copyAddr(CArchNetAddress addr)
|
||||
ArchNetAddress
|
||||
ArchNetworkBSD::copyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
// allocate and copy address
|
||||
return new CArchNetAddressImpl(*addr);
|
||||
return new ArchNetAddressImpl(*addr);
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkBSD::nameToAddr(const std::string& name)
|
||||
ArchNetAddress
|
||||
ArchNetworkBSD::nameToAddr(const std::string& name)
|
||||
{
|
||||
// allocate address
|
||||
CArchNetAddressImpl* addr = new CArchNetAddressImpl;
|
||||
ArchNetAddressImpl* addr = new ArchNetAddressImpl;
|
||||
|
||||
// try to convert assuming an IPv4 dot notation address
|
||||
struct sockaddr_in inaddr;
|
||||
|
@ -723,7 +723,7 @@ CArchNetworkBSD::nameToAddr(const std::string& name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::closeAddr(CArchNetAddress addr)
|
||||
ArchNetworkBSD::closeAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -731,7 +731,7 @@ CArchNetworkBSD::closeAddr(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkBSD::addrToName(CArchNetAddress addr)
|
||||
ArchNetworkBSD::addrToName(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -755,7 +755,7 @@ CArchNetworkBSD::addrToName(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkBSD::addrToString(CArchNetAddress addr)
|
||||
ArchNetworkBSD::addrToString(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -776,7 +776,7 @@ CArchNetworkBSD::addrToString(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
IArchNetwork::EAddressFamily
|
||||
CArchNetworkBSD::getAddrFamily(CArchNetAddress addr)
|
||||
ArchNetworkBSD::getAddrFamily(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -790,7 +790,7 @@ CArchNetworkBSD::getAddrFamily(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::setAddrPort(CArchNetAddress addr, int port)
|
||||
ArchNetworkBSD::setAddrPort(ArchNetAddress addr, int port)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -809,7 +809,7 @@ CArchNetworkBSD::setAddrPort(CArchNetAddress addr, int port)
|
|||
}
|
||||
|
||||
int
|
||||
CArchNetworkBSD::getAddrPort(CArchNetAddress addr)
|
||||
ArchNetworkBSD::getAddrPort(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -827,7 +827,7 @@ CArchNetworkBSD::getAddrPort(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkBSD::isAnyAddr(CArchNetAddress addr)
|
||||
ArchNetworkBSD::isAnyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -846,26 +846,26 @@ CArchNetworkBSD::isAnyAddr(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkBSD::isEqualAddr(CArchNetAddress a, CArchNetAddress b)
|
||||
ArchNetworkBSD::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||
{
|
||||
return (a->m_len == b->m_len &&
|
||||
memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0);
|
||||
}
|
||||
|
||||
const int*
|
||||
CArchNetworkBSD::getUnblockPipe()
|
||||
ArchNetworkBSD::getUnblockPipe()
|
||||
{
|
||||
CArchMultithreadPosix* mt = CArchMultithreadPosix::getInstance();
|
||||
CArchThread thread = mt->newCurrentThread();
|
||||
ArchMultithreadPosix* mt = ArchMultithreadPosix::getInstance();
|
||||
ArchThread thread = mt->newCurrentThread();
|
||||
const int* p = getUnblockPipeForThread(thread);
|
||||
ARCH->closeThread(thread);
|
||||
return p;
|
||||
}
|
||||
|
||||
const int*
|
||||
CArchNetworkBSD::getUnblockPipeForThread(CArchThread thread)
|
||||
ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||
{
|
||||
CArchMultithreadPosix* mt = CArchMultithreadPosix::getInstance();
|
||||
ArchMultithreadPosix* mt = ArchMultithreadPosix::getInstance();
|
||||
int* unblockPipe = (int*)mt->getNetworkDataForThread(thread);
|
||||
if (unblockPipe == NULL) {
|
||||
unblockPipe = new int[2];
|
||||
|
@ -888,7 +888,7 @@ CArchNetworkBSD::getUnblockPipeForThread(CArchThread thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::throwError(int err)
|
||||
ArchNetworkBSD::throwError(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case EINTR:
|
||||
|
@ -960,7 +960,7 @@ CArchNetworkBSD::throwError(int err)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkBSD::throwNameError(int err)
|
||||
ArchNetworkBSD::throwNameError(int err)
|
||||
{
|
||||
static const char* s_msg[] = {
|
||||
"The specified host is unknown",
|
||||
|
|
|
@ -37,17 +37,17 @@ typedef int socklen_t;
|
|||
// compatible so we always use it.
|
||||
typedef char optval_t;
|
||||
|
||||
#define ARCH_NETWORK CArchNetworkBSD
|
||||
#define ARCH_NETWORK ArchNetworkBSD
|
||||
|
||||
class CArchSocketImpl {
|
||||
class ArchSocketImpl {
|
||||
public:
|
||||
int m_fd;
|
||||
int m_refCount;
|
||||
};
|
||||
|
||||
class CArchNetAddressImpl {
|
||||
class ArchNetAddressImpl {
|
||||
public:
|
||||
CArchNetAddressImpl() : m_len(sizeof(m_addr)) { }
|
||||
ArchNetAddressImpl() : m_len(sizeof(m_addr)) { }
|
||||
|
||||
public:
|
||||
struct sockaddr m_addr;
|
||||
|
@ -55,50 +55,50 @@ public:
|
|||
};
|
||||
|
||||
//! Berkeley (BSD) sockets implementation of IArchNetwork
|
||||
class CArchNetworkBSD : public IArchNetwork {
|
||||
class ArchNetworkBSD : public IArchNetwork {
|
||||
public:
|
||||
CArchNetworkBSD();
|
||||
virtual ~CArchNetworkBSD();
|
||||
ArchNetworkBSD();
|
||||
virtual ~ArchNetworkBSD();
|
||||
|
||||
virtual void init();
|
||||
|
||||
// IArchNetwork overrides
|
||||
virtual CArchSocket newSocket(EAddressFamily, ESocketType);
|
||||
virtual CArchSocket copySocket(CArchSocket s); virtual void closeSocket(CArchSocket s);
|
||||
virtual void closeSocketForRead(CArchSocket s);
|
||||
virtual void closeSocketForWrite(CArchSocket s);
|
||||
virtual void bindSocket(CArchSocket s, CArchNetAddress addr);
|
||||
virtual void listenOnSocket(CArchSocket s);
|
||||
virtual CArchSocket acceptSocket(CArchSocket s, CArchNetAddress* addr);
|
||||
virtual bool connectSocket(CArchSocket s, CArchNetAddress name);
|
||||
virtual int pollSocket(CPollEntry[], int num, double timeout);
|
||||
virtual void unblockPollSocket(CArchThread thread);
|
||||
virtual size_t readSocket(CArchSocket s, void* buf, size_t len);
|
||||
virtual size_t writeSocket(CArchSocket s,
|
||||
virtual ArchSocket newSocket(EAddressFamily, ESocketType);
|
||||
virtual ArchSocket copySocket(ArchSocket s); virtual void closeSocket(ArchSocket s);
|
||||
virtual void closeSocketForRead(ArchSocket s);
|
||||
virtual void closeSocketForWrite(ArchSocket s);
|
||||
virtual void bindSocket(ArchSocket s, ArchNetAddress addr);
|
||||
virtual void listenOnSocket(ArchSocket s);
|
||||
virtual ArchSocket acceptSocket(ArchSocket s, ArchNetAddress* addr);
|
||||
virtual bool connectSocket(ArchSocket s, ArchNetAddress name);
|
||||
virtual int pollSocket(PollEntry[], int num, double timeout);
|
||||
virtual void unblockPollSocket(ArchThread thread);
|
||||
virtual size_t readSocket(ArchSocket s, void* buf, size_t len);
|
||||
virtual size_t writeSocket(ArchSocket s,
|
||||
const void* buf, size_t len);
|
||||
virtual void throwErrorOnSocket(CArchSocket);
|
||||
virtual bool setNoDelayOnSocket(CArchSocket, bool noDelay);
|
||||
virtual bool setReuseAddrOnSocket(CArchSocket, bool reuse);
|
||||
virtual void throwErrorOnSocket(ArchSocket);
|
||||
virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay);
|
||||
virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse);
|
||||
virtual std::string getHostName();
|
||||
virtual CArchNetAddress newAnyAddr(EAddressFamily);
|
||||
virtual CArchNetAddress copyAddr(CArchNetAddress);
|
||||
virtual CArchNetAddress nameToAddr(const std::string&);
|
||||
virtual void closeAddr(CArchNetAddress);
|
||||
virtual std::string addrToName(CArchNetAddress);
|
||||
virtual std::string addrToString(CArchNetAddress);
|
||||
virtual EAddressFamily getAddrFamily(CArchNetAddress);
|
||||
virtual void setAddrPort(CArchNetAddress, int port);
|
||||
virtual int getAddrPort(CArchNetAddress);
|
||||
virtual bool isAnyAddr(CArchNetAddress);
|
||||
virtual bool isEqualAddr(CArchNetAddress, CArchNetAddress);
|
||||
virtual ArchNetAddress newAnyAddr(EAddressFamily);
|
||||
virtual ArchNetAddress copyAddr(ArchNetAddress);
|
||||
virtual ArchNetAddress nameToAddr(const std::string&);
|
||||
virtual void closeAddr(ArchNetAddress);
|
||||
virtual std::string addrToName(ArchNetAddress);
|
||||
virtual std::string addrToString(ArchNetAddress);
|
||||
virtual EAddressFamily getAddrFamily(ArchNetAddress);
|
||||
virtual void setAddrPort(ArchNetAddress, int port);
|
||||
virtual int getAddrPort(ArchNetAddress);
|
||||
virtual bool isAnyAddr(ArchNetAddress);
|
||||
virtual bool isEqualAddr(ArchNetAddress, ArchNetAddress);
|
||||
|
||||
private:
|
||||
const int* getUnblockPipe();
|
||||
const int* getUnblockPipeForThread(CArchThread);
|
||||
const int* getUnblockPipeForThread(ArchThread);
|
||||
void setBlockingOnSocket(int fd, bool blocking);
|
||||
void throwError(int);
|
||||
void throwNameError(int);
|
||||
|
||||
private:
|
||||
CArchMutex m_mutex;
|
||||
ArchMutex m_mutex;
|
||||
};
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
#include "arch/unix/ArchPluginUnix.h"
|
||||
|
||||
CArchPluginUnix::CArchPluginUnix()
|
||||
ArchPluginUnix::ArchPluginUnix()
|
||||
{
|
||||
}
|
||||
|
||||
CArchPluginUnix::~CArchPluginUnix()
|
||||
ArchPluginUnix::~ArchPluginUnix()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CArchPluginUnix::init(void* eventTarget, IEventQueue* events)
|
||||
ArchPluginUnix::init(void* eventTarget, IEventQueue* events)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -20,15 +20,15 @@
|
|||
|
||||
#include "arch/IArchPlugin.h"
|
||||
|
||||
#define ARCH_PLUGIN CArchPluginUnix
|
||||
#define ARCH_PLUGIN ArchPluginUnix
|
||||
|
||||
class IEventQueue;
|
||||
|
||||
//! Unix implementation of IArchPlugin
|
||||
class CArchPluginUnix : public IArchPlugin {
|
||||
class ArchPluginUnix : public IArchPlugin {
|
||||
public:
|
||||
CArchPluginUnix();
|
||||
virtual ~CArchPluginUnix();
|
||||
ArchPluginUnix();
|
||||
virtual ~ArchPluginUnix();
|
||||
|
||||
// IArchPlugin overrides
|
||||
void init(void* eventTarget, IEventQueue* events);
|
||||
|
|
|
@ -43,21 +43,21 @@
|
|||
#endif
|
||||
|
||||
//
|
||||
// CArchSleepUnix
|
||||
// ArchSleepUnix
|
||||
//
|
||||
|
||||
CArchSleepUnix::CArchSleepUnix()
|
||||
ArchSleepUnix::ArchSleepUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchSleepUnix::~CArchSleepUnix()
|
||||
ArchSleepUnix::~ArchSleepUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchSleepUnix::sleep(double timeout)
|
||||
ArchSleepUnix::sleep(double timeout)
|
||||
{
|
||||
ARCH->testCancelThread();
|
||||
if (timeout < 0.0) {
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchSleep.h"
|
||||
|
||||
#define ARCH_SLEEP CArchSleepUnix
|
||||
#define ARCH_SLEEP ArchSleepUnix
|
||||
|
||||
//! Unix implementation of IArchSleep
|
||||
class CArchSleepUnix : public IArchSleep {
|
||||
class ArchSleepUnix : public IArchSleep {
|
||||
public:
|
||||
CArchSleepUnix();
|
||||
virtual ~CArchSleepUnix();
|
||||
ArchSleepUnix();
|
||||
virtual ~ArchSleepUnix();
|
||||
|
||||
// IArchSleep overrides
|
||||
virtual void sleep(double timeout);
|
||||
|
|
|
@ -21,22 +21,22 @@
|
|||
#include <stdio.h>
|
||||
|
||||
//
|
||||
// CArchStringUnix
|
||||
// ArchStringUnix
|
||||
//
|
||||
|
||||
#include "arch/multibyte.h"
|
||||
#include "arch/vsnprintf.h"
|
||||
|
||||
CArchStringUnix::CArchStringUnix()
|
||||
ArchStringUnix::ArchStringUnix()
|
||||
{
|
||||
}
|
||||
|
||||
CArchStringUnix::~CArchStringUnix()
|
||||
ArchStringUnix::~ArchStringUnix()
|
||||
{
|
||||
}
|
||||
|
||||
IArchString::EWideCharEncoding
|
||||
CArchStringUnix::getWideCharEncoding()
|
||||
ArchStringUnix::getWideCharEncoding()
|
||||
{
|
||||
return kUCS4;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchString.h"
|
||||
|
||||
#define ARCH_STRING CArchStringUnix
|
||||
#define ARCH_STRING ArchStringUnix
|
||||
|
||||
//! Unix implementation of IArchString
|
||||
class CArchStringUnix : public IArchString {
|
||||
class ArchStringUnix : public IArchString {
|
||||
public:
|
||||
CArchStringUnix();
|
||||
virtual ~CArchStringUnix();
|
||||
ArchStringUnix();
|
||||
virtual ~ArchStringUnix();
|
||||
|
||||
// IArchString overrides
|
||||
virtual EWideCharEncoding
|
||||
|
|
|
@ -21,21 +21,21 @@
|
|||
#include <sys/utsname.h>
|
||||
|
||||
//
|
||||
// CArchSystemUnix
|
||||
// ArchSystemUnix
|
||||
//
|
||||
|
||||
CArchSystemUnix::CArchSystemUnix()
|
||||
ArchSystemUnix::ArchSystemUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchSystemUnix::~CArchSystemUnix()
|
||||
ArchSystemUnix::~ArchSystemUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchSystemUnix::getOSName() const
|
||||
ArchSystemUnix::getOSName() const
|
||||
{
|
||||
#if defined(HAVE_SYS_UTSNAME_H)
|
||||
struct utsname info;
|
||||
|
@ -53,7 +53,7 @@ CArchSystemUnix::getOSName() const
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchSystemUnix::getPlatformName() const
|
||||
ArchSystemUnix::getPlatformName() const
|
||||
{
|
||||
#if defined(HAVE_SYS_UTSNAME_H)
|
||||
struct utsname info;
|
||||
|
@ -65,12 +65,12 @@ CArchSystemUnix::getPlatformName() const
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchSystemUnix::setting(const std::string&) const
|
||||
ArchSystemUnix::setting(const std::string&) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
CArchSystemUnix::setting(const std::string&, const std::string&) const
|
||||
ArchSystemUnix::setting(const std::string&, const std::string&) const
|
||||
{
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchSystem.h"
|
||||
|
||||
#define ARCH_SYSTEM CArchSystemUnix
|
||||
#define ARCH_SYSTEM ArchSystemUnix
|
||||
|
||||
//! Unix implementation of IArchString
|
||||
class CArchSystemUnix : public IArchSystem {
|
||||
class ArchSystemUnix : public IArchSystem {
|
||||
public:
|
||||
CArchSystemUnix();
|
||||
virtual ~CArchSystemUnix();
|
||||
ArchSystemUnix();
|
||||
virtual ~ArchSystemUnix();
|
||||
|
||||
// IArchSystem overrides
|
||||
virtual std::string getOSName() const;
|
||||
|
|
|
@ -19,33 +19,33 @@
|
|||
#include "arch/unix/ArchTaskBarXWindows.h"
|
||||
|
||||
//
|
||||
// CArchTaskBarXWindows
|
||||
// ArchTaskBarXWindows
|
||||
//
|
||||
|
||||
CArchTaskBarXWindows::CArchTaskBarXWindows()
|
||||
ArchTaskBarXWindows::ArchTaskBarXWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchTaskBarXWindows::~CArchTaskBarXWindows()
|
||||
ArchTaskBarXWindows::~ArchTaskBarXWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarXWindows::addReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
ArchTaskBarXWindows::addReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarXWindows::removeReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
ArchTaskBarXWindows::removeReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarXWindows::updateReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
ArchTaskBarXWindows::updateReceiver(IArchTaskBarReceiver* /*receiver*/)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchTaskBar.h"
|
||||
|
||||
#define ARCH_TASKBAR CArchTaskBarXWindows
|
||||
#define ARCH_TASKBAR ArchTaskBarXWindows
|
||||
|
||||
//! X11 implementation of IArchTaskBar
|
||||
class CArchTaskBarXWindows : public IArchTaskBar {
|
||||
class ArchTaskBarXWindows : public IArchTaskBar {
|
||||
public:
|
||||
CArchTaskBarXWindows();
|
||||
virtual ~CArchTaskBarXWindows();
|
||||
ArchTaskBarXWindows();
|
||||
virtual ~ArchTaskBarXWindows();
|
||||
|
||||
// IArchTaskBar overrides
|
||||
virtual void addReceiver(IArchTaskBarReceiver*);
|
||||
|
|
|
@ -30,21 +30,21 @@
|
|||
#endif
|
||||
|
||||
//
|
||||
// CArchTimeUnix
|
||||
// ArchTimeUnix
|
||||
//
|
||||
|
||||
CArchTimeUnix::CArchTimeUnix()
|
||||
ArchTimeUnix::ArchTimeUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchTimeUnix::~CArchTimeUnix()
|
||||
ArchTimeUnix::~ArchTimeUnix()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
double
|
||||
CArchTimeUnix::time()
|
||||
ArchTimeUnix::time()
|
||||
{
|
||||
struct timeval t;
|
||||
gettimeofday(&t, NULL);
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchTime.h"
|
||||
|
||||
#define ARCH_TIME CArchTimeUnix
|
||||
#define ARCH_TIME ArchTimeUnix
|
||||
|
||||
//! Generic Unix implementation of IArchTime
|
||||
class CArchTimeUnix : public IArchTime {
|
||||
class ArchTimeUnix : public IArchTime {
|
||||
public:
|
||||
CArchTimeUnix();
|
||||
virtual ~CArchTimeUnix();
|
||||
ArchTimeUnix();
|
||||
virtual ~ArchTimeUnix();
|
||||
|
||||
// IArchTime overrides
|
||||
virtual double time();
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
|
||||
#include "arch/win32/ArchConsoleWindows.h"
|
||||
|
||||
CArchConsoleWindows::CArchConsoleWindows() { }
|
||||
ArchConsoleWindows::ArchConsoleWindows() { }
|
||||
|
||||
CArchConsoleWindows::~CArchConsoleWindows() { }
|
||||
ArchConsoleWindows::~ArchConsoleWindows() { }
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "arch/ArchConsoleStd.h"
|
||||
|
||||
#define ARCH_CONSOLE CArchConsoleWindows
|
||||
#define ARCH_CONSOLE ArchConsoleWindows
|
||||
|
||||
class CArchConsoleWindows : public CArchConsoleStd {
|
||||
class ArchConsoleWindows : public ArchConsoleStd {
|
||||
public:
|
||||
CArchConsoleWindows();
|
||||
virtual ~CArchConsoleWindows();
|
||||
ArchConsoleWindows();
|
||||
virtual ~ArchConsoleWindows();
|
||||
};
|
||||
|
|
|
@ -25,31 +25,31 @@
|
|||
#include <sstream>
|
||||
|
||||
//
|
||||
// CArchDaemonWindows
|
||||
// ArchDaemonWindows
|
||||
//
|
||||
|
||||
CArchDaemonWindows* CArchDaemonWindows::s_daemon = NULL;
|
||||
ArchDaemonWindows* ArchDaemonWindows::s_daemon = NULL;
|
||||
|
||||
CArchDaemonWindows::CArchDaemonWindows() :
|
||||
ArchDaemonWindows::ArchDaemonWindows() :
|
||||
m_daemonThreadID(0)
|
||||
{
|
||||
m_quitMessage = RegisterWindowMessage("SynergyDaemonExit");
|
||||
}
|
||||
|
||||
CArchDaemonWindows::~CArchDaemonWindows()
|
||||
ArchDaemonWindows::~ArchDaemonWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
int
|
||||
CArchDaemonWindows::runDaemon(RunFunc runFunc)
|
||||
ArchDaemonWindows::runDaemon(RunFunc runFunc)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
return s_daemon->doRunDaemon(runFunc);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::daemonRunning(bool running)
|
||||
ArchDaemonWindows::daemonRunning(bool running)
|
||||
{
|
||||
if (s_daemon != NULL) {
|
||||
s_daemon->doDaemonRunning(running);
|
||||
|
@ -57,7 +57,7 @@ CArchDaemonWindows::daemonRunning(bool running)
|
|||
}
|
||||
|
||||
UINT
|
||||
CArchDaemonWindows::getDaemonQuitMessage()
|
||||
ArchDaemonWindows::getDaemonQuitMessage()
|
||||
{
|
||||
if (s_daemon != NULL) {
|
||||
return s_daemon->doGetDaemonQuitMessage();
|
||||
|
@ -68,14 +68,14 @@ CArchDaemonWindows::getDaemonQuitMessage()
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::daemonFailed(int result)
|
||||
ArchDaemonWindows::daemonFailed(int result)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
throw XArchDaemonRunFailed(result);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::installDaemon(const char* name,
|
||||
ArchDaemonWindows::installDaemon(const char* name,
|
||||
const char* description,
|
||||
const char* pathname,
|
||||
const char* commandLine,
|
||||
|
@ -122,7 +122,7 @@ CArchDaemonWindows::installDaemon(const char* name,
|
|||
|
||||
// open the registry key for this service
|
||||
HKEY key = openNTServicesKey();
|
||||
key = CArchMiscWindows::addKey(key, name);
|
||||
key = ArchMiscWindows::addKey(key, name);
|
||||
if (key == NULL) {
|
||||
// can't open key
|
||||
DWORD err = GetLastError();
|
||||
|
@ -136,14 +136,14 @@ CArchDaemonWindows::installDaemon(const char* name,
|
|||
}
|
||||
|
||||
// set the description
|
||||
CArchMiscWindows::setValue(key, _T("Description"), description);
|
||||
ArchMiscWindows::setValue(key, _T("Description"), description);
|
||||
|
||||
// set command line
|
||||
key = CArchMiscWindows::addKey(key, _T("Parameters"));
|
||||
key = ArchMiscWindows::addKey(key, _T("Parameters"));
|
||||
if (key == NULL) {
|
||||
// can't open key
|
||||
DWORD err = GetLastError();
|
||||
CArchMiscWindows::closeKey(key);
|
||||
ArchMiscWindows::closeKey(key);
|
||||
try {
|
||||
uninstallDaemon(name);
|
||||
}
|
||||
|
@ -152,21 +152,21 @@ CArchDaemonWindows::installDaemon(const char* name,
|
|||
}
|
||||
throw XArchDaemonInstallFailed(new XArchEvalWindows(err));
|
||||
}
|
||||
CArchMiscWindows::setValue(key, _T("CommandLine"), commandLine);
|
||||
ArchMiscWindows::setValue(key, _T("CommandLine"), commandLine);
|
||||
|
||||
// done with registry
|
||||
CArchMiscWindows::closeKey(key);
|
||||
ArchMiscWindows::closeKey(key);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::uninstallDaemon(const char* name)
|
||||
ArchDaemonWindows::uninstallDaemon(const char* name)
|
||||
{
|
||||
// remove parameters for this service. ignore failures.
|
||||
HKEY key = openNTServicesKey();
|
||||
key = CArchMiscWindows::openKey(key, name);
|
||||
key = ArchMiscWindows::openKey(key, name);
|
||||
if (key != NULL) {
|
||||
CArchMiscWindows::deleteKey(key, _T("Parameters"));
|
||||
CArchMiscWindows::closeKey(key);
|
||||
ArchMiscWindows::deleteKey(key, _T("Parameters"));
|
||||
ArchMiscWindows::closeKey(key);
|
||||
}
|
||||
|
||||
// open service manager
|
||||
|
@ -223,7 +223,7 @@ CArchDaemonWindows::uninstallDaemon(const char* name)
|
|||
}
|
||||
|
||||
int
|
||||
CArchDaemonWindows::daemonize(const char* name, DaemonFunc func)
|
||||
ArchDaemonWindows::daemonize(const char* name, DaemonFunc func)
|
||||
{
|
||||
assert(name != NULL);
|
||||
assert(func != NULL);
|
||||
|
@ -234,7 +234,7 @@ CArchDaemonWindows::daemonize(const char* name, DaemonFunc func)
|
|||
// construct the service entry
|
||||
SERVICE_TABLE_ENTRY entry[2];
|
||||
entry[0].lpServiceName = const_cast<char*>(name);
|
||||
entry[0].lpServiceProc = &CArchDaemonWindows::serviceMainEntry;
|
||||
entry[0].lpServiceProc = &ArchDaemonWindows::serviceMainEntry;
|
||||
entry[1].lpServiceName = NULL;
|
||||
entry[1].lpServiceProc = NULL;
|
||||
|
||||
|
@ -252,7 +252,7 @@ CArchDaemonWindows::daemonize(const char* name, DaemonFunc func)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchDaemonWindows::canInstallDaemon(const char* /*name*/)
|
||||
ArchDaemonWindows::canInstallDaemon(const char* /*name*/)
|
||||
{
|
||||
// check if we can open service manager for write
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
|
||||
|
@ -263,13 +263,13 @@ CArchDaemonWindows::canInstallDaemon(const char* /*name*/)
|
|||
|
||||
// check if we can open the registry key
|
||||
HKEY key = openNTServicesKey();
|
||||
CArchMiscWindows::closeKey(key);
|
||||
ArchMiscWindows::closeKey(key);
|
||||
|
||||
return (key != NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
CArchDaemonWindows::isDaemonInstalled(const char* name)
|
||||
ArchDaemonWindows::isDaemonInstalled(const char* name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
|
@ -290,7 +290,7 @@ CArchDaemonWindows::isDaemonInstalled(const char* name)
|
|||
}
|
||||
|
||||
HKEY
|
||||
CArchDaemonWindows::openNTServicesKey()
|
||||
ArchDaemonWindows::openNTServicesKey()
|
||||
{
|
||||
static const char* s_keyNames[] = {
|
||||
_T("SYSTEM"),
|
||||
|
@ -299,11 +299,11 @@ CArchDaemonWindows::openNTServicesKey()
|
|||
NULL
|
||||
};
|
||||
|
||||
return CArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames);
|
||||
return ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames);
|
||||
}
|
||||
|
||||
bool
|
||||
CArchDaemonWindows::isRunState(DWORD state)
|
||||
ArchDaemonWindows::isRunState(DWORD state)
|
||||
{
|
||||
switch (state) {
|
||||
case SERVICE_START_PENDING:
|
||||
|
@ -317,7 +317,7 @@ CArchDaemonWindows::isRunState(DWORD state)
|
|||
}
|
||||
|
||||
int
|
||||
CArchDaemonWindows::doRunDaemon(RunFunc run)
|
||||
ArchDaemonWindows::doRunDaemon(RunFunc run)
|
||||
{
|
||||
// should only be called from DaemonFunc
|
||||
assert(m_serviceMutex != NULL);
|
||||
|
@ -370,7 +370,7 @@ CArchDaemonWindows::doRunDaemon(RunFunc run)
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::doDaemonRunning(bool running)
|
||||
ArchDaemonWindows::doDaemonRunning(bool running)
|
||||
{
|
||||
ARCH->lockMutex(m_serviceMutex);
|
||||
if (running) {
|
||||
|
@ -382,19 +382,19 @@ CArchDaemonWindows::doDaemonRunning(bool running)
|
|||
}
|
||||
|
||||
UINT
|
||||
CArchDaemonWindows::doGetDaemonQuitMessage()
|
||||
ArchDaemonWindows::doGetDaemonQuitMessage()
|
||||
{
|
||||
return m_quitMessage;
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::setStatus(DWORD state)
|
||||
ArchDaemonWindows::setStatus(DWORD state)
|
||||
{
|
||||
setStatus(state, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::setStatus(DWORD state, DWORD step, DWORD waitHint)
|
||||
ArchDaemonWindows::setStatus(DWORD state, DWORD step, DWORD waitHint)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
|
||||
|
@ -413,7 +413,7 @@ CArchDaemonWindows::setStatus(DWORD state, DWORD step, DWORD waitHint)
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::setStatusError(DWORD error)
|
||||
ArchDaemonWindows::setStatusError(DWORD error)
|
||||
{
|
||||
assert(s_daemon != NULL);
|
||||
|
||||
|
@ -432,7 +432,7 @@ CArchDaemonWindows::setStatusError(DWORD error)
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
|
||||
ArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
|
||||
{
|
||||
typedef std::vector<LPCTSTR> ArgList;
|
||||
typedef std::vector<std::string> Arguments;
|
||||
|
@ -444,7 +444,7 @@ CArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
|
|||
|
||||
// register our service handler function
|
||||
m_statusHandle = RegisterServiceCtrlHandler(argv[0],
|
||||
&CArchDaemonWindows::serviceHandlerEntry);
|
||||
&ArchDaemonWindows::serviceHandlerEntry);
|
||||
if (m_statusHandle == 0) {
|
||||
// cannot start as service
|
||||
m_daemonResult = -1;
|
||||
|
@ -466,10 +466,10 @@ CArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
|
|||
if (argc <= 1) {
|
||||
// read command line
|
||||
HKEY key = openNTServicesKey();
|
||||
key = CArchMiscWindows::openKey(key, argvIn[0]);
|
||||
key = CArchMiscWindows::openKey(key, _T("Parameters"));
|
||||
key = ArchMiscWindows::openKey(key, argvIn[0]);
|
||||
key = ArchMiscWindows::openKey(key, _T("Parameters"));
|
||||
if (key != NULL) {
|
||||
commandLine = CArchMiscWindows::readValueString(key,
|
||||
commandLine = ArchMiscWindows::readValueString(key,
|
||||
_T("CommandLine"));
|
||||
}
|
||||
|
||||
|
@ -553,13 +553,13 @@ CArchDaemonWindows::serviceMain(DWORD argc, LPTSTR* argvIn)
|
|||
}
|
||||
|
||||
void WINAPI
|
||||
CArchDaemonWindows::serviceMainEntry(DWORD argc, LPTSTR* argv)
|
||||
ArchDaemonWindows::serviceMainEntry(DWORD argc, LPTSTR* argv)
|
||||
{
|
||||
s_daemon->serviceMain(argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::serviceHandler(DWORD ctrl)
|
||||
ArchDaemonWindows::serviceHandler(DWORD ctrl)
|
||||
{
|
||||
assert(m_serviceMutex != NULL);
|
||||
assert(m_serviceCondVar != NULL);
|
||||
|
@ -616,13 +616,13 @@ CArchDaemonWindows::serviceHandler(DWORD ctrl)
|
|||
}
|
||||
|
||||
void WINAPI
|
||||
CArchDaemonWindows::serviceHandlerEntry(DWORD ctrl)
|
||||
ArchDaemonWindows::serviceHandlerEntry(DWORD ctrl)
|
||||
{
|
||||
s_daemon->serviceHandler(ctrl);
|
||||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::start(const char* name)
|
||||
ArchDaemonWindows::start(const char* name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
|
@ -646,7 +646,7 @@ CArchDaemonWindows::start(const char* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::stop(const char* name)
|
||||
ArchDaemonWindows::stop(const char* name)
|
||||
{
|
||||
// open service manager
|
||||
SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_READ);
|
||||
|
@ -675,12 +675,12 @@ CArchDaemonWindows::stop(const char* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::installDaemon()
|
||||
ArchDaemonWindows::installDaemon()
|
||||
{
|
||||
// install default daemon if not already installed.
|
||||
if (!isDaemonInstalled(DEFAULT_DAEMON_NAME)) {
|
||||
char path[MAX_PATH];
|
||||
GetModuleFileName(CArchMiscWindows::instanceWin32(), path, MAX_PATH);
|
||||
GetModuleFileName(ArchMiscWindows::instanceWin32(), path, MAX_PATH);
|
||||
|
||||
// wrap in quotes so a malicious user can't start \Program.exe as admin.
|
||||
std::stringstream ss;
|
||||
|
@ -695,7 +695,7 @@ CArchDaemonWindows::installDaemon()
|
|||
}
|
||||
|
||||
void
|
||||
CArchDaemonWindows::uninstallDaemon()
|
||||
ArchDaemonWindows::uninstallDaemon()
|
||||
{
|
||||
// remove legacy services if installed.
|
||||
if (isDaemonInstalled(LEGACY_SERVER_DAEMON_NAME)) {
|
||||
|
|
|
@ -26,15 +26,15 @@
|
|||
#include <Windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define ARCH_DAEMON CArchDaemonWindows
|
||||
#define ARCH_DAEMON ArchDaemonWindows
|
||||
|
||||
//! Win32 implementation of IArchDaemon
|
||||
class CArchDaemonWindows : public IArchDaemon {
|
||||
class ArchDaemonWindows : public IArchDaemon {
|
||||
public:
|
||||
typedef int (*RunFunc)(void);
|
||||
|
||||
CArchDaemonWindows();
|
||||
virtual ~CArchDaemonWindows();
|
||||
ArchDaemonWindows();
|
||||
virtual ~ArchDaemonWindows();
|
||||
|
||||
//! Run the daemon
|
||||
/*!
|
||||
|
@ -120,10 +120,10 @@ private:
|
|||
};
|
||||
|
||||
private:
|
||||
static CArchDaemonWindows* s_daemon;
|
||||
static ArchDaemonWindows* s_daemon;
|
||||
|
||||
CArchMutex m_serviceMutex;
|
||||
CArchCond m_serviceCondVar;
|
||||
ArchMutex m_serviceMutex;
|
||||
ArchCond m_serviceCondVar;
|
||||
DWORD m_serviceState;
|
||||
bool m_serviceHandlerWaiting;
|
||||
bool m_serviceRunning;
|
||||
|
|
|
@ -25,21 +25,21 @@
|
|||
#include <string.h>
|
||||
|
||||
//
|
||||
// CArchFileWindows
|
||||
// ArchFileWindows
|
||||
//
|
||||
|
||||
CArchFileWindows::CArchFileWindows()
|
||||
ArchFileWindows::ArchFileWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchFileWindows::~CArchFileWindows()
|
||||
ArchFileWindows::~ArchFileWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const char*
|
||||
CArchFileWindows::getBasename(const char* pathname)
|
||||
ArchFileWindows::getBasename(const char* pathname)
|
||||
{
|
||||
if (pathname == NULL) {
|
||||
return NULL;
|
||||
|
@ -64,7 +64,7 @@ CArchFileWindows::getBasename(const char* pathname)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileWindows::getUserDirectory()
|
||||
ArchFileWindows::getUserDirectory()
|
||||
{
|
||||
// try %HOMEPATH%
|
||||
TCHAR dir[MAX_PATH];
|
||||
|
@ -108,7 +108,7 @@ CArchFileWindows::getUserDirectory()
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileWindows::getSystemDirectory()
|
||||
ArchFileWindows::getSystemDirectory()
|
||||
{
|
||||
// get windows directory
|
||||
char dir[MAX_PATH];
|
||||
|
@ -122,7 +122,7 @@ CArchFileWindows::getSystemDirectory()
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileWindows::getInstalledDirectory()
|
||||
ArchFileWindows::getInstalledDirectory()
|
||||
{
|
||||
char fileNameBuffer[MAX_PATH];
|
||||
GetModuleFileName(NULL, fileNameBuffer, MAX_PATH);
|
||||
|
@ -134,13 +134,13 @@ CArchFileWindows::getInstalledDirectory()
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchFileWindows::getLogDirectory()
|
||||
ArchFileWindows::getLogDirectory()
|
||||
{
|
||||
return getInstalledDirectory();
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchFileWindows::concatPath(const std::string& prefix,
|
||||
ArchFileWindows::concatPath(const std::string& prefix,
|
||||
const std::string& suffix)
|
||||
{
|
||||
std::string path;
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchFile.h"
|
||||
|
||||
#define ARCH_FILE CArchFileWindows
|
||||
#define ARCH_FILE ArchFileWindows
|
||||
|
||||
//! Win32 implementation of IArchFile
|
||||
class CArchFileWindows : public IArchFile {
|
||||
class ArchFileWindows : public IArchFile {
|
||||
public:
|
||||
CArchFileWindows();
|
||||
virtual ~CArchFileWindows();
|
||||
ArchFileWindows();
|
||||
virtual ~ArchFileWindows();
|
||||
|
||||
// IArchFile overrides
|
||||
virtual const char* getBasename(const char* pathname);
|
||||
|
|
|
@ -24,20 +24,20 @@
|
|||
#include <Wininet.h>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
struct CWinINetUrl {
|
||||
CString m_scheme;
|
||||
CString m_host;
|
||||
CString m_path;
|
||||
struct WinINetUrl {
|
||||
String m_scheme;
|
||||
String m_host;
|
||||
String m_path;
|
||||
INTERNET_PORT m_port;
|
||||
DWORD m_flags;
|
||||
};
|
||||
|
||||
class CWinINetRequest {
|
||||
class WinINetRequest {
|
||||
public:
|
||||
CWinINetRequest(const CString& url);
|
||||
~CWinINetRequest();
|
||||
WinINetRequest(const String& url);
|
||||
~WinINetRequest();
|
||||
|
||||
CString send();
|
||||
String send();
|
||||
void openSession();
|
||||
void connect();
|
||||
void openRequest();
|
||||
|
@ -46,23 +46,23 @@ private:
|
|||
HINTERNET m_session;
|
||||
HINTERNET m_connect;
|
||||
HINTERNET m_request;
|
||||
CWinINetUrl m_url;
|
||||
WinINetUrl m_url;
|
||||
bool m_used;
|
||||
};
|
||||
|
||||
//
|
||||
// CArchInternetWindows
|
||||
// ArchInternetWindows
|
||||
//
|
||||
|
||||
CString
|
||||
CArchInternetWindows::get(const CString& url)
|
||||
String
|
||||
ArchInternetWindows::get(const String& url)
|
||||
{
|
||||
CWinINetRequest request(url);
|
||||
WinINetRequest request(url);
|
||||
return request.send();
|
||||
}
|
||||
|
||||
CString
|
||||
CArchInternetWindows::urlEncode(const CString& url)
|
||||
String
|
||||
ArchInternetWindows::urlEncode(const String& url)
|
||||
{
|
||||
TCHAR buffer[1024];
|
||||
DWORD bufferSize = sizeof(buffer);
|
||||
|
@ -71,7 +71,7 @@ CArchInternetWindows::urlEncode(const CString& url)
|
|||
throw XArch(new XArchEvalWindows());
|
||||
}
|
||||
|
||||
CString result(buffer);
|
||||
String result(buffer);
|
||||
|
||||
// the win32 url encoding funcitons are pretty useless (to us) and only
|
||||
// escape "unsafe" chars, but not + or =, so we need to replace these
|
||||
|
@ -83,12 +83,12 @@ CArchInternetWindows::urlEncode(const CString& url)
|
|||
}
|
||||
|
||||
//
|
||||
// CWinINetRequest
|
||||
// WinINetRequest
|
||||
//
|
||||
|
||||
static CWinINetUrl parseUrl(const CString& url);
|
||||
static WinINetUrl parseUrl(const String& url);
|
||||
|
||||
CWinINetRequest::CWinINetRequest(const CString& url) :
|
||||
WinINetRequest::WinINetRequest(const String& url) :
|
||||
m_session(NULL),
|
||||
m_connect(NULL),
|
||||
m_request(NULL),
|
||||
|
@ -97,7 +97,7 @@ CWinINetRequest::CWinINetRequest(const CString& url) :
|
|||
{
|
||||
}
|
||||
|
||||
CWinINetRequest::~CWinINetRequest()
|
||||
WinINetRequest::~WinINetRequest()
|
||||
{
|
||||
if (m_request != NULL) {
|
||||
InternetCloseHandle(m_request);
|
||||
|
@ -112,8 +112,8 @@ CWinINetRequest::~CWinINetRequest()
|
|||
}
|
||||
}
|
||||
|
||||
CString
|
||||
CWinINetRequest::send()
|
||||
String
|
||||
WinINetRequest::send()
|
||||
{
|
||||
if (m_used) {
|
||||
throw XArch("class is one time use.");
|
||||
|
@ -124,7 +124,7 @@ CWinINetRequest::send()
|
|||
connect();
|
||||
openRequest();
|
||||
|
||||
CString headers("Content-Type: text/html");
|
||||
String headers("Content-Type: text/html");
|
||||
if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) {
|
||||
throw XArch(new XArchEvalWindows());
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ CWinINetRequest::send()
|
|||
}
|
||||
|
||||
void
|
||||
CWinINetRequest::openSession()
|
||||
WinINetRequest::openSession()
|
||||
{
|
||||
std::stringstream userAgent;
|
||||
userAgent << "Synergy ";
|
||||
|
@ -162,7 +162,7 @@ CWinINetRequest::openSession()
|
|||
}
|
||||
|
||||
void
|
||||
CWinINetRequest::connect()
|
||||
WinINetRequest::connect()
|
||||
{
|
||||
m_connect = InternetConnect(
|
||||
m_session,
|
||||
|
@ -180,7 +180,7 @@ CWinINetRequest::connect()
|
|||
}
|
||||
|
||||
void
|
||||
CWinINetRequest::openRequest()
|
||||
WinINetRequest::openRequest()
|
||||
{
|
||||
m_request = HttpOpenRequest(
|
||||
m_connect,
|
||||
|
@ -200,10 +200,10 @@ CWinINetRequest::openRequest()
|
|||
// nb: i tried to use InternetCrackUrl here, but couldn't quite get that to
|
||||
// work. here's some (less robust) code to split the url into components.
|
||||
// this works fine with simple urls, but doesn't consider the full url spec.
|
||||
static CWinINetUrl
|
||||
parseUrl(const CString& url)
|
||||
static WinINetUrl
|
||||
parseUrl(const String& url)
|
||||
{
|
||||
CWinINetUrl parsed;
|
||||
WinINetUrl parsed;
|
||||
|
||||
size_t schemeEnd = url.find("://");
|
||||
size_t hostEnd = url.find('/', schemeEnd + 3);
|
||||
|
@ -215,7 +215,7 @@ parseUrl(const CString& url)
|
|||
parsed.m_port = INTERNET_DEFAULT_HTTP_PORT;
|
||||
parsed.m_flags = 0;
|
||||
|
||||
if (parsed.m_scheme.find("https") != CString::npos) {
|
||||
if (parsed.m_scheme.find("https") != String::npos) {
|
||||
parsed.m_port = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
parsed.m_flags = INTERNET_FLAG_SECURE;
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#define ARCH_INTERNET CArchInternetWindows
|
||||
#define ARCH_INTERNET ArchInternetWindows
|
||||
|
||||
#include "base/String.h"
|
||||
|
||||
class CArchInternetWindows {
|
||||
class ArchInternetWindows {
|
||||
public:
|
||||
CString get(const CString& url);
|
||||
CString urlEncode(const CString& url);
|
||||
String get(const String& url);
|
||||
String urlEncode(const String& url);
|
||||
};
|
||||
|
|
|
@ -22,21 +22,21 @@
|
|||
#include <string.h>
|
||||
|
||||
//
|
||||
// CArchLogWindows
|
||||
// ArchLogWindows
|
||||
//
|
||||
|
||||
CArchLogWindows::CArchLogWindows() : m_eventLog(NULL)
|
||||
ArchLogWindows::ArchLogWindows() : m_eventLog(NULL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchLogWindows::~CArchLogWindows()
|
||||
ArchLogWindows::~ArchLogWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogWindows::openLog(const char* name)
|
||||
ArchLogWindows::openLog(const char* name)
|
||||
{
|
||||
if (m_eventLog == NULL) {
|
||||
m_eventLog = RegisterEventSource(NULL, name);
|
||||
|
@ -44,7 +44,7 @@ CArchLogWindows::openLog(const char* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchLogWindows::closeLog()
|
||||
ArchLogWindows::closeLog()
|
||||
{
|
||||
if (m_eventLog != NULL) {
|
||||
DeregisterEventSource(m_eventLog);
|
||||
|
@ -53,13 +53,13 @@ CArchLogWindows::closeLog()
|
|||
}
|
||||
|
||||
void
|
||||
CArchLogWindows::showLog(bool)
|
||||
ArchLogWindows::showLog(bool)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchLogWindows::writeLog(ELevel level, const char* msg)
|
||||
ArchLogWindows::writeLog(ELevel level, const char* msg)
|
||||
{
|
||||
if (m_eventLog != NULL) {
|
||||
// convert priority
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#define ARCH_LOG CArchLogWindows
|
||||
#define ARCH_LOG ArchLogWindows
|
||||
|
||||
//! Win32 implementation of IArchLog
|
||||
class CArchLogWindows : public IArchLog {
|
||||
class ArchLogWindows : public IArchLog {
|
||||
public:
|
||||
CArchLogWindows();
|
||||
virtual ~CArchLogWindows();
|
||||
ArchLogWindows();
|
||||
virtual ~ArchLogWindows();
|
||||
|
||||
// IArchLog overrides
|
||||
virtual void openLog(const char* name);
|
||||
|
|
|
@ -41,92 +41,92 @@
|
|||
typedef DWORD EXECUTION_STATE;
|
||||
|
||||
//
|
||||
// CArchMiscWindows
|
||||
// ArchMiscWindows
|
||||
//
|
||||
|
||||
CArchMiscWindows::CDialogs* CArchMiscWindows::s_dialogs = NULL;
|
||||
DWORD CArchMiscWindows::s_busyState = 0;
|
||||
CArchMiscWindows::STES_t CArchMiscWindows::s_stes = NULL;
|
||||
HICON CArchMiscWindows::s_largeIcon = NULL;
|
||||
HICON CArchMiscWindows::s_smallIcon = NULL;
|
||||
HINSTANCE CArchMiscWindows::s_instanceWin32 = NULL;
|
||||
ArchMiscWindows::Dialogs* ArchMiscWindows::s_dialogs = NULL;
|
||||
DWORD ArchMiscWindows::s_busyState = 0;
|
||||
ArchMiscWindows::STES_t ArchMiscWindows::s_stes = NULL;
|
||||
HICON ArchMiscWindows::s_largeIcon = NULL;
|
||||
HICON ArchMiscWindows::s_smallIcon = NULL;
|
||||
HINSTANCE ArchMiscWindows::s_instanceWin32 = NULL;
|
||||
|
||||
void
|
||||
CArchMiscWindows::cleanup()
|
||||
ArchMiscWindows::cleanup()
|
||||
{
|
||||
delete s_dialogs;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::init()
|
||||
ArchMiscWindows::init()
|
||||
{
|
||||
s_dialogs = new CDialogs;
|
||||
s_dialogs = new Dialogs;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setIcons(HICON largeIcon, HICON smallIcon)
|
||||
ArchMiscWindows::setIcons(HICON largeIcon, HICON smallIcon)
|
||||
{
|
||||
s_largeIcon = largeIcon;
|
||||
s_smallIcon = smallIcon;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::getIcons(HICON& largeIcon, HICON& smallIcon)
|
||||
ArchMiscWindows::getIcons(HICON& largeIcon, HICON& smallIcon)
|
||||
{
|
||||
largeIcon = s_largeIcon;
|
||||
smallIcon = s_smallIcon;
|
||||
}
|
||||
|
||||
int
|
||||
CArchMiscWindows::runDaemon(RunFunc runFunc)
|
||||
ArchMiscWindows::runDaemon(RunFunc runFunc)
|
||||
{
|
||||
return CArchDaemonWindows::runDaemon(runFunc);
|
||||
return ArchDaemonWindows::runDaemon(runFunc);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::daemonRunning(bool running)
|
||||
ArchMiscWindows::daemonRunning(bool running)
|
||||
{
|
||||
CArchDaemonWindows::daemonRunning(running);
|
||||
ArchDaemonWindows::daemonRunning(running);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::daemonFailed(int result)
|
||||
ArchMiscWindows::daemonFailed(int result)
|
||||
{
|
||||
CArchDaemonWindows::daemonFailed(result);
|
||||
ArchDaemonWindows::daemonFailed(result);
|
||||
}
|
||||
|
||||
UINT
|
||||
CArchMiscWindows::getDaemonQuitMessage()
|
||||
ArchMiscWindows::getDaemonQuitMessage()
|
||||
{
|
||||
return CArchDaemonWindows::getDaemonQuitMessage();
|
||||
return ArchDaemonWindows::getDaemonQuitMessage();
|
||||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::openKey(HKEY key, const TCHAR* keyName)
|
||||
ArchMiscWindows::openKey(HKEY key, const TCHAR* keyName)
|
||||
{
|
||||
return openKey(key, keyName, false);
|
||||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::openKey(HKEY key, const TCHAR* const* keyNames)
|
||||
ArchMiscWindows::openKey(HKEY key, const TCHAR* const* keyNames)
|
||||
{
|
||||
return openKey(key, keyNames, false);
|
||||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::addKey(HKEY key, const TCHAR* keyName)
|
||||
ArchMiscWindows::addKey(HKEY key, const TCHAR* keyName)
|
||||
{
|
||||
return openKey(key, keyName, true);
|
||||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::addKey(HKEY key, const TCHAR* const* keyNames)
|
||||
ArchMiscWindows::addKey(HKEY key, const TCHAR* const* keyNames)
|
||||
{
|
||||
return openKey(key, keyNames, true);
|
||||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::openKey(HKEY key, const TCHAR* keyName, bool create)
|
||||
ArchMiscWindows::openKey(HKEY key, const TCHAR* keyName, bool create)
|
||||
{
|
||||
// ignore if parent is NULL
|
||||
if (key == NULL) {
|
||||
|
@ -154,7 +154,7 @@ CArchMiscWindows::openKey(HKEY key, const TCHAR* keyName, bool create)
|
|||
}
|
||||
|
||||
HKEY
|
||||
CArchMiscWindows::openKey(HKEY key, const TCHAR* const* keyNames, bool create)
|
||||
ArchMiscWindows::openKey(HKEY key, const TCHAR* const* keyNames, bool create)
|
||||
{
|
||||
for (size_t i = 0; key != NULL && keyNames[i] != NULL; ++i) {
|
||||
// open next key
|
||||
|
@ -164,7 +164,7 @@ CArchMiscWindows::openKey(HKEY key, const TCHAR* const* keyNames, bool create)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::closeKey(HKEY key)
|
||||
ArchMiscWindows::closeKey(HKEY key)
|
||||
{
|
||||
assert(key != NULL);
|
||||
if (key==NULL) return;
|
||||
|
@ -172,7 +172,7 @@ CArchMiscWindows::closeKey(HKEY key)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::deleteKey(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::deleteKey(HKEY key, const TCHAR* name)
|
||||
{
|
||||
assert(key != NULL);
|
||||
assert(name != NULL);
|
||||
|
@ -181,7 +181,7 @@ CArchMiscWindows::deleteKey(HKEY key, const TCHAR* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::deleteValue(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::deleteValue(HKEY key, const TCHAR* name)
|
||||
{
|
||||
assert(key != NULL);
|
||||
assert(name != NULL);
|
||||
|
@ -190,7 +190,7 @@ CArchMiscWindows::deleteValue(HKEY key, const TCHAR* name)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMiscWindows::hasValue(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::hasValue(HKEY key, const TCHAR* name)
|
||||
{
|
||||
DWORD type;
|
||||
LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL);
|
||||
|
@ -198,8 +198,8 @@ CArchMiscWindows::hasValue(HKEY key, const TCHAR* name)
|
|||
(type == REG_DWORD || type == REG_SZ));
|
||||
}
|
||||
|
||||
CArchMiscWindows::EValueType
|
||||
CArchMiscWindows::typeOfValue(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::EValueType
|
||||
ArchMiscWindows::typeOfValue(HKEY key, const TCHAR* name)
|
||||
{
|
||||
DWORD type;
|
||||
LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL);
|
||||
|
@ -222,7 +222,7 @@ CArchMiscWindows::typeOfValue(HKEY key, const TCHAR* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setValue(HKEY key,
|
||||
ArchMiscWindows::setValue(HKEY key,
|
||||
const TCHAR* name, const std::string& value)
|
||||
{
|
||||
assert(key != NULL);
|
||||
|
@ -233,7 +233,7 @@ CArchMiscWindows::setValue(HKEY key,
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setValue(HKEY key, const TCHAR* name, DWORD value)
|
||||
ArchMiscWindows::setValue(HKEY key, const TCHAR* name, DWORD value)
|
||||
{
|
||||
assert(key != NULL);
|
||||
if(key ==NULL) return; // TODO: throw exception
|
||||
|
@ -243,7 +243,7 @@ CArchMiscWindows::setValue(HKEY key, const TCHAR* name, DWORD value)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setValueBinary(HKEY key,
|
||||
ArchMiscWindows::setValueBinary(HKEY key,
|
||||
const TCHAR* name, const std::string& value)
|
||||
{
|
||||
assert(key != NULL);
|
||||
|
@ -255,7 +255,7 @@ CArchMiscWindows::setValueBinary(HKEY key,
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
|
||||
ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
|
||||
{
|
||||
// get the size of the string
|
||||
DWORD actualType;
|
||||
|
@ -292,19 +292,19 @@ CArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR* name, DWORD type)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchMiscWindows::readValueString(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::readValueString(HKEY key, const TCHAR* name)
|
||||
{
|
||||
return readBinaryOrString(key, name, REG_SZ);
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchMiscWindows::readValueBinary(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::readValueBinary(HKEY key, const TCHAR* name)
|
||||
{
|
||||
return readBinaryOrString(key, name, REG_BINARY);
|
||||
}
|
||||
|
||||
DWORD
|
||||
CArchMiscWindows::readValueInt(HKEY key, const TCHAR* name)
|
||||
ArchMiscWindows::readValueInt(HKEY key, const TCHAR* name)
|
||||
{
|
||||
DWORD type;
|
||||
DWORD value;
|
||||
|
@ -318,21 +318,21 @@ CArchMiscWindows::readValueInt(HKEY key, const TCHAR* name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::addDialog(HWND hwnd)
|
||||
ArchMiscWindows::addDialog(HWND hwnd)
|
||||
{
|
||||
s_dialogs->insert(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::removeDialog(HWND hwnd)
|
||||
ArchMiscWindows::removeDialog(HWND hwnd)
|
||||
{
|
||||
s_dialogs->erase(hwnd);
|
||||
}
|
||||
|
||||
bool
|
||||
CArchMiscWindows::processDialog(MSG* msg)
|
||||
ArchMiscWindows::processDialog(MSG* msg)
|
||||
{
|
||||
for (CDialogs::const_iterator index = s_dialogs->begin();
|
||||
for (Dialogs::const_iterator index = s_dialogs->begin();
|
||||
index != s_dialogs->end(); ++index) {
|
||||
if (IsDialogMessage(*index, msg)) {
|
||||
return true;
|
||||
|
@ -342,21 +342,21 @@ CArchMiscWindows::processDialog(MSG* msg)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::addBusyState(DWORD busyModes)
|
||||
ArchMiscWindows::addBusyState(DWORD busyModes)
|
||||
{
|
||||
s_busyState |= busyModes;
|
||||
setThreadExecutionState(s_busyState);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::removeBusyState(DWORD busyModes)
|
||||
ArchMiscWindows::removeBusyState(DWORD busyModes)
|
||||
{
|
||||
s_busyState &= ~busyModes;
|
||||
setThreadExecutionState(s_busyState);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setThreadExecutionState(DWORD busyModes)
|
||||
ArchMiscWindows::setThreadExecutionState(DWORD busyModes)
|
||||
{
|
||||
// look up function dynamically so we work on older systems
|
||||
if (s_stes == NULL) {
|
||||
|
@ -366,7 +366,7 @@ CArchMiscWindows::setThreadExecutionState(DWORD busyModes)
|
|||
"SetThreadExecutionState"));
|
||||
}
|
||||
if (s_stes == NULL) {
|
||||
s_stes = &CArchMiscWindows::dummySetThreadExecutionState;
|
||||
s_stes = &ArchMiscWindows::dummySetThreadExecutionState;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,14 +387,14 @@ CArchMiscWindows::setThreadExecutionState(DWORD busyModes)
|
|||
}
|
||||
|
||||
DWORD
|
||||
CArchMiscWindows::dummySetThreadExecutionState(DWORD)
|
||||
ArchMiscWindows::dummySetThreadExecutionState(DWORD)
|
||||
{
|
||||
// do nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::wakeupDisplay()
|
||||
ArchMiscWindows::wakeupDisplay()
|
||||
{
|
||||
// We can't use ::setThreadExecutionState here because it sets
|
||||
// ES_CONTINUOUS, which we don't want.
|
||||
|
@ -406,7 +406,7 @@ CArchMiscWindows::wakeupDisplay()
|
|||
"SetThreadExecutionState"));
|
||||
}
|
||||
if (s_stes == NULL) {
|
||||
s_stes = &CArchMiscWindows::dummySetThreadExecutionState;
|
||||
s_stes = &ArchMiscWindows::dummySetThreadExecutionState;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,9 +417,9 @@ CArchMiscWindows::wakeupDisplay()
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMiscWindows::wasLaunchedAsService()
|
||||
ArchMiscWindows::wasLaunchedAsService()
|
||||
{
|
||||
CString name;
|
||||
String name;
|
||||
if (!getParentProcessName(name)) {
|
||||
LOG((CLOG_ERR "cannot determine if process was launched as service"));
|
||||
return false;
|
||||
|
@ -429,7 +429,7 @@ CArchMiscWindows::wasLaunchedAsService()
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMiscWindows::getParentProcessName(CString &name)
|
||||
ArchMiscWindows::getParentProcessName(String &name)
|
||||
{
|
||||
PROCESSENTRY32 parentEntry;
|
||||
if (!getParentProcessEntry(parentEntry)){
|
||||
|
@ -442,14 +442,14 @@ CArchMiscWindows::getParentProcessName(CString &name)
|
|||
}
|
||||
|
||||
BOOL WINAPI
|
||||
CArchMiscWindows::getSelfProcessEntry(PROCESSENTRY32& entry)
|
||||
ArchMiscWindows::getSelfProcessEntry(PROCESSENTRY32& entry)
|
||||
{
|
||||
// get entry from current PID
|
||||
return getProcessEntry(entry, GetCurrentProcessId());
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
CArchMiscWindows::getParentProcessEntry(PROCESSENTRY32& entry)
|
||||
ArchMiscWindows::getParentProcessEntry(PROCESSENTRY32& entry)
|
||||
{
|
||||
// get the current process, so we can get parent PID
|
||||
PROCESSENTRY32 selfEntry;
|
||||
|
@ -462,7 +462,7 @@ CArchMiscWindows::getParentProcessEntry(PROCESSENTRY32& entry)
|
|||
}
|
||||
|
||||
BOOL WINAPI
|
||||
CArchMiscWindows::getProcessEntry(PROCESSENTRY32& entry, DWORD processID)
|
||||
ArchMiscWindows::getProcessEntry(PROCESSENTRY32& entry, DWORD processID)
|
||||
{
|
||||
// first we need to take a snapshot of the running processes
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
|
@ -498,14 +498,14 @@ CArchMiscWindows::getProcessEntry(PROCESSENTRY32& entry, DWORD processID)
|
|||
}
|
||||
|
||||
HINSTANCE
|
||||
CArchMiscWindows::instanceWin32()
|
||||
ArchMiscWindows::instanceWin32()
|
||||
{
|
||||
assert(s_instanceWin32 != NULL);
|
||||
return s_instanceWin32;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMiscWindows::setInstanceWin32(HINSTANCE instance)
|
||||
ArchMiscWindows::setInstanceWin32(HINSTANCE instance)
|
||||
{
|
||||
assert(instance != NULL);
|
||||
s_instanceWin32 = instance;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <Tlhelp32.h>
|
||||
|
||||
//! Miscellaneous win32 functions.
|
||||
class CArchMiscWindows {
|
||||
class ArchMiscWindows {
|
||||
public:
|
||||
enum EValueType {
|
||||
kUNKNOWN,
|
||||
|
@ -65,25 +65,25 @@ public:
|
|||
|
||||
//! Run the daemon
|
||||
/*!
|
||||
Delegates to CArchDaemonWindows.
|
||||
Delegates to ArchDaemonWindows.
|
||||
*/
|
||||
static int runDaemon(RunFunc runFunc);
|
||||
|
||||
//! Indicate daemon is in main loop
|
||||
/*!
|
||||
Delegates to CArchDaemonWindows.
|
||||
Delegates to ArchDaemonWindows.
|
||||
*/
|
||||
static void daemonRunning(bool running);
|
||||
|
||||
//! Indicate failure of running daemon
|
||||
/*!
|
||||
Delegates to CArchDaemonWindows.
|
||||
Delegates to ArchDaemonWindows.
|
||||
*/
|
||||
static void daemonFailed(int result);
|
||||
|
||||
//! Get daemon quit message
|
||||
/*!
|
||||
Delegates to CArchDaemonWindows.
|
||||
Delegates to ArchDaemonWindows.
|
||||
*/
|
||||
static UINT getDaemonQuitMessage();
|
||||
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
static bool wasLaunchedAsService();
|
||||
|
||||
//! Returns true if we got the parent process name.
|
||||
static bool getParentProcessName(CString &name);
|
||||
static bool getParentProcessName(String &name);
|
||||
|
||||
static HINSTANCE instanceWin32();
|
||||
|
||||
|
@ -190,10 +190,10 @@ private:
|
|||
static DWORD WINAPI dummySetThreadExecutionState(DWORD);
|
||||
|
||||
private:
|
||||
typedef std::set<HWND> CDialogs;
|
||||
typedef std::set<HWND> Dialogs;
|
||||
typedef DWORD (WINAPI *STES_t)(DWORD);
|
||||
|
||||
static CDialogs* s_dialogs;
|
||||
static Dialogs* s_dialogs;
|
||||
static DWORD s_busyState;
|
||||
static STES_t s_stes;
|
||||
static HICON s_largeIcon;
|
||||
|
|
|
@ -37,13 +37,13 @@
|
|||
//
|
||||
|
||||
//
|
||||
// CArchThreadImpl
|
||||
// ArchThreadImpl
|
||||
//
|
||||
|
||||
class CArchThreadImpl {
|
||||
class ArchThreadImpl {
|
||||
public:
|
||||
CArchThreadImpl();
|
||||
~CArchThreadImpl();
|
||||
ArchThreadImpl();
|
||||
~ArchThreadImpl();
|
||||
|
||||
public:
|
||||
int m_refCount;
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
void* m_networkData;
|
||||
};
|
||||
|
||||
CArchThreadImpl::CArchThreadImpl() :
|
||||
ArchThreadImpl::ArchThreadImpl() :
|
||||
m_refCount(1),
|
||||
m_thread(NULL),
|
||||
m_id(0),
|
||||
|
@ -72,7 +72,7 @@ CArchThreadImpl::CArchThreadImpl() :
|
|||
m_cancel = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
}
|
||||
|
||||
CArchThreadImpl::~CArchThreadImpl()
|
||||
ArchThreadImpl::~ArchThreadImpl()
|
||||
{
|
||||
CloseHandle(m_exit);
|
||||
CloseHandle(m_cancel);
|
||||
|
@ -80,12 +80,12 @@ CArchThreadImpl::~CArchThreadImpl()
|
|||
|
||||
|
||||
//
|
||||
// CArchMultithreadWindows
|
||||
// ArchMultithreadWindows
|
||||
//
|
||||
|
||||
CArchMultithreadWindows* CArchMultithreadWindows::s_instance = NULL;
|
||||
ArchMultithreadWindows* ArchMultithreadWindows::s_instance = NULL;
|
||||
|
||||
CArchMultithreadWindows::CArchMultithreadWindows()
|
||||
ArchMultithreadWindows::ArchMultithreadWindows()
|
||||
{
|
||||
assert(s_instance == NULL);
|
||||
s_instance = this;
|
||||
|
@ -101,18 +101,18 @@ CArchMultithreadWindows::CArchMultithreadWindows()
|
|||
|
||||
// create thread for calling (main) thread and add it to our
|
||||
// list. no need to lock the mutex since we're the only thread.
|
||||
m_mainThread = new CArchThreadImpl;
|
||||
m_mainThread = new ArchThreadImpl;
|
||||
m_mainThread->m_thread = NULL;
|
||||
m_mainThread->m_id = GetCurrentThreadId();
|
||||
insert(m_mainThread);
|
||||
}
|
||||
|
||||
CArchMultithreadWindows::~CArchMultithreadWindows()
|
||||
ArchMultithreadWindows::~ArchMultithreadWindows()
|
||||
{
|
||||
s_instance = NULL;
|
||||
|
||||
// clean up thread list
|
||||
for (CThreadList::iterator index = m_threadList.begin();
|
||||
for (ThreadList::iterator index = m_threadList.begin();
|
||||
index != m_threadList.end(); ++index) {
|
||||
delete *index;
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ CArchMultithreadWindows::~CArchMultithreadWindows()
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::setNetworkDataForCurrentThread(void* data)
|
||||
ArchMultithreadWindows::setNetworkDataForCurrentThread(void* data)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
ArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
thread->m_networkData = data;
|
||||
unlockMutex(m_threadMutex);
|
||||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadWindows::getNetworkDataForThread(CArchThread thread)
|
||||
ArchMultithreadWindows::getNetworkDataForThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
void* data = thread->m_networkData;
|
||||
|
@ -140,27 +140,27 @@ CArchMultithreadWindows::getNetworkDataForThread(CArchThread thread)
|
|||
}
|
||||
|
||||
HANDLE
|
||||
CArchMultithreadWindows::getCancelEventForCurrentThread()
|
||||
ArchMultithreadWindows::getCancelEventForCurrentThread()
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
ArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
unlockMutex(m_threadMutex);
|
||||
return thread->m_cancel;
|
||||
}
|
||||
|
||||
CArchMultithreadWindows*
|
||||
CArchMultithreadWindows::getInstance()
|
||||
ArchMultithreadWindows*
|
||||
ArchMultithreadWindows::getInstance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
CArchCond
|
||||
CArchMultithreadWindows::newCondVar()
|
||||
ArchCond
|
||||
ArchMultithreadWindows::newCondVar()
|
||||
{
|
||||
CArchCondImpl* cond = new CArchCondImpl;
|
||||
cond->m_events[CArchCondImpl::kSignal] = CreateEvent(NULL,
|
||||
ArchCondImpl* cond = new ArchCondImpl;
|
||||
cond->m_events[ArchCondImpl::kSignal] = CreateEvent(NULL,
|
||||
FALSE, FALSE, NULL);
|
||||
cond->m_events[CArchCondImpl::kBroadcast] = CreateEvent(NULL,
|
||||
cond->m_events[ArchCondImpl::kBroadcast] = CreateEvent(NULL,
|
||||
TRUE, FALSE, NULL);
|
||||
cond->m_waitCountMutex = newMutex();
|
||||
cond->m_waitCount = 0;
|
||||
|
@ -168,16 +168,16 @@ CArchMultithreadWindows::newCondVar()
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::closeCondVar(CArchCond cond)
|
||||
ArchMultithreadWindows::closeCondVar(ArchCond cond)
|
||||
{
|
||||
CloseHandle(cond->m_events[CArchCondImpl::kSignal]);
|
||||
CloseHandle(cond->m_events[CArchCondImpl::kBroadcast]);
|
||||
CloseHandle(cond->m_events[ArchCondImpl::kSignal]);
|
||||
CloseHandle(cond->m_events[ArchCondImpl::kBroadcast]);
|
||||
closeMutex(cond->m_waitCountMutex);
|
||||
delete cond;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::signalCondVar(CArchCond cond)
|
||||
ArchMultithreadWindows::signalCondVar(ArchCond cond)
|
||||
{
|
||||
// is anybody waiting?
|
||||
lockMutex(cond->m_waitCountMutex);
|
||||
|
@ -186,12 +186,12 @@ CArchMultithreadWindows::signalCondVar(CArchCond cond)
|
|||
|
||||
// wake one thread if anybody is waiting
|
||||
if (hasWaiter) {
|
||||
SetEvent(cond->m_events[CArchCondImpl::kSignal]);
|
||||
SetEvent(cond->m_events[ArchCondImpl::kSignal]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::broadcastCondVar(CArchCond cond)
|
||||
ArchMultithreadWindows::broadcastCondVar(ArchCond cond)
|
||||
{
|
||||
// is anybody waiting?
|
||||
lockMutex(cond->m_waitCountMutex);
|
||||
|
@ -200,13 +200,13 @@ CArchMultithreadWindows::broadcastCondVar(CArchCond cond)
|
|||
|
||||
// wake all threads if anybody is waiting
|
||||
if (hasWaiter) {
|
||||
SetEvent(cond->m_events[CArchCondImpl::kBroadcast]);
|
||||
SetEvent(cond->m_events[ArchCondImpl::kBroadcast]);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadWindows::waitCondVar(CArchCond cond,
|
||||
CArchMutex mutex, double timeout)
|
||||
ArchMultithreadWindows::waitCondVar(ArchCond cond,
|
||||
ArchMutex mutex, double timeout)
|
||||
{
|
||||
// prepare to wait
|
||||
const DWORD winTimeout = (timeout < 0.0) ? INFINITE :
|
||||
|
@ -215,8 +215,8 @@ CArchMultithreadWindows::waitCondVar(CArchCond cond,
|
|||
// make a list of the condition variable events and the cancel event
|
||||
// for the current thread.
|
||||
HANDLE handles[4];
|
||||
handles[0] = cond->m_events[CArchCondImpl::kSignal];
|
||||
handles[1] = cond->m_events[CArchCondImpl::kBroadcast];
|
||||
handles[0] = cond->m_events[ArchCondImpl::kSignal];
|
||||
handles[1] = cond->m_events[ArchCondImpl::kBroadcast];
|
||||
handles[2] = getCancelEventForCurrentThread();
|
||||
|
||||
// update waiter count
|
||||
|
@ -248,7 +248,7 @@ CArchMultithreadWindows::waitCondVar(CArchCond cond,
|
|||
|
||||
// reset the broadcast event if we're the last waiter
|
||||
if (last) {
|
||||
ResetEvent(cond->m_events[CArchCondImpl::kBroadcast]);
|
||||
ResetEvent(cond->m_events[ArchCondImpl::kBroadcast]);
|
||||
}
|
||||
|
||||
// reacquire the mutex
|
||||
|
@ -264,40 +264,40 @@ CArchMultithreadWindows::waitCondVar(CArchCond cond,
|
|||
result == WAIT_OBJECT_0 + 1);
|
||||
}
|
||||
|
||||
CArchMutex
|
||||
CArchMultithreadWindows::newMutex()
|
||||
ArchMutex
|
||||
ArchMultithreadWindows::newMutex()
|
||||
{
|
||||
CArchMutexImpl* mutex = new CArchMutexImpl;
|
||||
ArchMutexImpl* mutex = new ArchMutexImpl;
|
||||
InitializeCriticalSection(&mutex->m_mutex);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::closeMutex(CArchMutex mutex)
|
||||
ArchMultithreadWindows::closeMutex(ArchMutex mutex)
|
||||
{
|
||||
DeleteCriticalSection(&mutex->m_mutex);
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::lockMutex(CArchMutex mutex)
|
||||
ArchMultithreadWindows::lockMutex(ArchMutex mutex)
|
||||
{
|
||||
EnterCriticalSection(&mutex->m_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::unlockMutex(CArchMutex mutex)
|
||||
ArchMultithreadWindows::unlockMutex(ArchMutex mutex)
|
||||
{
|
||||
LeaveCriticalSection(&mutex->m_mutex);
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadWindows::newThread(ThreadFunc func, void* data)
|
||||
ArchThread
|
||||
ArchMultithreadWindows::newThread(ThreadFunc func, void* data)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
|
||||
// create thread impl for new thread
|
||||
CArchThreadImpl* thread = new CArchThreadImpl;
|
||||
ArchThreadImpl* thread = new ArchThreadImpl;
|
||||
thread->m_func = func;
|
||||
thread->m_userData = data;
|
||||
|
||||
|
@ -327,18 +327,18 @@ CArchMultithreadWindows::newThread(ThreadFunc func, void* data)
|
|||
return thread;
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadWindows::newCurrentThread()
|
||||
ArchThread
|
||||
ArchMultithreadWindows::newCurrentThread()
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = find(GetCurrentThreadId());
|
||||
ArchThreadImpl* thread = find(GetCurrentThreadId());
|
||||
unlockMutex(m_threadMutex);
|
||||
assert(thread != NULL);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::closeThread(CArchThread thread)
|
||||
ArchMultithreadWindows::closeThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -360,15 +360,15 @@ CArchMultithreadWindows::closeThread(CArchThread thread)
|
|||
}
|
||||
}
|
||||
|
||||
CArchThread
|
||||
CArchMultithreadWindows::copyThread(CArchThread thread)
|
||||
ArchThread
|
||||
ArchMultithreadWindows::copyThread(ArchThread thread)
|
||||
{
|
||||
refThread(thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::cancelThread(CArchThread thread)
|
||||
ArchMultithreadWindows::cancelThread(ArchThread thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -377,14 +377,14 @@ CArchMultithreadWindows::cancelThread(CArchThread thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::setPriorityOfThread(CArchThread thread, int n)
|
||||
ArchMultithreadWindows::setPriorityOfThread(ArchThread thread, int n)
|
||||
{
|
||||
struct CPriorityInfo {
|
||||
struct PriorityInfo {
|
||||
public:
|
||||
DWORD m_class;
|
||||
int m_level;
|
||||
};
|
||||
static const CPriorityInfo s_pClass[] = {
|
||||
static const PriorityInfo s_pClass[] = {
|
||||
{ IDLE_PRIORITY_CLASS, THREAD_PRIORITY_IDLE },
|
||||
{ IDLE_PRIORITY_CLASS, THREAD_PRIORITY_LOWEST },
|
||||
{ IDLE_PRIORITY_CLASS, THREAD_PRIORITY_BELOW_NORMAL },
|
||||
|
@ -436,11 +436,11 @@ CArchMultithreadWindows::setPriorityOfThread(CArchThread thread, int n)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::testCancelThread()
|
||||
ArchMultithreadWindows::testCancelThread()
|
||||
{
|
||||
// find current thread
|
||||
lockMutex(m_threadMutex);
|
||||
CArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
ArchThreadImpl* thread = findNoRef(GetCurrentThreadId());
|
||||
unlockMutex(m_threadMutex);
|
||||
|
||||
// test cancel on thread
|
||||
|
@ -448,14 +448,14 @@ CArchMultithreadWindows::testCancelThread()
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadWindows::wait(CArchThread target, double timeout)
|
||||
ArchMultithreadWindows::wait(ArchThread target, double timeout)
|
||||
{
|
||||
assert(target != NULL);
|
||||
|
||||
lockMutex(m_threadMutex);
|
||||
|
||||
// find current thread
|
||||
CArchThreadImpl* self = findNoRef(GetCurrentThreadId());
|
||||
ArchThreadImpl* self = findNoRef(GetCurrentThreadId());
|
||||
|
||||
// ignore wait if trying to wait on ourself
|
||||
if (target == self) {
|
||||
|
@ -510,20 +510,20 @@ CArchMultithreadWindows::wait(CArchThread target, double timeout)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadWindows::isSameThread(CArchThread thread1, CArchThread thread2)
|
||||
ArchMultithreadWindows::isSameThread(ArchThread thread1, ArchThread thread2)
|
||||
{
|
||||
return (thread1 == thread2);
|
||||
}
|
||||
|
||||
bool
|
||||
CArchMultithreadWindows::isExitedThread(CArchThread thread)
|
||||
ArchMultithreadWindows::isExitedThread(ArchThread thread)
|
||||
{
|
||||
// poll exit event
|
||||
return (WaitForSingleObject(thread->m_exit, 0) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
void*
|
||||
CArchMultithreadWindows::getResultOfThread(CArchThread thread)
|
||||
ArchMultithreadWindows::getResultOfThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
void* result = thread->m_result;
|
||||
|
@ -532,13 +532,13 @@ CArchMultithreadWindows::getResultOfThread(CArchThread thread)
|
|||
}
|
||||
|
||||
IArchMultithread::ThreadID
|
||||
CArchMultithreadWindows::getIDOfThread(CArchThread thread)
|
||||
ArchMultithreadWindows::getIDOfThread(ArchThread thread)
|
||||
{
|
||||
return static_cast<ThreadID>(thread->m_id);
|
||||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::setSignalHandler(
|
||||
ArchMultithreadWindows::setSignalHandler(
|
||||
ESignal signal, SignalFunc func, void* userData)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
|
@ -548,7 +548,7 @@ CArchMultithreadWindows::setSignalHandler(
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::raiseSignal(ESignal signal)
|
||||
ArchMultithreadWindows::raiseSignal(ESignal signal)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
if (m_signalFunc[signal] != NULL) {
|
||||
|
@ -561,26 +561,26 @@ CArchMultithreadWindows::raiseSignal(ESignal signal)
|
|||
unlockMutex(m_threadMutex);
|
||||
}
|
||||
|
||||
CArchThreadImpl*
|
||||
CArchMultithreadWindows::find(DWORD id)
|
||||
ArchThreadImpl*
|
||||
ArchMultithreadWindows::find(DWORD id)
|
||||
{
|
||||
CArchThreadImpl* impl = findNoRef(id);
|
||||
ArchThreadImpl* impl = findNoRef(id);
|
||||
if (impl != NULL) {
|
||||
refThread(impl);
|
||||
}
|
||||
return impl;
|
||||
}
|
||||
|
||||
CArchThreadImpl*
|
||||
CArchMultithreadWindows::findNoRef(DWORD id)
|
||||
ArchThreadImpl*
|
||||
ArchMultithreadWindows::findNoRef(DWORD id)
|
||||
{
|
||||
CArchThreadImpl* impl = findNoRefOrCreate(id);
|
||||
ArchThreadImpl* impl = findNoRefOrCreate(id);
|
||||
if (impl == NULL) {
|
||||
// create thread for calling thread which isn't in our list and
|
||||
// add it to the list. this won't normally happen but it can if
|
||||
// the system calls us under a new thread, like it does when we
|
||||
// run as a service.
|
||||
impl = new CArchThreadImpl;
|
||||
impl = new ArchThreadImpl;
|
||||
impl->m_thread = NULL;
|
||||
impl->m_id = GetCurrentThreadId();
|
||||
insert(impl);
|
||||
|
@ -588,11 +588,11 @@ CArchMultithreadWindows::findNoRef(DWORD id)
|
|||
return impl;
|
||||
}
|
||||
|
||||
CArchThreadImpl*
|
||||
CArchMultithreadWindows::findNoRefOrCreate(DWORD id)
|
||||
ArchThreadImpl*
|
||||
ArchMultithreadWindows::findNoRefOrCreate(DWORD id)
|
||||
{
|
||||
// linear search
|
||||
for (CThreadList::const_iterator index = m_threadList.begin();
|
||||
for (ThreadList::const_iterator index = m_threadList.begin();
|
||||
index != m_threadList.end(); ++index) {
|
||||
if ((*index)->m_id == id) {
|
||||
return *index;
|
||||
|
@ -602,7 +602,7 @@ CArchMultithreadWindows::findNoRefOrCreate(DWORD id)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::insert(CArchThreadImpl* thread)
|
||||
ArchMultithreadWindows::insert(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -614,9 +614,9 @@ CArchMultithreadWindows::insert(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::erase(CArchThreadImpl* thread)
|
||||
ArchMultithreadWindows::erase(ArchThreadImpl* thread)
|
||||
{
|
||||
for (CThreadList::iterator index = m_threadList.begin();
|
||||
for (ThreadList::iterator index = m_threadList.begin();
|
||||
index != m_threadList.end(); ++index) {
|
||||
if (*index == thread) {
|
||||
m_threadList.erase(index);
|
||||
|
@ -626,7 +626,7 @@ CArchMultithreadWindows::erase(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::refThread(CArchThreadImpl* thread)
|
||||
ArchMultithreadWindows::refThread(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
assert(findNoRefOrCreate(thread->m_id) != NULL);
|
||||
|
@ -634,7 +634,7 @@ CArchMultithreadWindows::refThread(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::testCancelThreadImpl(CArchThreadImpl* thread)
|
||||
ArchMultithreadWindows::testCancelThreadImpl(ArchThreadImpl* thread)
|
||||
{
|
||||
assert(thread != NULL);
|
||||
|
||||
|
@ -658,10 +658,10 @@ CArchMultithreadWindows::testCancelThreadImpl(CArchThreadImpl* thread)
|
|||
}
|
||||
|
||||
unsigned int __stdcall
|
||||
CArchMultithreadWindows::threadFunc(void* vrep)
|
||||
ArchMultithreadWindows::threadFunc(void* vrep)
|
||||
{
|
||||
// get the thread
|
||||
CArchThreadImpl* thread = reinterpret_cast<CArchThreadImpl*>(vrep);
|
||||
ArchThreadImpl* thread = reinterpret_cast<ArchThreadImpl*>(vrep);
|
||||
|
||||
// run thread
|
||||
s_instance->doThreadFunc(thread);
|
||||
|
@ -671,7 +671,7 @@ CArchMultithreadWindows::threadFunc(void* vrep)
|
|||
}
|
||||
|
||||
void
|
||||
CArchMultithreadWindows::doThreadFunc(CArchThread thread)
|
||||
ArchMultithreadWindows::doThreadFunc(ArchThread thread)
|
||||
{
|
||||
// wait for parent to initialize this object
|
||||
lockMutex(m_threadMutex);
|
||||
|
|
|
@ -24,27 +24,27 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#define ARCH_MULTITHREAD CArchMultithreadWindows
|
||||
#define ARCH_MULTITHREAD ArchMultithreadWindows
|
||||
|
||||
class CArchCondImpl {
|
||||
class ArchCondImpl {
|
||||
public:
|
||||
enum { kSignal = 0, kBroadcast };
|
||||
|
||||
HANDLE m_events[2];
|
||||
mutable int m_waitCount;
|
||||
CArchMutex m_waitCountMutex;
|
||||
ArchMutex m_waitCountMutex;
|
||||
};
|
||||
|
||||
class CArchMutexImpl {
|
||||
class ArchMutexImpl {
|
||||
public:
|
||||
CRITICAL_SECTION m_mutex;
|
||||
};
|
||||
|
||||
//! Win32 implementation of IArchMultithread
|
||||
class CArchMultithreadWindows : public IArchMultithread {
|
||||
class ArchMultithreadWindows : public IArchMultithread {
|
||||
public:
|
||||
CArchMultithreadWindows();
|
||||
virtual ~CArchMultithreadWindows();
|
||||
ArchMultithreadWindows();
|
||||
virtual ~ArchMultithreadWindows();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
@ -57,59 +57,59 @@ public:
|
|||
|
||||
HANDLE getCancelEventForCurrentThread();
|
||||
|
||||
void* getNetworkDataForThread(CArchThread);
|
||||
void* getNetworkDataForThread(ArchThread);
|
||||
|
||||
static CArchMultithreadWindows* getInstance();
|
||||
static ArchMultithreadWindows* getInstance();
|
||||
|
||||
//@}
|
||||
|
||||
// IArchMultithread overrides
|
||||
virtual CArchCond newCondVar();
|
||||
virtual void closeCondVar(CArchCond);
|
||||
virtual void signalCondVar(CArchCond);
|
||||
virtual void broadcastCondVar(CArchCond);
|
||||
virtual bool waitCondVar(CArchCond, CArchMutex, double timeout);
|
||||
virtual CArchMutex newMutex();
|
||||
virtual void closeMutex(CArchMutex);
|
||||
virtual void lockMutex(CArchMutex);
|
||||
virtual void unlockMutex(CArchMutex);
|
||||
virtual CArchThread newThread(ThreadFunc, void*);
|
||||
virtual CArchThread newCurrentThread();
|
||||
virtual CArchThread copyThread(CArchThread);
|
||||
virtual void closeThread(CArchThread);
|
||||
virtual void cancelThread(CArchThread);
|
||||
virtual void setPriorityOfThread(CArchThread, int n);
|
||||
virtual ArchCond newCondVar();
|
||||
virtual void closeCondVar(ArchCond);
|
||||
virtual void signalCondVar(ArchCond);
|
||||
virtual void broadcastCondVar(ArchCond);
|
||||
virtual bool waitCondVar(ArchCond, ArchMutex, double timeout);
|
||||
virtual ArchMutex newMutex();
|
||||
virtual void closeMutex(ArchMutex);
|
||||
virtual void lockMutex(ArchMutex);
|
||||
virtual void unlockMutex(ArchMutex);
|
||||
virtual ArchThread newThread(ThreadFunc, void*);
|
||||
virtual ArchThread newCurrentThread();
|
||||
virtual ArchThread copyThread(ArchThread);
|
||||
virtual void closeThread(ArchThread);
|
||||
virtual void cancelThread(ArchThread);
|
||||
virtual void setPriorityOfThread(ArchThread, int n);
|
||||
virtual void testCancelThread();
|
||||
virtual bool wait(CArchThread, double timeout);
|
||||
virtual bool isSameThread(CArchThread, CArchThread);
|
||||
virtual bool isExitedThread(CArchThread);
|
||||
virtual void* getResultOfThread(CArchThread);
|
||||
virtual ThreadID getIDOfThread(CArchThread);
|
||||
virtual bool wait(ArchThread, double timeout);
|
||||
virtual bool isSameThread(ArchThread, ArchThread);
|
||||
virtual bool isExitedThread(ArchThread);
|
||||
virtual void* getResultOfThread(ArchThread);
|
||||
virtual ThreadID getIDOfThread(ArchThread);
|
||||
virtual void setSignalHandler(ESignal, SignalFunc, void*);
|
||||
virtual void raiseSignal(ESignal);
|
||||
|
||||
private:
|
||||
CArchThreadImpl* find(DWORD id);
|
||||
CArchThreadImpl* findNoRef(DWORD id);
|
||||
CArchThreadImpl* findNoRefOrCreate(DWORD id);
|
||||
void insert(CArchThreadImpl* thread);
|
||||
void erase(CArchThreadImpl* thread);
|
||||
ArchThreadImpl* find(DWORD id);
|
||||
ArchThreadImpl* findNoRef(DWORD id);
|
||||
ArchThreadImpl* findNoRefOrCreate(DWORD id);
|
||||
void insert(ArchThreadImpl* thread);
|
||||
void erase(ArchThreadImpl* thread);
|
||||
|
||||
void refThread(CArchThreadImpl* rep);
|
||||
void testCancelThreadImpl(CArchThreadImpl* rep);
|
||||
void refThread(ArchThreadImpl* rep);
|
||||
void testCancelThreadImpl(ArchThreadImpl* rep);
|
||||
|
||||
void doThreadFunc(CArchThread thread);
|
||||
void doThreadFunc(ArchThread thread);
|
||||
static unsigned int __stdcall threadFunc(void* vrep);
|
||||
|
||||
private:
|
||||
typedef std::list<CArchThread> CThreadList;
|
||||
typedef std::list<ArchThread> ThreadList;
|
||||
|
||||
static CArchMultithreadWindows* s_instance;
|
||||
static ArchMultithreadWindows* s_instance;
|
||||
|
||||
CArchMutex m_threadMutex;
|
||||
ArchMutex m_threadMutex;
|
||||
|
||||
CThreadList m_threadList;
|
||||
CArchThread m_mainThread;
|
||||
ThreadList m_threadList;
|
||||
ArchThread m_mainThread;
|
||||
|
||||
SignalFunc m_signalFunc[kNUM_SIGNALS];
|
||||
void* m_signalUserData[kNUM_SIGNALS];
|
||||
|
|
|
@ -82,25 +82,25 @@ netGetProcAddress(HMODULE module, LPCSTR name)
|
|||
return func;
|
||||
}
|
||||
|
||||
CArchNetAddressImpl*
|
||||
CArchNetAddressImpl::alloc(size_t size)
|
||||
ArchNetAddressImpl*
|
||||
ArchNetAddressImpl::alloc(size_t size)
|
||||
{
|
||||
size_t totalSize = size + ADDR_HDR_SIZE;
|
||||
CArchNetAddressImpl* addr = (CArchNetAddressImpl*)malloc(totalSize);
|
||||
ArchNetAddressImpl* addr = (ArchNetAddressImpl*)malloc(totalSize);
|
||||
addr->m_len = (int)size;
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// CArchNetworkWinsock
|
||||
// ArchNetworkWinsock
|
||||
//
|
||||
|
||||
CArchNetworkWinsock::CArchNetworkWinsock()
|
||||
ArchNetworkWinsock::ArchNetworkWinsock()
|
||||
{
|
||||
}
|
||||
|
||||
CArchNetworkWinsock::~CArchNetworkWinsock()
|
||||
ArchNetworkWinsock::~ArchNetworkWinsock()
|
||||
{
|
||||
if (s_networkModule != NULL) {
|
||||
WSACleanup_winsock();
|
||||
|
@ -111,14 +111,14 @@ CArchNetworkWinsock::~CArchNetworkWinsock()
|
|||
}
|
||||
ARCH->closeMutex(m_mutex);
|
||||
|
||||
CEventList::iterator it;
|
||||
EventList::iterator it;
|
||||
for (it = m_unblockEvents.begin(); it != m_unblockEvents.end(); it++) {
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::init()
|
||||
ArchNetworkWinsock::init()
|
||||
{
|
||||
static const char* s_library[] = { "ws2_32.dll" };
|
||||
|
||||
|
@ -142,7 +142,7 @@ CArchNetworkWinsock::init()
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::initModule(HMODULE module)
|
||||
ArchNetworkWinsock::initModule(HMODULE module)
|
||||
{
|
||||
if (module == NULL) {
|
||||
throw XArchNetworkSupport("");
|
||||
|
@ -199,8 +199,8 @@ CArchNetworkWinsock::initModule(HMODULE module)
|
|||
s_networkModule = module;
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type)
|
||||
ArchSocket
|
||||
ArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type)
|
||||
{
|
||||
// create socket
|
||||
SOCKET fd = socket_winsock(s_family[family], s_type[type], 0);
|
||||
|
@ -216,7 +216,7 @@ CArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type)
|
|||
}
|
||||
|
||||
// allocate socket object
|
||||
CArchSocketImpl* socket = new CArchSocketImpl;
|
||||
ArchSocketImpl* socket = new ArchSocketImpl;
|
||||
socket->m_socket = fd;
|
||||
socket->m_refCount = 1;
|
||||
socket->m_event = WSACreateEvent_winsock();
|
||||
|
@ -224,8 +224,8 @@ CArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type)
|
|||
return socket;
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkWinsock::copySocket(CArchSocket s)
|
||||
ArchSocket
|
||||
ArchNetworkWinsock::copySocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -237,7 +237,7 @@ CArchNetworkWinsock::copySocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::closeSocket(CArchSocket s)
|
||||
ArchNetworkWinsock::closeSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -262,7 +262,7 @@ CArchNetworkWinsock::closeSocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::closeSocketForRead(CArchSocket s)
|
||||
ArchNetworkWinsock::closeSocketForRead(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -274,7 +274,7 @@ CArchNetworkWinsock::closeSocketForRead(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::closeSocketForWrite(CArchSocket s)
|
||||
ArchNetworkWinsock::closeSocketForWrite(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -286,7 +286,7 @@ CArchNetworkWinsock::closeSocketForWrite(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::bindSocket(CArchSocket s, CArchNetAddress addr)
|
||||
ArchNetworkWinsock::bindSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
|
@ -297,7 +297,7 @@ CArchNetworkWinsock::bindSocket(CArchSocket s, CArchNetAddress addr)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::listenOnSocket(CArchSocket s)
|
||||
ArchNetworkWinsock::listenOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -307,14 +307,14 @@ CArchNetworkWinsock::listenOnSocket(CArchSocket s)
|
|||
}
|
||||
}
|
||||
|
||||
CArchSocket
|
||||
CArchNetworkWinsock::acceptSocket(CArchSocket s, CArchNetAddress* addr)
|
||||
ArchSocket
|
||||
ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
// create new socket and temporary address
|
||||
CArchSocketImpl* socket = new CArchSocketImpl;
|
||||
CArchNetAddress tmp = CArchNetAddressImpl::alloc(sizeof(struct sockaddr));
|
||||
ArchSocketImpl* socket = new ArchSocketImpl;
|
||||
ArchNetAddress tmp = ArchNetAddressImpl::alloc(sizeof(struct sockaddr));
|
||||
|
||||
// accept on socket
|
||||
SOCKET fd = accept_winsock(s->m_socket, &tmp->m_addr, &tmp->m_len);
|
||||
|
@ -356,7 +356,7 @@ CArchNetworkWinsock::acceptSocket(CArchSocket s, CArchNetAddress* addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkWinsock::connectSocket(CArchSocket s, CArchNetAddress addr)
|
||||
ArchNetworkWinsock::connectSocket(ArchSocket s, ArchNetAddress addr)
|
||||
{
|
||||
assert(s != NULL);
|
||||
assert(addr != NULL);
|
||||
|
@ -375,7 +375,7 @@ CArchNetworkWinsock::connectSocket(CArchSocket s, CArchNetAddress addr)
|
|||
}
|
||||
|
||||
int
|
||||
CArchNetworkWinsock::pollSocket(CPollEntry pe[], int num, double timeout)
|
||||
ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout)
|
||||
{
|
||||
int i;
|
||||
DWORD n;
|
||||
|
@ -429,8 +429,8 @@ CArchNetworkWinsock::pollSocket(CPollEntry pe[], int num, double timeout)
|
|||
}
|
||||
|
||||
// add the unblock event
|
||||
CArchMultithreadWindows* mt = CArchMultithreadWindows::getInstance();
|
||||
CArchThread thread = mt->newCurrentThread();
|
||||
ArchMultithreadWindows* mt = ArchMultithreadWindows::getInstance();
|
||||
ArchThread thread = mt->newCurrentThread();
|
||||
WSAEVENT* unblockEvent = (WSAEVENT*)mt->getNetworkDataForThread(thread);
|
||||
ARCH->closeThread(thread);
|
||||
if (unblockEvent == NULL) {
|
||||
|
@ -527,10 +527,10 @@ CArchNetworkWinsock::pollSocket(CPollEntry pe[], int num, double timeout)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::unblockPollSocket(CArchThread thread)
|
||||
ArchNetworkWinsock::unblockPollSocket(ArchThread thread)
|
||||
{
|
||||
// set the unblock event
|
||||
CArchMultithreadWindows* mt = CArchMultithreadWindows::getInstance();
|
||||
ArchMultithreadWindows* mt = ArchMultithreadWindows::getInstance();
|
||||
WSAEVENT* unblockEvent = (WSAEVENT*)mt->getNetworkDataForThread(thread);
|
||||
if (unblockEvent != NULL) {
|
||||
WSASetEvent_winsock(*unblockEvent);
|
||||
|
@ -538,7 +538,7 @@ CArchNetworkWinsock::unblockPollSocket(CArchThread thread)
|
|||
}
|
||||
|
||||
size_t
|
||||
CArchNetworkWinsock::readSocket(CArchSocket s, void* buf, size_t len)
|
||||
ArchNetworkWinsock::readSocket(ArchSocket s, void* buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -554,7 +554,7 @@ CArchNetworkWinsock::readSocket(CArchSocket s, void* buf, size_t len)
|
|||
}
|
||||
|
||||
size_t
|
||||
CArchNetworkWinsock::writeSocket(CArchSocket s, const void* buf, size_t len)
|
||||
ArchNetworkWinsock::writeSocket(ArchSocket s, const void* buf, size_t len)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -574,7 +574,7 @@ CArchNetworkWinsock::writeSocket(CArchSocket s, const void* buf, size_t len)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::throwErrorOnSocket(CArchSocket s)
|
||||
ArchNetworkWinsock::throwErrorOnSocket(ArchSocket s)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -593,7 +593,7 @@ CArchNetworkWinsock::throwErrorOnSocket(CArchSocket s)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::setBlockingOnSocket(SOCKET s, bool blocking)
|
||||
ArchNetworkWinsock::setBlockingOnSocket(SOCKET s, bool blocking)
|
||||
{
|
||||
assert(s != 0);
|
||||
|
||||
|
@ -604,7 +604,7 @@ CArchNetworkWinsock::setBlockingOnSocket(SOCKET s, bool blocking)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkWinsock::setNoDelayOnSocket(CArchSocket s, bool noDelay)
|
||||
ArchNetworkWinsock::setNoDelayOnSocket(ArchSocket s, bool noDelay)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -628,7 +628,7 @@ CArchNetworkWinsock::setNoDelayOnSocket(CArchSocket s, bool noDelay)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkWinsock::setReuseAddrOnSocket(CArchSocket s, bool reuse)
|
||||
ArchNetworkWinsock::setReuseAddrOnSocket(ArchSocket s, bool reuse)
|
||||
{
|
||||
assert(s != NULL);
|
||||
|
||||
|
@ -652,7 +652,7 @@ CArchNetworkWinsock::setReuseAddrOnSocket(CArchSocket s, bool reuse)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkWinsock::getHostName()
|
||||
ArchNetworkWinsock::getHostName()
|
||||
{
|
||||
char name[256];
|
||||
if (gethostname_winsock(name, sizeof(name)) == -1) {
|
||||
|
@ -664,13 +664,13 @@ CArchNetworkWinsock::getHostName()
|
|||
return name;
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkWinsock::newAnyAddr(EAddressFamily family)
|
||||
ArchNetAddress
|
||||
ArchNetworkWinsock::newAnyAddr(EAddressFamily family)
|
||||
{
|
||||
CArchNetAddressImpl* addr = NULL;
|
||||
ArchNetAddressImpl* addr = NULL;
|
||||
switch (family) {
|
||||
case kINET: {
|
||||
addr = CArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
addr = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
struct sockaddr_in* ipAddr = TYPED_ADDR(struct sockaddr_in, addr);
|
||||
ipAddr->sin_family = AF_INET;
|
||||
ipAddr->sin_port = 0;
|
||||
|
@ -684,21 +684,21 @@ CArchNetworkWinsock::newAnyAddr(EAddressFamily family)
|
|||
return addr;
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkWinsock::copyAddr(CArchNetAddress addr)
|
||||
ArchNetAddress
|
||||
ArchNetworkWinsock::copyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
CArchNetAddressImpl* copy = CArchNetAddressImpl::alloc(addr->m_len);
|
||||
ArchNetAddressImpl* copy = ArchNetAddressImpl::alloc(addr->m_len);
|
||||
memcpy(TYPED_ADDR(void, copy), TYPED_ADDR(void, addr), addr->m_len);
|
||||
return copy;
|
||||
}
|
||||
|
||||
CArchNetAddress
|
||||
CArchNetworkWinsock::nameToAddr(const std::string& name)
|
||||
ArchNetAddress
|
||||
ArchNetworkWinsock::nameToAddr(const std::string& name)
|
||||
{
|
||||
// allocate address
|
||||
CArchNetAddressImpl* addr = NULL;
|
||||
ArchNetAddressImpl* addr = NULL;
|
||||
|
||||
// try to convert assuming an IPv4 dot notation address
|
||||
struct sockaddr_in inaddr;
|
||||
|
@ -708,7 +708,7 @@ CArchNetworkWinsock::nameToAddr(const std::string& name)
|
|||
inaddr.sin_addr.s_addr = inet_addr_winsock(name.c_str());
|
||||
if (inaddr.sin_addr.s_addr != INADDR_NONE) {
|
||||
// it's a dot notation address
|
||||
addr = CArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
addr = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
memcpy(TYPED_ADDR(void, addr), &inaddr, addr->m_len);
|
||||
}
|
||||
|
||||
|
@ -721,7 +721,7 @@ CArchNetworkWinsock::nameToAddr(const std::string& name)
|
|||
|
||||
// copy over address (only IPv4 currently supported)
|
||||
if (info->h_addrtype == AF_INET) {
|
||||
addr = CArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
addr = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in));
|
||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0],
|
||||
sizeof(inaddr.sin_addr));
|
||||
memcpy(TYPED_ADDR(void, addr), &inaddr, addr->m_len);
|
||||
|
@ -737,7 +737,7 @@ CArchNetworkWinsock::nameToAddr(const std::string& name)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::closeAddr(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::closeAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -745,7 +745,7 @@ CArchNetworkWinsock::closeAddr(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkWinsock::addrToName(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::addrToName(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -762,7 +762,7 @@ CArchNetworkWinsock::addrToName(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchNetworkWinsock::addrToString(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::addrToString(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -780,7 +780,7 @@ CArchNetworkWinsock::addrToString(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
IArchNetwork::EAddressFamily
|
||||
CArchNetworkWinsock::getAddrFamily(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::getAddrFamily(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -794,7 +794,7 @@ CArchNetworkWinsock::getAddrFamily(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::setAddrPort(CArchNetAddress addr, int port)
|
||||
ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -813,7 +813,7 @@ CArchNetworkWinsock::setAddrPort(CArchNetAddress addr, int port)
|
|||
}
|
||||
|
||||
int
|
||||
CArchNetworkWinsock::getAddrPort(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::getAddrPort(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -831,7 +831,7 @@ CArchNetworkWinsock::getAddrPort(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkWinsock::isAnyAddr(CArchNetAddress addr)
|
||||
ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
|
@ -850,14 +850,14 @@ CArchNetworkWinsock::isAnyAddr(CArchNetAddress addr)
|
|||
}
|
||||
|
||||
bool
|
||||
CArchNetworkWinsock::isEqualAddr(CArchNetAddress a, CArchNetAddress b)
|
||||
ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||
{
|
||||
return (a == b || (a->m_len == b->m_len &&
|
||||
memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0));
|
||||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::throwError(int err)
|
||||
ArchNetworkWinsock::throwError(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case WSAEACCES:
|
||||
|
@ -928,7 +928,7 @@ CArchNetworkWinsock::throwError(int err)
|
|||
}
|
||||
|
||||
void
|
||||
CArchNetworkWinsock::throwNameError(int err)
|
||||
ArchNetworkWinsock::throwNameError(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case WSAHOST_NOT_FOUND:
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#include <Windows.h>
|
||||
#include <list>
|
||||
|
||||
#define ARCH_NETWORK CArchNetworkWinsock
|
||||
#define ARCH_NETWORK ArchNetworkWinsock
|
||||
|
||||
class CArchSocketImpl {
|
||||
class ArchSocketImpl {
|
||||
public:
|
||||
SOCKET m_socket;
|
||||
int m_refCount;
|
||||
|
@ -40,55 +40,55 @@ public:
|
|||
bool m_pollWrite;
|
||||
};
|
||||
|
||||
class CArchNetAddressImpl {
|
||||
class ArchNetAddressImpl {
|
||||
public:
|
||||
static CArchNetAddressImpl* alloc(size_t);
|
||||
static ArchNetAddressImpl* alloc(size_t);
|
||||
|
||||
public:
|
||||
int m_len;
|
||||
struct sockaddr m_addr;
|
||||
};
|
||||
#define ADDR_HDR_SIZE offsetof(CArchNetAddressImpl, m_addr)
|
||||
#define ADDR_HDR_SIZE offsetof(ArchNetAddressImpl, m_addr)
|
||||
#define TYPED_ADDR(type_, addr_) (reinterpret_cast<type_*>(&addr_->m_addr))
|
||||
|
||||
//! Win32 implementation of IArchNetwork
|
||||
class CArchNetworkWinsock : public IArchNetwork {
|
||||
class ArchNetworkWinsock : public IArchNetwork {
|
||||
public:
|
||||
CArchNetworkWinsock();
|
||||
virtual ~CArchNetworkWinsock();
|
||||
ArchNetworkWinsock();
|
||||
virtual ~ArchNetworkWinsock();
|
||||
|
||||
virtual void init();
|
||||
|
||||
// IArchNetwork overrides
|
||||
virtual CArchSocket newSocket(EAddressFamily, ESocketType);
|
||||
virtual CArchSocket copySocket(CArchSocket s);
|
||||
virtual void closeSocket(CArchSocket s);
|
||||
virtual void closeSocketForRead(CArchSocket s);
|
||||
virtual void closeSocketForWrite(CArchSocket s);
|
||||
virtual void bindSocket(CArchSocket s, CArchNetAddress addr);
|
||||
virtual void listenOnSocket(CArchSocket s);
|
||||
virtual CArchSocket acceptSocket(CArchSocket s, CArchNetAddress* addr);
|
||||
virtual bool connectSocket(CArchSocket s, CArchNetAddress name);
|
||||
virtual int pollSocket(CPollEntry[], int num, double timeout);
|
||||
virtual void unblockPollSocket(CArchThread thread);
|
||||
virtual size_t readSocket(CArchSocket s, void* buf, size_t len);
|
||||
virtual size_t writeSocket(CArchSocket s,
|
||||
virtual ArchSocket newSocket(EAddressFamily, ESocketType);
|
||||
virtual ArchSocket copySocket(ArchSocket s);
|
||||
virtual void closeSocket(ArchSocket s);
|
||||
virtual void closeSocketForRead(ArchSocket s);
|
||||
virtual void closeSocketForWrite(ArchSocket s);
|
||||
virtual void bindSocket(ArchSocket s, ArchNetAddress addr);
|
||||
virtual void listenOnSocket(ArchSocket s);
|
||||
virtual ArchSocket acceptSocket(ArchSocket s, ArchNetAddress* addr);
|
||||
virtual bool connectSocket(ArchSocket s, ArchNetAddress name);
|
||||
virtual int pollSocket(PollEntry[], int num, double timeout);
|
||||
virtual void unblockPollSocket(ArchThread thread);
|
||||
virtual size_t readSocket(ArchSocket s, void* buf, size_t len);
|
||||
virtual size_t writeSocket(ArchSocket s,
|
||||
const void* buf, size_t len);
|
||||
virtual void throwErrorOnSocket(CArchSocket);
|
||||
virtual bool setNoDelayOnSocket(CArchSocket, bool noDelay);
|
||||
virtual bool setReuseAddrOnSocket(CArchSocket, bool reuse);
|
||||
virtual void throwErrorOnSocket(ArchSocket);
|
||||
virtual bool setNoDelayOnSocket(ArchSocket, bool noDelay);
|
||||
virtual bool setReuseAddrOnSocket(ArchSocket, bool reuse);
|
||||
virtual std::string getHostName();
|
||||
virtual CArchNetAddress newAnyAddr(EAddressFamily);
|
||||
virtual CArchNetAddress copyAddr(CArchNetAddress);
|
||||
virtual CArchNetAddress nameToAddr(const std::string&);
|
||||
virtual void closeAddr(CArchNetAddress);
|
||||
virtual std::string addrToName(CArchNetAddress);
|
||||
virtual std::string addrToString(CArchNetAddress);
|
||||
virtual EAddressFamily getAddrFamily(CArchNetAddress);
|
||||
virtual void setAddrPort(CArchNetAddress, int port);
|
||||
virtual int getAddrPort(CArchNetAddress);
|
||||
virtual bool isAnyAddr(CArchNetAddress);
|
||||
virtual bool isEqualAddr(CArchNetAddress, CArchNetAddress);
|
||||
virtual ArchNetAddress newAnyAddr(EAddressFamily);
|
||||
virtual ArchNetAddress copyAddr(ArchNetAddress);
|
||||
virtual ArchNetAddress nameToAddr(const std::string&);
|
||||
virtual void closeAddr(ArchNetAddress);
|
||||
virtual std::string addrToName(ArchNetAddress);
|
||||
virtual std::string addrToString(ArchNetAddress);
|
||||
virtual EAddressFamily getAddrFamily(ArchNetAddress);
|
||||
virtual void setAddrPort(ArchNetAddress, int port);
|
||||
virtual int getAddrPort(ArchNetAddress);
|
||||
virtual bool isAnyAddr(ArchNetAddress);
|
||||
virtual bool isEqualAddr(ArchNetAddress, ArchNetAddress);
|
||||
|
||||
private:
|
||||
void initModule(HMODULE);
|
||||
|
@ -99,8 +99,8 @@ private:
|
|||
void throwNameError(int);
|
||||
|
||||
private:
|
||||
typedef std::list<WSAEVENT> CEventList;
|
||||
typedef std::list<WSAEVENT> EventList;
|
||||
|
||||
CArchMutex m_mutex;
|
||||
CEventList m_unblockEvents;
|
||||
ArchMutex m_mutex;
|
||||
EventList m_unblockEvents;
|
||||
};
|
||||
|
|
|
@ -32,37 +32,37 @@ typedef int (*initFunc)(void (*sendEvent)(const char*, void*), void (*log)(const
|
|||
void* g_eventTarget = NULL;
|
||||
IEventQueue* g_events = NULL;
|
||||
|
||||
CArchPluginWindows::CArchPluginWindows()
|
||||
ArchPluginWindows::ArchPluginWindows()
|
||||
{
|
||||
}
|
||||
|
||||
CArchPluginWindows::~CArchPluginWindows()
|
||||
ArchPluginWindows::~ArchPluginWindows()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CArchPluginWindows::init(void* eventTarget, IEventQueue* events)
|
||||
ArchPluginWindows::init(void* eventTarget, IEventQueue* events)
|
||||
{
|
||||
g_eventTarget = eventTarget;
|
||||
g_events = events;
|
||||
|
||||
CString dir = getPluginsDir();
|
||||
String dir = getPluginsDir();
|
||||
LOG((CLOG_DEBUG "plugins dir: %s", dir.c_str()));
|
||||
|
||||
CString pattern = CString(dir).append("\\*.dll");
|
||||
std::vector<CString> plugins;
|
||||
String pattern = String(dir).append("\\*.dll");
|
||||
std::vector<String> plugins;
|
||||
getFilenames(pattern, plugins);
|
||||
|
||||
std::vector<CString>::iterator it;
|
||||
std::vector<String>::iterator it;
|
||||
for (it = plugins.begin(); it != plugins.end(); ++it)
|
||||
load(*it);
|
||||
}
|
||||
|
||||
void
|
||||
CArchPluginWindows::load(const CString& dllFilename)
|
||||
ArchPluginWindows::load(const String& dllFilename)
|
||||
{
|
||||
LOG((CLOG_DEBUG "loading plugin: %s", dllFilename.c_str()));
|
||||
CString path = CString(getPluginsDir()).append("\\").append(dllFilename);
|
||||
String path = String(getPluginsDir()).append("\\").append(dllFilename);
|
||||
HINSTANCE library = LoadLibrary(path.c_str());
|
||||
if (library == NULL)
|
||||
throw XArch(new XArchEvalWindows);
|
||||
|
@ -71,18 +71,18 @@ CArchPluginWindows::load(const CString& dllFilename)
|
|||
initPlugin(&sendEvent, &log);
|
||||
}
|
||||
|
||||
CString
|
||||
CArchPluginWindows::getModuleDir()
|
||||
String
|
||||
ArchPluginWindows::getModuleDir()
|
||||
{
|
||||
TCHAR c_modulePath[MAX_PATH];
|
||||
if (GetModuleFileName(NULL, c_modulePath, MAX_PATH) == 0) {
|
||||
throw XArch(new XArchEvalWindows);
|
||||
}
|
||||
|
||||
CString modulePath(c_modulePath);
|
||||
String modulePath(c_modulePath);
|
||||
size_t lastSlash = modulePath.find_last_of("\\");
|
||||
|
||||
if (lastSlash != CString::npos) {
|
||||
if (lastSlash != String::npos) {
|
||||
return modulePath.substr(0, lastSlash);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ CArchPluginWindows::getModuleDir()
|
|||
}
|
||||
|
||||
void
|
||||
CArchPluginWindows::getFilenames(const CString& pattern, std::vector<CString>& filenames)
|
||||
ArchPluginWindows::getFilenames(const String& pattern, std::vector<String>& filenames)
|
||||
{
|
||||
WIN32_FIND_DATA data;
|
||||
HANDLE find = FindFirstFile(pattern.c_str(), &data);
|
||||
|
@ -107,7 +107,7 @@ CArchPluginWindows::getFilenames(const CString& pattern, std::vector<CString>& f
|
|||
FindClose(find);
|
||||
}
|
||||
|
||||
CString CArchPluginWindows::getPluginsDir()
|
||||
String ArchPluginWindows::getPluginsDir()
|
||||
{
|
||||
return getModuleDir().append("\\").append(PLUGINS_DIR);
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ void
|
|||
sendEvent(const char* eventName, void* data)
|
||||
{
|
||||
LOG((CLOG_DEBUG5 "plugin sending event"));
|
||||
CEvent::Type type = g_events->getRegisteredType(eventName);
|
||||
g_events->addEvent(CEvent(type, g_eventTarget, data));
|
||||
Event::Type type = g_events->getRegisteredType(eventName);
|
||||
g_events->addEvent(Event(type, g_eventTarget, data));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -23,25 +23,25 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#define ARCH_PLUGIN CArchPluginWindows
|
||||
#define ARCH_PLUGIN ArchPluginWindows
|
||||
|
||||
class CScreen;
|
||||
class Screen;
|
||||
class IEventQueue;
|
||||
|
||||
//! Windows implementation of IArchPlugin
|
||||
class CArchPluginWindows : public IArchPlugin {
|
||||
class ArchPluginWindows : public IArchPlugin {
|
||||
public:
|
||||
CArchPluginWindows();
|
||||
virtual ~CArchPluginWindows();
|
||||
ArchPluginWindows();
|
||||
virtual ~ArchPluginWindows();
|
||||
|
||||
// IArchPlugin overrides
|
||||
void init(void* eventTarget, IEventQueue* events);
|
||||
|
||||
private:
|
||||
CString getModuleDir();
|
||||
void getFilenames(const CString& pattern, std::vector<CString>& filenames);
|
||||
void load(const CString& dllPath);
|
||||
CString getPluginsDir();
|
||||
String getModuleDir();
|
||||
void getFilenames(const String& pattern, std::vector<String>& filenames);
|
||||
void load(const String& dllPath);
|
||||
String getPluginsDir();
|
||||
};
|
||||
|
||||
void sendEvent(const char* text, void* data);
|
||||
|
|
|
@ -21,21 +21,21 @@
|
|||
#include "arch/win32/ArchMultithreadWindows.h"
|
||||
|
||||
//
|
||||
// CArchSleepWindows
|
||||
// ArchSleepWindows
|
||||
//
|
||||
|
||||
CArchSleepWindows::CArchSleepWindows()
|
||||
ArchSleepWindows::ArchSleepWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchSleepWindows::~CArchSleepWindows()
|
||||
ArchSleepWindows::~ArchSleepWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CArchSleepWindows::sleep(double timeout)
|
||||
ArchSleepWindows::sleep(double timeout)
|
||||
{
|
||||
ARCH->testCancelThread();
|
||||
if (timeout < 0.0) {
|
||||
|
@ -46,7 +46,7 @@ CArchSleepWindows::sleep(double timeout)
|
|||
// works if we're using the windows multithread object but
|
||||
// this is windows so that's pretty certain; we'll get a
|
||||
// link error if we're not, though.
|
||||
CArchMultithreadWindows* mt = CArchMultithreadWindows::getInstance();
|
||||
ArchMultithreadWindows* mt = ArchMultithreadWindows::getInstance();
|
||||
if (mt != NULL) {
|
||||
HANDLE cancelEvent = mt->getCancelEventForCurrentThread();
|
||||
WaitForSingleObject(cancelEvent, (DWORD)(1000.0 * timeout));
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchSleep.h"
|
||||
|
||||
#define ARCH_SLEEP CArchSleepWindows
|
||||
#define ARCH_SLEEP ArchSleepWindows
|
||||
|
||||
//! Win32 implementation of IArchSleep
|
||||
class CArchSleepWindows : public IArchSleep {
|
||||
class ArchSleepWindows : public IArchSleep {
|
||||
public:
|
||||
CArchSleepWindows();
|
||||
virtual ~CArchSleepWindows();
|
||||
ArchSleepWindows();
|
||||
virtual ~ArchSleepWindows();
|
||||
|
||||
// IArchSleep overrides
|
||||
virtual void sleep(double timeout);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
//
|
||||
// CArchStringWindows
|
||||
// ArchStringWindows
|
||||
//
|
||||
|
||||
#include "arch/multibyte.h"
|
||||
|
@ -31,16 +31,16 @@
|
|||
#define ARCH_VSNPRINTF _vsnprintf
|
||||
#include "arch/vsnprintf.h"
|
||||
|
||||
CArchStringWindows::CArchStringWindows()
|
||||
ArchStringWindows::ArchStringWindows()
|
||||
{
|
||||
}
|
||||
|
||||
CArchStringWindows::~CArchStringWindows()
|
||||
ArchStringWindows::~ArchStringWindows()
|
||||
{
|
||||
}
|
||||
|
||||
IArchString::EWideCharEncoding
|
||||
CArchStringWindows::getWideCharEncoding()
|
||||
ArchStringWindows::getWideCharEncoding()
|
||||
{
|
||||
return kUTF16;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchString.h"
|
||||
|
||||
#define ARCH_STRING CArchStringWindows
|
||||
#define ARCH_STRING ArchStringWindows
|
||||
|
||||
//! Win32 implementation of IArchString
|
||||
class CArchStringWindows : public IArchString {
|
||||
class ArchStringWindows : public IArchString {
|
||||
public:
|
||||
CArchStringWindows();
|
||||
virtual ~CArchStringWindows();
|
||||
ArchStringWindows();
|
||||
virtual ~ArchStringWindows();
|
||||
|
||||
// IArchString overrides
|
||||
virtual EWideCharEncoding
|
||||
|
|
|
@ -30,21 +30,21 @@ static const char* s_settingsKeyNames[] = {
|
|||
};
|
||||
|
||||
//
|
||||
// CArchSystemWindows
|
||||
// ArchSystemWindows
|
||||
//
|
||||
|
||||
CArchSystemWindows::CArchSystemWindows()
|
||||
ArchSystemWindows::ArchSystemWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CArchSystemWindows::~CArchSystemWindows()
|
||||
ArchSystemWindows::~ArchSystemWindows()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
std::string
|
||||
CArchSystemWindows::getOSName() const
|
||||
ArchSystemWindows::getOSName() const
|
||||
{
|
||||
#if WINVER >= _WIN32_WINNT_WIN2K
|
||||
OSVERSIONINFOEX info;
|
||||
|
@ -96,7 +96,7 @@ CArchSystemWindows::getOSName() const
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchSystemWindows::getPlatformName() const
|
||||
ArchSystemWindows::getPlatformName() const
|
||||
{
|
||||
#ifdef _X86_
|
||||
if(isWOW64())
|
||||
|
@ -113,26 +113,26 @@ CArchSystemWindows::getPlatformName() const
|
|||
}
|
||||
|
||||
std::string
|
||||
CArchSystemWindows::setting(const std::string& valueName) const
|
||||
ArchSystemWindows::setting(const std::string& valueName) const
|
||||
{
|
||||
HKEY key = CArchMiscWindows::openKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
|
||||
HKEY key = ArchMiscWindows::openKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
|
||||
if (key == NULL)
|
||||
return "";
|
||||
|
||||
return CArchMiscWindows::readValueString(key, valueName.c_str());
|
||||
return ArchMiscWindows::readValueString(key, valueName.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
CArchSystemWindows::setting(const std::string& valueName, const std::string& valueString) const
|
||||
ArchSystemWindows::setting(const std::string& valueName, const std::string& valueString) const
|
||||
{
|
||||
HKEY key = CArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
|
||||
HKEY key = ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames);
|
||||
if (key == NULL)
|
||||
throw XArch(std::string("could not access registry key: ") + valueName);
|
||||
CArchMiscWindows::setValue(key, valueName.c_str(), valueString.c_str());
|
||||
ArchMiscWindows::setValue(key, valueName.c_str(), valueString.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
CArchSystemWindows::isWOW64() const
|
||||
ArchSystemWindows::isWOW64() const
|
||||
{
|
||||
#if WINVER >= _WIN32_WINNT_WINXP
|
||||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchSystem.h"
|
||||
|
||||
#define ARCH_SYSTEM CArchSystemWindows
|
||||
#define ARCH_SYSTEM ArchSystemWindows
|
||||
|
||||
//! Win32 implementation of IArchString
|
||||
class CArchSystemWindows : public IArchSystem {
|
||||
class ArchSystemWindows : public IArchSystem {
|
||||
public:
|
||||
CArchSystemWindows();
|
||||
virtual ~CArchSystemWindows();
|
||||
ArchSystemWindows();
|
||||
virtual ~ArchSystemWindows();
|
||||
|
||||
// IArchSystem overrides
|
||||
virtual std::string getOSName() const;
|
||||
|
|
|
@ -33,19 +33,19 @@ static const UINT kNotifyReceiver = WM_USER + 13;
|
|||
static const UINT kFirstReceiverID = WM_USER + 14;
|
||||
|
||||
//
|
||||
// CArchTaskBarWindows
|
||||
// ArchTaskBarWindows
|
||||
//
|
||||
|
||||
CArchTaskBarWindows* CArchTaskBarWindows::s_instance = NULL;
|
||||
ArchTaskBarWindows* ArchTaskBarWindows::s_instance = NULL;
|
||||
|
||||
CArchTaskBarWindows::CArchTaskBarWindows() :
|
||||
ArchTaskBarWindows::ArchTaskBarWindows() :
|
||||
m_nextID(kFirstReceiverID)
|
||||
{
|
||||
// save the singleton instance
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
CArchTaskBarWindows::~CArchTaskBarWindows()
|
||||
ArchTaskBarWindows::~ArchTaskBarWindows()
|
||||
{
|
||||
if (m_thread != NULL) {
|
||||
PostMessage(m_hwnd, WM_QUIT, 0, 0);
|
||||
|
@ -58,7 +58,7 @@ CArchTaskBarWindows::~CArchTaskBarWindows()
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::init()
|
||||
ArchTaskBarWindows::init()
|
||||
{
|
||||
// we need a mutex
|
||||
m_mutex = ARCH->newMutex();
|
||||
|
@ -77,7 +77,7 @@ CArchTaskBarWindows::init()
|
|||
// create a window on the current desktop with the current
|
||||
// thread then the current thread won't be able to switch
|
||||
// desktops if it needs to.
|
||||
m_thread = ARCH->newThread(&CArchTaskBarWindows::threadEntry, this);
|
||||
m_thread = ARCH->newThread(&ArchTaskBarWindows::threadEntry, this);
|
||||
|
||||
// wait for child thread
|
||||
while (!m_ready) {
|
||||
|
@ -89,19 +89,19 @@ CArchTaskBarWindows::init()
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::addDialog(HWND hwnd)
|
||||
ArchTaskBarWindows::addDialog(HWND hwnd)
|
||||
{
|
||||
CArchMiscWindows::addDialog(hwnd);
|
||||
ArchMiscWindows::addDialog(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::removeDialog(HWND hwnd)
|
||||
ArchTaskBarWindows::removeDialog(HWND hwnd)
|
||||
{
|
||||
CArchMiscWindows::removeDialog(hwnd);
|
||||
ArchMiscWindows::removeDialog(hwnd);
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::addReceiver(IArchTaskBarReceiver* receiver)
|
||||
ArchTaskBarWindows::addReceiver(IArchTaskBarReceiver* receiver)
|
||||
{
|
||||
// ignore bogus receiver
|
||||
if (receiver == NULL) {
|
||||
|
@ -109,10 +109,10 @@ CArchTaskBarWindows::addReceiver(IArchTaskBarReceiver* receiver)
|
|||
}
|
||||
|
||||
// add receiver if necessary
|
||||
CReceiverToInfoMap::iterator index = m_receivers.find(receiver);
|
||||
ReceiverToInfoMap::iterator index = m_receivers.find(receiver);
|
||||
if (index == m_receivers.end()) {
|
||||
// add it, creating a new message ID for it
|
||||
CReceiverInfo info;
|
||||
ReceiverInfo info;
|
||||
info.m_id = getNextID();
|
||||
index = m_receivers.insert(std::make_pair(receiver, info)).first;
|
||||
|
||||
|
@ -125,10 +125,10 @@ CArchTaskBarWindows::addReceiver(IArchTaskBarReceiver* receiver)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::removeReceiver(IArchTaskBarReceiver* receiver)
|
||||
ArchTaskBarWindows::removeReceiver(IArchTaskBarReceiver* receiver)
|
||||
{
|
||||
// find receiver
|
||||
CReceiverToInfoMap::iterator index = m_receivers.find(receiver);
|
||||
ReceiverToInfoMap::iterator index = m_receivers.find(receiver);
|
||||
if (index == m_receivers.end()) {
|
||||
return;
|
||||
}
|
||||
|
@ -145,10 +145,10 @@ CArchTaskBarWindows::removeReceiver(IArchTaskBarReceiver* receiver)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::updateReceiver(IArchTaskBarReceiver* receiver)
|
||||
ArchTaskBarWindows::updateReceiver(IArchTaskBarReceiver* receiver)
|
||||
{
|
||||
// find receiver
|
||||
CReceiverToInfoMap::const_iterator index = m_receivers.find(receiver);
|
||||
ReceiverToInfoMap::const_iterator index = m_receivers.find(receiver);
|
||||
if (index == m_receivers.end()) {
|
||||
return;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ CArchTaskBarWindows::updateReceiver(IArchTaskBarReceiver* receiver)
|
|||
}
|
||||
|
||||
UINT
|
||||
CArchTaskBarWindows::getNextID()
|
||||
ArchTaskBarWindows::getNextID()
|
||||
{
|
||||
if (m_oldIDs.empty()) {
|
||||
return m_nextID++;
|
||||
|
@ -169,13 +169,13 @@ CArchTaskBarWindows::getNextID()
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::recycleID(UINT id)
|
||||
ArchTaskBarWindows::recycleID(UINT id)
|
||||
{
|
||||
m_oldIDs.push_back(id);
|
||||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::addIcon(UINT id)
|
||||
ArchTaskBarWindows::addIcon(UINT id)
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
CIDToReceiverMap::const_iterator index = m_idTable.find(id);
|
||||
|
@ -186,7 +186,7 @@ CArchTaskBarWindows::addIcon(UINT id)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::removeIcon(UINT id)
|
||||
ArchTaskBarWindows::removeIcon(UINT id)
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
removeIconNoLock(id);
|
||||
|
@ -194,7 +194,7 @@ CArchTaskBarWindows::removeIcon(UINT id)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::updateIcon(UINT id)
|
||||
ArchTaskBarWindows::updateIcon(UINT id)
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
CIDToReceiverMap::const_iterator index = m_idTable.find(id);
|
||||
|
@ -205,10 +205,10 @@ CArchTaskBarWindows::updateIcon(UINT id)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::addAllIcons()
|
||||
ArchTaskBarWindows::addAllIcons()
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
for (CReceiverToInfoMap::const_iterator index = m_receivers.begin();
|
||||
for (ReceiverToInfoMap::const_iterator index = m_receivers.begin();
|
||||
index != m_receivers.end(); ++index) {
|
||||
modifyIconNoLock(index, NIM_ADD);
|
||||
}
|
||||
|
@ -216,10 +216,10 @@ CArchTaskBarWindows::addAllIcons()
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::removeAllIcons()
|
||||
ArchTaskBarWindows::removeAllIcons()
|
||||
{
|
||||
ARCH->lockMutex(m_mutex);
|
||||
for (CReceiverToInfoMap::const_iterator index = m_receivers.begin();
|
||||
for (ReceiverToInfoMap::const_iterator index = m_receivers.begin();
|
||||
index != m_receivers.end(); ++index) {
|
||||
removeIconNoLock(index->second.m_id);
|
||||
}
|
||||
|
@ -227,8 +227,8 @@ CArchTaskBarWindows::removeAllIcons()
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::modifyIconNoLock(
|
||||
CReceiverToInfoMap::const_iterator index, DWORD taskBarMessage)
|
||||
ArchTaskBarWindows::modifyIconNoLock(
|
||||
ReceiverToInfoMap::const_iterator index, DWORD taskBarMessage)
|
||||
{
|
||||
// get receiver
|
||||
UINT id = index->second.m_id;
|
||||
|
@ -274,7 +274,7 @@ CArchTaskBarWindows::modifyIconNoLock(
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::removeIconNoLock(UINT id)
|
||||
ArchTaskBarWindows::removeIconNoLock(UINT id)
|
||||
{
|
||||
NOTIFYICONDATA data;
|
||||
data.cbSize = sizeof(NOTIFYICONDATA);
|
||||
|
@ -286,7 +286,7 @@ CArchTaskBarWindows::removeIconNoLock(UINT id)
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::handleIconMessage(
|
||||
ArchTaskBarWindows::handleIconMessage(
|
||||
IArchTaskBarReceiver* receiver, LPARAM lParam)
|
||||
{
|
||||
// process message
|
||||
|
@ -317,7 +317,7 @@ CArchTaskBarWindows::handleIconMessage(
|
|||
}
|
||||
|
||||
bool
|
||||
CArchTaskBarWindows::processDialogs(MSG* msg)
|
||||
ArchTaskBarWindows::processDialogs(MSG* msg)
|
||||
{
|
||||
// only one thread can be in this method on any particular object
|
||||
// at any given time. that's not a problem since only our event
|
||||
|
@ -329,7 +329,7 @@ CArchTaskBarWindows::processDialogs(MSG* msg)
|
|||
m_dialogs.erase(false);
|
||||
|
||||
// merge added dialogs into the dialog list
|
||||
for (CDialogs::const_iterator index = m_addedDialogs.begin();
|
||||
for (Dialogs::const_iterator index = m_addedDialogs.begin();
|
||||
index != m_addedDialogs.end(); ++index) {
|
||||
m_dialogs.insert(std::make_pair(index->first, index->second));
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ CArchTaskBarWindows::processDialogs(MSG* msg)
|
|||
// removeDialog() don't change the map itself (just the
|
||||
// values of some elements).
|
||||
ARCH->lockMutex(m_mutex);
|
||||
for (CDialogs::const_iterator index = m_dialogs.begin();
|
||||
for (Dialogs::const_iterator index = m_dialogs.begin();
|
||||
index != m_dialogs.end(); ++index) {
|
||||
if (index->second) {
|
||||
ARCH->unlockMutex(m_mutex);
|
||||
|
@ -360,7 +360,7 @@ CArchTaskBarWindows::processDialogs(MSG* msg)
|
|||
}
|
||||
|
||||
LRESULT
|
||||
CArchTaskBarWindows::wndProc(HWND hwnd,
|
||||
ArchTaskBarWindows::wndProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
|
@ -399,16 +399,16 @@ CArchTaskBarWindows::wndProc(HWND hwnd,
|
|||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
CArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
||||
ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// if msg is WM_NCCREATE, extract the CArchTaskBarWindows* and put
|
||||
// if msg is WM_NCCREATE, extract the ArchTaskBarWindows* and put
|
||||
// it in the extra window data then forward the call.
|
||||
CArchTaskBarWindows* self = NULL;
|
||||
ArchTaskBarWindows* self = NULL;
|
||||
if (msg == WM_NCCREATE) {
|
||||
CREATESTRUCT* createInfo;
|
||||
createInfo = reinterpret_cast<CREATESTRUCT*>(lParam);
|
||||
self = reinterpret_cast<CArchTaskBarWindows*>(
|
||||
self = reinterpret_cast<ArchTaskBarWindows*>(
|
||||
createInfo->lpCreateParams);
|
||||
SetWindowLong(hwnd, 0, reinterpret_cast<LONG>(self));
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ CArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
|||
// get the extra window data and forward the call
|
||||
LONG data = GetWindowLong(hwnd, 0);
|
||||
if (data != 0) {
|
||||
self = reinterpret_cast<CArchTaskBarWindows*>(
|
||||
self = reinterpret_cast<ArchTaskBarWindows*>(
|
||||
reinterpret_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ CArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
|||
}
|
||||
|
||||
void
|
||||
CArchTaskBarWindows::threadMainLoop()
|
||||
ArchTaskBarWindows::threadMainLoop()
|
||||
{
|
||||
// register the task bar restart message
|
||||
m_taskBarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
|
||||
|
@ -440,9 +440,9 @@ CArchTaskBarWindows::threadMainLoop()
|
|||
WNDCLASSEX classInfo;
|
||||
classInfo.cbSize = sizeof(classInfo);
|
||||
classInfo.style = CS_NOCLOSE;
|
||||
classInfo.lpfnWndProc = &CArchTaskBarWindows::staticWndProc;
|
||||
classInfo.lpfnWndProc = &ArchTaskBarWindows::staticWndProc;
|
||||
classInfo.cbClsExtra = 0;
|
||||
classInfo.cbWndExtra = sizeof(CArchTaskBarWindows*);
|
||||
classInfo.cbWndExtra = sizeof(ArchTaskBarWindows*);
|
||||
classInfo.hInstance = instanceWin32();
|
||||
classInfo.hIcon = NULL;
|
||||
classInfo.hCursor = NULL;
|
||||
|
@ -491,13 +491,13 @@ CArchTaskBarWindows::threadMainLoop()
|
|||
}
|
||||
|
||||
void*
|
||||
CArchTaskBarWindows::threadEntry(void* self)
|
||||
ArchTaskBarWindows::threadEntry(void* self)
|
||||
{
|
||||
reinterpret_cast<CArchTaskBarWindows*>(self)->threadMainLoop();
|
||||
reinterpret_cast<ArchTaskBarWindows*>(self)->threadMainLoop();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HINSTANCE CArchTaskBarWindows::instanceWin32()
|
||||
HINSTANCE ArchTaskBarWindows::instanceWin32()
|
||||
{
|
||||
return CArchMiscWindows::instanceWin32();
|
||||
return ArchMiscWindows::instanceWin32();
|
||||
}
|
|
@ -26,13 +26,13 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#define ARCH_TASKBAR CArchTaskBarWindows
|
||||
#define ARCH_TASKBAR ArchTaskBarWindows
|
||||
|
||||
//! Win32 implementation of IArchTaskBar
|
||||
class CArchTaskBarWindows : public IArchTaskBar {
|
||||
class ArchTaskBarWindows : public IArchTaskBar {
|
||||
public:
|
||||
CArchTaskBarWindows();
|
||||
virtual ~CArchTaskBarWindows();
|
||||
ArchTaskBarWindows();
|
||||
virtual ~ArchTaskBarWindows();
|
||||
|
||||
virtual void init();
|
||||
|
||||
|
@ -56,15 +56,15 @@ public:
|
|||
virtual void updateReceiver(IArchTaskBarReceiver*);
|
||||
|
||||
private:
|
||||
class CReceiverInfo {
|
||||
class ReceiverInfo {
|
||||
public:
|
||||
UINT m_id;
|
||||
};
|
||||
|
||||
typedef std::map<IArchTaskBarReceiver*, CReceiverInfo> CReceiverToInfoMap;
|
||||
typedef std::map<UINT, CReceiverToInfoMap::iterator> CIDToReceiverMap;
|
||||
typedef std::map<IArchTaskBarReceiver*, ReceiverInfo> ReceiverToInfoMap;
|
||||
typedef std::map<UINT, ReceiverToInfoMap::iterator> CIDToReceiverMap;
|
||||
typedef std::vector<UINT> CIDStack;
|
||||
typedef std::map<HWND, bool> CDialogs;
|
||||
typedef std::map<HWND, bool> Dialogs;
|
||||
|
||||
UINT getNextID();
|
||||
void recycleID(UINT);
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
void updateIcon(UINT);
|
||||
void addAllIcons();
|
||||
void removeAllIcons();
|
||||
void modifyIconNoLock(CReceiverToInfoMap::const_iterator,
|
||||
void modifyIconNoLock(ReceiverToInfoMap::const_iterator,
|
||||
DWORD taskBarMessage);
|
||||
void removeIconNoLock(UINT id);
|
||||
void handleIconMessage(IArchTaskBarReceiver*, LPARAM);
|
||||
|
@ -89,26 +89,26 @@ private:
|
|||
HINSTANCE instanceWin32();
|
||||
|
||||
private:
|
||||
static CArchTaskBarWindows* s_instance;
|
||||
static ArchTaskBarWindows* s_instance;
|
||||
|
||||
// multithread data
|
||||
CArchMutex m_mutex;
|
||||
CArchCond m_condVar;
|
||||
ArchMutex m_mutex;
|
||||
ArchCond m_condVar;
|
||||
bool m_ready;
|
||||
int m_result;
|
||||
CArchThread m_thread;
|
||||
ArchThread m_thread;
|
||||
|
||||
// child thread data
|
||||
HWND m_hwnd;
|
||||
UINT m_taskBarRestart;
|
||||
|
||||
// shared data
|
||||
CReceiverToInfoMap m_receivers;
|
||||
ReceiverToInfoMap m_receivers;
|
||||
CIDToReceiverMap m_idTable;
|
||||
CIDStack m_oldIDs;
|
||||
UINT m_nextID;
|
||||
|
||||
// dialogs
|
||||
CDialogs m_dialogs;
|
||||
CDialogs m_addedDialogs;
|
||||
Dialogs m_dialogs;
|
||||
Dialogs m_addedDialogs;
|
||||
};
|
||||
|
|
|
@ -41,10 +41,10 @@ static PTimeGetTime s_tgt = NULL;
|
|||
|
||||
|
||||
//
|
||||
// CArchTimeWindows
|
||||
// ArchTimeWindows
|
||||
//
|
||||
|
||||
CArchTimeWindows::CArchTimeWindows()
|
||||
ArchTimeWindows::ArchTimeWindows()
|
||||
{
|
||||
assert(s_freq == 0.0 || s_mmInstance == NULL);
|
||||
|
||||
|
@ -61,7 +61,7 @@ CArchTimeWindows::CArchTimeWindows()
|
|||
}
|
||||
}
|
||||
|
||||
CArchTimeWindows::~CArchTimeWindows()
|
||||
ArchTimeWindows::~ArchTimeWindows()
|
||||
{
|
||||
s_freq = 0.0;
|
||||
if (s_mmInstance == NULL) {
|
||||
|
@ -72,7 +72,7 @@ CArchTimeWindows::~CArchTimeWindows()
|
|||
}
|
||||
|
||||
double
|
||||
CArchTimeWindows::time()
|
||||
ArchTimeWindows::time()
|
||||
{
|
||||
// get time. we try three ways, in order of descending precision
|
||||
if (s_freq != 0.0) {
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
|
||||
#include "arch/IArchTime.h"
|
||||
|
||||
#define ARCH_TIME CArchTimeWindows
|
||||
#define ARCH_TIME ArchTimeWindows
|
||||
|
||||
//! Win32 implementation of IArchTime
|
||||
class CArchTimeWindows : public IArchTime {
|
||||
class ArchTimeWindows : public IArchTime {
|
||||
public:
|
||||
CArchTimeWindows();
|
||||
virtual ~CArchTimeWindows();
|
||||
ArchTimeWindows();
|
||||
virtual ~ArchTimeWindows();
|
||||
|
||||
// IArchTime overrides
|
||||
virtual double time();
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#include "base/EventQueue.h"
|
||||
|
||||
//
|
||||
// CEvent
|
||||
// Event
|
||||
//
|
||||
|
||||
CEvent::CEvent() :
|
||||
Event::Event() :
|
||||
m_type(kUnknown),
|
||||
m_target(NULL),
|
||||
m_data(NULL),
|
||||
|
@ -33,7 +33,7 @@ CEvent::CEvent() :
|
|||
// do nothing
|
||||
}
|
||||
|
||||
CEvent::CEvent(Type type, void* target, void* data, Flags flags) :
|
||||
Event::Event(Type type, void* target, void* data, Flags flags) :
|
||||
m_type(type),
|
||||
m_target(target),
|
||||
m_data(data),
|
||||
|
@ -43,38 +43,38 @@ CEvent::CEvent(Type type, void* target, void* data, Flags flags) :
|
|||
// do nothing
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEvent::getType() const
|
||||
Event::Type
|
||||
Event::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void*
|
||||
CEvent::getTarget() const
|
||||
Event::getTarget() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
void*
|
||||
CEvent::getData() const
|
||||
Event::getData() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
CEventData*
|
||||
CEvent::getDataObject() const
|
||||
EventData*
|
||||
Event::getDataObject() const
|
||||
{
|
||||
return m_dataObject;
|
||||
}
|
||||
|
||||
CEvent::Flags
|
||||
CEvent::getFlags() const
|
||||
Event::Flags
|
||||
Event::getFlags() const
|
||||
{
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
void
|
||||
CEvent::deleteData(const CEvent& event)
|
||||
Event::deleteData(const Event& event)
|
||||
{
|
||||
switch (event.getType()) {
|
||||
case kUnknown:
|
||||
|
@ -93,7 +93,7 @@ CEvent::deleteData(const CEvent& event)
|
|||
}
|
||||
|
||||
void
|
||||
CEvent::setDataObject(CEventData* dataObject)
|
||||
Event::setDataObject(EventData* dataObject)
|
||||
{
|
||||
assert(m_dataObject == nullptr);
|
||||
m_dataObject = dataObject;
|
||||
|
|
|
@ -21,17 +21,17 @@
|
|||
#include "common/basic_types.h"
|
||||
#include "common/stdmap.h"
|
||||
|
||||
class CEventData {
|
||||
class EventData {
|
||||
public:
|
||||
CEventData() { }
|
||||
virtual ~CEventData() { }
|
||||
EventData() { }
|
||||
virtual ~EventData() { }
|
||||
};
|
||||
|
||||
//! Event
|
||||
/*!
|
||||
A \c CEvent holds an event type and a pointer to event data.
|
||||
A \c Event holds an event type and a pointer to event data.
|
||||
*/
|
||||
class CEvent {
|
||||
class Event {
|
||||
public:
|
||||
typedef UInt32 Type;
|
||||
enum {
|
||||
|
@ -49,9 +49,9 @@ public:
|
|||
kDontFreeData = 0x02 //!< Don't free data in deleteData
|
||||
};
|
||||
|
||||
CEvent();
|
||||
Event();
|
||||
|
||||
//! Create \c CEvent with data (POD)
|
||||
//! Create \c Event with data (POD)
|
||||
/*!
|
||||
The \p data must be POD (plain old data) allocated by malloc(),
|
||||
which means it cannot have a constructor, destructor or be
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
\p target is the intended recipient of the event.
|
||||
\p flags is any combination of \c Flags.
|
||||
*/
|
||||
CEvent(Type type, void* target = NULL, void* data = NULL,
|
||||
Event(Type type, void* target = NULL, void* data = NULL,
|
||||
Flags flags = kNone);
|
||||
|
||||
//! @name manipulators
|
||||
|
@ -70,14 +70,14 @@ public:
|
|||
/*!
|
||||
Deletes event data for the given event (using free()).
|
||||
*/
|
||||
static void deleteData(const CEvent&);
|
||||
static void deleteData(const Event&);
|
||||
|
||||
//! Set data (non-POD)
|
||||
/*!
|
||||
Set non-POD (non plain old data), where delete is called when the event
|
||||
is deleted, and the destructor is called.
|
||||
*/
|
||||
void setDataObject(CEventData* dataObject);
|
||||
void setDataObject(EventData* dataObject);
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
\c getData() is that when delete is called on this data, so non-POD
|
||||
(non plain old data) dtor is called.
|
||||
*/
|
||||
CEventData* getDataObject() const;
|
||||
EventData* getDataObject() const;
|
||||
|
||||
//! Get event flags
|
||||
/*!
|
||||
|
@ -122,5 +122,5 @@ private:
|
|||
void* m_target;
|
||||
void* m_data;
|
||||
Flags m_flags;
|
||||
CEventData* m_dataObject;
|
||||
EventData* m_dataObject;
|
||||
};
|
||||
|
|
|
@ -28,21 +28,21 @@
|
|||
#include "base/Log.h"
|
||||
#include "base/XBase.h"
|
||||
|
||||
EVENT_TYPE_ACCESSOR(CClient)
|
||||
EVENT_TYPE_ACCESSOR(Client)
|
||||
EVENT_TYPE_ACCESSOR(IStream)
|
||||
EVENT_TYPE_ACCESSOR(CIpcClient)
|
||||
EVENT_TYPE_ACCESSOR(CIpcClientProxy)
|
||||
EVENT_TYPE_ACCESSOR(CIpcServer)
|
||||
EVENT_TYPE_ACCESSOR(CIpcServerProxy)
|
||||
EVENT_TYPE_ACCESSOR(IpcClient)
|
||||
EVENT_TYPE_ACCESSOR(IpcClientProxy)
|
||||
EVENT_TYPE_ACCESSOR(IpcServer)
|
||||
EVENT_TYPE_ACCESSOR(IpcServerProxy)
|
||||
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(OSXScreen)
|
||||
EVENT_TYPE_ACCESSOR(ClientListener)
|
||||
EVENT_TYPE_ACCESSOR(ClientProxy)
|
||||
EVENT_TYPE_ACCESSOR(ClientProxyUnknown)
|
||||
EVENT_TYPE_ACCESSOR(Server)
|
||||
EVENT_TYPE_ACCESSOR(ServerApp)
|
||||
EVENT_TYPE_ACCESSOR(IKeyState)
|
||||
EVENT_TYPE_ACCESSOR(IPrimaryScreen)
|
||||
EVENT_TYPE_ACCESSOR(IScreen)
|
||||
|
@ -50,89 +50,89 @@ EVENT_TYPE_ACCESSOR(IScreen)
|
|||
// interrupt handler. this just adds a quit event to the queue.
|
||||
static
|
||||
void
|
||||
interrupt(CArch::ESignal, void* data)
|
||||
interrupt(Arch::ESignal, void* data)
|
||||
{
|
||||
CEventQueue* events = reinterpret_cast<CEventQueue*>(data);
|
||||
events->addEvent(CEvent(CEvent::kQuit));
|
||||
EventQueue* events = reinterpret_cast<EventQueue*>(data);
|
||||
events->addEvent(Event(Event::kQuit));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// CEventQueue
|
||||
// EventQueue
|
||||
//
|
||||
|
||||
CEventQueue::CEventQueue() :
|
||||
EventQueue::EventQueue() :
|
||||
m_systemTarget(0),
|
||||
m_nextType(CEvent::kLast),
|
||||
m_typesForCClient(NULL),
|
||||
m_nextType(Event::kLast),
|
||||
m_typesForClient(NULL),
|
||||
m_typesForIStream(NULL),
|
||||
m_typesForCIpcClient(NULL),
|
||||
m_typesForCIpcClientProxy(NULL),
|
||||
m_typesForCIpcServer(NULL),
|
||||
m_typesForCIpcServerProxy(NULL),
|
||||
m_typesForIpcClient(NULL),
|
||||
m_typesForIpcClientProxy(NULL),
|
||||
m_typesForIpcServer(NULL),
|
||||
m_typesForIpcServerProxy(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_typesForOSXScreen(NULL),
|
||||
m_typesForClientListener(NULL),
|
||||
m_typesForClientProxy(NULL),
|
||||
m_typesForClientProxyUnknown(NULL),
|
||||
m_typesForServer(NULL),
|
||||
m_typesForServerApp(NULL),
|
||||
m_typesForIKeyState(NULL),
|
||||
m_typesForIPrimaryScreen(NULL),
|
||||
m_typesForIScreen(NULL),
|
||||
m_readyMutex(new CMutex),
|
||||
m_readyCondVar(new CCondVar<bool>(m_readyMutex, false))
|
||||
m_readyMutex(new Mutex),
|
||||
m_readyCondVar(new CondVar<bool>(m_readyMutex, false))
|
||||
{
|
||||
m_mutex = ARCH->newMutex();
|
||||
ARCH->setSignalHandler(CArch::kINTERRUPT, &interrupt, this);
|
||||
ARCH->setSignalHandler(CArch::kTERMINATE, &interrupt, this);
|
||||
m_buffer = new CSimpleEventQueueBuffer;
|
||||
ARCH->setSignalHandler(Arch::kINTERRUPT, &interrupt, this);
|
||||
ARCH->setSignalHandler(Arch::kTERMINATE, &interrupt, this);
|
||||
m_buffer = new SimpleEventQueueBuffer;
|
||||
}
|
||||
|
||||
CEventQueue::~CEventQueue()
|
||||
EventQueue::~EventQueue()
|
||||
{
|
||||
delete m_buffer;
|
||||
delete m_readyCondVar;
|
||||
delete m_readyMutex;
|
||||
|
||||
ARCH->setSignalHandler(CArch::kINTERRUPT, NULL, NULL);
|
||||
ARCH->setSignalHandler(CArch::kTERMINATE, NULL, NULL);
|
||||
ARCH->setSignalHandler(Arch::kINTERRUPT, NULL, NULL);
|
||||
ARCH->setSignalHandler(Arch::kTERMINATE, NULL, NULL);
|
||||
ARCH->closeMutex(m_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::loop()
|
||||
EventQueue::loop()
|
||||
{
|
||||
m_buffer->init();
|
||||
{
|
||||
CLock lock(m_readyMutex);
|
||||
Lock lock(m_readyMutex);
|
||||
*m_readyCondVar = true;
|
||||
m_readyCondVar->signal();
|
||||
}
|
||||
LOG((CLOG_DEBUG "event queue is ready"));
|
||||
while (!m_pending.empty()) {
|
||||
LOG((CLOG_DEBUG "add pending events to buffer"));
|
||||
CEvent& event = m_pending.front();
|
||||
Event& event = m_pending.front();
|
||||
addEventToBuffer(event);
|
||||
m_pending.pop();
|
||||
}
|
||||
|
||||
CEvent event;
|
||||
Event event;
|
||||
getEvent(event);
|
||||
while (event.getType() != CEvent::kQuit) {
|
||||
while (event.getType() != Event::kQuit) {
|
||||
dispatchEvent(event);
|
||||
CEvent::deleteData(event);
|
||||
Event::deleteData(event);
|
||||
getEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEventQueue::registerTypeOnce(CEvent::Type& type, const char* name)
|
||||
Event::Type
|
||||
EventQueue::registerTypeOnce(Event::Type& type, const char* name)
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
if (type == CEvent::kUnknown) {
|
||||
ArchMutexLock lock(m_mutex);
|
||||
if (type == Event::kUnknown) {
|
||||
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));
|
||||
|
@ -142,23 +142,23 @@ CEventQueue::registerTypeOnce(CEvent::Type& type, const char* name)
|
|||
}
|
||||
|
||||
const char*
|
||||
CEventQueue::getTypeName(CEvent::Type type)
|
||||
EventQueue::getTypeName(Event::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case CEvent::kUnknown:
|
||||
case Event::kUnknown:
|
||||
return "nil";
|
||||
|
||||
case CEvent::kQuit:
|
||||
case Event::kQuit:
|
||||
return "quit";
|
||||
|
||||
case CEvent::kSystem:
|
||||
case Event::kSystem:
|
||||
return "system";
|
||||
|
||||
case CEvent::kTimer:
|
||||
case Event::kTimer:
|
||||
return "timer";
|
||||
|
||||
default:
|
||||
CTypeMap::const_iterator i = m_typeMap.find(type);
|
||||
TypeMap::const_iterator i = m_typeMap.find(type);
|
||||
if (i == m_typeMap.end()) {
|
||||
return "<unknown>";
|
||||
}
|
||||
|
@ -169,9 +169,9 @@ CEventQueue::getTypeName(CEvent::Type type)
|
|||
}
|
||||
|
||||
void
|
||||
CEventQueue::adoptBuffer(IEventQueueBuffer* buffer)
|
||||
EventQueue::adoptBuffer(IEventQueueBuffer* buffer)
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
|
||||
LOG((CLOG_DEBUG "adopting new buffer"));
|
||||
|
||||
|
@ -183,8 +183,8 @@ CEventQueue::adoptBuffer(IEventQueueBuffer* buffer)
|
|||
|
||||
// discard old buffer and old events
|
||||
delete m_buffer;
|
||||
for (CEventTable::iterator i = m_events.begin(); i != m_events.end(); ++i) {
|
||||
CEvent::deleteData(i->second);
|
||||
for (EventTable::iterator i = m_events.begin(); i != m_events.end(); ++i) {
|
||||
Event::deleteData(i->second);
|
||||
}
|
||||
m_events.clear();
|
||||
m_oldEventIDs.clear();
|
||||
|
@ -192,14 +192,14 @@ CEventQueue::adoptBuffer(IEventQueueBuffer* buffer)
|
|||
// use new buffer
|
||||
m_buffer = buffer;
|
||||
if (m_buffer == NULL) {
|
||||
m_buffer = new CSimpleEventQueueBuffer;
|
||||
m_buffer = new SimpleEventQueueBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CEventQueue::getEvent(CEvent& event, double timeout)
|
||||
EventQueue::getEvent(Event& event, double timeout)
|
||||
{
|
||||
CStopwatch timer(true);
|
||||
Stopwatch timer(true);
|
||||
retry:
|
||||
// if no events are waiting then handle timers and then wait
|
||||
while (m_buffer->isEmpty()) {
|
||||
|
@ -244,7 +244,7 @@ retry:
|
|||
|
||||
case IEventQueueBuffer::kUser:
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
event = removeEvent(dataID);
|
||||
return true;
|
||||
}
|
||||
|
@ -256,12 +256,12 @@ retry:
|
|||
}
|
||||
|
||||
bool
|
||||
CEventQueue::dispatchEvent(const CEvent& event)
|
||||
EventQueue::dispatchEvent(const Event& event)
|
||||
{
|
||||
void* target = event.getTarget();
|
||||
IEventJob* job = getHandler(event.getType(), target);
|
||||
if (job == NULL) {
|
||||
job = getHandler(CEvent::kUnknown, target);
|
||||
job = getHandler(Event::kUnknown, target);
|
||||
}
|
||||
if (job != NULL) {
|
||||
job->run(event);
|
||||
|
@ -271,22 +271,22 @@ CEventQueue::dispatchEvent(const CEvent& event)
|
|||
}
|
||||
|
||||
void
|
||||
CEventQueue::addEvent(const CEvent& event)
|
||||
EventQueue::addEvent(const Event& event)
|
||||
{
|
||||
// discard bogus event types
|
||||
switch (event.getType()) {
|
||||
case CEvent::kUnknown:
|
||||
case CEvent::kSystem:
|
||||
case CEvent::kTimer:
|
||||
case Event::kUnknown:
|
||||
case Event::kSystem:
|
||||
case Event::kTimer:
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((event.getFlags() & CEvent::kDeliverImmediately) != 0) {
|
||||
if ((event.getFlags() & Event::kDeliverImmediately) != 0) {
|
||||
dispatchEvent(event);
|
||||
CEvent::deleteData(event);
|
||||
Event::deleteData(event);
|
||||
}
|
||||
else if (!(*m_readyCondVar)) {
|
||||
m_pending.push(event);
|
||||
|
@ -297,9 +297,9 @@ CEventQueue::addEvent(const CEvent& event)
|
|||
}
|
||||
|
||||
void
|
||||
CEventQueue::addEventToBuffer(const CEvent& event)
|
||||
EventQueue::addEventToBuffer(const Event& event)
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
|
||||
// store the event's data locally
|
||||
UInt32 eventID = saveEvent(event);
|
||||
|
@ -308,60 +308,60 @@ CEventQueue::addEventToBuffer(const CEvent& event)
|
|||
if (!m_buffer->addEvent(eventID)) {
|
||||
// failed to send event
|
||||
removeEvent(eventID);
|
||||
CEvent::deleteData(event);
|
||||
Event::deleteData(event);
|
||||
}
|
||||
}
|
||||
|
||||
CEventQueueTimer*
|
||||
CEventQueue::newTimer(double duration, void* target)
|
||||
EventQueueTimer*
|
||||
EventQueue::newTimer(double duration, void* target)
|
||||
{
|
||||
assert(duration > 0.0);
|
||||
|
||||
CEventQueueTimer* timer = m_buffer->newTimer(duration, false);
|
||||
EventQueueTimer* timer = m_buffer->newTimer(duration, false);
|
||||
if (target == NULL) {
|
||||
target = timer;
|
||||
}
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
m_timers.insert(timer);
|
||||
// initial duration is requested duration plus whatever's on
|
||||
// the clock currently because the latter will be subtracted
|
||||
// the next time we check for timers.
|
||||
m_timerQueue.push(CTimer(timer, duration,
|
||||
m_timerQueue.push(Timer(timer, duration,
|
||||
duration + m_time.getTime(), target, false));
|
||||
return timer;
|
||||
}
|
||||
|
||||
CEventQueueTimer*
|
||||
CEventQueue::newOneShotTimer(double duration, void* target)
|
||||
EventQueueTimer*
|
||||
EventQueue::newOneShotTimer(double duration, void* target)
|
||||
{
|
||||
assert(duration > 0.0);
|
||||
|
||||
CEventQueueTimer* timer = m_buffer->newTimer(duration, true);
|
||||
EventQueueTimer* timer = m_buffer->newTimer(duration, true);
|
||||
if (target == NULL) {
|
||||
target = timer;
|
||||
}
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
m_timers.insert(timer);
|
||||
// initial duration is requested duration plus whatever's on
|
||||
// the clock currently because the latter will be subtracted
|
||||
// the next time we check for timers.
|
||||
m_timerQueue.push(CTimer(timer, duration,
|
||||
m_timerQueue.push(Timer(timer, duration,
|
||||
duration + m_time.getTime(), target, true));
|
||||
return timer;
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::deleteTimer(CEventQueueTimer* timer)
|
||||
EventQueue::deleteTimer(EventQueueTimer* timer)
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
for (CTimerQueue::iterator index = m_timerQueue.begin();
|
||||
ArchMutexLock lock(m_mutex);
|
||||
for (TimerQueue::iterator index = m_timerQueue.begin();
|
||||
index != m_timerQueue.end(); ++index) {
|
||||
if (index->getTimer() == timer) {
|
||||
m_timerQueue.erase(index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
CTimers::iterator index = m_timers.find(timer);
|
||||
Timers::iterator index = m_timers.find(timer);
|
||||
if (index != m_timers.end()) {
|
||||
m_timers.erase(index);
|
||||
}
|
||||
|
@ -369,24 +369,24 @@ CEventQueue::deleteTimer(CEventQueueTimer* timer)
|
|||
}
|
||||
|
||||
void
|
||||
CEventQueue::adoptHandler(CEvent::Type type, void* target, IEventJob* handler)
|
||||
EventQueue::adoptHandler(Event::Type type, void* target, IEventJob* handler)
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
IEventJob*& job = m_handlers[target][type];
|
||||
delete job;
|
||||
job = handler;
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::removeHandler(CEvent::Type type, void* target)
|
||||
EventQueue::removeHandler(Event::Type type, void* target)
|
||||
{
|
||||
IEventJob* handler = NULL;
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
CHandlerTable::iterator index = m_handlers.find(target);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
CTypeHandlerTable& typeHandlers = index->second;
|
||||
CTypeHandlerTable::iterator index2 = typeHandlers.find(type);
|
||||
TypeHandlerTable& typeHandlers = index->second;
|
||||
TypeHandlerTable::iterator index2 = typeHandlers.find(type);
|
||||
if (index2 != typeHandlers.end()) {
|
||||
handler = index2->second;
|
||||
typeHandlers.erase(index2);
|
||||
|
@ -397,16 +397,16 @@ CEventQueue::removeHandler(CEvent::Type type, void* target)
|
|||
}
|
||||
|
||||
void
|
||||
CEventQueue::removeHandlers(void* target)
|
||||
EventQueue::removeHandlers(void* target)
|
||||
{
|
||||
std::vector<IEventJob*> handlers;
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
CHandlerTable::iterator index = m_handlers.find(target);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
HandlerTable::iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
// copy to handlers array and clear table for target
|
||||
CTypeHandlerTable& typeHandlers = index->second;
|
||||
for (CTypeHandlerTable::iterator index2 = typeHandlers.begin();
|
||||
TypeHandlerTable& typeHandlers = index->second;
|
||||
for (TypeHandlerTable::iterator index2 = typeHandlers.begin();
|
||||
index2 != typeHandlers.end(); ++index2) {
|
||||
handlers.push_back(index2->second);
|
||||
}
|
||||
|
@ -422,19 +422,19 @@ CEventQueue::removeHandlers(void* target)
|
|||
}
|
||||
|
||||
bool
|
||||
CEventQueue::isEmpty() const
|
||||
EventQueue::isEmpty() const
|
||||
{
|
||||
return (m_buffer->isEmpty() && getNextTimerTimeout() != 0.0);
|
||||
}
|
||||
|
||||
IEventJob*
|
||||
CEventQueue::getHandler(CEvent::Type type, void* target) const
|
||||
EventQueue::getHandler(Event::Type type, void* target) const
|
||||
{
|
||||
CArchMutexLock lock(m_mutex);
|
||||
CHandlerTable::const_iterator index = m_handlers.find(target);
|
||||
ArchMutexLock lock(m_mutex);
|
||||
HandlerTable::const_iterator index = m_handlers.find(target);
|
||||
if (index != m_handlers.end()) {
|
||||
const CTypeHandlerTable& typeHandlers = index->second;
|
||||
CTypeHandlerTable::const_iterator index2 = typeHandlers.find(type);
|
||||
const TypeHandlerTable& typeHandlers = index->second;
|
||||
TypeHandlerTable::const_iterator index2 = typeHandlers.find(type);
|
||||
if (index2 != typeHandlers.end()) {
|
||||
return index2->second;
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ CEventQueue::getHandler(CEvent::Type type, void* target) const
|
|||
}
|
||||
|
||||
UInt32
|
||||
CEventQueue::saveEvent(const CEvent& event)
|
||||
EventQueue::saveEvent(const Event& event)
|
||||
{
|
||||
// choose id
|
||||
UInt32 id;
|
||||
|
@ -462,17 +462,17 @@ CEventQueue::saveEvent(const CEvent& event)
|
|||
return id;
|
||||
}
|
||||
|
||||
CEvent
|
||||
CEventQueue::removeEvent(UInt32 eventID)
|
||||
Event
|
||||
EventQueue::removeEvent(UInt32 eventID)
|
||||
{
|
||||
// look up id
|
||||
CEventTable::iterator index = m_events.find(eventID);
|
||||
EventTable::iterator index = m_events.find(eventID);
|
||||
if (index == m_events.end()) {
|
||||
return CEvent();
|
||||
return Event();
|
||||
}
|
||||
|
||||
// get data
|
||||
CEvent event = index->second;
|
||||
Event event = index->second;
|
||||
m_events.erase(index);
|
||||
|
||||
// save old id for reuse
|
||||
|
@ -482,7 +482,7 @@ CEventQueue::removeEvent(UInt32 eventID)
|
|||
}
|
||||
|
||||
bool
|
||||
CEventQueue::hasTimerExpired(CEvent& event)
|
||||
EventQueue::hasTimerExpired(Event& event)
|
||||
{
|
||||
// return true if there's a timer in the timer priority queue that
|
||||
// has expired. if returning true then fill in event appropriately
|
||||
|
@ -496,7 +496,7 @@ CEventQueue::hasTimerExpired(CEvent& event)
|
|||
m_time.reset();
|
||||
|
||||
// countdown elapsed time
|
||||
for (CTimerQueue::iterator index = m_timerQueue.begin();
|
||||
for (TimerQueue::iterator index = m_timerQueue.begin();
|
||||
index != m_timerQueue.end(); ++index) {
|
||||
(*index) -= time;
|
||||
}
|
||||
|
@ -507,12 +507,12 @@ CEventQueue::hasTimerExpired(CEvent& event)
|
|||
}
|
||||
|
||||
// remove timer from queue
|
||||
CTimer timer = m_timerQueue.top();
|
||||
Timer timer = m_timerQueue.top();
|
||||
m_timerQueue.pop();
|
||||
|
||||
// prepare event and reset the timer's clock
|
||||
timer.fillEvent(m_timerEvent);
|
||||
event = CEvent(CEvent::kTimer, timer.getTarget(), &m_timerEvent);
|
||||
event = Event(Event::kTimer, timer.getTarget(), &m_timerEvent);
|
||||
timer.reset();
|
||||
|
||||
// reinsert timer into queue if it's not a one-shot
|
||||
|
@ -524,7 +524,7 @@ CEventQueue::hasTimerExpired(CEvent& event)
|
|||
}
|
||||
|
||||
double
|
||||
CEventQueue::getNextTimerTimeout() const
|
||||
EventQueue::getNextTimerTimeout() const
|
||||
{
|
||||
// return -1 if no timers, 0 if the top timer has expired, otherwise
|
||||
// the time until the top timer in the timer priority queue will
|
||||
|
@ -538,28 +538,28 @@ CEventQueue::getNextTimerTimeout() const
|
|||
return m_timerQueue.top();
|
||||
}
|
||||
|
||||
CEvent::Type
|
||||
CEventQueue::getRegisteredType(const CString& name) const
|
||||
Event::Type
|
||||
EventQueue::getRegisteredType(const String& name) const
|
||||
{
|
||||
CNameMap::const_iterator found = m_nameMap.find(name);
|
||||
NameMap::const_iterator found = m_nameMap.find(name);
|
||||
if (found != m_nameMap.end())
|
||||
return found->second;
|
||||
|
||||
return CEvent::kUnknown;
|
||||
return Event::kUnknown;
|
||||
}
|
||||
|
||||
void*
|
||||
CEventQueue::getSystemTarget()
|
||||
EventQueue::getSystemTarget()
|
||||
{
|
||||
// any unique arbitrary pointer will do
|
||||
return &m_systemTarget;
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::waitForReady() const
|
||||
EventQueue::waitForReady() const
|
||||
{
|
||||
double timeout = ARCH->time() + 10;
|
||||
CLock lock(m_readyMutex);
|
||||
Lock lock(m_readyMutex);
|
||||
|
||||
while (!m_readyCondVar->wait()) {
|
||||
if(ARCH->time() > timeout) {
|
||||
|
@ -569,10 +569,10 @@ CEventQueue::waitForReady() const
|
|||
}
|
||||
|
||||
//
|
||||
// CEventQueue::CTimer
|
||||
// EventQueue::Timer
|
||||
//
|
||||
|
||||
CEventQueue::CTimer::CTimer(CEventQueueTimer* timer, double timeout,
|
||||
EventQueue::Timer::Timer(EventQueueTimer* timer, double timeout,
|
||||
double initialTime, void* target, bool oneShot) :
|
||||
m_timer(timer),
|
||||
m_timeout(timeout),
|
||||
|
@ -583,49 +583,49 @@ CEventQueue::CTimer::CTimer(CEventQueueTimer* timer, double timeout,
|
|||
assert(m_timeout > 0.0);
|
||||
}
|
||||
|
||||
CEventQueue::CTimer::~CTimer()
|
||||
EventQueue::Timer::~Timer()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::CTimer::reset()
|
||||
EventQueue::Timer::reset()
|
||||
{
|
||||
m_time = m_timeout;
|
||||
}
|
||||
|
||||
CEventQueue::CTimer&
|
||||
CEventQueue::CTimer::operator-=(double dt)
|
||||
EventQueue::Timer&
|
||||
EventQueue::Timer::operator-=(double dt)
|
||||
{
|
||||
m_time -= dt;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CEventQueue::CTimer::operator double() const
|
||||
EventQueue::Timer::operator double() const
|
||||
{
|
||||
return m_time;
|
||||
}
|
||||
|
||||
bool
|
||||
CEventQueue::CTimer::isOneShot() const
|
||||
EventQueue::Timer::isOneShot() const
|
||||
{
|
||||
return m_oneShot;
|
||||
}
|
||||
|
||||
CEventQueueTimer*
|
||||
CEventQueue::CTimer::getTimer() const
|
||||
EventQueueTimer*
|
||||
EventQueue::Timer::getTimer() const
|
||||
{
|
||||
return m_timer;
|
||||
}
|
||||
|
||||
void*
|
||||
CEventQueue::CTimer::getTarget() const
|
||||
EventQueue::Timer::getTarget() const
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
void
|
||||
CEventQueue::CTimer::fillEvent(CTimerEvent& event) const
|
||||
EventQueue::Timer::fillEvent(TimerEvent& event) const
|
||||
{
|
||||
event.m_timer = m_timer;
|
||||
event.m_count = 0;
|
||||
|
@ -635,7 +635,7 @@ CEventQueue::CTimer::fillEvent(CTimerEvent& event) const
|
|||
}
|
||||
|
||||
bool
|
||||
CEventQueue::CTimer::operator<(const CTimer& t) const
|
||||
EventQueue::Timer::operator<(const Timer& t) const
|
||||
{
|
||||
return m_time < t.m_time;
|
||||
}
|
||||
|
|
|
@ -29,162 +29,162 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
class CMutex;
|
||||
class Mutex;
|
||||
|
||||
//! Event queue
|
||||
/*!
|
||||
An event queue that implements the platform independent parts and
|
||||
delegates the platform dependent parts to a subclass.
|
||||
*/
|
||||
class CEventQueue : public IEventQueue {
|
||||
class EventQueue : public IEventQueue {
|
||||
public:
|
||||
CEventQueue();
|
||||
virtual ~CEventQueue();
|
||||
EventQueue();
|
||||
virtual ~EventQueue();
|
||||
|
||||
// IEventQueue overrides
|
||||
virtual void loop();
|
||||
virtual void adoptBuffer(IEventQueueBuffer*);
|
||||
virtual bool getEvent(CEvent& event, double timeout = -1.0);
|
||||
virtual bool dispatchEvent(const CEvent& event);
|
||||
virtual void addEvent(const CEvent& event);
|
||||
virtual CEventQueueTimer*
|
||||
virtual bool getEvent(Event& event, double timeout = -1.0);
|
||||
virtual bool dispatchEvent(const Event& event);
|
||||
virtual void addEvent(const Event& event);
|
||||
virtual EventQueueTimer*
|
||||
newTimer(double duration, void* target);
|
||||
virtual CEventQueueTimer*
|
||||
virtual EventQueueTimer*
|
||||
newOneShotTimer(double duration, void* target);
|
||||
virtual void deleteTimer(CEventQueueTimer*);
|
||||
virtual void adoptHandler(CEvent::Type type,
|
||||
virtual void deleteTimer(EventQueueTimer*);
|
||||
virtual void adoptHandler(Event::Type type,
|
||||
void* target, IEventJob* handler);
|
||||
virtual void removeHandler(CEvent::Type type, void* target);
|
||||
virtual void removeHandler(Event::Type type, void* target);
|
||||
virtual void removeHandlers(void* target);
|
||||
virtual CEvent::Type
|
||||
registerTypeOnce(CEvent::Type& type, const char* name);
|
||||
virtual Event::Type
|
||||
registerTypeOnce(Event::Type& type, const char* name);
|
||||
virtual bool isEmpty() const;
|
||||
virtual IEventJob* getHandler(CEvent::Type type, void* target) const;
|
||||
virtual const char* getTypeName(CEvent::Type type);
|
||||
virtual CEvent::Type
|
||||
getRegisteredType(const CString& name) const;
|
||||
virtual IEventJob* getHandler(Event::Type type, void* target) const;
|
||||
virtual const char* getTypeName(Event::Type type);
|
||||
virtual Event::Type
|
||||
getRegisteredType(const String& name) const;
|
||||
void* getSystemTarget();
|
||||
virtual void waitForReady() const;
|
||||
|
||||
private:
|
||||
UInt32 saveEvent(const CEvent& event);
|
||||
CEvent removeEvent(UInt32 eventID);
|
||||
bool hasTimerExpired(CEvent& event);
|
||||
UInt32 saveEvent(const Event& event);
|
||||
Event removeEvent(UInt32 eventID);
|
||||
bool hasTimerExpired(Event& event);
|
||||
double getNextTimerTimeout() const;
|
||||
void addEventToBuffer(const CEvent& event);
|
||||
void addEventToBuffer(const Event& event);
|
||||
|
||||
private:
|
||||
class CTimer {
|
||||
class Timer {
|
||||
public:
|
||||
CTimer(CEventQueueTimer*, double timeout, double initialTime,
|
||||
Timer(EventQueueTimer*, double timeout, double initialTime,
|
||||
void* target, bool oneShot);
|
||||
~CTimer();
|
||||
~Timer();
|
||||
|
||||
void reset();
|
||||
|
||||
CTimer& operator-=(double);
|
||||
Timer& operator-=(double);
|
||||
|
||||
operator double() const;
|
||||
|
||||
bool isOneShot() const;
|
||||
CEventQueueTimer*
|
||||
EventQueueTimer*
|
||||
getTimer() const;
|
||||
void* getTarget() const;
|
||||
void fillEvent(CTimerEvent&) const;
|
||||
void fillEvent(TimerEvent&) const;
|
||||
|
||||
bool operator<(const CTimer&) const;
|
||||
bool operator<(const Timer&) const;
|
||||
|
||||
private:
|
||||
CEventQueueTimer* m_timer;
|
||||
EventQueueTimer* m_timer;
|
||||
double m_timeout;
|
||||
void* m_target;
|
||||
bool m_oneShot;
|
||||
double m_time;
|
||||
};
|
||||
|
||||
typedef std::set<CEventQueueTimer*> CTimers;
|
||||
typedef CPriorityQueue<CTimer> CTimerQueue;
|
||||
typedef std::map<UInt32, CEvent> CEventTable;
|
||||
typedef std::vector<UInt32> CEventIDList;
|
||||
typedef std::map<CEvent::Type, const char*> CTypeMap;
|
||||
typedef std::map<CString, CEvent::Type> CNameMap;
|
||||
typedef std::map<CEvent::Type, IEventJob*> CTypeHandlerTable;
|
||||
typedef std::map<void*, CTypeHandlerTable> CHandlerTable;
|
||||
typedef std::set<EventQueueTimer*> Timers;
|
||||
typedef PriorityQueue<Timer> TimerQueue;
|
||||
typedef std::map<UInt32, Event> EventTable;
|
||||
typedef std::vector<UInt32> EventIDList;
|
||||
typedef std::map<Event::Type, const char*> TypeMap;
|
||||
typedef std::map<String, Event::Type> NameMap;
|
||||
typedef std::map<Event::Type, IEventJob*> TypeHandlerTable;
|
||||
typedef std::map<void*, TypeHandlerTable> HandlerTable;
|
||||
|
||||
int m_systemTarget;
|
||||
CArchMutex m_mutex;
|
||||
ArchMutex m_mutex;
|
||||
|
||||
// registered events
|
||||
CEvent::Type m_nextType;
|
||||
CTypeMap m_typeMap;
|
||||
CNameMap m_nameMap;
|
||||
Event::Type m_nextType;
|
||||
TypeMap m_typeMap;
|
||||
NameMap m_nameMap;
|
||||
|
||||
// buffer of events
|
||||
IEventQueueBuffer* m_buffer;
|
||||
|
||||
// saved events
|
||||
CEventTable m_events;
|
||||
CEventIDList m_oldEventIDs;
|
||||
EventTable m_events;
|
||||
EventIDList m_oldEventIDs;
|
||||
|
||||
// timers
|
||||
CStopwatch m_time;
|
||||
CTimers m_timers;
|
||||
CTimerQueue m_timerQueue;
|
||||
CTimerEvent m_timerEvent;
|
||||
Stopwatch m_time;
|
||||
Timers m_timers;
|
||||
TimerQueue m_timerQueue;
|
||||
TimerEvent m_timerEvent;
|
||||
|
||||
// event handlers
|
||||
CHandlerTable m_handlers;
|
||||
HandlerTable m_handlers;
|
||||
|
||||
public:
|
||||
//
|
||||
// Event type providers.
|
||||
//
|
||||
CClientEvents& forCClient();
|
||||
ClientEvents& forClient();
|
||||
IStreamEvents& forIStream();
|
||||
CIpcClientEvents& forCIpcClient();
|
||||
CIpcClientProxyEvents& forCIpcClientProxy();
|
||||
CIpcServerEvents& forCIpcServer();
|
||||
CIpcServerProxyEvents& forCIpcServerProxy();
|
||||
IpcClientEvents& forIpcClient();
|
||||
IpcClientProxyEvents& forIpcClientProxy();
|
||||
IpcServerEvents& forIpcServer();
|
||||
IpcServerProxyEvents& forIpcServerProxy();
|
||||
IDataSocketEvents& forIDataSocket();
|
||||
IListenSocketEvents& forIListenSocket();
|
||||
ISocketEvents& forISocket();
|
||||
COSXScreenEvents& forCOSXScreen();
|
||||
CClientListenerEvents& forCClientListener();
|
||||
CClientProxyEvents& forCClientProxy();
|
||||
CClientProxyUnknownEvents& forCClientProxyUnknown();
|
||||
CServerEvents& forCServer();
|
||||
CServerAppEvents& forCServerApp();
|
||||
OSXScreenEvents& forOSXScreen();
|
||||
ClientListenerEvents& forClientListener();
|
||||
ClientProxyEvents& forClientProxy();
|
||||
ClientProxyUnknownEvents& forClientProxyUnknown();
|
||||
ServerEvents& forServer();
|
||||
ServerAppEvents& forServerApp();
|
||||
IKeyStateEvents& forIKeyState();
|
||||
IPrimaryScreenEvents& forIPrimaryScreen();
|
||||
IScreenEvents& forIScreen();
|
||||
|
||||
private:
|
||||
CClientEvents* m_typesForCClient;
|
||||
ClientEvents* m_typesForClient;
|
||||
IStreamEvents* m_typesForIStream;
|
||||
CIpcClientEvents* m_typesForCIpcClient;
|
||||
CIpcClientProxyEvents* m_typesForCIpcClientProxy;
|
||||
CIpcServerEvents* m_typesForCIpcServer;
|
||||
CIpcServerProxyEvents* m_typesForCIpcServerProxy;
|
||||
IpcClientEvents* m_typesForIpcClient;
|
||||
IpcClientProxyEvents* m_typesForIpcClientProxy;
|
||||
IpcServerEvents* m_typesForIpcServer;
|
||||
IpcServerProxyEvents* m_typesForIpcServerProxy;
|
||||
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;
|
||||
OSXScreenEvents* m_typesForOSXScreen;
|
||||
ClientListenerEvents* m_typesForClientListener;
|
||||
ClientProxyEvents* m_typesForClientProxy;
|
||||
ClientProxyUnknownEvents* m_typesForClientProxyUnknown;
|
||||
ServerEvents* m_typesForServer;
|
||||
ServerAppEvents* m_typesForServerApp;
|
||||
IKeyStateEvents* m_typesForIKeyState;
|
||||
IPrimaryScreenEvents* m_typesForIPrimaryScreen;
|
||||
IScreenEvents* m_typesForIScreen;
|
||||
CMutex* m_readyMutex;
|
||||
CCondVar<bool>* m_readyCondVar;
|
||||
std::queue<CEvent> m_pending;
|
||||
Mutex* m_readyMutex;
|
||||
CondVar<bool>* m_readyCondVar;
|
||||
std::queue<Event> m_pending;
|
||||
};
|
||||
|
||||
#define EVENT_TYPE_ACCESSOR(type_) \
|
||||
type_##Events& \
|
||||
CEventQueue::for##type_() { \
|
||||
EventQueue::for##type_() { \
|
||||
if (m_typesFor##type_ == NULL) { \
|
||||
m_typesFor##type_ = new type_##Events(); \
|
||||
m_typesFor##type_->setEvents(dynamic_cast<IEventQueue*>(this)); \
|
||||
|
|
|
@ -21,31 +21,31 @@
|
|||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
CEventTypes::CEventTypes() :
|
||||
EventTypes::EventTypes() :
|
||||
m_events(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
IEventQueue*
|
||||
CEventTypes::getEvents() const
|
||||
EventTypes::getEvents() const
|
||||
{
|
||||
assert(m_events != NULL);
|
||||
return m_events;
|
||||
}
|
||||
|
||||
void
|
||||
CEventTypes::setEvents(IEventQueue* events)
|
||||
EventTypes::setEvents(IEventQueue* events)
|
||||
{
|
||||
m_events = events;
|
||||
}
|
||||
|
||||
//
|
||||
// CClient
|
||||
// Client
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CClient, connected)
|
||||
REGISTER_EVENT(CClient, connectionFailed)
|
||||
REGISTER_EVENT(CClient, disconnected)
|
||||
REGISTER_EVENT(Client, connected)
|
||||
REGISTER_EVENT(Client, connectionFailed)
|
||||
REGISTER_EVENT(Client, disconnected)
|
||||
|
||||
//
|
||||
// IStream
|
||||
|
@ -58,24 +58,24 @@ REGISTER_EVENT(IStream, inputShutdown)
|
|||
REGISTER_EVENT(IStream, outputShutdown)
|
||||
|
||||
//
|
||||
// CIpcClient
|
||||
// IpcClient
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CIpcClient, connected)
|
||||
REGISTER_EVENT(CIpcClient, messageReceived)
|
||||
REGISTER_EVENT(IpcClient, connected)
|
||||
REGISTER_EVENT(IpcClient, messageReceived)
|
||||
|
||||
//
|
||||
// CIpcClientProxy
|
||||
// IpcClientProxy
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CIpcClientProxy, messageReceived)
|
||||
REGISTER_EVENT(CIpcClientProxy, disconnected)
|
||||
REGISTER_EVENT(IpcClientProxy, messageReceived)
|
||||
REGISTER_EVENT(IpcClientProxy, disconnected)
|
||||
|
||||
//
|
||||
// CIpcServerProxy
|
||||
// IpcServerProxy
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CIpcServerProxy, messageReceived)
|
||||
REGISTER_EVENT(IpcServerProxy, messageReceived)
|
||||
|
||||
//
|
||||
// IDataSocket
|
||||
|
@ -97,52 +97,52 @@ REGISTER_EVENT(IListenSocket, connecting)
|
|||
REGISTER_EVENT(ISocket, disconnected)
|
||||
|
||||
//
|
||||
// COSXScreen
|
||||
// OSXScreen
|
||||
//
|
||||
|
||||
REGISTER_EVENT(COSXScreen, confirmSleep)
|
||||
REGISTER_EVENT(OSXScreen, confirmSleep)
|
||||
|
||||
//
|
||||
// CClientListener
|
||||
// ClientListener
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CClientListener, connected)
|
||||
REGISTER_EVENT(ClientListener, connected)
|
||||
|
||||
//
|
||||
// CClientProxy
|
||||
// ClientProxy
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CClientProxy, ready)
|
||||
REGISTER_EVENT(CClientProxy, disconnected)
|
||||
REGISTER_EVENT(CClientProxy, clipboardChanged)
|
||||
REGISTER_EVENT(ClientProxy, ready)
|
||||
REGISTER_EVENT(ClientProxy, disconnected)
|
||||
REGISTER_EVENT(ClientProxy, clipboardChanged)
|
||||
|
||||
//
|
||||
// CClientProxyUnknown
|
||||
// ClientProxyUnknown
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CClientProxyUnknown, success)
|
||||
REGISTER_EVENT(CClientProxyUnknown, failure)
|
||||
REGISTER_EVENT(ClientProxyUnknown, success)
|
||||
REGISTER_EVENT(ClientProxyUnknown, failure)
|
||||
|
||||
//
|
||||
// CServer
|
||||
// Server
|
||||
//
|
||||
|
||||
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)
|
||||
REGISTER_EVENT(Server, error)
|
||||
REGISTER_EVENT(Server, connected)
|
||||
REGISTER_EVENT(Server, disconnected)
|
||||
REGISTER_EVENT(Server, switchToScreen)
|
||||
REGISTER_EVENT(Server, switchInDirection)
|
||||
REGISTER_EVENT(Server, keyboardBroadcast)
|
||||
REGISTER_EVENT(Server, lockCursorToScreen)
|
||||
REGISTER_EVENT(Server, screenSwitched)
|
||||
|
||||
//
|
||||
// CServerApp
|
||||
// ServerApp
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CServerApp, reloadConfig)
|
||||
REGISTER_EVENT(CServerApp, forceReconnect)
|
||||
REGISTER_EVENT(CServerApp, resetServer)
|
||||
REGISTER_EVENT(ServerApp, reloadConfig)
|
||||
REGISTER_EVENT(ServerApp, forceReconnect)
|
||||
REGISTER_EVENT(ServerApp, resetServer)
|
||||
|
||||
//
|
||||
// IKeyState
|
||||
|
@ -181,8 +181,8 @@ REGISTER_EVENT(IScreen, fileChunkSending)
|
|||
REGISTER_EVENT(IScreen, fileRecieveCompleted)
|
||||
|
||||
//
|
||||
// CIpcServer
|
||||
// IpcServer
|
||||
//
|
||||
|
||||
REGISTER_EVENT(CIpcServer, clientConnected)
|
||||
REGISTER_EVENT(CIpcServer, messageReceived)
|
||||
REGISTER_EVENT(IpcServer, clientConnected)
|
||||
REGISTER_EVENT(IpcServer, messageReceived)
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
class IEventQueue;
|
||||
|
||||
class CEventTypes {
|
||||
class EventTypes {
|
||||
public:
|
||||
CEventTypes();
|
||||
EventTypes();
|
||||
void setEvents(IEventQueue* events);
|
||||
|
||||
protected:
|
||||
|
@ -34,18 +34,18 @@ private:
|
|||
};
|
||||
|
||||
#define REGISTER_EVENT(type_, name_) \
|
||||
CEvent::Type \
|
||||
Event::Type \
|
||||
type_##Events::name_() \
|
||||
{ \
|
||||
return getEvents()->registerTypeOnce(m_##name_, __FUNCTION__); \
|
||||
}
|
||||
|
||||
class CClientEvents : public CEventTypes {
|
||||
class ClientEvents : public EventTypes {
|
||||
public:
|
||||
CClientEvents() :
|
||||
m_connected(CEvent::kUnknown),
|
||||
m_connectionFailed(CEvent::kUnknown),
|
||||
m_disconnected(CEvent::kUnknown) { }
|
||||
ClientEvents() :
|
||||
m_connected(Event::kUnknown),
|
||||
m_connectionFailed(Event::kUnknown),
|
||||
m_disconnected(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -55,14 +55,14 @@ public:
|
|||
Returns the connected event type. This is sent when the client has
|
||||
successfully connected to the server.
|
||||
*/
|
||||
CEvent::Type connected();
|
||||
Event::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*.
|
||||
server fails for some reason. The event data is a FailInfo*.
|
||||
*/
|
||||
CEvent::Type connectionFailed();
|
||||
Event::Type connectionFailed();
|
||||
|
||||
//! Get disconnected event type
|
||||
/*!
|
||||
|
@ -70,24 +70,24 @@ public:
|
|||
has disconnected from the server (and only after having successfully
|
||||
connected).
|
||||
*/
|
||||
CEvent::Type disconnected();
|
||||
Event::Type disconnected();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_connected;
|
||||
CEvent::Type m_connectionFailed;
|
||||
CEvent::Type m_disconnected;
|
||||
Event::Type m_connected;
|
||||
Event::Type m_connectionFailed;
|
||||
Event::Type m_disconnected;
|
||||
};
|
||||
|
||||
class IStreamEvents : public CEventTypes {
|
||||
class IStreamEvents : public EventTypes {
|
||||
public:
|
||||
IStreamEvents() :
|
||||
m_inputReady(CEvent::kUnknown),
|
||||
m_outputFlushed(CEvent::kUnknown),
|
||||
m_outputError(CEvent::kUnknown),
|
||||
m_inputShutdown(CEvent::kUnknown),
|
||||
m_outputShutdown(CEvent::kUnknown) { }
|
||||
m_inputReady(Event::kUnknown),
|
||||
m_outputFlushed(Event::kUnknown),
|
||||
m_outputError(Event::kUnknown),
|
||||
m_inputShutdown(Event::kUnknown),
|
||||
m_outputShutdown(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
Returns the input ready event type. A stream sends this event
|
||||
when \c read() will return with data.
|
||||
*/
|
||||
CEvent::Type inputReady();
|
||||
Event::Type inputReady();
|
||||
|
||||
//! Get output flushed event type
|
||||
/*!
|
||||
|
@ -107,14 +107,14 @@ public:
|
|||
\c close() will not discard any data and \c flush() will return
|
||||
immediately.
|
||||
*/
|
||||
CEvent::Type outputFlushed();
|
||||
Event::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();
|
||||
Event::Type outputError();
|
||||
|
||||
//! Get input shutdown event type
|
||||
/*!
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
input side of the stream has shutdown. When the input has
|
||||
shutdown, no more data will ever be available to read.
|
||||
*/
|
||||
CEvent::Type inputShutdown();
|
||||
Event::Type inputShutdown();
|
||||
|
||||
//! Get output shutdown event type
|
||||
/*!
|
||||
|
@ -131,106 +131,106 @@ public:
|
|||
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();
|
||||
Event::Type outputShutdown();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_inputReady;
|
||||
CEvent::Type m_outputFlushed;
|
||||
CEvent::Type m_outputError;
|
||||
CEvent::Type m_inputShutdown;
|
||||
CEvent::Type m_outputShutdown;
|
||||
Event::Type m_inputReady;
|
||||
Event::Type m_outputFlushed;
|
||||
Event::Type m_outputError;
|
||||
Event::Type m_inputShutdown;
|
||||
Event::Type m_outputShutdown;
|
||||
};
|
||||
|
||||
class CIpcClientEvents : public CEventTypes {
|
||||
class IpcClientEvents : public EventTypes {
|
||||
public:
|
||||
CIpcClientEvents() :
|
||||
m_connected(CEvent::kUnknown),
|
||||
m_messageReceived(CEvent::kUnknown) { }
|
||||
IpcClientEvents() :
|
||||
m_connected(Event::kUnknown),
|
||||
m_messageReceived(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Raised when the socket is connected.
|
||||
CEvent::Type connected();
|
||||
Event::Type connected();
|
||||
|
||||
//! Raised when a message is received.
|
||||
CEvent::Type messageReceived();
|
||||
Event::Type messageReceived();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_connected;
|
||||
CEvent::Type m_messageReceived;
|
||||
Event::Type m_connected;
|
||||
Event::Type m_messageReceived;
|
||||
};
|
||||
|
||||
class CIpcClientProxyEvents : public CEventTypes {
|
||||
class IpcClientProxyEvents : public EventTypes {
|
||||
public:
|
||||
CIpcClientProxyEvents() :
|
||||
m_messageReceived(CEvent::kUnknown),
|
||||
m_disconnected(CEvent::kUnknown) { }
|
||||
IpcClientProxyEvents() :
|
||||
m_messageReceived(Event::kUnknown),
|
||||
m_disconnected(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Raised when the server receives a message from a client.
|
||||
CEvent::Type messageReceived();
|
||||
Event::Type messageReceived();
|
||||
|
||||
//! Raised when the client disconnects from the server.
|
||||
CEvent::Type disconnected();
|
||||
Event::Type disconnected();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_messageReceived;
|
||||
CEvent::Type m_disconnected;
|
||||
Event::Type m_messageReceived;
|
||||
Event::Type m_disconnected;
|
||||
};
|
||||
|
||||
class CIpcServerEvents : public CEventTypes {
|
||||
class IpcServerEvents : public EventTypes {
|
||||
public:
|
||||
CIpcServerEvents() :
|
||||
m_clientConnected(CEvent::kUnknown),
|
||||
m_messageReceived(CEvent::kUnknown) { }
|
||||
IpcServerEvents() :
|
||||
m_clientConnected(Event::kUnknown),
|
||||
m_messageReceived(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Raised when we have created the client proxy.
|
||||
CEvent::Type clientConnected();
|
||||
Event::Type clientConnected();
|
||||
|
||||
//! Raised when a message is received through a client proxy.
|
||||
CEvent::Type messageReceived();
|
||||
Event::Type messageReceived();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_clientConnected;
|
||||
CEvent::Type m_messageReceived;
|
||||
Event::Type m_clientConnected;
|
||||
Event::Type m_messageReceived;
|
||||
};
|
||||
|
||||
class CIpcServerProxyEvents : public CEventTypes {
|
||||
class IpcServerProxyEvents : public EventTypes {
|
||||
public:
|
||||
CIpcServerProxyEvents() :
|
||||
m_messageReceived(CEvent::kUnknown) { }
|
||||
IpcServerProxyEvents() :
|
||||
m_messageReceived(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Raised when the client receives a message from the server.
|
||||
CEvent::Type messageReceived();
|
||||
Event::Type messageReceived();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_messageReceived;
|
||||
Event::Type m_messageReceived;
|
||||
};
|
||||
|
||||
class IDataSocketEvents : public CEventTypes {
|
||||
class IDataSocketEvents : public EventTypes {
|
||||
public:
|
||||
IDataSocketEvents() :
|
||||
m_connected(CEvent::kUnknown),
|
||||
m_connectionFailed(CEvent::kUnknown) { }
|
||||
m_connected(Event::kUnknown),
|
||||
m_connectionFailed(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -240,27 +240,27 @@ public:
|
|||
Returns the socket connected event type. A socket sends this
|
||||
event when a remote connection has been established.
|
||||
*/
|
||||
CEvent::Type connected();
|
||||
Event::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.
|
||||
The data is a pointer to a ConnectionFailedInfo.
|
||||
*/
|
||||
CEvent::Type connectionFailed();
|
||||
Event::Type connectionFailed();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_connected;
|
||||
CEvent::Type m_connectionFailed;
|
||||
Event::Type m_connected;
|
||||
Event::Type m_connectionFailed;
|
||||
};
|
||||
|
||||
class IListenSocketEvents : public CEventTypes {
|
||||
class IListenSocketEvents : public EventTypes {
|
||||
public:
|
||||
IListenSocketEvents() :
|
||||
m_connecting(CEvent::kUnknown) { }
|
||||
m_connecting(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -270,18 +270,18 @@ public:
|
|||
Returns the socket connecting event type. A socket sends this
|
||||
event when a remote connection is waiting to be accepted.
|
||||
*/
|
||||
CEvent::Type connecting();
|
||||
Event::Type connecting();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_connecting;
|
||||
Event::Type m_connecting;
|
||||
};
|
||||
|
||||
class ISocketEvents : public CEventTypes {
|
||||
class ISocketEvents : public EventTypes {
|
||||
public:
|
||||
ISocketEvents() :
|
||||
m_disconnected(CEvent::kUnknown) { }
|
||||
m_disconnected(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -292,34 +292,34 @@ public:
|
|||
event when the remote side of the socket has disconnected or
|
||||
shutdown both input and output.
|
||||
*/
|
||||
CEvent::Type disconnected();
|
||||
Event::Type disconnected();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_disconnected;
|
||||
Event::Type m_disconnected;
|
||||
};
|
||||
|
||||
class COSXScreenEvents : public CEventTypes {
|
||||
class OSXScreenEvents : public EventTypes {
|
||||
public:
|
||||
COSXScreenEvents() :
|
||||
m_confirmSleep(CEvent::kUnknown) { }
|
||||
OSXScreenEvents() :
|
||||
m_confirmSleep(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
CEvent::Type confirmSleep();
|
||||
Event::Type confirmSleep();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_confirmSleep;
|
||||
Event::Type m_confirmSleep;
|
||||
};
|
||||
|
||||
class CClientListenerEvents : public CEventTypes {
|
||||
class ClientListenerEvents : public EventTypes {
|
||||
public:
|
||||
CClientListenerEvents() :
|
||||
m_connected(CEvent::kUnknown) { }
|
||||
ClientListenerEvents() :
|
||||
m_connected(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -329,20 +329,20 @@ public:
|
|||
Returns the connected event type. This is sent whenever a
|
||||
a client connects.
|
||||
*/
|
||||
CEvent::Type connected();
|
||||
Event::Type connected();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_connected;
|
||||
Event::Type m_connected;
|
||||
};
|
||||
|
||||
class CClientProxyEvents : public CEventTypes {
|
||||
class ClientProxyEvents : public EventTypes {
|
||||
public:
|
||||
CClientProxyEvents() :
|
||||
m_ready(CEvent::kUnknown),
|
||||
m_disconnected(CEvent::kUnknown),
|
||||
m_clipboardChanged(CEvent::kUnknown) { }
|
||||
ClientProxyEvents() :
|
||||
m_ready(Event::kUnknown),
|
||||
m_disconnected(Event::kUnknown),
|
||||
m_clipboardChanged(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -353,36 +353,36 @@ public:
|
|||
completed the initial handshake. Until it is sent, the client is
|
||||
not fully connected.
|
||||
*/
|
||||
CEvent::Type ready();
|
||||
Event::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();
|
||||
Event::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.
|
||||
IScreen::ClipboardInfo.
|
||||
*/
|
||||
CEvent::Type clipboardChanged();
|
||||
Event::Type clipboardChanged();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_ready;
|
||||
CEvent::Type m_disconnected;
|
||||
CEvent::Type m_clipboardChanged;
|
||||
Event::Type m_ready;
|
||||
Event::Type m_disconnected;
|
||||
Event::Type m_clipboardChanged;
|
||||
};
|
||||
|
||||
class CClientProxyUnknownEvents : public CEventTypes {
|
||||
class ClientProxyUnknownEvents : public EventTypes {
|
||||
public:
|
||||
CClientProxyUnknownEvents() :
|
||||
m_success(CEvent::kUnknown),
|
||||
m_failure(CEvent::kUnknown) { }
|
||||
ClientProxyUnknownEvents() :
|
||||
m_success(Event::kUnknown),
|
||||
m_failure(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -392,33 +392,33 @@ public:
|
|||
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();
|
||||
Event::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();
|
||||
Event::Type failure();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_success;
|
||||
CEvent::Type m_failure;
|
||||
Event::Type m_success;
|
||||
Event::Type m_failure;
|
||||
};
|
||||
|
||||
class CServerEvents : public CEventTypes {
|
||||
class ServerEvents : public EventTypes {
|
||||
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) { }
|
||||
ServerEvents() :
|
||||
m_error(Event::kUnknown),
|
||||
m_connected(Event::kUnknown),
|
||||
m_disconnected(Event::kUnknown),
|
||||
m_switchToScreen(Event::kUnknown),
|
||||
m_switchInDirection(Event::kUnknown),
|
||||
m_keyboardBroadcast(Event::kUnknown),
|
||||
m_lockCursorToScreen(Event::kUnknown),
|
||||
m_screenSwitched(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -428,208 +428,208 @@ public:
|
|||
Returns the error event type. This is sent when the server fails
|
||||
for some reason.
|
||||
*/
|
||||
CEvent::Type error();
|
||||
Event::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
|
||||
has connected. The event data is a \c ScreenConnectedInfo* that
|
||||
indicates the connected screen.
|
||||
*/
|
||||
CEvent::Type connected();
|
||||
Event::Type connected();
|
||||
|
||||
//! Get disconnected event type
|
||||
/*!
|
||||
Returns the disconnected event type. This is sent when all the
|
||||
clients have disconnected.
|
||||
*/
|
||||
CEvent::Type disconnected();
|
||||
Event::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*
|
||||
by switching screens. The event data is a \c SwitchToScreenInfo*
|
||||
that indicates the target screen.
|
||||
*/
|
||||
CEvent::Type switchToScreen();
|
||||
Event::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*
|
||||
by switching screens. The event data is a \c SwitchInDirectionInfo*
|
||||
that indicates the target direction.
|
||||
*/
|
||||
CEvent::Type switchInDirection();
|
||||
Event::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*.
|
||||
event data is a \c KeyboardBroadcastInfo*.
|
||||
*/
|
||||
CEvent::Type keyboardBroadcast();
|
||||
Event::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*.
|
||||
event data is a \c LockCursorToScreenInfo*.
|
||||
*/
|
||||
CEvent::Type lockCursorToScreen();
|
||||
Event::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();
|
||||
Event::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;
|
||||
Event::Type m_error;
|
||||
Event::Type m_connected;
|
||||
Event::Type m_disconnected;
|
||||
Event::Type m_switchToScreen;
|
||||
Event::Type m_switchInDirection;
|
||||
Event::Type m_keyboardBroadcast;
|
||||
Event::Type m_lockCursorToScreen;
|
||||
Event::Type m_screenSwitched;
|
||||
};
|
||||
|
||||
class CServerAppEvents : public CEventTypes {
|
||||
class ServerAppEvents : public EventTypes {
|
||||
public:
|
||||
CServerAppEvents() :
|
||||
m_reloadConfig(CEvent::kUnknown),
|
||||
m_forceReconnect(CEvent::kUnknown),
|
||||
m_resetServer(CEvent::kUnknown) { }
|
||||
ServerAppEvents() :
|
||||
m_reloadConfig(Event::kUnknown),
|
||||
m_forceReconnect(Event::kUnknown),
|
||||
m_resetServer(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
CEvent::Type reloadConfig();
|
||||
CEvent::Type forceReconnect();
|
||||
CEvent::Type resetServer();
|
||||
Event::Type reloadConfig();
|
||||
Event::Type forceReconnect();
|
||||
Event::Type resetServer();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_reloadConfig;
|
||||
CEvent::Type m_forceReconnect;
|
||||
CEvent::Type m_resetServer;
|
||||
Event::Type m_reloadConfig;
|
||||
Event::Type m_forceReconnect;
|
||||
Event::Type m_resetServer;
|
||||
};
|
||||
|
||||
class IKeyStateEvents : public CEventTypes {
|
||||
class IKeyStateEvents : public EventTypes {
|
||||
public:
|
||||
IKeyStateEvents() :
|
||||
m_keyDown(CEvent::kUnknown),
|
||||
m_keyUp(CEvent::kUnknown),
|
||||
m_keyRepeat(CEvent::kUnknown) { }
|
||||
m_keyDown(Event::kUnknown),
|
||||
m_keyUp(Event::kUnknown),
|
||||
m_keyRepeat(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Get key down event type. Event data is CKeyInfo*, count == 1.
|
||||
CEvent::Type keyDown();
|
||||
//! Get key down event type. Event data is KeyInfo*, count == 1.
|
||||
Event::Type keyDown();
|
||||
|
||||
//! Get key up event type. Event data is CKeyInfo*, count == 1.
|
||||
CEvent::Type keyUp();
|
||||
//! Get key up event type. Event data is KeyInfo*, count == 1.
|
||||
Event::Type keyUp();
|
||||
|
||||
//! Get key repeat event type. Event data is CKeyInfo*.
|
||||
CEvent::Type keyRepeat();
|
||||
//! Get key repeat event type. Event data is KeyInfo*.
|
||||
Event::Type keyRepeat();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_keyDown;
|
||||
CEvent::Type m_keyUp;
|
||||
CEvent::Type m_keyRepeat;
|
||||
Event::Type m_keyDown;
|
||||
Event::Type m_keyUp;
|
||||
Event::Type m_keyRepeat;
|
||||
};
|
||||
|
||||
class IPrimaryScreenEvents : public CEventTypes {
|
||||
class IPrimaryScreenEvents : public EventTypes {
|
||||
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_buttonDown(Event::kUnknown),
|
||||
m_buttonUp(Event::kUnknown),
|
||||
m_motionOnPrimary(Event::kUnknown),
|
||||
m_motionOnSecondary(Event::kUnknown),
|
||||
m_wheel(Event::kUnknown),
|
||||
m_screensaverActivated(Event::kUnknown),
|
||||
m_screensaverDeactivated(Event::kUnknown),
|
||||
m_hotKeyDown(Event::kUnknown),
|
||||
m_hotKeyUp(Event::kUnknown),
|
||||
m_fakeInputBegin(Event::kUnknown),
|
||||
m_fakeInputEnd(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! button down event type. Event data is CButtonInfo*.
|
||||
CEvent::Type buttonDown();
|
||||
//! button down event type. Event data is ButtonInfo*.
|
||||
Event::Type buttonDown();
|
||||
|
||||
//! button up event type. Event data is CButtonInfo*.
|
||||
CEvent::Type buttonUp();
|
||||
//! button up event type. Event data is ButtonInfo*.
|
||||
Event::Type buttonUp();
|
||||
|
||||
//! mouse motion on the primary screen event type
|
||||
/*!
|
||||
Event data is CMotionInfo* and the values are an absolute position.
|
||||
Event data is MotionInfo* and the values are an absolute position.
|
||||
*/
|
||||
CEvent::Type motionOnPrimary();
|
||||
Event::Type motionOnPrimary();
|
||||
|
||||
//! mouse motion on a secondary screen event type
|
||||
/*!
|
||||
Event data is CMotionInfo* and the values are motion deltas not
|
||||
Event data is MotionInfo* and the values are motion deltas not
|
||||
absolute coordinates.
|
||||
*/
|
||||
CEvent::Type motionOnSecondary();
|
||||
Event::Type motionOnSecondary();
|
||||
|
||||
//! mouse wheel event type. Event data is CWheelInfo*.
|
||||
CEvent::Type wheel();
|
||||
//! mouse wheel event type. Event data is WheelInfo*.
|
||||
Event::Type wheel();
|
||||
|
||||
//! screensaver activated event type
|
||||
CEvent::Type screensaverActivated();
|
||||
Event::Type screensaverActivated();
|
||||
|
||||
//! screensaver deactivated event type
|
||||
CEvent::Type screensaverDeactivated();
|
||||
Event::Type screensaverDeactivated();
|
||||
|
||||
//! hot key down event type. Event data is CHotKeyInfo*.
|
||||
CEvent::Type hotKeyDown();
|
||||
//! hot key down event type. Event data is HotKeyInfo*.
|
||||
Event::Type hotKeyDown();
|
||||
|
||||
//! hot key up event type. Event data is CHotKeyInfo*.
|
||||
CEvent::Type hotKeyUp();
|
||||
//! hot key up event type. Event data is HotKeyInfo*.
|
||||
Event::Type hotKeyUp();
|
||||
|
||||
//! start of fake input event type
|
||||
CEvent::Type fakeInputBegin();
|
||||
Event::Type fakeInputBegin();
|
||||
|
||||
//! end of fake input event type
|
||||
CEvent::Type fakeInputEnd();
|
||||
Event::Type fakeInputEnd();
|
||||
|
||||
//@}
|
||||
|
||||
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;
|
||||
Event::Type m_buttonDown;
|
||||
Event::Type m_buttonUp;
|
||||
Event::Type m_motionOnPrimary;
|
||||
Event::Type m_motionOnSecondary;
|
||||
Event::Type m_wheel;
|
||||
Event::Type m_screensaverActivated;
|
||||
Event::Type m_screensaverDeactivated;
|
||||
Event::Type m_hotKeyDown;
|
||||
Event::Type m_hotKeyUp;
|
||||
Event::Type m_fakeInputBegin;
|
||||
Event::Type m_fakeInputEnd;
|
||||
};
|
||||
|
||||
class IScreenEvents : public CEventTypes {
|
||||
class IScreenEvents : public EventTypes {
|
||||
public:
|
||||
IScreenEvents() :
|
||||
m_error(CEvent::kUnknown),
|
||||
m_shapeChanged(CEvent::kUnknown),
|
||||
m_clipboardGrabbed(CEvent::kUnknown),
|
||||
m_suspend(CEvent::kUnknown),
|
||||
m_resume(CEvent::kUnknown),
|
||||
m_fileChunkSending(CEvent::kUnknown),
|
||||
m_fileRecieveCompleted(CEvent::kUnknown) { }
|
||||
m_error(Event::kUnknown),
|
||||
m_shapeChanged(Event::kUnknown),
|
||||
m_clipboardGrabbed(Event::kUnknown),
|
||||
m_suspend(Event::kUnknown),
|
||||
m_resume(Event::kUnknown),
|
||||
m_fileChunkSending(Event::kUnknown),
|
||||
m_fileRecieveCompleted(Event::kUnknown) { }
|
||||
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
@ -639,51 +639,51 @@ public:
|
|||
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();
|
||||
Event::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();
|
||||
Event::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.
|
||||
anymore. The data is a pointer to a ClipboardInfo.
|
||||
*/
|
||||
CEvent::Type clipboardGrabbed();
|
||||
Event::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();
|
||||
Event::Type suspend();
|
||||
|
||||
//! Get resume event type
|
||||
/*!
|
||||
Returns the resume event type. This is sent whenever the system wakes
|
||||
up or a user session is activated (fast user switching).
|
||||
*/
|
||||
CEvent::Type resume();
|
||||
Event::Type resume();
|
||||
|
||||
//! Sending a file chunk
|
||||
CEvent::Type fileChunkSending();
|
||||
Event::Type fileChunkSending();
|
||||
|
||||
//! Completed receiving a file
|
||||
CEvent::Type fileRecieveCompleted();
|
||||
Event::Type fileRecieveCompleted();
|
||||
|
||||
//@}
|
||||
|
||||
private:
|
||||
CEvent::Type m_error;
|
||||
CEvent::Type m_shapeChanged;
|
||||
CEvent::Type m_clipboardGrabbed;
|
||||
CEvent::Type m_suspend;
|
||||
CEvent::Type m_resume;
|
||||
CEvent::Type m_fileChunkSending;
|
||||
CEvent::Type m_fileRecieveCompleted;
|
||||
Event::Type m_error;
|
||||
Event::Type m_shapeChanged;
|
||||
Event::Type m_clipboardGrabbed;
|
||||
Event::Type m_suspend;
|
||||
Event::Type m_resume;
|
||||
Event::Type m_fileChunkSending;
|
||||
Event::Type m_fileRecieveCompleted;
|
||||
};
|
||||
|
|
|
@ -19,24 +19,24 @@
|
|||
#include "base/FunctionEventJob.h"
|
||||
|
||||
//
|
||||
// CFunctionEventJob
|
||||
// FunctionEventJob
|
||||
//
|
||||
|
||||
CFunctionEventJob::CFunctionEventJob(
|
||||
void (*func)(const CEvent&, void*), void* arg) :
|
||||
FunctionEventJob::FunctionEventJob(
|
||||
void (*func)(const Event&, void*), void* arg) :
|
||||
m_func(func),
|
||||
m_arg(arg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CFunctionEventJob::~CFunctionEventJob()
|
||||
FunctionEventJob::~FunctionEventJob()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CFunctionEventJob::run(const CEvent& event)
|
||||
FunctionEventJob::run(const Event& event)
|
||||
{
|
||||
if (m_func != NULL) {
|
||||
m_func(event, m_arg);
|
||||
|
|
|
@ -24,16 +24,16 @@
|
|||
/*!
|
||||
An event job class that invokes a function.
|
||||
*/
|
||||
class CFunctionEventJob : public IEventJob {
|
||||
class FunctionEventJob : public IEventJob {
|
||||
public:
|
||||
//! run() invokes \c func(arg)
|
||||
CFunctionEventJob(void (*func)(const CEvent&, void*), void* arg = NULL);
|
||||
virtual ~CFunctionEventJob();
|
||||
FunctionEventJob(void (*func)(const Event&, void*), void* arg = NULL);
|
||||
virtual ~FunctionEventJob();
|
||||
|
||||
// IEventJob overrides
|
||||
virtual void run(const CEvent&);
|
||||
virtual void run(const Event&);
|
||||
|
||||
private:
|
||||
void (*m_func)(const CEvent&, void*);
|
||||
void (*m_func)(const Event&, void*);
|
||||
void* m_arg;
|
||||
};
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
#include "base/FunctionJob.h"
|
||||
|
||||
//
|
||||
// CFunctionJob
|
||||
// FunctionJob
|
||||
//
|
||||
|
||||
CFunctionJob::CFunctionJob(void (*func)(void*), void* arg) :
|
||||
FunctionJob::FunctionJob(void (*func)(void*), void* arg) :
|
||||
m_func(func),
|
||||
m_arg(arg)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CFunctionJob::~CFunctionJob()
|
||||
FunctionJob::~FunctionJob()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CFunctionJob::run()
|
||||
FunctionJob::run()
|
||||
{
|
||||
if (m_func != NULL) {
|
||||
m_func(m_arg);
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
/*!
|
||||
A job class that invokes a function.
|
||||
*/
|
||||
class CFunctionJob : public IJob {
|
||||
class FunctionJob : public IJob {
|
||||
public:
|
||||
//! run() invokes \c func(arg)
|
||||
CFunctionJob(void (*func)(void*), void* arg = NULL);
|
||||
virtual ~CFunctionJob();
|
||||
FunctionJob(void (*func)(void*), void* arg = NULL);
|
||||
virtual ~FunctionJob();
|
||||
|
||||
// IJob overrides
|
||||
virtual void run();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "common/IInterface.h"
|
||||
|
||||
class CEvent;
|
||||
class Event;
|
||||
|
||||
//! Event handler interface
|
||||
/*!
|
||||
|
@ -29,5 +29,5 @@ An event job is an interface for executing a event handler.
|
|||
class IEventJob : public IInterface {
|
||||
public:
|
||||
//! Run the job
|
||||
virtual void run(const CEvent&) = 0;
|
||||
virtual void run(const Event&) = 0;
|
||||
};
|
||||
|
|
|
@ -27,40 +27,40 @@ class IEventQueueBuffer;
|
|||
|
||||
// Opaque type for timer info. This is defined by subclasses of
|
||||
// IEventQueueBuffer.
|
||||
class CEventQueueTimer;
|
||||
class EventQueueTimer;
|
||||
|
||||
// Event type registration classes.
|
||||
class CClientEvents;
|
||||
class ClientEvents;
|
||||
class IStreamEvents;
|
||||
class CIpcClientEvents;
|
||||
class CIpcClientProxyEvents;
|
||||
class CIpcServerEvents;
|
||||
class CIpcServerProxyEvents;
|
||||
class IpcClientEvents;
|
||||
class IpcClientProxyEvents;
|
||||
class IpcServerEvents;
|
||||
class IpcServerProxyEvents;
|
||||
class IDataSocketEvents;
|
||||
class IListenSocketEvents;
|
||||
class ISocketEvents;
|
||||
class COSXScreenEvents;
|
||||
class CClientListenerEvents;
|
||||
class CClientProxyEvents;
|
||||
class CClientProxyUnknownEvents;
|
||||
class CServerEvents;
|
||||
class CServerAppEvents;
|
||||
class OSXScreenEvents;
|
||||
class ClientListenerEvents;
|
||||
class ClientProxyEvents;
|
||||
class ClientProxyUnknownEvents;
|
||||
class ServerEvents;
|
||||
class ServerAppEvents;
|
||||
class IKeyStateEvents;
|
||||
class IPrimaryScreenEvents;
|
||||
class IScreenEvents;
|
||||
|
||||
//! Event queue interface
|
||||
/*!
|
||||
An event queue provides a queue of CEvents. Clients can block waiting
|
||||
An event queue provides a queue of Events. Clients can block waiting
|
||||
on any event becoming available at the head of the queue and can place
|
||||
new events at the end of the queue. Clients can also add and remove
|
||||
timers which generate events periodically.
|
||||
*/
|
||||
class IEventQueue : public IInterface {
|
||||
public:
|
||||
class CTimerEvent {
|
||||
class TimerEvent {
|
||||
public:
|
||||
CEventQueueTimer* m_timer; //!< The timer
|
||||
EventQueueTimer* m_timer; //!< The timer
|
||||
UInt32 m_count; //!< Number of repeats
|
||||
};
|
||||
|
||||
|
@ -86,26 +86,26 @@ public:
|
|||
available then blocks for up to \p timeout seconds, or forever if
|
||||
\p timeout is negative. Returns true iff an event was available.
|
||||
*/
|
||||
virtual bool getEvent(CEvent& event, double timeout = -1.0) = 0;
|
||||
virtual bool getEvent(Event& event, double timeout = -1.0) = 0;
|
||||
|
||||
//! Dispatch an event
|
||||
/*!
|
||||
Looks up the dispatcher for the event's target and invokes it.
|
||||
Returns true iff a dispatcher exists for the target.
|
||||
*/
|
||||
virtual bool dispatchEvent(const CEvent& event) = 0;
|
||||
virtual bool dispatchEvent(const Event& event) = 0;
|
||||
|
||||
//! Add event to queue
|
||||
/*!
|
||||
Adds \p event to the end of the queue.
|
||||
*/
|
||||
virtual void addEvent(const CEvent& event) = 0;
|
||||
virtual void addEvent(const Event& event) = 0;
|
||||
|
||||
//! Create a recurring timer
|
||||
/*!
|
||||
Creates and returns a timer. An event is returned after \p duration
|
||||
seconds and the timer is reset to countdown again. When a timer event
|
||||
is returned the data points to a \c CTimerEvent. The client must pass
|
||||
is returned the data points to a \c TimerEvent. The client must pass
|
||||
the returned timer to \c deleteTimer() (whether or not the timer has
|
||||
expired) to release the timer. The returned timer event uses the
|
||||
given \p target. If \p target is NULL it uses the returned timer as
|
||||
|
@ -113,25 +113,25 @@ public:
|
|||
|
||||
Events for a single timer don't accumulate in the queue, even if the
|
||||
client reading events can't keep up. Instead, the \c m_count member
|
||||
of the \c CTimerEvent indicates how many events for the timer would
|
||||
of the \c TimerEvent indicates how many events for the timer would
|
||||
have been put on the queue since the last event for the timer was
|
||||
removed (or since the timer was added).
|
||||
*/
|
||||
virtual CEventQueueTimer*
|
||||
virtual EventQueueTimer*
|
||||
newTimer(double duration, void* target) = 0;
|
||||
|
||||
//! Create a one-shot timer
|
||||
/*!
|
||||
Creates and returns a one-shot timer. An event is returned when
|
||||
the timer expires and the timer is removed from further handling.
|
||||
When a timer event is returned the data points to a \c CTimerEvent.
|
||||
The c_count member of the \c CTimerEvent is always 1. The client
|
||||
When a timer event is returned the data points to a \c TimerEvent.
|
||||
The c_count member of the \c TimerEvent is always 1. The client
|
||||
must pass the returned timer to \c deleteTimer() (whether or not the
|
||||
timer has expired) to release the timer. The returned timer event
|
||||
uses the given \p target. If \p target is NULL it uses the returned
|
||||
timer as the target.
|
||||
*/
|
||||
virtual CEventQueueTimer*
|
||||
virtual EventQueueTimer*
|
||||
newOneShotTimer(double duration,
|
||||
void* target) = 0;
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
Destroys a previously created timer. The timer is removed from the
|
||||
queue and will not generate event, even if the timer has expired.
|
||||
*/
|
||||
virtual void deleteTimer(CEventQueueTimer*) = 0;
|
||||
virtual void deleteTimer(EventQueueTimer*) = 0;
|
||||
|
||||
//! Register an event handler for an event type
|
||||
/*!
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
of type \p type. If no such handler exists it will use the handler
|
||||
for \p target and type \p kUnknown if it exists.
|
||||
*/
|
||||
virtual void adoptHandler(CEvent::Type type,
|
||||
virtual void adoptHandler(Event::Type type,
|
||||
void* target, IEventJob* handler) = 0;
|
||||
|
||||
//! Unregister an event handler for an event type
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
Unregisters an event handler for the \p type, \p target pair and
|
||||
deletes it.
|
||||
*/
|
||||
virtual void removeHandler(CEvent::Type type, void* target) = 0;
|
||||
virtual void removeHandler(Event::Type type, void* target) = 0;
|
||||
|
||||
//! Unregister all event handlers for an event target
|
||||
/*!
|
||||
|
@ -172,8 +172,8 @@ public:
|
|||
type id otherwise it is left alone. The final value of \p type
|
||||
is returned.
|
||||
*/
|
||||
virtual CEvent::Type
|
||||
registerTypeOnce(CEvent::Type& type,
|
||||
virtual Event::Type
|
||||
registerTypeOnce(Event::Type& type,
|
||||
const char* name) = 0;
|
||||
|
||||
//! Wait for event queue to become ready
|
||||
|
@ -199,24 +199,24 @@ public:
|
|||
Finds and returns the event handler for the \p type, \p target pair
|
||||
if it exists, otherwise it returns NULL.
|
||||
*/
|
||||
virtual IEventJob* getHandler(CEvent::Type type, void* target) const = 0;
|
||||
virtual IEventJob* getHandler(Event::Type type, void* target) const = 0;
|
||||
|
||||
//! Get name for event
|
||||
/*!
|
||||
Returns the name for the event \p type. This is primarily for
|
||||
debugging.
|
||||
*/
|
||||
virtual const char* getTypeName(CEvent::Type type) = 0;
|
||||
virtual const char* getTypeName(Event::Type type) = 0;
|
||||
|
||||
//! Get an event type by name
|
||||
/*!
|
||||
Returns the registered type for an event for a given name.
|
||||
*/
|
||||
virtual CEvent::Type getRegisteredType(const CString& name) const = 0;
|
||||
virtual Event::Type getRegisteredType(const String& name) const = 0;
|
||||
|
||||
//! Get the system event type target
|
||||
/*!
|
||||
Returns the target to use for dispatching \c CEvent::kSystem events.
|
||||
Returns the target to use for dispatching \c Event::kSystem events.
|
||||
*/
|
||||
virtual void* getSystemTarget() = 0;
|
||||
|
||||
|
@ -226,21 +226,21 @@ public:
|
|||
// Event type providers.
|
||||
//
|
||||
|
||||
virtual CClientEvents& forCClient() = 0;
|
||||
virtual ClientEvents& forClient() = 0;
|
||||
virtual IStreamEvents& forIStream() = 0;
|
||||
virtual CIpcClientEvents& forCIpcClient() = 0;
|
||||
virtual CIpcClientProxyEvents& forCIpcClientProxy() = 0;
|
||||
virtual CIpcServerEvents& forCIpcServer() = 0;
|
||||
virtual CIpcServerProxyEvents& forCIpcServerProxy() = 0;
|
||||
virtual IpcClientEvents& forIpcClient() = 0;
|
||||
virtual IpcClientProxyEvents& forIpcClientProxy() = 0;
|
||||
virtual IpcServerEvents& forIpcServer() = 0;
|
||||
virtual IpcServerProxyEvents& forIpcServerProxy() = 0;
|
||||
virtual IDataSocketEvents& forIDataSocket() = 0;
|
||||
virtual IListenSocketEvents& forIListenSocket() = 0;
|
||||
virtual ISocketEvents& forISocket() = 0;
|
||||
virtual COSXScreenEvents& forCOSXScreen() = 0;
|
||||
virtual CClientListenerEvents& forCClientListener() = 0;
|
||||
virtual CClientProxyEvents& forCClientProxy() = 0;
|
||||
virtual CClientProxyUnknownEvents& forCClientProxyUnknown() = 0;
|
||||
virtual CServerEvents& forCServer() = 0;
|
||||
virtual CServerAppEvents& forCServerApp() = 0;
|
||||
virtual OSXScreenEvents& forOSXScreen() = 0;
|
||||
virtual ClientListenerEvents& forClientListener() = 0;
|
||||
virtual ClientProxyEvents& forClientProxy() = 0;
|
||||
virtual ClientProxyUnknownEvents& forClientProxyUnknown() = 0;
|
||||
virtual ServerEvents& forServer() = 0;
|
||||
virtual ServerAppEvents& forServerApp() = 0;
|
||||
virtual IKeyStateEvents& forIKeyState() = 0;
|
||||
virtual IPrimaryScreenEvents& forIPrimaryScreen() = 0;
|
||||
virtual IScreenEvents& forIScreen() = 0;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue