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(_("Configmode"), config.Nims[self.nim.slotid].configMode))
39 if config.Nims[self.nim.slotid].configMode.value == 0: #simple setup
40 self.list.append(getConfigListEntry(_("Diseqcmode"), 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] == _("Diseqcmode"):
64 if self["config"].getCurrent()[0] == _("Configmode"):
68 self["config"].handleKey(config.key["prevElement"])
72 #forbid to enable advanced mode until its ready
73 #perhaps its better to use an own element here
74 #this suckz .. how enable advanced config?
75 if self["config"].getCurrent()[0] == _("Configmode"):
76 if self.nim.slotid == 0:
79 self["config"].handleKey(config.key["nextElement"])
82 def keyNumberGlobal(self, number):
83 print "You pressed number " + str(number)
84 if (self["config"].getCurrent()[1].parent.enabled == True):
85 self["config"].handleKey(config.key[str(number)])
88 for x in self["config"].list:
90 nimmanager.sec.update()
94 for x in self["config"].list:
98 def __init__(self, session, nim):
99 Screen.__init__(self, session)
102 self["actions"] = NumberActionMap(["SetupActions"],
105 "cancel": self.keyCancel,
106 "left": self.keyLeft,
107 "right": self.keyRight,
108 "1": self.keyNumberGlobal,
109 "2": self.keyNumberGlobal,
110 "3": self.keyNumberGlobal,
111 "4": self.keyNumberGlobal,
112 "5": self.keyNumberGlobal,
113 "6": self.keyNumberGlobal,
114 "7": self.keyNumberGlobal,
115 "8": self.keyNumberGlobal,
116 "9": self.keyNumberGlobal,
117 "0": self.keyNumberGlobal
121 self["config"] = ConfigList(self.list)
125 class NimSelection(Screen):
126 def __init__(self, session):
127 Screen.__init__(self, session)
129 self["nimlist"] = MenuList(nimmanager.nimList())
131 self["actions"] = ActionMap(["OkCancelActions"],
133 "ok": self.okbuttonClick ,
137 def okbuttonClick(self):
138 selection = self["nimlist"].getCurrent()
139 if selection[1].nimType != -1: #unknown/empty
140 self.session.open(NimSetup, selection[1])