aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Screens
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/Screens')
-rw-r--r--lib/python/Screens/ChannelSelection.py25
-rw-r--r--lib/python/Screens/InputBox.py51
-rw-r--r--lib/python/Screens/Makefile.am2
-rw-r--r--lib/python/Screens/ParentalControlSetup.py264
-rw-r--r--lib/python/Screens/SubservicesQuickzap.py7
-rw-r--r--lib/python/Screens/__init__.py2
6 files changed, 344 insertions, 7 deletions
diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py
index 6c3abb5d..58c57f41 100644
--- a/lib/python/Screens/ChannelSelection.py
+++ b/lib/python/Screens/ChannelSelection.py
@@ -11,8 +11,11 @@ from Tools.NumericalTextInput import NumericalTextInput
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
@@ -75,6 +78,11 @@ class ChannelContextMenu(Screen):
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:
@@ -130,6 +138,21 @@ class ChannelContextMenu(Screen):
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:
diff --git a/lib/python/Screens/InputBox.py b/lib/python/Screens/InputBox.py
index 558cbc01..e73215c3 100644
--- a/lib/python/Screens/InputBox.py
+++ b/lib/python/Screens/InputBox.py
@@ -5,15 +5,17 @@ from Components.ActionMap import NumberActionMap
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"],
{
@@ -85,3 +87,50 @@ class InputBox(Screen):
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
diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am
index 0d253d5e..4abfcd1f 100644
--- a/lib/python/Screens/Makefile.am
+++ b/lib/python/Screens/Makefile.am
@@ -11,4 +11,4 @@ install_PYTHON = \
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
diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py
new file mode 100644
index 00000000..2a907466
--- /dev/null
+++ b/lib/python/Screens/ParentalControlSetup.py
@@ -0,0 +1,264 @@
+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)
+
diff --git a/lib/python/Screens/SubservicesQuickzap.py b/lib/python/Screens/SubservicesQuickzap.py
index 07e35e36..09f2e727 100644
--- a/lib/python/Screens/SubservicesQuickzap.py
+++ b/lib/python/Screens/SubservicesQuickzap.py
@@ -4,14 +4,14 @@ from Components.Label import Label
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()
@@ -118,6 +118,7 @@ class SubservicesQuickzap(InfoBarShowHide, InfoBarMenu, InfoBarServiceName, Info
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))
diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py
index 3cb12226..5eac3b16 100644
--- a/lib/python/Screens/__init__.py
+++ b/lib/python/Screens/__init__.py
@@ -6,4 +6,4 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu",
"EpgSelection", "EventView", "Standby", "ServiceInfo",
"InfoBarGenerics", "HelpMenu", "Wizard", "PiPSetup",
"PVRState", "Console", "InputBox", "ChoiceBox", "SimpleSummary",
- "TimerSelection", "SubservicesQuickzap" ]
+ "TimerSelection", "SubservicesQuickzap", "ParentalControlSetup" ]