diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-15 22:08:13 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-15 22:08:13 +0200 |
commit | f5019ba96647bd1c33153e6e9099d21dcf47bfa7 (patch) | |
tree | 5791e6832d3ad617f6e4a3fa3a6761a97d3dee8c /src/eu/siacs/conversations/services/XmppConnectionService.java | |
parent | 89cc4d12477e4c5593d10b69e0ed42cbaedfb190 (diff) |
detect deleted files on start up. got rid of lagecy image provider for performance reasons. NOTE: this will prevent you to access images older than version 0.6
Diffstat (limited to 'src/eu/siacs/conversations/services/XmppConnectionService.java')
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 07897f8cd..04d5711af 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -27,6 +27,7 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; +import eu.siacs.conversations.entities.Downloadable; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.MucOptions.OnRenameListener; @@ -797,11 +798,21 @@ public class XmppConnectionService extends Service { Account account = accountLookupTable.get(conv.getAccountUuid()); conv.setAccount(account); conv.setMessages(databaseBackend.getMessages(conv, 50)); + checkDeletedFiles(conv); } } - return this.conversations; } + + private void checkDeletedFiles(Conversation conversation) { + for(Message message : conversation.getMessages()) { + if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP) { + if (!getFileBackend().isFileAvailable(message)) { + message.setDownloadable(new DeletedDownloadable()); + } + } + } + } public void populateWithOrderedConversations(List<Conversation> list) { populateWithOrderedConversations(list, true); @@ -1833,4 +1844,23 @@ public class XmppConnectionService extends Service { public HttpConnectionManager getHttpConnectionManager() { return this.mHttpConnectionManager; } + + private class DeletedDownloadable implements Downloadable { + + @Override + public void start() { + return; + } + + @Override + public int getStatus() { + return Downloadable.STATUS_DELETED; + } + + @Override + public long getFileSize() { + return 0; + } + + } } |