Пример #1
0
        /// <summary>
        /// Callback called by LinphoneCore when the state of a sent message changes.
        /// </summary>
        public void MessageStateChanged(LinphoneChatMessage message, LinphoneChatMessageState state)
        {
            Logger.Msg("[Chat] Message state changed: " + state.ToString());

            Dispatcher.BeginInvoke(() =>
            {
                if (ProgressPopup.Visibility == Visibility.Visible)
                {
                    ProgressPopup.Visibility = Visibility.Collapsed;
                    MessageBox.Visibility    = Visibility.Visible;
                    AddSendButtonsToAppBar();
                }

                if (state == LinphoneChatMessageState.InProgress)
                {
                    // Create the chat bubble for both text or image messages
                    OutgoingChatBubble bubble = new OutgoingChatBubble(message);
                    bubble.MessageDeleted    += bubble_MessageDeleted;
                    MessagesList.Children.Insert(MessagesList.Children.Count - 1, bubble);
                    scrollToBottom();
                }
                else if (state == LinphoneChatMessageState.FileTransferDone && !message.IsOutgoing)
                {
                    try
                    {
                        message.AppData   = message.FileTransferFilePath;
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((IncomingChatBubble)bubble).RefreshImage();
                        }
                        EnableDownloadButtons(true);
                    }
                    catch { }
                }
                else
                {
                    // Update the outgoing status of the message
                    try
                    {
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((OutgoingChatBubble)bubble).UpdateStatus(state);
                        }
                    }
                    catch { }
                }

                if (chatRoom != null)
                {
                    chatRoom.MarkAsRead();
                }
            });
        }
        /// <summary>
        /// Changes the icon indicating the status of the message (InProgress, Delivered or NotDelivered).
        /// </summary>
        public void UpdateStatus(LinphoneChatMessageState state)
        {
            string delivered = "/Assets/AppBar/check.png";
            string notdelivered = "/Assets/AppBar/stop.png";

            if (state == LinphoneChatMessageState.Delivered)
            {
                Status.Source = new BitmapImage(new Uri(delivered, UriKind.RelativeOrAbsolute));
            }
            else if (state == LinphoneChatMessageState.NotDelivered)
            {
                Status.Source = new BitmapImage(new Uri(notdelivered, UriKind.RelativeOrAbsolute));
            }
        }
Пример #3
0
        /// <summary>
        /// Changes the icon indicating the status of the message (InProgress, Delivered or NotDelivered).
        /// </summary>
        public void UpdateStatus(LinphoneChatMessageState state)
        {
            string delivered    = "/Assets/AppBar/check.png";
            string notdelivered = "/Assets/AppBar/stop.png";

            if (state == LinphoneChatMessageState.Delivered)
            {
                Status.Source = new BitmapImage(new Uri(delivered, UriKind.RelativeOrAbsolute));
            }
            else if (state == LinphoneChatMessageState.NotDelivered)
            {
                Status.Source = new BitmapImage(new Uri(notdelivered, UriKind.RelativeOrAbsolute));
            }
        }
Пример #4
0
        private void OnMessageStatusChanged(IntPtr msgPtr, LinphoneChatMessageState state)
        {
            if (linphoneCore == IntPtr.Zero) return;

            lock (messagingLock)
            {
                if (OnChatMessageStatusChangedEvent != null)
                    OnChatMessageStatusChangedEvent(msgPtr, state);
            }
        }
Пример #5
0
 internal void SetStatusLastMessageInActiveChat(VATRPContact contact, string msgText, LinphoneChatMessageState status)
 {
     if ((msgText != null) && (contact != null))
     {
         VATRPChat chat = this.FindChat(contact);
         if ((((chat != null) && ((chat.Messages != null) && (chat.Messages.Count != 0))) &&
              msgText.Equals(chat.Messages[chat.Messages.Count - 1])) &&
             (status > chat.Messages[chat.Messages.Count - 1].Status))
         {
             chat.Messages[chat.Messages.Count - 1].Status = status;
         }
     }
 }
Пример #6
0
 internal void SetStatusForMessage(VATRPContact contact, string msgId, LinphoneChatMessageState status)
 {
     if (msgId.NotBlank())
     {
         if (contact != null)
         {
             VATRPChat chat = this.FindChat(contact);
             if ((chat != null) && msgId.NotBlank())
             {
                 foreach (VATRPChatMessage message in chat.Messages)
                 {
                     if (message.ID == msgId)
                     {
                         if (status > message.Status)
                         {
                             message.Status = status;
                         }
                         break;
                     }
                 }
             }
         }
         else
         {
             using (IEnumerator<VATRPChat> enumerator2 = this._chatItems.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     foreach (VATRPChatMessage message2 in enumerator2.Current.Messages)
                     {
                         if (message2.ID == msgId)
                         {
                             if (status > message2.Status)
                             {
                                 message2.Status = status;
                             }
                             return;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #7
0
 private void OnChatStatusChanged(IntPtr chatMsgPtr, LinphoneChatMessageState state)
 {
     System.Windows.Threading.Dispatcher dispatcher = null;
     try
     {
         dispatcher = this._serviceManager.Dispatcher;
     }
     catch (NullReferenceException)
     {
         return;
     }
     if (dispatcher != null)
         dispatcher.BeginInvoke((Action) delegate()
         {
             lock (this._chatItems)
             {
                 foreach (var chatItem in this._chatItems)
                 {
                     var chatMessage = chatItem.FindMessage(chatMsgPtr);
                     if (chatMessage != null)
                     {
                         chatMessage.Status = state;
                         return;
                     }
                 }
             }
         });
 }
Пример #8
0
 public static extern IntPtr linphone_chat_room_create_message_2(IntPtr cr, string message,
     string external_body_url, LinphoneChatMessageState state, uint time, bool is_read, bool is_incoming);
Пример #9
0
 public static extern IntPtr linphone_chat_message_state_to_string(LinphoneChatMessageState state);
Пример #10
0
        /// <summary>
        /// Callback called by LinphoneCore when the state of a sent message changes.
        /// </summary>
        public void MessageStateChanged(LinphoneChatMessage message, LinphoneChatMessageState state)
        {
            Logger.Msg("[Chat] Message state changed: " + state.ToString());

            Dispatcher.BeginInvoke(() =>
            {
                if (ProgressPopup.Visibility == Visibility.Visible)
                {
                    ProgressPopup.Visibility = Visibility.Collapsed;
                    MessageBox.Visibility = Visibility.Visible;
                    AddSendButtonsToAppBar();
                }

                if (state == LinphoneChatMessageState.InProgress)
                {
                    // Create the chat bubble for both text or image messages
                    OutgoingChatBubble bubble = new OutgoingChatBubble(message);
                    bubble.MessageDeleted += bubble_MessageDeleted;
                    MessagesList.Children.Insert(MessagesList.Children.Count - 1, bubble);
                    scrollToBottom();
                }
                else if (state == LinphoneChatMessageState.FileTransferDone && !message.IsOutgoing)
                {
                    try
                    {
                        message.AppData = message.FileTransferFilePath;
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((IncomingChatBubble)bubble).RefreshImage();
                        }
                        EnableDownloadButtons(true);
                    }
                    catch { }
                }
                else
                {
                    // Update the outgoing status of the message
                    try
                    {
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((OutgoingChatBubble)bubble).UpdateStatus(state);
                        }
                    }
                    catch { }
                }

                if (chatRoom != null)
                {
                    chatRoom.MarkAsRead();
                }
            });
        }