Пример #1
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.QtGui = QtGui
     if sys.platform.startswith('linux'):
         self.resourcespath = utils.findWorkingDir() + "/resources/"
     else:
         self.resourcespath = utils.findWorkingDir() + "\\resources\\"
     self.setWindowTitle("Syncplay v" + version)
     self.mainLayout = QtGui.QVBoxLayout()
     self.addTopLayout(self)
     self.addBottomLayout(self)
     self.addMenubar(self)
     self.addMainFrame(self)
     self.loadSettings()
     self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png"))
     self.show()
     self.setAcceptDrops(True)
Пример #2
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.QtGui = QtGui
     if sys.platform.startswith('win'):
         self.resourcespath = utils.findWorkingDir() + "\\resources\\"
     else:
         self.resourcespath = utils.findWorkingDir() + "/resources/"
     self.setWindowTitle("Syncplay v" + version)
     self.mainLayout = QtGui.QVBoxLayout()
     self.addTopLayout(self)
     self.addBottomLayout(self)
     self.addMenubar(self)
     self.addMainFrame(self)
     self.loadSettings()
     self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png"))
     self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & Qt.WindowMinimizeButtonHint & ~Qt.WindowContextHelpButtonHint)
     self.show()
     self.setAcceptDrops(True)
Пример #3
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.QtGui = QtGui
     if sys.platform.startswith('linux'):
         self.resourcespath = utils.findWorkingDir() + "/resources/"
     else:
         self.resourcespath = utils.findWorkingDir() + "\\resources\\"
     self.setWindowTitle("Syncplay v" + version)
     self.mainLayout = QtGui.QVBoxLayout()
     self.addTopLayout(self)
     self.addBottomLayout(self)
     self.addMenubar(self)
     self.addMainFrame(self)
     self.loadSettings()
     self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png"))
     self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint
                         & Qt.WindowMinimizeButtonHint
                         & ~Qt.WindowContextHelpButtonHint)
     self.show()
     self.setAcceptDrops(True)
Пример #4
0
 def __init__(self, playerController, playerPath, filePath, args, vlcReady):
     self.__playerController = playerController
     call = [playerPath]
     if(filePath):
         if (self.__playerController._isASCII(filePath) == True):
             call.append(filePath) #TODO: Proper Unicode support
         else:
             playerController._client.ui.showErrorMessage(getMessage("en", "vlc-unicode-loadfile-error"), True)
     def _usevlcintf(vlcIntfPath):
         vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
         if os.path.isfile(vlcSyncplayInterfacePath):
             with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                 for line in interfacefile:
                     if "local connectorversion" in line:
                         interface_version = line[26:31]
                         if (int(interface_version.replace(".","")) >= int(constants.VLC_INTERFACE_MIN_VERSION.replace(".",""))):
                             return True
                         else:
                             playerController._client.ui.showErrorMessage(getMessage("en", "vlc-interface-oldversion-ignored"))
                             return False
         playerController._client.ui.showErrorMessage(getMessage("en", "vlc-interface-not-installed"))
         return False
     playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\","/") + "/lua/intf/" # TODO: Make Mac version use /Applications/VLC.app/Contents/MacOS/share/lua/intf/
     playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
     if _usevlcintf(playerController.vlcIntfPath) == True:
         playerController.SLAVE_ARGS.append('--lua-config=syncplay={{port=\"{}\"}}'.format(str(playerController.vlcport)))
     else:
         playerController.vlcDataPath = utils.findWorkingDir()+"\\resources"               
         playerController.SLAVE_ARGS.append('--data-path={}'.format(playerController.vlcDataPath))
         playerController.SLAVE_ARGS.append('--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(playerController.vlcModulePath,str(playerController.vlcport)))
     
     call.extend(playerController.SLAVE_ARGS)
     if(args): 
         call.extend(args)
     
     self._vlcready = vlcReady
     self.__process = subprocess.Popen(call, stderr=subprocess.PIPE)
     for line in iter(self.__process.stderr.readline,''):
         if "[syncplay]" in line:
             if "Listening on host" in line:
                 break
             elif "lua interface error" in line:
                 playerController._client.ui.showErrorMessage(getMessage("en", "vlc-error-echo").format(line), True)
                 break
     threading.Thread.__init__(self, name="VLC Listener")
     asynchat.async_chat.__init__(self)
     self.set_terminator("\n")
     self._ibuffer = []
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     self._sendingData = threading.Lock()
Пример #5
0
    def paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex):
        column = indexQModelIndex.column()
        if column == 0:
            currentQAbstractItemModel = indexQModelIndex.model()
            itemQModelIndex = currentQAbstractItemModel.index(indexQModelIndex.row(), 0, indexQModelIndex.parent())
            if sys.platform.startswith('win'):
                resourcespath = utils.findWorkingDir() + "\\resources\\"
            else:
                resourcespath = utils.findWorkingDir() + "/resources/"
            controlIconQPixmap = QtGui.QPixmap(resourcespath + "user_key.png")
            tickIconQPixmap = QtGui.QPixmap(resourcespath + "tick.png")
            crossIconQPixmap = QtGui.QPixmap(resourcespath + "cross.png")
            roomController = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE)
            userReady = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_READY_ROLE)

            if roomController and not controlIconQPixmap.isNull():
                itemQPainter.drawPixmap (
                    optionQStyleOptionViewItem.rect.x()+6,
                    optionQStyleOptionViewItem.rect.y(),
                    controlIconQPixmap.scaled(16, 16, Qt.KeepAspectRatio))

            if userReady and not tickIconQPixmap.isNull():
                itemQPainter.drawPixmap (
                    (optionQStyleOptionViewItem.rect.x()-10),
                    optionQStyleOptionViewItem.rect.y(),
                    tickIconQPixmap.scaled(16, 16, Qt.KeepAspectRatio))

            elif userReady == False and not crossIconQPixmap.isNull():
                itemQPainter.drawPixmap (
                    (optionQStyleOptionViewItem.rect.x()-10),
                    optionQStyleOptionViewItem.rect.y(),
                    crossIconQPixmap.scaled(16, 16, Qt.KeepAspectRatio))
            isUserRow = indexQModelIndex.parent() != indexQModelIndex.parent().parent()
            if isUserRow:
                optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+constants.USERLIST_GUI_USERNAME_OFFSET)
        QtGui.QStyledItemDelegate.paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex)
Пример #6
0
 def _checkForPortableFile(self):
     path = utils.findWorkingDir()
     for name in constants.CONFIG_NAMES:
         if os.path.isfile(os.path.join(path, name)):
             return os.path.join(path, name)
