aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/entities/Roster.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-19 15:15:09 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-19 15:15:09 +0200
commit993477cd8301e1a9a19ccdc10008bc23928faf08 (patch)
tree06f7f52d55546676eaf4e894a58fe79423ab3ef6 /src/eu/siacs/conversations/entities/Roster.java
parent590e2403ab6d9d8f3b0158bf5218802216e9cd50 (diff)
reworked roster/contact handling. might break some stuff. not sycing to disk yet
Diffstat (limited to 'src/eu/siacs/conversations/entities/Roster.java')
-rw-r--r--src/eu/siacs/conversations/entities/Roster.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/entities/Roster.java b/src/eu/siacs/conversations/entities/Roster.java
new file mode 100644
index 00000000..7c18d80a
--- /dev/null
+++ b/src/eu/siacs/conversations/entities/Roster.java
@@ -0,0 +1,63 @@
+package eu.siacs.conversations.entities;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class Roster {
+ Account account;
+ HashMap<String, Contact> contacts = new HashMap<String, Contact>();
+ private String version = null;
+
+ public Roster(Account account) {
+ this.account = account;
+ }
+
+ public boolean hasContact(String jid) {
+ String cleanJid = jid.split("/")[0];
+ return contacts.containsKey(cleanJid);
+ }
+
+ public Contact getContact(String jid) {
+ String cleanJid = jid.split("/")[0];
+ if (contacts.containsKey(cleanJid)) {
+ return contacts.get(cleanJid);
+ } else {
+ Contact contact = new Contact(cleanJid);
+ contact.setAccount(account);
+ contacts.put(cleanJid, contact);
+ return contact;
+ }
+ }
+
+ public void clearPresences() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void markAllAsNotInRoster() {
+
+ }
+
+ public List<Contact> getContacts() {
+ return new ArrayList<Contact>(this.contacts.values());
+ }
+
+ public void initContact(Contact contact) {
+ contact.setAccount(account);
+ contact.setOption(Contact.Options.IN_ROSTER);
+ contacts.put(contact.getJid(),contact);
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public Account getAccount() {
+ return this.account;
+ }
+}