diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-29 02:10:55 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-29 02:10:55 +0100 |
commit | bd5f9b8cbfd168a21141607218446222ab9d8642 (patch) | |
tree | e78baabff21e9b6fefaeef4a709098ca30b35922 /plugins/adhoc | |
parent | 9b89441dd008a8b3fda12d9217ff6f9ba240df9a (diff) | |
parent | a2055895d362fed58ff314820bb7fddd53e40436 (diff) | |
download | prosody-bd5f9b8cbfd168a21141607218446222ab9d8642.tar.gz prosody-bd5f9b8cbfd168a21141607218446222ab9d8642.zip |
Merge 0.9->trunk
Diffstat (limited to 'plugins/adhoc')
-rw-r--r-- | plugins/adhoc/adhoc.lib.lua | 11 | ||||
-rw-r--r-- | plugins/adhoc/mod_adhoc.lua | 16 |
2 files changed, 14 insertions, 13 deletions
diff --git a/plugins/adhoc/adhoc.lib.lua b/plugins/adhoc/adhoc.lib.lua index 0cb4efe1..57059b3f 100644 --- a/plugins/adhoc/adhoc.lib.lua +++ b/plugins/adhoc/adhoc.lib.lua @@ -25,6 +25,7 @@ function _M.new(name, node, handler, permission) end function _M.handle_cmd(command, origin, stanza) + local cmdtag, actions; local sessionid = stanza.tags[1].attr.sessionid or uuid.generate(); local dataIn = {}; dataIn.to = stanza.attr.to; @@ -58,7 +59,7 @@ function _M.handle_cmd(command, origin, stanza) elseif name == "error" then cmdtag:tag("note", {type="error"}):text(content.message):up(); elseif name =="actions" then - local actions = st.stanza("actions"); + actions = st.stanza("actions"); for _, action in ipairs(content) do if (action == "prev") or (action == "next") or (action == "complete") then actions:tag(action):up(); @@ -67,7 +68,6 @@ function _M.handle_cmd(command, origin, stanza) '" at node "'..command.node..'" provided an invalid action "'..action..'"'); end end - cmdtag:add_child(actions); elseif name == "form" then cmdtag:add_child((content.layout or content):form(content.values)); elseif name == "result" then @@ -76,6 +76,13 @@ function _M.handle_cmd(command, origin, stanza) cmdtag:add_child(content); end end + + if not actions then + actions = st.stanza("actions"); + actions:tag("complete"):up(); + end + cmdtag:add_child(actions); + stanza:add_child(cmdtag); origin.send(stanza); diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua index 6d826338..49d07103 100644 --- a/plugins/adhoc/mod_adhoc.lua +++ b/plugins/adhoc/mod_adhoc.lua @@ -90,19 +90,13 @@ module:hook("iq/host/"..xmlns_cmd..":command", function (event) end end, 500); -local function handle_item_added(item) +local function adhoc_added(event) + local item = event.item; commands[item.node] = item; end -module:hook("item-added/adhoc", function (event) - return handle_item_added(event.item); -end, 500); - -module:hook("item-removed/adhoc", function (event) +local function adhoc_removed(event) commands[event.item.node] = nil; -end, 500); - --- Pick up any items that are already added -for _, item in ipairs(module:get_host_items("adhoc")) do - handle_item_added(item); end + +module:handle_items("adhoc", adhoc_added, adhoc_removed); |