예제 #1
0
        // Входящий звонок
        private void softphone_IncomingCallEvent(Call incomingCall)
        {
            // Reject incoming call, if we have active
            if (this.call != null)
            {
                Softphone.TerminateCall(incomingCall);

                // write rejected call to base
                RecordToLocalDataBase.Phone      = GetPhone(incomingCall.From);
                RecordToLocalDataBase.TimeStart  = DateTime.Now;
                RecordToLocalDataBase.isRejected = true;

                return;
            }
            ;

            // set flag
            isIncoming = true;
            // Recieve incoming call
            this.call = incomingCall;

            //Echo cancellation
            Softphone.EchoCancellation(this.call, Settings.isEchoOff);

            string phone  = GetPhone(this.call.From);
            string callId = GetCallId(this.call.From);

            InvokeGUIThread(() =>
            {
                dialog = new IncomingDialog();
                // show incoming call dialog
                dialog.Call      = this.call;
                dialog.SoftPhone = Softphone;
                dialog.UpdateTextPanel(phone, callId);

                dialog.Show();

                // change icon to incoming call
                this.txtStatus.Text  = "Занят";
                lblStatusRecord.Text = "Входящий";
                PhoneIcon.SetResourceReference(Image.SourceProperty, "decline");
                StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available");
                this.btnConnectOrReject.Background = Brushes.Red;
            });

            // Play Sound
#pragma warning disable CS0103 // The name 'Properties' does not exist in the current context
#pragma warning disable CS0103 // The name 'Properties' does not exist in the current context
            Classes.LocalAudioPlayer.PlaySound(Properties.Resources.signal, true);
#pragma warning restore CS0103 // The name 'Properties' does not exist in the current context
#pragma warning restore CS0103 // The name 'Properties' does not exist in the current context

            // record call info
            RecordToLocalDataBase.Phone     = phone;
            RecordToLocalDataBase.TimeStart = DateTime.Now;

            // Get information about caller
            GetInfoAboutCaller(call.From);
        }
예제 #2
0
 private void softphone_PhoneDisconnectedEvent()
 {
     InvokeGUIThread(() =>
     {
         //set unavailable icon and text message
         StatusIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "presenceNotAvailable");
         txtStatus.Text = "Нет подключения!";
     });
 }
예제 #3
0
        // Звонок завершился
        private void softphone_CallCompletedEvent(Call call)
        {
            if (isIncoming)
            {
                // drop down Incoming call form
                InvokeGUIThread(() =>
                {
                    // Close borderCallNotification
                    CloseCallNotification();

                    // hide incoming call dialog
                    if (dialog != null)
                    {
                        dialog.Close();
                        dialog = null;
                    }

                    // add badge value to history button
                    int value            = string.IsNullOrEmpty(viewModel.BadgeValue) ? 0 : Convert.ToInt32(viewModel.BadgeValue);
                    viewModel.BadgeValue = (++value).ToString();
                });
            }

            // write to database
            RecordToLocalDataBase.isOutcoming = isOutcoming;
            RecordToLocalDataBase.isIncoming  = isIncoming;
            RecordToLocalDataBase.TimeEnd     = DateTime.Now;
            Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase);

            // clear flags
            isIncoming  = false;
            isOutcoming = false;

            this.call = null;

            InvokeGUIThread(() =>
            {
                txtStatus.Text = "Свободно";
                PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer");
                StatusIcon.SetResourceReference(Image.SourceProperty, "presenceAvailable");
                btnConnectOrReject.Background = Brushes.Green;

                CloseCallNotification();

                // discard blur effect to infoPanel
                if (borderCallNotification.BitmapEffect != null)
                {
                    borderCallNotification.BitmapEffect = null;
                    borderCallNotification.Background   = null;
                }
            });

            Classes.LocalAudioPlayer.PlaySound(Properties.Resources.notification_call_ended);
        }
예제 #4
0
 private void softphone_PhoneConnectedEvent()
 {
     InvokeGUIThread(() =>
     {
         //set available icon and text message
         PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "answer");
         this.btnConnectOrReject.Background = Brushes.Green;
         StatusIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "presenceAvailable");
         txtStatus.Text = "Подключен!";
     });
 }
예제 #5
0
        // Звонок принят или исходящий
        private void softphone_CallActiveEvent(Call call)
        {
            if (isIncoming)
            {
                // sound notification off
                Classes.LocalAudioPlayer.StopSound();

                if (dialog != null)
                {
                    dialog.Close();
                }

                // write incoming call to base
                RecordToLocalDataBase.Phone      = GetPhone(call.From);
                RecordToLocalDataBase.TimeStart  = DateTime.Now;
                RecordToLocalDataBase.isRejected = false;
            }
            else
            {
                this.call = call;
                // set outcoming call flag
                isOutcoming = true;

                // Disable echo
                Softphone.EchoCancellation(this.call, Settings.isEchoOff);
                string phone = GetPhone(call.To);

                //show caller info
                GetInfoAboutCaller(call.To);

                InvokeGUIThread(() =>
                {
                    txtStatus.Text       = "Занят";
                    lblStatusRecord.Text = "Исходящий";
                    PhoneIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "decline");
                    StatusIcon.SetResourceReference(Image.SourceProperty, "presence_not_available");
                    btnConnectOrReject.Background = Brushes.Red;
                });

                // set volume
                Softphone.SetSpeakerValue(this.call, (float)volumeSliderValue);

                // db record
                RecordToLocalDataBase.Phone       = phone;
                RecordToLocalDataBase.isOutcoming = true;
                RecordToLocalDataBase.TimeStart   = DateTime.Now;
                //Classes.SQLiteBase.AddRecordToDataBase(RecordToLocalDataBase);
            }
        }
예제 #6
0
        private void softphone_ErrorEvent(Call call, Phone.Error error)
        {
            switch (error)
            {
            case Phone.Error.CallError:
                InvokeGUIThread(() =>
                {
                    txtStatus.Text = "Ошибка вызова!";
                });
                break;

            case Phone.Error.LineIsBusyError:
                InvokeGUIThread(() =>
                {
                    txtStatus.Text = "Линия занята!";
                });
                break;

            case Phone.Error.OrderError:
            {
            }
            break;

            case Phone.Error.RegisterFailed:
            {
                InvokeGUIThread(() =>
                    {
                        //set unavailable icon and text message
                        StatusIcon.SetResourceReference(System.Windows.Controls.Image.SourceProperty, "presenceNotAvailable");
                        txtStatus.Text = "Нет подключения!";
                    });
            }
            break;

            case Phone.Error.UnknownError:
            {
                InvokeGUIThread(() =>
                    {
                        txtStatus.Text = "Неизвестная ошибка!";
                    });
            }
            break;
            }
        }