Changeset

395:e86144a4eaa1

plugins: Cleanup [luacheck]
author Kim Alvefur <zash@zash.se>
date Thu, 03 Sep 2015 22:41:27 +0200
parents 394:c2e959b60c13
children 396:b0afde43b3e5
files plugins/proxy65.lua plugins/pubsub.lua plugins/roster.lua plugins/sasl.lua plugins/session.lua plugins/smacks.lua plugins/vcard.lua plugins/vcard_update.lua plugins/version.lua
diffstat 9 files changed, 24 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/proxy65.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/proxy65.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -1,4 +1,4 @@
-local events = require "util.events";
+local verse =	require "verse";
 local uuid = require "util.uuid";
 local sha1 = require "util.hashes".sha1;
 
@@ -109,9 +109,9 @@
 		else
 			-- Target connected to streamhost, connect ourselves
 			local streamhost_used = reply.tags[1]:get_child("streamhost-used");
-			if not streamhost_used then
+			-- if not streamhost_used then
 				--FIXME: Emit error
-			end
+			-- end
 			conn.streamhost_jid = streamhost_used.attr.jid;
 			local host, port;
 			for _, proxy in ipairs(proxies or self.proxies) do
@@ -120,24 +120,23 @@
 					break;
 				end
 			end
-			if not (host and port) then
+			-- if not (host and port) then
 				--FIXME: Emit error
-			end
+			-- end
 
 			conn:connect(host, port);
 
 			local function handle_proxy_connected()
 				conn:unhook("connected", handle_proxy_connected);
 				-- Both of us connected, tell proxy to activate connection
-				local request = verse.iq{to = conn.streamhost_jid, type="set"}
+				local activate_request = verse.iq{to = conn.streamhost_jid, type="set"}
 					:tag("query", { xmlns = xmlns_bytestreams, sid = conn.bytestream_sid })
 						:tag("activate"):text(target_jid);
-				self.stream:send_iq(request, function (reply)
-					if reply.attr.type == "result" then
+				self.stream:send_iq(activate_request, function (activated)
+					if activated.attr.type == "result" then
 						-- Connection activated, ready to use
 						conn:event("connected", conn);
-					else
-						--FIXME: Emit error
+					-- else --FIXME: Emit error
 					end
 				end);
 				return true;
--- a/plugins/pubsub.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/pubsub.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -1,12 +1,11 @@
 local verse = require "verse";
-local jid_bare = require "util.jid".bare;
 
 local t_insert = table.insert;
 
 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
-local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors";
+-- local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors";
 
 local pubsub = {};
 local pubsub_mt = { __index = pubsub };
@@ -213,7 +212,7 @@
 	if options ~= nil then
 		error("Subscription configuration is not implemented yet.");
 	end
-	self.stream:send_iq(pubsub_iq("set", self.service, nil, "subscribe", self.node, jid, id)
+	self.stream:send_iq(pubsub_iq("set", self.service, nil, "subscribe", self.node, jid)
 	, callback);
 end
 
--- a/plugins/roster.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/roster.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -39,7 +39,6 @@
 		local item_table = { };
 		local groups = {};
 		item_table.groups = groups;
-		local jid = xml_item.attr.jid;
 
 		for k, v in pairs(xml_item.attr) do
 			if k ~= "xmlns" then
@@ -75,8 +74,7 @@
 			if reply.attr.type == "result" then
 				callback(true);
 			else
-				local type, condition, text = reply:get_error();
-				callback(nil, { type, condition, text });
+				callback(nil, reply);
 			end
 		end);
 	end
@@ -94,8 +92,7 @@
 				if reply.attr.type == "result" then
 					callback(true);
 				else
-					local type, condition, text = reply:get_error();
-					callback(nil, { type, condition, text });
+					callback(nil, reply);
 				end
 			end);
 	end
@@ -126,8 +123,7 @@
 					end
 					callback(roster);
 				else
