add default services lists as a scan alternative
[enigma2.git] / lib / python / Screens / DefaultWizard.py
index 87f6816a50d816f47e160bf5c43b64b3f965deb2..c74e5866f1b539df0a24addd3c5cc8f8d8cb9b32 100644 (file)
@@ -5,6 +5,8 @@ from Tools.Directories import crawlDirectory, resolveFilename, SCOPE_DEFAULTDIR,
 from Components.Pixmap import Pixmap, MovingPixmap
 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, getConfigListEntry
 from Components.DreamInfoHandler import DreamInfoHandler, InfoHandler, InfoHandlerParseError
 from Components.Pixmap import Pixmap, MovingPixmap
 from Components.config import config, ConfigBoolean, configfile, ConfigYesNo, getConfigListEntry
 from Components.DreamInfoHandler import DreamInfoHandler, InfoHandler, InfoHandlerParseError
+from Components.PluginComponent import plugins
+from Plugins.Plugin import PluginDescriptor
 import os
 
 config.misc.defaultchosen = ConfigBoolean(default = True)
 import os
 
 config.misc.defaultchosen = ConfigBoolean(default = True)
@@ -12,12 +14,10 @@ config.misc.defaultchosen = ConfigBoolean(default = True)
 import xml.sax
 
 class DefaultWizard(WizardLanguage, DreamInfoHandler):
 import xml.sax
 
 class DefaultWizard(WizardLanguage, DreamInfoHandler):
-       def __init__(self, session, silent = True):
-               DreamInfoHandler.__init__(self, self.statusCallback)
+       def __init__(self, session, silent = True, showSteps = False, neededTag = None):
+               DreamInfoHandler.__init__(self, self.statusCallback, neededTag = neededTag)
                self.silent = silent
                self.silent = silent
-               os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
-               self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
-               self.xmlfile = "defaultwizard.xml"
+               self.setDirectory()
         
                WizardLanguage.__init__(self, session, showSteps = False)
                self["wizard"] = Pixmap()
         
                WizardLanguage.__init__(self, session, showSteps = False)
                self["wizard"] = Pixmap()
@@ -25,6 +25,11 @@ class DefaultWizard(WizardLanguage, DreamInfoHandler):
                self["arrowdown"] = MovingPixmap()
                self["arrowup"] = MovingPixmap()
                self["arrowup2"] = MovingPixmap()
                self["arrowdown"] = MovingPixmap()
                self["arrowup"] = MovingPixmap()
                self["arrowup2"] = MovingPixmap()
+       
+       def setDirectory(self):
+               os.system("mount %s %s" % (resolveFilename(SCOPE_DEFAULTPARTITION), resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)))
+               self.directory = resolveFilename(SCOPE_DEFAULTPARTITIONMOUNTDIR)
+               self.xmlfile = "defaultwizard.xml"
         
        def markDone(self):
                config.misc.defaultchosen.value = 0
         
        def markDone(self):
                config.misc.defaultchosen.value = 0
@@ -58,6 +63,17 @@ class DefaultWizard(WizardLanguage, DreamInfoHandler):
                                indexList.append(x)
                self.installPackages(indexList)
                
                                indexList.append(x)
                self.installPackages(indexList)
                
+class DreamPackageWizard(DefaultWizard):
+       def __init__(self, session, packagefile, silent = False):
+               os.system("mkdir /tmp/package")
+               os.system("tar xpzf %s -C /tmp/package" % packagefile)
+               self.packagefile = packagefile
+               DefaultWizard.__init__(self, session, silent)
+               
+       def setDirectory(self):
+               self.directory = "/tmp/package"
+               self.xmlfile = "dreampackagewizard.xml"
+               
 class ImageDefaultInstaller(DreamInfoHandler):
        def __init__(self):
                DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
 class ImageDefaultInstaller(DreamInfoHandler):
        def __init__(self):
                DreamInfoHandler.__init__(self, self.statusCallback, blocking = True)
@@ -67,8 +83,40 @@ class ImageDefaultInstaller(DreamInfoHandler):
                
        def statusCallback(self, status, progress):
                pass
                
        def statusCallback(self, status, progress):
                pass
-               
+
+def install(choice):
+       if choice is not None:
+               #os.system("mkdir /tmp/package && tar xpzf %s ")
+               choice[2].open(DreamPackageWizard, choice[1])
+
+def filescan_open(list, session, **kwargs):
+       from Screens.ChoiceBox import ChoiceBox
+       print "open default wizard"
+       filelist = [(os.path.split(x.path)[1], x.path, session) for x in list]
+       print filelist
+       session.openWithCallback(install, ChoiceBox, title = _("Please choose he package..."), list=filelist)
+
+def filescan(**kwargs):
+       from Components.Scanner import Scanner, ScanPath
+       from mimetypes import add_type
+       add_type("application/x-dream-package", "dmpkg")
+       return \
+               Scanner(mimetypes = ["application/x-dream-package"], 
+                       paths_to_scan = 
+                               [
+                                       ScanPath(path = "dmpkg", with_subdirs = True), 
+                                       ScanPath(path = "", with_subdirs = False), 
+                               ], 
+                       name = "Dream-Package", 
+                       description = "Install settings, skins, software...", 
+                       openfnc = filescan_open, )
+
+print "add dreampackage scanner plugin"
+plugins.addPlugin(PluginDescriptor(name="Dream-Package", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan, internal = True))
+print "added"
+
 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
 wizardManager.registerWizard(DefaultWizard, config.misc.defaultchosen.value, priority = 6)
+
 if config.misc.defaultchosen.value:
        print "Installing image defaults"
        installer = ImageDefaultInstaller()
 if config.misc.defaultchosen.value:
        print "Installing image defaults"
        installer = ImageDefaultInstaller()