Exemple #1
0
 def displayInvalidPinMessage(level=1):
     # Invalid Key Notification: Dialog, Popup Notification, None
     notifType = Settings.getInvalidPinNotificationType()
     if notifType == Settings.INVALID_PIN_NOTIFICATION_POPUP:
         cmd = ""
         if Settings.getNumberOfLevels() > 1:
             cmd = 'Notification("{0}", "{1} {2}", 3000, "{3}")'.format(ADDON.getLocalizedString(32104).encode('utf-8'), ADDON.getLocalizedString(32211).encode('utf-8'), str(level), ICON)
         else:
             cmd = 'Notification("{0}", "{1}", 3000, "{2}")'.format(ADDON.getLocalizedString(32001).encode('utf-8'), ADDON.getLocalizedString(32104).encode('utf-8'), ICON)
         xbmc.executebuiltin(cmd)
     elif notifType == Settings.INVALID_PIN_NOTIFICATION_DIALOG:
         line3 = None
         if Settings.getNumberOfLevels() > 1:
             line3 = "%s %d" % (ADDON.getLocalizedString(32211), level)
         xbmcgui.Dialog().ok(ADDON.getLocalizedString(32001).encode('utf-8'), ADDON.getLocalizedString(32104).encode('utf-8'), line3)
Exemple #2
0
 def displayInvalidPinMessage(level=1):
     # Invalid Key Notification: Dialog, Popup Notification, None
     notifType = Settings.getInvalidPinNotificationType()
     if notifType == Settings.INVALID_PIN_NOTIFICATION_POPUP:
         cmd = ""
         if Settings.getNumberOfLevels() > 1:
             cmd = 'Notification("{0}", "{1} {2}", 3000, "{3}")'.format(
                 ADDON.getLocalizedString(32104).encode('utf-8'),
                 ADDON.getLocalizedString(32211).encode('utf-8'),
                 str(level), ICON)
         else:
             cmd = 'Notification("{0}", "{1}", 3000, "{2}")'.format(
                 ADDON.getLocalizedString(32001).encode('utf-8'),
                 ADDON.getLocalizedString(32104).encode('utf-8'), ICON)
         xbmc.executebuiltin(cmd)
     elif notifType == Settings.INVALID_PIN_NOTIFICATION_DIALOG:
         line3 = None
         if Settings.getNumberOfLevels() > 1:
             line3 = "%s %d" % (ADDON.getLocalizedString(32211), level)
         xbmcgui.Dialog().ok(
             ADDON.getLocalizedString(32001).encode('utf-8'),
             ADDON.getLocalizedString(32104).encode('utf-8'), line3)
Exemple #3
0
    def setSecurity(self,
                    type,
                    title,
                    id,
                    oldLevel,
                    classBlocked=False,
                    forceLevel=None):
        log("Setting security for (id:%s) %s" % (id, title))

        level = 1

        # Check if we need to prompt the user or the new security level has been supplied
        if forceLevel is None:
            # Set the new security level to be used
            if oldLevel > 0:
                # Default is to disable it if it was enabled
                level = 0

            numLevels = Settings.getNumberOfLevels()
            if numLevels > 1 or classBlocked:
                # Need to prompt the user to see which pin they are trying to set
                displayNameList = []
                # Add the option to turn it off
                displayNameList.append("%s %s" %
                                       (ADDON.getLocalizedString(32211),
                                        ADDON.getLocalizedString(32013)))
                for i in range(1, numLevels + 1):
                    secLevStr = str(i)
                    if numLevels < 2:
                        # If there is only one security level, use "On" rather than the number
                        secLevStr = ADDON.getLocalizedString(32014)
                    displayString = "%s %s" % (ADDON.getLocalizedString(32211),
                                               secLevStr)
                    displayNameList.append(displayString)

                # Check if we need the option to disable a classification restriction
                if classBlocked:
                    displayNameList.append(ADDON.getLocalizedString(32212))

                select = xbmcgui.Dialog().select(
                    ADDON.getLocalizedString(32001), displayNameList)

                if select != -1:
                    level = select
                    if classBlocked and (select >= (len(displayNameList) - 1)):
                        level = -1
                    log("Setting security level to %d" % level)
                else:
                    log("Exiting set security as no level selected")
                    return
        else:
            level = forceLevel

        # This could take a little time to set the value so show the busy dialog
        xbmc.executebuiltin("ActivateWindow(busydialog)")

        if title not in [None, ""]:
            pinDB = PinSentryDB()
            if type == MenuNavigator.TVSHOWS:
                # Set the security level for this title, setting it to zero
                # will result in the entry being removed from the database
                # as the default for an item is unset
                pinDB.setTvShowSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.MOVIES:
                pinDB.setMovieSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.MOVIESETS:
                pinDB.setMovieSetSecurityLevel(title, int(id), level)
                # As well as setting the security on the Movie set, we need
                # to also set it on each movie in the Movie Set
                self._setSecurityOnMoviesInMovieSets(int(id), level)
            elif type == MenuNavigator.MUSICVIDEOS:
                pinDB.setMusicVideoSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.PLUGINS:
                pinDB.setPluginSecurityLevel(title, id, level)
            elif type == MenuNavigator.FILESOURCE:
                pinDB.setFileSourceSecurityLevel(title, id, level)
            elif type == MenuNavigator.CLASSIFICATIONS_MOVIES:
                pinDB.setMovieClassificationSecurityLevel(id, title, level)
            elif type == MenuNavigator.CLASSIFICATIONS_TV:
                pinDB.setTvClassificationSecurityLevel(id, title, level)
            del pinDB
        else:
            # Handle the bulk operations like set All security for the movies
            self._setBulkSecurity(type, level)

        xbmc.executebuiltin("Dialog.Close(busydialog)")
        xbmc.executebuiltin("Container.Refresh")
