36 -- We need this to let modules access the real global namespace |
36 -- We need this to let modules access the real global namespace |
37 local _G = _G; |
37 local _G = _G; |
38 |
38 |
39 module "modulemanager" |
39 module "modulemanager" |
40 |
40 |
41 local api = {}; -- Module API container |
41 api = {}; |
|
42 local api = api; -- Module API container |
42 |
43 |
43 local modulemap = { ["*"] = {} }; |
44 local modulemap = { ["*"] = {} }; |
44 |
45 |
45 local stanza_handlers = multitable_new(); |
46 local stanza_handlers = multitable_new(); |
46 local handler_info = {}; |
47 local handler_info = {}; |
132 if not success then |
133 if not success then |
133 log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil"); |
134 log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil"); |
134 return nil, ret; |
135 return nil, ret; |
135 end |
136 end |
136 |
137 |
|
138 if module_has_method(pluginenv, "load") then |
|
139 local ok, err = call_module_method(pluginenv, "load"); |
|
140 if (not ok) and err then |
|
141 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err); |
|
142 end |
|
143 end |
|
144 |
137 -- Use modified host, if the module set one |
145 -- Use modified host, if the module set one |
138 modulemap[api_instance.host][module_name] = pluginenv; |
146 modulemap[api_instance.host][module_name] = pluginenv; |
139 |
147 |
140 if api_instance.host == "*" and host ~= "*" then |
148 if api_instance.host == "*" and host ~= "*" then |
141 api_instance:set_global(); |
149 api_instance:set_global(); |
188 local mod = get_module(host, name); |
196 local mod = get_module(host, name); |
189 if not mod then return nil, "module-not-loaded"; end |
197 if not mod then return nil, "module-not-loaded"; end |
190 |
198 |
191 local _mod, err = pluginloader.load_code(name); -- checking for syntax errors |
199 local _mod, err = pluginloader.load_code(name); -- checking for syntax errors |
192 if not _mod then |
200 if not _mod then |
193 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
201 log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); |
194 return nil, err; |
202 return nil, err; |
195 end |
203 end |
196 |
204 |
197 local saved; |
205 local saved; |
198 |
206 |