fully replaced gui/daemon named pipes ipc with tcp ipc.

This commit is contained in:
Nick Bolton
2012-07-03 14:15:05 +00:00
parent 79d73bd163
commit 7d5fbde71d
25 changed files with 315 additions and 399 deletions

View File

@@ -42,7 +42,6 @@
# include "CArchDaemonWindows.h"
# include "CArchFileWindows.h"
# include "CArchLogWindows.h"
# include "CArchIpcLogWindows.h"
# include "CArchMiscWindows.h"
# include "CArchMultithreadWindows.h"
# include "CArchNetworkWinsock.h"
@@ -57,7 +56,6 @@
# include "CArchDaemonUnix.h"
# include "CArchFileUnix.h"
# include "CArchLogUnix.h"
# include "CArchIpcLogUnix.h"
# if HAVE_PTHREAD
# include "CArchMultithreadPosix.h"
# endif
@@ -111,7 +109,6 @@ public:
*/
static CArch* getInstance();
ARCH_IPC_LOG& ipcLog() const { return (ARCH_IPC_LOG&)m_ipcLog; }
ARCH_PLUGIN& plugin() const { return (ARCH_PLUGIN&)m_plugin; }
private:
@@ -120,7 +117,6 @@ private:
private:
static CArch* s_instance;
ARCH_IPC_LOG m_ipcLog;
ARCH_PLUGIN m_plugin;
};

View File

@@ -1,46 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CArchIpcLogUnix.h"
CArchIpcLogUnix::CArchIpcLogUnix()
{
}
CArchIpcLogUnix::~CArchIpcLogUnix()
{
}
void
CArchIpcLogUnix::openLog(const char* name)
{
}
void
CArchIpcLogUnix::closeLog()
{
}
void
CArchIpcLogUnix::showLog(bool showIfEmpty)
{
}
void
CArchIpcLogUnix::writeLog(ELevel, const char*)
{
}

View File

@@ -1,34 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "IArchLog.h"
#define ARCH_IPC_LOG CArchIpcLogUnix
class CArchIpcLogUnix : public IArchLog {
public:
CArchIpcLogUnix();
virtual ~CArchIpcLogUnix();
// IArchLog overrides
virtual void openLog(const char* name);
virtual void closeLog();
virtual void showLog(bool showIfEmpty);
virtual void writeLog(ELevel, const char*);
};

View File

@@ -1,111 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2002 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CArchIpcLogWindows.h"
#include "CArchMiscWindows.h"
#include "XArch.h"
#include "CThread.h"
#include "TMethodJob.h"
#include "CArch.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
//
// CArchIpcLogWindows
//
CArchIpcLogWindows::CArchIpcLogWindows() :
m_pipe(NULL),
m_listenThread(NULL),
m_connected(false)
{
}
CArchIpcLogWindows::~CArchIpcLogWindows()
{
if (m_listenThread != NULL)
delete m_listenThread;
}
void
CArchIpcLogWindows::openLog(const char* name)
{
// grant access to everyone.
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, static_cast<PACL>(0), FALSE);
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
HANDLE pipe = CreateNamedPipe(
TEXT("\\\\.\\pipe\\SynergyLog"),
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
1024, 1024, 0, &sa);
if (pipe == INVALID_HANDLE_VALUE)
XArch("could not create named pipe.");
m_pipe = pipe;
m_listenThread = new CThread(new TMethodJob<CArchIpcLogWindows>(
this, &CArchIpcLogWindows::connectThread, nullptr));
}
void
CArchIpcLogWindows::connectThread(void*)
{
// HACK: this seems like a hacky pile of bollocks. it will continuously call
// ConnectNamedPipe every second. if there is no client, it will block,
// but if there is a client it will return FALSE and GetLastError() will
// be ERROR_PIPE_CONNECTED. in any other case, the client has gone away
// and ConnectNamedPipe will go back to blocking (waiting for the client
// to reconnect).
while (true) {
BOOL result = ConnectNamedPipe(m_pipe, NULL);
if ((result == TRUE) || (GetLastError() == ERROR_PIPE_CONNECTED)) {
m_connected = true;
ARCH->sleep(1);
} else {
DisconnectNamedPipe(m_pipe);
}
}
}
void
CArchIpcLogWindows::closeLog()
{
}
void
CArchIpcLogWindows::showLog(bool)
{
}
void
CArchIpcLogWindows::writeLog(ELevel level, const char* data)
{
if (!m_connected)
return;
DWORD bytesWritten;
WriteFile(m_pipe, data, (DWORD)strlen(data), &bytesWritten, NULL);
}

View File

@@ -1,48 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define WIN32_LEAN_AND_MEAN
#include "IArchLog.h"
#include <windows.h>
#define ARCH_IPC_LOG CArchIpcLogWindows
class CThread;
//! Win32 implementation of IArchLog (IPC version)
class CArchIpcLogWindows : public IArchLog {
public:
CArchIpcLogWindows();
virtual ~CArchIpcLogWindows();
// IArchLog overrides
virtual void openLog(const char* name);
virtual void closeLog();
virtual void showLog(bool showIfEmpty);
virtual void writeLog(ELevel, const char*);
private:
void connectThread(void*);
private:
HANDLE m_pipe;
CThread* m_listenThread;
bool m_connected;
};

View File

@@ -27,7 +27,6 @@ if (WIN32)
CArchDaemonWindows.h
CArchFileWindows.h
CArchLogWindows.h
CArchIpcLogWindows.h
CArchMiscWindows.h
CArchMultithreadWindows.h
CArchNetworkWinsock.h
@@ -51,7 +50,6 @@ if (WIN32)
CArchDaemonWindows.cpp
CArchFileWindows.cpp
CArchLogWindows.cpp
CArchIpcLogWindows.cpp
CArchMiscWindows.cpp
CArchMultithreadWindows.cpp
CArchNetworkWinsock.cpp
@@ -71,7 +69,6 @@ elseif (UNIX)
CArchDaemonUnix.cpp
CArchFileUnix.cpp
CArchLogUnix.cpp
CArchIpcLogUnix.cpp
CArchMultithreadPosix.cpp
CArchNetworkBSD.cpp
CArchSleepUnix.cpp