forked from mumble-voip/mumble
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Murmur: allow both bitmasked version and version string when setting …
…'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
Showing
1 changed file
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
#include "PacketDataStream.h" | ||
#include "ServerDB.h" | ||
#include "ServerUser.h" | ||
#include "Version.h" | ||
|
||
#ifdef USE_BONJOUR | ||
#include "BonjourServer.h" | ||
|
@@ -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()) | ||
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mkrautz
Author
Owner
|
||
// 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; | ||
|
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 .