moved stream into synergy namespace (to prevent naming collision in win libs)

implemented ipc "hello" message (to identify client type)
integ tests working for hello message, but use of ipc in main program has problem with events.
This commit is contained in:
Nick Bolton 2012-07-05 18:05:35 +00:00
parent 4e268760b3
commit 3d6551f708
57 changed files with 367 additions and 173 deletions

View file

@ -25,6 +25,10 @@
#include "LogOutputters.h"
#include "XSynergy.h"
#include "CArgsBase.h"
#include "CIpcServerProxy.h"
#include "TMethodEventJob.h"
#include "CIpcMessage.h"
#include "Ipc.h"
#if SYSAPI_WIN32
#include "CArchMiscWindows.h"
@ -46,7 +50,8 @@ m_createTaskBarReceiver(createTaskBarReceiver),
m_args(args),
m_bye(&exit),
m_taskBarReceiver(NULL),
m_suspended(false)
m_suspended(false),
m_ipcClient(nullptr)
{
assert(s_instance == nullptr);
s_instance = this;
@ -142,6 +147,10 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i)
argsBase().m_disableTray = true;
}
else if (isArg(i, argc, argv, NULL, "--ipc")) {
argsBase().m_enableIpc = true;
}
#if VNC_SUPPORT
else if (isArg(i, argc, argv, NULL, "--vnc")) {
argsBase().m_enableVnc = true;
@ -335,3 +344,33 @@ CApp::initApp(int argc, const char** argv)
m_taskBarReceiver = m_createTaskBarReceiver(logBuffer);
}
}
void
CApp::initIpcClient()
{
// TODO: delete ipc client on shutdown and the 2 event handlers.
m_ipcClient = new CIpcClient();
m_ipcClient->connect();
EVENTQUEUE->adoptHandler(
CIpcClient::getConnectedEvent(), m_ipcClient,
new TMethodEventJob<CApp>(this, &CApp::handleIpcConnected));
}
void
CApp::handleIpcConnected(const CEvent& e, void*)
{
EVENTQUEUE->adoptHandler(
CIpcServerProxy::getMessageReceivedEvent(), e.getData(),
new TMethodEventJob<CApp>(this, &CApp::handleIpcMessage));
}
void
CApp::handleIpcMessage(const CEvent& e, void*)
{
CIpcMessage* m = static_cast<CIpcMessage*>(e.getData());
if (m->m_type == kIpcShutdown) {
LOG((CLOG_INFO "got ipc shutdown message"));
EVENTQUEUE->addEvent(CEvent(CEvent::kQuit));
}
}