Exemple #4
0
    def setSecurity(self, type, title, id, oldLevel, classBlocked=False, forceLevel=None):
        log("Setting security for (id:%s) %s" % (id, title))

        level = 1

        # Check if we need to prompt the user or the new security level has been supplied
        if forceLevel is None:
            # Set the new security level to be used
            if oldLevel > 0:
                # Default is to disable it if it was enabled
                level = 0

            numLevels = Settings.getNumberOfLevels()
            if numLevels > 1 or classBlocked:
                # Need to prompt the user to see which pin they are trying to set
                displayNameList = []
                # Add the option to turn it off
                displayNameList.append("%s %s" % (ADDON.getLocalizedString(32211), ADDON.getLocalizedString(32013)))
                for i in range(1, numLevels + 1):
                    secLevStr = str(i)
                    if numLevels < 2:
                        # If there is only one security level, use "On" rather than the number
                        secLevStr = ADDON.getLocalizedString(32014)
                    displayString = "%s %s" % (ADDON.getLocalizedString(32211), secLevStr)
                    displayNameList.append(displayString)

                # Check if we need the option to disable a classification restriction
                if classBlocked:
                    displayNameList.append(ADDON.getLocalizedString(32212))

                select = xbmcgui.Dialog().select(ADDON.getLocalizedString(32001), displayNameList)

                if select != -1:
                    level = select
                    if classBlocked and (select >= (len(displayNameList) - 1)):
                        level = -1
                    log("Setting security level to %d" % level)
                else:
                    log("Exiting set security as no level selected")
                    return
        else:
            level = forceLevel

        # This could take a little time to set the value so show the busy dialog
        xbmc.executebuiltin("ActivateWindow(busydialog)")

        if title not in [None, ""]:
            pinDB = PinSentryDB()
            if type == MenuNavigator.TVSHOWS:
                # Set the security level for this title, setting it to zero
                # will result in the entry being removed from the database
                # as the default for an item is unset
                pinDB.setTvShowSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.MOVIES:
                pinDB.setMovieSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.MOVIESETS:
                pinDB.setMovieSetSecurityLevel(title, int(id), level)
                # As well as setting the security on the Movie set, we need
                # to also set it on each movie in the Movie Set
                self._setSecurityOnMoviesInMovieSets(int(id), level)
            elif type == MenuNavigator.MUSICVIDEOS:
                pinDB.setMusicVideoSecurityLevel(title, int(id), level)
            elif type == MenuNavigator.PLUGINS:
                pinDB.setPluginSecurityLevel(title, id, level)
            elif type == MenuNavigator.FILESOURCE:
                pinDB.setFileSourceSecurityLevel(title, id, level)
            elif type == MenuNavigator.CLASSIFICATIONS_MOVIES:
                pinDB.setMovieClassificationSecurityLevel(id, title, level)
            elif type == MenuNavigator.CLASSIFICATIONS_TV:
                pinDB.setTvClassificationSecurityLevel(id, title, level)
            del pinDB
        else:
            # Handle the bulk operations like set All security for the movies
            self._setBulkSecurity(type, level)

        xbmc.executebuiltin("Dialog.Close(busydialog)")
        xbmc.executebuiltin("Container.Refresh")
Exemple #5
0
##################################
# Main of the PinSentry Setter
##################################
if __name__ == '__main__':
    log("Starting Pin Sentry Setter")

    # Before setting the pin we need to ensure that all dialog boxes are closed
    xbmc.executebuiltin("Dialog.Close(all, true)", True)

    numArgs = len(sys.argv)
    log("SetPin: Number of arguments %d" % numArgs)

    # If there are no arguments, then the pins are for default pin access per video
    if numArgs < 2:
        # Get the number of pins that have been set
        numLevels = Settings.getNumberOfLevels()
        log("SetPin: number of pins is %d" % numLevels)

        if numLevels < 2:
            # Only one pin to set
            setPin()
        else:
            # Need to prompt the user to see which pin they are trying to set
            displayNameList = []
            for i in range(1, numLevels + 1):
                notSetMsg = ""
                if not Settings.isPinSet(i):
                    notSetMsg = " %s" % ADDON.getLocalizedString(32024)

                displayString = "%s %d%s" % (ADDON.getLocalizedString(32021),
                                             i, notSetMsg)
Exemple #6
0
##################################
# Main of the PinSentry Setter
##################################
if __name__ == "__main__":
    log("Starting Pin Sentry Setter")

    # Before setting the pin we need to ensure that all dialog boxes are closed
    xbmc.executebuiltin("Dialog.Close(all, true)", True)

    numArgs = len(sys.argv)
    log("SetPin: Number of arguments %d" % numArgs)

    # If there are no arguments, then the pins are for default pin access per video
    if numArgs < 2:
        # Get the number of pins that have been set
        numLevels = Settings.getNumberOfLevels()
        log("SetPin: number of pins is %d" % numLevels)

        if numLevels < 2:
            # Only one pin to set
            setPin()
        else:
            # Need to prompt the user to see which pin they are trying to set
            displayNameList = []
            for i in range(1, numLevels + 1):
                notSetMsg = ""
                if not Settings.isPinSet(i):
                    notSetMsg = " %s" % ADDON.getLocalizedString(32024)

                displayString = "%s %d%s" % (ADDON.getLocalizedString(32021), i, notSetMsg)
                displayNameList.append(displayString)