aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/xmpp/jingle/stanzas
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/xmpp/jingle/stanzas')
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java64
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java28
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java2
3 files changed, 51 insertions, 43 deletions
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
index 494ff0d6..1e8e3fd6 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
@@ -4,17 +4,17 @@ 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);
}
-
+
public Content() {
super("content");
}
-
+
public Content(String creator, String name) {
super("content");
this.setAttribute("creator", creator);
@@ -24,39 +24,43 @@ public class Content extends Element {
public void setTransportId(String sid) {
this.transportId = sid;
}
-
+
public void setFileOffer(JingleFile actualFile, boolean otr) {
- Element description = this.addChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
+ 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.getSize());
+ file.addChild("size").setContent("" + actualFile.getSize());
if (otr) {
- file.addChild("name").setContent(actualFile.getName()+".otr");
+ file.addChild("name").setContent(actualFile.getName() + ".otr");
} else {
file.addChild("name").setContent(actualFile.getName());
}
}
-
+
public Element getFileOffer() {
- Element description = this.findChild("description", "urn:xmpp:jingle:apps:file-transfer:3");
- if (description==null) {
+ Element description = this.findChild("description",
+ "urn:xmpp:jingle:apps:file-transfer:3");
+ if (description == null) {
return null;
}
Element offer = description.findChild("offer");
- if (offer==null) {
+ if (offer == null) {
return null;
}
return offer.findChild("file");
}
-
+
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");
+ 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() {
if (hasSocks5Transport()) {
this.transportId = socks5transport().getAttribute("sid");
@@ -65,30 +69,34 @@ public class Content extends Element {
}
return this.transportId;
}
-
+
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");
+ 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);
}
return transport;
}
-
+
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:ibb:1");
+ Element transport = this.findChild("transport",
+ "urn:xmpp:jingle:transports:ibb:1");
+ if (transport == null) {
+ transport = this.addChild("transport",
+ "urn:xmpp:jingle:transports:ibb:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
-
+
public boolean hasSocks5Transport() {
return this.hasChild("transport", "urn:xmpp:jingle:transports:s5b:1");
}
-
+
public boolean hasIbbTransport() {
- return this.hasChild("transport","urn:xmpp:jingle:transports:ibb:1");
+ 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 55700609..77a73643 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java
@@ -7,18 +7,18 @@ public class JinglePacket extends IqPacket {
Content content = null;
Reason reason = null;
Element jingle = new Element("jingle");
-
+
@Override
public Element addChild(Element child) {
if ("jingle".equals(child.getName())) {
Element contentElement = child.findChild("content");
- if (contentElement!=null) {
+ if (contentElement != null) {
this.content = new Content();
this.content.setChildren(contentElement.getChildren());
this.content.setAttributes(contentElement.getAttributes());
}
Element reasonElement = child.findChild("reason");
- if (reasonElement!=null) {
+ if (reasonElement != null) {
this.reason = new Reason();
this.reason.setChildren(reasonElement.getChildren());
this.reason.setAttributes(reasonElement.getAttributes());
@@ -27,33 +27,33 @@ public class JinglePacket extends IqPacket {
}
return child;
}
-
+
public JinglePacket setContent(Content content) {
this.content = content;
return this;
}
-
+
public Content getJingleContent() {
- if (this.content==null) {
+ if (this.content == null) {
this.content = new Content();
}
return this.content;
}
-
+
public JinglePacket setReason(Reason reason) {
this.reason = reason;
return this;
}
-
+
public Reason getReason() {
return this.reason;
}
-
+
private void build() {
this.children.clear();
this.jingle.clearChildren();
this.jingle.setAttribute("xmlns", "urn:xmpp:jingle:1");
- if (this.content!=null) {
+ if (this.content != null) {
jingle.addChild(this.content);
}
if (this.reason != null) {
@@ -66,11 +66,11 @@ public class JinglePacket extends IqPacket {
public String getSessionId() {
return this.jingle.getAttribute("sid");
}
-
+
public void setSessionId(String sid) {
this.jingle.setAttribute("sid", sid);
}
-
+
@Override
public String toString() {
this.build();
@@ -80,11 +80,11 @@ public class JinglePacket extends IqPacket {
public void setAction(String action) {
this.jingle.setAttribute("action", action);
}
-
+
public String getAction() {
return this.jingle.getAttribute("action");
}
-
+
public void setInitiator(String initiator) {
this.jingle.setAttribute("initiator", initiator);
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
index 195e0db7..610d5e76 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Reason.java
@@ -6,7 +6,7 @@ public class Reason extends Element {
private Reason(String name) {
super(name);
}
-
+
public Reason() {
super("reason");
}