1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.ActionMap import ActionMap
4 from Components.ConfigList import ConfigList
5 from Components.config import *
6 from Components.MenuList import MenuList
7 from Components.NimManager import nimmanager
8 from Components.config import getConfigListEntry
10 class NimSetup(Screen):
11 def createSimpleSetup(self, nim, list, mode):
12 if mode == 0: #single Sat
13 list.append(getConfigListEntry(_("Satellite"), config.Nims[nim.slotid].diseqcA))
15 list.append(getConfigListEntry(_("Port A"), config.Nims[nim.slotid].diseqcA))
17 if mode >= 1: # > 1 Sats
18 list.append(getConfigListEntry(_("Port B"), config.Nims[nim.slotid].diseqcB))
19 if mode >= 3: # > 2 Sats
20 list.append(getConfigListEntry(_("Port C"), config.Nims[nim.slotid].diseqcC))
21 list.append(getConfigListEntry(_("Port D"), config.Nims[nim.slotid].diseqcD))
23 def createPositionerSetup(self, nim, list):
24 list.append(getConfigListEntry(_("Positioner mode"), config.Nims[nim.slotid].positionerMode))
25 if (config.Nims[nim.slotid].positionerMode.value == 0): # USALS
26 list.append(getConfigListEntry(_("Longitude"), config.Nims[nim.slotid].longitude))
27 list.append(getConfigListEntry("", config.Nims[nim.slotid].longitudeOrientation))
28 list.append(getConfigListEntry(_("Latitude"), config.Nims[nim.slotid].latitude))
29 list.append(getConfigListEntry("", config.Nims[nim.slotid].latitudeOrientation))
30 elif (config.Nims[nim.slotid].positionerMode.value == 1): # manual
33 def createSetup(self):
36 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
37 self.list.append(getConfigListEntry(_("Configuration Mode"), config.Nims[self.nim.slotid].configMode))
39 if config.Nims[self.nim.slotid].configMode.value == 0: #simple setup
40 self.list.append(getConfigListEntry(_("DiSEqC Mode"), config.Nims[self.nim.slotid].diseqcMode))
42 if (0 <= config.Nims[self.nim.slotid].diseqcMode.value < 4):
43 self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
44 if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
45 self.createPositionerSetup(self.nim, self.list)
46 elif config.Nims[self.nim.slotid].configMode.value == 1: # linked tuner
47 #self.list.append(getConfigListEntry(_("Linked to"), config.Nims[self.nim.slotid].linkedTo))
49 elif config.Nims[self.nim.slotid].configMode.value == 2: # advanced mode
50 print "FIXME: implement advanced mode"
52 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-C"]):
53 self.list.append(getConfigListEntry(_("Cable provider"), config.Nims[self.nim.slotid].cable))
54 elif (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-T"]):
55 self.list.append(getConfigListEntry(_("Terrestrial provider"), config.Nims[self.nim.slotid].terrestrial))
58 self["config"].list = self.list
59 self["config"].l.setList(self.list)
62 if self["config"].getCurrent()[0] == _("DiSEqC Mode"):
64 if self["config"].getCurrent()[0] == _("Configuration Mode"):
68 if self["config"].getCurrent()[0] == _("Configuration Mode"):
69 if self.nim.slotid == 0:
71 self["config"].handleKey(config.key["prevElement"])
75 #forbid to enable advanced mode until its ready
76 #perhaps its better to use an own element here
77 #this suckz .. how enable advanced config?
78 if self["config"].getCurrent()[0] == _("Configuration Mode"):
79 if self.nim.slotid == 0:
82 self["config"].handleKey(config.key["nextElement"])
85 def keyNumberGlobal(self, number):
86 print "You pressed number " + str(number)
87 if (self["config"].getCurrent()[1].parent.enabled == True):
88 self["config"].handleKey(config.key[str(number)])
91 for x in self["config"].list:
93 nimmanager.sec.update()
100 for x in self["config"].list:
104 def __init__(self, session, slotid):
105 Screen.__init__(self, session)
107 self.nim = nimmanager.nimList()[slotid][1]
109 self["actions"] = NumberActionMap(["SetupActions"],
112 "cancel": self.keyCancel,
113 "left": self.keyLeft,
114 "right": self.keyRight,
115 "1": self.keyNumberGlobal,
116 "2": self.keyNumberGlobal,
117 "3": self.keyNumberGlobal,
118 "4": self.keyNumberGlobal,
119 "5": self.keyNumberGlobal,
120 "6": self.keyNumberGlobal,
121 "7": self.keyNumberGlobal,
122 "8": self.keyNumberGlobal,
123 "9": self.keyNumberGlobal,
124 "0": self.keyNumberGlobal
128 self["config"] = ConfigList(self.list)
132 class NimSelection(Screen):
133 def __init__(self, session):
134 Screen.__init__(self, session)
136 self["nimlist"] = MenuList(nimmanager.nimList())
138 self["actions"] = ActionMap(["OkCancelActions"],
140 "ok": self.okbuttonClick ,
144 def okbuttonClick(self):
145 selection = self["nimlist"].getCurrent()
146 if selection[1].nimType != -1: #unknown/empty
147 self.session.open(NimSetup, selection[1].slotid)