Added sending the "controller" status with a list

This commit is contained in:
Uriziel 2014-10-12 22:07:01 +02:00
parent 7032a9634c
commit e88863e2ac
3 changed files with 13 additions and 4 deletions

View File

@ -574,10 +574,12 @@ class SyncplayUserlist(object):
message = getMessage("file-differences-notification") + ", ".join(differences)
self.ui.showMessage(message, not constants.SHOW_OSD_WARNINGS)
def addUser(self, username, room, file_, noMessage=False):
def addUser(self, username, room, file_, noMessage=False, isController=False):
if username == self.currentUser.username:
return
user = SyncplayUser(username, room, file_)
if isController:
user.setAsController()
self._users[username] = user
if not noMessage:
self.__showUserChangeMessage(username, room, file_)

View File

@ -148,7 +148,8 @@ class SyncClientProtocol(JSONCommandProtocol):
for user in room[1].iteritems():
userName = user[0]
file_ = user[1]['file'] if user[1]['file'] <> {} else None
self._client.userlist.addUser(userName, roomName, file_, noMessage=True)
isController = user[1]['controller'] if 'controller' in user[1] else False
self._client.userlist.addUser(userName, roomName, file_, noMessage=True, isController=isController)
self._client.userlist.showUserList()
def sendList(self):
@ -360,7 +361,11 @@ class SyncServerProtocol(JSONCommandProtocol):
if room:
if room.getName() not in userlist:
userlist[room.getName()] = {}
userFile = { "position": 0, "file": watcher.getFile() if watcher.getFile() else {} }
userFile = {
"position": 0,
"file": watcher.getFile() if watcher.getFile() else {},
"controller": watcher.isController()
}
userlist[room.getName()][watcher.getName()] = userFile
def sendList(self):

View File

@ -1,6 +1,5 @@
import hashlib
import random
import re
from twisted.internet import task, reactor
from twisted.internet.protocol import Factory
import syncplay
@ -402,6 +401,9 @@ class Watcher(object):
if doSeek or pauseChanged:
self._server.forcePositionUpdate(self, doSeek, paused)
def isController(self):
return RoomPasswordProvider.isControlledRoom(self._room.getName()) \
and self._room.canControl(self)
class ConfigurationGetter(object):
def getConfiguration(self):