diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2016-01-17 16:28:38 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2016-01-24 17:46:08 -0500 |
commit | bf5b2f73f5a61f0a0179c9d4431579f87eecb001 (patch) | |
tree | 5bd8b9aaa8b4326dfecb699fd1cdcf97a02b8097 /src/main/java/eu/siacs/conversations/entities/Presence.java | |
parent | ad36a4ba89f880a5522ffd5179dcaa98985e4164 (diff) |
Use a Presence class for presence information
Only has status for now, but doing it so I can add disco to it
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Presence.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Presence.java b/src/main/java/eu/siacs/conversations/entities/Presence.java new file mode 100644 index 00000000..adba74d1 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/entities/Presence.java @@ -0,0 +1,49 @@ +package eu.siacs.conversations.entities; + +import java.lang.Comparable; + +import eu.siacs.conversations.xml.Element; + +public class Presence implements Comparable { + + public enum Status { + CHAT, ONLINE, AWAY, XA, DND, OFFLINE; + + public String toShowString() { + switch(this) { + case CHAT: return "chat"; + case AWAY: return "away"; + case XA: return "xa"; + case DND: return "dnd"; + } + + return null; + } + } + + protected final Status status; + + public Presence(Element show) { + if ((show == null) || (show.getContent() == null)) { + this.status = Status.ONLINE; + } else if (show.getContent().equals("away")) { + this.status = Status.AWAY; + } else if (show.getContent().equals("xa")) { + this.status = Status.XA; + } else if (show.getContent().equals("chat")) { + this.status = Status.CHAT; + } else if (show.getContent().equals("dnd")) { + this.status = Status.DND; + } else { + this.status = Status.OFFLINE; + } + } + + public int compareTo(Object other) { + return this.status.compareTo(((Presence)other).status); + } + + public Status getStatus() { + return this.status; + } +} |