add notifications
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 30 Nov 2005 00:16:24 +0000 (00:16 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 30 Nov 2005 00:16:24 +0000 (00:16 +0000)
RecordTimer.py
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Screen.py
lib/python/Tools/Makefile.am
lib/python/Tools/Notifications.py [new file with mode: 0644]
lib/python/Tools/__init__.py

index d893382..e42c168 100644 (file)
@@ -1,11 +1,12 @@
 import time
 import codecs
 #from time import datetime
-from Tools import Directories
+from Tools import Directories, Notifications
 
 import timer
 import xml.dom.minidom
 
+from Screens.MessageBox import MessageBox
 import NavigationInstance
 
 from Tools.XMLTools import elementsWithTag
@@ -63,12 +64,14 @@ class RecordTimerEntry(timer.TimerEntry):
                        if self.record_service == None:
                                print "timer record failed."
                        else:   
-                               self.record_service.prepare(self.Filename + ".ts")
+                               if self.record_service.prepare(self.Filename + ".ts"):
+                                       # error. 
+                                       Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nReason: unknown."))
+
                                f = open(self.Filename + ".ts.meta", "w")
                                f.write(str(self.service_ref) + "\n")
                                f.write(self.epg_data + "\n")
                                del f
-                               
                elif self.record_service == None:
                        if event != self.EventAbort:
                                print "timer record start failed, can't finish recording."
@@ -80,6 +83,11 @@ class RecordTimerEntry(timer.TimerEntry):
                        self.record_service = None
                        print "Timer successfully ended"
 
+       def failureCB(self, answer):
+               if answer == True:
+                       print "kill user to record"
+               else:
+                       print "user killed record"
 
 def createTimer(xml):
        begin = int(xml.getAttribute("begin"))
@@ -158,6 +166,8 @@ class RecordTimer(timer.Timer):
                
                entry.repeated = False
 
+               entry.repeated = False
+
                if entry.state == timer.TimerEntry.StateRunning:
                        print "remove running timer."
                        entry.end = time.time()
index 62e4fcd..3ddb1c3 100644 (file)
@@ -7,10 +7,12 @@ from Components.Clock import Clock
 from Components.ActionMap import ActionMap
 from Components.ServicePosition import ServicePosition
 
+from Tools.Notifications import AddNotificationWithCallback
+
 from Screens.InfoBarGenerics import InfoBarVolumeControl, InfoBarShowHide, \
        InfoBarPowerKey, InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, \
        InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarPVR, InfoBarInstantRecord, \
-       InfoBarAudioSelection, InfoBarAdditionalInfo
+       InfoBarAudioSelection, InfoBarAdditionalInfo, InfoBarNotifications
 
 from Screens.HelpMenu import HelpableScreen, HelpMenu
 
@@ -21,7 +23,7 @@ import time
 class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey,
        InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG,
        InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, 
-       HelpableScreen, InfoBarAdditionalInfo):
+       HelpableScreen, InfoBarAdditionalInfo, InfoBarNotifications):
 
        def __init__(self, session):
                Screen.__init__(self, session)
@@ -35,7 +37,7 @@ class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey,
                                InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
                                InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
                                InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
-                               InfoBarAdditionalInfo:
+                               InfoBarAdditionalInfo, InfoBarNotifications:
                        x.__init__(self)
 
                self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
@@ -51,7 +53,7 @@ class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey,
 
 class MoviePlayer(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
                InfoBarMenu, \
-               InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection, HelpableScreen):
+               InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection, HelpableScreen, InfoBarNotifications):
                
        def __init__(self, session, service):
                Screen.__init__(self, session)
@@ -61,7 +63,7 @@ class MoviePlayer(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey
                                "leavePlayer": self.leavePlayer
                        })
                
-               for x in HelpableScreen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection:
+               for x in HelpableScreen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, InfoBarMenu, InfoBarServiceName, InfoBarPVR, InfoBarAudioSelection, InfoBarNotifications:
                        x.__init__(self)
 
                self["CurrentTime"] = ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
