model: add Conversation, Account

Change-Id: Ia0717957d9b7489dd2b299ad9f8696e25b662ec7
diff --git a/model/Account.js b/model/Account.js
index 3141176..6b43f1c 100644
--- a/model/Account.js
+++ b/model/Account.js
@@ -1,8 +1,13 @@
+const Contact = require('./Contact')
+
 class Account {
     constructor(id, details, volatileDetails) {
         this.id = id
         this.details = details
         this.volatileDetails = volatileDetails
+        this.contactCache = {}
+        this.contacts = {}
+        this.conversations = {}
     }
 
     static from(object) {
@@ -14,6 +19,14 @@
         this.volatileDetails = data.volatileDetails
     }
 
+    getObject() {
+        return {
+            id: this.id,
+            details: this.details,
+            volatileDetails: this.volatileDetails
+        }
+    }
+
     getId() { return this.id }
 
     getType() { return this.details["Account.type"] }
@@ -23,15 +36,8 @@
     getRegisteredName() { return this.volatileDetails["Account.registeredName"] }
 
     isRendezVous() { return this.details["Account.rendezVous"] === Account.BOOL_TRUE }
-    isPublicIn() { return this.details["DHT.PublicInCalls"] === Account.BOOL_TRUE }
 
-    getObject() {
-        return {
-            id: this.id,
-            details: this.details,
-            volatileDetails: this.volatileDetails
-        }
-    }
+    isPublicIn() { return this.details["DHT.PublicInCalls"] === Account.BOOL_TRUE }
 
     getSummary() {
         return this.getObject()
@@ -44,6 +50,35 @@
     getDisplayUri() {
         return this.getRegisteredName() || this.getUri()
     }
+
+    getConversationIds() {
+        return Object.keys(this.conversations)
+    }
+
+    getConversation(conversationId) {
+        return this.conversations[conversationId]
+    }
+
+    addConversation(conversation) {
+        this.conversations[conversation.getId()] = conversation
+    }
+
+    removeConversation(conversationId) {
+        delete this.conversations[conversationId]
+    }
+
+    getContactFromCache(uri) {
+        let contact = this.contactCache[uri]
+        if (!contact) {
+            contact = new Contact(uri)
+            this.contactCache[uri] = contact
+        }
+        return contact
+    }
+
+    getContacts() {
+        return this.contacts
+    }
 }
 
 Account.TYPE_JAMI = "RING"
@@ -52,4 +87,4 @@
 Account.BOOL_TRUE = "true"
 Account.BOOL_FALSE = "false"
 
-module.exports = Account;
+module.exports = Account