diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-12-06 23:15:48 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-12-06 23:15:48 +0000 |
commit | c16c3b6f6700c9c43c4b42e5e1e923f535eb565f (patch) | |
tree | 627cbff6765ad241bec92c3a877d7450f865bd33 /core/modulemanager.lua | |
parent | b3e9fc629cab5f1da5b8e0b9b2b1673ea8499558 (diff) | |
download | prosody-c16c3b6f6700c9c43c4b42e5e1e923f535eb565f.tar.gz prosody-c16c3b6f6700c9c43c4b42e5e1e923f535eb565f.zip |
Temporary hack for global modules
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r-- | core/modulemanager.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 3f335c89..65ab3e1a 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -44,7 +44,7 @@ module "modulemanager" local api = {}; -- Module API container -local modulemap = {}; +local modulemap = { ["*"] = {} }; local m_handler_info = multitable_new(); local m_stanza_handlers = multitable_new(); @@ -69,11 +69,6 @@ function load(host, module_name, config) if not (host and module_name) then return nil, "insufficient-parameters"; end - local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); - if not mod then - log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); - return nil, err; - end if not modulemap[host] then modulemap[host] = {}; @@ -81,8 +76,17 @@ function load(host, module_name, config) elseif modulemap[host][module_name] then log("warn", "%s is already loaded for %s, so not loading again", module_name, host); return nil, "module-already-loaded"; + elseif modulemap["*"][module_name] then + return nil, "global-module-already-loaded"; end + + local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); + if not mod then + log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); + return nil, err; + end + local _log = logger.init(host..":"..module_name); local api_instance = setmetatable({ name = module_name, host = host, config = config, _log = _log, log = function (self, ...) return _log(...); end }, { __index = api }); @@ -96,7 +100,8 @@ function load(host, module_name, config) return nil, ret; end - modulemap[host][module_name] = mod; + -- Use modified host, if the module set one + modulemap[api_instance.host][module_name] = mod; return true; end |