Merge branch 'master' of git://github.com/Uriziel/syncplay
This commit is contained in:
commit
bbee87932a
@ -1,3 +1,3 @@
|
|||||||
version = '1.2.7'
|
version = '1.2.8'
|
||||||
milestone = 'Biscuit'
|
milestone = 'Hammer'
|
||||||
projectURL = 'http://syncplay.pl/'
|
projectURL = 'http://syncplay.pl/'
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
#coding:utf8
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
@ -11,6 +10,7 @@ from syncplay.messages import getMessage
|
|||||||
import threading
|
import threading
|
||||||
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
|
from syncplay.constants import PRIVACY_SENDHASHED_MODE, PRIVACY_DONTSEND_MODE, \
|
||||||
PRIVACY_HIDDENFILENAME, FILENAME_STRIP_REGEX
|
PRIVACY_HIDDENFILENAME, FILENAME_STRIP_REGEX
|
||||||
|
import collections
|
||||||
# <MAL DISABLE>
|
# <MAL DISABLE>
|
||||||
libMal = None
|
libMal = None
|
||||||
'''try:
|
'''try:
|
||||||
@ -19,6 +19,7 @@ except ImportError:
|
|||||||
libMal = None
|
libMal = None
|
||||||
'''
|
'''
|
||||||
# </MAL DISABLE>
|
# </MAL DISABLE>
|
||||||
|
|
||||||
class SyncClientFactory(ClientFactory):
|
class SyncClientFactory(ClientFactory):
|
||||||
def __init__(self, client, retry=constants.RECONNECT_RETRIES):
|
def __init__(self, client, retry=constants.RECONNECT_RETRIES):
|
||||||
self._client = client
|
self._client = client
|
||||||
@ -466,8 +467,13 @@ class SyncplayUser(object):
|
|||||||
return sameName and sameSize and sameDuration
|
return sameName and sameSize and sameDuration
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self.username < other.username
|
return self.username.lower() < other.username.lower()
|
||||||
|
|
||||||
|
def __repr__(self, *args, **kwargs):
|
||||||
|
if(self.file):
|
||||||
|
return "{}: {} ({}, {})".format(self.username, self.file['name'], self.file['duration'], self.file['size'])
|
||||||
|
else:
|
||||||
|
return "{}".format(self.username)
|
||||||
|
|
||||||
class MalUpdater(object):
|
class MalUpdater(object):
|
||||||
def __init__(self, username, password, ui):
|
def __init__(self, username, password, ui):
|
||||||
@ -623,12 +629,18 @@ class SyncplayUserlist(object):
|
|||||||
if(self.currentUser.room not in rooms):
|
if(self.currentUser.room not in rooms):
|
||||||
rooms[self.currentUser.room] = []
|
rooms[self.currentUser.room] = []
|
||||||
rooms[self.currentUser.room].append(self.currentUser)
|
rooms[self.currentUser.room].append(self.currentUser)
|
||||||
|
rooms = self.sortList(rooms)
|
||||||
self.ui.showUserList(self.currentUser, rooms)
|
self.ui.showUserList(self.currentUser, rooms)
|
||||||
|
|
||||||
def clearList(self):
|
def clearList(self):
|
||||||
self._users = {}
|
self._users = {}
|
||||||
|
|
||||||
|
def sortList(self, rooms):
|
||||||
|
for room in rooms:
|
||||||
|
rooms[room] = sorted(rooms[room])
|
||||||
|
rooms = collections.OrderedDict(sorted(rooms.items(), key=lambda s: s[0].lower()))
|
||||||
|
return rooms
|
||||||
|
|
||||||
class UiManager(object):
|
class UiManager(object):
|
||||||
def __init__(self, client, ui):
|
def __init__(self, client, ui):
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|||||||
@ -8,6 +8,8 @@ UI_TIME_FORMAT = "[%X] "
|
|||||||
CONFIG_NAMES = [".syncplay", "syncplay.ini"] #Syncplay searches first to last
|
CONFIG_NAMES = [".syncplay", "syncplay.ini"] #Syncplay searches first to last
|
||||||
DEFAULT_CONFIG_NAME_WINDOWS = "syncplay.ini"
|
DEFAULT_CONFIG_NAME_WINDOWS = "syncplay.ini"
|
||||||
DEFAULT_CONFIG_NAME_LINUX = ".syncplay"
|
DEFAULT_CONFIG_NAME_LINUX = ".syncplay"
|
||||||
|
RECENT_CLIENT_THRESHOLD = "1.2.7" #This and higher considered 'recent' clients (no warnings)
|
||||||
|
WARN_OLD_CLIENTS = True #Use MOTD to inform old clients to upgrade
|
||||||
|
|
||||||
#Changing these might be ok
|
#Changing these might be ok
|
||||||
REWIND_THRESHOLD = 4
|
REWIND_THRESHOLD = 4
|
||||||
|
|||||||
@ -163,6 +163,9 @@ en = {
|
|||||||
|
|
||||||
"help-tooltip" : "Opens the Syncplay.pl user guide.",
|
"help-tooltip" : "Opens the Syncplay.pl user guide.",
|
||||||
|
|
||||||
|
# Server messages to client
|
||||||
|
"new-syncplay-available-motd-message" : "<NOTICE> You are using Syncplay {} but a newer version is available from http://syncplay.pl </NOTICE>", #ClientVersion
|
||||||
|
|
||||||
# Server notifications
|
# Server notifications
|
||||||
"welcome-server-notification" : "Welcome to Syncplay server, ver. {0}", #version
|
"welcome-server-notification" : "Welcome to Syncplay server, ver. {0}", #version
|
||||||
"client-connected-room-server-notification" : "{0}({2}) connected to room '{1}'", #username, host, room
|
"client-connected-room-server-notification" : "{0}({2}) connected to room '{1}'", #username, host, room
|
||||||
|
|||||||
@ -291,9 +291,9 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
return
|
return
|
||||||
self._factory.addWatcher(self, username, roomName, roomPassword)
|
self._factory.addWatcher(self, username, roomName, roomPassword)
|
||||||
self._logged = True
|
self._logged = True
|
||||||
self.sendHello()
|
self.sendHello(version)
|
||||||
|
|
||||||
def sendHello(self):
|
def sendHello(self, clientVersion):
|
||||||
hello = {}
|
hello = {}
|
||||||
username = self._factory.watcherGetUsername(self)
|
username = self._factory.watcherGetUsername(self)
|
||||||
hello["username"] = username
|
hello["username"] = username
|
||||||
@ -301,7 +301,7 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
room = self._factory.watcherGetRoom(self)
|
room = self._factory.watcherGetRoom(self)
|
||||||
if(room): hello["room"] = {"name": room}
|
if(room): hello["room"] = {"name": room}
|
||||||
hello["version"] = syncplay.version
|
hello["version"] = syncplay.version
|
||||||
hello["motd"] = self._factory.getMotd(userIp, username, room)
|
hello["motd"] = self._factory.getMotd(userIp, username, room, clientVersion)
|
||||||
self.sendMessage({"Hello": hello})
|
self.sendMessage({"Hello": hello})
|
||||||
|
|
||||||
@requireLogged
|
@requireLogged
|
||||||
|
|||||||
@ -136,15 +136,24 @@ class SyncFactory(Factory):
|
|||||||
position += timePassedSinceSet
|
position += timePassedSinceSet
|
||||||
return paused, position
|
return paused, position
|
||||||
|
|
||||||
def getMotd(self, userIp, username, room):
|
def getMotd(self, userIp, username, room, clientVersion):
|
||||||
|
oldClient = False
|
||||||
|
if constants.WARN_OLD_CLIENTS:
|
||||||
|
if int(clientVersion.replace(".","")) < int(constants.RECENT_CLIENT_THRESHOLD.replace(".","")):
|
||||||
|
oldClient = True
|
||||||
if(self._motdFilePath and os.path.isfile(self._motdFilePath)):
|
if(self._motdFilePath and os.path.isfile(self._motdFilePath)):
|
||||||
tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read()
|
tmpl = codecs.open(self._motdFilePath, "r", "utf-8-sig").read()
|
||||||
args = dict(version=syncplay.version, userIp=userIp, username=username, room=room)
|
args = dict(version=syncplay.version, userIp=userIp, username=username, room=room)
|
||||||
try:
|
try:
|
||||||
motd = Template(tmpl).substitute(args)
|
motd = Template(tmpl).substitute(args)
|
||||||
|
if oldClient:
|
||||||
|
motdwarning = getMessage("en","new-syncplay-available-motd-message").format(clientVersion)
|
||||||
|
motd = "{}\n{}".format(motdwarning, motd)
|
||||||
return motd if len(motd) < constants.SERVER_MAX_TEMPLATE_LENGTH else getMessage("en", "server-messed-up-motd-too-long").format(constants.SERVER_MAX_TEMPLATE_LENGTH, len(motd))
|
return motd if len(motd) < constants.SERVER_MAX_TEMPLATE_LENGTH else getMessage("en", "server-messed-up-motd-too-long").format(constants.SERVER_MAX_TEMPLATE_LENGTH, len(motd))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return getMessage("en", "server-messed-up-motd-unescaped-placeholders")
|
return getMessage("en", "server-messed-up-motd-unescaped-placeholders")
|
||||||
|
elif oldClient:
|
||||||
|
return getMessage("en", "new-syncplay-available-motd-message").format(clientVersion)
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
|
try:
|
||||||
from syncplay.ui.gui import MainWindow as GraphicalUI
|
from syncplay.ui.gui import MainWindow as GraphicalUI
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
from syncplay.ui.consoleUI import ConsoleUI
|
from syncplay.ui.consoleUI import ConsoleUI
|
||||||
|
|
||||||
def getUi(graphical=True):
|
def getUi(graphical=True):
|
||||||
|
|||||||
@ -211,7 +211,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
t = self._syncplayClient.getUserOffset() + sign * t
|
t = self._syncplayClient.getUserOffset() + sign * t
|
||||||
self._syncplayClient.setUserOffset(t)
|
self._syncplayClient.setUserOffset(t)
|
||||||
else:
|
else:
|
||||||
self.showMessage("Invalid offset value", True)
|
self.showErrorMessage("Invalid offset value")
|
||||||
|
|
||||||
def openUserGuide(self):
|
def openUserGuide(self):
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux'):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user