mirror of
https://github.com/Syncplay/syncplay
synced 2025-03-05 19:27:54 +00:00
Add 'Set Trusted Domain' feature to main GUI and highlight untrusted domains in playlist
This commit is contained in:
parent
dc798d1173
commit
a1ab184e9a
@ -1,4 +1,4 @@
|
||||
version = '1.4.0'
|
||||
milestone = 'Yoitsu'
|
||||
release_number = '25'
|
||||
release_number = '26'
|
||||
projectURL = 'http://syncplay.pl/'
|
||||
|
@ -455,6 +455,12 @@ class SyncplayClient(object):
|
||||
self.sendFile()
|
||||
self.playlist.changeToPlaylistIndexFromFilename(filename)
|
||||
|
||||
def setTrustedDomains(self, newTrustedDomains):
|
||||
from syncplay.ui.ConfigurationGetter import ConfigurationGetter
|
||||
ConfigurationGetter().setConfigOption("trustedDomains", newTrustedDomains)
|
||||
self._config['trustedDomains'] = newTrustedDomains
|
||||
self.fileSwitchFoundFiles()
|
||||
|
||||
def isURITrusted(self, URIToTest):
|
||||
for trustedProtocol in constants.TRUSTABLE_WEB_PROTOCOLS:
|
||||
if URIToTest.startswith(trustedProtocol):
|
||||
|
@ -144,6 +144,7 @@ STYLE_ERRORNOTIFICATION = "color: red;"
|
||||
STYLE_DIFFERENTITEM_COLOR = 'red'
|
||||
STYLE_NOFILEITEM_COLOR = 'blue'
|
||||
STYLE_NOTCONTROLLER_COLOR = 'grey'
|
||||
STYLE_UNTRUSTEDITEM_COLOR = 'purple'
|
||||
|
||||
USERLIST_GUI_USERNAME_OFFSET = 21 # Pixels
|
||||
USERLIST_GUI_USERNAME_COLUMN = 0
|
||||
|
@ -267,6 +267,7 @@ de = {
|
||||
"setoffset-menu-label" : u"&Offset einstellen",
|
||||
"createcontrolledroom-menu-label" : u"&Zentral gesteuerten Raum erstellen",
|
||||
"identifyascontroller-menu-label" : u"Als Raumleiter &identifizieren",
|
||||
"settrusteddomains-menu-label" : u"Set &trusted domains", # TODO: Translate
|
||||
|
||||
"playback-menu-label" : u"&Wiedergabe",
|
||||
|
||||
@ -283,6 +284,7 @@ de = {
|
||||
"addfolder-label" : u"Add folder", # TODO: Translate
|
||||
|
||||
"adduris-msgbox-label" : u"Add URLs to playlist (one per line)", # TODO: Translate
|
||||
"trusteddomains-msgbox-label" : u"Domains it is okay to automatically switch to (one per line)", # TODO: Translate
|
||||
|
||||
"createcontrolledroom-msgbox-label" : u"Zentral gesteuerten Raum erstellen",
|
||||
"controlledroominfo-msgbox-label" : u"Namen des zentral gesteuerten Raums eingeben\r\n(siehe http://syncplay.pl/guide/ für eine Anleitung [Englisch]):",
|
||||
@ -388,7 +390,7 @@ de = {
|
||||
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username
|
||||
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
|
||||
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not automatically load {} because it is not on a trusted domain. You can switch to the URL manually by double clicking it in the playlist, and add trusted domains via File->Advanced->Set Trusted Domains.", # Filename
|
||||
"sharedplaylistenabled-label" : u"Enable shared playlists",
|
||||
"removefromplaylist-menu-label" : u"Remove from playlist",
|
||||
"shuffleplaylist-menuu-label" : u"Shuffle playlist",
|
||||
|
@ -269,6 +269,7 @@ en = {
|
||||
"setoffset-menu-label" : "Set &offset",
|
||||
"createcontrolledroom-menu-label" : "&Create managed room",
|
||||
"identifyascontroller-menu-label" : "&Identify as room operator",
|
||||
"settrusteddomains-menu-label" : u"Set &trusted domains",
|
||||
|
||||
"playback-menu-label" : u"&Playback",
|
||||
|
||||
@ -285,6 +286,7 @@ en = {
|
||||
"addfolder-label" : u"Add folder",
|
||||
|
||||
"adduris-msgbox-label" : u"Add URLs to playlist (one per line)",
|
||||
"trusteddomains-msgbox-label" : u"Domains it is okay to automatically switch to (one per line)",
|
||||
|
||||
"createcontrolledroom-msgbox-label" : "Create managed room",
|
||||
"controlledroominfo-msgbox-label" : "Enter name of managed room\r\n(see http://syncplay.pl/guide/ for usage instructions):",
|
||||
@ -389,7 +391,7 @@ en = {
|
||||
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username
|
||||
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
|
||||
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not automatically load {} because it is not on a trusted domain. You can switch to the URL manually by double clicking it in the playlist, and add trusted domains via File->Advanced->Set Trusted Domains.", # Filename
|
||||
"sharedplaylistenabled-label" : u"Enable shared playlists",
|
||||
"removefromplaylist-menu-label" : u"Remove from playlist",
|
||||
"shuffleplaylist-menuu-label" : u"Shuffle playlist",
|
||||
|
@ -269,6 +269,7 @@ ru = {
|
||||
"setoffset-menu-label" : u"Установить &смещение",
|
||||
"createcontrolledroom-menu-label" : u"&Создать управляемую комнату",
|
||||
"identifyascontroller-menu-label" : u"&Войти как оператор комнаты",
|
||||
"settrusteddomains-menu-label" : u"Set &trusted domains", # TODO: Translate
|
||||
|
||||
"playback-menu-label" : u"&Воспроизведение",
|
||||
|
||||
@ -285,6 +286,7 @@ ru = {
|
||||
"addfolder-label" : u"Add folder", # TODO: Translate
|
||||
|
||||
"adduris-msgbox-label" : u"Add URLs to playlist (one per line)", # TODO: Translate
|
||||
"trusteddomains-msgbox-label" : u"Domains it is okay to automatically switch to (one per line)", # TODO: Translate
|
||||
|
||||
"createcontrolledroom-msgbox-label" : u"Создать управляемую комнату",
|
||||
"controlledroominfo-msgbox-label" : u"Введите имя управляемой комнаты\r\n(см. инструкцию на странице http://syncplay.pl/guide/):",
|
||||
@ -388,7 +390,7 @@ ru = {
|
||||
"playlist-contents-changed-notification" : u"{} updated the playlist", # Username
|
||||
"cannot-find-file-for-playlist-switch-error" : u"Could not find file {} in media directories for playlist switch!", # Filename
|
||||
"cannot-add-duplicate-error" : u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.", #Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not load {} because it is not known as a trusted path.", # Filename
|
||||
"cannot-add-unsafe-path-error" : u"Could not automatically load {} because it is not on a trusted domain. You can switch to the URL manually by double clicking it in the playlist, and add trusted domains via File->Advanced->Set Trusted Domains.", # Filename # TODO: Translate
|
||||
"sharedplaylistenabled-label" : u"Enable shared playlists",
|
||||
"removefromplaylist-menu-label" : u"Remove from playlist",
|
||||
"shuffleplaylist-menuu-label" : u"Shuffle playlist",
|
||||
|
@ -182,7 +182,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
isPlayingFilename = itemFilename == self.playlistIndexFilename
|
||||
self.item(item).setData(Qt.UserRole + constants.PLAYLISTITEM_CURRENTLYPLAYING_ROLE, isPlayingFilename)
|
||||
fileIsAvailable = self.selfWindow.isFileAvailable(itemFilename)
|
||||
if fileIsAvailable:
|
||||
fileIsUntrusted = self.selfWindow.isItemUntrusted(itemFilename)
|
||||
if fileIsUntrusted:
|
||||
self.item(item).setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_UNTRUSTEDITEM_COLOR)))
|
||||
elif fileIsAvailable:
|
||||
self.item(item).setForeground(QtGui.QBrush(QtGui.QColor(QtGui.QPalette.ColorRole(QtGui.QPalette.Text))))
|
||||
else:
|
||||
self.item(item).setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
|
||||
@ -349,6 +352,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.newWatchlist.extend([filename])
|
||||
return constants.FILEITEM_SWITCH_NO_SWITCH
|
||||
|
||||
@needsClient
|
||||
def isItemUntrusted(self, filename):
|
||||
return isURL(filename) and not self._syncplayClient.isURITrusted(filename)
|
||||
|
||||
@needsClient
|
||||
def isFileAvailable(self, filename):
|
||||
if filename:
|
||||
@ -834,6 +841,32 @@ class MainWindow(QtGui.QMainWindow):
|
||||
newMediaDirectories = utils.convertMultilineStringToList(MediaDirectoriesTextbox.toPlainText())
|
||||
self._syncplayClient.fileSwitch.changeMediaDirectories(newMediaDirectories)
|
||||
|
||||
@needsClient
|
||||
def openSetTrustedDomainsDialog(self):
|
||||
TrustedDomainsDialog = QtGui.QDialog()
|
||||
TrustedDomainsDialog.setWindowTitle(getMessage("settrusteddomains-menu-label"))
|
||||
TrustedDomainsLayout = QtGui.QGridLayout()
|
||||
TrustedDomainsLabel = QtGui.QLabel(getMessage("trusteddomains-msgbox-label"))
|
||||
TrustedDomainsLayout.addWidget(TrustedDomainsLabel, 0, 0, 1, 1)
|
||||
TrustedDomainsTextbox = QtGui.QPlainTextEdit()
|
||||
TrustedDomainsTextbox.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
|
||||
TrustedDomainsTextbox.setPlainText(utils.getListAsMultilineString(self.config["trustedDomains"]))
|
||||
TrustedDomainsLayout.addWidget(TrustedDomainsTextbox, 1, 0, 1, 1)
|
||||
TrustedDomainsButtonBox = QtGui.QDialogButtonBox()
|
||||
TrustedDomainsButtonBox.setOrientation(Qt.Horizontal)
|
||||
TrustedDomainsButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel)
|
||||
TrustedDomainsButtonBox.accepted.connect(TrustedDomainsDialog.accept)
|
||||
TrustedDomainsButtonBox.rejected.connect(TrustedDomainsDialog.reject)
|
||||
TrustedDomainsLayout.addWidget(TrustedDomainsButtonBox, 2, 0, 1, 1)
|
||||
TrustedDomainsDialog.setLayout(TrustedDomainsLayout)
|
||||
TrustedDomainsDialog.setModal(True)
|
||||
TrustedDomainsDialog.show()
|
||||
result = TrustedDomainsDialog.exec_()
|
||||
if result == QtGui.QDialog.Accepted:
|
||||
newTrustedDomains = utils.convertMultilineStringToList(TrustedDomainsTextbox.toPlainText())
|
||||
self._syncplayClient.setTrustedDomains(newTrustedDomains)
|
||||
|
||||
|
||||
@needsClient
|
||||
def openAddMediaDirectoryDialog(self, MediaDirectoriesTextbox, MediaDirectoriesDialog):
|
||||
folderName = unicode(QtGui.QFileDialog.getExistingDirectory(self,None,self.getInitialMediaDirectory(includeUserSpecifiedDirectories=False),QtGui.QFileDialog.ShowDirsOnly))
|
||||
@ -1179,6 +1212,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
window.identifyascontroller = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'key_go.png'),
|
||||
getMessage("identifyascontroller-menu-label"))
|
||||
window.identifyascontroller.triggered.connect(self.identifyAsController)
|
||||
window.setTrustedDomainsAction = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'film_folder_edit.png'),
|
||||
getMessage("settrusteddomains-menu-label"))
|
||||
window.setTrustedDomainsAction.triggered.connect(self.openSetTrustedDomainsDialog)
|
||||
|
||||
window.menuBar.addMenu(window.advancedMenu)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user