aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-02-19 20:47:23 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-02-19 20:47:23 +0000
commit57534d26a3ec9cc77ab3eedc5ad393897e4dee95 (patch)
tree42b9c2fd59234c4fb6830728c9824bce1625d01c
parentdaaf4b6ba8fbddd81553e0076385220ef1a7f327 (diff)
downloadenigma2-57534d26a3ec9cc77ab3eedc5ad393897e4dee95.tar.gz
enigma2-57534d26a3ec9cc77ab3eedc5ad393897e4dee95.zip
re-add autostart plugins
-rw-r--r--doc/PLUGINS15
-rw-r--r--lib/python/Components/PluginComponent.py29
-rw-r--r--mytest.py4
3 files changed, 40 insertions, 8 deletions
diff --git a/doc/PLUGINS b/doc/PLUGINS
index fab701cb..96558775 100644
--- a/doc/PLUGINS
+++ b/doc/PLUGINS
@@ -68,3 +68,18 @@ def main(session):
with MyScreen being a GUI screen.
+
+autostarting plugins
+====================
+
+you can configure your plugin to automatically start on enigma startup, and
+end on shutdown.
+
+you just have to use "WHERE_AUTOSTART". your entry point must (fnc) look
+like:
+
+def autostartEntry(raeson):
+ if reason == 0: # startup
+ print "startup"
+ elif reason == 1:
+ print "shutdown"
diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py
index cfdbc4d0..bd8a6d07 100644
--- a/lib/python/Components/PluginComponent.py
+++ b/lib/python/Components/PluginComponent.py
@@ -1,6 +1,7 @@
import os
from Tools.Directories import *
+from Plugins.Plugin import PluginDescriptor
def my_import(name):
mod = __import__(name)
@@ -12,12 +13,27 @@ def my_import(name):
class PluginComponent:
def __init__(self):
self.plugins = {}
+ self.pluginList = [ ]
self.setPluginPrefix("Plugins.")
def setPluginPrefix(self, prefix):
self.prefix = prefix
-
- def readPluginList(self, runAutostartPlugins=False, runAutoendPlugins=False):
+
+ def addPlugin(self, plugin):
+ self.pluginList.append(plugin)
+ for x in plugin.where:
+ self.plugins.setdefault(x, []).append(plugin)
+ if x == PluginDescriptor.WHERE_AUTOSTART:
+ plugin(reason=0)
+
+ def removePlugin(self, plugin):
+ self.pluginList.remove(plugin)
+ for x in plugin.where:
+ self.plugins[x].remove(plugin)
+ if x == PluginDescriptor.WHERE_AUTOSTART:
+ plugin(reason=1)
+
+ def readPluginList(self):
"""enumerates plugins"""
directories = os.listdir(resolveFilename(SCOPE_PLUGINS))
@@ -40,10 +56,7 @@ class PluginComponent:
plugins = [ plugins ]
for p in plugins:
- print "imported plugin %s" % (p.name)
-
- for x in p.where:
- self.plugins.setdefault(x, []).append(p)
+ self.addPlugin(p);
def getPlugins(self, where):
"""Get list of plugins in a specific category"""
@@ -56,4 +69,8 @@ class PluginComponent:
res.append(p)
return res
+ def shutdown(self):
+ for p in self.pluginList[:]:
+ self.removePlugin(p)
+
plugins = PluginComponent()
diff --git a/mytest.py b/mytest.py
index dda2c87a..91cb9f95 100644
--- a/mytest.py
+++ b/mytest.py
@@ -35,7 +35,7 @@ except:
# initialize autorun plugins and plugin menu entries
from Components.PluginComponent import plugins
-plugins.readPluginList(runAutostartPlugins=True)
+plugins.readPluginList()
from Screens.Wizard import wizardManager
from Screens.StartWizard import *
@@ -331,7 +331,7 @@ import Components.NimManager
# first, setup a screen
try:
runScreenTest()
-# plugins.getPluginList(runAutoendPlugins=True)
+ plugins.shutdown()
except:
print 'EXCEPTION IN PYTHON STARTUP CODE:'
print '-'*60