class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): def __init__(self, session, pin, pinname): Screen.__init__(self, session) self.pin = pin self.list = [] self.pin1 = ConfigPIN(default = 1111, censor = "*") self.pin2 = ConfigPIN(default = 1112, censor = "*") self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("New pin"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter new pin"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) # print "old pin:", pin #if pin.value != "aaaa": #self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.pin.value], title = _("please enter the old pin"), windowTitle = _("Change pin code"))) ProtectedScreen.__init__(self) self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"], { "cancel": self.cancel, }, -1) def valueChanged(self, pin, value): if pin == 1: self["config"].setCurrentIndex(1) elif pin == 2: self.keyOK() def getPinText(self): return _("Please enter the old pin code") def isProtected(self): return (self.pin.value != "aaaa") def protectedWithPin(self): return self.pin.value # def pinEntered(self, result): #if result[0] is None: #self.close() #if not result[0]: #print result, "-", self.pin.value #self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR) def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback(self.close, MessageBox, _("The pin code has been changed successfully."), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _("The pin codes you entered are different."), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number)
def addEntry(self, list, entry): if entry[0] == "TEXT": #handle every item (text / pin only?) list.append( (entry[1], ConfigNothing(), entry[2]) ) if entry[0] == "PIN": pinlength = entry[1] if entry[3] == 1: # masked pins: x = ConfigPIN(0, len = pinlength, censor = "*") else: # unmasked pins: x = ConfigPIN(0, len = pinlength) x.addEndNotifier(self.pinEntered) self["subtitle"].setText(entry[2]) list.append( getConfigListEntry("", x) ) self["bottom"].setText(_("please press OK when ready"))
def addEntry(self, list, entry): if entry[0] == 'TEXT': list.append((entry[1], ConfigNothing(), entry[2])) if entry[0] == 'PIN': pinlength = entry[1] pin = config.cipin.pin1.value if len(str(config.cipin.pin1.value)) == 3: pin = '0' + str(config.cipin.pin1.value) pinlength = 4 if entry[3] == 1: x = ConfigPIN(int(pin), len=pinlength, censor='*') else: x = ConfigPIN(int(pin), len=pinlength) x.addEndNotifier(self.pinEntered) self['subtitle'].setText(entry[2]) list.append(getConfigListEntry('', x)) self['bottom'].setText(_('please press OK when ready')) if config.cipin.pin1autook.value: self.okbuttonClick()
def addEntry(self, list, entry): if entry[0] == "TEXT": #handle every item (text / pin only?) list.append( (entry[1], ConfigNothing(), entry[2]) ) if entry[0] == "PIN": pinlength = entry[1] pin = config.cipin.pin1.value if len(str(config.cipin.pin1.value)) == 3: pin = "0" + str(config.cipin.pin1.value) pinlength = 4 if entry[3] == 1: # masked pins: x = ConfigPIN(int(pin), len = pinlength, censor = "*") else: # unmasked pins: x = ConfigPIN(int(pin), len = pinlength) x.addEndNotifier(self.pinEntered) self["subtitle"].setText(entry[2]) list.append( getConfigListEntry("", x) ) self["bottom"].setText(_("please press OK when ready")) if config.cipin.pin1autook.value: self.okbuttonClick()
class PermanentPinEntry(Screen, ConfigListScreen): def __init__(self, session, pin, pin_slot): Screen.__init__(self, session) self.skinName = ["ParentalControlChangePin", "Setup" ] self.setup_title = _("Enter pin code") self.onChangedEntry = [ ] self.slot = pin_slot self.pin = pin self.list = [] self.pin1 = ConfigPIN(default = 0, censor = "*") self.pin2 = ConfigPIN(default = 0, censor = "*") self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("Enter PIN"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter PIN"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"], { "cancel": self.cancel, "red": self.cancel, "save": self.keyOK, }, -1) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self["config"].setCurrentIndex(1) elif pin == 2: self.keyOK() def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback(self.close, MessageBox, _("The PIN code has been saved successfully."), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _("The PIN codes you entered are different."), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent()[0] def getCurrentValue(self): return str(self["config"].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary
class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): def __init__(self, session, pin, pinname): Screen.__init__(self, session) # for the skin: first try ParentalControlChangePin, then Setup, this allows individual skinning self.skinName = ["ParentalControlChangePin", "Setup"] self.setup_title = _("Change pin code") self.onChangedEntry = [] self.pin = pin self.list = [] self.pin1 = ConfigPIN(default=1111, censor="*") self.pin2 = ConfigPIN(default=1112, censor="*") self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("New PIN"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter new PIN"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) # print "old pin:", pin # if pin.value != "aaaa": # self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.pin.value], title = _("please enter the old pin"), windowTitle = _("Change pin code"))) ProtectedScreen.__init__(self) self["actions"] = NumberActionMap( ["DirectionActions", "ColorActions", "OkCancelActions"], {"cancel": self.cancel, "red": self.cancel, "save": self.keyOK}, -1, ) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self["config"].setCurrentIndex(1) elif pin == 2: self.keyOK() def getPinText(self): return _("Please enter the old PIN code") def isProtected(self): return self.pin.value != "aaaa" def protectedWithPin(self): return self.pin.value # def pinEntered(self, result): # if result[0] is None: # self.close() # if not result[0]: # print result, "-", self.pin.value # self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR) def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback( self.close, MessageBox, _("The PIN code has been changed successfully."), MessageBox.TYPE_INFO ) else: self.session.open(MessageBox, _("The PIN codes you entered are different."), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent()[0] def getCurrentValue(self): return str(self["config"].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary
class ParentalControlChangePin(Screen, ConfigListScreen, ProtectedScreen): def __init__(self, session, pin, pinname): Screen.__init__(self, session) # for the skin: first try ParentalControlChangePin, then Setup, this allows individual skinning self.skinName = ["ParentalControlChangePin", "Setup" ] self.setup_title = _("Change pin code") self.onChangedEntry = [ ] self.pin = pin self.list = [] self.pin1 = ConfigPIN(default = 1111, censor = "*") self.pin2 = ConfigPIN(default = 1112, censor = "*") self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("New PIN"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter new PIN"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) ProtectedScreen.__init__(self) self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions", "MenuActions"], { "cancel": self.keyCancel, "red": self.keyCancel, "save": self.keyOK, "menu": self.closeRecursive, }, -1) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self["config"].setCurrentIndex(1) elif pin == 2: self.keyOK() def getPinText(self): return _("Please enter the old PIN code") def isProtected(self): return (self.pin.value != 'aaaa') def protectedWithPin(self): return self.pin.value def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback(self.close, MessageBox, _("The PIN code has been changed successfully."), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _("The PIN codes you entered are different."), MessageBox.TYPE_ERROR) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent()[0] def getCurrentValue(self): return str(self["config"].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary
class PermanentPinEntry(Screen, ConfigListScreen): def __init__(self, session, pin, pin_slot): Screen.__init__(self, session) self.skinName = ["ParentalControlChangePin", "Setup" ] self.setup_title = _("Enter pin code") self.onChangedEntry = [ ] self.slot = pin_slot self.pin = pin self.list = [] self.pin1 = ConfigPIN(default = 0, censor = "*") self.pin2 = ConfigPIN(default = 0, censor = "*") self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_("Enter PIN"), NoSave(self.pin1))) self.list.append(getConfigListEntry(_("Reenter PIN"), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions"], { "cancel": self.cancel, "red": self.cancel, "save": self.keyOK, }, -1) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self["config"].setCurrentIndex(1) elif pin == 2: self.keyOK() def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback(self.close, MessageBox, _("The PIN code has been saved successfully."), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _("The PIN codes you entered are different."), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent()[0] def getCurrentValue(self): return str(self["config"].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary
class PermanentPinEntry(Screen, ConfigListScreen): def __init__(self, session, pin, pin_slot): Screen.__init__(self, session) self.skinName = ['ParentalControlChangePin', 'Setup'] self.setup_title = _('Enter pin code') self.onChangedEntry = [] self.slot = pin_slot self.pin = pin self.list = [] self.pin1 = ConfigPIN(default=0, censor='*') self.pin2 = ConfigPIN(default=0, censor='*') self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_('Enter PIN'), NoSave(self.pin1))) self.list.append( getConfigListEntry(_('Reenter PIN'), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) self['actions'] = NumberActionMap( ['DirectionActions', 'ColorActions', 'OkCancelActions'], { 'cancel': self.cancel, 'red': self.cancel, 'save': self.keyOK }, -1) self['key_red'] = StaticText(_('Cancel')) self['key_green'] = StaticText(_('OK')) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self['config'].setCurrentIndex(1) elif pin == 2: self.keyOK() def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback( self.close, MessageBox, _('The PIN code has been saved successfully.'), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _('The PIN codes you entered are different.'), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self['config'].getCurrent()[0] def getCurrentValue(self): return str(self['config'].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary
class PermanentPinEntry(Screen, ConfigListScreen): def __init__(self, session, pin, pin_slot): Screen.__init__(self, session) self.skinName = ['ParentalControlChangePin', 'Setup'] self.setup_title = _('Enter pin code') self.onChangedEntry = [] self.slot = pin_slot self.pin = pin self.list = [] self.pin1 = ConfigPIN(default=0, censor='*') self.pin2 = ConfigPIN(default=0, censor='*') self.pin1.addEndNotifier(boundFunction(self.valueChanged, 1)) self.pin2.addEndNotifier(boundFunction(self.valueChanged, 2)) self.list.append(getConfigListEntry(_('Enter PIN'), NoSave(self.pin1))) self.list.append(getConfigListEntry(_('Reenter PIN'), NoSave(self.pin2))) ConfigListScreen.__init__(self, self.list) self['actions'] = NumberActionMap(['DirectionActions', 'ColorActions', 'OkCancelActions'], {'cancel': self.cancel, 'red': self.cancel, 'save': self.keyOK}, -1) self['key_red'] = StaticText(_('Cancel')) self['key_green'] = StaticText(_('OK')) self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): self.setTitle(self.setup_title) def valueChanged(self, pin, value): if pin == 1: self['config'].setCurrentIndex(1) elif pin == 2: self.keyOK() def keyOK(self): if self.pin1.value == self.pin2.value: self.pin.value = self.pin1.value self.pin.save() self.session.openWithCallback(self.close, MessageBox, _('The PIN code has been saved successfully.'), MessageBox.TYPE_INFO) else: self.session.open(MessageBox, _('The PIN codes you entered are different.'), MessageBox.TYPE_ERROR) def cancel(self): self.close(None) return def keyNumberGlobal(self, number): ConfigListScreen.keyNumberGlobal(self, number) def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self['config'].getCurrent()[0] def getCurrentValue(self): return str(self['config'].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary