Changeset

379:d80d27234e38

plugins.jingle_ft: Update to version 0.16
author Kim Alvefur <zash@zash.se>
date Fri, 01 May 2015 21:46:24 +0200 (2015-05-01)
parents 368:154c2f04d73b
children 380:0891b4e27766
files plugins/jingle_ft.lua
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/jingle_ft.lua	Sun Nov 16 19:33:18 2014 +0100
+++ b/plugins/jingle_ft.lua	Fri May 01 21:46:24 2015 +0200
@@ -3,8 +3,7 @@
 
 local dirsep = package.config:sub(1,1);
 
-local xmlns_jingle_ft = "urn:xmpp:jingle:apps:file-transfer:1";
-local xmlns_si_file_transfer = "http://jabber.org/protocol/si/profile/file-transfer";
+local xmlns_jingle_ft = "urn:xmpp:jingle:apps:file-transfer:4";
 
 function verse.plugins.jingle_ft(stream)
 	stream:hook("ready", function ()
@@ -26,10 +25,12 @@
 	
 	local ft_mt = { __index = ft_content };
 	stream:hook("jingle/content/"..xmlns_jingle_ft, function (jingle, description_tag)
-		local file_tag = description_tag:get_child("offer"):get_child("file", xmlns_si_file_transfer);
+		local file_tag = description_tag:get_child("file");
 		local file = {
-			name = file_tag.attr.name;
-			size = tonumber(file_tag.attr.size);
+			name = file_tag:get_child_text("name");
+			size = tonumber(file_tag:get_child_text("size"));
+			desc = file_tag:get_child_text("desc");
+			date = file_tag:get_child_text("date");
 		};
 		
 		return setmetatable({ jingle = jingle, file = file }, ft_mt);
@@ -42,14 +43,12 @@
 			date = os.date("!%Y-%m-%dT%H:%M:%SZ", file_info.timestamp);
 		end
 		return verse.stanza("description", { xmlns = xmlns_jingle_ft })
-			:tag("offer")
-				:tag("file", { xmlns = xmlns_si_file_transfer,
-					name = file_info.filename, -- Mandatory
-					size = file_info.size, -- Mandatory
-					date = date,
-					hash = file_info.hash,
-				})
-					:tag("desc"):text(file_info.description or "");
+			:tag("file")
+				:tag("name"):text(file_info.filename):up()
+				:tag("size"):text(tostring(file_info.size)):up()
+				:tag("date"):text(date):up()
+				:tag("desc"):text(file_info.description):up()
+			:up();
 	end);
 
 	function stream:send_file(to, filename)