From: Stefan Pluecken Date: Wed, 22 Feb 2006 22:14:19 +0000 (+0000) Subject: cleanup the plugins to fit the new namespace X-Git-Tag: 2.6.0~4053 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/31fb73a15d12559b15f5506622c3902476d3ea0f cleanup the plugins to fit the new namespace --- diff --git a/configure.ac b/configure.ac index b5a19aad..c77d3ceb 100644 --- a/configure.ac +++ b/configure.ac @@ -60,12 +60,15 @@ lib/python/Makefile lib/python/Components/Makefile lib/python/Screens/Makefile lib/python/Plugins/Makefile -lib/python/Plugins/update/Makefile -lib/python/Plugins/FileManager/Makefile -lib/python/Plugins/fpupgrade/Makefile -lib/python/Plugins/test/Makefile -lib/python/Plugins/tuxboxplugins/Makefile -lib/python/Plugins/web/Makefile +lib/python/Plugins/SystemPlugins/Makefile +lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile +lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile +lib/python/Plugins/DemoPlugins/Makefile +lib/python/Plugins/DemoPlugins/TestPlugin/Makefile +lib/python/Plugins/Extensions/Makefile +lib/python/Plugins/Extensions/TuxboxPlugins/Makefile +lib/python/Plugins/Extensions/WebInterface/Makefile +lib/python/Plugins/Extensions/FileManager/Makefile lib/python/Tools/Makefile lib/service/Makefile lib/components/Makefile diff --git a/lib/python/Plugins/DemoPlugins/Makefile.am b/lib/python/Plugins/DemoPlugins/Makefile.am new file mode 100644 index 00000000..86e98ec2 --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = TestPlugin diff --git a/lib/python/Plugins/DemoPlugins/TestPlugin/Makefile.am b/lib/python/Plugins/DemoPlugins/TestPlugin/Makefile.am new file mode 100644 index 00000000..dd6980ac --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/TestPlugin/Makefile.am @@ -0,0 +1,6 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/TestPlugin + +install_PYTHON = \ + __init__.py \ + plugin.py + diff --git a/lib/python/Plugins/DemoPlugins/TestPlugin/__init__.py b/lib/python/Plugins/DemoPlugins/TestPlugin/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py new file mode 100644 index 00000000..5991f594 --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py @@ -0,0 +1,69 @@ +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import NumberActionMap +from Components.Label import Label +from Components.Input import Input +from Components.GUIComponent import * +from Components.Pixmap import Pixmap +from Components.FileList import FileEntryComponent, FileList +from Plugins.Plugin import PluginDescriptor + +import os + +class Test(Screen): + skin = """ + + + + + """ + def __init__(self, session, args = None): + self.skin = Test.skin + Screen.__init__(self, session) + + self["list"] = FileList("/", matchingPattern = "^.*\.(png|avi|mp3|mpeg|ts)") + self["pixmap"] = Pixmap() + + #self["text"] = Input("1234", maxSize=True, type=Input.NUMBER) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions"], + { + "ok": self.ok, + "back": self.close, +# "left": self.keyLeft, +# "right": self.keyRight, + "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) + + def keyLeft(self): + self["text"].left() + + def keyRight(self): + self["text"].right() + + def ok(self): + selection = self["list"].getSelection() + if selection[1] == True: # isDir + self["list"].changeDir(selection[0]) + else: + self["pixmap"].instance.setPixmapFromFile(selection[0]) + + def keyNumberGlobal(self, number): + print "pressed", number + self["text"].number(number) + +def main(session): + session.open(Test) + +def Plugins(): + return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main) diff --git a/lib/python/Plugins/Extensions/Makefile.am b/lib/python/Plugins/Extensions/Makefile.am new file mode 100644 index 00000000..a8998c13 --- /dev/null +++ b/lib/python/Plugins/Extensions/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = TuxboxPlugins WebInterface FileManager diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/Makefile.am b/lib/python/Plugins/Extensions/TuxboxPlugins/Makefile.am new file mode 100644 index 00000000..529d9888 --- /dev/null +++ b/lib/python/Plugins/Extensions/TuxboxPlugins/Makefile.am @@ -0,0 +1,8 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/TuxboxPlugins + +install_PYTHON = \ + __init__.py \ + plugin.py \ + tuxbox.png + + diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/__init__.py b/lib/python/Plugins/Extensions/TuxboxPlugins/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py b/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py new file mode 100644 index 00000000..7ab02da7 --- /dev/null +++ b/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py @@ -0,0 +1,46 @@ +# must be fixed for the new plugin interface +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import ActionMap +from Components.Label import Label +from Tools.BoundFunction import boundFunction +from Tools.Directories import pathExists +from Plugins.Plugin import PluginDescriptor + +import os + +TUXBOX_PLUGINS_PATH = "/usr/lib/tuxbox/plugins/" + +def getPlugins(): + pluginlist = [] + + if pathExists(TUXBOX_PLUGINS_PATH): + dir = os.listdir(TUXBOX_PLUGINS_PATH) + + for x in dir: + if x[-3:] == "cfg": + params = getPluginParams(x) + pluginlist.append(PluginDescriptor(name=params["name"], description=params["desc"], where = PluginDescriptor.WHERE_PLUGINMENU, icon="tuxbox.png", fnc=boundFunction(main, plugin=x))) + + return pluginlist + +def getPluginParams(file): + params = {} + try: + file = open(TUXBOX_PLUGINS_PATH + file, "r") + for x in file.readlines(): + split = x.split("=") + params[split[0]] = split[1] + file.close() + except IOError: + print "no tuxbox plugins found" + + return params + +def main(session, plugin): + print "Running plugin " + plugin[:-4] + ".so with config file", plugin + print getPluginParams(plugin) + +def Plugins(): + return getPlugins() \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/tuxbox.png b/lib/python/Plugins/Extensions/TuxboxPlugins/tuxbox.png new file mode 100644 index 00000000..0d28db01 Binary files /dev/null and b/lib/python/Plugins/Extensions/TuxboxPlugins/tuxbox.png differ diff --git a/lib/python/Plugins/Extensions/WebInterface/Makefile.am b/lib/python/Plugins/Extensions/WebInterface/Makefile.am new file mode 100644 index 00000000..9b7bd296 --- /dev/null +++ b/lib/python/Plugins/Extensions/WebInterface/Makefile.am @@ -0,0 +1,7 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/WebInterface + +install_PYTHON = \ + __init__.py \ + plugin.py \ + update.png + \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/WebInterface/__init__.py b/lib/python/Plugins/Extensions/WebInterface/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/Extensions/WebInterface/plugin.py b/lib/python/Plugins/Extensions/WebInterface/plugin.py new file mode 100644 index 00000000..f0be4e45 --- /dev/null +++ b/lib/python/Plugins/Extensions/WebInterface/plugin.py @@ -0,0 +1,19 @@ +from Plugins.Plugin import PluginDescriptor + +def startWebserver(): + from twisted.internet import reactor + from twisted.web2 import server, http, static + toplevel = static.File("/hdd") + site = server.Site(toplevel) + + reactor.listenTCP(80, http.HTTPFactory(site)) + +def autostart(reason): + if reason == 0: + try: + startWebserver() + except ImportError: + print "twisted not available, not starting web services" + +def Plugins(): + return PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) diff --git a/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile.am b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile.am new file mode 100644 index 00000000..2475d674 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile.am @@ -0,0 +1,6 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/FrontprocessorUpgrade + +install_PYTHON = \ + __init__.py \ + plugin.py + diff --git a/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/__init__.py b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/plugin.py b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/plugin.py new file mode 100644 index 00000000..fea38424 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/plugin.py @@ -0,0 +1,54 @@ +from Screens.Screen import Screen +from Components.ActionMap import ActionMap +from Components.Label import Label +from Plugins.Plugin import PluginDescriptor + +def getUpgradeVersion(): + import os + r = os.popen("fpupgrade --version").read() + if r[:16] != "FP update tool v": + return None + else: + return int(r[16:]) + +class FPUpgrade(Screen): + skin = """ + + + + + + + """ + def __init__(self, session): + self.skin = FPUpgrade.skin + Screen.__init__(self, session) + + from Tools.DreamboxHardware import getFPVersion + version = str(getFPVersion() or "N/A") + newversion = str(getUpgradeVersion() or "N/A") + + self["text"] = Label(_("Your frontprocessor firmware must be upgraded.\nPress OK to start upgrade.")) + self["oldversion_label"] = Label(_("Current version:")) + self["newversion_label"] = Label(_("New version:")) + + self["oldversion"] = Label(version) + self["newversion"] = Label(newversion) + + self["actions"] = ActionMap(["OkCancelActions"], + { + "ok": self.ok, + "cancel": self.close, + }) + + def ok(self): + self.close(4) + +def Plugins(): + from Tools.DreamboxHardware import getFPVersion + version = getFPVersion() + newversion = getUpgradeVersion() or 0 + if version is not None and version < newversion: + return PluginDescriptor(name="FP Upgrade", where = PluginDescriptor.WHERE_WIZARD, fnc=FPUpgrade) + else: + return [ ] diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am new file mode 100644 index 00000000..2b71624c --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = SoftwareUpdate FrontprocessorUpgrade diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am new file mode 100644 index 00000000..9f7bd4c4 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile.am @@ -0,0 +1,7 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/SoftwareUpdate + +install_PYTHON = \ + __init__.py \ + plugin.py \ + update.png + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/__init__.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py new file mode 100644 index 00000000..c065c815 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py @@ -0,0 +1,222 @@ +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import ActionMap, NumberActionMap +from Components.ScrollLabel import ScrollLabel +from Components.GUIComponent import * +from Components.MenuList import MenuList +from Components.Input import Input +from Screens.Console import Console +from Plugins.Plugin import PluginDescriptor + +import os + +class UpdatePluginMenu(Screen): + skin = """ + + + """ + + def __init__(self, session, args = 0): + self.skin = UpdatePluginMenu.skin + Screen.__init__(self, session) + + self.menu = args + + list = [] + if self.menu == 0: + list.append((_("Upgrade"), "upgrade")) + list.append((_("Advanced"), "advanced")) + elif self.menu == 1: + list.append((_("Choose source"), "source")) + list.append((_("Packet management"), "ipkg")) + list.append((_("Settings"), "setup")) + + self["menu"] = MenuList(list) + + self["actions"] = ActionMap(["WizardActions", "DirectionActions"], + { + "ok": self.go, + "back": self.close, + }, -1) + + def go(self): + if self.menu == 0: + if (self["menu"].l.getCurrentSelection()[1] == "upgrade"): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!")) + if (self["menu"].l.getCurrentSelection()[1] == "advanced"): + self.session.open(UpdatePluginMenu, 1) + if self.menu == 1: + if (self["menu"].l.getCurrentSelection()[1] == "source"): + self.session.open(IPKGSource) + elif (self["menu"].l.getCurrentSelection()[1] == "ipkg"): + self.session.open(Ipkg) + elif (self["menu"].l.getCurrentSelection()[1] == "setup"): + self.session.open(MessageBox, _("Function not yet implemented"), MessageBox.TYPE_ERROR) + def runUpgrade(self, result): + if result: + self.session.open(Console, ["ipkg update", "ipkg upgrade -force-defaults -force-overwrite"]) + +class IPKGSource(Screen): + skin = """ + + + """ + + def __init__(self, session, args = None): + self.skin = IPKGSource.skin + Screen.__init__(self, session) + + fp = file('/etc/ipkg/official-feed.conf', 'r') + sources = fp.readlines() + fp.close() + + self["text"] = Input(sources[0], maxSize=False, type=Input.TEXT) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions"], + { + "ok": self.go, + "back": self.close, + "left": self.keyLeft, + "right": self.keyRight, + "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) + + def go(self): + fp = file('/etc/ipkg/official-feed.conf', 'w') + fp.write(self["text"].getText()) + fp.close() + self.close() + + def keyLeft(self): + self["text"].left() + + def keyRight(self): + self["text"].right() + + def keyNumberGlobal(self, number): + print "pressed", number + self["text"].number(number) + +RT_HALIGN_LEFT = 0 +RT_HALIGN_RIGHT = 1 +RT_HALIGN_CENTER = 2 +RT_HALIGN_BLOCK = 4 + +RT_VALIGN_TOP = 0 +RT_VALIGN_CENTER = 8 +RT_VALIGN_BOTTOM = 16 + +def PacketEntryComponent(packet): + res = [ packet ] + + res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[0])) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 250, 0, 200, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[1])) + res.append((eListboxPythonMultiContent.TYPE_TEXT, 450, 0, 100, 30, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, packet[2])) + return res + +class PacketList(GUIComponent): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonMultiContent() + self.l.setList(list) + self.l.setFont(0, gFont("Regular", 20)) + self.l.setFont(1, gFont("Regular", 18)) + + def getCurrent(self): + return self.l.getCurrentSelection() + + def GUIcreate(self, parent): + self.instance = eListbox(parent) + self.instance.setContent(self.l) + self.instance.setItemHeight(30) + + def GUIdelete(self): + self.instance.setContent(None) + self.instance = None + + def invalidate(self): + self.l.invalidate() + +class Ipkg(Screen): + skin = """ + + + """ + + def __init__(self, session, args = None): + self.skin = Ipkg.skin + Screen.__init__(self, session) + + list = [] + self.list = list + self.fillPacketList() + + self["list"] = PacketList(self.list) + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.close, + "back": self.close + }, -1) + + + def fillPacketList(self): + lines = os.popen("ipkg list", "r").readlines() + packetlist = [] + for x in lines: + split = x.split(' - ') + packetlist.append([split[0].strip(), split[1].strip()]) + + lines = os.popen("ipkg list_installed", "r").readlines() + + installedlist = {} + for x in lines: + split = x.split(' - ') + installedlist[split[0].strip()] = split[1].strip() + + for x in packetlist: + status = "" + if installedlist.has_key(x[0]): + if installedlist[x[0]] == x[1]: + status = "installed" + else: + status = "upgradable" + self.list.append(PacketEntryComponent([x[0], x[1], status])) + + def go(self): + if self.update: + self.session.openWithCallback(self.doUpdate, MessageBox, _("Do you want to update your Dreambox?\nAfter pressing OK, please wait!")) + else: + self.close() + + def doUpdateDelay(self): + lines = os.popen("ipkg update && ipkg upgrade", "r").readlines() + string = "" + for x in lines: + string += x + self["text"].setText(_("Updating finished. Here is the result:") + "\n\n" + string) + self.update = False + + + def doUpdate(self, val = False): + if val == True: + self["text"].setText(_("Updating... Please wait... This can take some minutes...")) + self.delayTimer.start(0, 1) + else: + self.close() + +def UpgradeMain(session): + session.open(UpdatePluginMenu) + +def Plugins(): + return PluginDescriptor(name="Softwareupdate", description="Updates your receiver's software", icon="update.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=UpgradeMain) diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png new file mode 100644 index 00000000..6bc17b1e Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/update.png differ