+ self.current_dialog = None
+
+ def execDialog(self, dialog):
+ self.pushCurrent()
+ self.current_dialog = dialog
+ self.current_dialog.isTmp = False
+ self.current_dialog.callback = None # would cause re-entrancy problems.
+ self.execBegin()
+
+ def openWithCallback(self, callback, screen, *arguments, **kwargs):
+ dlg = self.open(screen, *arguments, **kwargs)
+ dlg.callback = callback
+ return dlg
+
+ def open(self, screen, *arguments, **kwargs):
+ if self.dialog_stack and not self.in_exec:
+ raise RuntimeError("modal open are allowed only from a screen which is modal!")
+ # ...unless it's the very first screen.
+
+ self.pushCurrent()
+ dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
+ dlg.isTmp = True
+ dlg.callback = None
+ self.execBegin()
+ return dlg
+
+ def close(self, screen, *retval):
+ if not self.in_exec:
+ print "close after exec!"
+ return
+
+ # be sure that the close is for the right dialog!
+ # if it's not, you probably closed after another dialog
+ # was opened. this can happen if you open a dialog
+ # onExecBegin, and forget to do this only once.
+ # after close of the top dialog, the underlying will
+ # gain focus again (for a short time), thus triggering
+ # the onExec, which opens the dialog again, closing the loop.
+ assert screen == self.current_dialog
+
+ self.current_dialog.returnValue = retval
+ self.delay_timer.start(0, 1)
+ self.execEnd()
+
+ def pushSummary(self):
+ if self.summary is not None:
+ self.summary.hide()
+ self.summary_stack.append(self.summary)
+ self.summary = None
+
+ def popSummary(self):
+ if self.summary is not None:
+ self.summary.doClose()
+ self.summary = self.summary_stack.pop()
+ if self.summary is not None:
+ self.summary.show()
+
+profile("Standby,PowerKey")
+import Screens.Standby
+from Screens.Menu import MainMenu, mdom
+from GlobalActions import globalActionMap
+
+class PowerKey:
+ """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
+
+ def __init__(self, session):
+ self.session = session
+ globalActionMap.actions["power_down"]=self.powerdown
+ globalActionMap.actions["power_up"]=self.powerup
+ globalActionMap.actions["power_long"]=self.powerlong
+ globalActionMap.actions["deepstandby"]=self.shutdown # frontpanel long power button press
+ self.standbyblocked = 1
+
+ def MenuClosed(self, *val):
+ self.session.infobar = None
+
+ def shutdown(self):
+ print "PowerOff - Now!"
+ if not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
+ self.session.open(Screens.Standby.TryQuitMainloop, 1)
+
+ def powerlong(self):
+ if Screens.Standby.inTryQuitMainloop or (self.session.current_dialog and not self.session.current_dialog.ALLOW_SUSPEND):
+ return
+ self.doAction(action = config.usage.on_long_powerpress.value)
+
+ def doAction(self, action):
+ self.standbyblocked = 1
+ if action == "shutdown":
+ self.shutdown()
+ elif action == "show_menu":
+ print "Show shutdown Menu"
+ root = mdom.getroot()
+ for x in root.findall("menu"):
+ y = x.find("id")
+ if y is not None:
+ id = y.get("val")
+ if id and id == "shutdown":
+ self.session.infobar = self
+ menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x)
+ menu_screen.setTitle(_("Standby / Restart"))
+ return
+ elif action == "standby":
+ self.standby()
+
+ def powerdown(self):
+ self.standbyblocked = 0
+
+ def powerup(self):
+ if self.standbyblocked == 0:
+ self.doAction(action = config.usage.on_short_powerpress.value)
+
+ def standby(self):
+ if not Screens.Standby.inStandby and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND and self.session.in_exec:
+ self.session.open(Screens.Standby.Standby)
+
+profile("Scart")
+from Screens.Scart import Scart
+
+class AutoScartControl:
+ def __init__(self, session):
+ self.force = False
+ self.current_vcr_sb = eAVSwitch.getInstance().getVCRSlowBlanking()
+ if self.current_vcr_sb and config.av.vcrswitch.value:
+ self.scartDialog = session.instantiateDialog(Scart, True)
+ else:
+ self.scartDialog = session.instantiateDialog(Scart, False)
+ config.av.vcrswitch.addNotifier(self.recheckVCRSb)
+ eAVSwitch.getInstance().vcr_sb_notifier.get().append(self.VCRSbChanged)
+
+ def recheckVCRSb(self, configElement):
+ self.VCRSbChanged(self.current_vcr_sb)
+
+ def VCRSbChanged(self, value):
+ #print "vcr sb changed to", value
+ self.current_vcr_sb = value
+ if config.av.vcrswitch.value or value > 2:
+ if value:
+ self.scartDialog.showMessageBox()
+ else:
+ self.scartDialog.switchToTV()
+
+profile("Load:CI")
+from enigma import eDVBCIInterfaces
+from Screens.Ci import CiHandler
+
+profile("Load:VolumeControl")
+from Components.VolumeControl import VolumeControl
+
+def runScreenTest():
+ config.misc.startCounter.value += 1
+
+ profile("readPluginList")
+ plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
+
+ profile("Init:Session")
+ nav = Navigation(config.misc.isNextRecordTimerAfterEventActionAuto.value)
+ session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = nav)
+
+ CiHandler.setSession(session)
+
+ screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
+
+ profile("wizards")
+ screensToRun += wizardManager.getWizards()
+
+ screensToRun.append((100, Screens.InfoBar.InfoBar))
+
+ screensToRun.sort()
+
+ ePythonConfigQuery.setQueryFunc(configfile.getResolvedKey)
+
+# eDVBCIInterfaces.getInstance().setDescrambleRules(0 # Slot Number
+# ,( ["1:0:1:24:4:85:C00000:0:0:0:"], #service_list
+# ["PREMIERE"], #provider_list,
+# [] #caid_list
+# ));
+
+ def runNextScreen(session, screensToRun, *result):
+ if result:
+ quitMainloop(*result)
+ return
+
+ screen = screensToRun[0][1]
+ args = screensToRun[0][2:]
+
+ if screensToRun:
+ session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args)
+ else:
+ session.open(screen, *args)
+
+ runNextScreen(session, screensToRun)
+
+ profile("Init:VolumeControl")
+ vol = VolumeControl(session)
+ profile("Init:PowerKey")
+ power = PowerKey(session)
+
+ # we need session.scart to access it from within menu.xml
+ session.scart = AutoScartControl(session)
+
+ profile("RunReactor")
+ profile_final()
+ runReactor()
+
+ config.misc.startCounter.save()
+
+ profile("wakeup")
+ from time import time, strftime, localtime
+ from Tools.DreamboxHardware import setFPWakeuptime, getFPWakeuptime, setRTCtime
+ #get currentTime
+ nowTime = time()
+ wakeupList = [
+ x for x in ((session.nav.RecordTimer.getNextRecordingTime(), 0, session.nav.RecordTimer.isNextRecordAfterEventActionAuto()),
+ (session.nav.RecordTimer.getNextZapTime(), 1),
+ (plugins.getNextWakeupTime(), 2))
+ if x[0] != -1
+ ]
+ wakeupList.sort()
+ recordTimerWakeupAuto = False
+ if wakeupList:
+ from time import strftime
+ startTime = wakeupList[0]
+ if (startTime[0] - nowTime) < 270: # no time to switch box back on
+ wptime = nowTime + 30 # so switch back on in 30 seconds
+ else:
+ wptime = startTime[0] - 240
+ if not config.misc.useTransponderTime.value:
+ print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
+ setRTCtime(nowTime)
+ print "set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime))
+ setFPWakeuptime(wptime)
+ recordTimerWakeupAuto = startTime[1] == 0 and startTime[2]
+ config.misc.isNextRecordTimerAfterEventActionAuto.value = recordTimerWakeupAuto
+ config.misc.isNextRecordTimerAfterEventActionAuto.save()
+
+ profile("stopService")
+ session.nav.stopService()
+ profile("nav shutdown")
+ session.nav.shutdown()
+
+ profile("configfile.save")
+ configfile.save()
+