def ipkgCallback(self, event, param):
     if event == IpkgComponent.EVENT_DONE:
         if self.updating:
             self.updating = False
             self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE_LIST)
         elif self.ipkg.currentCommand == IpkgComponent.CMD_UPGRADE_LIST:
             self.total_packages = len(self.ipkg.getFetchedList())
             print('[OnlineVersionCheck] %s updates available' %
                   self.total_packages)
             if self.total_packages:
                 config.softwareupdate.updatefound.setValue(True)
                 if not versioncheck.user_notified:
                     versioncheck.user_notified = True
                     msg = _("Online update available.\n")
                     if self.total_packages > 100:
                         msg += _(
                             "\nThis is a large update. Consider a full USB update instead.\n"
                         )
                     msg += _("\nInstall now?\n")
                     default = self.total_packages <= 100
                     Notifications.AddNotificationWithUniqueIDCallback(
                         self.updateNotificationAnswer,
                         "OnlineUpdateAvailable",
                         SuspendableMessageBox,
                         msg,
                         default=default)
             else:
                 config.softwareupdate.updatefound.setValue(False)
         else:
             config.softwareupdate.updatefound.setValue(False)
Esempio n. 2
0
    def activate(self):
        next_state = self.state + 1
        self.log(5, "activating state %d" % next_state)

        if next_state == self.StatePrepared and (
                self.timerType == TIMERTYPE.AUTOSTANDBY
                or self.timerType == TIMERTYPE.AUTODEEPSTANDBY):

            # This is the first action for an auto* timer.
            # It binds any key press to keyPressed(), which resets the timer delay,
            # and sets the initial delay.

            eActionMap.getInstance().bindAction('', -0x7FFFFFFF,
                                                self.keyPressed)
            self.begin = time() + int(self.autosleepdelay) * 60
            if self.end <= self.begin:
                self.end = self.begin

        if next_state == self.StatePrepared:
            self.log(6, "prepare ok, waiting for begin")
            self.next_activation = self.begin
            self.backoff = 0
            return True

        elif next_state == self.StateRunning:
            self.wasPowerTimerWakeup = False
            if os.path.exists("/tmp/was_powertimer_wakeup"):
                self.wasPowerTimerWakeup = int(
                    open("/tmp/was_powertimer_wakeup",
                         "r").read()) and True or False
                os.remove("/tmp/was_powertimer_wakeup")
            # if this timer has been cancelled, just go to "end" state.
            if self.cancelled:
                return True

            if self.failed:
                return True

            if self.timerType == TIMERTYPE.WAKEUP:
                if Screens.Standby.inStandby:
                    Screens.Standby.inStandby.Power()
                return True

            elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:
                return True

            elif self.timerType == TIMERTYPE.STANDBY:
                if not Screens.Standby.inStandby:  # not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
                return True

            elif self.timerType == TIMERTYPE.AUTOSTANDBY:
                if NavigationInstance.instance.getCurrentlyPlayingServiceReference(
                ) and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()
                       or '4097:' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()):
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inStandby:  # not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
                    if self.autosleeprepeat == "once":
                        eActionMap.getInstance().unbindAction(
                            '', self.keyPressed)
                        return True
                    else:
                        self.begin = time() + int(self.autosleepdelay) * 60
                        if self.end <= self.begin:
                            self.end = self.begin
                else:
                    self.begin = time() + int(self.autosleepdelay) * 60
                    if self.end <= self.begin:
                        self.end = self.begin

            elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY:

                # Check for there being any active Movie playback or IPTV channel
                # or any streaming clients before going to Deep Standby.
                # However, it is possible to put the box into Standby with the
                # MoviePlayer still active (it will play if the box is taken out
                # of Standby) - similarly for the IPTV player. This should not
                # prevent a DeepStandby
                # And check for existing or imminent recordings, etc..
                # Also added () around the test and split them across lines
                # to make it clearer what each test is.

                from Components.Converter.ClientsStreaming import ClientsStreaming
                if ((not Screens.Standby.inStandby and NavigationInstance.
                     instance.getCurrentlyPlayingServiceReference() and
                     ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()
                      or '4097:' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()) or
                     (int(ClientsStreaming("NUMBER").getText()) > 0)) or
                    (NavigationInstance.instance.RecordTimer.isRecording()
                     or abs(NavigationInstance.instance.RecordTimer.
                            getNextRecordingTime() - time()) <= 900
                     or abs(NavigationInstance.instance.RecordTimer.
                            getNextZapTime() - time()) <= 900)
                        or (self.autosleepinstandbyonly == 'yes'
                            and not Screens.Standby.inStandby)
                        or (self.autosleepinstandbyonly == 'yes'
                            and Screens.Standby.inStandby
                            and internalHDDNotSleeping())):
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # not a shutdown messagebox is open
                    if Screens.Standby.inStandby:  # in standby
                        quitMainloop(1)
                        return True
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
                        if self.autosleeprepeat == "once":
                            eActionMap.getInstance().unbindAction(
                                '', self.keyPressed)
                            return True
                        else:
                            self.begin = time() + int(self.autosleepdelay) * 60
                            if self.end <= self.begin:
                                self.end = self.begin

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and self.wasPowerTimerWakeup:
                return True

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and not self.wasPowerTimerWakeup:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # not a shutdown messagebox is open
                    if Screens.Standby.inStandby:  # in standby
                        quitMainloop(1)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.REBOOT:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # not a shutdown messagebox is open
                    if Screens.Standby.inStandby:  # in standby
                        quitMainloop(2)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRebootNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to reboot your receiver. Do that now?"
                              ),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.RESTART:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # not a shutdown messagebox is open
                    if Screens.Standby.inStandby:  # in standby
                        quitMainloop(3)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRestartNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to restart the user interface.\nDo that now?"
                              ),
                            timeout=180)
                return True

        elif next_state == self.StateEnded:
            old_end = self.end
            NavigationInstance.instance.PowerTimer.saveTimer()
            if self.afterEvent == AFTEREVENT.STANDBY:
                if not Screens.Standby.inStandby:  # not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
            elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    # retry
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # not a shutdown messagebox is open
                    if Screens.Standby.inStandby:  # in standby
                        quitMainloop(1)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
            return True
    def activate(self):
        next_state = self.state + 1
        self.log(5, "activating state %d" % next_state)

        if next_state == self.StatePrepared and (
                self.timerType == TIMERTYPE.AUTOSTANDBY
                or self.timerType == TIMERTYPE.AUTODEEPSTANDBY):

            eActionMap.getInstance().bindAction('', -0x7FFFFFFF,
                                                self.keyPressed)
            self.begin = time() + int(self.autosleepdelay) * 60
            if self.end <= self.begin:
                self.end = self.begin

        if next_state == self.StatePrepared:
            self.log(6, "prepare ok, waiting for begin")
            self.next_activation = self.begin
            self.backoff = 0
            return True

        elif next_state == self.StateRunning:
            self.wasPowerTimerWakeup = False
            if os.path.exists("/tmp/was_powertimer_wakeup"):
                self.wasPowerTimerWakeup = int(
                    open("/tmp/was_powertimer_wakeup",
                         "r").read()) and True or False
                os.remove("/tmp/was_powertimer_wakeup")
            if self.cancelled:
                return True

            if self.failed:
                return True

            if self.timerType == TIMERTYPE.WAKEUP:
                if Screens.Standby.inStandby:
                    Screens.Standby.inStandby.Power()
                return True

            elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:
                return True

            elif self.timerType == TIMERTYPE.STANDBY:
                if not Screens.Standby.inStandby:
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
                return True

            elif self.timerType == TIMERTYPE.AUTOSTANDBY:
                if NavigationInstance.instance.getCurrentlyPlayingServiceReference(
                ) and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()
                       or '4097:' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()):
                    self.do_backoff()
                    return False
                if not Screens.Standby.inStandby:
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
                    if self.autosleeprepeat == "once":
                        eActionMap.getInstance().unbindAction(
                            '', self.keyPressed)
                        return True
                    else:
                        self.begin = time() + int(self.autosleepdelay) * 60
                        if self.end <= self.begin:
                            self.end = self.begin
                else:
                    self.begin = time() + int(self.autosleepdelay) * 60
                    if self.end <= self.begin:
                        self.end = self.begin

            elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY:

                from Components.Converter.ClientsStreaming import ClientsStreaming
                if ((not Screens.Standby.inStandby and NavigationInstance.
                     instance.getCurrentlyPlayingServiceReference() and
                     ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()
                      or '4097:' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()) or
                     (int(ClientsStreaming("NUMBER").getText()) > 0)) or
                    (NavigationInstance.instance.RecordTimer.isRecording()
                     or abs(NavigationInstance.instance.RecordTimer.
                            getNextRecordingTime() - time()) <= 900
                     or abs(NavigationInstance.instance.RecordTimer.
                            getNextZapTime() - time()) <= 900)
                        or (self.autosleepinstandbyonly == 'yes'
                            and not Screens.Standby.inStandby)
                        or (self.autosleepinstandbyonly == 'yes'
                            and Screens.Standby.inStandby
                            and internalHDDNotSleeping())):
                    self.do_backoff()
                    return False
                if not Screens.Standby.inTryQuitMainloop:
                    if Screens.Standby.inStandby:
                        quitMainloop(1)
                        return True
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
                        if self.autosleeprepeat == "once":
                            eActionMap.getInstance().unbindAction(
                                '', self.keyPressed)
                            return True
                        else:
                            self.begin = time() + int(self.autosleepdelay) * 60
                            if self.end <= self.begin:
                                self.end = self.begin

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and self.wasPowerTimerWakeup:
                return True

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and not self.wasPowerTimerWakeup:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    return False
                if not Screens.Standby.inTryQuitMainloop:
                    if Screens.Standby.inStandby:
                        quitMainloop(1)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.REBOOT:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    return False
                if not Screens.Standby.inTryQuitMainloop:
                    if Screens.Standby.inStandby:
                        quitMainloop(2)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRebootNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to reboot your receiver. Do that now?"
                              ),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.RESTART:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    return False
                if not Screens.Standby.inTryQuitMainloop:
                    if Screens.Standby.inStandby:
                        quitMainloop(3)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRestartNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to restart the user interface.\nDo that now?"
                              ),
                            timeout=180)
                return True

        elif next_state == self.StateEnded:
            old_end = self.end
            NavigationInstance.instance.PowerTimer.saveTimer()
            if self.afterEvent == AFTEREVENT.STANDBY:
                if not Screens.Standby.inStandby:
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A finished powertimer wants to set your receiver to standby. Do that now?"
                          ),
                        timeout=180)
            elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
                if NavigationInstance.instance.RecordTimer.isRecording(
                ) or abs(NavigationInstance.instance.RecordTimer.
                         getNextRecordingTime() -
                         time()) <= 900 or abs(NavigationInstance.instance.
                                               RecordTimer.getNextZapTime() -
                                               time()) <= 900:
                    self.do_backoff()
                    return False
                if not Screens.Standby.inTryQuitMainloop:
                    if Screens.Standby.inStandby:
                        quitMainloop(1)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A finished powertimer wants to shutdown your receiver. Do that now?"
                              ),
                            timeout=180)
            return True
