1 from config import config #global config instance
3 from config import configElement
4 from config import ConfigSubsection
5 from config import ConfigSlider
6 from config import configSelection
7 from config import configSatlist
10 from xml.dom import EMPTY_NAMESPACE
11 from skin import elementsWithTag
12 from Tools import XMLTools
15 def __init__(self, fnc, *args):
18 def __call__(self, *args):
19 self.fnc(*self.args + args)
22 def __init__(self, slotid, nimtype, name):
24 self.nimType = nimtype
28 def readSatsfromFile(self):
31 satfile = file('/etc/tuxbox/satellites.xml', 'r')
32 satdom = xml.dom.minidom.parseString(satfile.read())
35 for entries in elementsWithTag(satdom.childNodes, "satellites"):
36 for x in elementsWithTag(entries.childNodes, "sat"):
37 #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
38 tpos = x.getAttribute('position')
39 tname = x.getAttribute('name')
41 self.satellites[tpos] = tname
42 self.satList.append( (tname, tpos) )
44 def getNimType(self, slotID):
45 #FIXME get it from /proc
47 return self.nimType["DVB-S"]
49 return self.nimType["empty/unknown"]
51 def getNimName(self, slotID):
52 #FIXME get it from /proc
55 def getNimSocketCount(self):
56 #FIXME get it from /proc
59 def getConfigPrefix(self, slotid):
60 return "config.Nim" + ("A","B","C","D")[slotid] + "."
64 self.nimType = { "empty/unknown": -1,
70 self.readSatsfromFile()
72 self.nimCount = self.getNimSocketCount()
76 while x < self.nimCount:
77 tType = self.getNimType(x)
78 tName = self.getNimName(x)
79 tNim = nimSlot(x, tType, tName)
80 self.nimslots.append(tNim)
83 InitNimManager(self) #init config stuff
87 for slot in self.nimslots:
88 nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
89 if slot.nimType == -1:
90 nimText += "empty/unknown"
92 nimText += slot.name + " ("
93 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
94 list.append((nimText, slot))
97 #callbacks for c++ config
98 def nimConfigModeChanged(self, slotid, mode):
99 print "nimConfigModeChanged set to " + str(mode)
100 def nimDiseqcModeChanged(self, slotid, mode):
101 print "nimDiseqcModeChanged set to " + str(mode)
102 def nimPortAChanged(self, slotid, val):
103 print "nimDiseqcA set to " + str(val)
104 def nimPortBChanged(self, slotid, val):
105 print "nimDiseqcB set to " + str(val)
106 def nimPortCChanged(self, slotid, val):
107 print "nimDiseqcC set to " + str(val)
108 def nimPortDChanged(self, slotid, val):
109 print "nimDiseqcD set to " + str(val)
112 def InitNimManager(nimmgr):
113 config.Nims = [ConfigSubsection()] * nimmgr.nimCount
115 def nimConfigModeChanged(slotid, configElement):
116 nimmgr.nimConfigModeChanged(slotid, configElement.value)
117 def nimDiseqcModeChanged(slotid, configElement):
118 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
120 def nimPortAChanged(slotid, configElement):
121 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
122 def nimPortBChanged(slotid, configElement):
123 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
124 def nimPortCChanged(slotid, configElement):
125 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
126 def nimPortDChanged(slotid, configElement):
127 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
129 for slot in nimmgr.nimslots:
131 cname = nimmgr.getConfigPrefix(x)
133 if slot.nimType == nimmgr.nimType["DVB-S"]:
134 config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
135 config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D"));
136 config.Nims[x].diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
137 config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
138 config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
139 config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
141 #perhaps the instance of the slot is more useful?
142 config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
143 config.Nims[x].diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
144 config.Nims[x].diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
145 config.Nims[x].diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
146 config.Nims[x].diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
147 config.Nims[x].diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
149 print "pls add support for this frontend type!"
151 nimmanager = NimManager()