Updates recent chats when erasing chat history.

fix-message-formatting
Damian Minkov 12 years ago
parent 449cda9df9
commit 29c0cf0340

@ -2956,6 +2956,9 @@ public void eraseLocallyStoredHistory()
HistoryID historyId = HistoryID.createFromRawID(
new String[] { "messages" });
historyService.purgeLocallyStoredHistory(historyId);
if(this.messageSourceService != null)
this.messageSourceService.eraseLocallyStoredHistory();
}
/**
@ -2975,6 +2978,9 @@ public void eraseLocallyStoredHistory(MetaContact contact)
History history = this.getHistory(null, item);
historyService.purgeLocallyStoredHistory(history.getID());
}
if(this.messageSourceService != null)
this.messageSourceService.eraseLocallyStoredHistory(contact);
}
/**
@ -2988,6 +2994,9 @@ public void eraseLocallyStoredHistory(ChatRoom room)
{
History history = this.getHistoryForMultiChat(room);
historyService.purgeLocallyStoredHistory(history.getID());
if(this.messageSourceService != null)
this.messageSourceService.eraseLocallyStoredHistory(room);
}
/**

@ -12,6 +12,7 @@
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.*;
@ -1211,6 +1212,100 @@ public void supportedOperationSetsChanged(ContactCapabilitiesEvent event)
}
}
/**
* 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.
*/

Loading…
Cancel
Save