Ejemplo n.º 1
0
def setUserPin(pinId):
    # Prompt the user for the pin
    numberpad = NumberPad.createNumberPad(32106)
    numberpad.doModal()

    # Get the code that the user entered
    enteredPin = numberpad.getPin()
    del numberpad

    # Check to ensure the user has either set no password or one the correct length
    if (len(enteredPin) > 0) and (Settings.getPinLength() > len(enteredPin)):
        log("SetPin: Incorrect length pin entered, expecting %d digits" % Settings.getPinLength())
        xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32109).encode('utf-8'))
    elif Settings.checkUserPinClash(enteredPin, pinId):
        # This pin clashes with an existing pin
        log("SetPin: Entered pin clashes with an existing pin")
        xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32112).encode('utf-8'))
    else:
        # Now double check the value the user entered
        numberpad = NumberPad.createNumberPad(32107)
        numberpad.doModal()

        # Get the code that the user entered
        enteredPin2 = numberpad.getPin()
        del numberpad

        if enteredPin == enteredPin2:
            Settings.setUserPinValue(enteredPin, pinId)
        else:
            log("SetPin: Pin entry different, first: %s, second %s" % (enteredPin, enteredPin2))
            xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32108).encode('utf-8'))
Ejemplo n.º 2
0
def setPin(pinLevel=1):
    okToChangePin = True

    # Check if the pin is already set, if it is, then we need to prompt for that first
    # before we allow the user to just change it
    if Settings.isPinSet(pinLevel):
        log("SetPin: Existing pin set, prompting for it")
        # Prompt the user for the pin
        numberpad = NumberPad.createNumberPad(32105)
        numberpad.doModal()

        # Get the code that the user entered
        enteredPin = numberpad.getPin()
        del numberpad

        if not Settings.isPinCorrect(enteredPin, pinLevel):
            log("SetPin: Incorrect Existing Pin Entered")
            okToChangePin = False
            xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32104).encode('utf-8'))
        else:
            log("SetPin: Correct Existing Pin Entered")

    # If we are OK to change the pin, prompt the user
    if okToChangePin:
        # Prompt the user for the pin
        numberpad = NumberPad.createNumberPad(32106)
        numberpad.doModal()

        # Get the code that the user entered
        enteredPin = numberpad.getPin()
        del numberpad

        # Check to ensure the user has either set no password or one the correct length
        if (len(enteredPin) > 0) and (Settings.getPinLength() > len(enteredPin)):
            log("SetPin: Incorrect length pin entered, expecting %d digits" % Settings.getPinLength())
            xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32109).encode('utf-8'))
        elif Settings.checkPinClash(enteredPin, pinLevel):
            # This pin clashes with an existing pin
            log("SetPin: Entered pin clashes with an existing pin")
            xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32112).encode('utf-8'))
        else:
            # Now double check the value the user entered
            numberpad = NumberPad.createNumberPad(32107)
            numberpad.doModal()

            # Get the code that the user entered
            enteredPin2 = numberpad.getPin()
            del numberpad

            if enteredPin == enteredPin2:
                Settings.setPinValue(enteredPin, pinLevel)
            else:
                log("SetPin: Pin entry different, first: %s, second %s" % (enteredPin, enteredPin2))
                xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32108).encode('utf-8'))
Ejemplo n.º 3
0
    def promptUserForPin():
        userHasAccess = True

        # Set the background
        background = Background.createBackground()
        if background is not None:
            background.show()

        # Prompt the user to enter the pin
        numberpad = NumberPad.createNumberPad()
        numberpad.doModal()

        # Remove the background if we had one
        if background is not None:
            background.close()
            del background

        # Get the code that the user entered
        enteredPin = numberpad.getPin()
        del numberpad

        # Check to see if the pin entered is correct
        if Settings.isPinCorrect(enteredPin):
            log("PinSentry: Pin entered Correctly")
            userHasAccess = True
            # Check if we are allowed to cache the pin level
            PinSentry.setCachedPinLevel(1)
        else:
            log("PinSentry: Incorrect Pin Value Entered")
            userHasAccess = False

        return userHasAccess
