Network.py,NetworkSetup.py,skin_default.xml: * Introduce new unified naming for netwo...
[enigma2.git] / lib / python / Screens / ServiceScan.py
1 from Screen import Screen
2 from Components.ServiceScan import ServiceScan as CScan
3 from Components.ProgressBar import ProgressBar
4 from Components.Label import Label
5 from Components.ActionMap import ActionMap
6 from Components.FIFOList import FIFOList
7 from Components.Sources.FrontendInfo import FrontendInfo
8
9 class ServiceScanSummary(Screen):
10         skin = """
11         <screen position="0,0" size="132,64">
12                 <widget name="Title" position="6,4" size="120,42" font="Regular;16" transparent="1" />
13                 <widget name="scan_progress" position="6,50" zPosition="1" borderWidth="1" size="56,12" backgroundColor="dark" />
14                 <widget name="Service" position="6,22" size="120,26" font="Regular;12" transparent="1" />
15         </screen>"""
16         
17         def __init__(self, session, parent, showStepSlider = True):
18                 Screen.__init__(self, session, parent)
19                 
20                 self["Title"] = Label(parent.title or "ServiceScan")
21                 self["Service"] = Label("No Service")
22                 self["scan_progress"] = ProgressBar()
23                 
24         def updateProgress(self, value):
25                 self["scan_progress"].setValue(value)
26
27         def updateService(self, name):
28                 self["Service"].setText(name)
29
30 class ServiceScan(Screen):
31         
32         def ok(self):
33                 print "ok"
34                 if self["scan"].isDone():
35                         self.resetTimeout()
36                         self.close()
37         
38         def cancel(self):
39                 self.resetTimeout()
40                 self.close()
41                 
42         def setTimeout(self):
43                 try:
44                         self.oldtimeoutvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
45                         open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
46                 except:
47                         print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"                
48                 
49         def resetTimeout(self):
50                 try:
51                         open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(self.oldtimeoutvalue)
52                 except:
53                         print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
54         
55         def __init__(self, session, scanList):
56                 Screen.__init__(self, session)
57                 
58                 self.scanList = scanList
59                 
60                 self.session.nav.stopService()
61                 
62                 self["scan_progress"] = ProgressBar()
63                 self["scan_state"] = Label(_("scan state"))
64                 self["network"] = Label()
65                 self["transponder"] = Label()
66
67                 self["pass"] = Label("")
68                 self["servicelist"] = FIFOList(len=10)
69                 self["FrontendInfo"] = FrontendInfo()
70                 
71                 self["actions"] = ActionMap(["OkCancelActions"], 
72                         {
73                                 "ok": self.ok,
74                                 "cancel": self.cancel
75                         })
76                 
77                 self.setTimeout()
78                 
79                 self.onFirstExecBegin.append(self.doServiceScan)
80
81         def doServiceScan(self):
82                 self["scan"] = CScan(self["scan_progress"], self["scan_state"], self["servicelist"], self["pass"], self.scanList, self["network"], self["transponder"], self["FrontendInfo"], self.session.summary)
83
84         def createSummary(self):
85                 print "ServiceScanCreateSummary"
86                 return ServiceScanSummary