Merge commit 'origin/bug_112_enable_extensions_manager' into experimental
[enigma2.git] / lib / python / Components / Sources / FrontendInfo.py
1 from enigma import iPlayableService
2 from Source import Source
3 from Components.PerServiceDisplay import PerServiceBase
4
5 class FrontendInfo(Source, PerServiceBase):
6         def __init__(self, service_source = None, frontend_source = None, navcore = None):
7                 self.navcore = None
8                 Source.__init__(self)
9                 if navcore:
10                         PerServiceBase.__init__(self, navcore,
11                         {
12                                 iPlayableService.evTunedIn: self.updateFrontendData,
13                                 iPlayableService.evEnd: self.serviceEnd
14                         })
15                 self.service_source = service_source
16                 self.frontend_source = frontend_source
17                 self.updateFrontendData()
18
19         def serviceEnd(self):
20 #               import pdb
21 #               pdb.set_trace()
22                 self.slot_number = self.frontend_type = None
23                 self.changed((self.CHANGED_CLEAR, ))
24
25         def updateFrontendData(self):
26                 data = self.getFrontendData()
27                 if not data:
28                         self.slot_number = self.frontend_type = None
29                 else:
30                         self.slot_number = data.get("tuner_number")
31                         self.frontend_type = data.get("tuner_type")
32                 self.changed((self.CHANGED_ALL, ))
33
34         def getFrontendData(self):
35                 if self.frontend_source:
36                         frontend = self.frontend_source()
37                         dict = { }
38                         if frontend:
39                                 frontend.getFrontendData(dict)
40                         return dict
41                 elif self.service_source:
42                         service = self.navcore and self.service_source()
43                         feinfo = service and service.frontendInfo()
44                         return feinfo and feinfo.getFrontendData()
45                 elif self.navcore:
46                         service = self.navcore.getCurrentService()
47                         feinfo = service and service.frontendInfo()
48                         return feinfo and feinfo.getFrontendData()
49                 else:
50                         return None
51
52         def destroy(self):
53                 if not self.frontend_source and not self.service_source:
54                         PerServiceBase.destroy(self)
55                 Source.destroy(self)