Пример #7
0
    def __init__(self, config, playerpaths, error):
        
        from syncplay import utils
        self.config = config
        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('linux'):
            resourcespath = utils.findWorkingDir() + "/resources/"
        else:
            resourcespath = utils.findWorkingDir() + "\\resources\\"

        super(ConfigDialog, self).__init__()
        
        self.setWindowTitle(getMessage("en", "config-window-title"))
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))
              
        if(config['host'] == None):
            host = ""
        elif(":" in config['host']):
            host = config['host']
        else:
            host = config['host']+":"+str(config['port'])
            
        self.connectionSettingsGroup = QtGui.QGroupBox("Connection Settings")
        self.hostTextbox = QLineEdit(host, self)
        self.hostLabel = QLabel(getMessage("en", "host-label"), self)
        self.usernameTextbox = QLineEdit(config['name'],self)
        self.serverpassLabel = QLabel(getMessage("en", "password-label"), self)
        self.defaultroomTextbox = QLineEdit(config['room'],self)
        self.usernameLabel = QLabel(getMessage("en", "username-label"), self)
        self.serverpassTextbox = QLineEdit(config['password'],self)
        self.defaultroomLabel = QLabel(getMessage("en", "room-label"), self)
        self.connectionSettingsLayout = QtGui.QGridLayout()
        self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
        self.connectionSettingsLayout.addWidget(self.hostTextbox, 0, 1)
        self.connectionSettingsLayout.addWidget(self.serverpassLabel, 1, 0)
        self.connectionSettingsLayout.addWidget(self.serverpassTextbox, 1, 1)
        self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
        self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
        self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
        self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1)
        self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)
        
        self.mediaplayerSettingsGroup = QtGui.QGroupBox("Media Player Settings")
        self.executablepathCombobox = QtGui.QComboBox(self)
        self.executablepathCombobox.setEditable(True)
        self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'],playerpaths))
        self.executablepathCombobox.setMinimumWidth(200)
        self.executablepathCombobox.setMaximumWidth(200)
        self.executablepathLabel = QLabel("Path to player executable:", self)
        self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),"Browse")
        self.executablebrowseButton.clicked.connect(self.browsePlayerpath)
        self.mediapathTextbox = QLineEdit(config['file'], self)
        self.mediapathLabel = QLabel("Path to media file:", self)
        self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),"Browse")
        self.mediabrowseButton.clicked.connect(self.browseMediapath)
        self.slowdownCheckbox = QCheckBox("Slow down on desync")
        self.mediaplayerSettingsLayout = QtGui.QGridLayout()
        self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
        self.mediaplayerSettingsLayout.addWidget(self.executablepathCombobox , 0, 1)
        self.mediaplayerSettingsLayout.addWidget(self.executablebrowseButton , 0, 2)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 1)
        self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 2)
        self.mediaplayerSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0)
        self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)
        if config['slowOnDesync'] == True:
            self.slowdownCheckbox.setChecked(True)

        self.malSettingsGroup = QtGui.QGroupBox("Enable MyAnimeList Updater (EXPERIMENTAL)")
        self.malSettingsGroup.setCheckable(True)
        self.malSettingsGroup.toggled.connect(self.malToggled)
        self.malSettingsSplit = QtGui.QSplitter(self)
        self.malusernameTextbox = QLineEdit(config['malUsername'],self)
        self.malusernameLabel = QLabel("MAL Username:"******"MAL Password:"******"Enable MyAnimeList Updater (EXPERIMENTAL)")
        self.malenabledCheckbox.toggled.connect(self.malToggled) 
        if config['malPassword'] == None or config['malPassword'] == "":
            self.malenabledCheckbox.setChecked(False)
            self.malSettingsGroup.hide()
        else:
            self.malenabledCheckbox.hide()
        
        self.alwaysshowCheckbox = QCheckBox("Always Show This Dialog")
        if config['forceGuiPrompt'] == True:
            self.alwaysshowCheckbox.setChecked(True)
        
        self.donotstoreCheckbox = QCheckBox("Do Not Store This Configuration")       
        self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate)
                      
        self.mainLayout = QtGui.QVBoxLayout()
        if error:
            self.errorLabel = QLabel(error, self)
            self.errorLabel.setAlignment(Qt.AlignCenter)
            self.errorLabel.setStyleSheet("QLabel { color : red; }")
            self.mainLayout.addWidget(self.errorLabel)
        self.mainLayout.addWidget(self.connectionSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.mediaplayerSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.malenabledCheckbox)
        self.mainLayout.addWidget(self.malSettingsGroup)
        
        self.topLayout = QtGui.QHBoxLayout()
        self.helpButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'help.png'),"Help")
        self.helpButton.setMaximumSize(self.helpButton.sizeHint())
        self.helpButton.pressed.connect(self.openHelp)
        self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'),"Store configuration and run Syncplay")
        self.runButton.pressed.connect(self._saveDataAndLeave)
        if config['noStore'] == True:
            self.donotstoreCheckbox.setChecked(True)
            self.runButton.setText("Run Syncplay")
        self.topLayout.addWidget(self.helpButton, Qt.AlignLeft)
        self.topLayout.addWidget(self.runButton, Qt.AlignRight)
        self.mainLayout.addWidget(self.alwaysshowCheckbox)
        self.mainLayout.addWidget(self.donotstoreCheckbox)
        self.mainLayout.addLayout(self.topLayout)
        
        self.mainLayout.addStretch(1)
        self.setLayout(self.mainLayout)
        self.runButton.setFocus()        
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)
Пример #8
0
        def __init__(self, playerController, playerPath, filePath, args,
                     vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))

            def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
                vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if utils.meetsMinVersion(
                                        interface_version,
                                        constants.VLC_INTERFACE_MIN_VERSION):
                                    return True
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    return False
                playerController._client.ui.showErrorMessage(
                    getMessage("vlc-interface-not-installed"))
                return False

            if sys.platform.startswith('linux'):
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif sys.platform.startswith('darwin'):
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'),
                    "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif 'bsd' in sys.platform or sys.platform.startswith('dragonfly'):
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            if _usevlcintf(playerController.vlcIntfPath,
                           playerController.vlcIntfUserPath):
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{port=\"{}\"}}'.format(
                        str(playerController.vlcport)))
            else:
                if sys.platform.startswith('linux'):
                    playerController.vlcDataPath = "/usr/lib/syncplay/resources"
                else:
                    playerController.vlcDataPath = utils.findWorkingDir(
                    ) + "\\resources"
                playerController.SLAVE_ARGS.append('--data-path={}'.format(
                    playerController.vlcDataPath))
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.
                    format(playerController.vlcModulePath,
                           str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if self.oldIntfVersion:
                self.__playerController.drop(
                    getMessage("vlc-interface-version-mismatch").format(
                        self.oldIntfVersion,
                        constants.VLC_INTERFACE_MIN_VERSION))

            else:
                self.__process = subprocess.Popen(call,
                                                  stderr=subprocess.PIPE,
                                                  stdout=subprocess.PIPE)
                self.timeVLCLaunched = time.time()
                if self._shouldListenForSTDOUT():
                    for line in iter(self.__process.stderr.readline, ''):
                        self.vlcHasResponded = True
                        self.timeVLCLaunched = None
                        if "[syncplay]" in line:
                            if "Listening on host" in line:
                                break
                            if "Hosting Syncplay" in line:
                                break
                            elif "Couldn't find lua interface" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("vlc-failed-noscript").format(
                                        line), True)
                                break
                            elif "lua interface error" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("media-player-error").format(
                                        line), True)
                                break
                if not sys.platform.startswith('darwin'):
                    self.__process.stderr = None
                else:
                    vlcoutputthread = threading.Thread(
                        target=self.handle_vlcoutput, args=())
                    vlcoutputthread.setDaemon(True)
                    vlcoutputthread.start()
                threading.Thread.__init__(self, name="VLC Listener")
                asynchat.async_chat.__init__(self)
                self.set_terminator("\n")
                self._ibuffer = []
                self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
                self._sendingData = threading.Lock()
