diff options
Diffstat (limited to 'src/eu/siacs/conversations/entities')
-rw-r--r-- | src/eu/siacs/conversations/entities/Account.java | 17 | ||||
-rw-r--r-- | src/eu/siacs/conversations/entities/Presences.java | 22 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java index 41d94fee9..3f9510b36 100644 --- a/src/eu/siacs/conversations/entities/Account.java +++ b/src/eu/siacs/conversations/entities/Account.java @@ -60,6 +60,7 @@ public class Account extends AbstractEntity{ transient OtrEngine otrEngine = null; transient XmppConnection xmppConnection = null; + transient protected Presences presences = new Presences(); private String otrFingerprint; @@ -249,4 +250,20 @@ public class Account extends AbstractEntity{ this.getOtrEngine(applicationContext); return this.getOtrFingerprint(); } + + public void updatePresence(String resource, int status) { + this.presences.updatePresence(resource, status); + } + + public void removePresence(String resource) { + this.presences.removePresence(resource); + } + + public void clearPresences() { + this.presences = new Presences(); + } + + public int countPresences() { + return this.presences.size(); + } } diff --git a/src/eu/siacs/conversations/entities/Presences.java b/src/eu/siacs/conversations/entities/Presences.java index af7926a8b..9a22e559c 100644 --- a/src/eu/siacs/conversations/entities/Presences.java +++ b/src/eu/siacs/conversations/entities/Presences.java @@ -8,6 +8,8 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import eu.siacs.conversations.xml.Element; + public class Presences { public static final int CHAT = -1; @@ -73,4 +75,24 @@ public class Presences { } return presences; } + + public static int parseShow(Element show) { + if (show == null) { + return Presences.ONLINE; + } else if (show.getContent().equals("away")) { + return Presences.AWAY; + } else if (show.getContent().equals("xa")) { + return Presences.XA; + } else if (show.getContent().equals("chat")) { + return Presences.CHAT; + } else if (show.getContent().equals("dnd")) { + return Presences.DND; + } else { + return Presences.OFFLINE; + } + } + + public int size() { + return presences.size(); + } } |