Merge branch 'bug_570_playback_skip_fixes_and_cleanup_ml_aholst' into experimental
[enigma2.git] / lib / python / Screens / ServiceStopScreen.py
1 from Screens.MessageBox import MessageBox
2
3 class ServiceStopScreen:
4         def __init__(self):
5                 try:
6                         self.session
7                 except:
8                         print "[ServiceStopScreen] ERROR: no self.session set"
9
10                 self.oldref = None
11                 self.onClose.append(self.__onClose)
12                 
13         def pipAvailable(self):
14                 # pip isn't available in every state of e2
15                 try:
16                         self.session.pipshown
17                         pipavailable = True
18                 except:
19                         pipavailable = False
20                 return pipavailable
21                 
22         def stopService(self):          
23                 self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
24                 self.session.nav.stopService()
25                 if self.pipAvailable():
26                         if self.session.pipshown: # try to disable pip
27                                 self.session.pipshown = False
28                                 del self.session.pip
29                 
30         def __onClose(self):
31                 self.session.nav.playService(self.oldref)
32                 
33         def restoreService(self, msg = _("Zap back to previously tuned service?")):
34                 if self.oldref:
35                         self.session.openWithCallback(self.restartPrevService, MessageBox, msg, MessageBox.TYPE_YESNO)
36                 else:
37                         self.restartPrevService(False)
38                 
39         def restartPrevService(self, yesno):
40                 if not yesno:
41                         self.oldref=None
42                 self.close()