Enigma2-{Wizard.py,Networksetup.py,ConfigList.py,skin_default.xml,NetworkWizard.py...
[enigma2.git] / 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
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('/usr/share/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
391         def keyGotAscii(self):
392                 if (self.wizard[self.currStep]["config"]["screen"] != None):
393                         self["config"].handleKey(KEY_ASCII)
394                 
395         def left(self):
396                 self.resetCounter()
397                 if (self.wizard[self.currStep]["config"]["screen"] != None):
398                         self.configInstance.keyLeft()
399                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
400                         self["config"].handleKey(KEY_LEFT)
401                 print "left"
402         
403         def right(self):
404                 self.resetCounter()
405                 if (self.wizard[self.currStep]["config"]["screen"] != None):
406                         self.configInstance.keyRight()
407                 elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"):
408                         self["config"].handleKey(KEY_RIGHT)     
409                 print "right"
410
411         def up(self):
412                 self.resetCounter()
413                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
414                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
415                         self.handleInputHelpers()
416                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
417                         self["list"].selectPrevious()
418                         if self.wizard[self.currStep].has_key("onselect"):
419                                 print "current:", self["list"].current
420                                 self.selection = self["list"].current[-1]
421                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
422                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
423                 print "up"
424                 
425         def down(self):
426                 self.resetCounter()
427                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None  or self.wizard[self.currStep]["config"]["type"] == "dynamic"):
428                         self["config"].instance.moveSelection(self["config"].instance.moveDown)
429                         self.handleInputHelpers()
430                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
431                         #self["list"].instance.moveSelection(self["list"].instance.moveDown)
432                         self["list"].selectNext()
433                         if self.wizard[self.currStep].has_key("onselect"):
434                                 print "current:", self["list"].current
435                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
436                                 #exec("self." + self.wizard[self.currStep]["onselect"] + "()")
437                                 self.selection = self["list"].current[-1]
438                                 #self.selection = self.wizard[self.currStep]["evaluatedlist"][self["list"].l.getCurrentSelectionIndex()][1]
439                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
440                 print "down"
441                 
442         def selChanged(self):
443                 self.resetCounter()
444                 
445                 if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
446                         self["config"].instance.moveSelection(self["config"].instance.moveUp)
447                 elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0):
448                         if self.wizard[self.currStep].has_key("onselect"):
449                                 self.selection = self["list"].current[-1]
450                                 print "self.selection:", self.selection
451                                 exec("self." + self.wizard[self.currStep]["onselect"] + "()")
452                 
453         def resetCounter(self):
454                 self.timeoutCounter = self.wizard[self.currStep]["timeout"]
455                 
456         def runCode(self, code):
457                 if code != "":
458                         print "code", code
459                         exec(code)
460                         return True
461                 return False
462
463         def getTranslation(self, text):
464                 return _(text)
465                         
466         def updateText(self, firstset = False):
467                 text = self.getTranslation(self.wizard[self.currStep]["text"])
468                 if text.find("[timeout]") != -1:
469                         text = text.replace("[timeout]", str(self.timeoutCounter))
470                         self["text"].setText(text)
471                 else:
472                         if firstset:
473                                 self["text"].setText(text)
474                 
475         def updateValues(self):
476                 print "Updating values in step " + str(self.currStep)
477                 # calling a step which doesn't exist can only happen if the condition in the last step is not fulfilled
478                 # if a non-existing step is called, end the wizard 
479                 if self.currStep > len(self.wizard):
480                         self.markDone()
481                         self.close()
482                         return
483
484                 self.timeoutTimer.stop()
485                 
486                 if self.configInstance is not None:
487                         # remove callbacks
488                         self.configInstance["config"].onSelectionChanged = []
489                         del self.configInstance["config"]
490                         self.configInstance.doClose()
491                         self.configInstance = None
492
493                 self.condition = True
494                 exec (self.wizard[self.currStep]["condition"])
495                 if not self.condition:
496                         print "keys*******************:", self.wizard[self.currStep].keys()
497                         if self.wizard[self.currStep].has_key("laststep"): # exit wizard, if condition of laststep doesn't hold
498                                 self.markDone()
499                                 self.close()
500                                 return
501                         else:
502                                 self.currStep += 1
503                                 self.updateValues()
504                 else:
505                         if self.wizard[self.currStep].has_key("displaytext"):
506                                 displaytext = self.wizard[self.currStep]["displaytext"]
507                                 print "set LCD text"
508                                 for x in self.lcdCallbacks:
509                                         x(displaytext)
510                         if len(self.stepHistory) == 0 or self.stepHistory[-1] != self.currStep:
511                                 self.stepHistory.append(self.currStep)
512                         print "wizard step:", self.wizard[self.currStep]
513                         
514                         if self.showSteps:
515                                 self["step"].setText(self.getTranslation("Step ") + str(self.currStep) + "/" + str(self.numSteps))
516                         if self.showStepSlider:
517                                 self["stepslider"].setValue(self.currStep)
518                 
519                         if self.wizard[self.currStep]["timeout"] is not None:
520                                 self.resetCounter() 
521                                 self.timeoutTimer.start(1000)
522                         
523                         print "wizard text", self.getTranslation(self.wizard[self.currStep]["text"])
524                         self.updateText(firstset = True)
525                         if self.wizard[self.currStep].has_key("displaytext"):
526                                 displaytext = self.wizard[self.currStep]["displaytext"]
527                                 print "set LCD text"
528                                 for x in self.lcdCallbacks:
529                                         x(displaytext)
530                                 
531                         self.codeafter=False
532                         self.runCode(self.wizard[self.currStep]["code"])
533                         if self.runCode(self.wizard[self.currStep]["code_async"]):
534                                 if self.updateValues in self.onShown:
535                                         self.onShown.remove(self.updateValues)
536                         else:
537                                 self.afterAsyncCode()
538
539         def afterAsyncCode(self):
540                 if not self.updateValues in self.onShown:
541                         self.onShown.append(self.updateValues)
542
543                 if self.codeafter:
544                         if self.wizard[self.prevStep]["nextstep"] is not None:
545                                 self.currStep = self.getStepWithID(self.wizard[self.prevStep]["nextstep"])
546                         if self.gotoStep is not None:
547                                 self.currStep = self.getStepWithID(self.gotoStep)
548                         self.currStep += 1
549                         self.updateValues()
550                         print "Now: " + str(self.currStep)
551                 else:
552                         if self.showList:
553                                 print "showing list,", self.currStep
554                                 for renderer in self.renderer:
555                                         rootrenderer = renderer
556                                         while renderer.source is not None:
557                                                 print "self.list:", self["list"]
558                                                 if renderer.source is self["list"]:
559                                                         print "setZPosition"
560                                                         rootrenderer.instance.setZPosition(1)
561                                                 renderer = renderer.source
562
563                                 #self["list"].instance.setZPosition(1)
564                                 self.list = []
565                                 if (self.wizard[self.currStep].has_key("dynamiclist")):
566                                         print "dynamic list, calling",  self.wizard[self.currStep]["dynamiclist"]
567                                         newlist = eval("self." + self.wizard[self.currStep]["dynamiclist"] + "()")
568                                         #self.wizard[self.currStep]["evaluatedlist"] = []
569                                         for entry in newlist:
570                                                 #self.wizard[self.currStep]["evaluatedlist"].append(entry)
571                                                 self.list.append(entry)
572                                         #del self.wizard[self.currStep]["dynamiclist"]
573                                 if (len(self.wizard[self.currStep]["list"]) > 0):
574                                         #self["list"].instance.setZPosition(2)
575                                         for x in self.wizard[self.currStep]["list"]:
576                                                 self.list.append((self.getTranslation(x[0]), x[1]))
577                                 self.wizard[self.currStep]["evaluatedlist"] = self.list
578                                 self["list"].list = self.list
579                                 self["list"].index = 0
580                         else:
581                                 self["list"].hide()
582         
583                         if self.showConfig:
584                                 print "showing config"
585                                 self["config"].instance.setZPosition(1)
586                                 if self.wizard[self.currStep]["config"]["type"] == "dynamic":
587                                                 print "config type is dynamic"
588                                                 self["config"].instance.setZPosition(2)
589                                                 self["config"].l.setList(eval("self." + self.wizard[self.currStep]["config"]["source"])())
590                                 elif (self.wizard[self.currStep]["config"]["screen"] != None):
591                                         if self.wizard[self.currStep]["config"]["type"] == "standalone":
592                                                 print "Type is standalone"
593                                                 self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
594                                         else:
595                                                 self["config"].instance.setZPosition(2)
596                                                 print "wizard screen", self.wizard[self.currStep]["config"]["screen"]
597                                                 if self.wizard[self.currStep]["config"]["args"] == None:
598                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
599                                                 else:
600                                                         self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
601                                                 self["config"].l.setList(self.configInstance["config"].list)
602                                                 callbacks = self.configInstance["config"].onSelectionChanged
603                                                 self.configInstance["config"].destroy()
604                                                 print "clearConfigList", self.configInstance["config"], self["config"]
605                                                 self.configInstance["config"] = self["config"]
606                                                 self.configInstance["config"].onSelectionChanged = callbacks
607                                                 print "clearConfigList", self.configInstance["config"], self["config"]
608                                 else:
609                                         self["config"].l.setList([])
610                                         self.handleInputHelpers()
611                                         
612                                         
613                         else:
614                                 if self.has_key("config"):
615                                         self["config"].hide()
616
617         def timeoutCounterFired(self):
618                 self.timeoutCounter -= 1
619                 print "timeoutCounter:", self.timeoutCounter
620                 if self.timeoutCounter == 0:
621                         if self.wizard[self.currStep]["timeoutaction"] == "selectnext":
622                                 print "selection next item"
623                                 self.down()
624                         else:
625                                 if self.wizard[self.currStep]["timeoutaction"] == "changestep":
626                                         self.finished(gotoStep = self.wizard[self.currStep]["timeoutstep"])
627                 self.updateText()
628
629         def handleInputHelpers(self):
630                 if self["config"].getCurrent() is not None:
631                         if isinstance(self["config"].getCurrent()[1], ConfigText) or isinstance(self["config"].getCurrent()[1], ConfigPassword):
632                                 if self.has_key("VKeyIcon"):
633                                         self["VirtualKB"].setEnabled(True)
634                                         self["VKeyIcon"].boolean = True
635                                 if self.has_key("HelpWindow"):
636                                         if self["config"].getCurrent()[1].help_window.instance is not None:
637                                                 helpwindowpos = self["HelpWindow"].getPosition()
638                                                 from enigma import ePoint
639                                                 self["config"].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
640                         else:
641                                 if self.has_key("VKeyIcon"):
642                                         self["VirtualKB"].setEnabled(False)
643                                         self["VKeyIcon"].boolean = False
644                 else:
645                         if self.has_key("VKeyIcon"):
646                                 self["VirtualKB"].setEnabled(False)
647                                 self["VKeyIcon"].boolean = False
648
649         def KeyText(self):
650                 from Screens.VirtualKeyBoard import VirtualKeyBoard
651                 self.currentConfigIndex = self["config"].getCurrentIndex()
652                 self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title = self["config"].getCurrent()[0], text = self["config"].getCurrent()[1].getValue())
653
654         def VirtualKeyBoardCallback(self, callback = None):
655                 if callback is not None and len(callback):
656                         if isinstance(self["config"].getCurrent()[1], ConfigText) or isinstance(self["config"].getCurrent()[1], ConfigPassword):
657                                 if self.has_key("HelpWindow"):
658                                         if self["config"].getCurrent()[1].help_window.instance is not None:
659                                                 helpwindowpos = self["HelpWindow"].getPosition()
660                                                 from enigma import ePoint
661                                                 self["config"].getCurrent()[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1]))
662                         self["config"].instance.moveSelectionTo(self.currentConfigIndex)
663                         self["config"].setCurrentIndex(self.currentConfigIndex)
664                         self["config"].getCurrent()[1].setValue(callback)
665                         self["config"].invalidate(self["config"].getCurrent())
666
667
668 class WizardManager:
669         def __init__(self):
670                 self.wizards = []
671         
672         def registerWizard(self, wizard, precondition, priority = 0):
673                 self.wizards.append((wizard, precondition, priority))
674         
675         def getWizards(self):
676                 # x[1] is precondition
677                 for wizard in self.wizards:
678                         wizard[0].isLastWizard = False
679                 if len(self.wizards) > 0:
680                         self.wizards[-1][0].isLastWizard = True
681                 return [(x[2], x[0]) for x in self.wizards if x[1] == 1]
682
683 wizardManager = WizardManager()