define movepaths for MovingPixmaps and proof of concept in the start-wizard
[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         
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
31                         pass
32         
33         def createSetup(self):
34                 self.list = [ ]
35                 
36                 if (nimmanager.getNimType(self.nim.slotid) == nimmanager.nimType["DVB-S"]):
37                         self.list.append(getConfigListEntry(_("Configmode"), config.Nims[self.nim.slotid].configMode))
38                         
39                         if config.Nims[self.nim.slotid].configMode.value == 0:                  #simple setup
40                                 self.list.append(getConfigListEntry(_("Diseqcmode"), config.Nims[self.nim.slotid].diseqcMode))
41                         
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))
48                                 pass
49                         elif config.Nims[self.nim.slotid].configMode.value == 2: # advanced mode
50                                 print "FIXME: implement advanced mode"
51                 
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))
56
57
58                 self["config"].list = self.list
59                 self["config"].l.setList(self.list)
60                 
61         def newConfig(self):    
62                 if self["config"].getCurrent()[0] == _("Diseqcmode"):
63                         self.createSetup()
64                 if self["config"].getCurrent()[0] == _("Configmode"):
65                         self.createSetup()
66                 
67         def keyLeft(self):
68                 if self["config"].getCurrent()[0] == _("Configmode"):
69                         if self.nim.slotid == 0:
70                                 return
71                 self["config"].handleKey(config.key["prevElement"])
72                 self.newConfig()
73
74         def keyRight(self):
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] == _("Configmode"):
79                         if self.nim.slotid == 0:
80                                 return
81
82                 self["config"].handleKey(config.key["nextElement"])
83                 self.newConfig()
84
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)])
89
90         def keySave(self):
91                 for x in self["config"].list:
92                         x[1].save()
93                 nimmanager.sec.update() 
94                 self.close()
95
96         def keyCancel(self):
97                 for x in self["config"].list:
98                         x[1].cancel()
99                 self.close()
100
101         def __init__(self, session, nim):
102                 Screen.__init__(self, session)
103                 self.nim = nim
104                 
105                 self["actions"] = NumberActionMap(["SetupActions"],
106                 {
107                         "ok": self.keySave,
108                         "cancel": self.keyCancel,
109                         "left": self.keyLeft,
110                         "right": self.keyRight,
111                         "1": self.keyNumberGlobal,
112                         "2": self.keyNumberGlobal,
113                         "3": self.keyNumberGlobal,
114                         "4": self.keyNumberGlobal,
115                         "5": self.keyNumberGlobal,
116                         "6": self.keyNumberGlobal,
117                         "7": self.keyNumberGlobal,
118                         "8": self.keyNumberGlobal,
119                         "9": self.keyNumberGlobal,
120                         "0": self.keyNumberGlobal
121                 }, -1)
122
123                 self.list = [ ]
124                 self["config"] = ConfigList(self.list)
125                 
126                 self.createSetup()
127
128 class NimSelection(Screen):
129         def __init__(self, session):
130                 Screen.__init__(self, session)
131
132                 self["nimlist"] = MenuList(nimmanager.nimList())
133
134                 self["actions"] = ActionMap(["OkCancelActions"],
135                 {
136                         "ok": self.okbuttonClick ,
137                         "cancel": self.close
138                 }, -1)
139
140         def okbuttonClick(self):
141                 selection = self["nimlist"].getCurrent()
142                 if selection[1].nimType != -1:  #unknown/empty
143                         self.session.open(NimSetup, selection[1])
144