Comparison

core/modulemanager.lua @ 573:f6555ebf84ec

Move module loading to modulemanager
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Dec 2008 04:03:33 +0000
parent 569:5216efe6088b
child 577:22f54a04471f
child 578:5879264e28e2
comparison
equal deleted inserted replaced
572:b2d665689df7 573:f6555ebf84ec
23 23
24 local logger = require "util.logger"; 24 local logger = require "util.logger";
25 local log = logger.init("modulemanager"); 25 local log = logger.init("modulemanager");
26 local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler; 26 local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler;
27 local eventmanager = require "core.eventmanager"; 27 local eventmanager = require "core.eventmanager";
28 local config = require "core.configmanager";
28 29
29 30
30 local loadfile, pcall = loadfile, pcall; 31 local loadfile, pcall = loadfile, pcall;
31 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv; 32 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv;
32 local pairs, ipairs = pairs, ipairs; 33 local pairs, ipairs = pairs, ipairs;
47 local handler_info = {}; 48 local handler_info = {};
48 local stanza_handlers = {}; 49 local stanza_handlers = {};
49 50
50 local modulehelpers = setmetatable({}, { __index = _G }); 51 local modulehelpers = setmetatable({}, { __index = _G });
51 52
53 -- Load modules when a host is activated
54 function load_modules_for_host(host)
55 local modules_enabled = config.get(host, "core", "modules_enabled");
56 if modules_enabled then
57 for _, module in pairs(modules_enabled) do
58 load(host, module);
59 end
60 end
61 end
62 eventmanager.add_event_hook("host-activated", load_modules_for_host);
63 --
52 64
53 function load(host, module_name, config) 65 function load(host, module_name, config)
54 if not (host and module_name) then 66 if not (host and module_name) then
55 return nil, "insufficient-parameters"; 67 return nil, "insufficient-parameters";
56 end 68 end