aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/xmpp/stanzas
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-19 23:07:54 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-19 23:07:54 +0100
commitd783cec97084a12873ca62b5fcd64620056ec01b (patch)
tree65e63d03dd4ab7a834c343ba593c8cd8917620cb /src/main/java/de/pixart/messenger/xmpp/stanzas
parent969ba45c56adaaa056f04464cd98aec115c9611b (diff)
reformat code
Diffstat (limited to 'src/main/java/de/pixart/messenger/xmpp/stanzas')
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java40
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractStanza.java82
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/IqPacket.java110
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/MessagePacket.java164
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/PresencePacket.java6
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/csi/ActivePacket.java8
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/csi/InactivePacket.java8
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/AckPacket.java10
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/EnablePacket.java10
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/RequestPacket.java8
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/ResumePacket.java12
11 files changed, 229 insertions, 229 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java
index 615c4dfbe..22d035e6e 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractAcknowledgeableStanza.java
@@ -4,28 +4,28 @@ import de.pixart.messenger.xml.Element;
abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
- protected AbstractAcknowledgeableStanza(String name) {
- super(name);
- }
+ protected AbstractAcknowledgeableStanza(String name) {
+ super(name);
+ }
- public String getId() {
- return this.getAttribute("id");
- }
+ public String getId() {
+ return this.getAttribute("id");
+ }
- public void setId(final String id) {
- setAttribute("id", id);
- }
+ public void setId(final String id) {
+ setAttribute("id", id);
+ }
- public Element getError() {
- Element error = findChild("error");
- if (error != null) {
- for(Element element : error.getChildren()) {
- if (!element.getName().equals("text")) {
- return element;
- }
- }
- }
- return null;
- }
+ public Element getError() {
+ Element error = findChild("error");
+ if (error != null) {
+ for (Element element : error.getChildren()) {
+ if (!element.getName().equals("text")) {
+ return element;
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractStanza.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractStanza.java
index a21d8b56d..8d1b24ef8 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractStanza.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/AbstractStanza.java
@@ -6,45 +6,45 @@ import de.pixart.messenger.xmpp.jid.Jid;
public class AbstractStanza extends Element {
- protected AbstractStanza(final String name) {
- super(name);
- }
-
- public Jid getTo() {
- return getAttributeAsJid("to");
- }
-
- public Jid getFrom() {
- return getAttributeAsJid("from");
- }
-
- public void setTo(final Jid to) {
- if (to != null) {
- setAttribute("to", to.toString());
- }
- }
-
- public void setFrom(final Jid from) {
- if (from != null) {
- setAttribute("from", from.toString());
- }
- }
-
- public boolean fromServer(final Account account) {
- return getFrom() == null
- || getFrom().equals(account.getServer())
- || getFrom().equals(account.getJid().toBareJid())
- || getFrom().equals(account.getJid());
- }
-
- public boolean toServer(final Account account) {
- return getTo() == null
- || getTo().equals(account.getServer())
- || getTo().equals(account.getJid().toBareJid())
- || getTo().equals(account.getJid());
- }
-
- public boolean fromAccount(final Account account) {
- return getFrom() != null && getFrom().toBareJid().equals(account.getJid().toBareJid());
- }
+ protected AbstractStanza(final String name) {
+ super(name);
+ }
+
+ public Jid getTo() {
+ return getAttributeAsJid("to");
+ }
+
+ public Jid getFrom() {
+ return getAttributeAsJid("from");
+ }
+
+ public void setTo(final Jid to) {
+ if (to != null) {
+ setAttribute("to", to.toString());
+ }
+ }
+
+ public void setFrom(final Jid from) {
+ if (from != null) {
+ setAttribute("from", from.toString());
+ }
+ }
+
+ public boolean fromServer(final Account account) {
+ return getFrom() == null
+ || getFrom().equals(account.getServer())
+ || getFrom().equals(account.getJid().toBareJid())
+ || getFrom().equals(account.getJid());
+ }
+
+ public boolean toServer(final Account account) {
+ return getTo() == null
+ || getTo().equals(account.getServer())
+ || getTo().equals(account.getJid().toBareJid())
+ || getTo().equals(account.getJid());
+ }
+
+ public boolean fromAccount(final Account account) {
+ return getFrom() != null && getFrom().toBareJid().equals(account.getJid().toBareJid());
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/IqPacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/IqPacket.java
index b0a22c314..2efc948f4 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/IqPacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/IqPacket.java
@@ -4,66 +4,66 @@ import de.pixart.messenger.xml.Element;
public class IqPacket extends AbstractAcknowledgeableStanza {
- public enum TYPE {
- ERROR,
- SET,
- RESULT,
- GET,
- INVALID,
- TIMEOUT
- }
+ public enum TYPE {
+ ERROR,
+ SET,
+ RESULT,
+ GET,
+ INVALID,
+ TIMEOUT
+ }
- public IqPacket(final TYPE type) {
- super("iq");
- if (type != TYPE.INVALID) {
- this.setAttribute("type", type.toString().toLowerCase());
- }
- }
+ public IqPacket(final TYPE type) {
+ super("iq");
+ if (type != TYPE.INVALID) {
+ this.setAttribute("type", type.toString().toLowerCase());
+ }
+ }
- public IqPacket() {
- super("iq");
- }
+ public IqPacket() {
+ super("iq");
+ }
- public Element query() {
- Element query = findChild("query");
- if (query == null) {
- query = addChild("query");
- }
- return query;
- }
+ public Element query() {
+ Element query = findChild("query");
+ if (query == null) {
+ query = addChild("query");
+ }
+ return query;
+ }
- public Element query(final String xmlns) {
- final Element query = query();
- query.setAttribute("xmlns", xmlns);
- return query();
- }
+ public Element query(final String xmlns) {
+ final Element query = query();
+ query.setAttribute("xmlns", xmlns);
+ return query();
+ }
- public TYPE getType() {
- final String type = getAttribute("type");
- if (type == null) {
- return TYPE.INVALID;
- }
- switch (type) {
- case "error":
- return TYPE.ERROR;
- case "result":
- return TYPE.RESULT;
- case "set":
- return TYPE.SET;
- case "get":
- return TYPE.GET;
- case "timeout":
- return TYPE.TIMEOUT;
- default:
- return TYPE.INVALID;
- }
- }
+ public TYPE getType() {
+ final String type = getAttribute("type");
+ if (type == null) {
+ return TYPE.INVALID;
+ }
+ switch (type) {
+ case "error":
+ return TYPE.ERROR;
+ case "result":
+ return TYPE.RESULT;
+ case "set":
+ return TYPE.SET;
+ case "get":
+ return TYPE.GET;
+ case "timeout":
+ return TYPE.TIMEOUT;
+ default:
+ return TYPE.INVALID;
+ }
+ }
- public IqPacket generateResponse(final TYPE type) {
- final IqPacket packet = new IqPacket(type);
- packet.setTo(this.getFrom());
- packet.setId(this.getId());
- return packet;
- }
+ public IqPacket generateResponse(final TYPE type) {
+ final IqPacket packet = new IqPacket(type);
+ packet.setTo(this.getFrom());
+ packet.setId(this.getId());
+ return packet;
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/MessagePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/MessagePacket.java
index 5af2d701b..2f7d7e071 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/MessagePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/MessagePacket.java
@@ -6,94 +6,94 @@ import de.pixart.messenger.parser.AbstractParser;
import de.pixart.messenger.xml.Element;
public class MessagePacket extends AbstractAcknowledgeableStanza {
- public static final int TYPE_CHAT = 0;
- public static final int TYPE_NORMAL = 2;
- public static final int TYPE_GROUPCHAT = 3;
- public static final int TYPE_ERROR = 4;
- public static final int TYPE_HEADLINE = 5;
+ public static final int TYPE_CHAT = 0;
+ public static final int TYPE_NORMAL = 2;
+ public static final int TYPE_GROUPCHAT = 3;
+ public static final int TYPE_ERROR = 4;
+ public static final int TYPE_HEADLINE = 5;
- public MessagePacket() {
- super("message");
- }
+ public MessagePacket() {
+ super("message");
+ }
- public String getBody() {
- return findChildContent("body");
- }
+ public String getBody() {
+ return findChildContent("body");
+ }
- public void setBody(String text) {
- this.children.remove(findChild("body"));
- Element body = new Element("body");
- body.setContent(text);
- this.children.add(0, body);
- }
+ public void setBody(String text) {
+ this.children.remove(findChild("body"));
+ Element body = new Element("body");
+ body.setContent(text);
+ this.children.add(0, body);
+ }
- public void setAxolotlMessage(Element axolotlMessage) {
- this.children.remove(findChild("body"));
- this.children.add(0, axolotlMessage);
- }
+ public void setAxolotlMessage(Element axolotlMessage) {
+ this.children.remove(findChild("body"));
+ this.children.add(0, axolotlMessage);
+ }
- public void setType(int type) {
- switch (type) {
- case TYPE_CHAT:
- this.setAttribute("type", "chat");
- break;
- case TYPE_GROUPCHAT:
- this.setAttribute("type", "groupchat");
- break;
- case TYPE_NORMAL:
- break;
- case TYPE_ERROR:
- this.setAttribute("type","error");
- break;
- default:
- this.setAttribute("type", "chat");
- break;
- }
- }
+ public void setType(int type) {
+ switch (type) {
+ case TYPE_CHAT:
+ this.setAttribute("type", "chat");
+ break;
+ case TYPE_GROUPCHAT:
+ this.setAttribute("type", "groupchat");
+ break;
+ case TYPE_NORMAL:
+ break;
+ case TYPE_ERROR:
+ this.setAttribute("type", "error");
+ break;
+ default:
+ this.setAttribute("type", "chat");
+ break;
+ }
+ }
- public int getType() {
- String type = getAttribute("type");
- if (type == null) {
- return TYPE_NORMAL;
- } else if (type.equals("normal")) {
- return TYPE_NORMAL;
- } else if (type.equals("chat")) {
- return TYPE_CHAT;
- } else if (type.equals("groupchat")) {
- return TYPE_GROUPCHAT;
- } else if (type.equals("error")) {
- return TYPE_ERROR;
- } else if (type.equals("headline")) {
- return TYPE_HEADLINE;
- } else {
- return TYPE_NORMAL;
- }
- }
+ public int getType() {
+ String type = getAttribute("type");
+ if (type == null) {
+ return TYPE_NORMAL;
+ } else if (type.equals("normal")) {
+ return TYPE_NORMAL;
+ } else if (type.equals("chat")) {
+ return TYPE_CHAT;
+ } else if (type.equals("groupchat")) {
+ return TYPE_GROUPCHAT;
+ } else if (type.equals("error")) {
+ return TYPE_ERROR;
+ } else if (type.equals("headline")) {
+ return TYPE_HEADLINE;
+ } else {
+ return TYPE_NORMAL;
+ }
+ }
- public Pair<MessagePacket,Long> getForwardedMessagePacket(String name, String namespace) {
- Element wrapper = findChild(name, namespace);
- if (wrapper == null) {
- return null;
- }
- Element forwarded = wrapper.findChild("forwarded", "urn:xmpp:forward:0");
- if (forwarded == null) {
- return null;
- }
- MessagePacket packet = create(forwarded.findChild("message"));
- if (packet == null) {
- return null;
- }
- Long timestamp = AbstractParser.parseTimestamp(forwarded, null);
- return new Pair(packet,timestamp);
- }
+ public Pair<MessagePacket, Long> getForwardedMessagePacket(String name, String namespace) {
+ Element wrapper = findChild(name, namespace);
+ if (wrapper == null) {
+ return null;
+ }
+ Element forwarded = wrapper.findChild("forwarded", "urn:xmpp:forward:0");
+ if (forwarded == null) {
+ return null;
+ }
+ MessagePacket packet = create(forwarded.findChild("message"));
+ if (packet == null) {
+ return null;
+ }
+ Long timestamp = AbstractParser.parseTimestamp(forwarded, null);
+ return new Pair(packet, timestamp);
+ }
- public static MessagePacket create(Element element) {
- if (element == null) {
- return null;
- }
- MessagePacket packet = new MessagePacket();
- packet.setAttributes(element.getAttributes());
- packet.setChildren(element.getChildren());
- return packet;
- }
+ public static MessagePacket create(Element element) {
+ if (element == null) {
+ return null;
+ }
+ MessagePacket packet = new MessagePacket();
+ packet.setAttributes(element.getAttributes());
+ packet.setChildren(element.getChildren());
+ return packet;
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/PresencePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/PresencePacket.java
index 6c816cac3..6c57de807 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/PresencePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/PresencePacket.java
@@ -2,7 +2,7 @@ package de.pixart.messenger.xmpp.stanzas;
public class PresencePacket extends AbstractAcknowledgeableStanza {
- public PresencePacket() {
- super("presence");
- }
+ public PresencePacket() {
+ super("presence");
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/ActivePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/ActivePacket.java
index 10abb3499..5d1cb61c3 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/ActivePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/ActivePacket.java
@@ -3,8 +3,8 @@ package de.pixart.messenger.xmpp.stanzas.csi;
import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class ActivePacket extends AbstractStanza {
- public ActivePacket() {
- super("active");
- setAttribute("xmlns", "urn:xmpp:csi:0");
- }
+ public ActivePacket() {
+ super("active");
+ setAttribute("xmlns", "urn:xmpp:csi:0");
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/InactivePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/InactivePacket.java
index ebaad8205..9e840190d 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/InactivePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/csi/InactivePacket.java
@@ -3,8 +3,8 @@ package de.pixart.messenger.xmpp.stanzas.csi;
import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class InactivePacket extends AbstractStanza {
- public InactivePacket() {
- super("inactive");
- setAttribute("xmlns", "urn:xmpp:csi:0");
- }
+ public InactivePacket() {
+ super("inactive");
+ setAttribute("xmlns", "urn:xmpp:csi:0");
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/AckPacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/AckPacket.java
index 5c8131878..f98707fbe 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/AckPacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/AckPacket.java
@@ -4,10 +4,10 @@ import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class AckPacket extends AbstractStanza {
- public AckPacket(int sequence, int smVersion) {
- super("a");
- this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
- this.setAttribute("h", Integer.toString(sequence));
- }
+ public AckPacket(int sequence, int smVersion) {
+ super("a");
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
+ this.setAttribute("h", Integer.toString(sequence));
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/EnablePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/EnablePacket.java
index 2beca0f20..d4c8ab242 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/EnablePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/EnablePacket.java
@@ -4,10 +4,10 @@ import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class EnablePacket extends AbstractStanza {
- public EnablePacket(int smVersion) {
- super("enable");
- this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
- this.setAttribute("resume", "true");
- }
+ public EnablePacket(int smVersion) {
+ super("enable");
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
+ this.setAttribute("resume", "true");
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/RequestPacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/RequestPacket.java
index 19880f3c6..cbd82eed6 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/RequestPacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/RequestPacket.java
@@ -4,9 +4,9 @@ import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class RequestPacket extends AbstractStanza {
- public RequestPacket(int smVersion) {
- super("r");
- this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
- }
+ public RequestPacket(int smVersion) {
+ super("r");
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
+ }
}
diff --git a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/ResumePacket.java b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/ResumePacket.java
index 1c7f8d08c..e47fc1b95 100644
--- a/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/ResumePacket.java
+++ b/src/main/java/de/pixart/messenger/xmpp/stanzas/streammgmt/ResumePacket.java
@@ -4,11 +4,11 @@ import de.pixart.messenger.xmpp.stanzas.AbstractStanza;
public class ResumePacket extends AbstractStanza {
- public ResumePacket(String id, int sequence, int smVersion) {
- super("resume");
- this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
- this.setAttribute("previd", id);
- this.setAttribute("h", Integer.toString(sequence));
- }
+ public ResumePacket(String id, int sequence, int smVersion) {
+ super("resume");
+ this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
+ this.setAttribute("previd", id);
+ this.setAttribute("h", Integer.toString(sequence));
+ }
}