refactor: remove ArchFile, move only use of getInstallDir to MSWindowsWatchdog
This commit is contained in:
parent
516f803eb4
commit
8b5a61f07f
8 changed files with 9 additions and 164 deletions
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
#include "arch/win32/ArchConsoleWindows.h"
|
#include "arch/win32/ArchConsoleWindows.h"
|
||||||
#include "arch/win32/ArchDaemonWindows.h"
|
#include "arch/win32/ArchDaemonWindows.h"
|
||||||
#include "arch/win32/ArchFileWindows.h"
|
|
||||||
#include "arch/win32/ArchLogWindows.h"
|
#include "arch/win32/ArchLogWindows.h"
|
||||||
#include "arch/win32/ArchMultithreadWindows.h"
|
#include "arch/win32/ArchMultithreadWindows.h"
|
||||||
#include "arch/win32/ArchNetworkWinsock.h"
|
#include "arch/win32/ArchNetworkWinsock.h"
|
||||||
|
|
@ -42,7 +41,6 @@
|
||||||
|
|
||||||
#include "arch/unix/ArchConsoleUnix.h"
|
#include "arch/unix/ArchConsoleUnix.h"
|
||||||
#include "arch/unix/ArchDaemonUnix.h"
|
#include "arch/unix/ArchDaemonUnix.h"
|
||||||
#include "arch/unix/ArchFileUnix.h"
|
|
||||||
#include "arch/unix/ArchLogUnix.h"
|
#include "arch/unix/ArchLogUnix.h"
|
||||||
#include "arch/unix/ArchNetworkBSD.h"
|
#include "arch/unix/ArchNetworkBSD.h"
|
||||||
#include "arch/unix/ArchSleepUnix.h"
|
#include "arch/unix/ArchSleepUnix.h"
|
||||||
|
|
@ -73,7 +71,6 @@ typically at the beginning of \c main().
|
||||||
*/
|
*/
|
||||||
class Arch : public ARCH_CONSOLE,
|
class Arch : public ARCH_CONSOLE,
|
||||||
public ARCH_DAEMON,
|
public ARCH_DAEMON,
|
||||||
public ARCH_FILE,
|
|
||||||
public ARCH_LOG,
|
public ARCH_LOG,
|
||||||
public ARCH_MULTITHREAD,
|
public ARCH_MULTITHREAD,
|
||||||
public ARCH_NETWORK,
|
public ARCH_NETWORK,
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ if(WIN32)
|
||||||
win32/ArchConsoleWindows.h
|
win32/ArchConsoleWindows.h
|
||||||
win32/ArchDaemonWindows.cpp
|
win32/ArchDaemonWindows.cpp
|
||||||
win32/ArchDaemonWindows.h
|
win32/ArchDaemonWindows.h
|
||||||
win32/ArchFileWindows.cpp
|
|
||||||
win32/ArchFileWindows.h
|
|
||||||
win32/ArchLogWindows.cpp
|
win32/ArchLogWindows.cpp
|
||||||
win32/ArchLogWindows.h
|
win32/ArchLogWindows.h
|
||||||
win32/ArchMiscWindows.cpp
|
win32/ArchMiscWindows.cpp
|
||||||
|
|
@ -36,8 +34,6 @@ elseif(UNIX)
|
||||||
unix/ArchConsoleUnix.h
|
unix/ArchConsoleUnix.h
|
||||||
unix/ArchDaemonUnix.cpp
|
unix/ArchDaemonUnix.cpp
|
||||||
unix/ArchDaemonUnix.h
|
unix/ArchDaemonUnix.h
|
||||||
unix/ArchFileUnix.cpp
|
|
||||||
unix/ArchFileUnix.h
|
|
||||||
unix/ArchLogUnix.cpp
|
unix/ArchLogUnix.cpp
|
||||||
unix/ArchLogUnix.h
|
unix/ArchLogUnix.h
|
||||||
unix/ArchMultithreadPosix.cpp
|
unix/ArchMultithreadPosix.cpp
|
||||||
|
|
@ -64,7 +60,6 @@ add_library(arch STATIC ${PLATFORM_CODE}
|
||||||
ArchDaemonNone.h
|
ArchDaemonNone.h
|
||||||
IArchConsole.h
|
IArchConsole.h
|
||||||
IArchDaemon.h
|
IArchDaemon.h
|
||||||
IArchFile.h
|
|
||||||
IArchLog.h
|
IArchLog.h
|
||||||
IArchMultithread.h
|
IArchMultithread.h
|
||||||
IArchNetwork.h
|
IArchNetwork.h
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/IInterface.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
//! Interface for architecture dependent file system operations
|
|
||||||
/*!
|
|
||||||
This interface defines the file system operations required by
|
|
||||||
deskflow. Each architecture must implement this interface.
|
|
||||||
*/
|
|
||||||
class IArchFile : public IInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! @name manipulators
|
|
||||||
//@{
|
|
||||||
|
|
||||||
//! Get installed directory
|
|
||||||
/*!
|
|
||||||
Returns the directory in which Deskflow is installed.
|
|
||||||
*/
|
|
||||||
virtual std::string getInstalledDirectory() = 0;
|
|
||||||
};
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "arch/unix/ArchFileUnix.h"
|
|
||||||
|
|
||||||
#include "common/Constants.h"
|
|
||||||
#include <cstring>
|
|
||||||
#include <filesystem>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// ArchFileUnix
|
|
||||||
//
|
|
||||||
|
|
||||||
ArchFileUnix::ArchFileUnix()
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchFileUnix::~ArchFileUnix()
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ArchFileUnix::getInstalledDirectory()
|
|
||||||
{
|
|
||||||
#if WINAPI_XWINDOWS
|
|
||||||
return "/usr/bin";
|
|
||||||
#else
|
|
||||||
std::string rtn = "/Applications/";
|
|
||||||
rtn.append(kAppName).append(".app/Contents/MacOS");
|
|
||||||
return rtn;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "arch/IArchFile.h"
|
|
||||||
|
|
||||||
#define ARCH_FILE ArchFileUnix
|
|
||||||
|
|
||||||
//! Unix implementation of IArchFile
|
|
||||||
class ArchFileUnix : public IArchFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArchFileUnix();
|
|
||||||
virtual ~ArchFileUnix();
|
|
||||||
|
|
||||||
// IArchFile overrides
|
|
||||||
virtual std::string getInstalledDirectory();
|
|
||||||
};
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "arch/win32/ArchFileWindows.h"
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// ArchFileWindows
|
|
||||||
//
|
|
||||||
|
|
||||||
ArchFileWindows::ArchFileWindows()
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
ArchFileWindows::~ArchFileWindows()
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ArchFileWindows::getInstalledDirectory()
|
|
||||||
{
|
|
||||||
char fileNameBuffer[MAX_PATH];
|
|
||||||
GetModuleFileName(NULL, fileNameBuffer, MAX_PATH);
|
|
||||||
std::string fileName(fileNameBuffer);
|
|
||||||
size_t lastSlash = fileName.find_last_of("\\");
|
|
||||||
fileName = fileName.substr(0, lastSlash);
|
|
||||||
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "arch/IArchFile.h"
|
|
||||||
|
|
||||||
#define ARCH_FILE ArchFileWindows
|
|
||||||
|
|
||||||
//! Win32 implementation of IArchFile
|
|
||||||
class ArchFileWindows : public IArchFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArchFileWindows();
|
|
||||||
virtual ~ArchFileWindows();
|
|
||||||
|
|
||||||
// IArchFile overrides
|
|
||||||
virtual std::string getInstalledDirectory();
|
|
||||||
};
|
|
||||||
|
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Free functions
|
// Free functions
|
||||||
|
|
@ -436,7 +439,12 @@ void MSWindowsWatchdog::shutdownExistingProcesses()
|
||||||
|
|
||||||
std::string MSWindowsWatchdog::runActiveDesktopUtility()
|
std::string MSWindowsWatchdog::runActiveDesktopUtility()
|
||||||
{
|
{
|
||||||
const auto installDir = ARCH->getInstalledDirectory();
|
char fileNameBuffer[MAX_PATH];
|
||||||
|
GetModuleFileName(NULL, fileNameBuffer, MAX_PATH);
|
||||||
|
std::string fileName(fileNameBuffer);
|
||||||
|
size_t lastSlash = fileName.find_last_of("\\");
|
||||||
|
const auto installDir = fileName.substr(0, lastSlash);
|
||||||
|
|
||||||
const auto coreBinPath = installDir + "\\deskflow-server.exe";
|
const auto coreBinPath = installDir + "\\deskflow-server.exe";
|
||||||
std::string utilityCommand = "\"" + coreBinPath + "\" --active-desktop";
|
std::string utilityCommand = "\"" + coreBinPath + "\" --active-desktop";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue