diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/xmpp/jingle/stanzas')
-rw-r--r-- | src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/JinglePacket.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/JinglePacket.java b/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/JinglePacket.java index de856772a..3f7cc8e5b 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/JinglePacket.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/stanzas/JinglePacket.java @@ -1,5 +1,7 @@ package de.pixart.messenger.xmpp.jingle.stanzas; +import android.util.Base64; + import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.jid.Jid; import de.pixart.messenger.xmpp.stanzas.IqPacket; @@ -7,6 +9,7 @@ import de.pixart.messenger.xmpp.stanzas.IqPacket; public class JinglePacket extends IqPacket { Content content = null; Reason reason = null; + Element checksum = null; Element jingle = new Element("jingle"); @Override @@ -24,6 +27,7 @@ public class JinglePacket extends IqPacket { this.reason.setChildren(reasonElement.getChildren()); this.reason.setAttributes(reasonElement.getAttributes()); } + this.checksum = child.findChild("checksum"); this.jingle.setAttributes(child.getAttributes()); } return child; @@ -50,6 +54,10 @@ public class JinglePacket extends IqPacket { return this.reason; } + public Element getChecksum() { + return this.checksum; + } + private void build() { this.children.clear(); this.jingle.clearChildren(); @@ -60,6 +68,9 @@ public class JinglePacket extends IqPacket { if (this.reason != null) { jingle.addChild(this.reason); } + if (this.checksum != null) { + jingle.addChild(checksum); + } this.children.add(jingle); this.setAttribute("type", "set"); } @@ -93,4 +104,12 @@ public class JinglePacket extends IqPacket { public boolean isAction(String action) { return action.equalsIgnoreCase(this.getAction()); } + + public void addChecksum(byte[] sha1Sum, String namespace) { + this.checksum = new Element("checksum", namespace); + checksum.setAttribute("creator", "initiator"); + checksum.setAttribute("name", "a-file-offer"); + Element hash = checksum.addChild("file").addChild("hash", "urn:xmpp:hashes:2"); + hash.setAttribute("algo", "sha-1").setContent(Base64.encodeToString(sha1Sum, Base64.NO_WRAP)); + } } |