Пример #9
0
 def _checkForPortableFile(self):
     path = utils.findWorkingDir()
     for name in constants.CONFIG_NAMES:
         if os.path.isfile(os.path.join(path, name)):
             return os.path.join(path, name)
Пример #10
0
    def __init__(self, config, playerpaths, error):

        from syncplay import utils
        self.config = config
        self.datacleared = False
        if config['clearGUIData'] == True:
            settings = QSettings("Syncplay", "PlayerList")
            settings.clear()
            settings = QSettings("Syncplay", "MediaBrowseDialog")
            settings.clear()
            settings = QSettings("Syncplay", "MainWindow")
            settings.clear()
            settings = QSettings("Syncplay", "MoreSettings")
            settings.clear()
            self.datacleared = True
        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('linux'):
            resourcespath = utils.findWorkingDir() + "/resources/"
        else:
            resourcespath = utils.findWorkingDir() + "\\resources\\"
        self.resourcespath = resourcespath

        super(ConfigDialog, self).__init__()

        self.setWindowTitle(getMessage("en", "config-window-title"))
        self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))

        if(config['host'] == None):
            host = ""
        elif(":" in config['host']):
            host = config['host']
        else:
            host = config['host'] + ":" + str(config['port'])

        self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("en", "connection-group-title"))
        self.hostTextbox = QLineEdit(host, self)
        self.hostLabel = QLabel(getMessage("en", "host-label"), self)
        self.usernameTextbox = QLineEdit(config['name'], self)
        self.serverpassLabel = QLabel(getMessage("en", "password-label"), self)
        self.defaultroomTextbox = QLineEdit(config['room'], self)
        self.usernameLabel = QLabel(getMessage("en", "username-label"), self)
        self.serverpassTextbox = QLineEdit(config['password'], self)
        self.defaultroomLabel = QLabel(getMessage("en", "room-label"), self)

        if (constants.SHOW_TOOLTIPS == True):
            self.hostLabel.setToolTip(getMessage("en", "host-tooltip"))
            self.hostTextbox.setToolTip(getMessage("en", "host-tooltip"))
            self.usernameLabel.setToolTip(getMessage("en", "username-tooltip"))
            self.usernameTextbox.setToolTip(getMessage("en", "username-tooltip"))
            self.serverpassLabel.setToolTip(getMessage("en", "password-tooltip"))
            self.serverpassTextbox.setToolTip(getMessage("en", "password-tooltip"))
            self.defaultroomLabel.setToolTip(getMessage("en", "room-tooltip"))
            self.defaultroomTextbox.setToolTip(getMessage("en", "room-tooltip"))

        self.connectionSettingsLayout = QtGui.QGridLayout()
        self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
        self.connectionSettingsLayout.addWidget(self.hostTextbox, 0, 1)
        self.connectionSettingsLayout.addWidget(self.serverpassLabel, 1, 0)
        self.connectionSettingsLayout.addWidget(self.serverpassTextbox, 1, 1)
        self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
        self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
        self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
        self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1)
        self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)

        self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("en", "media-setting-title"))
        self.executableiconImage = QtGui.QImage()
        self.executableiconLabel = QLabel(self)
        self.executableiconLabel.setMinimumWidth(16)
        self.executablepathCombobox = QtGui.QComboBox(self)
        self.executablepathCombobox.setEditable(True)
        self.executablepathCombobox.currentIndexChanged.connect(self.updateExecutableIcon)
        self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'], playerpaths))
        self.executablepathCombobox.setMinimumWidth(200)
        self.executablepathCombobox.setMaximumWidth(200)
        self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon)

        self.executablepathLabel = QLabel(getMessage("en", "executable-path-label"), self)
        self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("en", "browse-label"))
        self.executablebrowseButton.clicked.connect(self.browsePlayerpath)
        self.mediapathTextbox = QLineEdit(config['file'], self)
        self.mediapathLabel = QLabel(getMessage("en", "media-path-label"), self)
        self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("en", "browse-label"))
        self.mediabrowseButton.clicked.connect(self.browseMediapath)

        if (constants.SHOW_TOOLTIPS == True):
            self.executablepathLabel.setToolTip(getMessage("en", "executable-path-tooltip"))
            self.executablepathCombobox.setToolTip(getMessage("en", "executable-path-tooltip"))
            self.mediapathLabel.setToolTip(getMessage("en", "media-path-tooltip"))
            self.mediapathTextbox.setToolTip(getMessage("en", "media-path-tooltip"))

        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True:
            self.rewindCheckbox = QCheckBox(getMessage("en", "rewind-label"))
            if (constants.SHOW_TOOLTIPS == True):
                self.rewindCheckbox.setToolTip(getMessage("en", "rewind-tooltip"))
        self.mediaplayerSettingsLayout = QtGui.QGridLayout()
        self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
        self.mediaplayerSettingsLayout.addWidget(self.executableiconLabel, 0, 1)
        self.mediaplayerSettingsLayout.addWidget(self.executablepathCombobox, 0, 2)
        self.mediaplayerSettingsLayout.addWidget(self.executablebrowseButton, 0, 3)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2)
        self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3)
        self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)

        self.moreSettingsGroup = QtGui.QGroupBox(getMessage("en", "more-title"))

        self.moreSettingsGroup.setCheckable(True)

        self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self)
        self.filenameprivacyButtonGroup = QButtonGroup()
        self.filenameprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option"))
        self.filenameprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option"))
        self.filenameprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option"))
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption)

        self.filesizeprivacyLabel = QLabel(getMessage("en", "filesize-privacy-label"), self)
        self.filesizeprivacyButtonGroup = QButtonGroup()
        self.filesizeprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option"))
        self.filesizeprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option"))
        self.filesizeprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option"))
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption)

        self.slowdownCheckbox = QCheckBox(getMessage("en", "slowdown-label"))
        self.dontslowwithmeCheckbox = QCheckBox(getMessage("en", "dontslowwithme-label"))
        self.pauseonleaveCheckbox = QCheckBox(getMessage("en", "pauseonleave-label"))
        self.alwaysshowCheckbox = QCheckBox(getMessage("en", "alwayshow-label"))
        self.donotstoreCheckbox = QCheckBox(getMessage("en", "donotstore-label"))

        filenamePrivacyMode = config['filenamePrivacyMode']
        if filenamePrivacyMode == constants.PRIVACY_DONTSEND_MODE:
            self.filenameprivacyDontSendOption.setChecked(True)
        elif filenamePrivacyMode == constants.PRIVACY_SENDHASHED_MODE:
            self.filenameprivacySendHashedOption.setChecked(True)
        else:
            self.filenameprivacySendRawOption.setChecked(True)

        filesizePrivacyMode = config['filesizePrivacyMode']
        if filesizePrivacyMode == constants.PRIVACY_DONTSEND_MODE:
            self.filesizeprivacyDontSendOption.setChecked(True)
        elif filesizePrivacyMode == constants.PRIVACY_SENDHASHED_MODE:
            self.filesizeprivacySendHashedOption.setChecked(True)
        else:
            self.filesizeprivacySendRawOption.setChecked(True)

        if config['slowOnDesync'] == True:
            self.slowdownCheckbox.setChecked(True)
        if config['dontSlowDownWithMe'] == True:
            self.dontslowwithmeCheckbox.setChecked(True)

        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True and config['rewindOnDesync'] == True:
            self.rewindCheckbox.setChecked(True)
        if config['pauseOnLeave'] == True:
            self.pauseonleaveCheckbox.setChecked(True)

        if (constants.SHOW_TOOLTIPS == True):
            self.filenameprivacyLabel.setToolTip(getMessage("en", "filename-privacy-tooltip"))
            self.filenameprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip"))
            self.filenameprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip"))
            self.filenameprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip"))
            self.filesizeprivacyLabel.setToolTip(getMessage("en", "filesize-privacy-tooltip"))
            self.filesizeprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip"))
            self.filesizeprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip"))
            self.filesizeprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip"))

            self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip"))
            self.dontslowwithmeCheckbox.setToolTip(getMessage("en", "dontslowwithme-tooltip"))
            self.pauseonleaveCheckbox.setToolTip(getMessage("en", "pauseonleave-tooltip"))
            self.alwaysshowCheckbox.setToolTip(getMessage("en", "alwayshow-tooltip"))
            self.donotstoreCheckbox.setToolTip(getMessage("en", "donotstore-tooltip"))
            self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip"))

        self.moreSettingsLayout = QtGui.QGridLayout()

        self.privacySettingsLayout = QtGui.QGridLayout()
        self.privacyFrame = QtGui.QFrame()
        self.privacyFrame.setLineWidth(0)
        self.privacyFrame.setMidLineWidth(0)
        self.privacySettingsLayout.setContentsMargins(0, 0, 0, 0)
        self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 0, 0)
        self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 0, 1, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 0, 2, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 0, 3, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 1, 0)
        self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 1, 1, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 1, 2, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 1, 3, Qt.AlignRight)
        self.privacyFrame.setLayout(self.privacySettingsLayout)

        self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4)

        self.moreSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.dontslowwithmeCheckbox, 3, 0, 1, 4)
        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True:
            self.moreSettingsLayout.addWidget(self.rewindCheckbox, 4, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.pauseonleaveCheckbox, 5, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.alwaysshowCheckbox, 6, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.donotstoreCheckbox, 7, 0, 1, 4)

        self.moreSettingsGroup.setLayout(self.moreSettingsLayout)

        self.showmoreCheckbox = QCheckBox(getMessage("en", "more-title"))

        if self.getMoreState() == False:
            self.showmoreCheckbox.setChecked(False)
            self.moreSettingsGroup.hide()
        else:
            self.showmoreCheckbox.hide()
        self.showmoreCheckbox.toggled.connect(self.moreToggled)
        self.moreSettingsGroup.toggled.connect(self.moreToggled)

        if config['forceGuiPrompt'] == True:
            self.alwaysshowCheckbox.setChecked(True)

        if (constants.SHOW_TOOLTIPS == True):
            self.showmoreCheckbox.setToolTip(getMessage("en", "more-tooltip"))

        self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate)

        self.mainLayout = QtGui.QVBoxLayout()
        if error:
            self.errorLabel = QLabel(error, self)
            self.errorLabel.setAlignment(Qt.AlignCenter)
            self.errorLabel.setStyleSheet("QLabel { color : red; }")
            self.mainLayout.addWidget(self.errorLabel)
        self.mainLayout.addWidget(self.connectionSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.mediaplayerSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.showmoreCheckbox)
        self.mainLayout.addWidget(self.moreSettingsGroup)
        self.mainLayout.addSpacing(12)

        self.topLayout = QtGui.QHBoxLayout()
        self.helpButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'help.png'), getMessage("en", "help-label"))
        if (constants.SHOW_TOOLTIPS == True):
            self.helpButton.setToolTip(getMessage("en", "help-tooltip"))
        self.helpButton.setMaximumSize(self.helpButton.sizeHint())
        self.helpButton.pressed.connect(self.openHelp)
        self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("en", "storeandrun-label"))
        self.runButton.pressed.connect(self._saveDataAndLeave)
        if config['noStore'] == True:
            self.donotstoreCheckbox.setChecked(True)
            self.runButton.setText(getMessage("en", "run-label"))
        self.topLayout.addWidget(self.helpButton, Qt.AlignLeft)
        self.topLayout.addWidget(self.runButton, Qt.AlignRight)
        self.mainLayout.addLayout(self.topLayout)

        self.mainLayout.addStretch(1)
        self.setLayout(self.mainLayout)
        self.runButton.setFocus()
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)

        if self.datacleared == True:
            QtGui.QMessageBox.information(self, "Syncplay", getMessage("en", "gui-data-cleared-notification"))
