added configstuff
[enigma2.git] / lib / python / Components / NimManager.py
index 62b1fd8ddffebcb78b6a82f98d2b94dd4054af5f..abe75c40a29c52b377da6ccbb8c1512b37de6ed0 100644 (file)
@@ -4,6 +4,12 @@ from config import configElement
 from config import ConfigSubsection
 from config import ConfigSlider
 from config import configSelection
+from config import configSatlist
+
+import xml.dom.minidom
+from xml.dom import EMPTY_NAMESPACE
+from skin import elementsWithTag
+from Tools import XMLTools
 
 class nimSlot:
        def __init__(self, slotid, nimtype, name):
@@ -12,6 +18,22 @@ class nimSlot:
                self.name = name
 
 class NimManager:
+       def readSatsfromFile(self):
+               self.satellites = { }
+               #FIXME: path ok???
+               satfile = file('/etc/tuxbox/satellites.xml', 'r')
+               satdom = xml.dom.minidom.parseString(satfile.read())
+               satfile.close()
+
+               for entries in elementsWithTag(satdom.childNodes, "satellites"):
+                       for x in elementsWithTag(entries.childNodes, "sat"):
+                               #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
+                               tpos = x.getAttribute('position')
+                               tname = x.getAttribute('name')
+                               #tname.encode('utf8')
+                               self.satellites[tpos] = tname
+                               self.satList.append( (tname, tpos) )
+
        def getNimType(self, slotID):
                #FIXME get it from /proc
                if slotID == 0:
@@ -36,6 +58,9 @@ class NimManager:
                                                                                                "DVB-S": 0,
                                                                                                "DVB-C": 1,
                                                                                                "DVB-T": 2}
+               self.satList = [ ]                                                                              
+                                                                                               
+               self.readSatsfromFile()                                                                         
                                                                                                
                self.nimCount = self.getNimSocketCount()
 
@@ -70,14 +95,13 @@ def InitNimManager(nimmgr):
                cname = nimmgr.getConfigPrefix(x)
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
+                       #use custom configElement which can handle a dict (for sats)
                        config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
-                       config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 0, ("Single", "Toneburst A/B", "DiSEqC A/B"));
-                       config.Nims[x].diseqcMode = configElement(cname + "toneburstA",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "toneburstB",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "diseqcA",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "diseqcB",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "diseqcC",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "diseqcD",configSelection, 0, ("Astra", "Hotbird"));
+                       config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 0, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D"));
+                       config.Nims[x].diseqcA = configElement(cname + "diseqcA",configSatlist, 0, nimmgr.satList);
+                       config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 0, nimmgr.satList);
+                       config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
+                       config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
                else:
                        print "pls add support for this frontend type!"