Single app for server and client (#7239)
* Remove unused files * Add synergy-core * Update ChangeLog * Fix compilation * Fix code smell * Add ability to run synergy-core using synergyd for windows
This commit is contained in:
parent
9cedc57dc3
commit
aff2b717fd
10 changed files with 126 additions and 224 deletions
|
|
@ -7,6 +7,7 @@ Bug fixes:
|
|||
Enhancements:
|
||||
- #7222 Ability to initiate non-TLS connection from server
|
||||
- #7225 Ability to initiate TLS connection from server
|
||||
- #7239 Single app for server and client
|
||||
|
||||
1.14.5
|
||||
======
|
||||
|
|
|
|||
|
|
@ -18,3 +18,4 @@ add_subdirectory(synergyd)
|
|||
add_subdirectory(synergyc)
|
||||
add_subdirectory(synergys)
|
||||
add_subdirectory(syntool)
|
||||
add_subdirectory(synergy-core)
|
||||
|
|
|
|||
30
src/cmd/synergy-core/CMakeLists.txt
Normal file
30
src/cmd/synergy-core/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2012-2022 Symless Ltd.
|
||||
# Copyright (C) 2009 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 LICENSE 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/>.
|
||||
|
||||
set(sources
|
||||
synergy-core.cpp
|
||||
)
|
||||
|
||||
add_executable(synergy-core ${sources})
|
||||
target_link_libraries(synergy-core
|
||||
arch base client common io mt net ipc platform server synlib ${libs})
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
install (TARGETS synergy-core DESTINATION ${SYNERGY_BUNDLE_BINARY_DIR})
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
install (TARGETS synergy-core DESTINATION bin)
|
||||
endif()
|
||||
|
||||
69
src/cmd/synergy-core/synergy-core.cpp
Normal file
69
src/cmd/synergy-core/synergy-core.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2022 Symless Ltd.
|
||||
* Copyright (C) 2002 Chris Schoeneman
|
||||
*
|
||||
* 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 LICENSE 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 <iostream>
|
||||
#include "synergy/ClientApp.h"
|
||||
#include "synergy/ServerApp.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/EventQueue.h"
|
||||
#include <vector>
|
||||
|
||||
void showHelp()
|
||||
{
|
||||
std::cout<<"Usage: synergy-core <server | client> [...options]"<<std::endl;
|
||||
std::cout<<"sever - start as a server (synergys)"<<std::endl;
|
||||
std::cout<<"client - start as a client (synergyc)"<<std::endl;
|
||||
std::cout<<"use synergy-core <sever|client> --help for more information."<<std::endl;
|
||||
}
|
||||
|
||||
bool isServer(int argc, char** argv)
|
||||
{
|
||||
return (argc > 1 && argv[1] == std::string("server"));
|
||||
}
|
||||
|
||||
bool isClient(int argc, char** argv)
|
||||
{
|
||||
return (argc > 1 && argv[1] == std::string("client"));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#if SYSAPI_WIN32
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
if (isServer(argc, argv)) {
|
||||
ServerApp app(&events, nullptr);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
else if (isClient(argc, argv)) {
|
||||
ClientApp app(&events, nullptr);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
else {
|
||||
showHelp();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -611,7 +611,8 @@ MSWindowsWatchdog::shutdownExistingProcesses()
|
|||
if (entry.th32ProcessID != 0) {
|
||||
|
||||
if (_stricmp(entry.szExeFile, "synergyc.exe") == 0 ||
|
||||
_stricmp(entry.szExeFile, "synergys.exe") == 0) {
|
||||
_stricmp(entry.szExeFile, "synergys.exe") == 0 ||
|
||||
_stricmp(entry.szExeFile, "synergy-core.exe") == 0) {
|
||||
|
||||
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
|
||||
shutdownProcess(handle, entry.th32ProcessID, 10);
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ App::initApp(int argc, const char** argv)
|
|||
// load configuration
|
||||
loadConfig();
|
||||
|
||||
if (!argsBase().m_disableTray) {
|
||||
if (!argsBase().m_disableTray && m_createTaskBarReceiver) {
|
||||
|
||||
// create a log buffer so we can show the latest message
|
||||
// as a tray icon tooltip
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ ArgParser::parseServerArgs(lib::synergy::ServerArgs& args, int argc, const char*
|
|||
else if (isArg(i, argc, argv, "", "--serial-key", 1)) {
|
||||
args.m_serial = SerialKey(argv[++i]);
|
||||
}
|
||||
else if (isArg(i, argc, argv, nullptr, "server")) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
|
||||
return false;
|
||||
|
|
@ -120,6 +124,10 @@ ArgParser::parseClientArgs(lib::synergy::ClientArgs& args, int argc, const char*
|
|||
else if (isArg(i, argc, argv, nullptr, "--host")) {
|
||||
args.m_hostMode = true;
|
||||
}
|
||||
else if (isArg(i, argc, argv, nullptr, "client")) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (i + 1 == argc) {
|
||||
args.m_synergyAddress = argv[i];
|
||||
|
|
|
|||
|
|
@ -72,6 +72,19 @@ updateSetting(const IpcMessage& message)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
isServerCommandLine(const std::vector<String>& cmd)
|
||||
{
|
||||
auto isServer = false;
|
||||
|
||||
if (cmd.size() > 1) {
|
||||
isServer = (cmd[0].find("synergys") != String::npos) ||
|
||||
(cmd[0].find("synergy-core") != String::npos && cmd[1] == "server");
|
||||
}
|
||||
|
||||
return isServer;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
DaemonApp* DaemonApp::s_instance = NULL;
|
||||
|
|
@ -324,15 +337,11 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
|
|||
ArgParser::splitCommandString(command, argsArray);
|
||||
ArgParser argParser(NULL);
|
||||
const char** argv = argParser.getArgv(argsArray);
|
||||
|
||||
int argc = static_cast<int>(argsArray.size());
|
||||
bool server = argsArray[0].find("synergys") != String::npos;
|
||||
|
||||
|
||||
if (server) {
|
||||
if (isServerCommandLine(argsArray)) {
|
||||
auto serverArgs = new lib::synergy::ServerArgs();
|
||||
argParser.parseServerArgs(*serverArgs, argc, argv);
|
||||
|
||||
}
|
||||
else {
|
||||
auto clientArgs = new lib::synergy::ClientArgs();
|
||||
|
|
|
|||
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2003 Chris Schoeneman
|
||||
*
|
||||
* 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 LICENSE 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 "synergy/PortableTaskBarReceiver.h"
|
||||
#include "mt/Lock.h"
|
||||
#include "base/String.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "arch/Arch.h"
|
||||
#include "common/Version.h"
|
||||
|
||||
//
|
||||
// PortableTaskBarReceiver
|
||||
//
|
||||
|
||||
PortableTaskBarReceiver::PortableTaskBarReceiver(IEventQueue* events) :
|
||||
m_state(kNotRunning),
|
||||
m_events(events)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
PortableTaskBarReceiver::~PortableTaskBarReceiver()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
PortableTaskBarReceiver::updateStatus(INode* node, const String& errorMsg)
|
||||
{
|
||||
{
|
||||
// update our status
|
||||
m_errorMessage = errorMsg;
|
||||
if (node == NULL) {
|
||||
if (m_errorMessage.empty()) {
|
||||
m_state = kNotRunning;
|
||||
}
|
||||
else {
|
||||
m_state = kNotWorking;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_state = kNotConnected;
|
||||
}
|
||||
|
||||
// let subclasses have a go
|
||||
onStatusChanged(node);
|
||||
}
|
||||
|
||||
// tell task bar
|
||||
ARCH->updateReceiver(this);
|
||||
}
|
||||
|
||||
PortableTaskBarReceiver::EState
|
||||
PortableTaskBarReceiver::getStatus() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
const String&
|
||||
PortableTaskBarReceiver::getErrorMessage() const
|
||||
{
|
||||
return m_errorMessage;
|
||||
}
|
||||
|
||||
void
|
||||
PortableTaskBarReceiver::quit()
|
||||
{
|
||||
m_events->addEvent(Event(Event::kQuit));
|
||||
}
|
||||
|
||||
void
|
||||
PortableTaskBarReceiver::onStatusChanged(INode*)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
PortableTaskBarReceiver::lock() const
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
PortableTaskBarReceiver::unlock() const
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
std::string
|
||||
PortableTaskBarReceiver::getToolTip() const
|
||||
{
|
||||
switch (m_state) {
|
||||
case kNotRunning:
|
||||
return synergy::string::sprintf("%s: Not running", kAppVersion);
|
||||
|
||||
case kNotWorking:
|
||||
return synergy::string::sprintf("%s: %s",
|
||||
kAppVersion, m_errorMessage.c_str());
|
||||
|
||||
case kNotConnected:
|
||||
return synergy::string::sprintf("%s: Unknown", kAppVersion);
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2003 Chris Schoeneman
|
||||
*
|
||||
* 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 LICENSE 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 "synergy/INode.h"
|
||||
#include "arch/IArchTaskBarReceiver.h"
|
||||
#include "base/log_outputters.h"
|
||||
#include "base/EventTypes.h"
|
||||
#include "base/Event.h"
|
||||
#include "base/String.h"
|
||||
#include "common/stdvector.h"
|
||||
|
||||
class IEventQueue;
|
||||
|
||||
//! Implementation of IArchTaskBarReceiver for the synergy server
|
||||
class PortableTaskBarReceiver : public IArchTaskBarReceiver {
|
||||
public:
|
||||
PortableTaskBarReceiver(IEventQueue* events);
|
||||
virtual ~PortableTaskBarReceiver();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//! Update status
|
||||
/*!
|
||||
Determine the status and query required information from the server.
|
||||
*/
|
||||
void updateStatus(INode*, const String& errorMsg);
|
||||
|
||||
//@}
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus() = 0;
|
||||
virtual void runMenu(int x, int y) = 0;
|
||||
virtual void primaryAction() = 0;
|
||||
virtual void lock() const;
|
||||
virtual void unlock() const;
|
||||
virtual const Icon getIcon() const = 0;
|
||||
virtual std::string getToolTip() const;
|
||||
|
||||
protected:
|
||||
typedef std::vector<String> Clients;
|
||||
enum EState {
|
||||
kNotRunning,
|
||||
kNotWorking,
|
||||
kNotConnected,
|
||||
kConnected,
|
||||
kMaxState
|
||||
};
|
||||
|
||||
//! Get status
|
||||
EState getStatus() const;
|
||||
|
||||
//! Get error message
|
||||
const String& getErrorMessage() const;
|
||||
|
||||
//! Quit app
|
||||
/*!
|
||||
Causes the application to quit gracefully
|
||||
*/
|
||||
void quit();
|
||||
|
||||
//! Status change notification
|
||||
/*!
|
||||
Called when status changes. The default implementation does
|
||||
nothing.
|
||||
*/
|
||||
virtual void onStatusChanged(INode* node);
|
||||
|
||||
private:
|
||||
EState m_state;
|
||||
String m_errorMessage;
|
||||
|
||||
String m_server;
|
||||
Clients m_clients;
|
||||
|
||||
IEventQueue* m_events;
|
||||
};
|
||||
|
||||
IArchTaskBarReceiver* createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events);
|
||||
Loading…
Reference in a new issue