Пример #11
0
    def __init__(self, config, playerpaths, error):
        
        from syncplay import utils
        self.config = config
        self.datacleared = False
        if config['clearGUIData'] == True:
            settings = QSettings("Syncplay","PlayerList")
            settings.clear()
            settings = QSettings("Syncplay","MediaBrowseDialog")
            settings.clear()
            settings = QSettings("Syncplay","MainWindow")
            settings.clear()
            settings = QSettings("Syncplay","MoreSettings")
            settings.clear()
            self.datacleared = True
        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('linux'):
            resourcespath = utils.findWorkingDir() + "/resources/"
        else:
            resourcespath = utils.findWorkingDir() + "\\resources\\"
        self.resourcespath = resourcespath

        super(ConfigDialog, self).__init__()
        
        self.setWindowTitle(getMessage("en", "config-window-title"))
        self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))
              
        if(config['host'] == None):
            host = ""
        elif(":" in config['host']):
            host = config['host']
        else:
            host = config['host']+":"+str(config['port'])
            
        self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("en", "connection-group-title"))
        self.hostTextbox = QLineEdit(host, self)
        self.hostLabel = QLabel(getMessage("en", "host-label"), self)
        self.usernameTextbox = QLineEdit(config['name'],self)
        self.serverpassLabel = QLabel(getMessage("en", "password-label"), self)
        self.defaultroomTextbox = QLineEdit(config['room'],self)
        self.usernameLabel = QLabel(getMessage("en", "username-label"), self)
        self.serverpassTextbox = QLineEdit(config['password'],self)
        self.defaultroomLabel = QLabel(getMessage("en", "room-label"), self)

        if (constants.SHOW_TOOLTIPS == True):
            self.hostLabel.setToolTip(getMessage("en", "host-tooltip"))
            self.hostTextbox.setToolTip(getMessage("en", "host-tooltip"))
            self.usernameLabel.setToolTip(getMessage("en", "username-tooltip"))
            self.usernameTextbox.setToolTip(getMessage("en", "username-tooltip"))
            self.serverpassLabel.setToolTip(getMessage("en", "password-tooltip"))
            self.serverpassTextbox.setToolTip(getMessage("en", "password-tooltip"))
            self.defaultroomLabel.setToolTip(getMessage("en", "room-tooltip"))
            self.defaultroomTextbox.setToolTip(getMessage("en", "room-tooltip"))
            
        self.connectionSettingsLayout = QtGui.QGridLayout()
        self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
        self.connectionSettingsLayout.addWidget(self.hostTextbox, 0, 1)
        self.connectionSettingsLayout.addWidget(self.serverpassLabel, 1, 0)
        self.connectionSettingsLayout.addWidget(self.serverpassTextbox, 1, 1)
        self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
        self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
        self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
        self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1)
        self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)
        
        self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("en", "media-setting-title"))
        self.executableiconImage = QtGui.QImage()
        self.executableiconLabel = QLabel(self)
        self.executableiconLabel.setMinimumWidth(16)
        self.executablepathCombobox = QtGui.QComboBox(self)
        self.executablepathCombobox.setEditable(True)
        self.executablepathCombobox.currentIndexChanged.connect(self.updateExecutableIcon)
        self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'], playerpaths))
        self.executablepathCombobox.setMinimumWidth(200)
        self.executablepathCombobox.setMaximumWidth(200)
        self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon)
        
        self.executablepathLabel = QLabel(getMessage("en", "executable-path-label"), self)
        self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),getMessage("en", "browse-label"))
        self.executablebrowseButton.clicked.connect(self.browsePlayerpath)
        self.mediapathTextbox = QLineEdit(config['file'], self)
        self.mediapathLabel = QLabel(getMessage("en", "media-path-label"), self)
        self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),getMessage("en", "browse-label"))
        self.mediabrowseButton.clicked.connect(self.browseMediapath)
        
        if (constants.SHOW_TOOLTIPS == True):
            self.executablepathLabel.setToolTip(getMessage("en", "executable-path-tooltip"))
            self.executablepathCombobox.setToolTip(getMessage("en", "executable-path-tooltip"))
            self.mediapathLabel.setToolTip(getMessage("en", "media-path-tooltip"))
            self.mediapathTextbox.setToolTip(getMessage("en", "media-path-tooltip"))
        
        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True:
            self.rewindCheckbox = QCheckBox(getMessage("en", "rewind-label"))
            if (constants.SHOW_TOOLTIPS == True):
                self.rewindCheckbox.setToolTip(getMessage("en", "rewind-tooltip"))
        self.mediaplayerSettingsLayout = QtGui.QGridLayout()
        self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
        self.mediaplayerSettingsLayout.addWidget(self.executableiconLabel, 0, 1)
        self.mediaplayerSettingsLayout.addWidget(self.executablepathCombobox, 0, 2)
        self.mediaplayerSettingsLayout.addWidget(self.executablebrowseButton, 0, 3)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2)
        self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3)
        self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)

        self.moreSettingsGroup = QtGui.QGroupBox(getMessage("en", "more-title"))

        self.moreSettingsGroup.setCheckable(True)
        self.malSettingsSplit = QtGui.QSplitter(self)
        self.malusernameTextbox = QLineEdit(config['malUsername'],self)
        self.malusernameTextbox.setMaximumWidth(115)
        self.malusernameLabel = QLabel(getMessage("en", "mal-username-label"), self)
        
        self.malpasswordTextbox = QLineEdit(config['malPassword'],self)
        self.malpasswordTextbox.setEchoMode(QtGui.QLineEdit.Password)
        self.malpasswordLabel = QLabel(getMessage("en", "mal-password-label"), self)
        
        ### <MAL DISABLE>
        self.malpasswordTextbox.hide()
        self.malpasswordLabel.hide()
        self.malusernameTextbox.hide()
        self.malusernameLabel.hide()
        ### </MAL DISABLE>
        
        self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self)
        self.filenameprivacyButtonGroup = QButtonGroup()
        self.filenameprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option"))
        self.filenameprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option"))
        self.filenameprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option"))
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption)
        
        self.filesizeprivacyLabel = QLabel(getMessage("en", "filesize-privacy-label"), self)
        self.filesizeprivacyButtonGroup = QButtonGroup()
        self.filesizeprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option"))
        self.filesizeprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option"))
        self.filesizeprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option"))
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption)
        
        self.slowdownCheckbox = QCheckBox(getMessage("en", "slowdown-label"))
        self.pauseonleaveCheckbox = QCheckBox(getMessage("en", "pauseonleave-label"))
        self.alwaysshowCheckbox = QCheckBox(getMessage("en", "alwayshow-label"))
        self.donotstoreCheckbox = QCheckBox(getMessage("en", "donotstore-label"))
        
        filenamePrivacyMode = config['filenamePrivacyMode']
        if filenamePrivacyMode == constants.PRIVACY_DONTSEND_MODE:
            self.filenameprivacyDontSendOption.setChecked(True)
        elif filenamePrivacyMode == constants.PRIVACY_SENDHASHED_MODE:
            self.filenameprivacySendHashedOption.setChecked(True)
        else:
            self.filenameprivacySendRawOption.setChecked(True)
            
        filesizePrivacyMode = config['filesizePrivacyMode']
        if filesizePrivacyMode == constants.PRIVACY_DONTSEND_MODE:
            self.filesizeprivacyDontSendOption.setChecked(True)
        elif filesizePrivacyMode == constants.PRIVACY_SENDHASHED_MODE:
            self.filesizeprivacySendHashedOption.setChecked(True)
        else:
            self.filesizeprivacySendRawOption.setChecked(True)
        
        if config['slowOnDesync'] == True:
            self.slowdownCheckbox.setChecked(True)
        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True and config['rewindOnDesync'] == True:
            self.rewindCheckbox.setChecked(True)
        if config['pauseOnLeave'] == True:
            self.pauseonleaveCheckbox.setChecked(True)
        
        if (constants.SHOW_TOOLTIPS == True):
            self.malusernameLabel.setToolTip(getMessage("en", "mal-username-tooltip"))
            self.malusernameTextbox.setToolTip(getMessage("en", "mal-username-tooltip"))
            self.malpasswordLabel.setToolTip(getMessage("en", "mal-password-tooltip"))
            self.malpasswordTextbox.setToolTip(getMessage("en", "mal-password-tooltip"))
            
            self.filenameprivacyLabel.setToolTip(getMessage("en", "filename-privacy-tooltip"))
            self.filenameprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip"))
            self.filenameprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip"))
            self.filenameprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip"))
            self.filesizeprivacyLabel.setToolTip(getMessage("en", "filesize-privacy-tooltip"))
            self.filesizeprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip"))
            self.filesizeprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip"))
            self.filesizeprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip"))
            
            self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip"))
            self.pauseonleaveCheckbox.setToolTip(getMessage("en", "pauseonleave-tooltip"))
            self.alwaysshowCheckbox.setToolTip(getMessage("en", "alwayshow-tooltip"))
            self.donotstoreCheckbox.setToolTip(getMessage("en", "donotstore-tooltip"))
            self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip"))
            
        self.moreSettingsLayout = QtGui.QGridLayout()
        
        self.privacySettingsLayout = QtGui.QGridLayout()
        self.privacyFrame = QtGui.QFrame()
        self.privacyFrame.setLineWidth(0)
        self.privacyFrame.setMidLineWidth(0)
        self.privacySettingsLayout.setContentsMargins(0,0,0,0)
        self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 0, 0)
        self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 0, 1, Qt.AlignRight) 
        self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 0,2, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 0, 3, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 1, 0)
        self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 1, 1, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 1, 2, Qt.AlignRight)
        self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 1, 3, Qt.AlignRight)
        self.privacyFrame.setLayout(self.privacySettingsLayout)
        
        self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4)

        self.moreSettingsLayout.addWidget(self.malusernameLabel , 1, 0)
        self.moreSettingsLayout.addWidget(self.malusernameTextbox, 1, 1)
        self.moreSettingsLayout.addWidget(self.malpasswordLabel , 1, 2)
        self.moreSettingsLayout.addWidget(self.malpasswordTextbox, 1, 3)

        self.moreSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0,1,4)
        if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True:
            self.moreSettingsLayout.addWidget(self.rewindCheckbox, 3, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.pauseonleaveCheckbox, 4, 0, 1, 4)      
        self.moreSettingsLayout.addWidget(self.alwaysshowCheckbox, 5, 0, 1, 4)
        self.moreSettingsLayout.addWidget(self.donotstoreCheckbox, 6, 0, 1, 4)

        self.moreSettingsGroup.setLayout(self.moreSettingsLayout)
        
        self.showmoreCheckbox = QCheckBox(getMessage("en", "more-title"))
        
        if self.getMoreState() == False:
            self.showmoreCheckbox.setChecked(False)
            self.moreSettingsGroup.hide()
        else:
            self.showmoreCheckbox.hide()
        self.showmoreCheckbox.toggled.connect(self.moreToggled)            
        self.moreSettingsGroup.toggled.connect(self.moreToggled)
        
        if config['forceGuiPrompt'] == True:
            self.alwaysshowCheckbox.setChecked(True)
        
        if (constants.SHOW_TOOLTIPS == True):
            self.showmoreCheckbox.setToolTip(getMessage("en", "more-tooltip"))
               
        self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate)
                      
        self.mainLayout = QtGui.QVBoxLayout()
        if error:
            self.errorLabel = QLabel(error, self)
            self.errorLabel.setAlignment(Qt.AlignCenter)
            self.errorLabel.setStyleSheet("QLabel { color : red; }")
            self.mainLayout.addWidget(self.errorLabel)
        self.mainLayout.addWidget(self.connectionSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.mediaplayerSettingsGroup)
        self.mainLayout.addSpacing(12)
        self.mainLayout.addWidget(self.showmoreCheckbox)
        self.mainLayout.addWidget(self.moreSettingsGroup)
        self.mainLayout.addSpacing(12)
        
        self.topLayout = QtGui.QHBoxLayout()
        self.helpButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'help.png'),getMessage("en", "help-label"))
        if (constants.SHOW_TOOLTIPS == True):
            self.helpButton.setToolTip(getMessage("en", "help-tooltip"))
        self.helpButton.setMaximumSize(self.helpButton.sizeHint())
        self.helpButton.pressed.connect(self.openHelp)
        self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'),getMessage("en", "storeandrun-label"))
        self.runButton.pressed.connect(self._saveDataAndLeave)
        if config['noStore'] == True:
            self.donotstoreCheckbox.setChecked(True)
            self.runButton.setText(getMessage("en", "run-label"))
        self.topLayout.addWidget(self.helpButton, Qt.AlignLeft)
        self.topLayout.addWidget(self.runButton, Qt.AlignRight)
        self.mainLayout.addLayout(self.topLayout)
        
        self.mainLayout.addStretch(1)
        self.setLayout(self.mainLayout)
        self.runButton.setFocus()        
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)
        
        if self.datacleared == True:
            QtGui.QMessageBox.information(self,"Syncplay", getMessage("en", "gui-data-cleared-notification"))
