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
14 from xml.sax import make_parser
15 from xml.sax.handler import ContentHandler
18 def __init__(self, fnc, *args):
21 def __call__(self, *args):
22 self.fnc(*self.args + args)
25 def __init__(self, slotid, nimtype, name):
27 self.nimType = nimtype
31 class parseSats(ContentHandler):
32 def __init__(self, satList, satellites):
33 self.isPointsElement, self.isReboundsElement = 0, 0
34 self.satList = satList
35 self.satellites = satellites
37 def startElement(self, name, attrs):
39 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
40 tpos = attrs.get('position',"")
41 tname = attrs.get('name',"")
42 self.satellites[tpos] = tname
43 self.satList.append( (tname, tpos) )
45 def readSatsfromFile(self):
49 print "Reading satellites.xml"
50 parser = make_parser()
51 satHandler = self.parseSats(self.satList, self.satellites)
52 parser.setContentHandler(satHandler)
53 parser.parse('/etc/tuxbox/satellites.xml')
55 #satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml')
58 #for entries in elementsWithTag(satdom.childNodes, "satellites"):
59 #for x in elementsWithTag(entries.childNodes, "sat"):
60 ##print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
61 #tpos = x.getAttribute('position')
62 #tname = x.getAttribute('name')
63 ##tname.encode('utf8')
64 #self.satellites[tpos] = tname
65 #self.satList.append( (tname, tpos) )
67 def getNimType(self, slotID):
68 #FIXME get it from /proc
70 return self.nimType["DVB-S"]
72 return self.nimType["empty/unknown"]
74 def getNimName(self, slotID):
75 #FIXME get it from /proc
78 def getNimSocketCount(self):
79 #FIXME get it from /proc
82 def getConfigPrefix(self, slotid):
83 return "config.Nim" + ("A","B","C","D")[slotid] + "."
87 self.nimType = { "empty/unknown": -1,
93 self.readSatsfromFile()
95 self.nimCount = self.getNimSocketCount()
99 while x < self.nimCount:
100 tType = self.getNimType(x)
101 tName = self.getNimName(x)
102 tNim = nimSlot(x, tType, tName)
103 self.nimslots.append(tNim)
106 InitNimManager(self) #init config stuff
110 for slot in self.nimslots:
111 nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
112 if slot.nimType == -1:
113 nimText += "empty/unknown"
115 nimText += slot.name + " ("
116 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
117 list.append((nimText, slot))
120 #callbacks for c++ config
121 def nimConfigModeChanged(self, slotid, mode):
122 print "nimConfigModeChanged set to " + str(mode)
123 def nimDiseqcModeChanged(self, slotid, mode):
124 print "nimDiseqcModeChanged set to " + str(mode)
125 def nimPortAChanged(self, slotid, val):
126 print "nimDiseqcA set to " + str(val)
127 def nimPortBChanged(self, slotid, val):
128 print "nimDiseqcB set to " + str(val)
129 def nimPortCChanged(self, slotid, val):
130 print "nimDiseqcC set to " + str(val)
131 def nimPortDChanged(self, slotid, val):
132 print "nimDiseqcD set to " + str(val)
135 def InitNimManager(nimmgr):
136 config.Nims = [ConfigSubsection()] * nimmgr.nimCount
138 def nimConfigModeChanged(slotid, configElement):
139 nimmgr.nimConfigModeChanged(slotid, configElement.value)
140 def nimDiseqcModeChanged(slotid, configElement):
141 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
143 def nimPortAChanged(slotid, configElement):
144 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
145 def nimPortBChanged(slotid, configElement):
146 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
147 def nimPortCChanged(slotid, configElement):
148 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
149 def nimPortDChanged(slotid, configElement):
150 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
152 for slot in nimmgr.nimslots:
154 cname = nimmgr.getConfigPrefix(x)
156 if slot.nimType == nimmgr.nimType["DVB-S"]:
157 config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
158 config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D"));
159 config.Nims[x].diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
160 config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
161 config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
162 config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
164 #perhaps the instance of the slot is more useful?
165 config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
166 config.Nims[x].diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
167 config.Nims[x].diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
168 config.Nims[x].diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
169 config.Nims[x].diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
170 config.Nims[x].diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
172 print "pls add support for this frontend type!"
174 nimmanager = NimManager()