src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
/**
     * Process history messages.
     *
     * @param historyList The collection of messages coming from history.
     * @param escapedMessageID The incoming message needed to be ignored if
     * contained in history.
     */
Process history messages.
@param historyList The collection of messages coming from history.
@param escapedMessageID The incoming message needed to be ignored if
contained in history.
Process history messages . @param historyList The collection of messages coming from history . @param escapedMessageID The incoming message needed to be ignored if contained in history .
private void processHistory( Collection<Object> historyList,
                                String escapedMessageID)
    {
        Iterator<Object> iterator = historyList.iterator();
        String messageType;
        while (iterator.hasNext())
        {
            Object o = iterator.next();
            String historyString = "";
            if(o instanceof MessageDeliveredEvent)
            {
                MessageDeliveredEvent evt
                    = (MessageDeliveredEvent)o;
                ProtocolProviderService protocolProvider = evt
                    .getDestinationContact().getProtocolProvider();
                if (isGreyHistoryStyleDisabled(protocolProvider))
                    messageType = Chat.OUTGOING_MESSAGE;
                else
                    messageType = Chat.HISTORY_OUTGOING_MESSAGE;
                historyString = processHistoryMessage(
                            GuiActivator.getUIService().getMainFrame()
                                .getAccountAddress(protocolProvider),
                            GuiActivator.getUIService().getMainFrame()
                                .getAccountDisplayName(protocolProvider),
                            evt.getTimestamp(),
                            messageType,
                            evt.getSourceMessage().getContent(),
                            evt.getSourceMessage().getContentType(),
                            evt.getSourceMessage().getMessageUID());
            }
            else if(o instanceof MessageReceivedEvent)
            {
                MessageReceivedEvent evt = (MessageReceivedEvent)o;
                ProtocolProviderService protocolProvider
                    = evt.getSourceContact().getProtocolProvider();
                if(!evt.getSourceMessage().getMessageUID()
                        .equals(escapedMessageID))
                {
                    if (isGreyHistoryStyleDisabled(protocolProvider))
                        messageType = Chat.INCOMING_MESSAGE;
                    else
                        messageType = Chat.HISTORY_INCOMING_MESSAGE;
                    historyString = processHistoryMessage(
                                evt.getSourceContact().getAddress(),
                                evt.getSourceContact().getDisplayName(),
                                evt.getTimestamp(),
                                messageType,
                                evt.getSourceMessage().getContent(),
                                evt.getSourceMessage().getContentType(),
                                evt.getSourceMessage().getMessageUID());
                }
            }
            else if(o instanceof ChatRoomMessageDeliveredEvent)
            {
                ChatRoomMessageDeliveredEvent evt
                    = (ChatRoomMessageDeliveredEvent)o;
                ProtocolProviderService protocolProvider = evt
                    .getSourceChatRoom().getParentProvider();
                historyString = processHistoryMessage(
                            GuiActivator.getUIService().getMainFrame()
                                .getAccountAddress(protocolProvider),
                            GuiActivator.getUIService().getMainFrame()
                                .getAccountDisplayName(protocolProvider),
                            evt.getTimestamp(),
                            Chat.HISTORY_OUTGOING_MESSAGE,
                            evt.getMessage().getContent(),
                            evt.getMessage().getContentType(),
                            evt.getMessage().getMessageUID());
            }
            else if(o instanceof ChatRoomMessageReceivedEvent)
            {
                ChatRoomMessageReceivedEvent evt
                    = (ChatRoomMessageReceivedEvent) o;
                if(!evt.getMessage().getMessageUID()
                        .equals(escapedMessageID))
                {
                    historyString = processHistoryMessage(
                            evt.getSourceChatRoomMember().getContactAddress(),
                            evt.getSourceChatRoomMember().getName(),
                            evt.getTimestamp(),
                            Chat.HISTORY_INCOMING_MESSAGE,
                            evt.getMessage().getContent(),
                            evt.getMessage().getContentType(),
                            evt.getMessage().getMessageUID());
                }
            }
            else if (o instanceof FileRecord)
            {
                FileRecord fileRecord = (FileRecord) o;
                if (!fileRecord.getID().equals(escapedMessageID))
                {
                    FileHistoryConversationComponent component
                        = new FileHistoryConversationComponent(fileRecord);
                    conversationPanel.addComponent(component);
                }
            }
            if (historyString != null)
                conversationPanel.appendMessageToEnd(
                    historyString, ChatHtmlUtils.HTML_CONTENT_TYPE);
        }
        fireChatHistoryChange();
    }
