diff options
| author | Remko Tronçon <git@el-tramo.be> | 2013-09-20 20:32:57 (GMT) | 
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2013-09-21 06:41:34 (GMT) | 
| commit | 33f9dc5337f1a59932b7ac117b0dea56e1dafe1a (patch) | |
| tree | 8aeae2309c1a1770313bca0797cb92f8bcee4721 /Sluift/boot.lua | |
| parent | 577c0c8fd30ffc0df718a8958eb7b8784ec3b0ac (diff) | |
| download | swift-33f9dc5337f1a59932b7ac117b0dea56e1dafe1a.zip swift-33f9dc5337f1a59932b7ac117b0dea56e1dafe1a.tar.bz2 | |
Sluift: Add support for ad-hoc commands
Change-Id: I4ac2d0b07841b03086d9dbd9fa06d1f030f4e1ca
Diffstat (limited to 'Sluift/boot.lua')
| -rw-r--r-- | Sluift/boot.lua | 27 | 
1 files changed, 20 insertions, 7 deletions
| diff --git a/Sluift/boot.lua b/Sluift/boot.lua index e81257a..2505736 100644 --- a/Sluift/boot.lua +++ b/Sluift/boot.lua @@ -173,13 +173,25 @@ for method, event_type in pairs({messages = 'message', pubsub_events = 'pubsub'}  	end  end --- Register get_* convenience methods for some type of queries -for _, query_type in ipairs({'software_version', 'disco_items', 'xml', 'dom', 'vcard'}) do -	Client['get_' .. query_type] = 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'] or {}) -		return client:get(options) +-- +-- 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'}, +	set = {'command'} +} +for query_action, query_types in pairs(get_set_shortcuts) do +	for _, query_type in ipairs(query_types) do +		Client[query_action .. '_' .. query_type] = 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  	end  end @@ -403,6 +415,7 @@ end  local disco = {  	features = {  		DISCO_INFO = 'http://jabber.org/protocol/disco#info', +		COMMANDS = 'http://jabber.org/protocol/commands',  		USER_LOCATION = 'http://jabber.org/protocol/geoloc',  		USER_TUNE = 'http://jabber.org/protocol/tune',  		USER_AVATAR_METADATA = 'urn:xmpp:avatar:metadata', | 
 Swift
 Swift