diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-04-07 20:05:45 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-04-07 20:05:45 +0200 |
commit | 3f403fb8a976f6cc7d135cf1eb6dd6f0789c312a (patch) | |
tree | 69fb1e80e9380b337b775910798870b04c5e4037 /src/eu/siacs/conversations/xmpp/stanzas/jingle | |
parent | c30bf75a5d77fab21480e04ce18b46d6b2826295 (diff) |
jingle connection and manager. able to trigger dialog in gajim
Diffstat (limited to 'src/eu/siacs/conversations/xmpp/stanzas/jingle')
-rw-r--r-- | src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java | 22 | ||||
-rw-r--r-- | src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java | 32 |
2 files changed, 49 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java index ebd212b8..ed51a2a5 100644 --- a/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java +++ b/src/eu/siacs/conversations/xmpp/stanzas/jingle/Content.java @@ -1,5 +1,8 @@ package eu.siacs.conversations.xmpp.stanzas.jingle; +import java.io.File; +import java.util.List; + import eu.siacs.conversations.xml.Element; public class Content extends Element { @@ -10,4 +13,23 @@ public class Content extends Element { public Content() { super("content"); } + + public void offerFile(File actualFile) { + 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()); + } + + public void setCanditates(List<Element> canditates) { + Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1"); + if (transport==null) { + transport = this.addChild("transport", "urn:xmpp:jingle:transports:s5b:1"); + } + transport.clearChildren(); + for(Element canditate : canditates) { + transport.addChild(canditate); + } + } } diff --git a/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java index 51c60d1f..4c444a74 100644 --- a/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java +++ b/src/eu/siacs/conversations/xmpp/stanzas/jingle/JinglePacket.java @@ -6,6 +6,7 @@ import eu.siacs.conversations.xmpp.stanzas.IqPacket; public class JinglePacket extends IqPacket { Content content = null; Reason reason = null; + Element jingle = new Element("jingle"); @Override public Element addChild(Element child) { @@ -22,27 +23,25 @@ public class JinglePacket extends IqPacket { this.reason.setChildren(reasonElement.getChildren()); this.reason.setAttributes(reasonElement.getAttributes()); } - this.build(); - this.findChild("jingle").setAttributes(child.getAttributes()); + this.jingle.setAttributes(child.getAttributes()); } return child; } public JinglePacket setContent(Content content) { this.content = content; - this.build(); return this; } public JinglePacket setReason(Reason reason) { this.reason = reason; - this.build(); return this; } private void build() { this.children.clear(); - Element jingle = addChild("jingle", "urn:xmpp:jingle:1"); + this.jingle.clearChildren(); + this.jingle.setAttribute("xmlns", "urn:xmpp:jingle:1"); if (this.content!=null) { jingle.addChild(this.content); } @@ -50,5 +49,28 @@ public class JinglePacket extends IqPacket { jingle.addChild(this.reason); } this.children.add(jingle); + this.setAttribute("type", "set"); + } + + public String getSessionId() { + return this.jingle.getAttribute("sid"); + } + + public void setSessionId(String sid) { + this.jingle.setAttribute("sid", sid); + } + + @Override + public String toString() { + this.build(); + return super.toString(); + } + + public void setAction(String action) { + this.jingle.setAttribute("action", action); + } + + public void setInitiator(String initiator) { + this.jingle.setAttribute("initiator", initiator); } } |