reenable support for one (lonely) NIM
[enigma2.git] / lib / python / Components / NimManager.py
index 919bf58729b240d6b701f11f7e0fa97377fee8d0..2f0f088a960efd25b9e6d14f9248ff0da2884e98 100644 (file)
@@ -99,10 +99,11 @@ class nimSlot:
 
 class NimManager:
        class parseSats(ContentHandler):
-               def __init__(self, satList, satellites):
+               def __init__(self, satList, satellites, transponders):
                        self.isPointsElement, self.isReboundsElement = 0, 0
                        self.satList = satList
                        self.satellites = satellites
+                       self.transponders = transponders
        
                def startElement(self, name, attrs):
                        if (name == "sat"):
@@ -111,6 +112,21 @@ class NimManager:
                                tname = attrs.get('name',"")
                                self.satellites[tpos] = tname
                                self.satList.append( (tname, tpos) )
+                               self.parsedSat = int(tpos)
+                       elif (name == "transponder"):
+                               freq = int(attrs.get('frequency',""))
+                               sr = int(attrs.get('symbol_rate',""))
+                               pol = int(attrs.get('polarization',""))
+                               fec = int(attrs.get('fec_inner',""))
+                               if self.parsedSat in self.transponders:
+                                       pass
+                               else:
+                                       self.transponders[self.parsedSat] = [ ]
+
+                               self.transponders[self.parsedSat].append((0, freq, sr, pol, fec))
+
+       def getTransponders(self, pos):
+               return self.transponders[pos]
 
        def getConfiguredSats(self):
                return self.sec.getSatList()
@@ -120,49 +136,48 @@ class NimManager:
 
        def readSatsfromFile(self):
                self.satellites = { }
+               self.transponders = { }
 
                print "Reading satellites.xml"
                parser = make_parser()
-               satHandler = self.parseSats(self.satList, self.satellites)
+               satHandler = self.parseSats(self.satList, self.satellites, self.transponders)
                parser.setContentHandler(satHandler)
                parser.parse('/etc/tuxbox/satellites.xml')
-
-       def getNimType(self, slotID):
-               #FIXME get it from /proc
+               
+       def parseProc(self):
+               self.nimTypes = {}
+               self.nimNames = {}              
                nimfile = tryOpen("/proc/bus/nim_sockets")
 
                if nimfile == "":
-                       # FIXME: remove this in the final version
-                       # check if we have a device for 7020 comp?atibility reasons
-                       try:
-                               open("/dev/dvb/card0/frontend" + str(slotID))
-                               return self.nimType["DVB-S"]
-                       except IOError:
                                return self.nimType["empty/unknown"]
-
+                       
+               lastsocket = -1
 
                while 1:                
                        line = nimfile.readline()
                        if line == "":
                                break
-                       if line.startswith("NIM Socket"):
+                       if line.strip().startswith("NIM Socket"):
                                parts = line.strip().split(" ")
                                id = int(parts[2][:1])
-                               if id == slotID:
-                                       line = nimfile.readline()
-                                       if line == "":
-                                               break
-                                       if line.startswith("   Type:"):
-                                               nimfile.close()
-                                               return self.nimType["DVB-S"]
-                                       else:
-                                               break   
+                               lastsocket = int(id)
+                       elif line.strip().startswith("Type:"):
+                               self.nimTypes[lastsocket] = str(line.strip()[6:])
+                       elif line.strip().startswith("Name:"):
+                               self.nimNames[lastsocket] = str(line.strip()[6:])
+                       elif line.strip().startswith("empty"):
+                               self.nimNames[lastsocket] = _("N/A")
+                               self.nimTypes[lastsocket] = "empty/unknown"
+
                nimfile.close()
-               return self.nimType["empty/unknown"]
+               
+
+       def getNimType(self, slotID):
+               return self.nimType[self.nimTypes[slotID]]
 
        def getNimName(self, slotID):
-               #FIXME get it from /proc
-               return "Alps BSBE1"
+               return self.nimNames[slotID]
 
        def getNimSocketCount(self):
                #FIXME get it from /proc
@@ -180,9 +195,11 @@ class NimManager:
                self.satList = [ ]                                                                              
                                                                                                
                self.readSatsfromFile()                                                                         
-                                                                                               
+               
                self.nimCount = self.getNimSocketCount()
                
+               self.parseProc()
+               
                self.nimslots = [ ]
                x = 0
                while x < self.nimCount:
@@ -197,9 +214,9 @@ class NimManager:
        def nimList(self):
                list = [ ]
                for slot in self.nimslots:
-                       nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
+                       nimText = _("Socket ") + ("A", "B", "C", "D")[slot.slotid] + ": "
                        if slot.nimType == -1:
-                               nimText += "empty/unknown"
+                               nimText += _("empty/unknown")
                        else:
                                nimText += slot.name + " ("     
                                nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
@@ -269,8 +286,8 @@ def InitNimManager(nimmgr):
                nim = config.Nims[x]
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
-                       nim.configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
-                       nim.diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D", "Positioner"));
+                       nim.configMode = configElement(cname + "configMode",configSelection, 0, (_("Simple"), _("Advanced")));
+                       nim.diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, (_("Single"), _("Toneburst A/B"), _("DiSEqC A/B"), _("DiSEqC A/B/C/D"), _("Positioner")));
                        nim.diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
                        nim.diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
                        nim.diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);