Пример #12
0
    def __init__(self, config, playerpaths, error, defaultConfig):

        from syncplay import utils
        self.config = config
        self.defaultConfig = defaultConfig
        self.playerpaths = playerpaths
        self.datacleared = False
        self.config['resetConfig'] = False
        self.subitems = {}

        if self.config['clearGUIData'] == True:
            self.config['clearGUIData'] = False
            self.clearGUIData()

        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('win'):
            resourcespath = utils.findWorkingDir() + "\\resources\\"
        else:
            resourcespath = utils.findWorkingDir() + "/resources/"
        self.posixresourcespath = utils.findWorkingDir().replace("\\","/") + "/resources/"
        self.resourcespath = resourcespath

        super(ConfigDialog, self).__init__()

        self.setWindowTitle(getMessage("config-window-title"))
        self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))

        self.stackedLayout = QtGui.QStackedLayout()
        self.stackedFrame = QtGui.QFrame()
        self.stackedFrame.setLayout(self.stackedLayout)

        self.mainLayout = QtGui.QGridLayout()
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0,0,0,0)

        self.addBasicTab()
        self.addSyncTab()
        self.addMessageTab()
        self.addPrivacyTab()
        self.tabList()

        self.mainLayout.addWidget(self.stackedFrame, 0, 1)
        self.addBottomLayout()


        if self.getMoreState() == False:
            self.tabListFrame.hide()
            self.nostoreCheckbox.hide()
            self.alwaysshowCheckbox.hide()
            self.resetButton.hide()
        else:
            self.showmoreCheckbox.setChecked(True)
            self.tabListWidget.setCurrentRow(0)

        self.showmoreCheckbox.toggled.connect(self.moreToggled)

        self.setLayout(self.mainLayout)
        self.runButton.setFocus()
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)

        if constants.SHOW_TOOLTIPS:
            self.processWidget(self, lambda w: self.loadTooltips(w))
        self.processWidget(self, lambda w: self.loadValues(w))
        self.processWidget(self, lambda w: self.connectChildren(w))
