diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-27 20:40:42 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-27 20:40:42 +0100 |
commit | 4f902d8210d50a586c7ece1bb7da2ab26fd18da5 (patch) | |
tree | b15d34a909443f79ac10d28f23eca19cf1c3301e /src/de/gultsch/chat/services/XmppConnectionService.java | |
parent | 898b0ca8c485888e06e2b5b1c798eebce1a6dabc (diff) |
conversation archiveable. new conversation will find or restart old conversations
Diffstat (limited to '')
-rw-r--r-- | src/de/gultsch/chat/services/XmppConnectionService.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/de/gultsch/chat/services/XmppConnectionService.java b/src/de/gultsch/chat/services/XmppConnectionService.java index 67e3901e..20af9742 100644 --- a/src/de/gultsch/chat/services/XmppConnectionService.java +++ b/src/de/gultsch/chat/services/XmppConnectionService.java @@ -2,6 +2,8 @@ package de.gultsch.chat.services; import java.util.List; +import de.gultsch.chat.entities.Account; +import de.gultsch.chat.entities.Contact; import de.gultsch.chat.entities.Conversation; import de.gultsch.chat.entities.Message; import de.gultsch.chat.persistance.DatabaseBackend; @@ -35,15 +37,39 @@ public class XmppConnectionService extends Service { } public void sendMessage(Message message) { - Log.d(LOGTAG,"sending message"); + databaseBackend.createMessage(message); } public void addConversation(Conversation conversation) { - databaseBackend.addConversation(conversation); + databaseBackend.createConversation(conversation); } public List<Conversation> getConversations(int status) { return databaseBackend.getConversations(status); } + + public List<Message> getMessages(Conversation conversation) { + return databaseBackend.getMessages(conversation, 100); + } + public Conversation findOrCreateConversation(Account account, Contact contact) { + Conversation conversation = databaseBackend.findConversation(account, contact); + if (conversation!=null) { + Log.d("gultsch","found one. unarchive it"); + conversation.setStatus(Conversation.STATUS_AVAILABLE); + this.databaseBackend.updateConversation(conversation); + } else { + conversation = new Conversation(contact.getDisplayName(), contact.getProfilePhoto(), account, contact.getJid()); + this.databaseBackend.createConversation(conversation); + } + return conversation; + } + + public void updateConversation(Conversation conversation) { + this.databaseBackend.updateConversation(conversation); + } + + public int getConversationCount() { + return this.databaseBackend.getConversationCount(); + } } |