comparison plugins/adhoc/mod_adhoc.lua @ 4797:e239668aa6d2

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Apr 2012 02:10:55 +0100
parents 15547fba1f09
children 58714123f600
comparison
equal deleted inserted replaced
4796:04a34287dc12 4797:e239668aa6d2
88 return adhoc_handle_cmd(commands[node], origin, stanza); 88 return adhoc_handle_cmd(commands[node], origin, stanza);
89 end 89 end
90 end 90 end
91 end, 500); 91 end, 500);
92 92
93 local function handle_item_added(item) 93 local function adhoc_added(event)
94 local item = event.item;
94 commands[item.node] = item; 95 commands[item.node] = item;
95 end 96 end
96 97
97 module:hook("item-added/adhoc", function (event) 98 local function adhoc_removed(event)
98 return handle_item_added(event.item); 99 commands[event.item.node] = nil;
99 end, 500); 100 end
100 101
101 module:hook("item-removed/adhoc", function (event) 102 module:handle_items("adhoc", adhoc_added, adhoc_removed);
102 commands[event.item.node] = nil;
103 end, 500);
104
105 -- Pick up any items that are already added
106 for _, item in ipairs(module:get_host_items("adhoc")) do
107 handle_item_added(item);
108 end