diff options
author | Christian S <christian@pix-art.de> | 2016-04-30 21:10:24 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2016-04-30 21:10:24 +0200 |
commit | ab37336d1edc446f17d7a7aaeb653efb170283d9 (patch) | |
tree | 609ca7afbc7bd0c4af0344af310fa0bd352bd4ae /src/main/java/eu/siacs/conversations/entities/Presence.java | |
parent | fe60bd582aee184b49d1af14357cb88ad2637c3e (diff) | |
parent | 936006173ce11111f10c0bddd66d28c439ca584e (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master' into development
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/Presence.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Presence.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Presence.java b/src/main/java/eu/siacs/conversations/entities/Presence.java index 442f1bcac..485adaa13 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presence.java +++ b/src/main/java/eu/siacs/conversations/entities/Presence.java @@ -17,41 +17,46 @@ public class Presence implements Comparable { case XA: return "xa"; case DND: return "dnd"; } - return null; } + + public static Status fromShowString(String show) { + if (show == null) { + return ONLINE; + } else { + switch (show.toLowerCase(Locale.US)) { + case "away": + return AWAY; + case "xa": + return XA; + case "dnd": + return DND; + case "chat": + return CHAT; + default: + return ONLINE; + } + } + } } protected final Status status; protected ServiceDiscoveryResult disco; protected final String ver; protected final String hash; + protected final String message; - private Presence(Status status, String ver, String hash) { + private Presence(Status status, String ver, String hash, String message) { this.status = status; this.ver = ver; this.hash = hash; + this.message = message; } - public static Presence parse(String show, Element caps) { + public static Presence parse(String show, Element caps, String message) { final String hash = caps == null ? null : caps.getAttribute("hash"); final String ver = caps == null ? null : caps.getAttribute("ver"); - if (show == null) { - return new Presence(Status.ONLINE, ver, hash); - } else { - 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); - } - } + return new Presence(Status.fromShowString(show), ver, hash, message); } public int compareTo(Object other) { |