Beispiel #1
0
        public void AddMessage(Tags.jabber.client.message message)
        {
            JID    senderJid = new JID(message.from);
            string sender    = null;

            // Get the contact the message is from
            if (senderJid.Bare == Self)
            {
                sender = Self;
            }
            else if (senderJid.Bare == Other)
            {
                sender = Other;
            }
            else
            {
                return;
            }

            // The conversationitem we will be adding items to
            ConversationItem current = null;

            // Look if we have to add a new item or reuse an old one
            if (Items.Count > 0)
            {
                ConversationItem last = Items.First();
                if (last != null && last.Identifier == senderJid) // The last item is from the same sender as this item
                {
                    if (last.Messages.Count > 0)                  // It has messages
                    {
                        ConversationMessage lastMessage = last.Messages.Last();
                        if ((message.Timestamp - lastMessage.Timestamp).Minutes < 1) // The last messag is no older than two minutes
                        {
                            current = last;
                        }
                    }
                    else // It has no messages, we don't know why but we should add our items to it because an emtpy item looks bad
                    {
                        current = last;
                    }
                }
            }

            if (current == null)
            {
                current = new ConversationItem(new ConversationSender(Self, sender), senderJid, message.Timestamp);
                Items.Insert(0, current);
            }

            current.AddMessage(message);
        }
Beispiel #2
0
        public void AddMessage(Tags.jabber.client.message message)
        {
            JID senderJid = new JID(message.from);
            string sender = null;
            
            // Get the contact the message is from
            if( senderJid.Bare == Self )
                sender = Self;
            else if( senderJid.Bare == Other )
                sender = Other;
            else
                return;

            // The conversationitem we will be adding items to
            ConversationItem current = null;

            // Look if we have to add a new item or reuse an old one
            if (Items.Count > 0)
            {
                ConversationItem last = Items.First();
                if (last != null && last.Identifier == senderJid) // The last item is from the same sender as this item
                {
                    if (last.Messages.Count > 0) // It has messages
                    {
                        ConversationMessage lastMessage = last.Messages.Last();
                        if ((message.Timestamp - lastMessage.Timestamp).Minutes < 1) // The last messag is no older than two minutes
                            current = last;
                    }
                    else // It has no messages, we don't know why but we should add our items to it because an emtpy item looks bad
                    {
                        current = last;
                    }
                }
            }

            if (current == null)
            {
                current = new ConversationItem(new ConversationSender(Self, sender), senderJid, message.Timestamp);
                Items.Insert(0, current);
            }

            current.AddMessage(message);
        }