Merge branch 'bug_599_picload_fd_leak' into experimental
[vuplus_dvbapp] / lib / python / Screens / Wizard.py
1 from Screen import Screen
2 from Screens.HelpMenu import HelpableScreen
3 from Screens.MessageBox import MessageBox
4 from Components.config import config, ConfigText, ConfigPassword, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_0, KEY_DELETE, KEY_BACKSPACE, KEY_OK, KEY_TOGGLEOW, KEY_ASCII, KEY_TIMEOUT, KEY_NUMBERS
5
6 from Components.Label import Label
7 from Components.Sources.StaticText import StaticText
8 from Components.Slider import Slider
9 from Components.ActionMap import NumberActionMap
10 from Components.MenuList import MenuList
11 from Components.ConfigList import ConfigList
12 from Components.Sources.List import List
13 from enigma import eTimer, eEnv
14
15 from xml.sax import make_parser
16 from xml.sax.handler import ContentHandler
17
18 class WizardSummary(Screen):
19         skin = """
20         <screen position="0,0" size="132,64">
21                 <widget source="text" render="Label" position="6,0" size="120,16" font="Regular;16" transparent="1" />
22                 <widget source="parent.list" render="Label" position="6,18" size="120,46" font="Regular;12">
23                         <convert type="StringListSelection" />
24                 </widget>
25         </screen>"""
26         
27         def __init__(self, session, parent):
28                 Screen.__init__(self, session, parent)
29                 
30                 #names = parent.skinName
31                 #if not isinstance(names, list):
32                         #names = [names]
33 #                       
34                 #self.skinName = [x + "_summary" for x in names ]
35                 #self.skinName.append("Wizard")
36                 #print "*************+++++++++++++++++****************++++++++++******************* WizardSummary", self.skinName
37                         #
38                 self["text"] = StaticText("")
39                 self.onShow.append(self.setCallback)
40                 
41         def setCallback(self):
42                 self.parent.setLCDTextCallback(self.setText)
43                 
44         def setText(self, text):
45                 self["text"].setText(text)
46
47 class Wizard(Screen):
48         def createSummary(self):
49                         print "WizardCreateSummary"
50                         return WizardSummary
51
52         class parseWizard(ContentHandler):
53                 def __init__(self, wizard):
54                         self.isPointsElement, self.isReboundsElement = 0, 0
55                         self.wizard = wizard
56                         self.currContent = ""
57                         self.lastStep = 0       
58
59                 def startElement(self, name, attrs):
60                         #print "startElement", name
61                         self.currContent = name
62                         if (name == "step"):
63                                 self.lastStep += 1
64                                 if attrs.has_key('id'):
65                                         id = str(attrs.get('id'))
66                                 else:
67                                         id = ""
68                                 #print "id:", id
69                                 if attrs.has_key('nextstep'):
70                                         nextstep = str(attrs.get('nextstep'))
71                                 else:
72                                         nextstep = None
73                                 if attrs.has_key('timeout'):
74                                         timeout = int(attrs.get('timeout'))
75                                 else:
76                                         timeout = None
77                                 if attrs.has_key('timeoutaction'):
78                                         timeoutaction = str(attrs.get('timeoutaction'))
79                                 else:
80                                         timeoutaction = 'nextpage'
81
82                                 if attrs.has_key('timeoutstep'):
83                                         timeoutstep = str(attrs.get('timeoutstep'))
84                                 else:
85                                         timeoutstep = ''
86                                 self.wizard[self.lastStep] = {"id": id, "condition": "", "text": "", "timeout": timeout, "timeoutaction": timeoutaction, "timeoutstep": timeoutstep, "list": [], "config": {"screen": None, "args": None, "type": "" }, "code": "", "codeafter": "", "code_async": "", "codeafter_async": "", "nextstep": nextstep}
87                                 if attrs.has_key('laststep'):
88                                         self.wizard[self.lastStep]["laststep"] = str(attrs.get('laststep'))
89                         elif (name == "text"):
90                                 self.wizard[self.lastStep]["text"] = str(attrs.get('value')).replace("\\n", "\n")
91                         elif (name == "displaytext"):
92                                 self.wizard[self.lastStep]["displaytext"] = str(attrs.get('value')).replace("\\n", "\n")
93                         elif (name == "list"):
94                                 if (attrs.has_key('type')):
95                                         if attrs["type"] == "dynamic":
96                                                 self.wizard[self.lastStep]["dynamiclist"] = attrs.get("source")
97                                         #self.wizard[self.lastStep]["list"].append(("Hallo", "test"))
98                                 if (attrs.has_key("evaluation")):
99                                         #print "evaluation"
100                                         self.wizard[self.lastStep]["listevaluation"] = attrs.get("evaluation")
101                                 if (attrs.has_key("onselect")):
102                                         self.wizard[self.lastStep]["onselect"] = attrs.get("onselect")                  
103                         elif (name == "listentry"):
104                                 self.wizard[self.lastStep]["list"].append((str(attrs.get('caption')), str(attrs.get('step'))))
105                         elif (name == "config"):
106                                 type = str(attrs.get('type'))
107                                 self.wizard[self.lastStep]["config"]["type"] = type
108                                 if type == "ConfigList" or type == "standalone":
109                                         try:
110                                                 exec "from Screens." + str(attrs.get('module')) + " import *"
111                                         except:
112                                                 exec "from " + str(attrs.get('module')) + " import *"
113                                 
114                                         self.wizard[self.lastStep]["config"]["screen"] = eval(str(attrs.get('screen')))
115                                         if (attrs.has_key('args')):
116                                                 #print "has args"
117                                                 self.wizard[self.lastStep]["config"]["args"] = str(attrs.get('args'))
118                                 elif type == "dynamic":
119                                         self.wizard[self.lastStep]["config"]["source"] = str(attrs.get('source'))
120                                         if (attrs.has_key('evaluation')):
121                                                 self.wizard[self.lastStep]["config"]["evaluation"] = str(attrs.get('evaluation'))
122                         elif (name == "code"):
123                                 self.async_code = attrs.has_key('async') and str(attrs.get('async')) == "yes"
124                                 if attrs.has_key('pos') and str(attrs.get('pos')) == "after":
125                                         self.codeafter = True
126                                 else:
127                                         self.codeafter = False
128                         elif (name == "condition"):
129                                 pass
130                         
131                 def endElement(self, name):
132                         self.currContent = ""
133                         if name == 'code':
134                                 if self.async_code:
135                                         if self.codeafter:
136                                                 self.wizard[self.lastStep]["codeafter_async"] = self.wizard[self.lastStep]["codeafter_async"].strip()
137                                         else:
138                                                 self.wizard[self.lastStep]["code_async"] = self.wizard[self.lastStep]["code_async"].strip()
139                                 else:
140                                         if self.codeafter:
141                                                 self.wizard[self.lastStep]["codeafter"] = self.wizard[self.lastStep]["codeafter"].strip()
142                                         else:
143                                                 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"].strip()
144                         elif name == 'condition':
145                                 self.wizard[self.lastStep]["condition"] = self.wizard[self.lastStep]["condition"].strip()
146                         elif name == 'step':
147                                 #print "Step number", self.lastStep, ":", self.wizard[self.lastStep]
148                                 pass
149                                                                 
150                 def characters(self, ch):
151                         if self.currContent == "code":
152                                 if self.async_code:
153                                         if self.codeafter:
154                                                 self.wizard[self.lastStep]["codeafter_async"] = self.wizard[self.lastStep]["codeafter_async"] + ch
155                                         else:
156                                                 self.wizard[self.lastStep]["code_async"] = self.wizard[self.lastStep]["code_async"] + ch
157                                 else:
158                                         if self.codeafter:
159                                                 self.wizard[self.lastStep]["codeafter"] = self.wizard[self.lastStep]["codeafter"] + ch
160                                         else:
161                                                 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"] + ch
162                         elif self.currContent == "condition":
163                                  self.wizard[self.lastStep]["condition"] = self.wizard[self.lastStep]["condition"] + ch
164         
165         def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True):
166                 Screen.__init__(self, session)
167                 
168                 self.isLastWizard = False # can be used to skip a "goodbye"-screen in a wizard
169
170                 self.stepHistory = []
171
172                 self.wizard = {}
173                 parser = make_parser()
174                 if not isinstance(self.xmlfile, list):
175                         self.xmlfile = [self.xmlfile]
176                 print "Reading ", self.xmlfile
177                 wizardHandler = self.parseWizard(self.wizard)
178                 parser.setContentHandler(wizardHandler)
179                 for xmlfile in self.xmlfile:
180                         if xmlfile[0] != '/':
181                                 parser.parse(eEnv.resolve('${datadir}/enigma2/') + xmlfile)
182                         else:
183                                 parser.parse(xmlfile)
184
185                 self.showSteps = showSteps
186                 self.showStepSlider = showStepSlider
187                 self.showList = showList
188                 self.showConfig = showConfig
189
190                 self.numSteps = len(self.wizard)
191                 self.currStep = self.getStepWithID("start") + 1
192                 
193                 self.timeoutTimer = eTimer()
194                 self.timeoutTimer.callback.append(self.timeoutCounterFired)
195
196                 self["text"] = Label()
197
198                 if showConfig:
199                         self["config"] = ConfigList([], session = session)
200
201                 if self.showSteps:
202                         self["step"] = Label()
203                 
204                 if self.showStepSlider:
205                         self["stepslider"] = Slider(1, self.numSteps)
206                 
207                 if self.showList:
208                         self.list = []
209                         self["list"] = List(self.list, enableWrapAround = True)
210                         self["list"].onSelectionChanged.append(self.selChanged)
211                         #self["list"] = MenuList(self.list, enableWrapAround = True)
212
213                 self.onShown.append(self.updateValues)
214
215                 self.configInstance = None
216                 self.currentConfigIndex = None
217                 
218                 self.lcdCallbacks = []
219                 
220                 self.disableKeys = False
221                 
222                 self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions", "InputAsciiActions", "KeyboardInputActions"],
223                 {
224                         "gotAsciiCode": self.keyGotAscii,
225                         "ok": self.ok,
226                         "back": self.back,
227                         "left": self.left,
228                         "right": self.right,
229                         "up": self.up,
230                         "down": self.down,
231                         "red": self.red,
232                         "green": self.green,
233                         "yellow": self.yellow,
234                         "blue":self.blue,
235                         "deleteBackward": self.deleteBackward,
236                         "deleteForward": self.deleteForward,
237                         "1": self.keyNumberGlobal,
238                         "2": self.keyNumberGlobal,
239                         "3": self.keyNumberGlobal,
240                         "4": self.keyNumberGlobal,
241                         "5": self.keyNumberGlobal,
242                         "6": self.keyNumberGlobal,
243                         "7": self.keyNumberGlobal,
244                         "8": self.keyNumberGlobal,
245                         "9": self.keyNumberGlobal,
246                         "0": self.keyNumberGlobal
247                 }, -1)
248
249                 self["VirtualKB"] = NumberActionMap(["VirtualKeyboardActions"],
250                 {
251                         "showVirtualKeyboard": self.KeyText,
252                 }, -2)
253                 
254                 self["VirtualKB"].setEnabled(False)
255                 
256         def red(self):
257                 print "red"
258                 pass
259
260         def green(self):
261                 print "green"
262                 pass
263         
264         def yellow(self):
265                 print "yellow"
266                 pass
267         
268         def blue(self):
269                 print "blue"
270                 pass
271         
272         def deleteForward(self):
273                 self.resetCounter()
274                 if (self.wizard[self.currStep]["config"]["screen"] != None):
275                         self.configInstance.keyDelete()
276                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
277                         self["config"].handleKey(KEY_DELETE)
278                 print "deleteForward"
279
280         def deleteBackward(self):
281                 self.resetCounter()
282                 if (self.wizard[self.currStep]["config"]["screen"] != None):
283                         self.configInstance.keyBackspace()
284                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
285                         self["config"].handleKey(KEY_BACKSPACE)
286                 print "deleteBackward"
287         
288         def setLCDTextCallback(self, callback):
289                 self.lcdCallbacks.append(callback)
290
291         def back(self):
292                 if self.disableKeys:
293                         return
294                 print "getting back..."
295                 print "stepHistory:", self.stepHistory
296                 if len(self.stepHistory) > 1:
297                         self.currStep = self.stepHistory[-2]
298                         self.stepHistory = self.stepHistory[:-2]
299                 else:
300                         self.session.openWithCallback(self.exitWizardQuestion, MessageBox, (_("Are you sure you want to exit this wizard?") ) )
301                 if self.currStep < 1:
302                         self.currStep = 1
303                 print "currStep:", self.currStep
304                 print "new stepHistory:", self.stepHistory
305                 self.updateValues()
306                 print "after updateValues stepHistory:", self.stepHistory
307                 
308         def exitWizardQuestion(self, ret = False):
309                 if (ret):
310                         self.markDone()
311                         self.close()
312                 
313         def markDone(self):
314                 pass
315         
316         def getStepWithID(self, id):
317                 print "getStepWithID:", id
318                 count = 0
319                 for x in self.wizard.keys():
320                         if self.wizard[x]["id"] == id:
321                                 print "result:", count
322                                 return count
323                         count += 1
324                 print "result: nothing"
325                 return 0
326
327         def finished(self, gotoStep = None, *args, **kwargs):
328                 print "finished"
329                 currStep = self.currStep
330
331                 if self.updateValues not in self.onShown:
332                         self.onShown.append(self.updateValues)
333                         
334                 if self.showConfig:
335                         if self.wizard[currStep]["config"]["type"] == "dynamic":
336                                 eval("self." + self.wizard[currStep]["config"]["evaluation"])()
337
338                 if self.showList:
339                         if (len(self.wizard[currStep]["evaluatedlist"]) > 0):
340                                 print "current:", self["list"].current
341                                 nextStep = self["list"].current[1]
342                                 if (self.wizard[currStep].has_key("listevaluation")):
343                                         exec("self." + self.wizard[self.currStep]["listevaluation"] + "('" + nextStep + "')")
344                                 else:
345                                         self.currStep = self.getStepWithID(nextStep)
346
347                 print_now = True
348                 if ((currStep == self.numSteps and self.wizard[currStep]["nextstep"] is None) or self.wizard[currStep]["id"] == "end"): # wizard finished
349                         print "wizard finished"
350                         self.markDone()
351                         self.close()
352                 else:
353                         self.codeafter = True
354                         self.runCode(self.wizard[currStep]["codeafter"])
355                         self.prevStep = currStep
356                         self.gotoStep = gotoStep
357                         if not self.runCode(self.wizard[currStep]["codeafter_async"]):
358                                 self.afterAsyncCode()
359                         else:
360                                 if self.updateValues in self.onShown:
361                                         self.onShown.remove(self.updateValues)
362
363                 if print_now:
364                         print "Now: " + str(self.currStep)
365
366         def ok(self):
367                 print "OK"
368                 if self.disableKeys:
369                         return
370                 currStep = self.currStep
371                 
372                 if self.showConfig:
373                         if (self.wizard[currStep]["config"]["screen"] != None):
374                                 # TODO: don't die, if no run() is available
375                                 # there was a try/except here, but i can't see a reason
376                                 # for this. If there is one, please do a more specific check
377                                 # and/or a comment in which situation there is no run()
378                                 if callable(getattr(self.configInstance, "runAsync", None)):
379                                         if self.updateValues in self.onShown:
380                                                 self.onShown.remove(self.updateValues)
381                                         self.configInstance.runAsync(self.finished)
382                                         return
383                                 else:
384                                         self.configInstance.run()
385                 self.finished()
386
387         def keyNumberGlobal(self, number):
388                 if (self.wizard[self.currStep]["config"]["screen"] != None):
389                         self.configInstance.keyNumberGlobal(number)
390                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
391                         self["config"].handleKey(KEY_0 + number)
392
393         def keyGotAscii(self):
394                 if (self.wizard[self.currStep]["config"]["screen"] != None):
395                         self["config"].handleKey(KEY_ASCII)
396                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
397                         self["config"].handleKey(KEY_ASCII)
398                 
399         def left(self):
400                 self.resetCounter()
401                 if (self.wizard[self.currStep]["config"]["screen"] != None):
402                         self.configInstance.keyLeft()
403                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
404                         self["config"].handleKey(KEY_LEFT)
405                 print "left"
406         
407         def right(self):
408                 self.resetCounter()
409                 if (self.wizard[self.currStep]["config"]["screen"] != None):
410                         self.configInstance.keyRight()
411                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
412                         self["config"].handleKey(KEY_RIGHT)     
413                 print "right"
414
415         def up(self):
416                 self.resetCounter()
417                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
418                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
419                         self.handleInputHelpers()
420                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
421                         self["list"].selectPrevious()
422                         if self.wizard[self.currStep].has_key("onselect"):
423                                 print "current:", self["list"].current
424                                 self.selection = self["list"].current[-1]
425                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
426                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
427                 print "up"
428                 
429         def down(self):
430                 self.resetCounter()
431                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
432                         self["config"].instance.moveSelection(self["config"].instance.moveDown)
433                         self.handleInputHelpers()
434                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
435                         #self["list"].instance.moveSelection(self["list"].instance.moveDown)
436                         self["list"].selectNext()
437                         if self.wizard[self.currStep].has_key("onselect"):
438                                 print "current:", self["list"].current
439                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
440                                 #exec("self." + self.wizard[self.currStep]["onselect"] + "()")
441                                 self.selection = self["list"].current[-1]
442                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
443                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
444                 print "down"
445                 
446         def selChanged(self):
447                 self.resetCounter()
448                 
449                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
450                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
451                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
452                         if self.wizard[self.currStep].has_key("onselect"):
453                                 self.selection = self["list"].current[-1]
454                                 print "self.selection:", self.selection
455                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
456                 
457         def resetCounter(self):
458                 self.timeoutCounter = self.wizard[self.currStep]["timeout"]
459                 
460         def runCode(self, code):
461                 if code != "":
462                         print "code", code
463                         exec(code)
464                         return True
465                 return False
466
467         def getTranslation(self, text):
468                 return _(text)
469                         
470         def updateText(self, firstset = False):
471                 text = self.getTranslation(self.wizard[self.currStep]["text"])
472                 if text.find("[timeout]") != -1:
473                         text = text.replace("[timeout]", str(self.timeoutCounter))
474                         self["text"].setText(text)
475                 else:
476                         if firstset:
477                                 self["text"].setText(text)
478                 
479         def updateValues(self):
480                 print "Updating values in step " + str(self.currStep)
481                 # calling a step which doesn't exist can only happen if the condition in the last step is not fulfilled
482                 # if a non-existing step is called, end the wizard 
483                 if self.currStep > len(self.wizard):
484                         self.markDone()
485                         self.close()
486                         return
487
488                 self.timeoutTimer.stop()
489                 
490                 if self.configInstance is not None:
491                         # remove callbacks
492                         self.configInstance["config"].onSelectionChanged = []
493                         del self.configInstance["config"]
494                         self.configInstance.doClose()
495                         self.configInstance = None
496
497                 self.condition = True
498                 exec (self.wizard[self.currStep]["condition"])
499                 if not self.condition:
500                         print "keys*******************:", self.wizard[self.currStep].keys()
501                         if self.wizard[self.currStep].has_key("laststep"): # exit wizard, if condition of laststep doesn't hold
502                                 self.markDone()
503                                 self.close()
504                                 return
505                         else:
506                                 self.currStep += 1
507                                 self.updateValues()
508                 else:
509                         if self.wizard[self.currStep].has_key("displaytext"):
510                                 displaytext = self.wizard[self.currStep]["displaytext"]
511                                 print "set LCD text"
512                                 for x in self.lcdCallbacks:
513                                         x(displaytext)
514                         if len(self.stepHistory) == 0 or self.stepHistory[-1] != self.currStep:
515                                 self.stepHistory.append(self.currStep)
516                         print "wizard step:", self.wizard[self.currStep]
517                         
518                         if self.showSteps:
519                                 self["step"].setText(self.getTranslation("Step ") + str(self.currStep) + "/" + str(self.numSteps))
520                         if self.showStepSlider:
521                                 self["stepslider"].setValue(self.currStep)
522                 
523                         if self.wizard[self.currStep]["timeout"] is not None:
524                                 self.resetCounter() 
525                                 self.timeoutTimer.start(1000)
526                         
527                         print "wizard text", self.getTranslation(self.wizard[self.currStep]["text"])
528                         self.updateText(firstset = True)
529                         if self.wizard[self.currStep].has_key("displaytext"):
530                                 displaytext = self.wizard[self.currStep]["displaytext"]
531                                 print "set LCD text"
532                                 for x in self.lcdCallbacks:
533                                         x(displaytext)
534                                 
535                         self.codeafter=False
536                         self.runCode(self.wizard[self.currStep]["code"])
537                         if self.runCode(self.wizard[self.currStep]["code_async"]):
538                                 if self.updateValues in self.onShown:
539                                         self.onShown.remove(self.updateValues)
540                         else:
541                                 self.afterAsyncCode()
542
543         def afterAsyncCode(self):
544                 if not self.updateValues in self.onShown:
545                         self.onShown.append(self.updateValues)
546
547                 if self.codeafter:
548                         if self.wizard[self.prevStep]["nextstep"] is not None:
549                                 self.currStep = self.getStepWithID(self.wizard[self.prevStep]["nextstep"])
550                         if self.gotoStep is not None:
551                                 self.currStep = self.getStepWithID(self.gotoStep)
552                         self.currStep += 1
553                         self.updateValues()
554                         print "Now: " + str(self.currStep)
555                 else:
556                         if self.showList:
557                                 print "showing list,", self.currStep
558                                 for renderer in self.renderer:
559                                         rootrenderer = renderer
560                                         while renderer.source is not None:
561                                                 print "self.list:", self["list"]
562                                                 if renderer.source is self["list"]:
563                                                         print "setZPosition"
564                                                         rootrenderer.instance.setZPosition(1)
565                                                 renderer = renderer.source
566
567                                 #self["list"].instance.setZPosition(1)
568                                 self.list = []
569                                 if (self.wizard[self.currStep].has_key("dynamiclist")):
570                                         print "dynamic list, calling",  self.wizard[self.currStep]["dynamiclist"]
571                                         newlist = eval("self." + self.wizard[self.currStep]["dynamiclist"] + "()")
572                                         #self.wizard[self.currStep]["evaluatedlist"] = []
573                                         for entry in newlist:
574                                                 #self.wizard[self.currStep]["evaluatedlist"].append(entry)
575                                                 self.list.append(entry)
576                                         #del self.wizard[self.currStep]["dynamiclist"]
577                                 if (len(self.wizard[self.currStep]["list"]) > 0):
578                                         #self["list"].instance.setZPosition(2)
579                                         for x in self.wizard[self.currStep]["list"]:
580                                                 self.list.append((self.getTranslation(x[0]), x[1]))
581                                 self.wizard[self.currStep]["evaluatedlist"] = self.list
582                                 self["list"].list = self.list
583                                 self["list"].index = 0
584                         else:
585                                 self["list"].hide()
586         
587                         if self.showConfig:
588                                 print "showing config"
589                                 self["config"].instance.setZPosition(1)
590                                 if self.wizard[self.currStep]["config"]["type"] == "dynamic":
591                                                 print "config type is dynamic"
592                                                 self["config"].instance.setZPosition(2)
593                                                 self["config"].l.setList(eval("self." + self.wizard[self.currStep]["config"]["source"])())
594                                 elif (self.wizard[self.currStep]["config"]["screen"] != None):
595                                         if self.wizard[self.currStep]["config"]["type"] == "standalone":
596                                                 print "Type is standalone"
597                                                 self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
598                                         else:
599                                                 self["config"].instance.setZPosition(2)
600                                                 print "wizard screen", self.wizard[self.currStep]["config"]["screen"]
601                                                 if self.wizard[self.currStep]["config"]["args"] == None:
602                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
603                                                 else:
604                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
605                                                 self["config"].l.setList(self.configInstance["config"].list)
606                                                 callbacks = self.configInstance["config"].onSelectionChanged
607                                                 self.configInstance["config"].destroy()
608                                                 print "clearConfigList", self.configInstance["config"], self["config"]
609                                                 self.configInstance["config"] = self["config"]
610                                                 self.configInstance["config"].onSelectionChanged = callbacks
611                                                 print "clearConfigList", self.configInstance["config"], self["config"]
612                                 else:
613                                         self["config"].l.setList([])
614                                         self.handleInputHelpers()
615                                         
616                                         
617                         else:
618                                 if self.has_key("config"):
619                                         self["config"].hide()
620
621         def timeoutCounterFired(self):
622                 self.timeoutCounter -= 1
623                 print "timeoutCounter:", self.timeoutCounter
624                 if self.timeoutCounter == 0:
625                         if self.wizard[self.currStep]["timeoutaction"] == "selectnext":
626                                 print "selection next item"
627                                 self.down()
628                         else:
629                                 if self.wizard[self.currStep]["timeoutaction"] == "changestep":
630                                         self.finished(gotoStep = self.wizard[self.currStep]["timeoutstep"])
631                 self.updateText()
632
633         def handleInputHelpers(self):
634                 if self["config"].getCurrent() is not None:
635                         if isinstance(self["config"].getCurrent()[1], ConfigText) or isinstance(self["config"].getCurrent()[1], ConfigPassword):
636                                 if self.has_key("VKeyIcon"):
637                                         self["VirtualKB"].setEnabled(True)
638                                         self["VKeyIcon"].boolean = True
639                                 if self.has_key("HelpWindow"):
640                                         if self["config"].getCurrent()[1].help_window.instance is not None:
641                                                 helpwindowpos = self["HelpWindow"].getPosition()
642                                                 from enigma import ePoint
643                                                 self["config"].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
644                         else:
645                                 if self.has_key("VKeyIcon"):
646                                         self["VirtualKB"].setEnabled(False)
647                                         self["VKeyIcon"].boolean = False
648                 else:
649                         if self.has_key("VKeyIcon"):
650                                 self["VirtualKB"].setEnabled(False)
651                                 self["VKeyIcon"].boolean = False
652
653         def KeyText(self):
654                 from Screens.VirtualKeyBoard import VirtualKeyBoard
655                 self.currentConfigIndex = self["config"].getCurrentIndex()
656                 self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title = self["config"].getCurrent()[0], text = self["config"].getCurrent()[1].getValue())
657
658         def VirtualKeyBoardCallback(self, callback = None):
659                 if callback is not None and len(callback):
660                         if isinstance(self["config"].getCurrent()[1], ConfigText) or isinstance(self["config"].getCurrent()[1], ConfigPassword):
661                                 if self.has_key("HelpWindow"):
662                                         if self["config"].getCurrent()[1].help_window.instance is not None:
663                                                 helpwindowpos = self["HelpWindow"].getPosition()
664                                                 from enigma import ePoint
665                                                 self["config"].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
666                         self["config"].instance.moveSelectionTo(self.currentConfigIndex)
667                         self["config"].setCurrentIndex(self.currentConfigIndex)
668                         self["config"].getCurrent()[1].setValue(callback)
669                         self["config"].invalidate(self["config"].getCurrent())
670
671
672 class WizardManager:
673         def __init__(self):
674                 self.wizards = []
675         
676         def registerWizard(self, wizard, precondition, priority = 0):
677                 self.wizards.append((wizard, precondition, priority))
678         
679         def getWizards(self):
680                 # x[1] is precondition
681                 for wizard in self.wizards:
682                         wizard[0].isLastWizard = False
683                 if len(self.wizards) > 0:
684                         self.wizards[-1][0].isLastWizard = True
685                 return [(x[2], x[0]) for x in self.wizards if x[1] == 1]
686
687 wizardManager = WizardManager()