From a5cd0fab9e8364313489175462304dafffd9db9a Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Fri, 18 Oct 2024 16:13:13 +0100 Subject: [PATCH] feat: Option to change server protocol in GUI --- src/gui/src/ServerConfig.cpp | 44 +- src/gui/src/ServerConfig.h | 25 + src/gui/src/ServerConfigDialog.cpp | 17 + src/gui/src/ServerConfigDialog.ui | 889 +++++++++++++------------- src/lib/client/HelloBack.cpp | 2 +- src/lib/deskflow/XDeskflow.cpp | 9 + src/lib/deskflow/XDeskflow.h | 6 + src/lib/deskflow/option_types.h | 10 + src/lib/server/ClientProxyUnknown.cpp | 5 +- src/lib/server/ClientProxyUnknown.h | 1 + src/lib/server/Config.cpp | 28 + src/lib/server/Config.h | 1 + src/lib/server/Server.cpp | 24 +- src/lib/server/Server.h | 10 + 14 files changed, 623 insertions(+), 448 deletions(-) diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 9ca099f48..33eb72885 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -72,15 +72,26 @@ bool ServerConfig::save(const QString &fileName) const bool ServerConfig::operator==(const ServerConfig &sc) const { - return m_Screens == sc.m_Screens && m_Columns == sc.m_Columns && m_Rows == sc.m_Rows && - m_HasHeartbeat == sc.m_HasHeartbeat && m_Heartbeat == sc.m_Heartbeat && - m_RelativeMouseMoves == sc.m_RelativeMouseMoves && m_Win32KeepForeground == sc.m_Win32KeepForeground && - m_HasSwitchDelay == sc.m_HasSwitchDelay && m_SwitchDelay == sc.m_SwitchDelay && - m_HasSwitchDoubleTap == sc.m_HasSwitchDoubleTap && m_SwitchDoubleTap == sc.m_SwitchDoubleTap && - m_SwitchCornerSize == sc.m_SwitchCornerSize && m_SwitchCorners == sc.m_SwitchCorners && - m_Hotkeys == sc.m_Hotkeys && m_pAppConfig == sc.m_pAppConfig && - m_EnableDragAndDrop == sc.m_EnableDragAndDrop && m_DisableLockToScreen == sc.m_DisableLockToScreen && - m_ClipboardSharing == sc.m_ClipboardSharing && m_ClipboardSharingSize == sc.m_ClipboardSharingSize && + return m_Screens == sc.m_Screens && // + m_Columns == sc.m_Columns && // + m_Rows == sc.m_Rows && // + m_HasHeartbeat == sc.m_HasHeartbeat && // + m_Heartbeat == sc.m_Heartbeat && // + m_Protocol == sc.m_Protocol && // + m_RelativeMouseMoves == sc.m_RelativeMouseMoves && // + m_Win32KeepForeground == sc.m_Win32KeepForeground && // + m_HasSwitchDelay == sc.m_HasSwitchDelay && // + m_SwitchDelay == sc.m_SwitchDelay && // + m_HasSwitchDoubleTap == sc.m_HasSwitchDoubleTap && // + m_SwitchDoubleTap == sc.m_SwitchDoubleTap && // + m_SwitchCornerSize == sc.m_SwitchCornerSize && // + m_SwitchCorners == sc.m_SwitchCorners && // + m_Hotkeys == sc.m_Hotkeys && // + m_pAppConfig == sc.m_pAppConfig && // + m_EnableDragAndDrop == sc.m_EnableDragAndDrop && // + m_DisableLockToScreen == sc.m_DisableLockToScreen && // + m_ClipboardSharing == sc.m_ClipboardSharing && // + m_ClipboardSharingSize == sc.m_ClipboardSharingSize && // m_pMainWindow == sc.m_pMainWindow; } @@ -118,6 +129,7 @@ void ServerConfig::commit() settings().setValue("hasHeartbeat", hasHeartbeat()); settings().setValue("heartbeat", heartbeat()); + settings().setValue("protocol", static_cast(protocol())); settings().setValue("relativeMouseMoves", relativeMouseMoves()); settings().setValue("win32KeepForeground", win32KeepForeground()); settings().setValue("hasSwitchDelay", hasSwitchDelay()); @@ -172,6 +184,7 @@ void ServerConfig::recall() haveHeartbeat(settings().value("hasHeartbeat", false).toBool()); setHeartbeat(settings().value("heartbeat", 5000).toInt()); + setProtocol(static_cast(settings().value("protocol", static_cast(protocol())).toInt())); setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool()); setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool()); haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool()); @@ -232,6 +245,8 @@ int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) co QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) { + using enum synergy::gui::ServerProtocol; + outStream << "section: screens" << Qt::endl; foreach (const Screen &s, config.screens()) @@ -266,8 +281,15 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) outStream << "section: options" << Qt::endl; if (config.hasHeartbeat()) - outStream << "\t" - << "heartbeat = " << config.heartbeat() << Qt::endl; + outStream << "\t" << "heartbeat = " << config.heartbeat() << Qt::endl; + + if (config.protocol() == kSynergy) { + outStream << "\t" << "protocol = synergy" << Qt::endl; + } else if (config.protocol() == kBarrier) { + outStream << "\t" << "protocol = barrier" << Qt::endl; + } else { + qFatal("unrecognized protocol when writing config"); + } outStream << "\t" << "relativeMouseMoves = " << (config.relativeMouseMoves() ? "true" : "false") << Qt::endl; diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index ff16c1473..0dd446d2f 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -36,9 +36,25 @@ class ServerConfigDialog; class MainWindow; class AppConfig; +namespace synergy::gui { + +enum class ServerProtocol +{ + kSynergy, + kBarrier +}; + +// The default protocol was decided by a community vote. +// TODO: Remove this link when the vote concludes: +// https://github.com/deskflow/deskflow/discussions/7742 +const auto kDefaultProtocol = ServerProtocol::kSynergy; + +} // namespace synergy::gui + class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig { using QSettingsProxy = deskflow::gui::proxy::QSettingsProxy; + using ServerProtocol = synergy::gui::ServerProtocol; friend class ServerConfigDialog; friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config); @@ -80,6 +96,10 @@ public: { return m_Heartbeat; } + ServerProtocol protocol() const + { + return m_Protocol; + } bool relativeMouseMoves() const { return m_RelativeMouseMoves; @@ -188,6 +208,10 @@ private: { m_Heartbeat = val; } + void setProtocol(ServerProtocol val) + { + m_Protocol = val; + } void setRelativeMouseMoves(bool on) { m_RelativeMouseMoves = on; @@ -252,6 +276,7 @@ private: private: bool m_HasHeartbeat = false; int m_Heartbeat = 0; + ServerProtocol m_Protocol = synergy::gui::kDefaultProtocol; bool m_RelativeMouseMoves = false; bool m_Win32KeepForeground = false; bool m_HasSwitchDelay = false; diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp index a31c6bfd9..ceb53131f 100644 --- a/src/gui/src/ServerConfigDialog.cpp +++ b/src/gui/src/ServerConfigDialog.cpp @@ -30,6 +30,7 @@ #include using enum ScreenConfig::SwitchCorner; +using ServerProtocol = synergy::gui::ServerProtocol; ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, AppConfig &appConfig) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), @@ -51,6 +52,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap ui->m_pEditConfigFile->setText(serverConfig().configFile()); ui->m_pCheckBoxUseExternalConfig->setChecked(serverConfig().useExternalConfig()); ui->m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat()); + ui->m_pRadioProtocolSynergy->setChecked(serverConfig().protocol() == ServerProtocol::kSynergy); + ui->m_pRadioProtocolBarrier->setChecked(serverConfig().protocol() == ServerProtocol::kBarrier); ui->m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat()); ui->m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves()); @@ -99,6 +102,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap // computers connect(&m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this, &ServerConfigDialog::onChange); + +// Above Qt 6.7 the checkbox signal signature has changed from int to Qt::CheckState #if QT_VERSION <= QT_VERSION_CHECK(6, 7, 0) // advanced connect(ui->m_pCheckBoxSwitchDelay, &QCheckBox::stateChanged, this, [this](const int &v) { @@ -237,6 +242,18 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap onChange(); } ); + connect(ui->m_pRadioProtocolSynergy, &QRadioButton::toggled, this, [this](const bool &v) { + if (v) { + serverConfig().setProtocol(ServerProtocol::kSynergy); + onChange(); + } + }); + connect(ui->m_pRadioProtocolBarrier, &QRadioButton::toggled, this, [this](const bool &v) { + if (v) { + serverConfig().setProtocol(ServerProtocol::kBarrier); + onChange(); + } + }); connect(ui->m_pEditConfigFile, &QLineEdit::textChanged, this, [this]() { serverConfig().setConfigFile(ui->m_pEditConfigFile->text()); diff --git a/src/gui/src/ServerConfigDialog.ui b/src/gui/src/ServerConfigDialog.ui index 4d43879b9..9cef3a569 100644 --- a/src/gui/src/ServerConfigDialog.ui +++ b/src/gui/src/ServerConfigDialog.ui @@ -29,7 +29,7 @@ - 3 + 0 @@ -49,7 +49,7 @@ 5 - + 6 @@ -130,7 +130,7 @@ - + 0 @@ -334,327 +334,81 @@ Advanced - - - 9 - - - 9 - - - - - 0 - - - 0 - - - 0 - - - - - - true - - - - &Switch computer - - - - 6 - - - 6 - - - 6 - - - - - - - true - - - Switch &after waiting - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - 10 - - - 10000 - - - 10 - - - 250 - - - - - - - ms - - - - - - - - - - - true - - - Switch on double &tap within - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - 10 - - - 10000 - - - 10 - - - 250 - - - - - - - ms - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 13 - - - - - - - - - true - - - - Clipboard sharing - - - - 6 - - - - - 6 - - - - - - 0 - 0 - - - - Enable clipboard sharing - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - 10000 - - - 3 - - - - - - - mb - - - - - - - - - Qt::Vertical - - - - 20 - 60 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + true - &Dead corners for this computer + &Dead corners (for this computer) false - + 6 - - - - To&p-left - - + + + + + + &Bottom-left + + + + + + + To&p-left + + + + + + + Bottom-ri&ght + + + + + + + Top-rig&ht + + + + - - - - Top-rig&ht - - - - - - - &Bottom-left - - - - - - - Bottom-ri&ght - - - - - + + - Cor&ner Size: + Cor&ner size m_pSpinBoxSwitchCornerSize + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -664,6 +418,12 @@ + + + 0 + 0 + + px @@ -671,160 +431,429 @@ + + + + Qt::Vertical + + + + 20 + 0 + + + + - - - - 0 + + + + + false + - - 0 + + &Misc - - - - - false - - - - &Options - - - - 12 + + + + + Disable lock to screen (scroll lock key) - - + + + + + + true + + + Use &relative mouse movements + + + + + + + true + + + Don't take &foreground window (Windows only) + + + + + + + 6 + + + + + + 0 + 0 + + + + Enable clipboard sharing + + + true + + + + + - Qt::Vertical + Qt::Horizontal - 20 - 16 + 40 + 20 - - + + + + Limit: + + + + + - true + false - - Use &relative mouse moves + + 10000 + + + 3 - - - - 9 - - - 0 - - - - - true - - - &Check clients every - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - 0 - 0 - - - - 1000 - - - 30000 - - - 1000 - - - 5000 - - - - - - - ms - - - - - - - + + - Ignore auto config clients - - - - - - - Disable lock to screen - - - - - - - true - - - Don't take &foreground window on Windows servers + MB - - - + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + - - + + + + &Network + + + + + + 9 + + + 0 + + + + + true + + + <html><head/><body><p>Enables the network heartbeat to ping clients every <span style=" font-style:italic;">n</span> seconds. This may help to diagnose network problems by retrying the connection if the client becomes unresponsive.</p></body></html> + + + &Check clients every + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + 1000 + + + 30000 + + + 1000 + + + 5000 + + + + + + + ms + + + + + + + + + + + <p>Enables compatibility with programs that use either the Synergy or Barrier protocols:</p> +<ul> +<li>Deskflow uses the Synergy protocol.</li> +<li>Input Leap uses the Barrier protocol.</li> +</ul> +<p>A Deskflow client will automatically use either the Synergy or Barrier protocol depending on the server protocol.</p> + + + Network protocol + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Synergy + + + true + + + + + + + &Barrier + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + true + + + + &Switching + + + + 6 + + + 6 + + + 6 + + + + + + + true + + + Switch &after waiting + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + 10 + + + 10000 + + + 10 + + + 250 + + + + + + + ms + + + + + + + + + + + true + + + Switch on double &tap within + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + 10 + + + 10000 + + + 10 + + + 250 + + + + + + + ms + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + Qt::Vertical - - QSizePolicy::Fixed - 20 - 13 + 40 @@ -905,7 +934,7 @@ Enabling this setting will disable the server config GUI. - + 0 @@ -966,7 +995,7 @@ Enabling this setting will disable the server config GUI. - + 40 @@ -1165,18 +1194,12 @@ Enabling this setting will disable the server config GUI. m_pCheckBoxHeartbeat m_pSpinBoxHeartbeat m_pCheckBoxRelativeMouseMoves - m_pCheckBoxWin32KeepForeground - m_pCheckBoxIgnoreAutoConfigClient - m_pCheckBoxDisableLockToScreen - m_pCheckBoxCornerTopLeft - m_pCheckBoxCornerBottomLeft - m_pCheckBoxCornerTopRight - m_pCheckBoxCornerBottomRight m_pSpinBoxSwitchCornerSize m_pCheckBoxUseExternalConfig m_pEditConfigFile m_pTabWidget + m_pButtonBox diff --git a/src/lib/client/HelloBack.cpp b/src/lib/client/HelloBack.cpp index 65d5b0909..e93c49b33 100644 --- a/src/lib/client/HelloBack.cpp +++ b/src/lib/client/HelloBack.cpp @@ -52,7 +52,7 @@ void HelloBack::handleHello(deskflow::IStream *stream, const std::string &client } // check versions - LOG_DEBUG("got hello version %s, %d.%d", protocolName.c_str(), serverMajor, serverMinor); + LOG_DEBUG("got hello from %s, protocol v%d.%d", protocolName.c_str(), serverMajor, serverMinor); const auto helloBackMajor = m_majorVersion; auto helloBackMinor = m_minorVersion; diff --git a/src/lib/deskflow/XDeskflow.cpp b/src/lib/deskflow/XDeskflow.cpp index 11b3fb338..f8aa52ba5 100644 --- a/src/lib/deskflow/XDeskflow.cpp +++ b/src/lib/deskflow/XDeskflow.cpp @@ -28,6 +28,15 @@ String XBadClient::getWhat() const throw() return "XBadClient"; } +// +// XInvalidProtocol +// + +String XInvalidProtocol::getWhat() const throw() +{ + return "XInvalidProtocol"; +} + // // XIncompatibleClient // diff --git a/src/lib/deskflow/XDeskflow.h b/src/lib/deskflow/XDeskflow.h index b691f99e0..1b899da92 100644 --- a/src/lib/deskflow/XDeskflow.h +++ b/src/lib/deskflow/XDeskflow.h @@ -35,6 +35,12 @@ Thrown when the client fails to follow the protocol. */ XBASE_SUBCLASS_WHAT(XBadClient, XDeskflow); +//! Server protocol error +/*! +Thrown when the server protocol is unrecognized. +*/ +XBASE_SUBCLASS_WHAT(XInvalidProtocol, XDeskflow); + //! Incompatible client exception /*! Thrown when a client attempting to connect has an incompatible version. diff --git a/src/lib/deskflow/option_types.h b/src/lib/deskflow/option_types.h index 99db87a47..69befca68 100644 --- a/src/lib/deskflow/option_types.h +++ b/src/lib/deskflow/option_types.h @@ -55,6 +55,7 @@ static const OptionID kOptionModifierMapForAltGr = OPTION_CODE("MMFG"); static const OptionID kOptionModifierMapForMeta = OPTION_CODE("MMFM"); static const OptionID kOptionModifierMapForSuper = OPTION_CODE("MMFR"); static const OptionID kOptionHeartbeat = OPTION_CODE("HART"); +static const OptionID kOptionProtocol = OPTION_CODE("PROT"); static const OptionID kOptionScreenSwitchCorners = OPTION_CODE("SSCM"); static const OptionID kOptionScreenSwitchCornerSize = OPTION_CODE("SSCS"); static const OptionID kOptionScreenSwitchDelay = OPTION_CODE("SSWT"); @@ -98,4 +99,13 @@ enum EScreenSwitchCornerMasks }; //@} +//! @name Network protocol +//@{ +enum class ENetworkProtocol +{ + kSynergy, + kBarrier +}; +//@} + #undef OPTION_CODE diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index 0ed18fe33..eaebd7069 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -60,9 +60,10 @@ ClientProxyUnknown::ClientProxyUnknown(deskflow::IStream *stream, double timeout m_timer = m_events->newOneShotTimer(timeout, this); addStreamHandlers(); - std::string helloMessage = std::string(kSynergyProtocolName).append(kMsgHelloArgs); + const auto protocol = m_server->protocolString(); + const auto helloMessage = protocol + kMsgHelloArgs; - LOG((CLOG_DEBUG1 "saying hello")); + LOG_DEBUG("saying hello as %s, protocol v%d.%d", protocol.c_str(), kProtocolMajorVersion, kProtocolMinorVersion); ProtocolUtil::writef(m_stream, helloMessage.c_str(), kProtocolMajorVersion, kProtocolMinorVersion); } diff --git a/src/lib/server/ClientProxyUnknown.h b/src/lib/server/ClientProxyUnknown.h index 07e4649c1..d53c84246 100644 --- a/src/lib/server/ClientProxyUnknown.h +++ b/src/lib/server/ClientProxyUnknown.h @@ -21,6 +21,7 @@ #include "base/Event.h" #include "base/EventTypes.h" #include "base/String.h" +#include "deskflow/option_types.h" class ClientProxy; class EventQueueTimer; diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index aeeef31b4..a299c15c2 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -22,7 +22,9 @@ #include "common/stdistream.h" #include "common/stdostream.h" #include "deskflow/KeyMap.h" +#include "deskflow/XDeskflow.h" #include "deskflow/key_types.h" +#include "deskflow/option_types.h" #include "net/XSocket.h" #include "server/Server.h" @@ -32,6 +34,9 @@ using namespace deskflow::string; namespace deskflow::server { +const auto kSynergyProtocolOption = "synergy"; +const auto kBarrierProtocolOption = "barrier"; + // // Config // @@ -675,6 +680,8 @@ void Config::readSectionOptions(ConfigReadContext &s) } } else if (name == "heartbeat") { addOption("", kOptionHeartbeat, s.parseInt(value)); + } else if (name == "protocol") { + addOption("", kOptionProtocol, s.parseProtocol(value)); } else if (name == "switchCorners") { addOption("", kOptionScreenSwitchCorners, s.parseCorners(value)); } else if (name == "switchCornerSize") { @@ -1325,6 +1332,17 @@ String Config::getOptionValue(OptionID id, OptionValue value) } return result; } + if (id == kOptionProtocol) { + using enum ENetworkProtocol; + const auto enumValue = static_cast(value); + if (enumValue == kSynergy) { + return kSynergyProtocolOption; + } else if (enumValue == kBarrier) { + return kBarrierProtocolOption; + } else { + throw XInvalidProtocol(); + } + } return ""; } @@ -1822,6 +1840,16 @@ OptionValue ConfigReadContext::parseCorner(const String &arg) const throw XConfigRead(*this, "invalid argument \"%{1}\"", arg); } +OptionValue ConfigReadContext::parseProtocol(const String &args) const +{ + if (CaselessCmp::equal(args, kSynergyProtocolOption)) { + return static_cast(ENetworkProtocol::kSynergy); + } else if (CaselessCmp::equal(args, kBarrierProtocolOption)) { + return static_cast(ENetworkProtocol::kBarrier); + } + throw XConfigRead(*this, "invalid protocol argument \"%{1}\"", args); +} + OptionValue ConfigReadContext::parseCorners(const String &args) const { // find first token diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index 25c04fb62..99402b232 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -537,6 +537,7 @@ public: OptionValue parseModifierKey(const String &) const; OptionValue parseCorner(const String &) const; OptionValue parseCorners(const String &) const; + OptionValue parseProtocol(const String &) const; Config::Interval parseInterval(const ArgList &args) const; void parseNameWithArgs( const String &type, const String &line, const String &delim, String::size_type &index, String &name, ArgList &args diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 8e79c03fd..e5f513e15 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -31,6 +31,7 @@ #include "deskflow/PacketStreamFilter.h" #include "deskflow/Screen.h" #include "deskflow/StreamChunker.h" +#include "deskflow/XDeskflow.h" #include "deskflow/option_types.h" #include "deskflow/protocol_types.h" #include "mt/Thread.h" @@ -341,6 +342,17 @@ void Server::disconnect() } } +std::string Server::protocolString() const +{ + using enum ENetworkProtocol; + if (m_protocol == kSynergy) { + return kSynergyProtocolName; + } else if (m_protocol == kBarrier) { + return kBarrierProtocolName; + } + throw XInvalidProtocol(); +} + UInt32 Server::getNumClients() const { return (SInt32)m_clients.size(); @@ -1100,7 +1112,17 @@ void Server::processOptions() for (Config::ScreenOptions::const_iterator index = options->begin(); index != options->end(); ++index) { const OptionID id = index->first; const OptionValue value = index->second; - if (id == kOptionScreenSwitchDelay) { + if (id == kOptionProtocol) { + using enum ENetworkProtocol; + const auto enumValue = static_cast(value); + if (enumValue == kSynergy) { + m_protocol = kSynergy; + } else if (enumValue == kBarrier) { + m_protocol = kBarrier; + } else { + throw XInvalidProtocol(); + } + } else if (id == kOptionScreenSwitchDelay) { m_switchWaitDelay = 1.0e-3 * static_cast(value); if (m_switchWaitDelay < 0.0) { m_switchWaitDelay = 0.0; diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 352539cbc..38aa01b6c 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -31,6 +31,7 @@ #include "deskflow/clipboard_types.h" #include "deskflow/key_types.h" #include "deskflow/mouse_types.h" +#include "deskflow/option_types.h" #include "server/Config.h" #include @@ -192,6 +193,12 @@ public: //! @name accessors //@{ + //! Get the network protocol + /*! + Returns the network protocol used by the server. + */ + std::string protocolString() const; + //! Get number of connected clients /*! Returns the number of connected clients, including the server itself. @@ -422,6 +429,9 @@ private: UInt32 m_clipboardSeqNum; }; + // used in hello message sent to the client + ENetworkProtocol m_protocol; + // the primary screen client PrimaryClient *m_primaryClient;