diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-06-06 13:14:22 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2014-06-06 13:14:22 +0300 |
commit | 29c0cf0340d6335fc48b45808bb87dde33b344a8 (patch) | |
tree | a4768f38cdf6b47b128dcdc4d2e8bc759518acbe /src | |
parent | 449cda9df91a42919b6ffefef4bfcb8391ef923a (diff) | |
download | jitsi-29c0cf0340d6335fc48b45808bb87dde33b344a8.zip jitsi-29c0cf0340d6335fc48b45808bb87dde33b344a8.tar.gz jitsi-29c0cf0340d6335fc48b45808bb87dde33b344a8.tar.bz2 |
Updates recent chats when erasing chat history.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java | 9 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/msghistory/MessageSourceService.java | 95 |
2 files changed, 104 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index bd9d181..c6ed3cc 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -2956,6 +2956,9 @@ public class MessageHistoryServiceImpl HistoryID historyId = HistoryID.createFromRawID( new String[] { "messages" }); historyService.purgeLocallyStoredHistory(historyId); + + if(this.messageSourceService != null) + this.messageSourceService.eraseLocallyStoredHistory(); } /** @@ -2975,6 +2978,9 @@ public class MessageHistoryServiceImpl History history = this.getHistory(null, item); historyService.purgeLocallyStoredHistory(history.getID()); } + + if(this.messageSourceService != null) + this.messageSourceService.eraseLocallyStoredHistory(contact); } /** @@ -2988,6 +2994,9 @@ public class MessageHistoryServiceImpl { History history = this.getHistoryForMultiChat(room); historyService.purgeLocallyStoredHistory(history.getID()); + + if(this.messageSourceService != null) + this.messageSourceService.eraseLocallyStoredHistory(room); } /** diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageSourceService.java b/src/net/java/sip/communicator/impl/msghistory/MessageSourceService.java index cef4618..8e0cb70 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageSourceService.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageSourceService.java @@ -12,6 +12,7 @@ import java.text.*; import java.util.*; import java.util.regex.*; +import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.history.*; import net.java.sip.communicator.service.history.records.*; @@ -1212,6 +1213,100 @@ public class MessageSourceService } /** + * Permanently removes all locally stored message history, + * remove recent contacts. + */ + public void eraseLocallyStoredHistory() + throws IOException + { + synchronized(recentMessages) + { + List<MessageSourceContact> toRemove + = new ArrayList<MessageSourceContact>(recentMessages); + + recentMessages.clear(); + + if(recentQuery != null) + { + for(MessageSourceContact msc : toRemove) + { + recentQuery.fireContactRemoved(msc); + } + } + } + } + + /** + * Permanently removes locally stored message history for the metacontact, + * remove any recent contacts if any. + */ + public void eraseLocallyStoredHistory(MetaContact contact) + throws IOException + { + synchronized(recentMessages) + { + List<MessageSourceContact> toRemove + = new ArrayList<MessageSourceContact>(); + Iterator<Contact> iter = contact.getContacts(); + while(iter.hasNext()) + { + Contact item = iter.next(); + String id = item.getAddress(); + ProtocolProviderService provider = item.getProtocolProvider(); + + for(MessageSourceContact msc : recentMessages) + { + if(msc.getProtocolProviderService().equals(provider) + && msc.getContactAddress().equals(id)) + { + toRemove.add(msc); + } + } + } + + recentMessages.removeAll(toRemove); + + if(recentQuery != null) + { + for(MessageSourceContact msc : toRemove) + { + recentQuery.fireContactRemoved(msc); + } + } + } + + } + + /** + * Permanently removes locally stored message history for the chatroom, + * remove any recent contacts if any. + */ + public void eraseLocallyStoredHistory(ChatRoom room) + { + synchronized(recentMessages) + { + MessageSourceContact toRemove = null; + for(MessageSourceContact msg : recentMessages) + { + if(msg.getRoom() != null + && msg.getRoom().equals(room)) + { + toRemove = msg; + break; + } + } + + if(toRemove == null) + return; + + recentMessages.remove(toRemove); + + if(recentQuery != null) + recentQuery.fireContactRemoved(toRemove); + } + } + + /** * The contact query implementation. */ private class MessageHistoryContactQuery |