Merge branch 'master' of /home/tmbinc/enigma2-git into tmbinc/FixTimingBugs
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 050e350b96e7d5c366e61d82101665d054d2a63a..e64081e6924db11166e8a997f98af79ae17ff91c 100644 (file)
@@ -29,7 +29,7 @@ from Screens.TimeDateInput import TimeDateInput
 from ServiceReference import ServiceReference
 
 from Tools import Notifications
-from Tools.Directories import SCOPE_HDD, resolveFilename, pathExists
+from Tools.Directories import SCOPE_HDD, resolveFilename, fileExists
 
 from enigma import eTimer, eServiceCenter, eDVBServicePMTHandler, iServiceInformation, \
        iPlayableService, eServiceReference, eEPGCache
@@ -779,12 +779,21 @@ class InfoBarSeek:
                        print "not pauseable."
                        state = self.SEEK_STATE_PLAY
 
-               oldstate = self.seekstate
                self.seekstate = state
 
-               for i in range(3):
-                       if oldstate[i] != self.seekstate[i]:
-                               (self.session.nav.pause, pauseable.setFastForward, pauseable.setSlowMotion)[i](self.seekstate[i])
+               if pauseable is not None:
+                       if self.seekstate[0]:
+                               print "resolved to PAUSE"
+                               pauseable.pause()
+                       elif self.seekstate[1]:
+                               print "resolved to FAST FORWARD"
+                               pauseable.setFastForward(self.seekstate[1])
+                       elif self.seekstate[2]:
+                               print "resolved to SLOW MOTION"
+                               pauseable.setSlowMotion(self.seekstate[2])
+                       else:
+                               print "resolved to PLAY"
+                               pauseable.unpause()
 
                for c in self.onPlayStateChanged:
                        c(self.seekstate)
@@ -1024,7 +1033,13 @@ class InfoBarPVRState:
        def __playStateChanged(self, state):
                playstateString = state[3]
                self.pvrStateDialog["state"].setText(playstateString)
-               self._mayShow()
+               
+               # if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed
+               if not config.usage.show_infobar_on_skip.value and self.seekstate == self.SEEK_STATE_PLAY:
+                       self.pvrStateDialog.hide()
+               else:
+                       self._mayShow()
+                       
 
 class InfoBarTimeshiftState(InfoBarPVRState):
        def __init__(self):
@@ -1215,7 +1230,7 @@ class InfoBarExtensions:
                self["InstantExtensionsActions"] = HelpableActionMap(self, "InfobarExtensions",
                        {
                                "extensions": (self.showExtensionSelection, _("view extensions...")),
-                       })
+                       }, 1) # lower priority
 
        def addExtension(self, extension, key = None, type = EXTENSION_SINGLE):
                self.list.append((type, extension, key))
@@ -1449,10 +1464,28 @@ class InfoBarInstantRecord:
 
                recording = RecordTimerEntry(serviceref, begin, end, name, description, eventid, dirname = config.movielist.last_videodir.value)
                recording.dontSave = True
-               recording.autoincrease = True
-               if recording.setAutoincreaseEnd():
-                       self.session.nav.RecordTimer.record(recording)
-                       self.recording.append(recording)
+               
+               if event is None or limitEvent == False:
+                       recording.autoincrease = True
+                       if recording.setAutoincreaseEnd():
+                               self.session.nav.RecordTimer.record(recording)
+                               self.recording.append(recording)
+               else:
+                               simulTimerList = self.session.nav.RecordTimer.record(recording)
+                               if simulTimerList is not None:  # conflict with other recording
+                                       name = simulTimerList[1].name
+                                       name_date = name + strftime(" %c", localtime(simulTimerList[1].begin))
+                                       print "[TIMER] conflicts with", name_date
+                                       recording.autoincrease = True   # start with max available length, then increment
+                                       if recording.setAutoincreaseEnd():
+                                               self.session.nav.RecordTimer.record(recording)
+                                               self.recording.append(recording)
+                                               self.session.open(MessageBox, _("Record time limited due to conflicting timer %s") % name_date, MessageBox.TYPE_INFO)
+                                       else:
+                                               self.session.open(MessageBox, _("Couldn't record due to conflicting timer %s") % name, MessageBox.TYPE_INFO)
+                                       recording.autoincrease = False
+                               else:
+                                       self.recording.append(recording)
 
        def isInstantRecordRunning(self):
                print "self.recording:", self.recording
@@ -1530,7 +1563,7 @@ class InfoBarInstantRecord:
 
        def instantRecord(self):
                dir = config.movielist.last_videodir.value
-               if not pathExists(dir):
+               if not fileExists(dir, 'w'):
                        dir = resolveFilename(SCOPE_HDD)
                try:
                        stat = os_stat(dir)
@@ -1542,21 +1575,21 @@ class InfoBarInstantRecord:
                if self.isInstantRecordRunning():
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("A recording is currently running.\nWhat do you want to do?"), \
-                               list=[(_("stop recording"), "stop"), \
-                               (_("change recording (duration)"), "changeduration"), \
-                               (_("change recording (endtime)"), "changeendtime"), \
-                               (_("add recording (indefinitely)"), "indefinitely"), \
-                               (_("add recording (stop after current event)"), "event"), \
+                               list=[(_("add recording (stop after current event)"), "event"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
+                               (_("add recording (indefinitely)"), "indefinitely"), \
+                               (_("change recording (duration)"), "changeduration"), \
+                               (_("change recording (endtime)"), "changeendtime"), \
+                               (_("stop recording"), "stop"), \
                                (_("do nothing"), "no")])
                else:
                        self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \
                                title=_("Start recording?"), \
-                               list=[(_("add recording (indefinitely)"), "indefinitely"), \
-                               (_("add recording (stop after current event)"), "event"), \
+                               list=[(_("add recording (stop after current event)"), "event"), \
                                (_("add recording (enter recording duration)"), "manualduration"), \
                                (_("add recording (enter recording endtime)"), "manualendtime"), \
+                               (_("add recording (indefinitely)"), "indefinitely"), \
                                (_("don't record"), "no")])
 
 from Tools.ISO639 import LanguageCodes