modify skin of plugins.
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / Blindscan / plugin.py
1 from Plugins.Plugin import PluginDescriptor
2
3 from Screens.Screen import Screen
4 from Screens.ServiceScan import ServiceScan
5 from Screens.MessageBox import MessageBox
6 from Screens.DefaultWizard import DefaultWizard
7
8 from Components.Label import Label
9 from Components.TuneTest import Tuner
10 from Components.ConfigList import ConfigListScreen
11 from Components.Sources.StaticText import StaticText
12 from Components.ActionMap import NumberActionMap, ActionMap
13 from Components.NimManager import nimmanager, getConfigSatlist
14 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigYesNo, ConfigInteger, getConfigListEntry, ConfigSlider, ConfigEnableDisable
15
16 from Tools.HardwareInfo import HardwareInfo
17 from Tools.Directories import resolveFilename, SCOPE_DEFAULTPARTITIONMOUNTDIR, SCOPE_DEFAULTDIR, SCOPE_DEFAULTPARTITION
18
19 from enigma import eTimer, eDVBFrontendParametersSatellite, eComponentScan, eDVBSatelliteEquipmentControl, eDVBFrontendParametersTerrestrial, eDVBFrontendParametersCable, eConsoleAppContainer, eDVBResourceManager, getDesktop
20
21 class Blindscan(ConfigListScreen, Screen):
22         skin =  """
23                 <screen position="center,center" size="560,390" title="Blindscan">
24                         <ePixmap pixmap="skin_default/buttons/red.png" position="40,10" size="140,40" alphatest="on" />
25                         <ePixmap pixmap="skin_default/buttons/green.png" position="210,10" size="140,40" alphatest="on" />
26                         <ePixmap pixmap="skin_default/buttons/blue.png" position="380,10" size="140,40" alphatest="on" />
27
28                         <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1"/>
29                         <widget source="key_green" render="Label" position="210,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1"/>
30                         <widget source="key_blue" render="Label" position="380,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" foregroundColor="#ffffff" transparent="1"/>
31
32                         <widget name="config" position="5,70" size="550,280" scrollbarMode="showOnDemand" />
33                         <widget name="introduction" position="0,365" size="560,20" font="Regular;20" halign="center" />
34                 </screen>
35                 """
36
37         def __init__(self, session): 
38                 Screen.__init__(self, session)
39
40                 self.current_play_service = self.session.nav.getCurrentlyPlayingServiceReference()
41
42                 # update sat list
43                 self.satList = []
44                 for slot in nimmanager.nim_slots:
45                         if slot.isCompatible("DVB-S"):
46                                 self.satList.append(nimmanager.getSatListForNim(slot.slot))
47                         else:
48                                 self.satList.append(None)
49
50                 # make config
51                 self.createConfig()
52
53                 self.list = []
54                 self.status = ""
55
56                 ConfigListScreen.__init__(self, self.list)
57                 if self.scan_nims.value != None and self.scan_nims.value != "" :
58                         self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
59                         {
60                                 "red": self.keyCancel,
61                                 "green": self.keyGo,
62                                 "blue":self.keyGoAll,
63                                 "ok": self.keyGo,
64                                 "cancel": self.keyCancel,
65                         }, -2)
66                         self["key_red"] = StaticText(_("Exit"))
67                         self["key_green"] = StaticText("Scan")
68                         self["key_blue"] = StaticText("Scan All")
69                         self["introduction"] = Label(_("Press Green/OK to start the scan"))
70                         self.createSetup()
71                 else :
72                         self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
73                         {
74                                 "red": self.keyCancel,
75                                 "green": self.keyNone,
76                                 "blue":self.keyNone,
77                                 "ok": self.keyNone,
78                                 "cancel": self.keyCancel,
79                         }, -2)
80                         self["key_red"] = StaticText(_("Exit"))
81                         self["key_green"] = StaticText(" ")
82                         self["key_blue"] = StaticText(" ")
83                         self["introduction"] = Label(_("Please setup your tuner configuration."))
84
85                 self.i2c_mapping_table = None
86                 self.makeNimSocket()
87
88         def makeNimSocket(self):
89                 self.i2c_mapping_table = {0:2, 1:3, 2:1, 3:0}
90
91         def getNimSocket(self, slot_number):
92                 if slot_number < 0 or slot_number > 3:
93                         return -1
94                 return self.i2c_mapping_table[slot_number]
95
96         def keyNone(self):
97                 None
98         def callbackNone(self, *retval):
99                 None
100
101         def openFrontend(self):
102                 res_mgr = eDVBResourceManager.getInstance()
103                 if res_mgr:
104                         self.raw_channel = res_mgr.allocateRawChannel(self.feid)
105                         if self.raw_channel:
106                                 self.frontend = self.raw_channel.getFrontend()
107                                 if self.frontend:
108                                         return True
109                                 else:
110                                         print "getFrontend failed"
111                         else:
112                                 print "getRawChannel failed"
113                 else:
114                         print "getResourceManager instance failed"
115                 return False
116
117         def createConfig(self):
118                 self.feinfo = None
119                 frontendData = None
120                 defaultSat = {
121                         "orbpos": 192,
122                         "system": eDVBFrontendParametersSatellite.System_DVB_S,
123                         "frequency": 11836,
124                         "inversion": eDVBFrontendParametersSatellite.Inversion_Unknown,
125                         "symbolrate": 27500,
126                         "polarization": eDVBFrontendParametersSatellite.Polarisation_Horizontal,
127                         "fec": eDVBFrontendParametersSatellite.FEC_Auto,
128                         "fec_s2": eDVBFrontendParametersSatellite.FEC_9_10,
129                         "modulation": eDVBFrontendParametersSatellite.Modulation_QPSK 
130                 }
131
132                 self.service = self.session.nav.getCurrentService()
133                 if self.service is not None:
134                         self.feinfo = self.service.frontendInfo()
135                         frontendData = self.feinfo and self.feinfo.getAll(True)
136                 if frontendData is not None:
137                         ttype = frontendData.get("tuner_type", "UNKNOWN")
138                         if ttype == "DVB-S":
139                                 defaultSat["system"] = frontendData.get("system", eDVBFrontendParametersSatellite.System_DVB_S)
140                                 defaultSat["frequency"] = frontendData.get("frequency", 0) / 1000
141                                 defaultSat["inversion"] = frontendData.get("inversion", eDVBFrontendParametersSatellite.Inversion_Unknown)
142                                 defaultSat["symbolrate"] = frontendData.get("symbol_rate", 0) / 1000
143                                 defaultSat["polarization"] = frontendData.get("polarization", eDVBFrontendParametersSatellite.Polarisation_Horizontal)
144                                 if defaultSat["system"] == eDVBFrontendParametersSatellite.System_DVB_S2:
145                                         defaultSat["fec_s2"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
146                                         defaultSat["rolloff"] = frontendData.get("rolloff", eDVBFrontendParametersSatellite.RollOff_alpha_0_35)
147                                         defaultSat["pilot"] = frontendData.get("pilot", eDVBFrontendParametersSatellite.Pilot_Unknown)
148                                 else:
149                                         defaultSat["fec"] = frontendData.get("fec_inner", eDVBFrontendParametersSatellite.FEC_Auto)
150                                 defaultSat["modulation"] = frontendData.get("modulation", eDVBFrontendParametersSatellite.Modulation_QPSK)
151                                 defaultSat["orbpos"] = frontendData.get("orbital_position", 0)
152                 del self.feinfo
153                 del self.service
154                 del frontendData
155                 
156                 self.scan_sat = ConfigSubsection()
157                 self.scan_networkScan = ConfigYesNo(default = False)
158                 
159                 # blindscan add
160                 self.blindscan_hi = ConfigSelection(default = "hi_low", choices = [("low", _("low")), ("high", _("high")), ("hi_low", _("hi_low"))])
161
162                 #ConfigYesNo(default = True)
163                 self.blindscan_start_frequency = ConfigInteger(default = 950*1000000)
164                 self.blindscan_stop_frequency = ConfigInteger(default = 2150*1000000)
165                 self.blindscan_start_symbol = ConfigInteger(default = 2*1000000)
166                 self.blindscan_stop_symbol = ConfigInteger(default = 45*1000000)
167                 self.scan_clearallservices = ConfigYesNo(default = False)
168                 self.scan_onlyfree = ConfigYesNo(default = False)
169
170                 # collect all nims which are *not* set to "nothing"
171                 nim_list = []
172                 for n in nimmanager.nim_slots:
173                         if n.config_mode == "nothing":
174                                 continue
175                         if n.config_mode == "advanced" and len(nimmanager.getSatListForNim(n.slot)) < 1:
176                                 continue
177                         if n.config_mode in ("loopthrough", "satposdepends"):
178                                 root_id = nimmanager.sec.getRoot(n.slot_id, int(n.config.connectedTo.value))
179                                 if n.type == nimmanager.nim_slots[root_id].type: # check if connected from a DVB-S to DVB-S2 Nim or vice versa
180                                         continue
181                         if n.isCompatible("DVB-S"):
182                                 nim_list.append((str(n.slot), n.friendly_full_description))
183                 self.scan_nims = ConfigSelection(choices = nim_list)
184
185                 # sat
186                 self.scan_sat.frequency = ConfigInteger(default = defaultSat["frequency"], limits = (1, 99999))
187                 #self.scan_sat.polarization = ConfigSelection(default = defaultSat["polarization"], choices = [
188                 self.scan_sat.polarization = ConfigSelection(default = eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, choices = [
189                         (eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1, _("horizontal_vertical")),
190                         (eDVBFrontendParametersSatellite.Polarisation_Horizontal, _("horizontal")),
191                         (eDVBFrontendParametersSatellite.Polarisation_Vertical, _("vertical")),
192                         (eDVBFrontendParametersSatellite.Polarisation_CircularLeft, _("circular left")),
193                         (eDVBFrontendParametersSatellite.Polarisation_CircularRight, _("circular right"))])
194                 self.scan_scansat = {}
195                 for sat in nimmanager.satList:
196                         self.scan_scansat[sat[0]] = ConfigYesNo(default = False)
197                 
198                 self.scan_satselection = []
199                 for slot in nimmanager.nim_slots:
200                         if slot.isCompatible("DVB-S"):
201                                 self.scan_satselection.append(getConfigSatlist(defaultSat["orbpos"], self.satList[slot.slot]))
202                 return True
203
204         def getSelectedSatIndex(self, v):
205                 index    = 0
206                 none_cnt = 0
207                 for n in self.satList:
208                         if self.satList[index] == None:
209                                 none_cnt = none_cnt + 1
210                         if index == int(v):
211                                 return (index-none_cnt)
212                         index = index + 1
213                 return -1
214
215         def createSetup(self):
216                 self.list = []
217                 self.multiscanlist = []
218                 index_to_scan = int(self.scan_nims.value)
219                 print "ID: ", index_to_scan
220
221                 self.tunerEntry = getConfigListEntry(_("Tuner"), self.scan_nims)
222                 self.list.append(self.tunerEntry)
223                 
224                 if self.scan_nims == [ ]:
225                         return
226                 
227                 self.systemEntry = None
228                 self.modulationEntry = None
229                 nim = nimmanager.nim_slots[index_to_scan]
230
231                 self.scan_networkScan.value = False
232                 if nim.isCompatible("DVB-S") :
233                         self.list.append(getConfigListEntry(_('Satellite'), self.scan_satselection[self.getSelectedSatIndex(index_to_scan)]))
234                         self.list.append(getConfigListEntry(_('Scan start frequency'), self.blindscan_start_frequency))
235                         self.list.append(getConfigListEntry(_('Scan stop frequency'), self.blindscan_stop_frequency))
236                         self.list.append(getConfigListEntry(_("Polarity"), self.scan_sat.polarization))
237                         self.list.append(getConfigListEntry(_("Scan band"), self.blindscan_hi))
238                         self.list.append(getConfigListEntry(_('Scan start symbolrate'), self.blindscan_start_symbol))
239                         self.list.append(getConfigListEntry(_('Scan stop symbolrate'), self.blindscan_stop_symbol))
240                         self.list.append(getConfigListEntry(_("Clear before scan"), self.scan_clearallservices))
241                         self.list.append(getConfigListEntry(_("Only Free scan"), self.scan_onlyfree))
242                         self["config"].list = self.list
243                         self["config"].l.setList(self.list)
244                         
245         def newConfig(self):
246                 cur = self["config"].getCurrent()
247                 print "cur is", cur
248                 if cur == self.tunerEntry or \
249                         cur == self.systemEntry or \
250                         (self.modulationEntry and self.systemEntry[1].value == eDVBFrontendParametersSatellite.System_DVB_S2 and cur == self.modulationEntry):
251                         self.createSetup()
252
253         def checkSettings(self):
254                 if self.blindscan_start_frequency.value < 950*1000000 or self.blindscan_start_frequency.value > 2150*1000000 :
255                         self.session.open(MessageBox, _("Please check again.\nStart frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
256                         return False
257                 if self.blindscan_stop_frequency.value < 950*1000000 or self.blindscan_stop_frequency.value > 2150*1000000 :
258                         self.session.open(MessageBox, _("Please check again.\nStop frequency must be between 950 and 2150."), MessageBox.TYPE_ERROR)
259                         return False
260                 if self.blindscan_start_frequency.value > self.blindscan_stop_frequency.value :
261                         self.session.open(MessageBox, _("Please check again.\nFrequency : start value is larger than stop value."), MessageBox.TYPE_ERROR)
262                         return False
263                 if self.blindscan_start_symbol.value < 2*1000000 or self.blindscan_start_symbol.value > 45*1000000 :
264                         self.session.open(MessageBox, _("Please check again.\nStart symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
265                         return False
266                 if self.blindscan_stop_symbol.value < 2*1000000 or self.blindscan_stop_symbol.value > 45*1000000 :
267                         self.session.open(MessageBox, _("Please check again.\nStop symbolrate must be between 2MHz and 45MHz."), MessageBox.TYPE_ERROR)
268                         return False
269                 if self.blindscan_start_symbol.value > self.blindscan_stop_symbol.value :
270                         self.session.open(MessageBox, _("Please check again.\nSymbolrate : start value is larger than stop value."), MessageBox.TYPE_ERROR)
271                         return False
272                 return True
273
274         def keyLeft(self):
275                 ConfigListScreen.keyLeft(self)
276                 self.newConfig()
277
278         def keyRight(self):
279                 ConfigListScreen.keyRight(self)
280                 self.newConfig()
281                         
282         def keyCancel(self):
283                 self.session.nav.playService(self.current_play_service)
284                 for x in self["config"].list:
285                         x[1].cancel()
286                 self.close()
287
288         def keyGo(self):
289                 if self.checkSettings() == False:
290                         return
291
292                 tab_pol = {
293                         eDVBFrontendParametersSatellite.Polarisation_Horizontal : "horizontal", 
294                         eDVBFrontendParametersSatellite.Polarisation_Vertical : "vertical",
295                         eDVBFrontendParametersSatellite.Polarisation_CircularLeft : "circular left",
296                         eDVBFrontendParametersSatellite.Polarisation_CircularRight : "circular right",
297                         eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : "horizontal_vertical"
298                 }
299
300                 self.tmp_tplist=[]
301                 tmp_pol = []
302                 tmp_band = []
303                 idx_selected_sat = int(self.getSelectedSatIndex(self.scan_nims.value))
304                 tmp_list=[self.satList[int(self.scan_nims.value)][self.scan_satselection[idx_selected_sat].index]]
305
306                 if self.blindscan_hi.value == "hi_low" :
307                         tmp_band=["low","high"]
308                 else:
309                         tmp_band=[self.blindscan_hi.value]
310                         
311                 if self.scan_sat.polarization.value ==  eDVBFrontendParametersSatellite.Polarisation_CircularRight + 1 : 
312                         tmp_pol=["horizontal","vertical"]
313                 else:
314                         tmp_pol=[tab_pol[self.scan_sat.polarization.value]]
315
316                 self.doRun(tmp_list, tmp_pol, tmp_band)
317                 
318         def keyGoAll(self):
319                 if self.checkSettings() == False:
320                         return
321                 self.tmp_tplist=[]
322                 tmp_list=[]
323                 tmp_band=["low","high"]
324                 tmp_pol=["horizontal","vertical"]
325                 
326                 for slot in nimmanager.nim_slots:
327                         device_name = "/dev/dvb/adapter0/frontend%d" % (slot.slot)
328                         if slot.isCompatible("DVB-S") and int(self.scan_nims.value) == slot.slot:
329                                 for s in self.satList[slot.slot]:
330                                         tmp_list.append(s)
331                 self.doRun(tmp_list, tmp_pol, tmp_band)
332                 
333         def doRun(self, tmp_list, tmp_pol, tmp_band):
334                 self.full_data = ""
335                 self.total_list=[]
336                 for x in tmp_list:
337                         for y in tmp_pol:
338                                 for z in tmp_band:
339                                         self.total_list.append([x,y,z])
340                                         print "add scan item : ", x, ", ", y, ", ", z
341
342                 self.max_count = len(self.total_list)
343                 self.is_runable = True
344                 self.running_count = 0
345                 self.clockTimer = eTimer()
346                 self.clockTimer.callback.append(self.doClock)
347                 self.clockTimer.start(1000)
348
349         def doClock(self):
350                 is_scan = False
351                 if self.is_runable :
352                         if self.running_count >= self.max_count:
353                                 self.clockTimer.stop()
354                                 del self.clockTimer
355                                 self.clockTimer = None
356                                 print "Done"
357                                 return
358                         orb = self.total_list[self.running_count][0]
359                         pol = self.total_list[self.running_count][1]
360                         band = self.total_list[self.running_count][2]
361                         self.running_count = self.running_count + 1
362                         print "running status-[%d] : [%d][%s][%s]" %(self.running_count, orb[0], pol, band)
363                         if self.running_count == self.max_count:
364                                 is_scan = True
365                         self.prepareScanData(orb, pol, band, is_scan)
366
367         def prepareScanData(self, orb, pol, band, is_scan):
368                 self.is_runable = False
369                 self.orb_position = orb[0]
370                 self.feid = int(self.scan_nims.value)
371                 tab_hilow = {"high" : 1, "low" : 0}
372                 tab_pol = {
373                         "horizontal" : eDVBFrontendParametersSatellite.Polarisation_Horizontal, 
374                         "vertical" : eDVBFrontendParametersSatellite.Polarisation_Vertical,
375                         "circular left" : eDVBFrontendParametersSatellite.Polarisation_CircularLeft,
376                         "circular right" : eDVBFrontendParametersSatellite.Polarisation_CircularRight
377                 }
378
379                 returnvalue = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
380
381                 if not self.openFrontend():
382                         self.oldref = self.session.nav.getCurrentlyPlayingServiceReference()
383                         self.session.nav.stopService()
384                         if not self.openFrontend():
385                                 if self.session.pipshown:
386                                         self.session.pipshown = False
387                                         del self.session.pip
388                                         if not self.openFrontend():
389                                                 self.frontend = None
390                 self.tuner = Tuner(self.frontend)
391
392                 if tab_hilow[band]:
393                         self.scan_sat.frequency.value = 12515
394                 else:
395                         self.scan_sat.frequency.value = 11015
396                 returnvalue = (self.scan_sat.frequency.value,
397                                          0,
398                                          tab_pol[pol],
399                                          0,
400                                          0,
401                                          orb[0],
402                                          eDVBFrontendParametersSatellite.System_DVB_S,
403                                          0,
404                                          0,
405                                          0)
406                 self.tuner.tune(returnvalue)
407
408                 if self.getNimSocket(self.feid) < 0:
409                         print "can't find i2c number!!"
410                         return
411
412                 cmd = "vuplus_blindscan %d %d %d %d %d %d %d %d" % (self.blindscan_start_frequency.value/1000000, self.blindscan_stop_frequency.value/1000000, self.blindscan_start_symbol.value/1000000, self.blindscan_stop_symbol.value/1000000, tab_pol[pol], tab_hilow[band], self.feid, self.getNimSocket(self.feid))
413                 print "prepared command : [%s]" % (cmd)
414                 self.blindscan_container = eConsoleAppContainer()
415                 self.blindscan_container.appClosed.append(self.blindscanContainerClose)
416                 self.blindscan_container.dataAvail.append(self.blindscanContainerAvail)
417                 self.blindscan_container.execute(cmd)
418
419                 tmpstr = "Look for available transponders.\nThis works will take several minutes.\n\n   - Current Status : %d/%d\n   - Orbital Positions : %s\n   - Polarization : %s\n   - Bandwidth : %s" %(self.running_count, self.max_count, orb[1], pol, band)
420                 if is_scan :
421                         self.blindscan_session = self.session.openWithCallback(self.blindscanSessionClose, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
422                 else:
423                         self.blindscan_session = self.session.openWithCallback(self.blindscanSessionNone, MessageBox, _(tmpstr), MessageBox.TYPE_INFO)
424
425         def blindscanContainerClose(self, retval):
426                 lines = self.full_data.split('\n')
427                 for line in lines:
428                         data = line.split()
429                         print "cnt :", len(data), ", data :", data
430                         if len(data) >= 10:
431                                 if data[0] == 'OK':
432                                         parm = eDVBFrontendParametersSatellite()
433                                         sys = { "DVB-S" : eDVBFrontendParametersSatellite.System_DVB_S,
434                                                 "DVB-S2" : eDVBFrontendParametersSatellite.System_DVB_S2}
435                                         qam = { "QPSK" : parm.Modulation_QPSK,
436                                                 "8PSK" : parm.Modulation_8PSK}
437                                         inv = { "INVERSION_OFF" : parm.Inversion_Off,
438                                                 "INVERSION_ON" : parm.Inversion_On,
439                                                 "INVERSION_AUTO" : parm.Inversion_Unknown}
440                                         fec = { "FEC_AUTO" : parm.FEC_Auto,
441                                                 "FEC_1_2" : parm.FEC_1_2,
442                                                 "FEC_2_3" : parm.FEC_2_3,
443                                                 "FEC_3_4" : parm.FEC_3_4,
444                                                 "FEC_5_6": parm.FEC_5_6,
445                                                 "FEC_7_8" : parm.FEC_7_8,
446                                                 "FEC_8_9" : parm.FEC_8_9,
447                                                 "FEC_3_5" : parm.FEC_3_5,
448                                                 "FEC_9_10" : parm.FEC_9_10,
449                                                 "FEC_NONE" : parm.FEC_None}
450                                         roll ={ "ROLLOFF_20" : parm.RollOff_alpha_0_20,
451                                                 "ROLLOFF_25" : parm.RollOff_alpha_0_25,
452                                                 "ROLLOFF_35" : parm.RollOff_alpha_0_35}
453                                         pilot={ "PILOT_ON" : parm.Pilot_On,
454                                                 "PILOT_OFF" : parm.Pilot_Off}
455                                         pol = { "HORIZONTAL" : parm.Polarisation_Horizontal,
456                                                 "VERTICAL" : parm.Polarisation_Vertical}
457                                         try :
458                                                 parm.orbital_position = self.orb_position
459                                                 parm.polarisation = pol[data[1]]
460                                                 parm.frequency = int(data[2])
461                                                 parm.symbol_rate = int(data[3])
462                                                 parm.system = sys[data[4]]
463                                                 parm.inversion = inv[data[5]]
464                                                 parm.pilot = pilot[data[6]]
465                                                 parm.fec = fec[data[7]]
466                                                 parm.modulation = qam[data[8]]
467                                                 parm.rolloff = roll[data[9]]
468                                                 self.tmp_tplist.append(parm)
469                                         except:
470                                                 pass
471                 self.blindscan_session.close(True)
472
473         def blindscanContainerAvail(self, str):
474                 print str
475                 #if str.startswith("OK"):
476                 self.full_data = self.full_data + str
477
478         def blindscanSessionNone(self, *val):
479                 import time
480                 self.blindscan_container.sendCtrlC()
481                 self.blindscan_container = None
482                 time.sleep(2)
483
484                 if self.frontend:
485                         self.frontend = None
486                         del self.raw_channel
487
488                 if val[0] == False:
489                         self.tmp_tplist = []
490                         self.running_count = self.max_count
491
492                 self.is_runable = True
493
494         def blindscanSessionClose(self, *val):
495                 self.blindscanSessionNone(val[0])
496
497                 if self.tmp_tplist != None and self.tmp_tplist != []:
498                         for p in self.tmp_tplist:
499                                 print "data : [%d][%d][%d][%d][%d][%d][%d][%d][%d][%d]" % (p.orbital_position, p.polarisation, p.frequency, p.symbol_rate, p.system, p.inversion, p.pilot, p.fec, p.modulation, p.modulation)
500
501                         self.startScan(self.tmp_tplist, self.feid)
502                 else:
503                         msg = "No found transponders!!\nPlease check the satellite connection, or scan other search condition." 
504                         if val[0] == False:
505                                 msg = "Blindscan was canceled by the user."
506                         self.session.openWithCallback(self.callbackNone, MessageBox, _(msg), MessageBox.TYPE_INFO, timeout=10)
507                         self.tmp_tplist = []
508
509         def startScan(self, tlist, feid, networkid = 0):
510                 self.scan_session = None
511
512                 flags = 0
513                 if self.scan_clearallservices.value:
514                         flags |= eComponentScan.scanRemoveServices
515                 else:
516                         flags |= eComponentScan.scanDontRemoveUnscanned
517                 if self.scan_onlyfree.value:
518                         flags |= eComponentScan.scanOnlyFree
519                 self.session.open(ServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags, "networkid": networkid}])
520
521 def main(session, **kwargs):
522         session.open(Blindscan)
523                                                            
524 def Plugins(**kwargs):            
525         return PluginDescriptor(name=_("Blindscan"), description="scan type(DVB-S)", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
526