Software /
code /
prosody
Comparison
core/modulemanager.lua @ 3433:b567ac8e2040
modulemanager: Remove dependency on eventmanager
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 03 Aug 2010 10:52:53 +0100 |
parent | 3180:99be525bcfb4 |
child | 3530:73909cca846c |
comparison
equal
deleted
inserted
replaced
3432:7f3e45955725 | 3433:b567ac8e2040 |
---|---|
8 | 8 |
9 local plugin_dir = CFG_PLUGINDIR or "./plugins/"; | 9 local plugin_dir = CFG_PLUGINDIR or "./plugins/"; |
10 | 10 |
11 local logger = require "util.logger"; | 11 local logger = require "util.logger"; |
12 local log = logger.init("modulemanager"); | 12 local log = logger.init("modulemanager"); |
13 local eventmanager = require "core.eventmanager"; | |
14 local config = require "core.configmanager"; | 13 local config = require "core.configmanager"; |
15 local multitable_new = require "util.multitable".new; | 14 local multitable_new = require "util.multitable".new; |
16 local st = require "util.stanza"; | 15 local st = require "util.stanza"; |
17 local pluginloader = require "util.pluginloader"; | 16 local pluginloader = require "util.pluginloader"; |
18 | 17 |
19 local hosts = hosts; | 18 local hosts = hosts; |
20 local prosody = prosody; | 19 local prosody = prosody; |
20 local prosody_events = prosody.events; | |
21 | 21 |
22 local loadfile, pcall, xpcall = loadfile, pcall, xpcall; | 22 local loadfile, pcall, xpcall = loadfile, pcall, xpcall; |
23 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; | 23 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; |
24 local pairs, ipairs = pairs, ipairs; | 24 local pairs, ipairs = pairs, ipairs; |
25 local t_insert, t_concat = table.insert, table.concat; | 25 local t_insert, t_concat = table.insert, table.concat; |
102 load(host, module); | 102 load(host, module); |
103 end | 103 end |
104 end | 104 end |
105 end | 105 end |
106 end | 106 end |
107 eventmanager.add_event_hook("host-activated", load_modules_for_host); | 107 prosody_events.add_handler("host-activated", load_modules_for_host); |
108 eventmanager.add_event_hook("component-activated", load_modules_for_host); | 108 prosody_events.add_handler("component-activated", load_modules_for_host); |
109 -- | 109 -- |
110 | 110 |
111 function load(host, module_name, config) | 111 function load(host, module_name, config) |
112 if not (host and module_name) then | 112 if not (host and module_name) then |
113 return nil, "insufficient-parameters"; | 113 return nil, "insufficient-parameters"; |
372 handler(...); | 372 handler(...); |
373 end | 373 end |
374 end; | 374 end; |
375 function api:add_event_hook(name, handler) | 375 function api:add_event_hook(name, handler) |
376 if not hooked:get(self.host, self.name, name) then | 376 if not hooked:get(self.host, self.name, name) then |
377 eventmanager.add_event_hook(name, function(...) event_hook(self.host, self.name, name, ...); end); | 377 prosody_events.add_handler(name, function(...) event_hook(self.host, self.name, name, ...); end); |
378 hooked:set(self.host, self.name, name, true); | 378 hooked:set(self.host, self.name, name, true); |
379 end | 379 end |
380 event_hooks:set(self.host, self.name, name, handler, true); | 380 event_hooks:set(self.host, self.name, name, handler, true); |
381 end | 381 end |
382 | 382 |