summaryrefslogtreecommitdiff
path: root/src/plugin_manager.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-06 23:46:00 +0100
committermathieui <mathieui@mathieui.net>2011-11-06 23:46:00 +0100
commit961cf5df8548ec0985f2755d21af933d8c023ee4 (patch)
tree5e80b19af671320f777a65812c7404bbcad2fe07 /src/plugin_manager.py
parent840acd3bd4dcee91ca34c5b4e4c89ce5e78a56b4 (diff)
downloadpoezio-961cf5df8548ec0985f2755d21af933d8c023ee4.tar.gz
poezio-961cf5df8548ec0985f2755d21af933d8c023ee4.tar.bz2
poezio-961cf5df8548ec0985f2755d21af933d8c023ee4.tar.xz
poezio-961cf5df8548ec0985f2755d21af933d8c023ee4.zip
New type of events to be used with the plugins
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r--src/plugin_manager.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py
index 5bd6d75b..37db3d13 100644
--- a/src/plugin_manager.py
+++ b/src/plugin_manager.py
@@ -34,6 +34,7 @@ class PluginManager(object):
self.plugins = {} # module name -> plugin object
self.commands = {} # module name -> dict of commands loaded for the module
self.event_handlers = {} # module name -> list of event_name/handler pairs loaded for the module
+ self.poezio_event_handlers = {}
def load(self, name):
if name in self.plugins:
@@ -60,6 +61,7 @@ class PluginManager(object):
self.modules[name] = module
self.commands[name] = {}
self.event_handlers[name] = []
+ self.poezio_event_handlers[name] = []
self.plugins[name] = module.Plugin(self, self.core, plugins_conf_dir)
def unload(self, name):
@@ -69,14 +71,14 @@ class PluginManager(object):
del self.core.commands[command]
for event_name, handler in self.event_handlers[name]:
self.core.xmpp.del_event_handler(event_name, handler)
- for event_name in self.core.internal_events:
- if name in event_name:
- del event_name[name]
+ for handler in self.poezio_event_handlers[name]:
+ self.core.events.del_event_handler(None, handler)
self.plugins[name].unload()
del self.plugins[name]
del self.commands[name]
del self.event_handlers[name]
+ del self.poezio_event_handlers[name]
except Exception as e:
import traceback
self.core.information(_("Could not unload plugin (may not be safe to try again): ") + traceback.format_exc())
@@ -105,6 +107,16 @@ class PluginManager(object):
eh = self.event_handlers[module_name]
eh = list(filter(lambda e : e != (event_name, handler), eh))
+ def add_poezio_event_handler(self, module_name, event_name, handler, first, last, position):
+ eh = self.poezio_event_handlers[module_name]
+ eh.append(handler)
+ self.core.events.add_event_handler(event_name, handler, first, last, position)
+
+ def del_poezio_event_handler(self, module_name, event_name, handler):
+ self.core.events.del_event_handler(None, handler)
+ eh = self.poezio_event_handlers[module_name]
+ eh = list(filter(lambda e : e != handler, eh))
+
def completion_load(self, the_input):
"""
completion function that completes the name of the plugins, from