Skip to content

Commit

Permalink
Murmur: allow both bitmasked version and version string when setting …
Browse files Browse the repository at this point in the history
…'suggestversion' via RPC.

This commit changes the logic for setting the 'suggestversion' config
option via RPC to automatically figure out whether the passed-in value
is a bitmasked version or a version string.

If it is a version string, it will convert the version string to the
bitmasked format, which is what is used internally.

Prior to this, 'suggestversion' via RPC only allowed a bitmasked
version. This was confusing users, since the .ini file requires a
a version string.

Fixes mumble-voip#989
  • Loading branch information
mkrautz committed Dec 26, 2015
1 parent da8a95e commit dc918c9
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/murmur/Server.cpp
Expand Up @@ -43,6 +43,7 @@
#include "PacketDataStream.h"
#include "ServerDB.h"
#include "ServerUser.h"
#include "Version.h"

#ifdef USE_BONJOUR
#include "BonjourServer.h"
Expand Down Expand Up @@ -441,9 +442,19 @@ void Server::readParams() {
bCertRequired = getConf("certrequired", bCertRequired).toBool();
bForceExternalAuth = getConf("forceExternalAuth", bForceExternalAuth).toBool();

// The suggestversion config option can either be an integer, containing
// a bit-shifted version, where 1.3.0 would be
//
// (1 << 16) + (3 << 8) + 0) => 66053
//
// or it can be a string containing a version, such as "1.3.0".
qvSuggestVersion = getConf("suggestversion", qvSuggestVersion);
if (qvSuggestVersion.toUInt() == 0)
if (qvSuggestVersion.toUInt() == 0) {
qvSuggestVersion = MumbleVersion::getRaw(qvSuggestVersion.toString());
}
if (qvSuggestVersion.toUInt() == 0) {
qvSuggestVersion = QVariant();
}

qvSuggestPositional = getConf("suggestpositional", qvSuggestPositional);
if (qvSuggestPositional.toString().trimmed().isEmpty())
Expand Down Expand Up @@ -565,9 +576,27 @@ void Server::setLiveConf(const QString &key, const QString &value) {
qrUserName=!v.isNull() ? QRegExp(v) : Meta::mp.qrUserName;
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;
else if (key == "suggestpositional")
else if (key == "suggestversion") {
if (v.isNull()) {
qvSuggestVersion = Meta::mp.qvSuggestVersion;
} else {
// The suggestversion config option can either be an integer, containing

This comment has been minimized.

Copy link
@hacst

hacst Dec 26, 2015

Imho the commented block below should be extracted into a function. It's equivalent to what is done above (with the same comment). Can be a free function in the .cpp .

This comment has been minimized.

Copy link
@mkrautz

mkrautz Dec 26, 2015

Author Owner

Not exactly. One works on a QVariant, one works on a QString, but I will try to look at it.

// a bit-shifted version, where 1.3.0 would be
//
// (1 << 16) + (3 << 8) + 0) => 66053
//
// or it can be a string containing a version, such as "1.3.0".
uint suggestedVersion = v.toUInt();
if (suggestedVersion == 0) {
suggestedVersion = MumbleVersion::getRaw(v);
}
if (suggestedVersion != 0) {
qvSuggestVersion = suggestedVersion;
} else {
qvSuggestVersion = QVariant();
}
}
} else if (key == "suggestpositional")
qvSuggestPositional = ! v.isNull() ? (v.isEmpty() ? QVariant() : v) : Meta::mp.qvSuggestPositional;
else if (key == "suggestpushtotalk")
qvSuggestPushToTalk = ! v.isNull() ? (v.isEmpty() ? QVariant() : v) : Meta::mp.qvSuggestPushToTalk;
Expand Down

0 comments on commit dc918c9

Please sign in to comment.