aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Presence.java26
-rw-r--r--src/main/java/eu/siacs/conversations/parser/PresenceParser.java2
2 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Presence.java b/src/main/java/eu/siacs/conversations/entities/Presence.java
index 69cde832..442f1bca 100644
--- a/src/main/java/eu/siacs/conversations/entities/Presence.java
+++ b/src/main/java/eu/siacs/conversations/entities/Presence.java
@@ -1,6 +1,7 @@
package eu.siacs.conversations.entities;
import java.lang.Comparable;
+import java.util.Locale;
import eu.siacs.conversations.xml.Element;
@@ -32,21 +33,24 @@ public class Presence implements Comparable {
this.hash = hash;
}
- public static Presence parse(Element show, Element caps) {
+ public static Presence parse(String show, Element caps) {
final String hash = caps == null ? null : caps.getAttribute("hash");
final String ver = caps == null ? null : caps.getAttribute("ver");
- if ((show == null) || (show.getContent() == null)) {
+ if (show == null) {
return new Presence(Status.ONLINE, ver, hash);
- } else if (show.getContent().equals("away")) {
- return new Presence(Status.AWAY, ver, hash);
- } else if (show.getContent().equals("xa")) {
- return new Presence(Status.XA, ver, hash);
- } else if (show.getContent().equals("chat")) {
- return new Presence(Status.CHAT, ver, hash);
- } else if (show.getContent().equals("dnd")) {
- return new Presence(Status.DND, ver, hash);
} else {
- return new Presence(Status.OFFLINE, ver, hash);
+ switch (show.toLowerCase(Locale.US)) {
+ case "away":
+ return new Presence(Status.AWAY, ver, hash);
+ case "xa":
+ return new Presence(Status.XA, ver, hash);
+ case "dnd":
+ return new Presence(Status.DND, ver, hash);
+ case "chat":
+ return new Presence(Status.CHAT, ver, hash);
+ default:
+ return new Presence(Status.ONLINE, ver, hash);
+ }
}
}
diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
index 45c31e2b..dc02eda8 100644
--- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
@@ -186,7 +186,7 @@ public class PresenceParser extends AbstractParser implements
}
int sizeBefore = contact.getPresences().size();
- final Element show = packet.findChild("show");
+ final String show = packet.findChildContent("show");
final Element caps = packet.findChild("c", "http://jabber.org/protocol/caps");
final Presence presence = Presence.parse(show, caps);
contact.updatePresence(resource, presence);