1371e6ee39f341d1504ceede1f967a6416ef57f6
[enigma2.git] / lib / python / Screens / Satconfig.py
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
9
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))
14                 else:                                                   # > 1 Sats
15                         list.append(getConfigListEntry(_("Port A"), config.Nims[nim.slotid].diseqcA))
16
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))
22         def createPositionerSetup(self, nim, list):
23                 list.append(getConfigListEntry(_("Longitude"), config.Nims[nim.slotid].longitude))
24                 list.append(getConfigListEntry(_("Latitude"), config.Nims[nim.slotid].latitude))
25                 pass
26         
27         def createSetup(self):
28                 self.list = [ ]
29                 
30                 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
31                         self.list.append(getConfigListEntry(_("Configmode"), config.Nims[self.nim.slotid].configMode))
32                         
33                         if config.Nims[self.nim.slotid].configMode.value == 0:                  #simple setup
34                                 self.list.append(getConfigListEntry(_("Diseqcmode"), config.Nims[self.nim.slotid].diseqcMode))
35                         
36                                 if (0 <= config.Nims[self.nim.slotid].diseqcMode.value < 4):
37                                         self.createSimpleSetup(self.nim, self.list, config.Nims[self.nim.slotid].diseqcMode.value)
38                                 if (config.Nims[self.nim.slotid].diseqcMode.value == 4):
39                                         self.createPositionerSetup(self.nim, self.list)
40                         else:   
41                                 print "FIXME: implement advanced mode"
42
43                 self["config"].list = self.list
44                 self["config"].l.setList(self.list)
45                 
46         def newConfig(self):    
47                 if self["config"].getCurrent()[0] == _("Diseqcmode"):
48                         self.createSetup()
49                 if self["config"].getCurrent()[0] == _("Configmode"):
50                         self.createSetup()
51                 
52         def keyLeft(self):
53                 self["config"].handleKey(config.key["prevElement"])
54                 self.newConfig()
55
56         def keyRight(self):
57                 #forbid to enable advanced mode until its ready
58                 if self["config"].getCurrent()[0] != _("Configmode"):
59                         self["config"].handleKey(config.key["nextElement"])
60                 self.newConfig()
61
62         def keyNumberGlobal(self, number):
63                 print "You pressed number " + str(number)
64                 if (self["config"].getCurrent()[1].parent.enabled == True):
65                         self["config"].handleKey(config.key[str(number)])
66
67         def keySave(self):
68                 for x in self["config"].list:
69                         x[1].save()
70                 nimmanager.sec.update() 
71                 self.close()
72
73         def keyCancel(self):
74                 for x in self["config"].list:
75                         x[1].cancel()
76                 self.close()
77
78         def __init__(self, session, nim):
79                 Screen.__init__(self, session)
80                 self.nim = nim
81                 
82                 self["actions"] = NumberActionMap(["SetupActions"],
83                 {
84                         "ok": self.keySave,
85                         "cancel": self.keyCancel,
86                         "left": self.keyLeft,
87                         "right": self.keyRight,
88                         "1": self.keyNumberGlobal,
89                         "2": self.keyNumberGlobal,
90                         "3": self.keyNumberGlobal,
91                         "4": self.keyNumberGlobal,
92                         "5": self.keyNumberGlobal,
93                         "6": self.keyNumberGlobal,
94                         "7": self.keyNumberGlobal,
95                         "8": self.keyNumberGlobal,
96                         "9": self.keyNumberGlobal,
97                         "0": self.keyNumberGlobal
98                 }, -1)
99
100                 self.list = [ ]
101                 self["config"] = ConfigList(self.list)
102                 
103                 self.createSetup()
104
105 class NimSelection(Screen):
106         def __init__(self, session):
107                 Screen.__init__(self, session)
108
109                 self["nimlist"] = MenuList(nimmanager.nimList())
110
111                 self["actions"] = ActionMap(["OkCancelActions"],
112                 {
113                         "ok": self.okbuttonClick ,
114                         "cancel": self.close
115                 }, -1)
116
117         def okbuttonClick(self):
118                 selection = self["nimlist"].getCurrent()
119                 if selection[1].nimType != -1:  #unknown/empty
120                         self.session.open(NimSetup, selection[1])
121