private void processHistory ( Collection < Object > historyList , String escapedMessageID ) { Iterator < Object > iterator = historyList . iterator ( ) ; String messageType ; while ( iterator . hasNext ( ) ) { Object o = iterator . next ( ) ; String historyString = "" ; if ( o instanceof MessageDeliveredEvent ) { MessageDeliveredEvent evt = ( MessageDeliveredEvent ) o ; ProtocolProviderService protocolProvider = evt . getDestinationContact ( ) . getProtocolProvider ( ) ; if ( isGreyHistoryStyleDisabled ( protocolProvider ) ) messageType = Chat . OUTGOING_MESSAGE ; else messageType = Chat . HISTORY_OUTGOING_MESSAGE ; historyString = processHistoryMessage ( GuiActivator . getUIService ( ) . getMainFrame ( ) . getAccountAddress ( protocolProvider ) , GuiActivator . getUIService ( ) . getMainFrame ( ) . getAccountDisplayName ( protocolProvider ) , evt . getTimestamp ( ) , messageType , evt . getSourceMessage ( ) . getContent ( ) , evt . getSourceMessage ( ) . getContentType ( ) , evt . getSourceMessage ( ) . getMessageUID ( ) ) ; } else if ( o instanceof MessageReceivedEvent ) { MessageReceivedEvent evt = ( MessageReceivedEvent ) o ; ProtocolProviderService protocolProvider = evt . getSourceContact ( ) . getProtocolProvider ( ) ; if ( ! evt . getSourceMessage ( ) . getMessageUID ( ) . equals ( escapedMessageID ) ) { if ( isGreyHistoryStyleDisabled ( protocolProvider ) ) messageType = Chat . INCOMING_MESSAGE ; else messageType = Chat . HISTORY_INCOMING_MESSAGE ; historyString = processHistoryMessage ( evt . getSourceContact ( ) . getAddress ( ) , evt . getSourceContact ( ) . getDisplayName ( ) , evt . getTimestamp ( ) , messageType , evt . getSourceMessage ( ) . getContent ( ) , evt . getSourceMessage ( ) . getContentType ( ) , evt . getSourceMessage ( ) . getMessageUID ( ) ) ; } } else if ( o instanceof ChatRoomMessageDeliveredEvent ) { ChatRoomMessageDeliveredEvent evt = ( ChatRoomMessageDeliveredEvent ) o ; ProtocolProviderService protocolProvider = evt . getSourceChatRoom ( ) . getParentProvider ( ) ; historyString = processHistoryMessage ( GuiActivator . getUIService ( ) . getMainFrame ( ) . getAccountAddress ( protocolProvider ) , GuiActivator . getUIService ( ) . getMainFrame ( ) . getAccountDisplayName ( protocolProvider ) , evt . getTimestamp ( ) , Chat . HISTORY_OUTGOING_MESSAGE , evt . getMessage ( ) . getContent ( ) , evt . getMessage ( ) . getContentType ( ) , evt . getMessage ( ) . getMessageUID ( ) ) ; } else if ( o instanceof ChatRoomMessageReceivedEvent ) { ChatRoomMessageReceivedEvent evt = ( ChatRoomMessageReceivedEvent ) o ; if ( ! evt . getMessage ( ) . getMessageUID ( ) . equals ( escapedMessageID ) ) { historyString = processHistoryMessage ( evt . getSourceChatRoomMember ( ) . getContactAddress ( ) , evt . getSourceChatRoomMember ( ) . getName ( ) , evt . getTimestamp ( ) , Chat . HISTORY_INCOMING_MESSAGE , evt . getMessage ( ) . getContent ( ) , evt . getMessage ( ) . getContentType ( ) , evt . getMessage ( ) . getMessageUID ( ) ) ; } } else if ( o instanceof FileRecord ) { FileRecord fileRecord = ( FileRecord ) o ; if ( ! fileRecord . getID ( ) . equals ( escapedMessageID ) ) { FileHistoryConversationComponent component = new FileHistoryConversationComponent ( fileRecord ) ; conversationPanel . addComponent ( component ) ; } } if ( historyString != null ) conversationPanel . appendMessageToEnd ( historyString , ChatHtmlUtils . HTML_CONTENT_TYPE ) ; } fireChatHistoryChange ( ) ; }
Process history messages.
Process history messages .