Esempio n. 4
0
    def activate(self):
        next_state = self.state + 1
        self.log(5, "activating state %d" % next_state)

        if next_state == self.StatePrepared and self.timerType in (
                TIMERTYPE.AUTOSTANDBY, TIMERTYPE.AUTODEEPSTANDBY):
            eActionMap.getInstance().bindAction('', -0x7FFFFFFF,
                                                self.keyPressed)
            self.begin = time() + int(self.autosleepdelay) * 60
            if self.end <= self.begin:
                self.end = self.begin

        if next_state == self.StatePrepared:
            self.log(6, "prepare ok, waiting for begin")
            self.next_activation = self.begin
            self.backoff = 0
            return True

        elif next_state == self.StateRunning:
            self.wasPowerTimerWakeup = False
            if os.path.exists("/tmp/was_powertimer_wakeup"):
                self.wasPowerTimerWakeup = bool(
                    int(open("/tmp/was_powertimer_wakeup", "r").read()))
                os.remove("/tmp/was_powertimer_wakeup")
            # If this timer has been cancelled or has failed,
            # just go to "end" state.
            if self.cancelled:
                return True

            if self.failed:
                return True

            if self.timerType == TIMERTYPE.WAKEUP:
                if Screens.Standby.inStandby:
                    Screens.Standby.inStandby.Power()
                return True

            elif self.timerType == TIMERTYPE.WAKEUPTOSTANDBY:
                return True

            elif self.timerType == TIMERTYPE.STANDBY:
                if not Screens.Standby.inStandby:  # Not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
                return True

            elif self.timerType == TIMERTYPE.AUTOSTANDBY:
                if NavigationInstance.instance.getCurrentlyPlayingServiceReference(
                ) and ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()
                       or '4097:' in NavigationInstance.instance.
                       getCurrentlyPlayingServiceReference().toString()):
                    self.do_backoff()
                    # retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inStandby:  # Not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
                    if self.autosleeprepeat == "once":
                        eActionMap.getInstance().unbindAction(
                            '', self.keyPressed)
                        return True
                    else:
                        self.begin = time() + int(self.autosleepdelay) * 60
                        if self.end <= self.begin:
                            self.end = self.begin
                else:
                    self.begin = time() + int(self.autosleepdelay) * 60
                    if self.end <= self.begin:
                        self.end = self.begin

            elif self.timerType == TIMERTYPE.AUTODEEPSTANDBY:
                # Check for there being any active
                # Movie playback or IPTV channel or
                # any streaming clients before going
                # to Deep Standby.  However, it is
                # possible to put the box into Standby
                # with the MoviePlayer still active
                # (it will play if the box is taken
                # out of Standby) - similarly for the
                # IPTV player. This should not prevent
                # a DeepStandby And check for existing
                # or imminent recordings, etc..  Also
                # added () around the test and split
                # them across lines to make it clearer
                # what each test is.
                from Components.Converter.ClientsStreaming import ClientsStreaming
                if ((not Screens.Standby.inStandby and NavigationInstance.
                     instance.getCurrentlyPlayingServiceReference() and
                     ('0:0:0:0:0:0:0:0:0' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()
                      or '4097:' in NavigationInstance.instance.
                      getCurrentlyPlayingServiceReference().toString()) or
                     (int(ClientsStreaming("NUMBER").getText()) > 0))
                        or recordingsActive(900)
                        or (self.autosleepinstandbyonly == 'yes'
                            and not Screens.Standby.inStandby)
                        or (self.autosleepinstandbyonly == 'yes'
                            and Screens.Standby.inStandby
                            and internalHDDNotSleeping())):
                    self.do_backoff()
                    # Retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # The shutdown messagebox is not open
                    if Screens.Standby.inStandby:  # In standby
                        quitMainloop(Screens.Standby.QUIT_SHUTDOWN)
                        return True
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                        if self.autosleeprepeat == "once":
                            eActionMap.getInstance().unbindAction(
                                '', self.keyPressed)
                            return True
                        else:
                            self.begin = time() + int(self.autosleepdelay) * 60
                            if self.end <= self.begin:
                                self.end = self.begin

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and self.wasPowerTimerWakeup:
                return True

            elif self.timerType == TIMERTYPE.DEEPSTANDBY and not self.wasPowerTimerWakeup:
                if recordingsActive(900):
                    self.do_backoff()
                    # Retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # The shutdown messagebox is not open
                    if Screens.Standby.inStandby:  # In standby
                        quitMainloop(Screens.Standby.QUIT_SHUTDOWN)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.REBOOT:
                if recordingsActive(900):
                    self.do_backoff()
                    # Retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # The shutdown messagebox is not open
                    if Screens.Standby.inStandby:  # In standby
                        quitMainloop(Screens.Standby.QUIT_REBOOT)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRebootNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to reboot your %s %s.\nReboot now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                return True

            elif self.timerType == TIMERTYPE.RESTART:
                if recordingsActive(900):
                    self.do_backoff()
                    # Retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # The shutdown messagebox is not open
                    if Screens.Standby.inStandby:  # In standby
                        quitMainloop(Screens.Standby.QUIT_RESTART)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryToRestartNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to restart your %s %s user interface.\nRestart user interface now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
                return True

        elif next_state == self.StateEnded:
            NavigationInstance.instance.PowerTimer.saveTimer()
            if self.afterEvent == AFTEREVENT.STANDBY:
                if not Screens.Standby.inStandby:  # Not already in standby
                    Notifications.AddNotificationWithUniqueIDCallback(
                        self.sendStandbyNotification,
                        "PT_StateChange",
                        MessageBox,
                        _("A power timer wants to set your %s %s to standby mode.\nGo to standby mode now?"
                          ) % (getMachineBrand(), getMachineName()),
                        timeout=180)
            elif self.afterEvent == AFTEREVENT.DEEPSTANDBY:
                if recordingsActive(900):
                    self.do_backoff()
                    # Retry
                    self.begin = time() + self.backoff
                    if self.end <= self.begin:
                        self.end = self.begin
                    return False
                if not Screens.Standby.inTryQuitMainloop:  # The shutdown messagebox is not open
                    if Screens.Standby.inStandby:  # In standby
                        quitMainloop(Screens.Standby.QUIT_SHUTDOWN)
                    else:
                        Notifications.AddNotificationWithUniqueIDCallback(
                            self.sendTryQuitMainloopNotification,
                            "PT_StateChange",
                            MessageBox,
                            _("A power timer wants to shut down your %s %s.\nShut down now?"
                              ) % (getMachineBrand(), getMachineName()),
                            timeout=180)
            return True