Add some parental control improvements (made by Tode)
[enigma2.git] / lib / python / Screens / Ci.py
index d19386b21ef7d9b46df2eb2479b3d9d374e4ffe2..0fb0feeb19a366d9a01dbe5830ef84bee2e06f7b 100644 (file)
@@ -6,15 +6,27 @@ from Components.Label import Label
 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSubList, getConfigListEntry, KEY_LEFT, KEY_RIGHT, KEY_0, ConfigNothing, ConfigPIN
 from Components.ConfigList import ConfigList
 
-from enigma import eTimer, eDVBCI_UI
+from Components.SystemInfo import SystemInfo
+
+from enigma import eTimer, eDVBCI_UI, eDVBCIInterfaces
 
 MAX_NUM_CI = 4
 
+def setCIBitrate(configElement):
+       if configElement.value == "no":
+               eDVBCI_UI.getInstance().setClockRate(configElement.slotid, eDVBCI_UI.rateNormal)
+       else:
+               eDVBCI_UI.getInstance().setClockRate(configElement.slotid, eDVBCI_UI.rateHigh)
+
 def InitCiConfig():
        config.ci = ConfigSubList()
        for slot in range(MAX_NUM_CI):
                config.ci.append(ConfigSubsection())
                config.ci[slot].canDescrambleMultipleServices = ConfigSelection(choices = [("auto", _("Auto")), ("no", _("No")), ("yes", _("Yes"))], default = "auto")
+               if SystemInfo["CommonInterfaceSupportsHighBitrates"]:
+                       config.ci[slot].canHandleHighBitrates = ConfigSelection(choices = [("no", _("No")), ("yes", _("Yes"))], default = "no")
+                       config.ci[slot].canHandleHighBitrates.slotid = slot
+                       config.ci[slot].canHandleHighBitrates.addNotifier(setCIBitrate)
 
 class MMIDialog(Screen):
        def __init__(self, session, slotid, action, handler = eDVBCI_UI.getInstance(), wait_text = _("wait for ci...") ):
@@ -27,7 +39,7 @@ class MMIDialog(Screen):
                self.slotid = slotid
 
                self.timer = eTimer()
-               self.timer.timeout.get().append(self.keyCancel)
+               self.timer.callback.append(self.keyCancel)
 
                #else the skins fails
                self["title"] = Label("")
@@ -119,7 +131,7 @@ class MMIDialog(Screen):
                elif self.tag == "WAIT":
                        self.handler.stopMMI(self.slotid)
                        self.closeMmi()
-               elif self.tag in [ "MENU", "LIST" ]:
+               elif self.tag in ( "MENU", "LIST" ):
                        print "cancel list"
                        self.handler.answerMenu(self.slotid, 0)
                        self.showWait()
@@ -224,6 +236,13 @@ class CiMessageHandler:
                self.ci = { }
                self.dlgs = { }
                eDVBCI_UI.getInstance().ciStateChanged.get().append(self.ciStateChanged)
+               SystemInfo["CommonInterface"] = eDVBCIInterfaces.getInstance().getNumOfSlots() > 0
+               try:
+                       file = open("/proc/stb/tsmux/ci0_tsclk", "r")
+                       file.close()
+                       SystemInfo["CommonInterfaceSupportsHighBitrates"] = True
+               except:
+                       SystemInfo["CommonInterfaceSupportsHighBitrates"] = False
 
        def setSession(self, session):
                self.session = session
@@ -282,7 +301,7 @@ class CiSelection(Screen):
 
        def selectionChanged(self):
                cur_idx = self["entries"].getCurrentIndex()
-               self["text"].setText(_("Slot %d")%((cur_idx / 4)+1))
+               self["text"].setText(_("Slot %d")%((cur_idx / 5)+1))
 
        def keyConfigEntry(self, key):
                try:
@@ -312,6 +331,8 @@ class CiSelection(Screen):
                        self.list.append( (appname, ConfigNothing(), 2, slot) )
 
                self.list.append(getConfigListEntry(_("Multiple service support"), config.ci[slot].canDescrambleMultipleServices))
+               if SystemInfo["CommonInterfaceSupportsHighBitrates"]:
+                       self.list.append(getConfigListEntry(_("High bitrate support"), config.ci[slot].canHandleHighBitrates))
 
        def updateState(self, slot):
                state = eDVBCI_UI.getInstance().getState(slot)