epgrefresh: changes to how adapters are handled
[enigma2-plugins.git] / epgrefresh / src / MainPictureAdapter.py
1 import Screens.Standby
2
3 # MessageBox
4 from Screens.MessageBox import MessageBox
5 from Tools import Notifications
6
7 # Config
8 from Components.config import config
9
10 class MainPictureAdapter:
11         backgroundCapable = True
12         def __init__(self, session):
13                 self.session = session
14
15         def prepare(self):
16                 if config.plugins.epgrefresh.enablemessage.value:
17                         Notifications.AddNotification(MessageBox, _("EPG refresh starts scanning channels."), type=MessageBox.TYPE_INFO, timeout=4)
18                 self.previousService = session.nav.getCurrentlyPlayingServiceReference()
19                 return True
20
21         def play(self, service):
22                 print "[EPGRefresh.MainPictureAdapter.play]"
23                 return self.session.nav.playService(service)
24
25         def stop(self):
26                 if self.previousService is not None or Screens.Standby.inStandby:
27                         self.session.nav.playService(self.previousService)
28