Don't send dummy users to new console clients (#434)
This commit is contained in:
parent
37b93846db
commit
07499aaef4
@ -707,6 +707,7 @@ class SyncplayClient(object):
|
|||||||
# Can change during runtime:
|
# Can change during runtime:
|
||||||
features["sharedPlaylists"] = self.sharedPlaylistIsEnabled() # Can change during runtime
|
features["sharedPlaylists"] = self.sharedPlaylistIsEnabled() # Can change during runtime
|
||||||
features["chat"] = self.chatIsEnabled() # Can change during runtime
|
features["chat"] = self.chatIsEnabled() # Can change during runtime
|
||||||
|
features["uiMode"] = self.ui.getUIMode()
|
||||||
|
|
||||||
# Static for this version/release of Syncplay:
|
# Static for this version/release of Syncplay:
|
||||||
features["featureList"] = True
|
features["featureList"] = True
|
||||||
@ -1595,6 +1596,9 @@ class UiManager(object):
|
|||||||
self.lastAlertOSDEndTime = None
|
self.lastAlertOSDEndTime = None
|
||||||
self.lastError = ""
|
self.lastError = ""
|
||||||
|
|
||||||
|
def getUIMode(self):
|
||||||
|
return self.__ui.uiMode
|
||||||
|
|
||||||
def addFileToPlaylist(self, newPlaylistItem):
|
def addFileToPlaylist(self, newPlaylistItem):
|
||||||
self.__ui.addFileToPlaylist(newPlaylistItem)
|
self.__ui.addFileToPlaylist(newPlaylistItem)
|
||||||
|
|
||||||
|
|||||||
@ -349,3 +349,8 @@ DEFAULT_TRUSTED_DOMAINS = ["youtube.com", "youtu.be"]
|
|||||||
TRUSTABLE_WEB_PROTOCOLS = ["http", "https"]
|
TRUSTABLE_WEB_PROTOCOLS = ["http", "https"]
|
||||||
|
|
||||||
PRIVATE_FILE_FIELDS = ["path"]
|
PRIVATE_FILE_FIELDS = ["path"]
|
||||||
|
|
||||||
|
CONSOLE_UI_MODE = "CLI"
|
||||||
|
GRAPHICAL_UI_MODE = "GUI"
|
||||||
|
UNKNOWN_UI_MODE = "Unknown"
|
||||||
|
FALLBACK_ASSUMED_UI_MODE = GRAPHICAL_UI_MODE
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from twisted.python.versions import Version
|
|||||||
from zope.interface.declarations import implementer
|
from zope.interface.declarations import implementer
|
||||||
|
|
||||||
import syncplay
|
import syncplay
|
||||||
from syncplay.constants import PING_MOVING_AVERAGE_WEIGHT, CONTROLLED_ROOMS_MIN_VERSION, USER_READY_MIN_VERSION, SHARED_PLAYLIST_MIN_VERSION, CHAT_MIN_VERSION
|
from syncplay.constants import PING_MOVING_AVERAGE_WEIGHT, CONTROLLED_ROOMS_MIN_VERSION, USER_READY_MIN_VERSION, SHARED_PLAYLIST_MIN_VERSION, CHAT_MIN_VERSION, UNKNOWN_UI_MODE
|
||||||
from syncplay.messages import getMessage
|
from syncplay.messages import getMessage
|
||||||
from syncplay.utils import meetsMinVersion
|
from syncplay.utils import meetsMinVersion
|
||||||
|
|
||||||
@ -449,6 +449,7 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
self._features["readiness"] = meetsMinVersion(self._version, USER_READY_MIN_VERSION)
|
self._features["readiness"] = meetsMinVersion(self._version, USER_READY_MIN_VERSION)
|
||||||
self._features["managedRooms"] = meetsMinVersion(self._version, CONTROLLED_ROOMS_MIN_VERSION)
|
self._features["managedRooms"] = meetsMinVersion(self._version, CONTROLLED_ROOMS_MIN_VERSION)
|
||||||
self._features["persistentRooms"] = False
|
self._features["persistentRooms"] = False
|
||||||
|
self._features["uiMode"] = UNKNOWN_UI_MODE
|
||||||
return self._features
|
return self._features
|
||||||
|
|
||||||
def isLogged(self):
|
def isLogged(self):
|
||||||
@ -652,6 +653,7 @@ class SyncServerProtocol(JSONCommandProtocol):
|
|||||||
dummyCount = 0
|
dummyCount = 0
|
||||||
for watcher in watchers:
|
for watcher in watchers:
|
||||||
self._addUserOnList(userlist, watcher)
|
self._addUserOnList(userlist, watcher)
|
||||||
|
if self._watcher.isGUIUser(self.getFeatures()):
|
||||||
for emptyRoom in self._factory.getEmptyPersistentRooms():
|
for emptyRoom in self._factory.getEmptyPersistentRooms():
|
||||||
dummyCount += 1
|
dummyCount += 1
|
||||||
self._addDummyUserOnList(userlist, emptyRoom, dummyCount)
|
self._addDummyUserOnList(userlist, emptyRoom, dummyCount)
|
||||||
|
|||||||
@ -150,7 +150,7 @@ class SyncFactory(Factory):
|
|||||||
self._roomManager.broadcast(watcher, l)
|
self._roomManager.broadcast(watcher, l)
|
||||||
self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), False))
|
self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), False))
|
||||||
if self.roomsDbFile:
|
if self.roomsDbFile:
|
||||||
l = lambda w: w.sendList()
|
l = lambda w: w.sendList(toGUIOnly=True)
|
||||||
self._roomManager.broadcast(watcher, l)
|
self._roomManager.broadcast(watcher, l)
|
||||||
|
|
||||||
def removeWatcher(self, watcher):
|
def removeWatcher(self, watcher):
|
||||||
@ -158,7 +158,7 @@ class SyncFactory(Factory):
|
|||||||
self.sendLeftMessage(watcher)
|
self.sendLeftMessage(watcher)
|
||||||
self._roomManager.removeWatcher(watcher)
|
self._roomManager.removeWatcher(watcher)
|
||||||
if self.roomsDbFile:
|
if self.roomsDbFile:
|
||||||
l = lambda w: w.sendList()
|
l = lambda w: w.sendList(toGUIOnly=True)
|
||||||
self._roomManager.broadcast(watcher, l)
|
self._roomManager.broadcast(watcher, l)
|
||||||
|
|
||||||
def sendLeftMessage(self, watcher):
|
def sendLeftMessage(self, watcher):
|
||||||
@ -170,7 +170,7 @@ class SyncFactory(Factory):
|
|||||||
self._roomManager.broadcast(watcher, l)
|
self._roomManager.broadcast(watcher, l)
|
||||||
self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), False))
|
self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), False))
|
||||||
if self.roomsDbFile:
|
if self.roomsDbFile:
|
||||||
l = lambda w: w.sendList()
|
l = lambda w: w.sendList(toGUIOnly=True)
|
||||||
self._roomManager.broadcast(watcher, l)
|
self._roomManager.broadcast(watcher, l)
|
||||||
|
|
||||||
def sendFileUpdate(self, watcher):
|
def sendFileUpdate(self, watcher):
|
||||||
@ -781,9 +781,23 @@ class Watcher(object):
|
|||||||
if self._connector.meetsMinVersion(constants.CHAT_MIN_VERSION):
|
if self._connector.meetsMinVersion(constants.CHAT_MIN_VERSION):
|
||||||
self._connector.sendMessage({"Chat": message})
|
self._connector.sendMessage({"Chat": message})
|
||||||
|
|
||||||
def sendList(self):
|
def sendList(self, toGUIOnly=False):
|
||||||
|
if toGUIOnly and self.isGUIUser(self._connector.getFeatures()):
|
||||||
|
clientFeatures = self._connector.getFeatures()
|
||||||
|
if "uiMode" in clientFeatures:
|
||||||
|
if clientFeatures["uiMode"] == constants.CONSOLE_UI_MODE:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return
|
||||||
self._connector.sendList()
|
self._connector.sendList()
|
||||||
|
|
||||||
|
def isGUIUser(self, clientFeatures):
|
||||||
|
clientFeatures = self._connector.getFeatures()
|
||||||
|
uiMode = clientFeatures["uiMode"] if "uiMode" in clientFeatures else constants.UNKNOWN_UI_MODE
|
||||||
|
if uiMode == constants.UNKNOWN_UI_MODE:
|
||||||
|
uiMode = constants.FALLBACK_ASSUMED_UI_MODE
|
||||||
|
return uiMode == constants.GRAPHICAL_UI_MODE
|
||||||
|
|
||||||
def sendSetReady(self, username, isReady, manuallyInitiated=True):
|
def sendSetReady(self, username, isReady, manuallyInitiated=True):
|
||||||
self._connector.sendSetReady(username, isReady, manuallyInitiated)
|
self._connector.sendSetReady(username, isReady, manuallyInitiated)
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class ConsoleUI(threading.Thread):
|
|||||||
self.PromptResult = ""
|
self.PromptResult = ""
|
||||||
self.promptMode.set()
|
self.promptMode.set()
|
||||||
self._syncplayClient = None
|
self._syncplayClient = None
|
||||||
|
self.uiMode = constants.CONSOLE_UI_MODE
|
||||||
threading.Thread.__init__(self, name="ConsoleUI")
|
threading.Thread.__init__(self, name="ConsoleUI")
|
||||||
|
|
||||||
def addClient(self, client):
|
def addClient(self, client):
|
||||||
|
|||||||
@ -2081,3 +2081,4 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.show()
|
self.show()
|
||||||
self.setAcceptDrops(True)
|
self.setAcceptDrops(True)
|
||||||
self.clearedPlaylistNote = False
|
self.clearedPlaylistNote = False
|
||||||
|
self.uiMode = constants.GRAPHICAL_UI_MODE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user