diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-09 00:47:11 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-09 00:47:11 +0100 |
commit | c31101dd6458225a007466a3d58a2f4b591c684f (patch) | |
tree | 5606bbb1679301e6bbc51b92d5d6372d10789793 /src/de/gultsch/chat/entities/Contact.java | |
parent | 95068ee776d9ec8e6c390133ca2bed083a46546f (diff) |
presences are now somewhat stored and displayed to the user via the contact details action.
Diffstat (limited to '')
-rw-r--r-- | src/de/gultsch/chat/entities/Contact.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/de/gultsch/chat/entities/Contact.java b/src/de/gultsch/chat/entities/Contact.java index 6079d9bb..da3c0810 100644 --- a/src/de/gultsch/chat/entities/Contact.java +++ b/src/de/gultsch/chat/entities/Contact.java @@ -1,6 +1,7 @@ package de.gultsch.chat.entities; import java.io.Serializable; +import java.util.Hashtable; import android.content.ContentValues; import android.database.Cursor; @@ -16,7 +17,7 @@ public class Contact extends AbstractEntity implements Serializable { public static final String SYSTEMACCOUNT = "systemaccount"; public static final String PHOTOURI = "photouri"; public static final String OPENPGPKEY = "pgpkey"; - public static final String LASTPRESENCE = "presence"; + public static final String PRESENCES = "presences"; public static final String ACCOUNT = "accountUuid"; protected String accountUuid; @@ -26,7 +27,7 @@ public class Contact extends AbstractEntity implements Serializable { protected int systemAccount; protected String photoUri; protected String openPGPKey; - protected long lastPresence; + protected Presences presences = new Presences(); protected Account account; @@ -44,7 +45,7 @@ public class Contact extends AbstractEntity implements Serializable { public Contact(String uuid, String account, String displayName, String jid, String subscription, String photoUri, int systemAccount, - String pgpKey, long lastseen) { + String pgpKey,String presences) { this.uuid = uuid; this.accountUuid = account; this.displayName = displayName; @@ -53,7 +54,7 @@ public class Contact extends AbstractEntity implements Serializable { this.photoUri = photoUri; this.systemAccount = systemAccount; this.openPGPKey = pgpKey; - this.lastPresence = lastseen; + this.presences = Presences.fromJsonString(presences); } public String getDisplayName() { @@ -84,7 +85,7 @@ public class Contact extends AbstractEntity implements Serializable { values.put(SYSTEMACCOUNT, systemAccount); values.put(PHOTOURI, photoUri); values.put(OPENPGPKEY, openPGPKey); - values.put(LASTPRESENCE, lastPresence); + values.put(PRESENCES, presences.toJsonString()); return values; } @@ -97,12 +98,16 @@ public class Contact extends AbstractEntity implements Serializable { cursor.getString(cursor.getColumnIndex(PHOTOURI)), cursor.getInt(cursor.getColumnIndex(SYSTEMACCOUNT)), cursor.getString(cursor.getColumnIndex(OPENPGPKEY)), - cursor.getLong(cursor.getColumnIndex(LASTPRESENCE))); + cursor.getString(cursor.getColumnIndex(PRESENCES))); } public void setSubscription(String subscription) { this.subscription = subscription; } + + public String getSubscription() { + return this.subscription; + } public void setSystemAccount(int account) { this.systemAccount = account; @@ -136,4 +141,20 @@ public class Contact extends AbstractEntity implements Serializable { } } } + + public Hashtable<String, Integer> getPresences() { + return this.presences.getPresences(); + } + + public void updatePresence(String resource, int status) { + this.presences.updatePresence(resource, status); + } + + public void removePresence(String resource) { + this.presences.removePresence(resource); + } + + public int getMostAvailableStatus() { + return this.presences.getMostAvailableStatus(); + } } |