diff --git a/syncplay/client.py b/syncplay/client.py index 1c34c04..d8b1684 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -436,14 +436,14 @@ class SyncplayClient(object): def requireMinVersionDecorator(f): @wraps(f) def wrapper(self, *args, **kwds): - if int(self.serverVersion.replace(".", "")) < int(minVersion.replace(".", "")): + if not utils.meetsMinVersion(self.serverVersion,minVersion): self.ui.showErrorMessage(u"This feature is not supported by the server. The feature requires a server running Syncplay {}+, but the server is running Syncplay {}.".format(minVersion, self.serverVersion)) return return f(self, *args, **kwds) return wrapper return requireMinVersionDecorator - @requireMinServerVersion("1.3.0") + @requireMinServerVersion(constants.CONTROLLED_ROOMS_MIN_VERSION) def createControlledRoom(self, roomName): controlPassword = utils.RandomStringGenerator.generate_room_password() self.ui.showMessage(u"Attempting to create controlled room '{}' with password '{}'...".format(roomName, controlPassword)) @@ -463,7 +463,7 @@ class SyncplayClient(object): else: return "" - @requireMinServerVersion("1.3.0") + @requireMinServerVersion(constants.CONTROLLED_ROOMS_MIN_VERSION) def identifyAsController(self, controlPassword): controlPassword = self.stripControlPassword(controlPassword) self.ui.showMessage(getMessage("identifying-as-controller-notification").format(controlPassword)) diff --git a/syncplay/constants.py b/syncplay/constants.py index 3ad462b..265921c 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -52,6 +52,7 @@ COMMANDS_AUTH = ['a','auth'] MPC_MIN_VER = "1.6.4" VLC_MIN_VERSION = "2.0.0" VLC_INTERFACE_MIN_VERSION = "0.2.1" +CONTROLLED_ROOMS_MIN_VERSION = "1.3.0" MPC_PATHS = [ r"C:\Program Files (x86)\MPC-HC\mpc-hc.exe", r"C:\Program Files\MPC-HC\mpc-hc.exe", diff --git a/syncplay/server.py b/syncplay/server.py index f2cad52..221b262 100644 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -11,7 +11,7 @@ import codecs import os from string import Template import argparse -from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator +from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator, meetsMinVersion class SyncFactory(Factory): def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None): @@ -42,7 +42,7 @@ class SyncFactory(Factory): def getMotd(self, userIp, username, room, clientVersion): oldClient = False if constants.WARN_OLD_CLIENTS: - if int(clientVersion.replace(".", "")) < int(constants.RECENT_CLIENT_THRESHOLD.replace(".", "")): + if not meetsMinVersion(clientVersion, constants.RECENT_CLIENT_THRESHOLD): oldClient = True if self._motdFilePath and os.path.isfile(self._motdFilePath): tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read() diff --git a/syncplay/utils.py b/syncplay/utils.py index 9c2715d..f787c9a 100644 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -210,6 +210,13 @@ def sameFileduration (duration1, duration2): else: return False +def meetsMinVersion(version, minVersion): + def versiontotuple(ver): + return tuple(map(int, ver.split("."))) + versionTuple = versiontotuple(version) + minVersionTuple = versiontotuple(minVersion) + return versionTuple >= minVersionTuple + class RoomPasswordProvider(object): CONTROLLED_ROOM_REGEX = re.compile("^\+(.*):(\w{12})$") PASSWORD_REGEX = re.compile("[A-Z]{2}-\d{3}-\d{3}")