From 2e17a1667d8de25e281cf2d4a11b50234673ca79 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 23 Nov 2009 02:58:42 +0000 Subject: util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for! --- util/dependencies.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/dependencies.lua b/util/dependencies.lua index a0535e5c..cb022644 100644 --- a/util/dependencies.lua +++ b/util/dependencies.lua @@ -17,8 +17,12 @@ local function missingdep(name, sources, msg) print("Prosody was unable to find "..tostring(name)); print("This package can be obtained in the following ways:"); print(""); - for k,v in pairs(sources) do - print("", k, v); + local longest_platform = 0; + for platform in pairs(sources) do + longest_platform = math.max(longest_platform, #platform); + end + for platform, source in pairs(sources) do + print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source); end print(""); print(msg or (name.." is required for Prosody to run, so we will now exit.")); -- cgit v1.2.3 From d6a193d93e2670cb2ed48db22051b6fc9922c787 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Nov 2009 17:33:55 +0000 Subject: util.jid: Add join(node, host, resource) function to join the components and return nil if invalid --- util/jid.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'util') diff --git a/util/jid.lua b/util/jid.lua index ccc8309c..b43247cc 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -65,4 +65,17 @@ function prep(jid) return host; end +function join(node, host, resource) + if node and host and resource then + return node.."@"..host.."/"..resource; + elseif node and host then + return node.."@"..host; + elseif host and resource then + return host.."/"..resource; + elseif host then + return host; + end + return nil; -- Invalid JID +end + return _M; -- cgit v1.2.3 From fe45368b05889419c4f082edd0eddb5a5713cb34 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 30 Nov 2009 16:39:27 +0000 Subject: util.stanza: Add stanza:get_child(name, xmlns) to find a child tag given a name/xmlns --- util/stanza.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util') diff --git a/util/stanza.lua b/util/stanza.lua index d295d5cc..8d3b7747 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -93,6 +93,17 @@ function stanza_mt:add_child(child) return self; end +function stanza_mt:get_child(name, xmlns) + for _, child in ipairs(self.tags) do + if (not name or child.name == name) + and ((not xmlns and self.attr.xmlns == child.attr.xmlns) + or child.attr.xmlns == xmlns) then + + return child; + end + end +end + function stanza_mt:child_with_name(name) for _, child in ipairs(self.tags) do if child.name == name then return child; end -- cgit v1.2.3 From f80585f35478b8c9852a59cf2d8f28c0e12586a1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 22 Jan 2010 14:58:31 +0000 Subject: util.dataforms: Add optional type parameters (defaults to 'form') --- util/dataforms.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/dataforms.lua b/util/dataforms.lua index a3bde8ca..56671347 100644 --- a/util/dataforms.lua +++ b/util/dataforms.lua @@ -23,8 +23,8 @@ function new(layout) return setmetatable(layout, form_mt); end -function form_t.form(layout, data) - local form = st.stanza("x", { xmlns = xmlns_forms, type = "form" }); +function form_t.form(layout, data, formtype) + local form = st.stanza("x", { xmlns = xmlns_forms, type = formtype or "form" }); if layout.title then form:tag("title"):text(layout.title):up(); end -- cgit v1.2.3 From 9ed7624f754479dfb78d90a5367678567424a03b Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 31 Jan 2010 19:27:52 +0000 Subject: util.stanza: stanza.error_reply(): Fix to put the correct namespace on --- util/stanza.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'util') diff --git a/util/stanza.lua b/util/stanza.lua index 8d3b7747..069daa53 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -291,13 +291,16 @@ function reply(orig) return stanza(orig.name, orig.attr and { to = orig.attr.from, from = orig.attr.to, id = orig.attr.id, type = ((orig.name == "iq" and "result") or orig.attr.type) }); end -function error_reply(orig, type, condition, message) - local t = reply(orig); - t.attr.type = "error"; - t:tag("error", {type = type}) - :tag(condition, {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up(); - if (message) then t:tag("text"):text(message):up(); end - return t; -- stanza ready for adding app-specific errors +do + local xmpp_stanzas_attr = { xmlns = xmlns_stanzas }; + function error_reply(orig, type, condition, message) + local t = reply(orig); + t.attr.type = "error"; + t:tag("error", {type = type}) --COMPAT: Some day xmlns:stanzas goes here + :tag(condition, xmpp_stanzas_attr):up(); + if (message) then t:tag("text", xmpp_stanzas_attr):text(message):up(); end + return t; -- stanza ready for adding app-specific errors + end end function presence(attr) -- cgit v1.2.3 From 2f06e65cd617859e230cb978af8b9a57c4bab8e6 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Tue, 1 Dec 2009 22:32:37 +0500 Subject: util.sasl.plain: Allow empty authzid (thanks bjc). --- util/sasl.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/sasl.lua b/util/sasl.lua index 402f05b4..5bc6db75 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -38,7 +38,7 @@ local function new_plain(realm, credentials_handler) function object.feed(self, message) if message == "" or message == nil then return "failure", "malformed-request" end local response = message - local authorization = s_match(response, "([^%z]+)") + local authorization = s_match(response, "([^%z]*)") local authentication = s_match(response, "%z([^%z]+)%z") local password = s_match(response, "%z[^%z]+%z([^%z]+)") -- cgit v1.2.3