from enigma import *
+from Components.ParentalControl import parentalControl
+from Tools.BoundFunction import boundFunction
import RecordTimer
import NavigationInstance
NavigationInstance.instance = self
self.ServiceHandler = eServiceCenter.getInstance()
-
+
import Navigation as Nav
Nav.navcore = self
self.currentlyPlayingService = None
self.state = 0
self.RecordTimer = RecordTimer.RecordTimer()
-
+
def callEvent(self, i):
self.state = i != 1
for x in self.event:
x(i)
- def playService(self, ref):
+ def playService(self, ref, checkParentalControl = True):
print "playing", ref and ref.toString()
self.currentlyPlayingServiceReference = None
self.currentlyPlayingService = None
self.stopService()
return 0
- if self.pnav and not self.pnav.playService(ref):
- self.currentlyPlayingServiceReference = ref
- return 0
+ if not checkParentalControl or parentalControl.isServicePlayable(ref, boundFunction(self.playService, checkParentalControl = False)):
+ if self.pnav and not self.pnav.playService(ref):
+ self.currentlyPlayingServiceReference = ref
+ return 0
+ else:
+ self.stopService()
return 1
def getCurrentlyPlayingServiceReference(self):
<!--<item text="OSD"><setup id="osd" /></item>-->
<item><setup id="lcd" /></item>
<item text="Network..."><screen module="NetworkSetup" screen="NetworkSetup" /></item>
+ <item text="Parental control..."><screen module="ParentalControlSetup" screen="ParentalControlSetup" /></item>
</menu>
<item text="Common Interface"><screen module="Ci" screen="CiSelection" /></item>
+ <item text="Startwizard"><screen module="StartWizard" screen="StartWizard" /></item>
<!--<item text="Parental Control"><setup id="parental" /></item>-->
<!--<item text="Expert -disabled-"><setup id="expert" /></item>-->
</menu>
<widget name="footer" position="20,250" size="360,25" font="Regular;23"/>
<!--<widget name="introduction" position="20,360" size="280,30" font="Regular;23" />-->
</screen>
+ <screen name="ParentalControlSetup" position="100,88" size="520,400" title="Parental control setup">
+ <widget name="config" position="20,10" size="460,350" scrollbarMode="showOnDemand" />
+ </screen>
+ <screen name="ParentalControlEditor" position="100,88" size="520,400" title="Parental control services Editor">
+ <widget name="servicelist" position="20,10" size="460,350" scrollbarMode="showOnDemand" />
+ </screen>
<screen name="TimerEntry" position="110,88" size="500,400" title="Timer entry">
<widget name="config" position="5,10" size="480,350" />
<widget name="ok" position="140,365" size="53,30" pixmap="ok.png" />
<widget name="text" position="0,0" size="550,25" font="Regular;20" />
<widget name="input" position="0,30" size="550,25" font="Regular;20" />
</screen>
+ <screen name="PinInput" position="100,100" size="550,160" title="Pin code needed" >
+ <widget name="service" position="0,0" size="550,25" font="Regular;20" />
+ <widget name="text" position="0,30" size="550,25" font="Regular;20" />
+ <widget name="tries" position="0,60" size="550,25" font="Regular;20" />
+ <widget name="input" position="200,100" size="550,25" font="Regular;50" />
+
+ </screen>
+ <screen name="ParentalControlChangePin" position="100,100" size="550,160" title="Change pin code" >
+ <widget name="config" position="20,10" size="460,350" scrollbarMode="showOnDemand" />
+ </screen>
<screen name="ChoiceBox" position="150,100" size="550,400" title="Input" >
<widget name="text" position="0,0" size="550,25" font="Regular;20" />
<widget name="list" position="0,30" size="550,335" scrollbarMode="showOnDemand" />
self.currPos = 0
self.overwrite = 0
self.setText(text)
+
+ def __len__(self):
+ return len(self.text)
def update(self):
self.setMarkedPos(self.currPos)
PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \
FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \
MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \
- Element.py Playlist.py
+ Element.py Playlist.py ParentalControl.py ParentalControlList.py
--- /dev/null
+from Components.config import config, ConfigSubsection, ConfigSelection, ConfigPIN, ConfigYesNo, ConfigSubList
+from Components.Input import Input
+from Screens.InputBox import InputBox, PinInput
+from Screens.MessageBox import MessageBox
+from Tools.BoundFunction import boundFunction
+from ServiceReference import ServiceReference
+from Tools import Notifications
+from Tools.Directories import resolveFilename, SCOPE_CONFIG
+
+def InitParentalControl():
+ config.ParentalControl = ConfigSubsection()
+ config.ParentalControl.configured = ConfigYesNo(default = False)
+ config.ParentalControl.mode = ConfigSelection(default = "simple", choices = [("simple", _("simple")), ("complex", _("complex"))])
+ config.ParentalControl.storeservicepin = ConfigSelection(default = "never", choices = [("never", _("never")), ("5_minutes", _("5 minutes")), ("30_minutes", _("30 minutes")), ("60_minutes", _("60 minutes")), ("restart", _("until restart"))])
+ config.ParentalControl.servicepinactive = ConfigYesNo(default = False)
+ config.ParentalControl.setuppinactive = ConfigYesNo(default = False)
+ config.ParentalControl.type = ConfigSelection(default = "blacklist", choices = [("whitelist", _("whitelist")), ("blacklist", _("blacklist"))])
+ config.ParentalControl.setuppin = ConfigPIN(default = -1)
+# config.ParentalControl.configured = configElement("config.ParentalControl.configured", configSelection, 1, (("yes", _("yes")), ("no", _("no"))))
+ #config.ParentalControl.mode = configElement("config.ParentalControl.mode", configSelection, 0, (("simple", _("simple")), ("complex", _("complex"))))
+ #config.ParentalControl.storeservicepin = configElement("config.ParentalControl.storeservicepin", configSelection, 0, (("never", _("never")), ("5_minutes", _("5 minutes")), ("30_minutes", _("30 minutes")), ("60_minutes", _("60 minutes")), ("restart", _("until restart"))))
+ #config.ParentalControl.servicepinactive = configElement("config.ParentalControl.servicepinactive", configSelection, 1, (("yes", _("yes")), ("no", _("no"))))
+ #config.ParentalControl.setuppinactive = configElement("config.ParentalControl.setuppinactive", configSelection, 1, (("yes", _("yes")), ("no", _("no"))))
+ #config.ParentalControl.type = configElement("config.ParentalControl.type", configSelection, 0, (("whitelist", _("whitelist")), ("blacklist", _("blacklist"))))
+ #config.ParentalControl.setuppin = configElement("config.ParentalControl.setuppin", configSequence, "0000", configSequenceArg().get("PINCODE", (4, "")))
+
+ config.ParentalControl.servicepin = ConfigSubList()
+
+ for i in range(3):
+ config.ParentalControl.servicepin.append(ConfigPIN(default = -1))
+ #config.ParentalControl.servicepin.append(configElement("config.ParentalControl.servicepin.level" + str(i), configSequence, "0000", configSequenceArg().get("PINCODE", (4, ""))))
+
+class ParentalControl:
+ def __init__(self):
+ self.open()
+ self.serviceLevel = {}
+ self.tries = 3
+
+ def addWhitelistService(self, service):
+ self.whitelist.append(service.toString())
+
+ def addBlacklistService(self, service):
+ self.blacklist.append(service.toString())
+
+ def setServiceLevel(self, service, level):
+ self.serviceLevel[service.toString()] = level
+
+ def deleteWhitelistService(self, service):
+ self.whitelist.remove(service.toString())
+ if self.serviceLevel.has_key(service.toString()):
+ self.serviceLevel.remove(service.toString())
+
+ def deleteBlacklistService(self, service):
+ self.blacklist.remove(service.toString())
+ if self.serviceLevel.has_key(service.toString()):
+ self.serviceLevel.remove(service.toString())
+
+ def isServicePlayable(self, serviceref, callback):
+ service = serviceref.toString()
+ if not config.ParentalControl.configured.value:
+ return True
+ print "whitelist:", self.whitelist
+ print "blacklist:", self.blacklist
+ print "config.ParentalControl.type.value:", config.ParentalControl.type.value
+ print "not in whitelist:", (service not in self.whitelist)
+ print "checking parental control for service:", service
+ if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
+ self.callback = callback
+ print "service:", ServiceReference(service).getServiceName()
+ levelNeeded = 0
+ if self.serviceLevel.has_key(service):
+ levelNeeded = self.serviceLevel[service]
+ pinList = self.getPinList()[:levelNeeded + 1]
+ Notifications.AddNotificationWithCallback(boundFunction(self.servicePinEntered, service), PinInput, tries = self.tries, pinList = pinList, service = ServiceReference(service).getServiceName(), title = _("this service is protected by a parental control pin"), windowTitle = _("Parental control"))
+ return False
+ else:
+ return True
+
+ def protectService(self, service):
+ print "protect"
+ print "config.ParentalControl.type.value:", config.ParentalControl.type.value
+ if config.ParentalControl.type.value == "whitelist":
+ if service.toString() in self.whitelist:
+ self.deleteWhitelistService(service)
+ else: # blacklist
+ if service.toString() not in self.blacklist:
+ self.addBlacklistService(service)
+ print "whitelist:", self.whitelist
+ print "blacklist:", self.blacklist
+
+
+ def unProtectService(self, service):
+ print "unprotect"
+ print "config.ParentalControl.type.value:", config.ParentalControl.type.value
+ if config.ParentalControl.type.value == "whitelist":
+ if service.toString() not in self.whitelist:
+ self.addWhitelistService(service)
+ else: # blacklist
+ if service.toString() in self.blacklist:
+ self.deleteBlacklistService(service)
+ print "whitelist:", self.whitelist
+ print "blacklist:", self.blacklist
+
+
+
+ def getProtectionLevel(self, serviceref):
+ service = serviceref.toString()
+ if (config.ParentalControl.type.value == "whitelist" and service not in self.whitelist) or (config.ParentalControl.type.value == "blacklist" and service in self.blacklist):
+ if self.serviceLevel.has_key(service):
+ return self.serviceLevel[service]
+ else:
+ return 0
+ else:
+ return -1
+
+ def getPinList(self):
+ pinList = []
+ for x in config.ParentalControl.servicepin:
+ pinList.append(x.value)
+ return pinList
+
+ def servicePinEntered(self, service, result):
+# levelNeeded = 0
+ #if self.serviceLevel.has_key(service):
+ #levelNeeded = self.serviceLevel[service]
+#
+ #print "getPinList():", self.getPinList()
+ #pinList = self.getPinList()[:levelNeeded + 1]
+ #print "pinList:", pinList
+#
+# print "pin entered for service", service, "and pin was", pin
+ #if pin is not None and int(pin) in pinList:
+ if result[0] is not None and result[0]:
+ print "pin ok, playing service"
+ self.tries = 3
+ self.callback(ref = ServiceReference(service).ref)
+ else:
+ self.tries = result[1]
+ if result[0] is not None:
+ Notifications.AddNotification(MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
+ print "wrong pin entered"
+
+ def saveWhitelist(self):
+ file = open(resolveFilename(SCOPE_CONFIG, "whitelist"), 'w')
+ for x in self.whitelist:
+ file.write(x + "\n")
+ file.close
+
+ def openWhitelist(self):
+ self.whitelist = []
+ try:
+ file = open(resolveFilename(SCOPE_CONFIG, "whitelist"), 'r')
+ lines = file.readlines()
+ for x in lines:
+ self.whitelist.append(x.strip())
+ file.close
+ except:
+ pass
+
+ def saveBlacklist(self):
+ file = open(resolveFilename(SCOPE_CONFIG, "blacklist"), 'w')
+ for x in self.blacklist:
+ file.write(x + "\n")
+ file.close
+
+ def openBlacklist(self):
+ self.blacklist = []
+ try:
+ file = open(resolveFilename(SCOPE_CONFIG, "blacklist"), 'r')
+ lines = file.readlines()
+ for x in lines:
+ self.blacklist.append(x.strip())
+ file.close
+ except:
+ pass
+
+ def save(self):
+ self.saveBlacklist()
+ self.saveWhitelist()
+
+ def open(self):
+ self.openBlacklist()
+ self.openWhitelist()
+
+parentalControl = ParentalControl()
\ No newline at end of file
--- /dev/null
+from HTMLComponent import *
+from GUIComponent import *
+
+from MenuList import MenuList
+from Components.ParentalControl import parentalControl
+from Tools.Directories import *
+
+from enigma import *
+
+RT_HALIGN_LEFT = 0
+RT_HALIGN_RIGHT = 1
+RT_HALIGN_CENTER = 2
+RT_HALIGN_BLOCK = 4
+
+RT_VALIGN_TOP = 0
+RT_VALIGN_CENTER = 8
+RT_VALIGN_BOTTOM = 16
+
+lockPicture = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "lock-fs8.png"))
+
+def ParentalControlEntryComponent(service, name, locked = True):
+ res = [ (service, name, locked) ]
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 200, 50, 0, RT_HALIGN_LEFT, name))
+ if locked:
+ res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, lockPicture))
+
+ return res
+
+class ParentalControlList(MenuList, HTMLComponent, GUIComponent):
+ def __init__(self, list):
+ GUIComponent.__init__(self)
+ self.l = eListboxPythonMultiContent()
+ self.list = list
+ self.l.setList(list)
+ self.l.setFont(0, gFont("Regular", 20))
+
+ GUI_WIDGET = eListbox
+
+ def setList(self, list):
+ self.list = list
+ self.l.setList(list)
+
+ def postWidgetCreate(self, instance):
+ instance.setContent(self.l)
+ instance.setItemHeight(32)
+
+ def toggleSelectedLock(self):
+ print "self.l.getCurrentSelection():", self.l.getCurrentSelection()
+ print "self.l.getCurrentSelectionIndex():", self.l.getCurrentSelectionIndex()
+ self.list[self.l.getCurrentSelectionIndex()] = ParentalControlEntryComponent(self.l.getCurrentSelection()[0][0], self.l.getCurrentSelection()[0][1], not self.l.getCurrentSelection()[0][2]);
+ if self.l.getCurrentSelection()[0][2]:
+ parentalControl.protectService(self.l.getCurrentSelection()[0][0])
+ else:
+ parentalControl.unProtectService(self.l.getCurrentSelection()[0][0])
+ self.l.setList(self.list)
"InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
"IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry",
"Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck",
- "FileList", "MultiContent", "TunerInfo", "ChoiceList", "Playlist" ]
+ "FileList", "MultiContent", "TunerInfo", "ChoiceList", "Playlist",
+ "ParentalControl" ]
from Components.NimManager import nimmanager
from Components.Sources.Clock import Clock
from Components.Input import Input
-from Screens.InputBox import InputBox
+from Components.ParentalControl import parentalControl
+from Screens.InputBox import InputBox, PinInput
+from Screens.MessageBox import MessageBox
from ServiceReference import ServiceReference
+from Tools.BoundFunction import boundFunction
from re import *
from os import remove
if not csel.bouquet_mark_edit and not csel.movemode:
if not inBouquetRootList:
if (csel.getCurrentSelection().flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory:
+ if config.ParentalControl.configured.value:
+ if parentalControl.getProtectionLevel(csel.getCurrentSelection()) == -1:
+ menu.append((_("add to parental protection"), boundFunction(self.addParentalProtection, csel.getCurrentSelection())))
+ else:
+ menu.append((_("remove from parental protection"), boundFunction(self.removeParentalProtection, csel.getCurrentSelection())))
if haveBouquets:
menu.append((_("add service to bouquet"), self.addServiceToBouquetSelected))
else:
self.csel.addBouquet(bouquet, None)
self.close()
+ def addParentalProtection(self, service):
+ parentalControl.protectService(service)
+ self.close()
+
+ def removeParentalProtection(self, service):
+ self.session.openWithCallback(boundFunction(self.pinEntered, service), PinInput, pinList = [config.ParentalControl.servicepin[0].value], title = _("Enter the service pin"), windowTitle = _("Change pin code"))
+
+ def pinEntered(self, service, result):
+ if result[0]:
+ parentalControl.unProtectService(service)
+ self.close()
+ else:
+ self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
+
+
def addServiceToBouquetSelected(self):
bouquets = self.csel.getBouquetList()
if bouquets is None:
from Components.Label import Label
from Components.Input import Input
from Components.GUIComponent import *
+from Tools.BoundFunction import boundFunction
import os
class InputBox(Screen):
- def __init__(self, session, title = "", **kwargs):
+ def __init__(self, session, title = "", windowTitle = _("Input"), **kwargs):
Screen.__init__(self, session)
self["text"] = Label(title)
self["input"] = Input(**kwargs)
+ self.onShown.append(boundFunction(self.setTitle, windowTitle))
self["actions"] = NumberActionMap(["WizardActions", "InputBoxActions", "InputAsciiActions", "KeyboardInputActions"],
{
def keyInsert(self):
self["input"].toggleOverwrite()
+
+class PinInput(InputBox):
+ def __init__(self, session, service = "", tries = 1, pinList = [], *args, **kwargs):
+ InputBox.__init__(self, session = session, text="9876", maxSize=True, type=Input.PIN, *args, **kwargs)
+
+ self.showTries = True
+ if tries == 1:
+ self.showTries = False
+
+ self.pinList = pinList
+ self["service"] = Label(service)
+
+ self["tries"] = Label("")
+ self.onShown.append(boundFunction(self.setTries, tries))
+
+ def keyNumberGlobal(self, number):
+ if self["input"].currPos == len(self["input"]) - 1:
+ InputBox.keyNumberGlobal(self, number)
+ self.go()
+ else:
+ InputBox.keyNumberGlobal(self, number)
+
+ def checkPin(self, pin):
+ if pin is not None and int(pin) in self.pinList:
+ return True
+ return False
+
+ def go(self):
+ if self.checkPin(self["input"].getText()):
+ self.close((True, self.tries))
+ else:
+ self.keyHome()
+ self.setTries(self.tries - 1)
+ if self.tries == 0:
+ self.close((False, self.tries))
+ else:
+ pass
+
+ def cancel(self):
+ rcinput = eRCInput.getInstance()
+ rcinput.setKeyboardMode(rcinput.kmNone)
+ self.close((None, self.tries))
+
+ def setTries(self, tries):
+ self.tries = tries
+ if self.showTries:
+ self["tries"].setText(_("Tries left:") + " " + str(tries))
\ No newline at end of file
TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \
Console.py InputBox.py ChoiceBox.py SimpleSummary.py ImageWizard.py \
MediaPlayer.py TimerSelection.py PictureInPicture.py TimeDateInput.py \
- SubtitleDisplay.py SubservicesQuickzap.py NumericalTextInputHelpDialog.py
+ SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py
--- /dev/null
+from Screen import Screen
+from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.ActionMap import NumberActionMap
+from Components.config import config, getConfigListEntry, ConfigNothing, NoSave, ConfigPIN
+from Components.ServiceList import ServiceList
+from Components.ParentalControlList import ParentalControlEntryComponent, ParentalControlList
+from Components.ParentalControl import parentalControl
+from Screens.ChoiceBox import ChoiceBox
+from Screens.MessageBox import MessageBox
+from Screens.InputBox import InputBox, Input, PinInput
+from Tools.Directories import resolveFilename, SCOPE_CONFIG
+from Tools.BoundFunction import boundFunction
+from ServiceReference import ServiceReference
+from enigma import eServiceCenter, eServiceReference
+import os
+import operator
+
+class ProtectedScreen:
+ def __init__(self):
+ if self.isProtected():
+ self.onFirstExecBegin.append(boundFunction(self.session.openWithCallback, self.pinEntered, PinInput, pinList = [self.protectedWithPin()], title = self.getPinText(), windowTitle = _("Change pin code")))
+
+ def getPinText(self):
+ return _("Please enter the correct pin code")
+
+ def isProtected(self):
+ return True
+
+ def protectedWithPin(self):
+ return config.ParentalControl.setuppin.value
+
+ def pinEntered(self, result):
+ if result[0] is None:
+ self.close()
+ if not result[0]:
+ print result, "-", self.protectedWithPin()
+ self.session.openWithCallback(self.close, MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_ERROR)
+
+class ParentalControlSetup(Screen, ConfigListScreen, ProtectedScreen):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+ ProtectedScreen.__init__(self)
+
+ self["actions"] = NumberActionMap(["SetupActions"],
+ {
+ "cancel": self.keyCancel
+ }, -2)
+
+ self.list = []
+ ConfigListScreen.__init__(self, self.list)
+ self.createSetup()
+
+ def isProtected(self):
+ return config.ParentalControl.setuppinactive.value
+
+ def createSetup(self):
+ self.editListEntry = None
+ self.changePin = None
+ self.changeSetupPin = None
+
+ self.list = []
+ self.list.append(getConfigListEntry(_("Enable parental control"), config.ParentalControl.configured))
+ print "config.ParentalControl.configured.value", config.ParentalControl.configured.value
+ if config.ParentalControl.configured.value:
+ #self.list.append(getConfigListEntry(_("Configuration mode"), config.ParentalControl.mode))
+ self.list.append(getConfigListEntry(_("Protect setup"), config.ParentalControl.setuppinactive))
+ if config.ParentalControl.setuppinactive.value:
+ self.changeSetupPin = getConfigListEntry(_("Change setup pin"), NoSave(ConfigNothing()))
+ self.list.append(self.changeSetupPin)
+ self.list.append(getConfigListEntry(_("Protect services"), config.ParentalControl.servicepinactive))
+ if config.ParentalControl.servicepinactive.value:
+ self.list.append(getConfigListEntry(_("Parental control type"), config.ParentalControl.type))
+ if config.ParentalControl.mode.value == "complex":
+ self.changePin = getConfigListEntry(_("Change service pins"), NoSave(ConfigNothing()))
+ self.list.append(self.changePin)
+ elif config.ParentalControl.mode.value == "simple":
+ self.changePin = getConfigListEntry(_("Change service pin"), NoSave(ConfigNothing()))
+ self.list.append(self.changePin)
+ self.list.append(getConfigListEntry(_("Remember service pin"), config.ParentalControl.storeservicepin))
+ self.editListEntry = getConfigListEntry(_("Edit services list"), NoSave(ConfigNothing()))
+ self.list.append(self.editListEntry)
+
+ self["config"].list = self.list
+ self["config"].setList(self.list)
+
+ def keyOK(self):
+ print "self[\"config\"].l.getCurrentSelection()", self["config"].l.getCurrentSelection()
+ if self["config"].l.getCurrentSelection() == self.editListEntry:
+ self.session.open(ParentalControlEditor)
+ elif self["config"].l.getCurrentSelection() == self.changePin:
+ if config.ParentalControl.mode.value == "complex":
+ pass
+ else:
+ self.session.open(ParentalControlChangePin, config.ParentalControl.servicepin[0], _("service pin"))
+ elif self["config"].l.getCurrentSelection() == self.changeSetupPin:
+ self.session.open(ParentalControlChangePin, config.ParentalControl.setuppin, _("setup pin"))
+ else:
+ ConfigListScreen.keyRight(self)
+ print "current selection:", self["config"].l.getCurrentSelection()
+ self.createSetup()
+
+ def keyLeft(self):
+ ConfigListScreen.keyLeft(self)
+ print "current selection:", self["config"].l.getCurrentSelection()
+ self.createSetup()
+
+ def keyRight(self):
+ ConfigListScreen.keyRight(self)
+ print "current selection:", self["config"].l.getCurrentSelection()
+ self.createSetup()
+
+ def keyCancel(self):
+ for x in self["config"].list:
+ x[1].save()
+ self.close()
+
+ def keyNumberGlobal(self, number):
+ pass
+
+class ParentalControlEditor(Screen):
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+ self.list = []
+ self.servicelist = ParentalControlList(self.list)
+ self["servicelist"] = self.servicelist;
+
+ #self.onShown.append(self.chooseLetter)
+ self.currentLetter = ''
+
+ self.readServiceList()
+
+ self["actions"] = NumberActionMap(["DirectionActions", "ColorActions", "OkCancelActions", "NumberActions"],
+ {
+ "ok": self.select,
+ "cancel": self.cancel,
+ "red": self.chooseLetter,
+ #"left": self.keyLeft,
+ #"right": self.keyRight,
+ "1": self.keyNumberGlobal,
+ "2": self.keyNumberGlobal,
+ "3": self.keyNumberGlobal,
+ "4": self.keyNumberGlobal,
+ "5": self.keyNumberGlobal,
+ "6": self.keyNumberGlobal,
+ "7": self.keyNumberGlobal,
+ "8": self.keyNumberGlobal,
+ "9": self.keyNumberGlobal,
+ "0": self.keyNumberGlobal
+ }, -1)
+
+ def cancel(self):
+ parentalControl.save()
+ self.close()
+
+ def select(self):
+ self.servicelist.toggleSelectedLock()
+
+ def keyNumberGlobal(self, number):
+ pass
+
+ def readServiceList(self):
+ serviceHandler = eServiceCenter.getInstance()
+ self.service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17) || (type == 195) || (type == 25)'
+ refstr = '%s ORDER BY name' % (self.service_types_tv)
+ self.root = eServiceReference(refstr)
+
+ self.servicesList = {}
+
+ list = serviceHandler.list(self.root)
+ if list is not None:
+ while 1:
+ s = list.getNext()
+ if s.valid():
+ service = s.toString()
+ name = ServiceReference(service).getServiceName()
+ key = name.lower()[0]
+ if key < 'a' or key > 'z':
+ key = '&'
+ #key = str(key)
+ if not self.servicesList.has_key(key):
+ self.servicesList[key] = []
+ # (servicestring, eServiceRef, name)
+ self.servicesList[key].append((service, s, name))
+ else:
+ break
+ print self.servicesList
+
+ def chooseLetter(self):
+ print "choose letter"
+ list = []
+ for x in self.servicesList.keys():
+ if x == '&':
+ x = ("special characters", x)
+ else:
+ x = (x, x)
+ list.append(x)
+ print "sorted list:", sorted(list, key=operator.itemgetter(1))
+ print self.servicesList.keys()
+ self.session.openWithCallback(self.letterChosen, ChoiceBox, title=_("Show services beginning with"), list=list)
+
+ def letterChosen(self, result):
+ if result is not None:
+ print "result:", result
+ self.currentLetter = result[1]
+ self.list = []
+ for x in self.servicesList[result[1]]:
+ self.list.append(ParentalControlEntryComponent(x[1], x[2], parentalControl.getProtectionLevel(x[1]) != -1))
+ self.servicelist.setList(self.list)
+
+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.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 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)
+
from Screens.ChoiceBox import ChoiceBox
from Screens.MessageBox import MessageBox
-from InfoBarGenerics import InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport
+from InfoBarGenerics import InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarTimeshift, InfoBarSeek, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection
from enigma import eTimer
-class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, Screen):
+class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen):
def __init__(self, session, subservices):
Screen.__init__(self, session)
- for x in [InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions]:
+ for x in [InfoBarShowHide, InfoBarMenu, InfoBarServiceName, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]:
x.__init__(self)
self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
del self.subservices
del self.service
self.lastservice = self.currentlyPlayingSubservice
+ self.session.nav.stopService()
self.session.nav.playService(newservice)
self.currentlyPlayingSubservice = number
self.currentSubserviceNumberLabel.setText(str(number))
"EpgSelection", "EventView", "Standby", "ServiceInfo",
"InfoBarGenerics", "HelpMenu", "Wizard", "PiPSetup",
"PVRState", "Console", "InputBox", "ChoiceBox", "SimpleSummary",
- "TimerSelection", "SubservicesQuickzap" ]
+ "TimerSelection", "SubservicesQuickzap", "ParentalControlSetup" ]
import ServiceReference
+from Components.ParentalControl import InitParentalControl
+InitParentalControl()
+
from Navigation import Navigation
from skin import readSkin, applyAllAttributes
runScreenTest()
plugins.shutdown()
+
+ from Components.ParentalControl import parentalControl
+ parentalControl.save()
except:
print 'EXCEPTION IN PYTHON STARTUP CODE:'
print '-'*60