+ if iSoftwareTools.NetworkConnectionAvailable:
+ if self.packagefiles:
+ for package in self.packagefiles[:]:
+ 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)
+
+ def runUpgrade(self, result):
+ if result:
+ 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.close(True)
+ if result:
+ quitMainloop(3)
+
+ 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)
+
+ def reloadPluginlist(self):
+ plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
+
+ def fetchFailed(self,string):
+ self.setThumbnail(noScreenshot = True)
+ print "[PluginDetails] fetch failed " + string.getErrorMessage()
+
+
+class UpdatePlugin(Screen):
+ skin = """
+ <screen name="UpdatePlugin" position="center,center" size="550,300" title="Software update" >
+ <widget name="activityslider" position="0,0" size="550,5" />
+ <widget name="slider" position="0,150" size="550,30" />
+ <widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
+ <widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
+ </screen>"""
+
+ def __init__(self, session, args = None):
+ 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 = StaticText(_("Please wait..."))
+ self["status"] = self.status
+ self.package = StaticText(_("Verifying your internet connection..."))
+ self["package"] = self.package
+ self.oktext = _("Press OK on your remote control to continue.")
+
+ self.packages = 0
+ self.error = 0
+ self.processed_packages = []
+
+ self.activity = 0
+ self.activityTimer = eTimer()
+ self.activityTimer.callback.append(self.doActivityTimer)
+
+ self.ipkg = IpkgComponent()
+ self.ipkg.addCallback(self.ipkgCallback)
+
+ self.updating = False
+
+ self["actions"] = ActionMap(["WizardActions"],
+ {
+ "ok": self.exit,
+ "back": self.exit
+ }, -1)
+
+ iNetwork.checkNetworkState(self.checkNetworkCB)
+ self.onClose.append(self.cleanup)
+
+ def cleanup(self):
+ iNetwork.stopPingConsole()
+
+ def checkNetworkCB(self,data):
+ if data is not None:
+ if data <= 2:
+ self.updating = True
+ self.activityTimer.start(100, False)
+ self.package.setText(_("Package list update"))
+ self.status.setText(_("Upgrading Dreambox... Please wait"))
+ self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
+ else:
+ self.package.setText(_("Your network is not working. Please try again."))
+ self.status.setText(self.oktext)
+
+ 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"))
+ elif event == IpkgComponent.EVENT_UPGRADE:
+ if self.sliderPackages.has_key(param):
+ self.slider.setValue(self.sliderPackages[param])
+ self.package.setText(param)
+ self.status.setText(_("Upgrading"))
+ if not param in self.processed_packages:
+ self.processed_packages.append(param)
+ self.packages += 1
+ elif event == IpkgComponent.EVENT_INSTALL:
+ self.package.setText(param)
+ self.status.setText(_("Installing"))
+ if not param in self.processed_packages:
+ self.processed_packages.append(param)
+ self.packages += 1
+ elif event == IpkgComponent.EVENT_REMOVE:
+ self.package.setText(param)
+ self.status.setText(_("Removing"))
+ if not param in self.processed_packages:
+ self.processed_packages.append(param)
+ self.packages += 1
+ elif event == IpkgComponent.EVENT_CONFIGURING:
+ self.package.setText(param)
+ self.status.setText(_("Configuring"))
+
+ elif event == IpkgComponent.EVENT_MODIFIED:
+ if config.plugins.SoftwareManager.overwriteConfigFiles.value in ("N", "Y"):
+ self.ipkg.write(True and config.plugins.SoftwareManager.overwriteConfigFiles.value)
+ else:
+ self.session.openWithCallback(
+ self.modificationCallback,
+ MessageBox,
+ _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param)
+ )
+ elif event == IpkgComponent.EVENT_ERROR:
+ self.error += 1
+ elif event == IpkgComponent.EVENT_DONE:
+ if self.updating:
+ self.updating = False
+ self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False})
+ elif self.error == 0:
+ self.slider.setValue(4)
+
+ self.activityTimer.stop()
+ self.activityslider.setValue(0)
+
+ self.package.setText(_("Done - Installed or upgraded %d packages") % self.packages)
+ self.status.setText(self.oktext)
+ 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.")
+ 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.")
+ self.status.setText(_("Error") + " - " + error)
+ #print event, "-", param
+ pass
+
+ def modificationCallback(self, res):
+ self.ipkg.write(res and "N" or "Y")
+
+ 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?"))
+ else:
+ self.close()
+ else:
+ if not self.updating:
+ self.close()
+
+ def exitAnswer(self, result):
+ if result is not None and result:
+ quitMainloop(2)
+ self.close()
+
+
+
+class IPKGMenu(Screen):
+ skin = """
+ <screen name="IPKGMenu" position="center,center" size="560,400" title="Select upgrade source to edit." >
+ <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+ <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+ <widget name="filelist" position="5,50" size="550,340" scrollbarMode="showOnDemand" />
+ </screen>"""
+
+ def __init__(self, session, plugin_path):
+ Screen.__init__(self, session)
+ self.skin_path = plugin_path
+
+ self["key_red"] = StaticText(_("Close"))
+ self["key_green"] = StaticText(_("Edit"))
+
+ self.sel = []
+ self.val = []
+ self.entry = False
+ self.exe = False
+
+ self.path = ""
+
+ self["actions"] = NumberActionMap(["SetupActions"],
+ {
+ "ok": self.KeyOk,
+ "cancel": self.keyCancel
+ }, -1)
+
+ self["shortcuts"] = ActionMap(["ShortcutActions"],
+ {
+ "red": self.keyCancel,
+ "green": self.KeyOk,
+ })
+ self.flist = []
+ self["filelist"] = MenuList(self.flist)
+ self.fill_list()
+ self.onLayoutFinish.append(self.layoutFinished)
+
+ def layoutFinished(self):
+ self.setWindowTitle()
+
+ def setWindowTitle(self):
+ self.setTitle(_("Select upgrade source to edit."))
+
+ def fill_list(self):
+ self.flist = []
+ self.path = '/etc/ipkg/'
+ if (os_path.exists(self.path) == False):
+ self.entry = False
+ return
+ for file in listdir(self.path):
+ if (file.endswith(".conf")):
+ if file != 'arch.conf':
+ self.flist.append((file))
+ self.entry = True
+ self["filelist"].l.setList(self.flist)
+
+ def KeyOk(self):
+ if (self.exe == False) and (self.entry == True):
+ self.sel = self["filelist"].getCurrent()
+ self.val = self.path + self.sel
+ self.session.open(IPKGSource, self.val)
+
+ def keyCancel(self):
+ self.close()
+
+ def Exit(self):
+ self.close()
+
+
+class IPKGSource(Screen):
+ skin = """
+ <screen name="IPKGSource" position="center,center" size="560,80" title="Edit upgrade source url." >
+ <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+ <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+ <widget name="text" position="5,50" size="550,25" font="Regular;20" backgroundColor="background" foregroundColor="#cccccc" />
+ </screen>"""
+
+ def __init__(self, session, configfile = None):
+ Screen.__init__(self, session)
+ self.session = session
+ self.configfile = configfile
+ text = ""
+ if self.configfile:
+ try:
+ fp = file(configfile, 'r')
+ sources = fp.readlines()
+ if sources:
+ text = sources[0]
+ fp.close()
+ except IOError:
+ pass
+
+ desk = getDesktop(0)
+ x= int(desk.size().width())
+ y= int(desk.size().height())
+
+ 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,
+ "back": self.close,
+ "red": self.close,
+ "green": self.go,
+ "left": self.keyLeft,
+ "right": self.keyRight,
+ "home": self.keyHome,
+ "end": self.keyEnd,
+ "deleteForward": self.keyDeleteForward,
+ "deleteBackward": self.keyDeleteBackward,
+ "1": self.keyNumberGlobal,
+ "2": self.keyNumberGlobal,
+ "3": self.keyNumberGlobal,
+ "4": self.keyNumberGlobal,
+ "5": self.keyNumberGlobal,
+ "6": self.keyNumberGlobal,
+ "7": self.keyNumberGlobal,
+ "8": self.keyNumberGlobal,
+ "9": self.keyNumberGlobal,
+ "0": self.keyNumberGlobal
+ }, -1)
+
+ self.onLayoutFinish.append(self.layoutFinished)
+
+ def layoutFinished(self):
+ self.setWindowTitle()
+ self["text"].right()
+
+ def setWindowTitle(self):
+ self.setTitle(_("Edit upgrade source url."))
+
+ def go(self):
+ text = self["text"].getText()
+ if text:
+ fp = file(self.configfile, 'w')
+ fp.write(text)
+ fp.write("\n")
+ fp.close()
+ self.close()
+
+ def keyLeft(self):
+ self["text"].left()
+
+ def keyRight(self):
+ self["text"].right()
+
+ def keyHome(self):
+ self["text"].home()
+
+ def keyEnd(self):
+ self["text"].end()
+
+ def keyDeleteForward(self):
+ self["text"].delete()
+
+ def keyDeleteBackward(self):
+ self["text"].deleteBackward()
+
+ def keyNumberGlobal(self, number):
+ self["text"].number(number)
+
+
+class PacketManager(Screen, NumericalTextInput):
+ skin = """
+ <screen name="PacketManager" position="center,center" size="530,420" title="Packet manager" >
+ <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+ <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+ <widget source="list" render="Listbox" position="5,50" size="520,365" scrollbarMode="showOnDemand">
+ <convert type="TemplatedMultiContent">
+ {"template": [
+ MultiContentEntryText(pos = (5, 1), size = (440, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name
+ MultiContentEntryText(pos = (5, 26), size = (440, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description
+ MultiContentEntryPixmapAlphaTest(pos = (445, 2), size = (48, 48), png = 4), # index 4 is the status pixmap
+ MultiContentEntryPixmapAlphaTest(pos = (5, 50), size = (510, 2), png = 5), # index 4 is the div pixmap
+ ],
+ "fonts": [gFont("Regular", 22),gFont("Regular", 14)],
+ "itemHeight": 52
+ }
+ </convert>
+ </widget>
+ </screen>"""
+
+ def __init__(self, session, plugin_path, args = None):
+ Screen.__init__(self, session)
+ NumericalTextInput.__init__(self)
+ self.session = session
+ self.skin_path = plugin_path
+
+ self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz')
+
+ self["shortcuts"] = NumberActionMap(["ShortcutActions", "WizardActions", "NumberActions", "InputActions", "InputAsciiActions", "KeyboardInputActions" ],
+ {
+ "ok": self.go,
+ "back": self.exit,
+ "red": self.exit,
+ "green": self.reload,
+ "gotAsciiCode": self.keyGotAscii,
+ "1": self.keyNumberGlobal,
+ "2": self.keyNumberGlobal,
+ "3": self.keyNumberGlobal,
+ "4": self.keyNumberGlobal,
+ "5": self.keyNumberGlobal,
+ "6": self.keyNumberGlobal,
+ "7": self.keyNumberGlobal,
+ "8": self.keyNumberGlobal,
+ "9": self.keyNumberGlobal,
+ "0": self.keyNumberGlobal
+ }, -1)
+
+ self.list = []
+ self.statuslist = []
+ self["list"] = List(self.list)
+ self["key_red"] = StaticText(_("Close"))
+ self["key_green"] = StaticText(_("Reload"))
+
+ self.list_updating = True
+ self.packetlist = []
+ self.installed_packetlist = {}
+ self.upgradeable_packages = {}
+ self.Console = Console()
+ self.cmdList = []
+ self.cachelist = []
+ self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs)
+ 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)
+ self.onShown.append(self.setWindowTitle)
+ self.onLayoutFinish.append(self.rebuildList)
+
+ rcinput = eRCInput.getInstance()
+ rcinput.setKeyboardMode(rcinput.kmAscii)
+
+ def keyNumberGlobal(self, val):
+ key = self.getKey(val)
+ if key is not None:
+ keyvalue = key.encode("utf-8")
+ if len(keyvalue) == 1:
+ self.setNextIdx(keyvalue[0])
+
+ def keyGotAscii(self):
+ keyvalue = unichr(getPrevAsciiCode()).encode("utf-8")
+ if len(keyvalue) == 1:
+ self.setNextIdx(keyvalue[0])
+
+ def setNextIdx(self,char):
+ if char in ("0", "1", "a"):
+ self["list"].setIndex(0)
+ else:
+ idx = self.getNextIdx(char)
+ if idx and idx <= self["list"].count:
+ self["list"].setIndex(idx)
+
+ def getNextIdx(self,char):
+ idx = 0
+ for i in self["list"].list:
+ if i[0][0] == char:
+ return idx
+ idx += 1
+
+ def exit(self):
+ 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)
+ rcinput = eRCInput.getInstance()
+ rcinput.setKeyboardMode(rcinput.kmNone)
+ self.close()