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 configSequence
8 from config import configSatlist
10 import xml.dom.minidom
11 from xml.dom import EMPTY_NAMESPACE
12 from skin import elementsWithTag
13 from Tools import XMLTools
15 from xml.sax import make_parser
16 from xml.sax.handler import ContentHandler
19 def __init__(self, fnc, *args):
22 def __call__(self, *args):
23 self.fnc(*self.args + args)
26 def __init__(self, slotid, nimtype, name):
28 self.nimType = nimtype
32 class parseSats(ContentHandler):
33 def __init__(self, satList, satellites):
34 self.isPointsElement, self.isReboundsElement = 0, 0
35 self.satList = satList
36 self.satellites = satellites
38 def startElement(self, name, attrs):
40 #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
41 tpos = attrs.get('position',"")
42 tname = attrs.get('name',"")
43 self.satellites[tpos] = tname
44 self.satList.append( (tname, tpos) )
46 def readSatsfromFile(self):
50 print "Reading satellites.xml"
51 parser = make_parser()
52 satHandler = self.parseSats(self.satList, self.satellites)
53 parser.setContentHandler(satHandler)
54 parser.parse('/etc/tuxbox/satellites.xml')
56 #satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml')
59 #for entries in elementsWithTag(satdom.childNodes, "satellites"):
60 #for x in elementsWithTag(entries.childNodes, "sat"):
61 ##print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
62 #tpos = x.getAttribute('position')
63 #tname = x.getAttribute('name')
64 ##tname.encode('utf8')
65 #self.satellites[tpos] = tname
66 #self.satList.append( (tname, tpos) )
68 def getNimType(self, slotID):
69 #FIXME get it from /proc
71 return self.nimType["DVB-S"]
73 return self.nimType["empty/unknown"]
75 def getNimName(self, slotID):
76 #FIXME get it from /proc
79 def getNimSocketCount(self):
80 #FIXME get it from /proc
83 def getConfigPrefix(self, slotid):
84 return "config.Nim" + ("A","B","C","D")[slotid] + "."
88 self.nimType = { "empty/unknown": -1,
94 self.readSatsfromFile()
96 self.nimCount = self.getNimSocketCount()
100 while x < self.nimCount:
101 tType = self.getNimType(x)
102 tName = self.getNimName(x)
103 tNim = nimSlot(x, tType, tName)
104 self.nimslots.append(tNim)
107 InitNimManager(self) #init config stuff
111 for slot in self.nimslots:
112 nimText = "Socket " + ("A", "B", "C", "D")[slot.slotid] + ": "
113 if slot.nimType == -1:
114 nimText += "empty/unknown"
116 nimText += slot.name + " ("
117 nimText += ("DVB-S", "DVB-C", "DVB-T")[slot.nimType] + ")"
118 list.append((nimText, slot))
121 #callbacks for c++ config
122 def nimConfigModeChanged(self, slotid, mode):
123 print "nimConfigModeChanged set to " + str(mode)
124 def nimDiseqcModeChanged(self, slotid, mode):
125 print "nimDiseqcModeChanged set to " + str(mode)
126 def nimPortAChanged(self, slotid, val):
127 print "nimDiseqcA set to " + str(val)
128 def nimPortBChanged(self, slotid, val):
129 print "nimDiseqcB set to " + str(val)
130 def nimPortCChanged(self, slotid, val):
131 print "nimDiseqcC set to " + str(val)
132 def nimPortDChanged(self, slotid, val):
133 print "nimDiseqcD set to " + str(val)
136 def InitNimManager(nimmgr):
137 config.Nims = [ConfigSubsection()] * nimmgr.nimCount
139 def nimConfigModeChanged(slotid, configElement):
140 nimmgr.nimConfigModeChanged(slotid, configElement.value)
141 def nimDiseqcModeChanged(slotid, configElement):
142 nimmgr.nimDiseqcModeChanged(slotid, configElement.value)
144 def nimPortAChanged(slotid, configElement):
145 nimmgr.nimPortAChanged(slotid, configElement.vals[configElement.value][1])
146 def nimPortBChanged(slotid, configElement):
147 nimmgr.nimPortBChanged(slotid, configElement.vals[configElement.value][1])
148 def nimPortCChanged(slotid, configElement):
149 nimmgr.nimPortCChanged(slotid, configElement.vals[configElement.value][1])
150 def nimPortDChanged(slotid, configElement):
151 nimmgr.nimPortDChanged(slotid, configElement.vals[configElement.value][1])
153 for slot in nimmgr.nimslots:
155 cname = nimmgr.getConfigPrefix(x)
157 if slot.nimType == nimmgr.nimType["DVB-S"]:
158 config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
159 config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 2, ("Single", "Toneburst A/B", "DiSEqC A/B", "DiSEqC A/B/C/D", "Positioner"));
160 config.Nims[x].diseqcA = configElement(cname + "diseqcA",configSatlist, 192, nimmgr.satList);
161 config.Nims[x].diseqcB = configElement(cname + "diseqcB",configSatlist, 130, nimmgr.satList);
162 config.Nims[x].diseqcC = configElement(cname + "diseqcC",configSatlist, 0, nimmgr.satList);
163 config.Nims[x].diseqcD = configElement(cname + "diseqcD",configSatlist, 0, nimmgr.satList);
164 config.Nims[x].longitude = configElement(cname + "longitude",configSequence, [0,0], (("."), (1,999)));
165 config.Nims[x].latitude = configElement(cname + "latitude",configSequence, [0,0], (("."), (1,999)));
167 #perhaps the instance of the slot is more useful?
168 config.Nims[x].configMode.addNotifier(boundFunction(nimConfigModeChanged,x))
169 config.Nims[x].diseqcMode.addNotifier(boundFunction(nimDiseqcModeChanged,x))
170 config.Nims[x].diseqcA.addNotifier(boundFunction(nimPortAChanged,x))
171 config.Nims[x].diseqcB.addNotifier(boundFunction(nimPortBChanged,x))
172 config.Nims[x].diseqcC.addNotifier(boundFunction(nimPortCChanged,x))
173 config.Nims[x].diseqcD.addNotifier(boundFunction(nimPortDChanged,x))
175 print "pls add support for this frontend type!"
177 nimmanager = NimManager()