-					local type, condition, text = stanza:get_error();
-					callback(nil, { type, condition, text }); --FIXME
+					callback(nil, result);
 				end
 			end);
 	end
--- a/plugins/sasl.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/sasl.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -1,4 +1,4 @@
--- local verse = require"verse";
+local verse = require"verse";
 local base64, unbase64 = require "mime".b64, require"mime".unb64;
 local xmlns_sasl = "urn:ietf:params:xml:ns:xmpp-sasl";
 
--- a/plugins/session.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/session.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -14,7 +14,6 @@
 						if reply.attr.type == "result" then
 							stream:event("session-success");
 						elseif reply.attr.type == "error" then
-							local err = reply:child_with_name("error");
 							local type, condition, text = reply:get_error();
 							stream:event("session-failure", { error = condition, text = text, type = type });
 						end
--- a/plugins/smacks.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/smacks.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -22,7 +22,7 @@
 	end
 
 	-- Catch outgoing stanzas
-	function outgoing_stanza(stanza)
+	local function outgoing_stanza(stanza)
 		-- NOTE: This will not behave nice if stanzas are serialized before this point
 		if stanza.name and not stanza.attr.xmlns then
 			-- serialize stanzas in order to bypass this on resumption
--- a/plugins/vcard.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/vcard.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -7,8 +7,7 @@
 	function stream:get_vcard(jid, callback) --jid = nil for self
 		stream:send_iq(verse.iq({to = jid, type="get"})
 			:tag("vCard", {xmlns=xmlns_vcard}), callback and function(stanza)
-				local lCard, xCard;
-				vCard = stanza:get_child("vCard", xmlns_vcard);
+				local vCard = stanza:get_child("vCard", xmlns_vcard);
 				if stanza.attr.type == "result" and vCard then
 					vCard = vcard.from_xep54(vCard)
 					callback(vCard)
--- a/plugins/vcard_update.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/vcard_update.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -1,6 +1,7 @@
 local verse = require "verse";
 
-local xmlns_vcard, xmlns_vcard_update = "vcard-temp", "vcard-temp:x:update";
+-- local xmlns_vcard = "vcard-temp";
+local xmlns_vcard_update = "vcard-temp:x:update";
 
 local sha1 = require("util.hashes").sha1;
 
@@ -24,7 +25,7 @@
 
 	local x_vcard_update;
 
-	function update_vcard_photo(vCard)
+	local function update_vcard_photo(vCard)
 		local data;
 		for i=1,#vCard do
 			if vCard[i].name == "PHOTO" then
@@ -43,10 +44,10 @@
 		end
 	end
 
-	local _set_vcard = stream.set_vcard;
 
 	--[[ TODO Complete this, it's probably broken.
 	-- Maybe better to hook outgoing stanza?
+	local _set_vcard = stream.set_vcard;
 	function stream:set_vcard(vCard, callback)
 		_set_vcard(vCard, function(event, ...)
 			if event.attr.type == "result" then
@@ -63,7 +64,7 @@
 	--]]
 
 	local initial_vcard_fetch_started;
-	stream:hook("ready", function(event)
+	stream:hook("ready", function()
 		if initial_vcard_fetch_started then return; end
 		initial_vcard_fetch_started = true;
 		-- if stream:jid_supports(nil, xmlns_vcard) then TODO this, correctly
--- a/plugins/version.lua	Thu Sep 03 21:46:57 2015 +0200
+++ b/plugins/version.lua	Thu Sep 03 22:41:27 2015 +0200
@@ -28,8 +28,8 @@
 	end);
 
 	function stream:query_version(target_jid, callback)
-		callback = callback or function (version) return stream:event("version/response", version); end
-		stream:send_iq(verse.iq({ type = "get", to = target_jid })
+		callback = callback or function (version) return self:event("version/response", version); end
+		self:send_iq(verse.iq({ type = "get", to = target_jid })
 			:tag("query", { xmlns = xmlns_version }),
 			function (reply)
 				if reply.attr.type == "result" then