new fontsize in servicelist
[enigma2.git] / lib / python / Components / NimManager.py
index d0f8536bc8b9369e6f0af525ee899dda58dd1516..919bf58729b240d6b701f11f7e0fa97377fee8d0 100644 (file)
@@ -18,6 +18,13 @@ from Tools import XMLTools
 from xml.sax import make_parser
 from xml.sax.handler import ContentHandler
 
+def tryOpen(filename):
+       try:
+               procFile = open(filename)
+       except IOError:
+               return ""
+       return procFile
+
 class SecConfigure:
        def addLNBSimple(self, slotid, orbpos, toneburstmode, diseqcmode, diseqcpos):
                #simple defaults
@@ -39,9 +46,14 @@ class SecConfigure:
                sec.setCommittedCommand(diseqcpos)
                #print "set orbpos to:" + str(orbpos)
                sec.addSatellite(orbpos)
+               self.satList.append(orbpos)
+
+       def getSatList(self):
+               return self.satList
 
        def update(self):
                eDVBSatelliteEquipmentControl.getInstance().clear()
+               self.satList = []
 
                for slot in self.NimManager.nimslots:
                        x = slot.slotid
@@ -100,6 +112,12 @@ class NimManager:
                                self.satellites[tpos] = tname
                                self.satList.append( (tname, tpos) )
 
+       def getConfiguredSats(self):
+               return self.sec.getSatList()
+
+       def getSatDescription(self, pos):
+               return self.satellites[str(pos)]
+
        def readSatsfromFile(self):
                self.satellites = { }
 
@@ -111,10 +129,36 @@ class NimManager:
 
        def getNimType(self, slotID):
                #FIXME get it from /proc
-               if slotID == 0:
-                       return self.nimType["DVB-S"]
-               else:
-                       return self.nimType["empty/unknown"]
+               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"]
+
+
+               while 1:                
+                       line = nimfile.readline()
+                       if line == "":
+                               break
+                       if line.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   
+               nimfile.close()
+               return self.nimType["empty/unknown"]
 
        def getNimName(self, slotID):
                #FIXME get it from /proc
@@ -163,17 +207,19 @@ class NimManager:
                return list
        
        def getSatListForNim(self, slotid):
-               #print "slotid:", slotid
                list = []
-               #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
-               #print "diseqcA:", config.Nims[slotid].diseqcA.value
-               if (config.Nims[slotid].diseqcMode.value <= 3):
-                       list.append(self.satList[config.Nims[slotid].diseqcA.value])
-               if (0 < config.Nims[slotid].diseqcMode.value <= 3):
-                       list.append(self.satList[config.Nims[slotid].diseqcB.value])
-               if (config.Nims[slotid].diseqcMode.value == 3):
-                       list.append(self.satList[config.Nims[slotid].diseqcC.value])
-                       list.append(self.satList[config.Nims[slotid].diseqcD.value])
+               if (self.getNimType(slotid) != self.nimType["empty/unknown"]):
+                       #print "slotid:", slotid
+                       
+                       #print "self.satellites:", self.satList[config.Nims[slotid].diseqcA.value]
+                       #print "diseqcA:", config.Nims[slotid].diseqcA.value
+                       if (config.Nims[slotid].diseqcMode.value <= 3):
+                               list.append(self.satList[config.Nims[slotid].diseqcA.value])
+                       if (0 < config.Nims[slotid].diseqcMode.value <= 3):
+                               list.append(self.satList[config.Nims[slotid].diseqcB.value])
+                       if (config.Nims[slotid].diseqcMode.value == 3):
+                               list.append(self.satList[config.Nims[slotid].diseqcC.value])
+                               list.append(self.satList[config.Nims[slotid].diseqcD.value])
                return list
 
        #callbacks for c++ config
@@ -184,9 +230,10 @@ class NimManager:
                #print "nimDiseqcModeChanged set to " + str(mode)
                pass
        def nimPortAChanged(self, slotid, val):
-               #print "nimDiseqcA set to " + str(val)
+               #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
                pass
        def nimPortBChanged(self, slotid, val):
+               #print "nimDiseqcA set to " + str(slotid) + " val:" + str(val)
                #print "nimDiseqcB set to " + str(val)
                pass
        def nimPortCChanged(self, slotid, val):
@@ -198,8 +245,10 @@ class NimManager:
 
 
 def InitNimManager(nimmgr):
-       config.Nims = [ConfigSubsection()] * nimmgr.nimCount
-
+       config.Nims = []
+       for x in range(nimmgr.nimCount):
+               config.Nims.append(ConfigSubsection())
+               
        def nimConfigModeChanged(slotid, configElement):
                nimmgr.nimConfigModeChanged(slotid, configElement.value)
        def nimDiseqcModeChanged(slotid, configElement):
@@ -232,13 +281,13 @@ def InitNimManager(nimmgr):
                        #perhaps the instance of the slot is more useful?
                        nim.configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
                        nim.diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
-                       nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
+                       nim.diseqcA.addNotifier(boundFunction(nimPortAChanged,int(x)))
                        nim.diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
                        nim.diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
                        nim.diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
                else:
                        print "pls add support for this frontend type!"         
-                       
+
        nimmgr.sec = SecConfigure(nimmgr)
 
 nimmanager = NimManager()