Software /
code /
prosody
Changeset
584:eb0cea29c8d7
Temporary hack for global modules
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 06 Dec 2008 23:15:48 +0000 |
parents | 583:5821eaa80baa |
children | 585:033817e12ddb |
files | core/modulemanager.lua |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/core/modulemanager.lua Sat Dec 06 23:14:39 2008 +0000 +++ b/core/modulemanager.lua Sat Dec 06 23:15:48 2008 +0000 @@ -44,7 +44,7 @@ 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 @@ 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 @@ 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 @@ 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