Пример #13
0
        def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed):
            self.__playerController = playerController
            call = [playerPath]
            if filePath:
                if self.__playerController._isASCII(filePath) == True:
                    call.append(filePath)  # TODO: Proper Unicode support
                else:
                    playerController._client.ui.showErrorMessage(getMessage("en", "vlc-unicode-loadfile-error"), True)

            def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
                vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, "rU") as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if int(interface_version.replace(".", "")) >= int(
                                    constants.VLC_INTERFACE_MIN_VERSION.replace(".", "")
                                ):
                                    return True
                                else:
                                    playerController._client.ui.showErrorMessage(
                                        getMessage("en", "vlc-interface-oldversion-ignored")
                                    )
                                    return False
                playerController._client.ui.showErrorMessage(getMessage("en", "vlc-interface-not-installed"))
                return False

            if sys.platform.startswith("linux"):
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv("HOME", "."), ".local/share/vlc/lua/intf/")
            elif sys.platform.startswith("darwin"):
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv("HOME", "."), "Library/Application Support/org.videolan.vlc/lua/intf/"
                )
            else:
                playerController.vlcIntfPath = (
                    os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                )  # TODO: Make Mac version use /Applications/VLC.app/Contents/MacOS/share/lua/intf/
                playerController.vlcIntfUserPath = os.path.join(os.getenv("APPDATA", "."), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            if _usevlcintf(playerController.vlcIntfPath, playerController.vlcIntfUserPath) == True:
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{port="{}"}}'.format(str(playerController.vlcport))
                )
            else:
                if sys.platform.startswith("linux"):
                    playerController.vlcDataPath = "/usr/lib/syncplay/resources"
                else:
                    playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
                playerController.SLAVE_ARGS.append("--data-path={}".format(playerController.vlcDataPath))
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{modulepath="{}",port="{}"}}'.format(
                        playerController.vlcModulePath, str(playerController.vlcport)
                    )
                )

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self.__process = subprocess.Popen(call, stderr=subprocess.PIPE)
            for line in iter(self.__process.stderr.readline, ""):
                if "[syncplay]" in line:
                    if "Listening on host" in line:
                        break
                    if "Hosting Syncplay" in line:
                        break
                    elif "Couldn't find lua interface" in line:
                        playerController._client.ui.showErrorMessage(
                            getMessage("en", "vlc-failed-noscript").format(line), True
                        )
                        break
                    elif "lua interface error" in line:
                        playerController._client.ui.showErrorMessage(
                            getMessage("en", "vlc-error-echo").format(line), True
                        )
                        break
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator("\n")
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()
Пример #14
0
        def __init__(self, playerController, playerPath, filePath, args, reactor):
            self.__playerController = playerController
            self.reactor = reactor
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None

            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                if 'snap' in playerPath:
                    self.__playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/'
                    self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "snap/vlc/current/.local/share/vlc/lua/intf/")
                else:
                    self.__playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                    self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                self.__playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                self.__playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif "vlcportable.exe" in playerPath.lower():
                self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/App/vlc/lua/intf/"
                self.__playerController.vlcIntfUserPath = playerController.vlcIntfPath
            else:
                self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            self.__playerController.vlcModulePath = self.__playerController.vlcIntfPath + "modules/?.luac"
            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage("Found syncplay.lua intf directory:'{}'".format(vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua intf directory not found, so creating directory '{}'".format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755, parents=True, exist_ok=True)
            try:
                _createIntfFolder(self.__playerController.vlcIntfUserPath)
                copyForm = utils.findResourcePath("syncplay.lua")
                copyTo = os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua")
                self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo))
                import shutil
                if os.path.exists(copyTo):
                    os.chmod(copyTo, 0o755)
                shutil.copyfile(copyForm, copyTo)
                os.chmod(copyTo, 0o755)
            except Exception as e:
                self.__playerController._client.ui.showErrorMessage(e)
                return
            if isLinux():
                self.__playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                self.__playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
            self.__playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(
                    self.__playerController.vlcModulePath, str(self.__playerController.vlcport)))

            call.extend(self.__playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(
                    call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
                    shell=False, creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            self.__playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line), True)
                            break
                        elif "lua interface error" in line:
                            self.__playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line), True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            self.__playerController._vlcready.clear()
            self._factory = VLCClientFactory(self.__playerController, self.vlcHasResponded, self.timeVLCLaunched, self.__process)
            self.reactor.connectTCP('localhost', self.__playerController.vlcport, self._factory)
