refactor: move protocol from serverConfig => Settings::Server::Protocol
This commit is contained in:
parent
dff81e62fe
commit
77a97f815a
10 changed files with 28 additions and 32 deletions
|
|
@ -144,6 +144,7 @@ This section contains options used when in server mode it will begin with `[serv
|
||||||
|:-------------------|:-----------------:|:-----------|
|
|:-------------------|:-----------------:|:-----------|
|
||||||
| externalConfig | `true` or `false` | When true use the external config path |
|
| externalConfig | `true` or `false` | When true use the external config path |
|
||||||
| externalConfigFile | Filepath | Path the server config file if it does not exist the GUI will it generated based on the `internalConfig` section.|
|
| externalConfigFile | Filepath | Path the server config file if it does not exist the GUI will it generated based on the `internalConfig` section.|
|
||||||
|
| protocol | `barrier` or `synergy` | The protocol to use when saying hello to clients. Can be set to barrier or synergy. If not set barrier is used as the default |
|
||||||
|
|
||||||
### InternalConfig
|
### InternalConfig
|
||||||
|
|
||||||
|
|
@ -176,7 +177,6 @@ hotkeys\1\keys\size=1
|
||||||
hotkeys\size=1
|
hotkeys\size=1
|
||||||
numColumns=5
|
numColumns=5
|
||||||
numRows=3
|
numRows=3
|
||||||
protocol=1
|
|
||||||
relativeMouseMoves=false
|
relativeMouseMoves=false
|
||||||
screens\1\name=
|
screens\1\name=
|
||||||
screens\10\aliasArray\size=0
|
screens\10\aliasArray\size=0
|
||||||
|
|
@ -389,7 +389,6 @@ Note that links do not have to be symmetrical; for instance, here the edge betwe
|
||||||
|
|
||||||
```
|
```
|
||||||
section: options
|
section: options
|
||||||
protocol = barrier
|
|
||||||
heartbeat = 5000
|
heartbeat = 5000
|
||||||
switchDelay = 500
|
switchDelay = 500
|
||||||
end
|
end
|
||||||
|
|
@ -399,7 +398,6 @@ end
|
||||||
|
|
||||||
| Options | Value Values| Description|
|
| Options | Value Values| Description|
|
||||||
|:--------|:-----------:|:-----------|
|
|:--------|:-----------:|:-----------|
|
||||||
|protocol | barrier or synergy| The protocol to use when saying hello to clients. Can be set to barrier or synergy. If not set barrier is used as the default |
|
|
||||||
|heartbeat| integer (N) | The server will expect each client to send a message no less than every `N` milliseconds. If no message arrives from a client within `3N` seconds the server forces that client to disconnect. If deskflow fails to detect clients disconnecting while the server is sleeping or vice versa, try using this option. |
|
|heartbeat| integer (N) | The server will expect each client to send a message no less than every `N` milliseconds. If no message arrives from a client within `3N` seconds the server forces that client to disconnect. If deskflow fails to detect clients disconnecting while the server is sleeping or vice versa, try using this option. |
|
||||||
|switchCorners | none top-left top-right bottom-left bottom-right left right top bottom all | Deskflow won't switch computers when the mouse reaches the edge of the computer if it's in a listed corner. The size of all corners is given by the `switchCornerSize` option. The first name in the list is one of the above names and defines the initial set of corners. Subsequent names are prefixed with + or - to add the corner to or remove the corner from the set, respectively. For example: `all -left +top-left` starts will all corners, removes the left corners (top and bottom) then adds the top-left back in, resulting in the top-left, bottom-left and bottom-right corners.|
|
|switchCorners | none top-left top-right bottom-left bottom-right left right top bottom all | Deskflow won't switch computers when the mouse reaches the edge of the computer if it's in a listed corner. The size of all corners is given by the `switchCornerSize` option. The first name in the list is one of the above names and defines the initial set of corners. Subsequent names are prefixed with + or - to add the corner to or remove the corner from the set, respectively. For example: `all -left +top-left` starts will all corners, removes the left corners (top and bottom) then adds the top-left back in, resulting in the top-left, bottom-left and bottom-right corners.|
|
||||||
|switchCornerSize | integer (N) | Sets the size of all corners in pixels. The cursor must be within `N` pixels of the corner to be considered to be in the corner.|
|
|switchCornerSize | integer (N) | Sets the size of all corners in pixels. The cursor must be within `N` pixels of the corner to be considered to be in the corner.|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
inline static const auto kSynergyProtocolOption = "synergy";
|
inline static const auto kSynergyProtocolOption = "synergy";
|
||||||
|
|
@ -16,6 +17,7 @@ enum class NetworkProtocol
|
||||||
Synergy,
|
Synergy,
|
||||||
Barrier
|
Barrier
|
||||||
};
|
};
|
||||||
|
Q_DECLARE_METATYPE(NetworkProtocol);
|
||||||
|
|
||||||
static int networkProtocolToInt(const NetworkProtocol proto)
|
static int networkProtocolToInt(const NetworkProtocol proto)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#include "NetworkProtocol.h"
|
||||||
#include "UrlConstants.h"
|
#include "UrlConstants.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
@ -105,6 +106,8 @@ void Settings::cleanSettings()
|
||||||
{
|
{
|
||||||
const QStringList keys = m_settings->allKeys();
|
const QStringList keys = m_settings->allKeys();
|
||||||
for (const QString &key : keys) {
|
for (const QString &key : keys) {
|
||||||
|
if (key.startsWith(QStringLiteral("internalConfig/protocol")))
|
||||||
|
m_settings->remove(key);
|
||||||
if (key.startsWith(QStringLiteral("internalConfig")))
|
if (key.startsWith(QStringLiteral("internalConfig")))
|
||||||
continue;
|
continue;
|
||||||
if (!m_validKeys.contains(key))
|
if (!m_validKeys.contains(key))
|
||||||
|
|
@ -206,6 +209,9 @@ QVariant Settings::defaultValue(const QString &key)
|
||||||
if (key == Client::YScrollScale || key == Client::XScrollScale)
|
if (key == Client::YScrollScale || key == Client::XScrollScale)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
|
if (key == Server::Protocol)
|
||||||
|
return QVariant::fromValue(NetworkProtocol::Barrier);
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ public:
|
||||||
{
|
{
|
||||||
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
|
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
|
||||||
inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile");
|
inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile");
|
||||||
|
inline static const auto Protocol = QStringLiteral("server/protocol");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enums types used in settings
|
// Enums types used in settings
|
||||||
|
|
@ -251,6 +252,7 @@ private:
|
||||||
, Settings::Security::TlsEnabled
|
, Settings::Security::TlsEnabled
|
||||||
, Settings::Server::ExternalConfig
|
, Settings::Server::ExternalConfig
|
||||||
, Settings::Server::ExternalConfigFile
|
, Settings::Server::ExternalConfigFile
|
||||||
|
, Settings::Server::Protocol
|
||||||
};
|
};
|
||||||
|
|
||||||
// When checking the default values this list contains the ones that default to false.
|
// When checking the default values this list contains the ones that default to false.
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ static const OptionID kOptionModifierMapForAltGr = OPTION_CODE("MMFG");
|
||||||
static const OptionID kOptionModifierMapForMeta = OPTION_CODE("MMFM");
|
static const OptionID kOptionModifierMapForMeta = OPTION_CODE("MMFM");
|
||||||
static const OptionID kOptionModifierMapForSuper = OPTION_CODE("MMFR");
|
static const OptionID kOptionModifierMapForSuper = OPTION_CODE("MMFR");
|
||||||
static const OptionID kOptionHeartbeat = OPTION_CODE("HART");
|
static const OptionID kOptionHeartbeat = OPTION_CODE("HART");
|
||||||
static const OptionID kOptionProtocol = OPTION_CODE("PROT");
|
|
||||||
static const OptionID kOptionScreenSwitchCorners = OPTION_CODE("SSCM");
|
static const OptionID kOptionScreenSwitchCorners = OPTION_CODE("SSCM");
|
||||||
static const OptionID kOptionScreenSwitchCornerSize = OPTION_CODE("SSCS");
|
static const OptionID kOptionScreenSwitchCornerSize = OPTION_CODE("SSCS");
|
||||||
static const OptionID kOptionScreenSwitchDelay = OPTION_CODE("SSWT");
|
static const OptionID kOptionScreenSwitchDelay = OPTION_CODE("SSWT");
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,6 @@ void ServerConfig::commit()
|
||||||
|
|
||||||
settings().setValue("hasHeartbeat", hasHeartbeat());
|
settings().setValue("hasHeartbeat", hasHeartbeat());
|
||||||
settings().setValue("heartbeat", heartbeat());
|
settings().setValue("heartbeat", heartbeat());
|
||||||
settings().setValue("protocol", static_cast<int>(protocol()));
|
|
||||||
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
||||||
settings().setValue("win32KeepForeground", win32KeepForeground());
|
settings().setValue("win32KeepForeground", win32KeepForeground());
|
||||||
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
||||||
|
|
@ -159,7 +158,7 @@ void ServerConfig::recall()
|
||||||
|
|
||||||
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
||||||
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
||||||
setProtocol(networkProtocolFromInt(settings().value("protocol", networkProtocolToInt(protocol())).toInt()));
|
setProtocol(Settings::value(Settings::Server::Protocol).value<NetworkProtocol>());
|
||||||
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
||||||
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
||||||
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ServerConfigDialog.h"
|
#include "ServerConfigDialog.h"
|
||||||
#include "common/PlatformInfo.h"
|
|
||||||
#include "ui_ServerConfigDialog.h"
|
#include "ui_ServerConfigDialog.h"
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/NetworkProtocol.h"
|
#include "common/NetworkProtocol.h"
|
||||||
|
#include "common/PlatformInfo.h"
|
||||||
|
#include "common/Settings.h"
|
||||||
#include "dialogs/ActionDialog.h"
|
#include "dialogs/ActionDialog.h"
|
||||||
#include "dialogs/HotkeyDialog.h"
|
#include "dialogs/HotkeyDialog.h"
|
||||||
#include "dialogs/ScreenSettingsDialog.h"
|
#include "dialogs/ScreenSettingsDialog.h"
|
||||||
|
|
@ -32,6 +33,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_originalProtocol = Settings::value(Settings::Server::Protocol).value<NetworkProtocol>();
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ServerConfigDialog::accept);
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ServerConfigDialog::accept);
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ServerConfigDialog::reject);
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ServerConfigDialog::reject);
|
||||||
|
|
||||||
|
|
@ -365,6 +367,7 @@ void ServerConfigDialog::toggleProtocol()
|
||||||
{
|
{
|
||||||
auto proto = ui->rbProtocolBarrier->isChecked() ? NetworkProtocol::Barrier : NetworkProtocol::Synergy;
|
auto proto = ui->rbProtocolBarrier->isChecked() ? NetworkProtocol::Barrier : NetworkProtocol::Synergy;
|
||||||
serverConfig().setProtocol(proto);
|
serverConfig().setProtocol(proto);
|
||||||
|
Settings::setValue(Settings::Server::Protocol, networkProtocolToOption(proto));
|
||||||
onChange();
|
onChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -506,8 +509,10 @@ bool ServerConfigDialog::addComputer(const QString &clientName, bool doSilent)
|
||||||
|
|
||||||
void ServerConfigDialog::onChange()
|
void ServerConfigDialog::onChange()
|
||||||
{
|
{
|
||||||
bool isAppConfigDataEqual = m_originalServerConfigIsExternal == serverConfig().useExternalConfig() &&
|
bool isAppConfigDataEqual =
|
||||||
m_originalServerConfigUsesExternalFile == serverConfig().configFile();
|
m_originalServerConfigIsExternal == serverConfig().useExternalConfig() &&
|
||||||
|
m_originalServerConfigUsesExternalFile == serverConfig().configFile() &&
|
||||||
|
m_originalProtocol == Settings::value(Settings::Server::Protocol).value<NetworkProtocol>();
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)
|
ui->buttonBox->button(QDialogButtonBox::Ok)
|
||||||
->setEnabled(!isAppConfigDataEqual || !(m_originalServerConfig == m_serverConfig));
|
->setEnabled(!isAppConfigDataEqual || !(m_originalServerConfig == m_serverConfig));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ private:
|
||||||
std::unique_ptr<Ui::ServerConfigDialog> ui;
|
std::unique_ptr<Ui::ServerConfigDialog> ui;
|
||||||
QString m_message = "";
|
QString m_message = "";
|
||||||
ServerConfig &m_originalServerConfig;
|
ServerConfig &m_originalServerConfig;
|
||||||
|
NetworkProtocol m_originalProtocol;
|
||||||
bool m_originalServerConfigIsExternal;
|
bool m_originalServerConfigIsExternal;
|
||||||
QString m_originalServerConfigUsesExternalFile;
|
QString m_originalServerConfigUsesExternalFile;
|
||||||
ServerConfig m_serverConfig;
|
ServerConfig m_serverConfig;
|
||||||
|
|
|
||||||
|
|
@ -635,7 +635,12 @@ void Config::readSectionOptions(ConfigReadContext &s)
|
||||||
++i;
|
++i;
|
||||||
s.parseNameWithArgs("value", line, ",;\n", i, value, valueArgs);
|
s.parseNameWithArgs("value", line, ",;\n", i, value, valueArgs);
|
||||||
|
|
||||||
|
// Skip old protocol name
|
||||||
|
if (name == "protocol")
|
||||||
|
continue;
|
||||||
|
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
|
|
||||||
if (name == "address") {
|
if (name == "address") {
|
||||||
try {
|
try {
|
||||||
m_deskflowAddress = NetworkAddress(value, kDefaultPort);
|
m_deskflowAddress = NetworkAddress(value, kDefaultPort);
|
||||||
|
|
@ -645,8 +650,6 @@ void Config::readSectionOptions(ConfigReadContext &s)
|
||||||
}
|
}
|
||||||
} else if (name == "heartbeat") {
|
} else if (name == "heartbeat") {
|
||||||
addOption("", kOptionHeartbeat, s.parseInt(value));
|
addOption("", kOptionHeartbeat, s.parseInt(value));
|
||||||
} else if (name == "protocol") {
|
|
||||||
addOption("", kOptionProtocol, s.parseProtocol(value));
|
|
||||||
} else if (name == "switchCorners") {
|
} else if (name == "switchCorners") {
|
||||||
addOption("", kOptionScreenSwitchCorners, s.parseCorners(value));
|
addOption("", kOptionScreenSwitchCorners, s.parseCorners(value));
|
||||||
} else if (name == "switchCornerSize") {
|
} else if (name == "switchCornerSize") {
|
||||||
|
|
@ -1314,13 +1317,6 @@ std::string Config::getOptionValue(OptionID id, OptionValue value)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (id == kOptionProtocol) {
|
|
||||||
const auto enumValue = networkProtocolFromInt(value);
|
|
||||||
if (enumValue == NetworkProtocol::Unknown)
|
|
||||||
throw InvalidProtocolException();
|
|
||||||
return networkProtocolToOption(enumValue).toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1795,14 +1791,6 @@ OptionValue ConfigReadContext::parseCorner(const std::string &arg) const
|
||||||
throw ServerConfigReadException(*this, "invalid argument \"%{1}\"", arg);
|
throw ServerConfigReadException(*this, "invalid argument \"%{1}\"", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionValue ConfigReadContext::parseProtocol(const std::string &args) const
|
|
||||||
{
|
|
||||||
const auto protoValue = networkProtocolFromString(QString::fromStdString(args));
|
|
||||||
if (protoValue == NetworkProtocol::Unknown)
|
|
||||||
throw ServerConfigReadException(*this, "invalid protocol argument \"%{1}\"", args);
|
|
||||||
return static_cast<OptionValue>(protoValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
OptionValue ConfigReadContext::parseCorners(const std::string &args) const
|
OptionValue ConfigReadContext::parseCorners(const std::string &args) const
|
||||||
{
|
{
|
||||||
// find first token
|
// find first token
|
||||||
|
|
|
||||||
|
|
@ -1085,12 +1085,7 @@ void Server::processOptions()
|
||||||
for (auto [optionId, optionValue] : *options) {
|
for (auto [optionId, optionValue] : *options) {
|
||||||
const OptionID id = optionId;
|
const OptionID id = optionId;
|
||||||
const OptionValue value = optionValue;
|
const OptionValue value = optionValue;
|
||||||
if (id == kOptionProtocol) {
|
if (id == kOptionScreenSwitchDelay) {
|
||||||
const auto enumValue = networkProtocolFromInt(value);
|
|
||||||
if (enumValue == NetworkProtocol::Unknown)
|
|
||||||
throw InvalidProtocolException();
|
|
||||||
m_protocol = enumValue;
|
|
||||||
} else if (id == kOptionScreenSwitchDelay) {
|
|
||||||
m_switchWaitDelay = 1.0e-3 * static_cast<double>(value);
|
m_switchWaitDelay = 1.0e-3 * static_cast<double>(value);
|
||||||
if (m_switchWaitDelay < 0.0) {
|
if (m_switchWaitDelay < 0.0) {
|
||||||
m_switchWaitDelay = 0.0;
|
m_switchWaitDelay = 0.0;
|
||||||
|
|
@ -1135,6 +1130,7 @@ void Server::processOptions()
|
||||||
stopRelativeMoves();
|
stopRelativeMoves();
|
||||||
}
|
}
|
||||||
m_relativeMoves = newRelativeMoves;
|
m_relativeMoves = newRelativeMoves;
|
||||||
|
m_protocol = Settings::value(Settings::Server::Protocol).value<NetworkProtocol>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleShapeChanged(BaseClientProxy *client)
|
void Server::handleShapeChanged(BaseClientProxy *client)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue