mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-18 00:11:39 +03:00
Fixed "c" prefix compile error on Windows
This commit is contained in:
parent
34d8de4c3b
commit
1aaa55163c
@ -181,17 +181,17 @@ CMSWindowsPortableTaskBarReceiver::runMenu(int x, int y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_RELOAD_CONFIG:
|
case IDC_RELOAD_CONFIG:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().reloadConfig(),
|
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_FORCE_RECONNECT:
|
case IDC_FORCE_RECONNECT:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().forceReconnect(),
|
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SYNERGY_RESETSERVER:
|
case ID_SYNERGY_RESETSERVER:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().resetServer(),
|
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -195,17 +195,17 @@ CMSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_RELOAD_CONFIG:
|
case IDC_RELOAD_CONFIG:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().reloadConfig(),
|
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_FORCE_RECONNECT:
|
case IDC_FORCE_RECONNECT:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().forceReconnect(),
|
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SYNERGY_RESETSERVER:
|
case ID_SYNERGY_RESETSERVER:
|
||||||
m_events->addEvent(Event(m_events->forCServerApp().resetServer(),
|
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ FileLogOutputter::~FileLogOutputter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CFileLogOutputter::setLogFilename(const char* logFile)
|
FileLogOutputter::setLogFilename(const char* logFile)
|
||||||
{
|
{
|
||||||
assert(logFile != NULL);
|
assert(logFile != NULL);
|
||||||
m_fileName = logFile;
|
m_fileName = logFile;
|
||||||
|
@ -73,7 +73,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
typedef std::list<IpcClientProxy*> ClientList;
|
typedef std::list<IpcClientProxy*> ClientList;
|
||||||
|
|
||||||
CTCPListenSocket m_socket;
|
TCPListenSocket m_socket;
|
||||||
NetworkAddress m_address;
|
NetworkAddress m_address;
|
||||||
ClientList m_clients;
|
ClientList m_clients;
|
||||||
ArchMutex m_clientsMutex;
|
ArchMutex m_clientsMutex;
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// CTCPListenSocket
|
// TCPListenSocket
|
||||||
//
|
//
|
||||||
|
|
||||||
CTCPListenSocket::CTCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
|
TCPListenSocket::TCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer) :
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_socketMultiplexer(socketMultiplexer)
|
m_socketMultiplexer(socketMultiplexer)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ CTCPListenSocket::CTCPListenSocket(IEventQueue* events, SocketMultiplexer* socke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CTCPListenSocket::~CTCPListenSocket()
|
TCPListenSocket::~TCPListenSocket()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (m_socket != NULL) {
|
if (m_socket != NULL) {
|
||||||
@ -62,7 +62,7 @@ CTCPListenSocket::~CTCPListenSocket()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CTCPListenSocket::bind(const NetworkAddress& addr)
|
TCPListenSocket::bind(const NetworkAddress& addr)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Lock lock(m_mutex);
|
Lock lock(m_mutex);
|
||||||
@ -70,8 +70,8 @@ CTCPListenSocket::bind(const NetworkAddress& addr)
|
|||||||
ARCH->bindSocket(m_socket, addr.getAddress());
|
ARCH->bindSocket(m_socket, addr.getAddress());
|
||||||
ARCH->listenOnSocket(m_socket);
|
ARCH->listenOnSocket(m_socket);
|
||||||
m_socketMultiplexer->addSocket(this,
|
m_socketMultiplexer->addSocket(this,
|
||||||
new TSocketMultiplexerMethodJob<CTCPListenSocket>(
|
new TSocketMultiplexerMethodJob<TCPListenSocket>(
|
||||||
this, &CTCPListenSocket::serviceListening,
|
this, &TCPListenSocket::serviceListening,
|
||||||
m_socket, true, false));
|
m_socket, true, false));
|
||||||
}
|
}
|
||||||
catch (XArchNetworkAddressInUse& e) {
|
catch (XArchNetworkAddressInUse& e) {
|
||||||
@ -83,7 +83,7 @@ CTCPListenSocket::bind(const NetworkAddress& addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CTCPListenSocket::close()
|
TCPListenSocket::close()
|
||||||
{
|
{
|
||||||
Lock lock(m_mutex);
|
Lock lock(m_mutex);
|
||||||
if (m_socket == NULL) {
|
if (m_socket == NULL) {
|
||||||
@ -100,21 +100,21 @@ CTCPListenSocket::close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
CTCPListenSocket::getEventTarget() const
|
TCPListenSocket::getEventTarget() const
|
||||||
{
|
{
|
||||||
return const_cast<void*>(reinterpret_cast<const void*>(this));
|
return const_cast<void*>(reinterpret_cast<const void*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
IDataSocket*
|
IDataSocket*
|
||||||
CTCPListenSocket::accept()
|
TCPListenSocket::accept()
|
||||||
{
|
{
|
||||||
IDataSocket* socket = NULL;
|
IDataSocket* socket = NULL;
|
||||||
try {
|
try {
|
||||||
socket = new CTCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL));
|
socket = new CTCPSocket(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL));
|
||||||
if (socket != NULL) {
|
if (socket != NULL) {
|
||||||
m_socketMultiplexer->addSocket(this,
|
m_socketMultiplexer->addSocket(this,
|
||||||
new TSocketMultiplexerMethodJob<CTCPListenSocket>(
|
new TSocketMultiplexerMethodJob<TCPListenSocket>(
|
||||||
this, &CTCPListenSocket::serviceListening,
|
this, &TCPListenSocket::serviceListening,
|
||||||
m_socket, true, false));
|
m_socket, true, false));
|
||||||
}
|
}
|
||||||
return socket;
|
return socket;
|
||||||
@ -134,7 +134,7 @@ CTCPListenSocket::accept()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ISocketMultiplexerJob*
|
ISocketMultiplexerJob*
|
||||||
CTCPListenSocket::serviceListening(ISocketMultiplexerJob* job,
|
TCPListenSocket::serviceListening(ISocketMultiplexerJob* job,
|
||||||
bool read, bool, bool error)
|
bool read, bool, bool error)
|
||||||
{
|
{
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -30,10 +30,10 @@ class SocketMultiplexer;
|
|||||||
/*!
|
/*!
|
||||||
A listen socket using TCP.
|
A listen socket using TCP.
|
||||||
*/
|
*/
|
||||||
class CTCPListenSocket : public IListenSocket {
|
class TCPListenSocket : public IListenSocket {
|
||||||
public:
|
public:
|
||||||
CTCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
|
TCPListenSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
|
||||||
~CTCPListenSocket();
|
~TCPListenSocket();
|
||||||
|
|
||||||
// ISocket overrides
|
// ISocket overrides
|
||||||
virtual void bind(const NetworkAddress&);
|
virtual void bind(const NetworkAddress&);
|
||||||
|
@ -46,5 +46,5 @@ CTCPSocketFactory::create() const
|
|||||||
IListenSocket*
|
IListenSocket*
|
||||||
CTCPSocketFactory::createListen() const
|
CTCPSocketFactory::createListen() const
|
||||||
{
|
{
|
||||||
return new CTCPListenSocket(m_events, m_socketMultiplexer);
|
return new TCPListenSocket(m_events, m_socketMultiplexer);
|
||||||
}
|
}
|
||||||
|
@ -172,10 +172,10 @@ CMSWindowsSession::nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry)
|
|||||||
return gotEntry;
|
return gotEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString
|
String
|
||||||
CMSWindowsSession::getActiveDesktopName()
|
CMSWindowsSession::getActiveDesktopName()
|
||||||
{
|
{
|
||||||
CString result;
|
String result;
|
||||||
|
|
||||||
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
HDESK hd = OpenInputDesktop(0, TRUE, GENERIC_READ);
|
||||||
if (hd != NULL) {
|
if (hd != NULL) {
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
void updateActiveSession();
|
void updateActiveSession();
|
||||||
|
|
||||||
CString getActiveDesktopName();
|
String getActiveDesktopName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry);
|
BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry);
|
||||||
|
@ -45,7 +45,7 @@ typedef VOID (WINAPI *SendSas)(BOOL asUser);
|
|||||||
|
|
||||||
const char g_activeDesktop[] = {"activeDesktop:"};
|
const char g_activeDesktop[] = {"activeDesktop:"};
|
||||||
|
|
||||||
CMSWindowsWatchdog::CMSWindowsWatchdog(
|
MSWindowsWatchdog::MSWindowsWatchdog(
|
||||||
bool autoDetectCommand,
|
bool autoDetectCommand,
|
||||||
IpcServer& ipcServer,
|
IpcServer& ipcServer,
|
||||||
IpcLogOutputter& ipcLogOutputter) :
|
IpcLogOutputter& ipcLogOutputter) :
|
||||||
@ -68,7 +68,7 @@ CMSWindowsWatchdog::CMSWindowsWatchdog(
|
|||||||
m_condVar = ARCH->newCondVar();
|
m_condVar = ARCH->newCondVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMSWindowsWatchdog::~CMSWindowsWatchdog()
|
MSWindowsWatchdog::~MSWindowsWatchdog()
|
||||||
{
|
{
|
||||||
if (m_condVar != NULL) {
|
if (m_condVar != NULL) {
|
||||||
ARCH->closeCondVar(m_condVar);
|
ARCH->closeCondVar(m_condVar);
|
||||||
@ -80,17 +80,17 @@ CMSWindowsWatchdog::~CMSWindowsWatchdog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::startAsync()
|
MSWindowsWatchdog::startAsync()
|
||||||
{
|
{
|
||||||
m_thread = new Thread(new TMethodJob<CMSWindowsWatchdog>(
|
m_thread = new Thread(new TMethodJob<MSWindowsWatchdog>(
|
||||||
this, &CMSWindowsWatchdog::mainLoop, nullptr));
|
this, &MSWindowsWatchdog::mainLoop, nullptr));
|
||||||
|
|
||||||
m_outputThread = new Thread(new TMethodJob<CMSWindowsWatchdog>(
|
m_outputThread = new Thread(new TMethodJob<MSWindowsWatchdog>(
|
||||||
this, &CMSWindowsWatchdog::outputLoop, nullptr));
|
this, &MSWindowsWatchdog::outputLoop, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::stop()
|
MSWindowsWatchdog::stop()
|
||||||
{
|
{
|
||||||
m_monitoring = false;
|
m_monitoring = false;
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ CMSWindowsWatchdog::stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
CMSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security)
|
MSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security)
|
||||||
{
|
{
|
||||||
HANDLE sourceToken;
|
HANDLE sourceToken;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ CMSWindowsWatchdog::duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES
|
|||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
CMSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security)
|
MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security)
|
||||||
{
|
{
|
||||||
// always elevate if we are at the vista/7 login screen. we could also
|
// always elevate if we are at the vista/7 login screen. we could also
|
||||||
// elevate for the uac dialog (consent.exe) but this would be pointless,
|
// elevate for the uac dialog (consent.exe) but this would be pointless,
|
||||||
@ -160,7 +160,7 @@ CMSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::mainLoop(void*)
|
MSWindowsWatchdog::mainLoop(void*)
|
||||||
{
|
{
|
||||||
shutdownExistingProcesses();
|
shutdownExistingProcesses();
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ CMSWindowsWatchdog::mainLoop(void*)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CMSWindowsWatchdog::isProcessActive()
|
MSWindowsWatchdog::isProcessActive()
|
||||||
{
|
{
|
||||||
DWORD exitCode;
|
DWORD exitCode;
|
||||||
GetExitCodeProcess(m_processInfo.hProcess, &exitCode);
|
GetExitCodeProcess(m_processInfo.hProcess, &exitCode);
|
||||||
@ -263,13 +263,13 @@ CMSWindowsWatchdog::isProcessActive()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::setFileLogOutputter(CFileLogOutputter* outputter)
|
MSWindowsWatchdog::setFileLogOutputter(FileLogOutputter* outputter)
|
||||||
{
|
{
|
||||||
m_fileLogOutputter = outputter;
|
m_fileLogOutputter = outputter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::startProcess()
|
MSWindowsWatchdog::startProcess()
|
||||||
{
|
{
|
||||||
if (m_command.empty()) {
|
if (m_command.empty()) {
|
||||||
throw XMSWindowsWatchdogError("cannot start process, command is empty");
|
throw XMSWindowsWatchdogError("cannot start process, command is empty");
|
||||||
@ -325,7 +325,7 @@ CMSWindowsWatchdog::startProcess()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
CMSWindowsWatchdog::doStartProcess(CString& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
|
MSWindowsWatchdog::doStartProcess(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa)
|
||||||
{
|
{
|
||||||
// clear, as we're reusing process info struct
|
// clear, as we're reusing process info struct
|
||||||
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
|
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
|
||||||
@ -364,7 +364,7 @@ CMSWindowsWatchdog::doStartProcess(CString& command, HANDLE userToken, LPSECURIT
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::setCommand(const std::string& command, bool elevate)
|
MSWindowsWatchdog::setCommand(const std::string& command, bool elevate)
|
||||||
{
|
{
|
||||||
LOG((CLOG_INFO "service command updated"));
|
LOG((CLOG_INFO "service command updated"));
|
||||||
m_command = command;
|
m_command = command;
|
||||||
@ -374,7 +374,7 @@ CMSWindowsWatchdog::setCommand(const std::string& command, bool elevate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
CMSWindowsWatchdog::getCommand() const
|
MSWindowsWatchdog::getCommand() const
|
||||||
{
|
{
|
||||||
if (!m_autoDetectCommand) {
|
if (!m_autoDetectCommand) {
|
||||||
return m_command;
|
return m_command;
|
||||||
@ -400,7 +400,7 @@ CMSWindowsWatchdog::getCommand() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::outputLoop(void*)
|
MSWindowsWatchdog::outputLoop(void*)
|
||||||
{
|
{
|
||||||
// +1 char for \0
|
// +1 char for \0
|
||||||
CHAR buffer[kOutputBufferSize + 1];
|
CHAR buffer[kOutputBufferSize + 1];
|
||||||
@ -432,7 +432,7 @@ CMSWindowsWatchdog::outputLoop(void*)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
MSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
||||||
{
|
{
|
||||||
DWORD exitCode;
|
DWORD exitCode;
|
||||||
GetExitCodeProcess(handle, &exitCode);
|
GetExitCodeProcess(handle, &exitCode);
|
||||||
@ -472,7 +472,7 @@ CMSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::shutdownExistingProcesses()
|
MSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
{
|
{
|
||||||
// first we need to take a snapshot of the running processes
|
// first we need to take a snapshot of the running processes
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
@ -526,11 +526,11 @@ CMSWindowsWatchdog::shutdownExistingProcesses()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::getActiveDesktop(LPSECURITY_ATTRIBUTES security)
|
MSWindowsWatchdog::getActiveDesktop(LPSECURITY_ATTRIBUTES security)
|
||||||
{
|
{
|
||||||
CString installedDir = ARCH->getInstalledDirectory();
|
String installedDir = ARCH->getInstalledDirectory();
|
||||||
if (!installedDir.empty()) {
|
if (!installedDir.empty()) {
|
||||||
CString syntoolCommand;
|
String syntoolCommand;
|
||||||
syntoolCommand.append("\"").append(installedDir).append("\\").append("syntool").append("\"");
|
syntoolCommand.append("\"").append(installedDir).append("\\").append("syntool").append("\"");
|
||||||
syntoolCommand.append(" --get-active-desktop");
|
syntoolCommand.append(" --get-active-desktop");
|
||||||
|
|
||||||
@ -560,14 +560,14 @@ CMSWindowsWatchdog::getActiveDesktop(LPSECURITY_ATTRIBUTES security)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsWatchdog::testOutput(CString buffer)
|
MSWindowsWatchdog::testOutput(String buffer)
|
||||||
{
|
{
|
||||||
// HACK: check standard output seems hacky.
|
// HACK: check standard output seems hacky.
|
||||||
size_t i = buffer.find(g_activeDesktop);
|
size_t i = buffer.find(g_activeDesktop);
|
||||||
if (i != CString::npos) {
|
if (i != String::npos) {
|
||||||
size_t s = sizeof(g_activeDesktop);
|
size_t s = sizeof(g_activeDesktop);
|
||||||
CString defaultDesktop("Default");
|
String defaultDesktop("Default");
|
||||||
CString sub = buffer.substr(s - 1, defaultDesktop.size());
|
String sub = buffer.substr(s - 1, defaultDesktop.size());
|
||||||
if (sub != defaultDesktop) {
|
if (sub != defaultDesktop) {
|
||||||
m_autoElevated = true;
|
m_autoElevated = true;
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,20 @@ class IpcLogOutputter;
|
|||||||
class IpcServer;
|
class IpcServer;
|
||||||
class FileLogOutputter;
|
class FileLogOutputter;
|
||||||
|
|
||||||
class CMSWindowsWatchdog {
|
class MSWindowsWatchdog {
|
||||||
public:
|
public:
|
||||||
CMSWindowsWatchdog(
|
MSWindowsWatchdog(
|
||||||
bool autoDetectCommand,
|
bool autoDetectCommand,
|
||||||
IpcServer& ipcServer,
|
IpcServer& ipcServer,
|
||||||
IpcLogOutputter& ipcLogOutputter);
|
IpcLogOutputter& ipcLogOutputter);
|
||||||
virtual ~CMSWindowsWatchdog();
|
virtual ~MSWindowsWatchdog();
|
||||||
|
|
||||||
void startAsync();
|
void startAsync();
|
||||||
std::string getCommand() const;
|
std::string getCommand() const;
|
||||||
void setCommand(const std::string& command, bool elevate);
|
void setCommand(const std::string& command, bool elevate);
|
||||||
void stop();
|
void stop();
|
||||||
bool isProcessActive();
|
bool isProcessActive();
|
||||||
void setFileLogOutputter(CFileLogOutputter* outputter);
|
void setFileLogOutputter(FileLogOutputter* outputter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void mainLoop(void*);
|
void mainLoop(void*);
|
||||||
@ -55,20 +55,20 @@ private:
|
|||||||
HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security);
|
HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security);
|
||||||
HANDLE getUserToken(LPSECURITY_ATTRIBUTES security);
|
HANDLE getUserToken(LPSECURITY_ATTRIBUTES security);
|
||||||
void startProcess();
|
void startProcess();
|
||||||
BOOL doStartProcess(CString& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
|
BOOL doStartProcess(String& command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
|
||||||
void sendSas();
|
void sendSas();
|
||||||
void getActiveDesktop(LPSECURITY_ATTRIBUTES security);
|
void getActiveDesktop(LPSECURITY_ATTRIBUTES security);
|
||||||
void testOutput(CString buffer);
|
void testOutput(String buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Thread* m_thread;
|
Thread* m_thread;
|
||||||
bool m_autoDetectCommand;
|
bool m_autoDetectCommand;
|
||||||
std::string m_command;
|
std::string m_command;
|
||||||
bool m_monitoring;
|
bool m_monitoring;
|
||||||
bool m_commandChanged;
|
bool m_commandChanged;
|
||||||
HANDLE m_stdOutWrite;
|
HANDLE m_stdOutWrite;
|
||||||
HANDLE m_stdOutRead;
|
HANDLE m_stdOutRead;
|
||||||
Thread* m_outputThread;
|
Thread* m_outputThread;
|
||||||
IpcServer& m_ipcServer;
|
IpcServer& m_ipcServer;
|
||||||
IpcLogOutputter& m_ipcLogOutputter;
|
IpcLogOutputter& m_ipcLogOutputter;
|
||||||
bool m_elevateProcess;
|
bool m_elevateProcess;
|
||||||
@ -76,10 +76,10 @@ private:
|
|||||||
PROCESS_INFORMATION m_processInfo;
|
PROCESS_INFORMATION m_processInfo;
|
||||||
int m_processFailures;
|
int m_processFailures;
|
||||||
bool m_processRunning;
|
bool m_processRunning;
|
||||||
CFileLogOutputter* m_fileLogOutputter;
|
FileLogOutputter* m_fileLogOutputter;
|
||||||
bool m_autoElevated;
|
bool m_autoElevated;
|
||||||
CArchMutex m_mutex;
|
ArchMutex m_mutex;
|
||||||
CArchCond m_condVar;
|
ArchCond m_condVar;
|
||||||
bool m_ready;
|
bool m_ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -246,78 +246,78 @@ App::runEventsLoop(void*)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// CMinimalApp
|
// MinimalApp
|
||||||
//
|
//
|
||||||
|
|
||||||
CMinimalApp::CMinimalApp() :
|
MinimalApp::MinimalApp() :
|
||||||
CApp(NULL, NULL, new CArgsBase())
|
App(NULL, NULL, new ArgsBase())
|
||||||
{
|
{
|
||||||
setEvents(m_events);
|
setEvents(m_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMinimalApp::~CMinimalApp()
|
MinimalApp::~MinimalApp()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CMinimalApp::standardStartup(int argc, char** argv)
|
MinimalApp::standardStartup(int argc, char** argv)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CMinimalApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup)
|
MinimalApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc startup)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMinimalApp::startNode()
|
MinimalApp::startNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CMinimalApp::mainLoop()
|
MinimalApp::mainLoop()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CMinimalApp::foregroundStartup(int argc, char** argv)
|
MinimalApp::foregroundStartup(int argc, char** argv)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScreen*
|
Screen*
|
||||||
CMinimalApp::createScreen()
|
MinimalApp::createScreen()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMinimalApp::loadConfig()
|
MinimalApp::loadConfig()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CMinimalApp::loadConfig(const CString& pathname)
|
MinimalApp::loadConfig(const String& pathname)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
CMinimalApp::daemonInfo() const
|
MinimalApp::daemonInfo() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
CMinimalApp::daemonName() const
|
MinimalApp::daemonName() const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMinimalApp::parseArgs(int argc, const char* const* argv)
|
MinimalApp::parseArgs(int argc, const char* const* argv)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
void setSocketMultiplexer(SocketMultiplexer* sm) { m_socketMultiplexer = sm; }
|
void setSocketMultiplexer(SocketMultiplexer* sm) { m_socketMultiplexer = sm; }
|
||||||
SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer; }
|
SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer; }
|
||||||
|
|
||||||
void setEvents(CEventQueue& events) { m_events = &events; }
|
void setEvents(EventQueue& events) { m_events = &events; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleIpcMessage(const Event&, void*);
|
void handleIpcMessage(const Event&, void*);
|
||||||
@ -122,10 +122,10 @@ private:
|
|||||||
SocketMultiplexer* m_socketMultiplexer;
|
SocketMultiplexer* m_socketMultiplexer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMinimalApp : public CApp {
|
class MinimalApp : public App {
|
||||||
public:
|
public:
|
||||||
CMinimalApp();
|
MinimalApp();
|
||||||
virtual ~CMinimalApp();
|
virtual ~MinimalApp();
|
||||||
|
|
||||||
// IApp overrides
|
// IApp overrides
|
||||||
virtual int standardStartup(int argc, char** argv);
|
virtual int standardStartup(int argc, char** argv);
|
||||||
@ -133,17 +133,17 @@ public:
|
|||||||
virtual void startNode();
|
virtual void startNode();
|
||||||
virtual int mainLoop();
|
virtual int mainLoop();
|
||||||
virtual int foregroundStartup(int argc, char** argv);
|
virtual int foregroundStartup(int argc, char** argv);
|
||||||
virtual CScreen* createScreen();
|
virtual Screen* createScreen();
|
||||||
virtual void loadConfig();
|
virtual void loadConfig();
|
||||||
virtual bool loadConfig(const CString& pathname);
|
virtual bool loadConfig(const String& pathname);
|
||||||
virtual const char* daemonInfo() const;
|
virtual const char* daemonInfo() const;
|
||||||
virtual const char* daemonName() const;
|
virtual const char* daemonName() const;
|
||||||
virtual void parseArgs(int argc, const char* const* argv);
|
virtual void parseArgs(int argc, const char* const* argv);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CArch m_arch;
|
Arch m_arch;
|
||||||
CLog m_log;
|
Log m_log;
|
||||||
CEventQueue m_events;
|
EventQueue m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if WINAPI_MSWINDOWS
|
#if WINAPI_MSWINDOWS
|
||||||
|
@ -158,7 +158,7 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CArgParser::parseToolArgs(CToolArgs& args, int argc, const char* const* argv)
|
ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (isArg(i, argc, argv, NULL, "--get-active-desktop", 0)) {
|
if (isArg(i, argc, argv, NULL, "--get-active-desktop", 0)) {
|
||||||
|
@ -199,7 +199,7 @@ DaemonApp::mainLoop(bool logToFile)
|
|||||||
DAEMON_RUNNING(true);
|
DAEMON_RUNNING(true);
|
||||||
|
|
||||||
if (logToFile) {
|
if (logToFile) {
|
||||||
m_fileLogOutputter = new CFileLogOutputter(logFilename().c_str());
|
m_fileLogOutputter = new FileLogOutputter(logFilename().c_str());
|
||||||
CLOG->insert(m_fileLogOutputter);
|
CLOG->insert(m_fileLogOutputter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ DaemonApp::mainLoop(bool logToFile)
|
|||||||
CLOG->insert(m_ipcLogOutputter);
|
CLOG->insert(m_ipcLogOutputter);
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
m_watchdog = new CMSWindowsWatchdog(false, *m_ipcServer, *m_ipcLogOutputter);
|
m_watchdog = new MSWindowsWatchdog(false, *m_ipcServer, *m_ipcLogOutputter);
|
||||||
m_watchdog->setFileLogOutputter(m_fileLogOutputter);
|
m_watchdog->setFileLogOutputter(m_fileLogOutputter);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -339,12 +339,12 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
CString logFilename;
|
String logFilename;
|
||||||
if (argBase->m_logFile != NULL) {
|
if (argBase->m_logFile != NULL) {
|
||||||
logFilename = CString(argBase->m_logFile);
|
logFilename = String(argBase->m_logFile);
|
||||||
ARCH->setting("LogFilename", logFilename);
|
ARCH->setting("LogFilename", logFilename);
|
||||||
m_watchdog->setFileLogOutputter(m_fileLogOutputter);
|
m_watchdog->setFileLogOutputter(m_fileLogOutputter);
|
||||||
command = CArgParser::assembleCommand(argsArray, "--log", 1);
|
command = ArgParser::assembleCommand(argsArray, "--log", 1);
|
||||||
LOG((CLOG_DEBUG "removed log file argument and filename %s from command ", logFilename.c_str()));
|
LOG((CLOG_DEBUG "removed log file argument and filename %s from command ", logFilename.c_str()));
|
||||||
LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));
|
LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class IpcLogOutputter;
|
|||||||
class FileLogOutputter;
|
class FileLogOutputter;
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
class CMSWindowsWatchdog;
|
class MSWindowsWatchdog;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class DaemonApp {
|
class DaemonApp {
|
||||||
|
@ -45,7 +45,7 @@ ToolApp::run(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CArgParser argParser(this);
|
ArgParser argParser(this);
|
||||||
bool result = argParser.parseToolArgs(m_args, argc, argv);
|
bool result = argParser.parseToolArgs(m_args, argc, argv);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@ -55,7 +55,7 @@ ToolApp::run(int argc, char** argv)
|
|||||||
if (m_args.m_printActiveDesktopName) {
|
if (m_args.m_printActiveDesktopName) {
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
CMSWindowsSession session;
|
CMSWindowsSession session;
|
||||||
CString name = session.getActiveDesktopName();
|
String name = session.getActiveDesktopName();
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
LOG((CLOG_CRIT "failed to get active desktop name"));
|
LOG((CLOG_CRIT "failed to get active desktop name"));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
@ -82,6 +82,6 @@ ToolApp::run(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CToolApp::help()
|
ToolApp::help()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -27,5 +27,5 @@ public:
|
|||||||
UInt32 run(int argc, char** argv);
|
UInt32 run(int argc, char** argv);
|
||||||
void help();
|
void help();
|
||||||
private:
|
private:
|
||||||
CToolArgs m_args;
|
ToolArgs m_args;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "synergy/ToolArgs.h"
|
#include "synergy/ToolArgs.h"
|
||||||
|
|
||||||
CToolArgs::CToolArgs() :
|
ToolArgs::ToolArgs() :
|
||||||
m_printActiveDesktopName(false)
|
m_printActiveDesktopName(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
#include "base/String.h"
|
#include "base/String.h"
|
||||||
|
|
||||||
class CToolArgs {
|
class ToolArgs {
|
||||||
public:
|
public:
|
||||||
CToolArgs();
|
ToolArgs();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_printActiveDesktopName;
|
bool m_printActiveDesktopName;
|
||||||
|
Loading…
Reference in New Issue
Block a user