5 from enigma import quitMainloop
7 from Tools import Notifications
9 from Components.config import config, ConfigYesNo, ConfigSelection, ConfigSubsection
11 from Screens.MessageBox import MessageBox
12 from Screens.Standby import Standby
14 class SleepTimerEntry(timer.TimerEntry):
15 def __init__(self, begin):
16 timer.TimerEntry.__init__(self, int(begin), int(begin))
20 def getNextActivation(self):
24 if self.state == self.StateRunning:
25 if config.SleepTimer.action.value == "shutdown":
26 if config.SleepTimer.ask.value:
27 Notifications.AddNotificationWithCallback(self.shutdown, MessageBox, _("A sleep timer want's to shut down\nyour Dreambox. Shutdown now?"), timeout = 20)
30 elif config.SleepTimer.action.value == "standby":
31 if config.SleepTimer.ask.value:
32 Notifications.AddNotificationWithCallback(self.standby, MessageBox, _("A sleep timer want's to set your\nDreambox to standby. Do that now?"), timeout = 20)
41 def shutdown(self, answer):
42 if answer is not None:
46 def standby(self, answer):
47 if answer is not None:
49 Notifications.AddNotification(Standby, self)
51 class SleepTimer(timer.Timer):
53 config.SleepTimer = ConfigSubsection()
54 config.SleepTimer.ask = ConfigYesNo(default = True)
55 config.SleepTimer.action = ConfigSelection(default = "shutdown", choices = [("shutdown", _("shutdown")), ("standby", _("standby"))])
57 timer.Timer.__init__(self)
60 def setSleepTime(self, sleeptime):
62 self.addTimerEntry(SleepTimerEntry(time.time() + 60 * sleeptime))
67 def getCurrentSleepTime(self):
68 if (self.getNextRecordingTime() == -1):
69 return self.defaultTime
70 return int(math.ceil((self.getNextRecordingTime() - time.time()) / 60))
73 return len(self.timer_list) > 0