tools/ejabberd2prosody: Fixed private storage export
[prosody.git] / core / modulemanager.lua
index 4391fc7fc16c5938dce284a400800ffc73a4d800..6dbc8c53b6fe10cf53d4313631ad1905fde1f497 100644 (file)
@@ -28,7 +28,7 @@ local type = type;
 local next = next;
 local rawget = rawget;
 
-local tostring, print = tostring, print;
+local tostring = tostring;
 
 -- We need this to let modules access the real global namespace
 local _G = _G;
@@ -53,6 +53,10 @@ local NULL = {};
 
 -- Load modules when a host is activated
 function load_modules_for_host(host)
+       if config.get(host, "core", "modules_enable") == false then
+               return; -- Only load for hosts, not components, etc.
+       end
+
        -- Load modules from global section
        local modules_enabled = config.get("*", "core", "modules_enabled");
        local modules_disabled = config.get(host, "core", "modules_disabled");
@@ -123,6 +127,10 @@ function load(host, module_name, config)
        -- Use modified host, if the module set one
        modulemap[api_instance.host][module_name] = pluginenv;
        
+       if api_instance.host == "*" and host ~= "*" then
+               api_instance:set_global();
+       end
+               
        return true;
 end
 
@@ -204,7 +212,7 @@ function handle_stanza(host, origin, stanza)
        local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type;
        if name == "iq" and xmlns == "jabber:client" then
                if stanza.attr.type == "get" or stanza.attr.type == "set" then
-                       xmlns = stanza.tags[1].attr.xmlns;
+                       xmlns = stanza.tags[1].attr.xmlns or "jabber:client";
                        log("debug", "Stanza of type %s from %s has xmlns: %s", name, origin_type, xmlns);
                else
                        log("debug", "Discarding %s from %s of type: %s", name, origin_type, stanza.attr.type);
@@ -260,6 +268,10 @@ end
 
 function api:set_global()
        self.host = "*";
+       -- Update the logger
+       local _log = logger.init("mod_"..self.name);
+       self.log = function (self, ...) return _log(...); end;
+       self._log = _log;
 end
 
 local function _add_handler(module, origin_type, tag, xmlns, handler)