Пример #15
0
        def __init__(self, playerController, playerPath, filePath, args,
                     vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                if 'snap' in playerPath:
                    playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/'
                    playerController.vlcIntfUserPath = os.path.join(
                        os.getenv('HOME', '.'),
                        "snap/vlc/current/.local/share/vlc/lua/intf/")
                else:
                    playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                    playerController.vlcIntfUserPath = os.path.join(
                        os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'),
                    "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif "vlcportable.exe" in playerPath.lower():
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/App/vlc/lua/intf/"
                playerController.vlcIntfUserPath = playerController.vlcIntfPath
            else:
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"

            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage(
                    "Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage(
                        "Found syncplay.lua intf directory:'{}'".format(
                            vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage(
                        "syncplay.lua intf directory not found, so creating directory '{}'"
                        .format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755,
                                                        parents=True,
                                                        exist_ok=True)

            def _intfNeedsUpdating(vlcSyncplayInterfacePath):
                self.__playerController._client.ui.showDebugMessage(
                    "Checking if '{}' exists and if it is the expected version"
                    .format(vlcSyncplayInterfacePath))
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    self.__playerController._client.ui.showDebugMessage(
                        "syncplay.lua not found, so file needs copying")
                    return True
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if interface_version == constants.VLC_INTERFACE_VERSION:
                                    self.__playerController._client.ui.showDebugMessage(
                                        "syncplay.lua exists and is expected version, so no file needs copying"
                                    )
                                    return False
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    self.__playerController._client.ui.showDebugMessage(
                                        "syncplay.lua is {} but expected version is {} so file needs to be copied"
                                        .format(
                                            interface_version,
                                            constants.VLC_INTERFACE_VERSION))
                                    return True
                self.__playerController._client.ui.showDebugMessage(
                    "Up-to-dateness checks failed, so copy the file.")
                return True

            if _intfNeedsUpdating(
                    os.path.join(playerController.vlcIntfUserPath,
                                 "syncplay.lua")):
                try:
                    _createIntfFolder(playerController.vlcIntfUserPath)
                    copyForm = utils.findResourcePath("syncplay.lua")
                    copyTo = os.path.join(playerController.vlcIntfUserPath,
                                          "syncplay.lua")
                    self.__playerController._client.ui.showDebugMessage(
                        "Copying VLC Lua Interface from '{}' to '{}'".format(
                            copyForm, copyTo))
                    import shutil
                    if os.path.exists(copyTo):
                        os.chmod(copyTo, 0o755)
                    shutil.copyfile(copyForm, copyTo)
                    os.chmod(copyTo, 0o755)
                except Exception as e:
                    playerController._client.ui.showErrorMessage(e)
                    return
            if isLinux():
                playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                playerController.vlcDataPath = utils.findWorkingDir(
                ) + "\\resources"
            playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.
                format(playerController.vlcModulePath,
                       str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(
                    sys, '_MEIPASS',
                    '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(call,
                                                  stdin=subprocess.PIPE,
                                                  stderr=subprocess.PIPE,
                                                  stdout=subprocess.PIPE,
                                                  shell=False,
                                                  creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call,
                                                  stderr=subprocess.PIPE,
                                                  stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line),
                                True)
                            break
                        elif "lua interface error" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line),
                                True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(
                    target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator(b'\n')
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()
Пример #16
0
 def _checkForPortableFile(self):
     path = utils.findWorkingDir()
     if(os.path.isfile(os.path.join(path, constants.DEFAULT_CONFIG_NAME))):
         return os.path.join(path, constants.DEFAULT_CONFIG_NAME) 
Пример #17
0
        def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
                vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if utils.meetsMinVersion(interface_version, constants.VLC_INTERFACE_MIN_VERSION):
                                    return True
                                else:
                                    playerController._client.ui.showErrorMessage(getMessage("vlc-interface-oldversion-warning"))
                                    return False
                playerController._client.ui.showErrorMessage(getMessage("vlc-interface-not-installed"))
                return False
            if sys.platform.startswith('linux'):
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif sys.platform.startswith('darwin'):
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif 'bsd' in sys.platform or sys.platform.startswith('dragonfly'):
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            if _usevlcintf(playerController.vlcIntfPath, playerController.vlcIntfUserPath):
                playerController.SLAVE_ARGS.append('--lua-config=syncplay={{port=\"{}\"}}'.format(str(playerController.vlcport)))
            else:
                if sys.platform.startswith('linux'):
                    playerController.vlcDataPath = "/usr/lib/syncplay/resources"
                else:
                    playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
                playerController.SLAVE_ARGS.append('--data-path={}'.format(playerController.vlcDataPath))
                playerController.SLAVE_ARGS.append('--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(playerController.vlcModulePath, str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            for line in iter(self.__process.stderr.readline, ''):
                if "[syncplay]" in line:
                    if "Listening on host" in line:
                        break
                    if "Hosting Syncplay" in line:
                        break
                    elif "Couldn't find lua interface" in line:
                        playerController._client.ui.showErrorMessage(getMessage("vlc-failed-noscript").format(line), True)
                        break
                    elif "lua interface error" in line:
                        playerController._client.ui.showErrorMessage(getMessage("media-player-error").format(line), True)
                        break
            self.__process.stderr = None
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator("\n")
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()
Пример #18
0
        def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage("Found syncplay.lua intf directory:'{}'".format(vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua intf directory not found, so creating directory '{}'".format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755, parents=True, exist_ok=True)
            def _intfNeedsUpdating(vlcSyncplayInterfacePath):
                self.__playerController._client.ui.showDebugMessage("Checking if '{}' exists and if it is the expected version".format(vlcSyncplayInterfacePath))
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua not found, so file needs copying")
                    return True
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if interface_version == constants.VLC_INTERFACE_VERSION:
                                    self.__playerController._client.ui.showDebugMessage("syncplay.lua exists and is expected version, so no file needs copying")
                                    return False
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    self.__playerController._client.ui.showDebugMessage("syncplay.lua is {} but expected version is {} so file needs to be copied".format(interface_version, constants.VLC_INTERFACE_VERSION))
                                    return True
                self.__playerController._client.ui.showDebugMessage("Up-to-dateness checks failed, so copy the file.")
                return True
            if _intfNeedsUpdating(os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")):
                try:
                    _createIntfFolder(playerController.vlcIntfUserPath)
                    copyForm = utils.findResourcePath("syncplay.lua")
                    copyTo = os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")
                    self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo))
                    import shutil
                    if os.path.exists(copyTo):
                        os.chmod(copyTo, 0o755)
                    shutil.copyfile(copyForm, copyTo)
                    os.chmod(copyTo, 0o755)
                except Exception as e:
                    playerController._client.ui.showErrorMessage(e)
                    return
            if isLinux():
                playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
            playerController.SLAVE_ARGS.append('--data-path={}'.format(playerController.vlcDataPath))
            playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(
                    playerController.vlcModulePath, str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(
                    call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
                    shell=False, creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line), True)
                            break
                        elif "lua interface error" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line), True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator(b'\n')
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()