1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.config import config
4 from Components.AVSwitch import AVSwitch
5 from Components.SystemInfo import SystemInfo
6 from enigma import eDVBVolumecontrol
10 class Standby(Screen):
14 self.avswitch.setInput("ENCODER")
15 #restart last played service
18 #set brightness of lcd
19 config.lcd.bright.apply()
24 if (eDVBVolumecontrol.getInstance().isMuted()):
26 print "mute already active"
29 eDVBVolumecontrol.getInstance().volumeToggleMute()
32 if self.wasMuted == 0:
33 eDVBVolumecontrol.getInstance().volumeToggleMute()
35 def __init__(self, session):
36 Screen.__init__(self, session)
37 self.avswitch = AVSwitch()
41 self["actions"] = ActionMap( [ "StandbyActions" ],
49 self.paused_service = None
50 self.prev_running_service = None
51 if self.session.current_dialog:
52 if self.session.current_dialog.ALLOW_SUSPEND == Screen.SUSPEND_STOPS:
53 #get currently playing service reference
54 self.prev_running_service = self.session.nav.getCurrentlyPlayingServiceReference()
55 #stop actual played dvb-service
56 self.session.nav.stopService()
57 elif self.session.current_dialog.ALLOW_SUSPEND == Screen.SUSPEND_PAUSES:
58 self.paused_service = self.session.current_dialog
59 self.paused_service.pauseService()
61 #set input to vcr scart
62 if SystemInfo["ScartSwitch"]:
63 self.avswitch.setInput("SCART")
65 self.avswitch.setInput("AUX")
66 #set lcd brightness to standby value
67 config.lcd.standby.apply()
68 self.onFirstExecBegin.append(self.__onFirstExecBegin)
69 self.onClose.append(self.__onClose)
74 if self.prev_running_service:
75 self.session.nav.playService(self.prev_running_service)
76 elif self.paused_service:
77 self.paused_service.unPauseService()
78 self.session.screen["Standby"].boolean = False
80 def __onFirstExecBegin(self):
83 self.session.screen["Standby"].boolean = True
84 config.misc.standbyCounter.value += 1
86 def createSummary(self):
89 class StandbySummary(Screen):
91 <screen position="0,0" size="132,64">
92 <widget source="global.CurrentTime" render="Label" position="0,0" size="132,64" font="Regular;40" halign="center">
93 <convert type="ClockToText" />
95 <widget source="session.RecordState" render="FixedLabel" text=" " position="0,0" size="132,64" zPosition="1" >
96 <convert type="ConfigEntryTest">config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean</convert>
97 <convert type="ConditionalShowHide">Blink</convert>
101 from enigma import quitMainloop, iRecordableService
102 from Screens.MessageBox import MessageBox
103 from time import time
104 from Components.Task import job_manager
106 inTryQuitMainloop = False
108 class TryQuitMainloop(MessageBox):
109 def __init__(self, session, retvalue=1, timeout=-1, default_yes = True):
111 recordings = session.nav.getRecordings()
112 jobs = len(job_manager.getPendingJobs())
113 self.connected = False
117 next_rec_time = session.nav.RecordTimer.getNextRecordingTime()
118 if recordings or (next_rec_time > 0 and (next_rec_time - time()) < 360):
119 reason = _("Recording(s) are in progress or coming up in few seconds!") + '\n'
122 job = job_manager.getPendingJobs()[0]
123 reason += "%s: %s (%d%%)\n" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end)))
125 reason += (_("%d jobs are running in the background!") % jobs) + '\n'
128 MessageBox.__init__(self, session, reason+_("Really shutdown now?"), type = MessageBox.TYPE_YESNO, timeout = timeout, default = default_yes)
130 MessageBox.__init__(self, session, reason+_("Really reboot now?"), type = MessageBox.TYPE_YESNO, timeout = timeout, default = default_yes)
134 MessageBox.__init__(self, session, reason+_("Really restart now?"), type = MessageBox.TYPE_YESNO, timeout = timeout, default = default_yes)
135 self.skinName = "MessageBox"
136 session.nav.record_event.append(self.getRecordEvent)
137 self.connected = True
138 self.onShow.append(self.__onShow)
139 self.onHide.append(self.__onHide)
141 self.skin = """<screen position="0,0" size="0,0"/>"""
142 Screen.__init__(self, session)
145 def getRecordEvent(self, recservice, event):
146 if event == iRecordableService.evEnd:
147 recordings = self.session.nav.getRecordings()
148 if not recordings: # no more recordings exist
149 rec_time = self.session.nav.RecordTimer.getNextRecordingTime()
150 if rec_time > 0 and (rec_time - time()) < 360:
151 self.initTimeout(360) # wait for next starting timer
154 self.close(True) # immediate shutdown
155 elif event == iRecordableService.evStart:
158 def close(self, value):
160 self.conntected=False
161 self.session.nav.record_event.remove(self.getRecordEvent)
163 # hack .. we dont like to show any other screens when this screen has closed
164 self.onClose = [self.__closed]
165 self.session.dialog_stack = []
166 self.session.summary_stack = [None]
167 MessageBox.close(self, True)
170 quitMainloop(self.retval)
173 global inTryQuitMainloop
174 inTryQuitMainloop = True
177 global inTryQuitMainloop
178 inTryQuitMainloop = False