diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-02-19 11:09:28 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-02-19 11:09:28 +0100 |
commit | 49a3f6f281c9a01f9bdaf7f5141c46dd1c6ca2cb (patch) | |
tree | 80a8000b8394122d15e87a1fdfc3ff2e70382a9b /src/main/java | |
parent | ac687d6bbd08674d97a52b3548df8fe49bee48d9 (diff) |
never parse show in presences as offline
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Presence.java | 26 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/PresenceParser.java | 2 |
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); |