summaryrefslogtreecommitdiff
path: root/src/plugin_manager.py
diff options
context:
space:
mode:
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