Skip to content
Permalink
Browse files

Murmur: allow both bitmasked version and version string when setting …

…'suggestversion' via RPC.

This commit ensures that a 'suggestversion' is always normalized to a
bitmasked version.

Previously, only a bitmasked 'suggestverson' was allowed.

With this commit, 'suggestversion' may now be either a version string,
or a bitmasked integer value representing the version.

The previous behavior was confusing to users, since the murmur.ini
has always used 'suggestversion' with a version string.

Fixes #989
  • Loading branch information...
mkrautz committed Dec 26, 2015
1 parent b83316a commit 33f8448d7c85962344ee2c19646500d63cf09b09
Showing with 38 additions and 2 deletions.
  1. +38 −2 src/murmur/Server.cpp
@@ -43,6 +43,7 @@
#include "PacketDataStream.h"
#include "ServerDB.h"
#include "ServerUser.h"
#include "Version.h"

#ifdef USE_BONJOUR
#include "BonjourServer.h"
@@ -360,6 +361,41 @@ Server::~Server() {
log("Stopped");
}

/// normalizeSuggestVersion normalizes a 'suggestversion' config value.
/// The config value may be a version string, or a bitmasked
/// integer representing the version.
/// This function converts the 'suggestversion' config value to
/// always be a bitmasked integer representation.
///
/// On error, the function returns an empty QVariant.
static QVariant normalizeSuggestVersion(QVariant suggestVersion) {
uint integerValue = suggestVersion.toUInt();

// If the integer value is 0, it can mean two things:
//
// Either the suggestversion is set to 0.
// Or, the suggestversion is a version string such as "1.3.0",
// and cannot be converted to an integer value.
//
// We handle both cases the same: by pretending the
// suggestversion is a version string in both cases.
//
// If it is a version string, the call to MumbleVersion::getRaw()
// will return the bitmasked representation.
//
// If it is not a version string, the call to MumbleVersion::getRaw()
// will return 0, so it is effectively a no-op.
if (integerValue == 0) {
integerValue = MumbleVersion::getRaw(suggestVersion.toString());
}

if (integerValue != 0) {
return integerValue;
}

return QVariant();
}

void Server::readParams() {
qsPassword = Meta::mp.qsPassword;
usPort = static_cast<unsigned short>(Meta::mp.usPort + iServerNum - 1);
@@ -441,7 +477,7 @@ void Server::readParams() {
bCertRequired = getConf("certrequired", bCertRequired).toBool();
bForceExternalAuth = getConf("forceExternalAuth", bForceExternalAuth).toBool();

qvSuggestVersion = getConf("suggestversion", qvSuggestVersion);
qvSuggestVersion = normalizeSuggestVersion(getConf("suggestversion", qvSuggestVersion));
if (qvSuggestVersion.toUInt() == 0)
qvSuggestVersion = QVariant();

@@ -566,7 +602,7 @@ void Server::setLiveConf(const QString &key, const QString &value) {
else if (key == "channelname")
qrChannelName=!v.isNull() ? QRegExp(v) : Meta::mp.qrChannelName;
else if (key == "suggestversion")
qvSuggestVersion = ! v.isNull() ? (v.isEmpty() ? QVariant() : v) : Meta::mp.qvSuggestVersion;
qvSuggestVersion = ! v.isNull() ? (v.isEmpty() ? QVariant() : normalizeSuggestVersion(v)) : Meta::mp.qvSuggestVersion;
else if (key == "suggestpositional")
qvSuggestPositional = ! v.isNull() ? (v.isEmpty() ? QVariant() : v) : Meta::mp.qvSuggestPositional;
else if (key == "suggestpushtotalk")

0 comments on commit 33f8448

Please sign in to comment.
You can’t perform that action at this time.