aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/muc.lua16
-rw-r--r--util/pluginloader.lua33
2 files changed, 39 insertions, 10 deletions
diff --git a/util/muc.lua b/util/muc.lua
index 305157d8..2bb1311a 100644
--- a/util/muc.lua
+++ b/util/muc.lua
@@ -195,7 +195,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc
log("debug", "%s leaving %s", current_nick, room);
local data = self._participants[current_nick];
data.role = 'none';
- room_broadcast_presence(room, pr);
+ room_broadcast_presence(self, pr);
self._participants[current_nick] = nil;
self._jid_nick[from] = nil;
end
@@ -262,7 +262,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc
elseif type ~= 'result' then -- bad type
origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error?
end
- elseif not current_nick and type ~= "error" then -- not in room
+ elseif not current_nick and type ~= "error" and type ~= "result" then -- not in room
origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM
origin.send(st.error_reply(stanza, "modify", "bad-request"));
@@ -274,7 +274,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc
if o_data then
log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid);
local jid = o_data.jid;
- if stanza.name=='iq' and type=='get' and stanza.tags[1].attr.xmlns == 'vcard-temp' then jid = jid_bare(jid); end
+ -- TODO if stanza.name=='iq' and type=='get' and stanza.tags[1].attr.xmlns == 'vcard-temp' then jid = jid_bare(jid); end
stanza.attr.to, stanza.attr.from = jid, current_nick;
self:route_stanza(stanza);
elseif type ~= "error" and type ~= "result" then -- recipient not in room
@@ -338,14 +338,10 @@ end
local function room_handle_stanza(self, origin, stanza)
local to_node, to_host, to_resource = jid_split(stanza.attr.to);
- if to_resource and not to_node then
- if type == "error" or type == "result" then return; end
- origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- host/resource
- elseif to_resource then
+ if to_resource then
room_handle_to_occupant(self, origin, stanza);
- elseif to_node then
- room_handle_to_room(self, origin, stanza)
- else -- to the main muc domain
+ else
+ room_handle_to_room(self, origin, stanza);
end
end
diff --git a/util/pluginloader.lua b/util/pluginloader.lua
new file mode 100644
index 00000000..1bf22f62
--- /dev/null
+++ b/util/pluginloader.lua
@@ -0,0 +1,33 @@
+
+local plugin_dir = CFG_PLUGINDIR or "./plugins/";
+
+local io_open = io.open;
+local loadstring = loadstring;
+
+module "pluginloader"
+
+local function load_file(name)
+ local file, err = io_open(plugin_dir..name);
+ if not file then return file, err; end
+ local content = file:read("*a");
+ file:close();
+ return content, name;
+end
+
+function load_resource(plugin, resource)
+ if not resource then
+ resource = "mod_"..plugin..".lua";
+ end
+ local content, err = load_file(plugin.."/"..resource);
+ if not content then content, err = load_file(resource); end
+ -- TODO add support for packed plugins
+ return content, err;
+end
+
+function load_code(plugin, resource)
+ local content, err = load_resource(plugin, resource);
+ if not content then return content, err; end
+ return loadstring(content, err), err;
+end
+
+return _M;