Avoid duplicating incoming message when show history in chats is enabled

cusax-fix
Ingo Bauersachs 14 years ago
parent 7355e2f823
commit 67857bddcf

@ -652,6 +652,21 @@ public PopupDialog getPopupDialog()
* @see UIService#getChat(Contact)
*/
public ChatPanel getChat(Contact contact)
{
return this.getChat(contact, null);
}
/**
* Implements {@link UIService#getChat(Contact)}. If a chat for the given
* contact exists already, returns it; otherwise, creates a new one.
*
* @param contact the contact that we'd like to retrieve a chat window for.
* @param escapedMessageID the message ID of the message that should be
* excluded from the history when the last one is loaded in the chat
* @return the <tt>Chat</tt> corresponding to the specified contact.
* @see UIService#getChat(Contact)
*/
public ChatPanel getChat(Contact contact, String escapedMessageUID)
{
MetaContact metaContact
= GuiActivator.getContactListService()
@ -660,7 +675,10 @@ public ChatPanel getChat(Contact contact)
if(metaContact == null)
return null;
return chatWindowManager.getContactChat(metaContact, true);
return chatWindowManager.getContactChat(
metaContact,
true,
escapedMessageUID);
}
/**

@ -358,6 +358,40 @@ public ChatPanel getContactChat(MetaContact metaContact, boolean create)
}
}
/**
* Gets the <tt>ChatPanel</tt> corresponding to the specified
* <tt>MetaContact</tt> and optionally creates it if it does not exist.
*
* @param metaContact the <tt>MetaContact</tt> to get the corresponding
* <tt>ChatPanel</tt> of
* @param create <tt>true</tt> to create a <tt>ChatPanel</tt> corresponding
* to the specified <tt>MetaContact</tt> if such <tt>ChatPanel</tt> does not
* exist yet
* @param escapedMessageID the message ID of the message that should be
* excluded from the history when the last one is loaded in the chat
* @return the <tt>ChatPanel</tt> corresponding to the specified
* <tt>MetaContact</tt>; <tt>null</tt> if there is no such
* <tt>ChatPanel</tt> and <tt>create</tt> is <tt>false</tt>
*/
public ChatPanel getContactChat(MetaContact metaContact, boolean create,
String escapedMessageID)
{
// if we are not creating a ui we don't need any execution
// in event dispatch thread, lets execute now
if(!create)
return getContactChat(metaContact, null, create, escapedMessageID);
else
{
// we may create using event dispatch thread
MetaContactChatCreateRunnable runnable
= new MetaContactChatCreateRunnable(
metaContact,
null,
escapedMessageID);
return runnable.getChatPanel();
}
}
/**
* Returns the chat panel corresponding to the given meta contact
*
@ -386,7 +420,10 @@ public ChatPanel getContactChat(MetaContact metaContact,
{
// we may create using event dispatch thread
MetaContactChatCreateRunnable runnable
= new MetaContactChatCreateRunnable(metaContact, null, null);
= new MetaContactChatCreateRunnable(
metaContact,
null,
escapedMessageID);
return runnable.getChatPanel();
}
@ -1449,7 +1486,11 @@ private MetaContactChatCreateRunnable(MetaContact metaContact,
*/
protected ChatPanel createChatPanel()
{
return getContactChat(metaContact, null, true, null);
return getContactChat(
metaContact,
null,
true,
this.escapedMessageID);
}
}

@ -146,7 +146,8 @@ public class NotificationManager
public static void fireChatNotification(Object chatContact,
String eventType,
String messageTitle,
String message)
String message,
String messageUID)
{
NotificationService notificationService
= NotificationWiringActivator.getNotificationService();
@ -164,7 +165,7 @@ public static void fireChatNotification(Object chatContact,
Contact contact = (Contact) chatContact;
if(uiService != null)
chatPanel = uiService.getChat(contact);
chatPanel = uiService.getChat(contact, messageUID);
contactIcon = contact.getImage();
if(contactIcon == null)
@ -737,7 +738,8 @@ public void fileTransferRequestReceived(FileTransferRequestEvent event)
sourceContact,
INCOMING_FILE,
title,
request.getFileName());
request.getFileName(),
null);
}
catch(Throwable t)
{
@ -1189,7 +1191,8 @@ public void messageReceived(AdHocChatRoomMessageReceivedEvent evt)
sourceChatRoom,
INCOMING_MESSAGE,
title,
messageContent);
messageContent,
evt.getMessage().getMessageUID());
}
}
catch(Throwable t)
@ -1255,7 +1258,8 @@ public void messageReceived(ChatRoomMessageReceivedEvent evt)
sourceChatRoom,
INCOMING_MESSAGE,
title,
messageContent);
messageContent,
evt.getMessage().getMessageUID());
}
}
catch(Throwable t)
@ -1282,7 +1286,8 @@ public void messageReceived(MessageReceivedEvent evt)
evt.getSourceContact(),
INCOMING_MESSAGE,
title,
evt.getSourceMessage().getContent());
evt.getSourceMessage().getContent(),
evt.getSourceMessage().getMessageUID());
}
catch(Throwable t)
{
@ -1892,7 +1897,8 @@ public void typingNotificationReceived(TypingNotificationEvent ev)
PROACTIVE_NOTIFICATION,
contact.getDisplayName(),
NotificationWiringActivator.getResources().getI18NString(
"service.gui.PROACTIVE_NOTIFICATION"));
"service.gui.PROACTIVE_NOTIFICATION"),
null);
}
catch(Throwable t)
{

@ -214,6 +214,16 @@ public ExportedWindow getExportedWindow(WindowID windowID, Object[] params)
*/
public Chat getChat(Contact contact);
/**
* Returns the <tt>Chat</tt> corresponding to the given <tt>Contact</tt>.
*
* @param contact the <tt>Contact</tt> for which the searched chat is about.
* @param escapedMessageID the message ID of the message that should be
* excluded from the history when the last one is loaded in the chat
* @return the <tt>Chat</tt> corresponding to the given <tt>Contact</tt>.
*/
public Chat getChat(Contact contact, String escapedMessageID);
/**
* Returns the <tt>Chat</tt> corresponding to the given <tt>ChatRoom</tt>.
*

Loading…
Cancel
Save