index 978a113..c184279 100644 (file)
@@ -20,6 +20,8 @@ from Screens.Mute import Mute
 from Screens.Standby import Standby
 from Screens.EventView import EventView
 
+from Tools import Notifications
+
 #from enigma import eTimer, eDVBVolumecontrol, quitMainloop
 from enigma import *
 
@@ -522,4 +524,24 @@ class InfoBarAdditionalInfo:
                self["ButtonRedText"] = Label(_("Record"))
                self["ButtonGreen"] = Pixmap()
                self["ButtonYellow"] = Pixmap()
-               self["ButtonBlue"] = Pixmap()
\ No newline at end of file
+               self["ButtonBlue"] = Pixmap()
+
+class InfoBarNotifications:
+       def __init__(self):
+               self.onExecBegin.append(self.checkNotifications)
+               Notifications.notificationAdded.append(self.checkNotificationsIfExecing)
+       
+       def checkNotificationsIfExecing(self):
+               if self.execing:
+                       self.checkNotifications()
+
+       def checkNotifications(self):
+               if len(Notifications.notifications):
+                       n = Notifications.notifications[0]
+                       Notifications.notifications = Notifications.notifications[1:]
+                       print "open",n
+                       cb = n[0]
+                       if cb is not None:
+                               self.session.openWithCallback(cb, *n[1:])
+                       else:
+                               self.session.open(*n[1:])
index 13e31d6..231cbfa 100644 (file)
@@ -15,26 +15,40 @@ class Screen(dict, HTMLSkin, GUISkin):
                self.onExecBegin = [ ]
                self.onShown = [ ]
                
+               self.execing = False
+               
                # in order to support screens *without* a help,
                # we need the list in every screen. how ironic.
                self.helpList = [ ]
                
        def execBegin(self):
+               self.active_components = [ ]
                for x in self.onExecBegin:
                        x()
+                       if self.session.currentDialog != self:
+                               return
+
 #              assert self.session == None, "a screen can only exec one per time"
 #              self.session = session
+
                for (name, val) in self.items():
                        val.execBegin()
+                       if self.session.currentDialog != self:
+                               return
+                       self.active_components.append(val)
 
+               self.execing = True
+       
                for x in self.onShown:
                        x()
        
        def execEnd(self):
-               for (name, val) in self.items():
+#              for (name, val) in self.items():
+               for val in self.active_components:
                        val.execEnd()
 #              assert self.session != None, "execEnd on non-execing screen!"
 #              self.session = None
+               self.execing = False
        
        # never call this directly - it will be called from the session!
        def doClose(self):
index d205458..bee4dde 100644 (file)
@@ -1,4 +1,4 @@
 installdir = $(LIBDIR)/enigma2/python/Tools
 
 install_DATA = \
-       FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py KeyBindings.py BoundFunction.py ISO639.py __init__.py
+       FuzzyDate.py XMLTools.py Directories.py NumericalTextInput.py KeyBindings.py BoundFunction.py ISO639.py Notifications.py __init__.py
diff --git a/lib/python/Tools/Notifications.py b/lib/python/Tools/Notifications.py
new file mode 100644 (file)
index 0000000..b547639
--- /dev/null
@@ -0,0 +1,13 @@
+
+notifications = [ ]
+
+notificationAdded = [ ]
+
+def AddNotification(screen, *args):
+       AddNotificationWithCallback(None, screen, *args)
+
+def AddNotificationWithCallback(fnc, screen, *args):
+       notifications.append((fnc, screen) + args)
+       for x in notificationAdded:
+               x()
+
index 2d7c2ef..df963da 100644 (file)
@@ -1 +1 @@
-all = ["FuzzyDate.py", "XMLTools.py", "Directories.py", "KeyBindings.py", "BoundFunction.py", "ISO639.py"]
+all = ["FuzzyDate.py", "XMLTools.py", "Directories.py", "KeyBindings.py", "BoundFunction.py", "ISO639.py", "Notifications"]