Exemplo n.º 1
0
        private void CallInternal(StartPhoneCallCommand number, bool forceActivateLineWrapper = false)
        {
            try
            {
                var call = _core.CallManager.MakeCall(number.Destination, number.Attributes);
                if (call == null)
                {
                    TimeredBaloon.Show(txtNumber, CaptionStrings.CaptionStrings.ErrorNoAvailableLinesTitle, CaptionStrings.CaptionStrings.ErrorNoAvailableLinesDescription, ToolTipIcon.Error);
                }
                else
                {
                    if (call.Line < 5)
                    {
                        _mainFormPhoneLineControls[call.Line].Call = call;
                    }

                    if (forceActivateLineWrapper)
                    {
                        ChangeLineWrapper(_mainFormPhoneLineControls[call.Line]);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogWarn(e);
            }
        }
Exemplo n.º 2
0
        void CallManager_OnCallRemoved(ICall call, CallRemoveReason reason)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new CallRemovedDelegate(CallManager_OnCallRemoved), call, reason);

                return;
            }

            if (reason == CallRemoveReason.InvalidData)
            {
                TimeredBaloon.Show(txtNumber, CaptionStrings.CaptionStrings.ErrorWrongNumberTitle, CaptionStrings.CaptionStrings.ErrorWrongNumberDescription, ToolTipIcon.Error, 4000);
            }
            else if (reason == CallRemoveReason.Busy)
            {
                TimeredBaloon.Show(txtNumber, CaptionStrings.CaptionStrings.ErrorBusyTitle, CaptionStrings.CaptionStrings.ErrorBusyDescription, ToolTipIcon.Info, 4000);
            }
            else if ((reason == CallRemoveReason.RemoteHangup || reason == CallRemoveReason.UserHangup || reason == CallRemoveReason.Transfer) && call != null && call.LastState == CallState.ACTIVE)
            {
                var currentLineWrapper = GetActiveUILineWrapper();

                // Normal call stop. Try to activate another call.
                if (currentLineWrapper?.Call == null)
                {
                    ActivateNextLineWrapper();
                }
            }

            UpdateAccountStateUi(Core);
        }
Exemplo n.º 3
0
        private void btnCall_Click(object sender, EventArgs e)
        {
            if (Core.Sip.Account.RegisterState != SipAccountState.Online)
            {
                TimeredBaloon.Show(txtNumber, CaptionStrings.CaptionStrings.ErrorDisconnectedTitle, CaptionStrings.CaptionStrings.ErrorDisconnectedDescription, ToolTipIcon.Error, 3500);

                return;
            }
            if (Core.Audio.PlaybackDevice == null || Core.Audio.RecordingDevice == null)
            {
                TimeredBaloon.Show(txtNumber, CaptionStrings.CaptionStrings.ErrorNoAudioDevices, Core.Audio.PlaybackDevice == null ? CaptionStrings.CaptionStrings.ErrorNoPlaybackDevice : CaptionStrings.CaptionStrings.ErrorNoRecordingDevice, ToolTipIcon.Error, 3500);

                return;
            }

            var lineWrapper = GetActiveUILineWrapper();

            if (lineWrapper.Call != null)
            {
                if (lineWrapper.Call.State != CallState.ACTIVE &&
                    !TransferMode &&
                    txtNumber.Text == lineWrapper.Call.Number)
                {
                    if (lineWrapper.Call.State != CallState.HOLDING)
                    {
                        Logger.LogNotice("Trying to answer call: " + lineWrapper.Call);
                        lineWrapper.Call.Answer();
                    }
                    else
                    {
                        Logger.LogNotice("Trying to answer call: " + lineWrapper.Call);
                        lineWrapper.Call.UnHold();
                    }
                }
                else if (TransferMode && !string.IsNullOrEmpty(txtNumber.Text) &&
                         (lineWrapper.Call.State == CallState.HOLDING ||
                          lineWrapper.Call.State == CallState.ACTIVE))
                {
                    // Transfer Call
                    string number = txtNumber.Text;
                    Logger.LogNotice($"Transfer call '{lineWrapper.Call}' to '{number}'");

                    Task.Factory.StartNew(() =>
                    {
                        lineWrapper.Call.UnHold();
                        lineWrapper.Call.Transfer(number);

                        lineWrapper.Call.Drop();
                    });

                    TransferMode = false;

                    TimeredBaloon.Show(txtNumber, string.Format(CaptionStrings.CaptionStrings.ActionTransferTitle, number), CaptionStrings.CaptionStrings.ActionTransferDescription, ToolTipIcon.Info);
                }
                else if (
                    lineWrapper.Call.State != CallState.ACTIVE &&
                    lineWrapper.Call.Number != txtNumber.Text &&
                    !TransferMode)
                {
                    CallInternal(txtNumber.Text, true);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(txtNumber.Text))
                {
                    CallInternal(txtNumber.Text);
                }
            }
        }