summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2017-10-26 11:38:37 (GMT)
committerRoger Planas <roger.planas@isode.com>2017-10-26 11:39:23 (GMT)
commited25c7d2fe46dca4edecd359755b15e16620056e (patch)
tree8c6116500b1c8c49e4f0d90b7e569e1b72a9b6c1 /Sluift/core.lua
parent867ee9a1590f340ef57cebc15ab5ddb8a08f2a53 (diff)
downloadswift-ed25c7d2fe46dca4edecd359755b15e16620056e.zip
swift-ed25c7d2fe46dca4edecd359755b15e16620056e.tar.bz2
Sluift: Add shortcut for get disco_info to components
disco_info shortcut was available to clients but not to components. This patch addresses this. Test-information: Used component:get_disco_info and data is retrieved successfully. Change-Id: Ie8d80e3180ca400e5694fd581f60f08511e36ca4
Diffstat (limited to 'Sluift/core.lua')
-rw-r--r--Sluift/core.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/Sluift/core.lua b/Sluift/core.lua
index 89c96ba..daa8636 100644
--- a/Sluift/core.lua
+++ b/Sluift/core.lua
@@ -934,61 +934,61 @@ for method, event_type in pairs({messages = 'message'}) do
options = remove_help_parameters("type", get_help(Component.for_each_event).options)
}
Component[method] = function (component, ...)
local options = parse_options({}, ...)
options['type'] = event_type
return component:events (options)
end
register_help(Component[method])
end
_H = {
[[
Process all pending events
]],
parameters = { "self" }
}
function Component:process_events ()
for event in self:events{timeout=0} do end
end
register_help(Component.process_events)
--
-- Register get_* and set_* convenience methods for some type of queries
--
-- Example usages:
-- component:get_software_version{to = 'alice@wonderland.lit'}
-- component:set_command{to = 'alice@wonderland.lit', command = { type = 'execute', node = 'uptime' }}
--
local get_set_shortcuts = {
- get = {'software_version', 'disco_items', 'xml', 'dom', 'vcard'},
+ get = {'software_version', 'disco_items', 'disco_info', 'xml', 'dom', 'vcard'},
set = {'command', 'vcard'}
}
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"}, component_extra_help["Component.get"].options),
}
local method = query_action .. '_' .. query_type
Component[method] = function (component, 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 component[query_action](component, options)
end
register_help(Component[method])
end
end
--------------------------------------------------------------------------------
-- PubSub
--------------------------------------------------------------------------------
local function process_pubsub_event (event)
if event._type == 'pubsub_event_items' then
-- Add 'item' shortcut to payload of first item
event.item = event.items and event.items[1] and
event.items[1].data and event.items[1].data[1]