Ejemplo n.º 4
0
    def promptUserForPin(requiredLevel=1):
        userHasAccess = True

        # Set the background
        background = Background.createBackground()
        if background is not None:
            background.show()

        # Prompt the user to enter the pin
        numberpad = NumberPad.createNumberPad()
        numberpad.doModal()

        # Remove the background if we had one
        if background is not None:
            background.close()
            del background

        # Get the code that the user entered
        enteredPin = numberpad.getPin()
        del numberpad

        # Find out what level this pin gives access to
        # This will be the highest level
        pinMatchLevel = Settings.getSecurityLevelForPin(enteredPin)

        # Check to see if the pin entered is correct
        if pinMatchLevel >= requiredLevel:
            log("PinSentry: Pin entered correctly for security level %d" % pinMatchLevel)
            userHasAccess = True
            # Check if we are allowed to cache the pin level
            PinSentry.setCachedPinLevel(pinMatchLevel)
        else:
            log("PinSentry: Incorrect Pin Value Entered, required level %d entered level %d" % (requiredLevel, pinMatchLevel))
            userHasAccess = False

        return userHasAccess
Ejemplo n.º 5
0
    def startupCheck(self):
        # When the system starts up we need to check to see if User restriction is enabled
        if Settings.getNumberOfLimitedUsers() < 1:
            log("UserPinControl: No Limited users configured")
            self.isEnabled = False
            return

        self.isEnabled = True

        # Set the background
        background = Background.createBackground()
        if background is not None:
            background.show()

        preventAccess = False
        tryAgain = True
        while tryAgain:
            tryAgain = False
            # Need to find out which user this is, so prompt them for a pin
            numberpad = NumberPad.createNumberPad()
            numberpad.doModal()

            # Get the code that the user entered
            enteredPin = numberpad.getPin()
            del numberpad

            # Find out which user owns this pin
            self.userId = Settings.getUserForPin(enteredPin)

            # Check for the unrestricted user
            if self.userId == "unrestrictedUserPin":
                log("UserPinControl: Unrestricted user pin entered")
                self.isEnabled = False
                break

            if self.userId in [None, ""]:
                log("UserPinControl: Unknown pin entered, offering retry")
                # This is not a valid user, so display the error message and work out
                # if we should prompt the user again or shutdown the system
                tryAgain = xbmcgui.Dialog().yesno(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32104).encode('utf-8'), __addon__.getLocalizedString(32129).encode('utf-8'))

                if not tryAgain:
                    # Need to stop this user accessing the system
                    preventAccess = True

        # Remove the background if we had one
        if background is not None:
            background.close()
            del background

        if preventAccess:
            log("UserPinControl: Shutting down as unknown user pin entered")
            self.shutdown()
        elif self.isEnabled:
            log("UserPinControl: User logged in is %s" % self.userId)
            # Load the settings for this user
            self.allowedStartTime, displayStartTime = Settings.getUserStartTime(self.userId)
            self.allowedEndTime, displayEndTime = Settings.getUserEndTime(self.userId)
            self.usedViewingLimit = Settings.getUserViewingUsedTime(self.userId)

            self.displaySummary()

            # Now we can record when this user started viewing in this session
            localTime = time.localtime()
            self.startedViewing = (localTime.tm_hour * 60) + localTime.tm_min

            # We actually want to also record how many minutes have already been viewed in previous
            # sessions, so roll the clock back by that much
            self.startedViewing = self.startedViewing - self.usedViewingLimit

            log("UserPinControl: Time already used for user is %d" % self.usedViewingLimit)

            # Record that we are running as a restricted user so that the default script
            # can display the status of how long is left when it is selected
            xbmcgui.Window(10000).setProperty("PinSentry_RestrictedUser", self.userId)
Ejemplo n.º 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)

    okToChangePin = True

    # Check if the pin is already set, if it is, then we need to prompt for that first
    # before we allow the user to just change it
    if Settings.isPinSet():
        log("SetPin: Existing pin set, prompting for it")
        # Prompt the user for the pin
        numberpad = NumberPad.createNumberPad(32105)
        numberpad.doModal()

        # Get the code that the user entered
        enteredPin = numberpad.getPin()
        del numberpad

        if not Settings.isPinCorrect(enteredPin):
            log("SetPin: Incorrect Existing Pin Entered")
            okToChangePin = False
            xbmcgui.Dialog().ok(__addon__.getLocalizedString(32001).encode('utf-8'), __addon__.getLocalizedString(32104).encode('utf-8'))
        else:
            log("SetPin: Correct Existing Pin Entered")

    # If we are OK to change the pin, prompt the user
    if okToChangePin: