aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp/jingle/stanzas
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-04-20 22:34:27 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-04-20 22:34:27 +0200
commit4d730fd1edb6cab210c035b5f0f692a37dada5e9 (patch)
tree65331d142e327cd02bb2f44ea8ec7643ccf353a4 /src/eu/siacs/conversations/xmpp/jingle/stanzas
parent04418484a2eadca43772d2d63db300068fc7feca (diff)
added proxy activate and a lot of code clean up. totatly untested
Diffstat (limited to 'src/eu/siacs/conversations/xmpp/jingle/stanzas')
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java109
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java18
2 files changed, 40 insertions, 87 deletions
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
index 3cd30251..dbd2a9fc 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
@@ -1,12 +1,12 @@
package eu.siacs.conversations.xmpp.jingle.stanzas;
-import java.util.ArrayList;
-import java.util.List;
-
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.jingle.JingleFile;
public class Content extends Element {
+
+ private String transportId;
+
private Content(String name) {
super(name);
}
@@ -15,6 +15,10 @@ public class Content extends Element {
super("content");
}
+ public void setTransportId(String sid) {
+ this.transportId = sid;
+ }
+
public void setFileOffer(JingleFile actualFile) {
Element description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
Element offer = description.addChild("offer");
@@ -34,91 +38,58 @@ public class Content extends Element {
}
return offer.findChild("file");
}
-
- public void setCandidates(String transportId, 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.setAttribute("sid", transportId);
- transport.clearChildren();
- for(Element canditate : canditates) {
- transport.addChild(canditate);
- }
- }
- public List<Element> getCanditates() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
- if (transport==null) {
- return new ArrayList<Element>();
- } else {
- return transport.getChildren();
+ public void setFileOffer(Element fileOffer) {
+ Element description = this.findChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
+ if (description==null) {
+ description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
}
+ description.addChild(fileOffer);
}
public String getTransportId() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
- if (transport==null) {
- return null;
+ if (hasSocks5Transport()) {
+ this.transportId = socks5transport().getAttribute("sid");
+ } else if (hasIbbTransport()) {
+ this.transportId = ibbTransport().getAttribute("sid");
}
- return transport.getAttribute("sid");
+ return this.transportId;
}
- public String getUsedCandidate() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
- if (transport==null) {
- return null;
- }
- Element usedCandidate = transport.findChild("candidate-used");
- if (usedCandidate==null) {
- return null;
- } else {
- return usedCandidate.getAttribute("cid");
- }
+ public void setUsedCandidate(String cid) {
+ socks5transport().clearChildren();
+ Element usedCandidate = socks5transport().addChild("candidate-used");
+ usedCandidate.setAttribute("cid",cid);
}
-
- public boolean hasCandidateError() {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
- if (transport==null) {
- return false;
- }
- return transport.hasChild("candidate-error");
+
+ public void setCandidateError() {
+ socks5transport().clearChildren();
+ socks5transport().addChild("candidate-error");
}
- public void setUsedCandidate(String transportId, String cid) {
+ public Element socks5transport() {
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.setAttribute("sid", this.transportId);
}
- transport.setAttribute("sid", transportId);
- transport.clearChildren();
- Element usedCandidate = transport.addChild("candidate-used");
- usedCandidate.setAttribute("cid",cid);
+ return transport;
}
-
- public void addCandidate(Element candidate) {
- Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:s5b:1");
+
+ public Element ibbTransport() {
+ Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:ibb:1");
if (transport==null) {
- transport = this.addChild("transport", "urn:xmpp:jingle:transports:s5b:1");
+ transport = this.addChild("transport", "urn:xmpp:jingle:transports:ibb:1");
+ transport.setAttribute("sid", this.transportId);
}
- transport.addChild(candidate);
+ return transport;
}
-
- public void setFileOffer(Element fileOffer) {
- Element description = this.findChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
- if (description==null) {
- description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
- }
- description.addChild(fileOffer);
+
+ public boolean hasSocks5Transport() {
+ return this.hasChild("transport", "urn:xmpp:jingle:transports:s5b:1");
}
-
- public void setCandidateError(String transportId) {
- 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.setAttribute("sid", transportId);
- transport.clearChildren();
- transport.addChild("candidate-error");
+
+ public boolean hasIbbTransport() {
+ return this.hasChild("transport","urn:xmpp:jingle:transports:ibb:1");
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
index fdb53b36..55700609 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
@@ -92,22 +92,4 @@ public class JinglePacket extends IqPacket {
public boolean isAction(String action) {
return action.equalsIgnoreCase(this.getAction());
}
-
- public String toPrettyString() {
- StringBuilder output = new StringBuilder();
- output.append("["+getAction()+ " to:"+getTo());
- if (this.content!=null) {
- if (this.content.getUsedCandidate()!=null) {
- output.append(" [used-candidate="+this.content.getUsedCandidate()+"]");
- } else if (this.content.hasCandidateError()) {
- output.append(" [candidate-error]");
- } else {
- for(Element c : this.content.getCanditates()) {
- output.append(" ["+c.getAttribute("host")+":"+c.getAttribute("port")+"]");
- }
- }
- }
- output.append("]");
- return output.toString();
- }
}