Merge commit 'dm/experimental' into test branch
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / SoftwareManager / plugin.py
old mode 100755 (executable)
new mode 100644 (file)
index a6a611d..dce5179
@@ -125,11 +125,11 @@ class UpdatePluginMenu(Screen):
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
                if self.menu == 0:
                        print "building menu entries"
-                       self.list.append(("install-extensions", _("Manage extensions"), _("\nManage extensions or plugins for your Dreambox" ) + self.oktext, None))
-                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + 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 + "\n\n" + self.infotext, None))
-                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None))
+                       self.list.append(("install-extensions", _("Manage extensions"), _("\nManage extensions or plugins for your STB" ) + self.oktext, None))
+                       self.list.append(("software-update", _("Software update"), _("\nOnline update of your STB software." ) + self.oktext, None))
+                       self.list.append(("software-restore", _("Software restore"), _("\nRestore your STB with a new firmware." ) + self.oktext, None))
+                       self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your STB settings." ) + self.oktext + "\n\n" + self.infotext, None))
+                       self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your STB settings." ) + self.oktext, None))
                        self.list.append(("ipkg-install", _("Install local extension"),  _("\nScan for local extensions and install them." ) + self.oktext, None))
                        for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER):
                                if p.__call__.has_key("SoftwareSupported"):
@@ -230,7 +230,7 @@ class UpdatePluginMenu(Screen):
                        currentEntry = current[0]
                        if self.menu == 0:
                                if (currentEntry == "software-update"):
-                                       self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!"))
+                                       self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your STB?")+"\n"+_("\nAfter pressing OK, please wait!"))
                                elif (currentEntry == "software-restore"):
                                        self.session.open(ImageWizard)
                                elif (currentEntry == "install-extensions"):
@@ -261,9 +261,6 @@ class UpdatePluginMenu(Screen):
                                        for x in parts:
                                                if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/':
                                                        parts.remove(x)
-                                       for x in parts:
-                                               if x[1].startswith('/autofs/'):
-                                                       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 (currentEntry == "backupfiles"):
@@ -278,14 +275,20 @@ class UpdatePluginMenu(Screen):
 
        def backupfiles_choosen(self, ret):
                self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value )
-
+               config.plugins.configurationbackup.backupdirs.save()
+               config.plugins.configurationbackup.save()
+               config.save()
+               
        def backuplocation_choosen(self, option):
+               oldpath = config.plugins.configurationbackup.backuplocation.getValue()
                if option is not None:
                        config.plugins.configurationbackup.backuplocation.value = str(option[1])
                config.plugins.configurationbackup.backuplocation.save()
                config.plugins.configurationbackup.save()
                config.save()
-               self.createBackupfolders()
+               newpath = config.plugins.configurationbackup.backuplocation.getValue()
+               if newpath != oldpath:
+                       self.createBackupfolders()
 
        def runUpgrade(self, result):
                if result:
@@ -806,6 +809,8 @@ class PluginManager(Screen, DreamInfoHandler):
                                name = x[0].strip()
                                details = x[1].strip()
                                description = x[2].strip()
+                               if description == "":
+                                       description = "No description available."
                                packagename = x[3].strip()
                                selectState = self.getSelectionState(details)
                                if iSoftwareTools.installed_packetlist.has_key(packagename):
@@ -918,17 +923,20 @@ class PluginManager(Screen, DreamInfoHandler):
                        self.close()
 
        def runExecuteFinished(self):
-               self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
-
-       def ExecuteReboot(self, result):
-               if result is None:
-                       return
-               if result is False:
-                       self.reloadPluginlist()
+               self.reloadPluginlist()
+               restartRequired = plugins.restartRequired
+               if restartRequired:
+                       self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
+               else:
                        self.selectedFiles = []
                        self.detailsClosed(True)
+
+       def ExecuteReboot(self, result):
                if result:
                        quitMainloop(3)
+               else:
+                       self.selectedFiles = []
+                       self.detailsClosed(True)
 
        def reloadPluginlist(self):
                plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
@@ -1003,7 +1011,7 @@ class PluginManagerInfo(Screen):
                                elif cmd == 2:
                                        info = args['package']
                                else:
-                                       info = _("Dreambox software because updates are available.")
+                                       info = _("STB software because updates are available.")
 
                                self.list.append(self.buildEntryComponent(action,info))
                        self['list'].setList(self.list)
@@ -1284,30 +1292,24 @@ class PluginDetails(Screen, DreamInfoHandler):
                        self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList)
 
        def runUpgradeFinished(self):
-               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
-
-       def UpgradeReboot(self, result):
-               if result is None:
-                       return
-               if result is False:
+               self.reloadPluginlist()
+               restartRequired = plugins.restartRequired
+               if restartRequired:
+                       self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
+               else:
                        self.close(True)
+       def UpgradeReboot(self, result):
                if result:
                        quitMainloop(3)
+               else:
+                       self.close(True)
 
        def runRemove(self, result):
                if result:
                        self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList)
 
        def runRemoveFinished(self):
-               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
-
-       def RemoveReboot(self, result):
-               if result is None:
-                       return
-               if result is False:
-                       self.close(True)
-               if result:
-                       quitMainloop(3)
+               self.close(True)
 
        def reloadPluginlist(self):
                plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
@@ -1372,7 +1374,7 @@ class UpdatePlugin(Screen):
                                self.updating = True
                                self.activityTimer.start(100, False)
                                self.package.setText(_("Package list update"))
-                               self.status.setText(_("Upgrading Dreambox... Please wait"))
+                               self.status.setText(_("Upgrading STB... Please wait"))
                                self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
                        else:
                                self.package.setText(_("Your network is not working. Please try again."))
@@ -1437,11 +1439,11 @@ class UpdatePlugin(Screen):
                        else:
                                self.activityTimer.stop()
                                self.activityslider.setValue(0)
-                               error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.")
+                               error = _("your STB might be unusable now. Please consult the manual for further assistance before rebooting your STB.")
                                if self.packages == 0:
                                        error = _("No packages were upgraded yet. So you can check your network and try again.")
                                if self.updating:
-                                       error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.")
+                                       error = _("Your STB isn't connected to the internet properly. Please check it and try again.")
                                self.status.setText(_("Error") +  " - " + error)
                #print event, "-", param
                pass
@@ -1452,7 +1454,7 @@ class UpdatePlugin(Screen):
        def exit(self):
                if not self.ipkg.isRunning():
                        if self.packages != 0 and self.error == 0:
-                               self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"))
+                               self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your STB?"))
                        else:
                                self.close()
                else:
@@ -1514,7 +1516,7 @@ class IPKGMenu(Screen):
 
        def fill_list(self):
                self.flist = []
-               self.path = '/etc/ipkg/'
+               self.path = '/etc/opkg/'
                if (os_path.exists(self.path) == False):
                        self.entry = False
                        return
@@ -1705,7 +1707,6 @@ class PacketManager(Screen, NumericalTextInput):
                self.cache_file = eEnv.resolve('${libdir}/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache') #Path to cache directory
                self.oktext = _("\nAfter pressing OK, please wait!")
                self.unwanted_extensions = ('-dbg', '-dev', '-doc', 'busybox')
-               self.opkgAvail = fileExists('/usr/bin/opkg')
 
                self.ipkg = IpkgComponent()
                self.ipkg.addCallback(self.ipkgCallback)
@@ -1811,7 +1812,7 @@ class PacketManager(Screen, NumericalTextInput):
                        self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList)
 
        def runRemoveFinished(self):
-               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
 
        def RemoveReboot(self, result):
                if result is None:
@@ -1833,7 +1834,7 @@ class PacketManager(Screen, NumericalTextInput):
                        self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList)
 
        def runUpgradeFinished(self):
-               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO)
+               self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your STB?"), MessageBox.TYPE_YESNO)
                
        def UpgradeReboot(self, result):
                if result is None:
@@ -1859,7 +1860,7 @@ class PacketManager(Screen, NumericalTextInput):
                                self.list_updating = False
                                if not self.Console:
                                        self.Console = Console()
-                               cmd = "ipkg list"
+                               cmd = "opkg list"
                                self.Console.ePopen(cmd, self.IpkgList_Finished)
                #print event, "-", param
                pass
@@ -1882,7 +1883,7 @@ class PacketManager(Screen, NumericalTextInput):
 
                if not self.Console:
                        self.Console = Console()
-               cmd = "ipkg list_installed"
+               cmd = "opkg list-installed"
                self.Console.ePopen(cmd, self.IpkgListInstalled_Finished)
 
        def IpkgListInstalled_Finished(self, result, retval, extra_args = None):
@@ -1895,13 +1896,10 @@ class PacketManager(Screen, NumericalTextInput):
                                        l = len(tokens)
                                        version = l > 1 and tokens[1].strip() or ""
                                        self.installed_packetlist[name] = version
-               if self.opkgAvail:
-                       if not self.Console:
-                               self.Console = Console()
-                       cmd = "opkg list-upgradable"
-                       self.Console.ePopen(cmd, self.OpkgListUpgradeable_Finished)
-               else:
-                       self.buildPacketList()
+               if not self.Console:
+                       self.Console = Console()
+               cmd = "opkg list-upgradable"
+               self.Console.ePopen(cmd, self.OpkgListUpgradeable_Finished)
 
        def OpkgListUpgradeable_Finished(self, result, retval, extra_args = None):
                if result:
@@ -1917,6 +1915,8 @@ class PacketManager(Screen, NumericalTextInput):
        
        def buildEntryComponent(self, name, version, description, state):
                divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
+               if description == "":
+                       description = "No description available."
                if state == 'installed':
                        installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png"))
                        return((name, version, _(description), state, installedpng, divpng))    
@@ -1946,16 +1946,10 @@ class PacketManager(Screen, NumericalTextInput):
                        for x in self.packetlist:
                                status = ""
                                if self.installed_packetlist.has_key(x[0]):
-                                       if self.opkgAvail:
-                                               if self.upgradeable_packages.has_key(x[0]):
-                                                       status = "upgradeable"
-                                               else:
-                                                       status = "installed"
+                                       if self.upgradeable_packages.has_key(x[0]):
+                                               status = "upgradeable"
                                        else:
-                                               if self.installed_packetlist[x[0]] == x[1]:
-                                                       status = "installed"
-                                               else:
-                                                       status = "upgradeable"
+                                               status = "installed"
                                else:
                                        status = "installable"
                                self.list.append(self.buildEntryComponent(x[0], x[1], x[2], status))    
@@ -2039,9 +2033,9 @@ def Plugins(path, **kwargs):
        global plugin_path
        plugin_path = path
        list = [
-               PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup),
-               PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)
+               PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=startSetup),
+               PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, needsRestart = False, fnc = filescan)
        ]
        if config.usage.setup_level.index >= 2: # expert+
-               list.append(PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=UpgradeMain))
+               list.append(PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, needsRestart = False, fnc=UpgradeMain))
        return list