Merge branch 'bug_308_add_where_softwaremanager'
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
index ee3bbe1..c70201b 100755 (executable)
@@ -108,21 +108,47 @@ class UpdatePluginMenu(Screen):
                self.oktext = _("\nPress OK on your remote control to continue.")
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
                if self.menu == 0:
-                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext) )
-                       #self.list.append(("install-plugins", _("Install extensions"), _("\nInstall new Extensions or Plugins to your dreambox" ) + self.oktext) )
-                       self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext))
-                       self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext))
-                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext))
-                       self.list.append(("ipkg-install", _("Install local extension"),  _("\nScan for local packages and install them." ) + self.oktext))
+                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext, None))
+                       #self.list.append(("install-plugins", _("Install extensions"), _("\nInstall new Extensions or Plugins to your dreambox" ) + self.oktext, None))
+                       self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext, None))
+                       self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext, None))
+                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None))
+                       self.list.append(("ipkg-install", _("Install local extension"),  _("\nScan for local packages and install them." ) + self.oktext, None))
+                       for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER):
+                               if p.__call__.has_key("SoftwareSupported"):
+                                       callFnc = p.__call__["SoftwareSupported"](None)
+                                       if callFnc is not None:
+                                               if p.__call__.has_key("menuEntryName"):
+                                                       menuEntryName = p.__call__["menuEntryName"](None)
+                                               else:
+                                                       menuEntryName = _('Extended Software')
+                                               if p.__call__.has_key("menuEntryDescription"):
+                                                       menuEntryDescription = p.__call__["menuEntryDescription"](None)
+                                               else:
+                                                       menuEntryDescription = _('Extended Software Plugin')
+                                               self.list.append(('default-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc))
                        if config.usage.setup_level.index >= 2: # expert+
-                               self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext))
+                               self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext, None))
                elif self.menu == 1:
-                       self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext))
-                       self.list.append(("backuplocation", _("Choose backup location"),  _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext ))
-                       self.list.append(("backupfiles", _("Choose backup files"),  _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext))
+                       self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext, None))
+                       self.list.append(("backuplocation", _("Choose backup location"),  _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext, None))
+                       self.list.append(("backupfiles", _("Choose backup files"),  _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext, None))
                        if config.usage.setup_level.index >= 2: # expert+
-                               self.list.append(("ipkg-manager", _("Packet management"),  _("\nView, install and remove available or installed packages." ) + self.oktext))
-                       self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext))
+                               self.list.append(("ipkg-manager", _("Packet management"),  _("\nView, install and remove available or installed packages." ) + self.oktext, None))
+                       self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext, None))
+                       for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER):
+                               if p.__call__.has_key("AdvancedSoftwareSupported"):
+                                       callFnc = p.__call__["AdvancedSoftwareSupported"](None)
+                                       if callFnc is not None:
+                                               if p.__call__.has_key("menuEntryName"):
+                                                       menuEntryName = p.__call__["menuEntryName"](None)
+                                               else:
+                                                       menuEntryName = _('Advanced Software')
+                                               if p.__call__.has_key("menuEntryDescription"):
+                                                       menuEntryDescription = p.__call__["menuEntryDescription"](None)
+                                               else:
+                                                       menuEntryDescription = _('Advanced Software Plugin')
+                                               self.list.append(('advanced-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc))
 
                self["menu"] = List(self.list)
                self["key_red"] = StaticText(_("Close"))
@@ -150,33 +176,36 @@ class UpdatePluginMenu(Screen):
        def go(self):
                current = self["menu"].getCurrent()
                if current:
-                       current = current[0]
+                       currentEntry = current[0]
                        if self.menu == 0:
-                               if (current == "software-update"):
+                               if (currentEntry == "software-update"):
                                        self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!"))
-                               elif (current == "software-restore"):
+                               elif (currentEntry == "software-restore"):
                                        self.session.open(ImageWizard)
-                               elif (current == "install-plugins"):
+                               elif (currentEntry == "install-plugins"):
                                        self.session.open(PluginManager, self.skin_path)
-                               elif (current == "system-backup"):
+                               elif (currentEntry == "system-backup"):
                                        self.session.openWithCallback(self.backupDone,BackupScreen, runBackup = True)
-                               elif (current == "system-restore"):
+                               elif (currentEntry == "system-restore"):
                                        if os_path.exists(self.fullbackupfilename):
                                                self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore your Enigma2 backup?\nEnigma2 will restart after the restore"))
                                        else:
                                                self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO, timeout = 10)
-                               elif (current == "ipkg-install"):
+                               elif (currentEntry == "ipkg-install"):
                                        try:
                                                from Plugins.Extensions.MediaScanner.plugin import main
                                                main(self.session)
                                        except:
                                                self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO, timeout = 10)
-                               elif (current == "advanced"):
+                               elif (currentEntry == "default-plugin"):
+                                       self.extended = current[3]
+                                       self.extended(self.session, None)
+                               elif (currentEntry == "advanced"):
                                        self.session.open(UpdatePluginMenu, 1)
                        elif self.menu == 1:
-                               if (current == "ipkg-manager"):
+                               if (currentEntry == "ipkg-manager"):
                                        self.session.open(PacketManager, self.skin_path)
-                               elif (current == "backuplocation"):
+                               elif (currentEntry == "backuplocation"):
                                        parts = [ (r.description, r.mountpoint, self.session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
                                        for x in parts:
                                                if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/':
@@ -186,12 +215,15 @@ class UpdatePluginMenu(Screen):
                                                        parts.remove(x)
                                        if len(parts):
                                                self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts)
-                               elif (current == "backupfiles"):
+                               elif (currentEntry == "backupfiles"):
                                        self.session.openWithCallback(self.backupfiles_choosen,BackupSelection)
-                               elif (current == "advancedrestore"):
+                               elif (currentEntry == "advancedrestore"):
                                        self.session.open(RestoreMenu, self.skin_path)
-                               elif (current == "ipkg-source"):
+                               elif (currentEntry == "ipkg-source"):
                                        self.session.open(IPKGMenu, self.skin_path)
+                               elif (currentEntry == "advanced-plugin"):
+                                       self.extended = current[3]
+                                       self.extended(self.session, None)
 
        def backupfiles_choosen(self, ret):
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )