make it compatible with 7020 again (should be removed in the final version)
[enigma2.git] / lib / python / Components / NimManager.py
index 8bbe2810545f7522cb3e54157b391f91b71a6a7f..53c6b62c374e837c8274ee9dfcff3a0b0df7f50f 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
@@ -122,6 +129,37 @@ class NimManager:
 
        def getNimType(self, slotID):
                #FIXME get it from /proc
+               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"]
+               
                if slotID == 0:
                        return self.nimType["DVB-S"]
                elif slotID == 1: