X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/daceed220bdfbb2bd48d08372dbb77d450a8be61..3c95a4fba21a6925cbefad5066785b80d88c4659:/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index ffc227d6..ee3bbe15 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -7,7 +7,7 @@ from Screens.Ipkg import Ipkg from Components.ActionMap import ActionMap, NumberActionMap from Components.Input import Input from Components.Ipkg import IpkgComponent -from Components.Label import Label +from Components.Sources.StaticText import StaticText from Components.ScrollLabel import ScrollLabel from Components.Pixmap import Pixmap from Components.MenuList import MenuList @@ -23,7 +23,7 @@ from Components.About import about from Components.DreamInfoHandler import DreamInfoHandler from Components.Language import language from Components.AVSwitch import AVSwitch -from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_METADIR +from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR from Tools.LoadPixmap import LoadPixmap from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad from cPickle import dump, load @@ -74,9 +74,11 @@ def load_cache(cache_file): class UpdatePluginMenu(Screen): skin = """ - - - + + + + + {"template": [ MultiContentEntryText(pos = (2, 2), size = (290, 22), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText, @@ -86,7 +88,7 @@ class UpdatePluginMenu(Screen): } - + {"template": [ MultiContentEntryText(pos = (2, 2), size = (240, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description, @@ -111,7 +113,7 @@ class UpdatePluginMenu(Screen): 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 IPKG"), _("\nScan for local packages and install them." ) + self.oktext)) + self.list.append(("ipkg-install", _("Install local extension"), _("\nScan for local packages and install them." ) + self.oktext)) if config.usage.setup_level.index >= 2: # expert+ self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext)) elif self.menu == 1: @@ -123,7 +125,8 @@ class UpdatePluginMenu(Screen): self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext)) self["menu"] = List(self.list) - + self["key_red"] = StaticText(_("Close")) + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], { "ok": self.go, @@ -136,14 +139,14 @@ class UpdatePluginMenu(Screen): self.backupfile = getBackupFilename() self.fullbackupfilename = self.backuppath + "/" + self.backupfile self.onShown.append(self.setWindowTitle) - + def layoutFinished(self): idx = 0 self["menu"].index = idx - + def setWindowTitle(self): - self.setTitle(_("Software manager...")) - + self.setTitle(_("Software manager")) + def go(self): current = self["menu"].getCurrent() if current: @@ -160,14 +163,14 @@ class UpdatePluginMenu(Screen): elif (current == "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) + else: + self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO, timeout = 10) elif (current == "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) + self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO, timeout = 10) elif (current == "advanced"): self.session.open(UpdatePluginMenu, 1) elif self.menu == 1: @@ -200,7 +203,7 @@ class UpdatePluginMenu(Screen): config.plugins.configurationbackup.save() config.save() self.createBackupfolders() - + def runUpgrade(self, result): if result: self.session.open(UpdatePlugin, self.skin_path) @@ -212,13 +215,13 @@ class UpdatePluginMenu(Screen): if (os_path.exists(self.backuppath) == False): makedirs(self.backuppath) except OSError: - self.session.open(MessageBox, _("Sorry, your backup destination is not writeable.\n\nPlease choose another one."), MessageBox.TYPE_INFO) + self.session.open(MessageBox, _("Sorry, your backup destination is not writeable.\n\nPlease choose another one."), MessageBox.TYPE_INFO, timeout = 10) def backupDone(self,retval = None): if retval is True: - self.session.open(MessageBox, _("Backup done."), MessageBox.TYPE_INFO) + self.session.open(MessageBox, _("Backup done."), MessageBox.TYPE_INFO, timeout = 10) else: - self.session.open(MessageBox, _("Backup failed."), MessageBox.TYPE_INFO) + self.session.open(MessageBox, _("Backup failed."), MessageBox.TYPE_INFO, timeout = 10) def startRestore(self, ret = False): if (ret == True): @@ -227,20 +230,20 @@ class UpdatePluginMenu(Screen): class IPKGMenu(Screen): skin = """ - - - - - - + + + + + + """ def __init__(self, session, plugin_path): Screen.__init__(self, session) self.skin_path = plugin_path - self["closetext"] = Label(_("Close")) - self["edittext"] = Label(_("Edit")) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Edit")) self.sel = [] self.val = [] @@ -269,8 +272,7 @@ class IPKGMenu(Screen): self.setWindowTitle() def setWindowTitle(self): - self.setTitle(_("Select IPKG source to edit...")) - + self.setTitle(_("Select upgrade source to edit.")) def fill_list(self): self.flist = [] @@ -300,14 +302,14 @@ class IPKGMenu(Screen): class IPKGSource(Screen): skin = """ - - - - - - + + + + + + """ - + def __init__(self, session, configfile = None): Screen.__init__(self, session) self.session = session @@ -326,16 +328,15 @@ class IPKGSource(Screen): desk = getDesktop(0) x= int(desk.size().width()) y= int(desk.size().height()) - #print "[IPKGSource] mainscreen: current desktop size: %dx%d" % (x,y) - self["closetext"] = Label(_("Cancel")) - self["edittext"] = Label(_("Save")) - + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + if (y>=720): self["text"] = Input(text, maxSize=False, type=Input.TEXT) else: self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT) - + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"], { "ok": self.go, @@ -367,8 +368,8 @@ class IPKGSource(Screen): self["text"].right() def setWindowTitle(self): - self.setTitle(_("Edit IPKG source URL...")) - + self.setTitle(_("Edit upgrade source url.")) + def go(self): text = self["text"].getText() if text: @@ -377,7 +378,7 @@ class IPKGSource(Screen): fp.write("\n") fp.close() self.close() - + def keyLeft(self): self["text"].left() @@ -397,14 +398,17 @@ class IPKGSource(Screen): self["text"].deleteBackward() def keyNumberGlobal(self, number): - print "pressed", number self["text"].number(number) class PacketManager(Screen): skin = """ - - + + + + + + {"template": [ MultiContentEntryText(pos = (5, 1), size = (440, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name @@ -417,10 +421,6 @@ class PacketManager(Screen): } - - - - """ def __init__(self, session, plugin_path, args = None): @@ -439,8 +439,8 @@ class PacketManager(Screen): self.list = [] self.statuslist = [] self["list"] = List(self.list) - self["closetext"] = Label(_("Close")) - self["reloadtext"] = Label(_("Reload")) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Reload")) self.list_updating = True self.packetlist = [] @@ -478,13 +478,13 @@ class PacketManager(Screen): def setStatus(self,status = None): if status: self.statuslist = [] - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) if status == 'update': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'',statuspng, divpng )) self['list'].setList(self.statuslist) elif status == 'error': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installed.png")) + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) self.statuslist.append(( _("Error"), '', _("There was an error downloading the packetlist. Please try again." ),'',statuspng, divpng )) self['list'].setList(self.statuslist) @@ -600,15 +600,15 @@ class PacketManager(Screen): self.buildPacketList() def buildEntryComponent(self, name, version, description, state): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) if state == 'installed': - installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installed.png")) + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) return((name, version, description, state, installedpng, divpng)) elif state == 'upgradeable': - upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/upgradeable.png")) + upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgradeable.png")) return((name, version, description, state, upgradeablepng, divpng)) else: - installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) return((name, version, description, state, installablepng, divpng)) def buildPacketList(self): @@ -641,7 +641,7 @@ class PacketManager(Screen): status = "installable" self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) if not any(x[0].strip().endswith(x) for x in self.unwanted_extensions): - self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status]) + self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status]) write_cache(self.cache_file, self.cachelist) self['list'].setList(self.list) @@ -650,41 +650,40 @@ class PacketManager(Screen): class PluginManager(Screen, DreamInfoHandler): + + lastDownloadDate = None + skin = """ - - + + + + + + + + + + {"templates": - {"default": [ - MultiContentEntryText(pos = (30, 1), size = (500, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (30, 26), size = (500, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description - MultiContentEntryPixmapAlphaTest(pos = (500, 2), size = (48, 48), png = 5), # index 5 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 50), size = (550, 2), png = 6), # index 6 is the div pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 10), size = (25, 25), png = 7), # index 7 is the selected pixmap - ], - "category": [ - MultiContentEntryText(pos = (30, 1), size = (500, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (30, 26), size = (500, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description - MultiContentEntryPixmapAlphaTest(pos = (500, 2), size = (48, 48), png = 5), # index 5 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 50), size = (550, 2), png = 6), # index 6 is the div pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 10), size = (25, 25), png = 7), # index 7 is the selected pixmap - ] + {"default": (51,[ + MultiContentEntryText(pos = (30, 1), size = (470, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (30, 25), size = (470, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description + MultiContentEntryPixmapAlphaTest(pos = (475, 0), size = (48, 48), png = 5), # index 5 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 6), # index 6 is the div pixmap + ]), + "category": (40,[ + MultiContentEntryText(pos = (30, 0), size = (500, 22), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (30, 22), size = (500, 16), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the description + MultiContentEntryPixmapAlphaTest(pos = (0, 38), size = (550, 2), png = 3), # index 3 is the div pixmap + ]) }, - "fonts": [gFont("Regular", 22),gFont("Regular", 14)], + "fonts": [gFont("Regular", 22),gFont("Regular", 16)], "itemHeight": 52 } - - - - - - - - - - + """ def __init__(self, session, plugin_path, args = None): @@ -696,22 +695,20 @@ class PluginManager(Screen, DreamInfoHandler): self.ImageVersion = 'Experimental' else: self.ImageVersion = 'Stable' - lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" - if lang == "en": - self.language = None - else: - self.language = lang + self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" + DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion, language = self.language) self.directory = resolveFilename(SCOPE_METADIR) - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions", "HelpActions" ], { - "ok": self.go, + "ok": self.handleCurrent, "back": self.exit, "red": self.exit, - "green": self.installPlugins, - "yellow": self.changeSelectionState, - "blue": self.go, + "green": self.handleCurrent, + "yellow": self.handleSelected, + "showEventInfo": self.handleSelected, + "displayHelp": self.handleHelp, }, -1) self.list = [] @@ -719,14 +716,17 @@ class PluginManager(Screen, DreamInfoHandler): self.selectedFiles = [] self.categoryList = [] self["list"] = List(self.list) - self["closetext"] = Label(_("Close")) - self["installtext"] = Label() - self["selecttext"] = Label() - self["viewtext"] = Label() + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText("") + self["key_yellow"] = StaticText("") + self["key_blue"] = StaticText("") + self["status"] = StaticText("") self.list_updating = True self.packetlist = [] self.installed_packetlist = {} + self.available_packetlist = [] + self.available_updates = 0 self.Console = Console() self.cmdList = [] self.oktext = _("\nAfter pressing OK, please wait!") @@ -737,10 +737,9 @@ class PluginManager(Screen, DreamInfoHandler): if not self.selectionChanged in self["list"].onSelectionChanged: self["list"].onSelectionChanged.append(self.selectionChanged) - self["installtext"].hide() - self["selecttext"].hide() - self["viewtext"].hide() self.currList = "" + self.currentSelectedTag = None + self.currentSelectedIndex = None self.onShown.append(self.setWindowTitle) self.onLayoutFinish.append(self.rebuildList) @@ -751,41 +750,48 @@ class PluginManager(Screen, DreamInfoHandler): def exit(self): if self.currList == "packages": self.currList = "category" + self.currentSelectedTag = None + self["list"].style = "category" self['list'].setList(self.categoryList) + self["list"].setIndex(self.currentSelectedIndex) + self["list"].updateList(self.categoryList) + self.selectionChanged() else: self.ipkg.stop() if self.Console is not None: if len(self.Console.appContainers): for name in self.Console.appContainers.keys(): self.Console.kill(name) - self.close() + self.prepareInstall() + if len(self.cmdList): + self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) + else: + self.close() - def reload(self): - if (os_path.exists(self.cache_file) == True): - remove(self.cache_file) - self.list_updating = True - self.rebuildList() + def handleHelp(self): + if self.currList != "status": + self.session.open(PluginManagerHelp, self.skin_path) def setState(self,status = None): if status: self.currList = "status" self.statuslist = [] - self["installtext"].hide() - self["selecttext"].hide() - self["viewtext"].hide() - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + self["key_green"].setText("") + self["key_blue"].setText("") + self["key_yellow"].setText("") + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) if status == 'update': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'', '', statuspng, divpng, None, '' )) self["list"].style = "default" self['list'].setList(self.statuslist) elif status == 'sync': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) self.statuslist.append(( _("Package list update"), '', _("Searching for new installed or removed packages. Please wait..." ),'', '', statuspng, divpng, None, '' )) self["list"].style = "default" self['list'].setList(self.statuslist) elif status == 'error': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installed.png")) + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) self.statuslist.append(( _("Error"), '', _("There was an error downloading the packetlist. Please try again." ),'', '', statuspng, divpng, None, '' )) self["list"].style = "default" self['list'].setList(self.statuslist) @@ -795,78 +801,90 @@ class PluginManager(Screen, DreamInfoHandler): def selectionChanged(self): current = self["list"].getCurrent() + self["status"].setText("") if current: if self.currList == "packages": - self["closetext"].setText(_("Back")) - self["closetext"].show() - self["installtext"].setText(_("Install/\nRemove")) - self["installtext"].show() - self["viewtext"].setText(_("Details")) - self["viewtext"].show() - if current[8] == False: - self["selecttext"].setText(_("Select")) + self["key_red"].setText(_("Back")) + if current[4] == 'installed': + self["key_green"].setText(_("Remove")) + elif current[4] == 'installable': + self["key_green"].setText(_("Install")) + elif current[4] == 'remove': + self["key_green"].setText(_("Undo\nRemove")) + elif current[4] == 'install': + self["key_green"].setText(_("Undo\nInstall")) + self["key_yellow"].setText(_("View details")) + self["key_blue"].setText("") + if len(self.selectedFiles) == 0 and self.available_updates is not 0: + self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) + elif len(self.selectedFiles) is not 0: + self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) else: - self["selecttext"].setText(_("Deselect")) - self["selecttext"].show() + self["status"].setText(_("There is nothing to be done.")) elif self.currList == "category": - self["closetext"].setText(_("Close")) - self["closetext"].show() - self["installtext"].hide() - self["selecttext"].hide() - self["viewtext"].setText(_("View")) - self["viewtext"].show() - - - def changeSelectionState(self): - current = self["list"].getCurrent() - if current: - if current[8] is not '': - idx = self["list"].getIndex() - count = 0 - newList = [] - for x in self.list: - detailsFile = x[1] - if idx == count: - if x[8] == True: - SelectState = False - for entry in self.selectedFiles: - if entry[0] == detailsFile: - self.selectedFiles.remove(entry) - else: - SelectState = True - alreadyinList = False - for entry in self.selectedFiles: - if entry[0] == detailsFile: - alreadyinList = True - if not alreadyinList: - self.selectedFiles.append((detailsFile,x[4],x[3])) - newList.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), x[4].strip(), selected = SelectState)) - else: - newList.append(x) - count += 1 + self["key_red"].setText(_("Close")) + self["key_green"].setText("") + self["key_yellow"].setText("") + self["key_blue"].setText("") + if len(self.selectedFiles) == 0 and self.available_updates is not 0: + self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) + self["key_yellow"].setText(_("Update")) + elif len(self.selectedFiles) is not 0: + self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) + self["key_yellow"].setText(_("Process")) + else: + self["status"].setText(_("There is nothing to be done.")) - self.list = newList - self['list'].updateList(self.list) - self.selectionChanged() + def getSelectionState(self, detailsFile): + for entry in self.selectedFiles: + if entry[0] == detailsFile: + return True + return False def rebuildList(self): self.setState('update') - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + if not PluginManager.lastDownloadDate or (time() - PluginManager.lastDownloadDate) > 3600: + # Only update from internet once per hour + PluginManager.lastDownloadDate = time() + print "last update time > 1h" + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + else: + print "last update time < 1h" + self.startIpkgList() def ipkgCallback(self, event, param): if event == IpkgComponent.EVENT_ERROR: self.list_updating = False self.setState('error') elif event == IpkgComponent.EVENT_DONE: - if self.list_updating: - self.list_updating = False - if not self.Console: - self.Console = Console() - cmd = "ipkg list" ### ipkg install enigma2-plugins-meta - self.Console.ePopen(cmd, self.IpkgList_Finished) + self.startIpkgList() pass + def startIpkgList(self): + if self.list_updating: + if not self.Console: + self.Console = Console() + cmd = "ipkg list" + self.Console.ePopen(cmd, self.IpkgList_Finished) + def IpkgList_Finished(self, result, retval, extra_args = None): + if len(result): + self.available_packetlist = [] + for x in result.splitlines(): + split = x.split(' - ') + if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): + self.available_packetlist.append([split[0].strip(), split[1].strip(), split[2].strip()]) + self.startInstallMetaPackage() + + def startInstallMetaPackage(self): + if self.list_updating: + self.list_updating = False + if not self.Console: + self.Console = Console() + cmd = "ipkg install enigma2-meta" #dummy,will change probably" + self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) + + def InstallMetaPackage_Finished(self, result, retval, extra_args = None): if len(result): self.fillPackagesIndexList() if not self.Console: @@ -882,131 +900,192 @@ class PluginManager(Screen, DreamInfoHandler): split = x.split(' - ') if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): self.installed_packetlist[split[0].strip()] = split[1].strip() - self.buildCategoryList() + self.countUpdates() + if self.currentSelectedTag is None: + self.buildCategoryList() + else: + self.buildPacketList(self.currentSelectedTag) - def go(self, returnValue = None): + def countUpdates(self): + self.available_updates = 0 + for package in self.packagesIndexlist[:]: + attributes = package[0]["attributes"] + packagename = attributes["packagename"] + for x in self.available_packetlist: + if x[0].strip() == packagename: + if self.installed_packetlist.has_key(packagename): + if self.installed_packetlist[packagename] != x[1].strip(): + self.available_updates +=1 + + def handleCurrent(self): current = self["list"].getCurrent() if current: if self.currList == "category": - selectedTag = current[4] + self.currentSelectedIndex = self["list"].index + selectedTag = current[2] self.buildPacketList(selectedTag) elif self.currList == "packages": - if current[8] is not '': + if current[7] is not '': + idx = self["list"].getIndex() + detailsFile = self.list[idx][1] + if self.list[idx][7] == True: + for entry in self.selectedFiles: + if entry[0] == detailsFile: + self.selectedFiles.remove(entry) + else: + alreadyinList = False + for entry in self.selectedFiles: + if entry[0] == detailsFile: + alreadyinList = True + if not alreadyinList: + self.selectedFiles.append((detailsFile,current[4],current[3])) + if current[4] == 'installed': + self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'remove', True) + elif current[4] == 'installable': + self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'install', True) + elif current[4] == 'remove': + self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'installed', False) + elif current[4] == 'install': + self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'installable',False) + self["list"].setList(self.list) + self["list"].setIndex(idx) + self["list"].updateList(self.list) + self.selectionChanged() + + def handleSelected(self): + current = self["list"].getCurrent() + if current: + if self.currList == "packages": + if current[7] is not '': detailsfile = self.directory[0] + "/" + current[1] if (os_path.exists(detailsfile) == True): self.session.openWithCallback(self.detailsClosed, PluginDetails, self.skin_path, current) else: - self.session.open(MessageBox, _("Sorry, no Details available!"), MessageBox.TYPE_INFO) + self.session.open(MessageBox, _("Sorry, no Details available!"), MessageBox.TYPE_INFO, timeout = 10) + elif self.currList == "category": + self.prepareInstall() + if len(self.cmdList): + self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) + def detailsClosed(self, result): if result: if not self.Console: self.Console = Console() self.setState('sync') - cmd = "ipkg list_installed" - self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) + PluginManager.lastDownloadDate = time() + self.selectedFiles = [] + cmd = "ipkg update" + self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) def buildEntryComponent(self, name, details, description, packagename, state, selected = False): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) - if selected is False: - selectedicon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_off.png")) - else: - selectedicon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png")) - + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) if state == 'installed': - installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installed.png")) - return((name, details, description, packagename, state, installedpng, divpng, selectedicon, selected)) - else: - installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/installable.png")) - return((name, details, description, packagename, state, installablepng, divpng, selectedicon, selected)) + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) + return((name, details, description, packagename, state, installedpng, divpng, selected)) + elif state == 'installable': + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) + return((name, details, description, packagename, state, installablepng, divpng, selected)) + elif state == 'remove': + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + return((name, details, description, packagename, state, removepng, divpng, selected)) + elif state == 'install': + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + return((name, details, description, packagename, state, installpng, divpng, selected)) def buildPacketList(self, categorytag = None): if categorytag is not None: self.currList = "packages" - #print self.packagesIndexlist + self.currentSelectedTag = categorytag self.packetlist = [] for package in self.packagesIndexlist[:]: - #print "package--->",package prerequisites = package[0]["prerequisites"] - #print "prerequisite",prerequisites if prerequisites.has_key("tag"): for foundtag in prerequisites["tag"]: if categorytag == foundtag: attributes = package[0]["attributes"] - #print "attributes---->",attributes - self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) - + if attributes.has_key("packagetype"): + if attributes["packagetype"] == "internal": + continue + self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) + else: + self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) self.list = [] for x in self.packetlist: - print x status = "" + selectState = self.getSelectionState(x[1].strip()) if self.installed_packetlist.has_key(x[3].strip()): - status = "installed" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = False)) + if selectState == True: + status = "remove" + else: + status = "installed" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) else: - status = "installable" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = False)) - + if selectState == True: + status = "install" + else: + status = "installable" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) if len(self.list): self.list.sort(key=lambda x: x[0]) self["list"].style = "default" self['list'].setList(self.list) + self["list"].updateList(self.list) self.selectionChanged() - def buildCategoryList(self): self.currList = "category" - #print self.packagesIndexlist self.categories = [] self.categoryList = [] for package in self.packagesIndexlist[:]: - #print "package--->",package prerequisites = package[0]["prerequisites"] - #print "prerequisite",prerequisites if prerequisites.has_key("tag"): for foundtag in prerequisites["tag"]: - #print "found tag----",foundtag + attributes = package[0]["attributes"] if foundtag not in self.categories: self.categories.append(foundtag) self.categoryList.append(self.buildCategoryComponent(foundtag)) self.categoryList.sort(key=lambda x: x[0]) self["list"].style = "category" self['list'].setList(self.categoryList) + self["list"].updateList(self.categoryList) self.selectionChanged() def buildCategoryComponent(self, tag = None): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) if tag is not None: if tag == 'System': - return(( _("System"), '', _("View list of available system extensions" ),'', tag, None, divpng, None, '' )) + return(( _("System"), _("View list of available system extensions" ), tag, divpng )) elif tag == 'Skin': - return(( _("Skins"), '', _("View list of available skins" ),'', tag, None, divpng, None, '' )) + return(( _("Skins"), _("View list of available skins" ), tag, divpng )) elif tag == 'Recording': - return(( _("Recordings"), '', _("View list of available recording extensions" ),'', tag, None, divpng, None, '' )) + return(( _("Recordings"), _("View list of available recording extensions" ), tag, divpng )) elif tag == 'Network': - return(( _("Network"), '', _("View list of available networking extensions" ),'', tag, None, divpng, None, '' )) + return(( _("Network"), _("View list of available networking extensions" ), tag, divpng )) elif tag == 'CI': - return(( _("CommonInterface"), '', _("View list of available CommonInterface extensions" ),'', tag, None, divpng, None, '' )) + return(( _("CommonInterface"), _("View list of available CommonInterface extensions" ), tag, divpng )) elif tag == 'Default': - return(( _("Default Settings"), '', _("View list of available default settings" ),'', tag, None, divpng, None, '' )) + return(( _("Default Settings"), _("View list of available default settings" ), tag, divpng )) elif tag == 'SAT': - return(( _("Satteliteequipment"), '', _("View list of available Satteliteequipment extensions." ),'', tag, None, divpng, None, '' )) + return(( _("Satteliteequipment"), _("View list of available Satteliteequipment extensions." ), tag, divpng )) elif tag == 'Software': - return(( _("Software"), '', _("View list of available software extensions" ),'', tag, None, divpng, None, '' )) + return(( _("Software"), _("View list of available software extensions" ), tag, divpng )) elif tag == 'Multimedia': - return(( _("Multimedia"), '', _("View list of available multimedia extensions." ),'', tag, None, divpng, None, '' )) + return(( _("Multimedia"), _("View list of available multimedia extensions." ), tag, divpng )) elif tag == 'Display': - return(( _("Display and Userinterface"), '', _("View list of available Display and Userinterface extensions." ),'', tag, None, divpng, None, '' )) + return(( _("Display and Userinterface"), _("View list of available Display and Userinterface extensions." ), tag, divpng )) elif tag == 'EPG': - return(( _("Electronic Program Guide"), '', _("View list of available EPG extensions." ),'', tag, None, divpng, None, '' )) + return(( _("Electronic Program Guide"), _("View list of available EPG extensions." ), tag, divpng )) elif tag == 'Communication': - return(( _("Communication"), '', _("View list of available communication extensions." ),'', tag, None, divpng, None, '' )) + return(( _("Communication"), _("View list of available communication extensions." ), tag, divpng )) + else: # dynamically generate non existent tags + return(( str(tag), _("View list of available ") + str(tag) + _(" extensions." ), tag, divpng )) - - def installPlugins(self): + def prepareInstall(self): self.cmdList = [] + if self.available_updates > 0: + self.cmdList.append((IpkgComponent.CMD_UPGRADE, { "test_only": False })) if self.selectedFiles and len(self.selectedFiles): for plugin in self.selectedFiles: - #print "processing Plugin-->",plugin detailsfile = self.directory[0] + "/" + plugin[0] if (os_path.exists(detailsfile) == True): self.fillPackageDetails(plugin[0]) @@ -1018,57 +1097,26 @@ class PluginManager(Screen, DreamInfoHandler): if plugin[1] == 'installed': if self.packagefiles: for package in self.packagefiles[:]: - #print "removing package: ",package["name"] self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) + else: + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) else: if self.packagefiles: for package in self.packagefiles[:]: - #print "adding package: ",package["name"] self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] })) + else: + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) else: if plugin[1] == 'installed': - #print "removing package: ",plugin[2] self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) else: - #print "adding package: ",plugin[2] self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) - else: - current = self["list"].getCurrent() - if current: - if current[8] is not '': - detailsfile = self.directory[0] + "/" + current[1] - if (os_path.exists(detailsfile) == True): - self.fillPackageDetails(current[1]) - self.package = self.packageDetails[0] - if self.package[0].has_key("attributes"): - self.attributes = self.package[0]["attributes"] - if self.attributes.has_key("package"): - self.packagefiles = self.attributes["package"] - if current[4] == 'installed': - if self.packagefiles: - for package in self.packagefiles[:]: - #print "removing package: ",package["name"] - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) - else: - if self.packagefiles: - for package in self.packagefiles[:]: - #print "adding package: ",package["name"] - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] })) - else: - if current[4] == 'installed': - #print "removing package: ",current[0] - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": current[3] })) - else: - #print "adding package: ",current[0] - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": current[3] })) - - if len(self.cmdList): - print self.cmdList - self.session.openWithCallback(self.runExecute, MessageBox, _("Do you want to continue installing or removing selected plugins?\n") + self.oktext) def runExecute(self, result): if result: self.session.openWithCallback(self.runExecuteFinished, Ipkg, cmdList = self.cmdList) + else: + 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) @@ -1086,27 +1134,192 @@ class PluginManager(Screen, DreamInfoHandler): plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) +class PluginManagerInfo(Screen): + skin = """ + + + + + + + + {"template": [ + MultiContentEntryText(pos = (50, 1), size = (150, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state + MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap + ], + "fonts": [gFont("Regular", 22),gFont("Regular", 18)], + "itemHeight": 52 + } + + + + + """ + + def __init__(self, session, plugin_path, cmdlist = None): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + self.cmdlist = cmdlist + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "ok": self.process, + "back": self.exit, + "red": self.exit, + "green": self.process, + }, -1) + + self.list = [] + self["list"] = List(self.list) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Continue")) + self["status"] = StaticText(_("Following tasks will be done after you press continue!")) + + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + + def setWindowTitle(self): + self.setTitle(_("Plugin manager activity information")) + + def rebuildList(self): + self.list = [] + if self.cmdlist is not None: + for entry in self.cmdlist: + action = "" + info = "" + cmd = entry[0] + if cmd == 0: + action = 'install' + elif cmd == 2: + action = 'remove' + else: + action = 'upgrade' + args = entry[1] + if cmd == 0: + info = args['package'] + elif cmd == 2: + info = args['package'] + else: + info = _("Dreambox software because updates are available.") + + self.list.append(self.buildEntryComponent(action,info)) + self['list'].setList(self.list) + self['list'].updateList(self.list) + + def buildEntryComponent(self, action,info): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + upgradepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + if action == 'install': + return(( _('Installing'), info, installpng, divpng)) + elif action == 'remove': + return(( _('Removing'), info, removepng, divpng)) + else: + return(( _('Upgrading'), info, upgradepng, divpng)) + + def exit(self): + self.close(False) + + def process(self): + self.close(True) + + +class PluginManagerHelp(Screen): + skin = """ + + + + + + {"template": [ + MultiContentEntryText(pos = (50, 1), size = (540, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state + MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap + ], + "fonts": [gFont("Regular", 22),gFont("Regular", 18)], + "itemHeight": 52 + } + + + + + """ + + def __init__(self, session, plugin_path): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "back": self.exit, + "red": self.exit, + }, -1) + + self.list = [] + self["list"] = List(self.list) + self["key_red"] = StaticText(_("Close")) + self["status"] = StaticText(_("A small overview of the available icon states and actions.")) + + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + + def setWindowTitle(self): + self.setTitle(_("Plugin manager help")) + + def rebuildList(self): + self.list = [] + self.list.append(self.buildEntryComponent('install')) + self.list.append(self.buildEntryComponent('installable')) + self.list.append(self.buildEntryComponent('installed')) + self.list.append(self.buildEntryComponent('remove')) + self['list'].setList(self.list) + self['list'].updateList(self.list) + + def buildEntryComponent(self, state): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + + if state == 'installed': + return(( _('This plugin is installed.'), _('You can remove this plugin.'), installedpng, divpng)) + elif state == 'installable': + return(( _('This plugin is not installed.'), _('You can install this plugin.'), installablepng, divpng)) + elif state == 'install': + return(( _('This plugin will be installed.'), _('You can cancel the installation.'), installpng, divpng)) + elif state == 'remove': + return(( _('This plugin will be removed.'), _('You can cancel the removal.'), removepng, divpng)) + + def exit(self): + self.close() + + class PluginDetails(Screen, DreamInfoHandler): skin = """ - - - - - - - - - - + + + + + + + + + + """ def __init__(self, session, plugin_path, packagedata = None): Screen.__init__(self, session) self.skin_path = plugin_path - lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" - if lang == "en": - self.language = None - else: - self.language = lang + self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" + self.attributes = None + self.translatedAttributes = None DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, language = self.language) self.directory = resolveFilename(SCOPE_METADIR) if packagedata: @@ -1130,21 +1343,23 @@ class PluginDetails(Screen, DreamInfoHandler): "right": self.pageDown, }, -1) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText("") + self["author"] = StaticText() self["statuspic"] = Pixmap() self["divpic"] = Pixmap() self["screenshot"] = Pixmap() - self["closetext"] = Label(_("Close")) - self["statetext"] = Label() self["detailtext"] = ScrollLabel() - self["author"] = Label() + self["statuspic"].hide() self["screenshot"].hide() self["divpic"].hide() self.package = self.packageDetails[0] - #print "PACKAGE-------im DETAILS",self.package if self.package[0].has_key("attributes"): self.attributes = self.package[0]["attributes"] + if self.package[0].has_key("translation"): + self.translatedAttributes = self.package[0]["translation"] self.cmdList = [] self.oktext = _("\nAfter pressing OK, please wait!") @@ -1169,25 +1384,38 @@ class PluginDetails(Screen, DreamInfoHandler): pass def setInfos(self): - if self.attributes.has_key("name"): + if self.translatedAttributes.has_key("name"): + self.pluginname = self.translatedAttributes["name"] + elif self.attributes.has_key("name"): self.pluginname = self.attributes["name"] else: self.pluginname = _("unknown") - if self.attributes.has_key("author"): + + if self.translatedAttributes.has_key("author"): + self.author = self.translatedAttributes["author"] + elif self.attributes.has_key("author"): self.author = self.attributes["author"] else: self.author = _("unknown") - if self.attributes.has_key("description"): + + if self.translatedAttributes.has_key("description"): + self.description = self.translatedAttributes["description"] + elif self.attributes.has_key("description"): self.description = self.attributes["description"] else: - self.author = _("No description available.") - self.loadThumbnail(self.attributes) + self.description = _("No description available.") + + if self.translatedAttributes.has_key("screenshot"): + self.loadThumbnail(self.translatedAttributes) + else: + self.loadThumbnail(self.attributes) + self["author"].setText(_("Author: ") + self.author) self["detailtext"].setText(self.description.strip()) if self.pluginstate == 'installable': - self["statetext"].setText(_("Install")) + self["key_green"].setText(_("Install")) else: - self["statetext"].setText(_("Remove")) + self["key_green"].setText(_("Remove")) def loadThumbnail(self, entry): thumbnailUrl = None @@ -1204,7 +1432,7 @@ class PluginDetails(Screen, DreamInfoHandler): if not noScreenshot: filename = self.thumbnail else: - filename = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/SoftwareManager/noprev.png") + filename = resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/noprev.png") sc = AVSwitch().getFramebufferScale() self.picload.setPara((self["screenshot"].instance.size().width(), self["screenshot"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000")) @@ -1232,14 +1460,12 @@ class PluginDetails(Screen, DreamInfoHandler): if self.pluginstate == 'installed': if self.packagefiles: for package in self.packagefiles[:]: - #print "removing packagefile: ",package["name"] self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) if len(self.cmdList): self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n") + self.pluginname + "\n" + self.oktext) else: if self.packagefiles: for package in self.packagefiles[:]: - #print "adding packagefile: ",package["name"] self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] })) if len(self.cmdList): self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n") + self.pluginname + "\n" + self.oktext) @@ -1284,55 +1510,54 @@ class PluginDetails(Screen, DreamInfoHandler): class UpdatePlugin(Screen): skin = """ - + - - - + + + """ - + def __init__(self, session, args = None): - self.skin = UpdatePlugin.skin Screen.__init__(self, session) - + self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } - + self.slider = Slider(0, 4) self["slider"] = self.slider self.activityslider = Slider(0, 100) self["activityslider"] = self.activityslider - self.status = Label(_("Upgrading Dreambox... Please wait")) + self.status = StaticText(_("Upgrading Dreambox... Please wait")) self["status"] = self.status - self.package = Label() + self.package = StaticText() self["package"] = self.package - + self.packages = 0 self.error = 0 - + self.activity = 0 self.activityTimer = eTimer() self.activityTimer.callback.append(self.doActivityTimer) self.activityTimer.start(100, False) - + self.ipkg = IpkgComponent() self.ipkg.addCallback(self.ipkgCallback) - + self.updating = True self.package.setText(_("Package list update")) self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - + self["actions"] = ActionMap(["WizardActions"], { "ok": self.exit, "back": self.exit }, -1) - + def doActivityTimer(self): self.activity += 1 if self.activity == 100: self.activity = 0 self.activityslider.setValue(self.activity) - + def ipkgCallback(self, event, param): if event == IpkgComponent.EVENT_DOWNLOAD: self.status.setText(_("Downloading")) @@ -1390,7 +1615,7 @@ class UpdatePlugin(Screen): self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?")) else: self.close() - + def exitAnswer(self, result): if result is not None and result: quitMainloop(2) @@ -1399,17 +1624,17 @@ class UpdatePlugin(Screen): class IpkgInstaller(Screen): skin = """ - - - - - - - - """ + + + + + + + + + """ def __init__(self, session, list): - self.skin = IpkgInstaller.skin Screen.__init__(self, session) self.list = SelectionList() @@ -1417,18 +1642,18 @@ class IpkgInstaller(Screen): for listindex in range(len(list)): self.list.addSelection(list[listindex], list[listindex], listindex, True) - self["red"] = Label() - self["green"] = Label() - self["yellow"] = Label() - self["blue"] = Label() + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Install")) + self["introduction"] = StaticText(_("Press OK to toggle the selection.")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "ok": self.list.toggleSelection, - "cancel": self.close, + "cancel": self.close, + "red": self.close, "green": self.install }, -1) - + def install(self): list = self.list.getSelectionsList() cmdList = [] @@ -1436,6 +1661,7 @@ class IpkgInstaller(Screen): cmdList.append((IpkgComponent.CMD_INSTALL, { "package": item[1] })) self.session.open(Ipkg, cmdList = cmdList) + def filescan_open(list, session, **kwargs): filelist = [x.path for x in list] session.open(IpkgInstaller, filelist) # list @@ -1450,7 +1676,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Ipkg", - description = _("Install software updates..."), + description = _("Install extensions."), openfnc = filescan_open, ) @@ -1470,6 +1696,6 @@ def Plugins(path, **kwargs): PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) ] - if config.usage.setup_level.index >= 2: # expert+ - list.append(PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=UpgradeMain)) + if config.usage.setup_level.index >= 2: # expert+ + list.append(PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=UpgradeMain)) return list