Inheritance: System.EventArgs
Exemplo n.º 1
0
        private void OnChatMessageReceived(IntPtr chatPtr, IntPtr callChatPtr, string remoteUser, VATRPChatMessage chatMessage)
        {
            string dn, un, host;
            int port;
            if (callChatPtr == chatPtr /*&& RttEnabled*/)
            {
                return;
            }

            System.Windows.Threading.Dispatcher dispatcher = null;
            try
            {
               dispatcher = this._serviceManager.Dispatcher;
            }
            catch (NullReferenceException)
            {
                return;
            }

            if (dispatcher != null)
                dispatcher.BeginInvoke((Action) delegate()
                {
                    if (!VATRPCall.ParseSipAddressEx(remoteUser, out dn, out un,
                        out host, out port))
                        un = "";

                    if (!un.NotBlank())
                        return;

                    var contactAddress = string.Format("{0}@{1}", un, host);
                    var contactID = new ContactID(contactAddress, IntPtr.Zero);
                    VATRPContact contact = FindContact(contactID);

                    if (contact == null)
                    {
                        contact = new VATRPContact(contactID)
                        {
                            DisplayName = dn,
                            Fullname = dn.NotBlank() ? dn : un,
                            SipUsername = un,
                            RegistrationName = contactAddress
                        };
                        _contactSvc.AddContact(contact, "");
                        Contacts.Add(contact);
                        if (ContactAdded != null)
                            ContactAdded(this, new ContactEventArgs(new ContactID(contact)));
                    }

                    VATRPChat chat = GetChat(contact);
                    chat.NativePtr = chatPtr;

                    if (chat.CheckMessage(chatMessage))
                    {
                        chat.UnreadMsgCount++;
                        if (!chat.IsSelected)
                            contact.UnreadMsgCount++;
                        chatMessage.IsRTTMessage = false;
                        chatMessage.IsIncompleteMessage = false;
                        chatMessage.Chat = chat;
                        if (chatMessage.Content.StartsWith(VATRPChatMessage.DECLINE_PREFIX))
                        {
                            chatMessage.Content = chatMessage.Content.Substring(VATRPChatMessage.DECLINE_PREFIX.Length);

                            chatMessage.IsDeclineMessage = true;
                            if (ConversationDeclineMessageReceived != null)
                            {
                                var declineArgs = new DeclineMessageArgs(chatMessage.Content) { Sender = contact };
                                ConversationDeclineMessageReceived(this, declineArgs);
                            }
                        }

                        chat.AddMessage(chatMessage, false);
                        chat.UpdateLastMessage(false);

                        OnConversationUnReadStateChanged(chat);
                        this.OnConversationUpdated(chat, true);
                    }
                });
        }
        private void OnDeclineMessageReceived(object sender, DeclineMessageArgs args)
        {
            if (ServiceManager.Instance.Dispatcher.Thread != Thread.CurrentThread)
            {
                ServiceManager.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                    new EventHandler<DeclineMessageArgs>(OnDeclineMessageReceived) , sender, new object[] { args });
                return;
            }

            var newArgs = new DeclineMessageArgs(args.DeclineMessage);
            newArgs.Sender = args.Sender;
            if (DeclineMessageReceived != null)
                DeclineMessageReceived(sender, newArgs);
        }
Exemplo n.º 3
0
        private void OnDeclineMessageReceived(object sender, DeclineMessageArgs args)
        {
            var restartTimer = false;

            lock (_mainViewModel.CallsViewModelList)
            {
                if (_mainViewModel.ActiveCallModel != null)
                {
                    if (_mainViewModel.ActiveCallModel.Contact != null &&
                        _mainViewModel.ActiveCallModel.Contact.Equals(args.Sender))
                    {
                        _mainViewModel.ActiveCallModel.DeclinedMessage = args.DeclineMessage;
                        _mainViewModel.ActiveCallModel.DeclinedMessageHeader = args.MessageHeader;
                        switch (_mainViewModel.ActiveCallModel.CallState)
                        {
                            case VATRPCallState.Closed:
                            case VATRPCallState.Declined:
                                // ToDo VATRP-3878
                            //_mainViewModel.ActiveCallModel.ShowInfoMessage = false;
                            //_mainViewModel.ActiveCallModel.ShowDeclinedMessage = true;
                            ctrlCall.ctrlOverlay.ShowInfoMsgWindow(false);
                                restartTimer = true;
                                break;
                            case VATRPCallState.Connected:
                            case VATRPCallState.StreamsRunning:
                                // ToDo VATRP-3878
                                //_mainViewModel.ActiveCallModel.ShowInfoMessage = true;
                                // RearrangeUICallView(GetCallViewSize());
                                //ctrlCall.ctrlOverlay.UpdateInfoMsg(args.MessageHeader, args.DeclineMessage);
                                //ctrlCall.ctrlOverlay.ShowInfoMsgWindow(this.WindowState != WindowState.Minimized);
                                //_mainViewModel.ActiveCallModel.DeferredHideMessageControl();
                                return;
                        }
                    }
                }
                else
                {
                    restartTimer = true;
                }
            }

            if (!restartTimer)
                return;
            lock (deferredLock)
            {
                if (_mainViewModel.ActiveCallModel != null)
                    _mainViewModel.ActiveCallModel.WaitForDeclineMessage = false;
                deferredHideTimer.Stop();
                deferredHideTimer.Interval = TimeSpan.FromMilliseconds(DECLINE_WAIT_TIMEOUT);
                deferredHideTimer.Start();
            }
        }