summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sluift/core.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/Sluift/core.lua b/Sluift/core.lua
index aef2506..89c96ba 100644
--- a/Sluift/core.lua
+++ b/Sluift/core.lua
@@ -1,32 +1,32 @@
--[[
- Copyright (c) 2013-2014 Isode Limited.
+ Copyright (c) 2013-2017 Isode Limited.
All rights reserved.
See the COPYING file for more information.
--]]
local sluift = select(1, ...)
local _G = _G
local pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, unpack, io = pairs, ipairs, print, tostring, type, error, assert, next, rawset, xpcall, unpack, io
local setmetatable, getmetatable = setmetatable, getmetatable
local string = require "string"
local table = require "table"
local debug = require "debug"
_ENV = nil
--------------------------------------------------------------------------------
-- Table utility methods
--------------------------------------------------------------------------------
local function table_value_tostring(value)
local result = tostring(value)
if type(value) == 'number' then return result
elseif type(value) == 'boolean' then return result
elseif type(value) == 'string' then return "'" .. result .. "'"
else return '<' .. result .. '>'
end
end
local function table_tostring(table, print_functions, indent, accumulator, history)
local INDENT = ' '
local accumulator = accumulator or ''
local history = history or {}
@@ -730,61 +730,61 @@ for method, event_type in pairs({messages = 'message', pubsub_events = 'pubsub'}
options = remove_help_parameters("type", get_help(Client.for_each_event).options)
}
Client[method] = function (client, ...)
local options = parse_options({}, ...)
options['type'] = event_type
return client:events (options)
end
register_help(Client[method])
end
_H = {
[[
Process all pending events
]],
parameters = { "self" }
}
function Client:process_events ()
for event in self:events{timeout=0} do end
end
register_help(Client.process_events)
--
-- Register get_* and set_* convenience methods for some type of queries
--
-- Example usages:
-- client:get_software_version{to = 'alice@wonderland.lit'}
-- client:set_command{to = 'alice@wonderland.lit', command = { type = 'execute', node = 'uptime' }}
--
local get_set_shortcuts = {
- get = {'software_version', 'disco_items', 'xml', 'dom', 'vcard', 'mam'},
+ get = {'software_version', 'disco_items', 'disco_info', 'xml', 'dom', 'vcard', 'mam'},
set = {'command', 'vcard', 'mam'}
}
for query_action, query_types in pairs(get_set_shortcuts) do
for _, query_type in ipairs(query_types) do
_H = {
"Sends a `" .. query_action .. "` query of type `" .. query_type .. "`.\n" ..
"Apart from the options below, all top level elements of `" .. query_type .. "` can be passed.",
parameters = { "self" },
options = remove_help_parameters({"query", "type"}, extra_help["Client.get"].options),
}
local method = query_action .. '_' .. query_type
Client[method] = function (client, options)
options = options or {}
if type(options) ~= 'table' then error('Invalid options: ' .. options) end
options['query'] = merge_tables({_type = query_type}, options[query_type] or {})
return client[query_action](client, options)
end
register_help(Client[method])
end
end
_H = {
[[ Returns a @{PubSub} object for communicating with the PubSub service at `jid`. ]],
parameters = {
"self",
{"jid", "The JID of the PubSub service"}
}
}
function Client:pubsub (jid)
local result = { client = self, jid = jid }