Merge 0.10->trunk
[prosody.git] / core / moduleapi.lua
index bdf9959f7d098de8db7fc88fcc31e0d23aa378df..9b773f89c5314ba7e9a0771722869cf69d79d8c3 100644 (file)
@@ -23,7 +23,7 @@ local ipairs, pairs, select = ipairs, pairs, select;
 local tonumber, tostring = tonumber, tostring;
 local require = require;
 local pack = table.pack or function(...) return {n=select("#",...), ...}; end -- table.pack is only in 5.2
-local unpack = table.unpack or unpack; -- renamed in 5.2
+local unpack = table.unpack or unpack; --luacheck: ignore 113 -- renamed in 5.2
 
 local prosody = prosody;
 local hosts = prosody.hosts;
@@ -303,6 +303,20 @@ function api:get_option_inherited_set(name, ...)
        return value;
 end
 
+function api:get_option_path(name, default, parent)
+       if parent == nil then
+               parent = parent or self:get_directory();
+       elseif prosody.paths[parent] then
+               parent = prosody.paths[parent];
+       end
+       local value = self:get_option_string(name, default);
+       if value == nil then
+               return nil;
+       end
+       return resolve_relative_path(parent, value);
+end
+
+
 function api:context(host)
        return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
 end
@@ -361,8 +375,8 @@ function api:provides(name, item)
        self:add_item(name.."-provider", item);
 end
 
-function api:send(stanza)
-       return core_post_stanza(hosts[self.host], stanza);
+function api:send(stanza, origin)
+       return core_post_stanza(origin or hosts[self.host], stanza);
 end
 
 function api:broadcast(jids, stanza, iter)
@@ -385,7 +399,7 @@ function timer_methods:reschedule(delay)
        timer.reschedule(self.id, delay)
 end
 
-local function timer_callback(now, id, t)
+local function timer_callback(now, id, t) --luacheck: ignore 212/id
        if t.module_env.loaded == false then return; end
        return t.callback(now, unpack(t, 1, t.n));
 end