add dummies for setting the sec stuff
[enigma2.git] / lib / python / Components / ServiceScan.py
1 from enigma import eComponentScan, eDVBFrontendParametersSatellite, eDVBFrontendParametersCable, eDVBFrontendParametersTerrestrial
2
3 class ServiceScan:
4         
5         Idle = 1
6         Running = 2
7         Done = 3
8         Error = 4
9         
10         Errors = { 
11                 0: "error starting scanning",
12                 1: "error while scanning",
13                 2: "no resource manager",
14                 3: "no channel list"
15                 }
16         
17         def scanStatusChanged(self):
18                 if self.state == self.Running:
19                         self.progressbar.setValue(self.scan.getProgress())
20                         if self.scan.isDone():
21                                 errcode = self.scan.getError()
22                                 
23                                 if errcode == 0:
24                                         self.state = self.Done
25                                 else:
26                                         self.state = self.Error
27                                         self.errorcode = errcode
28                         else:
29                                 self.text.setText(_("scan in progress - %d %% done!\n%d services found!") % (self.scan.getProgress(), self.scan.getNumServices()))
30                 
31                 if self.state == self.Done:
32                         if self.scan.getNumServices() == 1:
33                                 self.text.setText(_("scan done!\nOne service found!"))
34                         elif self.scan.getNumServices() == 0:
35                                 self.text.setText(_("scan done!\nNo service found!"))
36                         else:
37                                 self.text.setText(_("scan done!\n%d services found!") % (self.scan.getNumServices()))
38                 
39                 if self.state == self.Error:
40                         self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
41         
42         def __init__(self, progressbar, text, transponders, feid, flags):
43                 self.progressbar = progressbar
44                 self.text = text
45                 self.scan = eComponentScan()
46                 self.state = self.Idle
47                 self.feid = feid
48                 self.flags = flags
49                 self.scanStatusChanged()
50                 
51 #               if 1:
52 #                       parm = eDVBFrontendParametersSatellite()
53 #
54 #                       parm.frequency = 11817000
55 #                       parm.symbol_rate = 27500000
56 #                       parm.polarisation = 1 # eDVBFrontendParametersSatellite.Polarisation.Vertical
57 #                       parm.fec = 3 # eDVBFrontendParametersSatellite.FEC.f3_4;
58 #                       parm.inversion = 1 #eDVBFrontendParametersSatellite.Inversion.Off;
59 #                       parm.orbital_position = 192
60 #                       self.scan.addInitial(parm)
61 #               else:
62 #                               # until we have a terrestrial.xml:
63 #                       for x in [490000000, 530000000, 546000000, 570000000, 626000000]:
64 #                               parm = eDVBFrontendParametersTerrestrial()
65 #                               parm.frequency = x
66 #                               parm.inversion = 2  # eDVBFrontendParametersTerrestrial.Inversion.Unknown;
67 #                               parm.bandwidth = 0  #eDVBFrontendParametersTerrestrial.Bandwidth.Bw8MHz;
68 #                               parm.code_rate_HP = parm.code_rate_LP = 6 #eDVBFrontendParametersTerrestrial.FEC.fAuto;
69 #                               parm.modulation = 1 #eDVBFrontendParametersTerrestrial.Modulation.QAM16;
70 #                               parm.transmission_mode = 1 # eDVBFrontendParametersTerrestrial.TransmissionMode.TM8k;
71 #                               parm.guard_interval = 0 # eDVBFrontendParametersTerrestrial.GuardInterval.GI_1_32;
72 #                               parm.hierarchy = 0 #eDVBFrontendParametersTerrestrial.Hierarchy.HNone;
73 #                               self.scan.addInitial(parm)
74                 
75                 for x in transponders:
76                         self.scan.addInitial(x)
77                 
78                 #self.scan.addInitial(parm)
79                 
80         def execBegin(self):
81                 self.scan.statusChanged.get().append(self.scanStatusChanged)
82                 self.state = self.Running
83                 err = self.scan.start(self.feid, self.flags)
84                 if err:
85                         self.state = self.Error
86                         self.errorcode = 0
87
88                 self.scanStatusChanged()
89         
90         def execEnd(self):
91                 self.scan.statusChanged.get().remove(self.scanStatusChanged)
92                 if not self.isDone():
93                         print "*** warning *** scan was not finished!"
94                 
95                 del self.scan
96
97         def isDone(self):
98                 print "state is %d " % (self.state)
99                 return self.state == self.Done or self.state == self.Error