feat: Option to change server protocol in GUI

This commit is contained in:
Nick Bolton
2024-10-18 16:13:13 +01:00
parent 512faeea28
commit a5cd0fab9e
14 changed files with 623 additions and 448 deletions

View File

@ -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<ENetworkProtocol>(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<OptionValue>(ENetworkProtocol::kSynergy);
} else if (CaselessCmp::equal(args, kBarrierProtocolOption)) {
return static_cast<OptionValue>(ENetworkProtocol::kBarrier);
}
throw XConfigRead(*this, "invalid protocol argument \"%{1}\"", args);
}
OptionValue ConfigReadContext::parseCorners(const String &args) const
{
// find first token