X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/daaf4b6ba8fbddd81553e0076385220ef1a7f327..57534d26a3ec9cc77ab3eedc5ad393897e4dee95:/lib/python/Components/PluginComponent.py 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()