Add "add X as trusted domain" playlist menu option

This commit is contained in:
Et0h 2016-10-17 23:50:45 +01:00
parent 65f6f4b4b9
commit 7465c85d8e
8 changed files with 33 additions and 3 deletions

View File

@ -658,6 +658,7 @@ guiIcons = ['resources/accept.png', 'resources/arrow_undo.png', 'resources/clock
'resources/film_folder_edit.png',
'resources/film_edit.png',
'resources/shield_edit.png',
'resources/shield_add.png',
'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng'
]
resources = ["resources/icon.ico", "resources/syncplay.png"]

BIN
resources/shield_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

View File

@ -462,10 +462,22 @@ class SyncplayClient(object):
def setTrustedDomains(self, newTrustedDomains):
from syncplay.ui.ConfigurationGetter import ConfigurationGetter
ConfigurationGetter().setConfigOption("trustedDomains", newTrustedDomains)
self._config['trustedDomains'] = newTrustedDomains
self.fileSwitchFoundFiles()
oldTrustedDomains = self._config['trustedDomains']
if oldTrustedDomains <> newTrustedDomains:
self._config['trustedDomains'] = newTrustedDomains
self.fileSwitchFoundFiles()
self.ui.showMessage("Trusted domains updated")
# TODO: Properly add message for setting trusted domains!
def isUntrustedTrustableURI(self, URIToTest):
if utils.isURL(URIToTest):
for trustedProtocol in constants.TRUSTABLE_WEB_PROTOCOLS:
if URIToTest.startswith(trustedProtocol) and not self.isURITrusted(URIToTest):
return True
return False
def isURITrusted(self, URIToTest):
URIToTest = URIToTest+u"/"
for trustedProtocol in constants.TRUSTABLE_WEB_PROTOCOLS:
if URIToTest.startswith(trustedProtocol):
if self._config['onlySwitchToTrustedDomains']:

View File

@ -269,6 +269,7 @@ de = {
"createcontrolledroom-menu-label" : u"&Zentral gesteuerten Raum erstellen",
"identifyascontroller-menu-label" : u"Als Raumleiter &identifizieren",
"settrusteddomains-menu-label" : u"Set &trusted domains", # TODO: Translate
"addtrusteddomain-menu-label" : u"Add {} as trusted domain", # Domain # TODO: Translate
"playback-menu-label" : u"&Wiedergabe",

View File

@ -271,6 +271,7 @@ en = {
"createcontrolledroom-menu-label" : "&Create managed room",
"identifyascontroller-menu-label" : "&Identify as room operator",
"settrusteddomains-menu-label" : u"Set &trusted domains",
"addtrusteddomain-menu-label" : u"Add {} as trusted domain", # Domain
"playback-menu-label" : u"&Playback",

View File

@ -230,6 +230,7 @@ ru = {
"unpause-ifminusersready-option" : u"Unpause if already ready or if all others ready and min users ready", # TODO: Translate into Russian
"unpause-always" : u"Always unpause", # TODO: Translate into Russian
"syncplay-trusteddomains-title": u"Trusted domains (for streaming services and hosted content)", # TODO: Translate into Russian
"addtrusteddomain-menu-label" : u"Add {} as trusted domain", # Domain # TODO: Translate
"help-label" : u"Помощь",
"reset-label" : u"Сброс настроек",

View File

@ -498,6 +498,9 @@ class MainWindow(QtGui.QMainWindow):
pathFound = self._syncplayClient.fileSwitch.findFilepath(firstFile)
if pathFound:
menu.addAction(QtGui.QPixmap(resourcespath + u"film_go.png"), getMessage("openmedia-menu-label"), lambda: self.openFile(pathFound))
if self._syncplayClient.isUntrustedTrustableURI(firstFile):
domain = utils.getDomainFromURL(firstFile)
menu.addAction(QtGui.QPixmap(resourcespath + u"shield_add.png"),getMessage("addtrusteddomain-menu-label").format(domain), lambda: self.addTrustedDomain(domain))
menu.addAction(QtGui.QPixmap(resourcespath + u"delete.png"), getMessage("removefromplaylist-menu-label"), lambda: self.deleteSelectedPlaylistItems())
menu.addSeparator()
menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_switch.png"), getMessage("shuffleplaylist-menuu-label"), lambda: self.shufflePlaylist())
@ -897,7 +900,12 @@ class MainWindow(QtGui.QMainWindow):
if result == QtGui.QDialog.Accepted:
newTrustedDomains = utils.convertMultilineStringToList(TrustedDomainsTextbox.toPlainText())
self._syncplayClient.setTrustedDomains(newTrustedDomains)
@needsClient
def addTrustedDomain(self, newDomain):
trustedDomains = self.config["trustedDomains"][:]
if newDomain:
trustedDomains.append(newDomain)
self._syncplayClient.setTrustedDomains(trustedDomains)
@needsClient
def openAddMediaDirectoryDialog(self, MediaDirectoriesTextbox, MediaDirectoriesDialog):

View File

@ -250,6 +250,12 @@ def getListAsMultilineString(pathArray):
def convertMultilineStringToList(multilineString):
return unicode.split(multilineString,u"\n") if multilineString else ""
def getDomainFromURL(URL):
try:
return URL.split("//")[-1].split("/")[0]
except:
return None
def getListOfPublicServers():
try:
import urllib, syncplay, sys, messages, json