From d936a830e4866f070ba7726ecb845cc66644a238 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 12 Apr 2014 10:02:48 +0200 Subject: add sha1 sum to file --- src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java | 4 +++- src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/eu/siacs/conversations/xmpp') diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index a5453443..31b643c0 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -34,6 +34,7 @@ public class JingleConnection { private String responder; private List candidates = new ArrayList(); private HashMap connections = new HashMap(); + private File file = null; private OnIqPacketReceived responseListener = new OnIqPacketReceived() { @@ -110,7 +111,8 @@ public class JingleConnection { if (message.getType() == Message.TYPE_IMAGE) { content.setAttribute("creator", "initiator"); content.setAttribute("name", "a-file-offer"); - content.offerFile(this.mXmppConnectionService.getFileBackend().getImageFile(message)); + this.file = this.mXmppConnectionService.getFileBackend().getImageFile(message); + content.offerFile(file,message.getBody()); content.setCandidates(this.mJingleConnectionManager.nextRandomId(),this.candidates); packet.setContent(content); Log.d("xmppService",packet.toString()); diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java index 27d6b9e3..304656ee 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java +++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java @@ -15,12 +15,13 @@ public class Content extends Element { super("content"); } - public void offerFile(File actualFile) { + public void offerFile(File actualFile, String hash) { Element description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3"); Element offer = description.addChild("offer"); Element file = offer.addChild("file"); file.addChild("size").setContent(""+actualFile.length()); file.addChild("name").setContent(actualFile.getName()); + file.addChild("hash","urn:xmpp:hashes:1").setAttribute("algo", "sha-1").setContent(hash); } public void setCandidates(String transportId, List canditates) { -- cgit v1.2.3