diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/modulemanager.lua | 12 | ||||
-rw-r--r-- | core/rostermanager.lua | 9 | ||||
-rw-r--r-- | core/sessionmanager.lua | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index f160521f..082dcbb8 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -38,7 +38,8 @@ local _G = _G; module "modulemanager" -local api = {}; -- Module API container +api = {}; +local api = api; -- Module API container local modulemap = { ["*"] = {} }; @@ -134,6 +135,13 @@ function load(host, module_name, config) return nil, ret; end + if module_has_method(pluginenv, "load") then + local ok, err = call_module_method(pluginenv, "load"); + if (not ok) and err then + log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err); + end + end + -- Use modified host, if the module set one modulemap[api_instance.host][module_name] = pluginenv; @@ -190,7 +198,7 @@ function reload(host, name, ...) local _mod, err = pluginloader.load_code(name); -- checking for syntax errors if not _mod then - log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); + log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); return nil, err; end diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 867add2c..514d3d8e 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -82,19 +82,24 @@ end function load_roster(username, host) log("debug", "load_roster: asked for: "..username.."@"..host); + local roster; if hosts[host] and hosts[host].sessions[username] then - local roster = hosts[host].sessions[username].roster; + roster = hosts[host].sessions[username].roster; if not roster then log("debug", "load_roster: loading for new user: "..username.."@"..host); roster = datamanager.load(username, host, "roster") or {}; if not roster[false] then roster[false] = { }; end hosts[host].sessions[username].roster = roster; + hosts[host].events.fire_event("roster-load", username, host, roster); end return roster; end + -- Attempt to load roster for non-loaded user log("debug", "load_roster: loading for offline user: "..username.."@"..host); - return datamanager.load(username, host, "roster") or {}; + roster = datamanager.load(username, host, "roster") or {}; + hosts[host].events.fire_event("roster-load", username, host, roster); + return roster; end function save_roster(username, host) diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 19943db0..103533de 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -149,6 +149,8 @@ function bind_resource(session, resource) session.roster = rm_load_roster(session.username, session.host); + hosts[session.host].events.fire_event("resource-bind", session); + return true; end |