Exemplo n.º 1
0
        /// <summary>
        /// Equality comparer.
        /// </summary>
        /// <param name="obj">Meant to be other PhoneCallInfo object.</param>
        /// <returns>Returns true if the two objects are equal, otherwise false.</returns>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            PhoneCallInfo other = obj as PhoneCallInfo;

            if (other == null)
            {
                return(false);
            }

            return
                (CallID.Equals(other.CallID) &&
                 PhoneLineInfo.Equals(other.PhoneLineInfo));
        }
Exemplo n.º 2
0
 private void AddCallToHistory(PhoneLineInfo line, string dial, CallDirection type)
 {
     PhoneCallInfo info = new PhoneCallInfo(line, dial, type);
     softphoneEngine.AddCallToHistory(info);
     lbCallHistory.Items.Add(info);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Incoming call has been cancelled.
        /// </summary>
        /// <param name="call"></param>
        public void IncomingCallCancelled(PhoneCallInfo call)
        {
            ActualIncomingCall = null;

            BeginInvoke((Action)(() =>
            {
                SetGUIState(new LineAndNoCall(this));
                tbDialNumber.Text = string.Empty;
            }));
            string logMsg = string.Format("Incoming call {0} has been cancelled [line: {1}]", call.Dial, call.PhoneLineInfo);
            LogEvent(logMsg);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Displays incoming call.
        /// </summary>
        /// <param name="call">The incoming call.</param>
        public void IncomingCall(PhoneCallInfo call)
        {
            if (call.Direction == CallDirection.Outgoing)
                return;

            if (InvokeRequired)
            {
                BeginInvoke((Action<MainForm, PhoneCallInfo>)((t, e1) => t.IncomingCall(e1)), this, call);
                return;
            }

            if (ActualIncomingCall != null)
            {
                softphoneEngine.RejectCall(call);
                ActualIncomingCall = null;
                ItsDisplay.Text = string.Empty;
            }

            ActualIncomingCall = call;
            ItsDisplay.Text = call.ToString();
            tbPhoneStatus.Text = "Incoming call!";

            string logMsg = string.Format("Incoming call from {0} [line: {1}]", call.Dial, call.PhoneLineInfo);
            LogEvent(logMsg);

            AddCallToHistory(call.PhoneLineInfo, call.Dial, call.Direction);

            SetGUIState(new IncommingCall(this));

            if (AutoAcceptCalls)
                currentState.PickUpPressed();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Displays call state information for the given call.
        /// </summary>
        /// <param name="callInfo">The call object.</param>
        /// <param name="callState">The state of the call.</param>
        public void CallStateInfo(PhoneCallInfo callInfo, CallState callState)
        {
            if (InvokeRequired)
            {
                BeginInvoke((Action<MainForm, PhoneCallInfo, CallState>)((t, c, c1) => t.CallStateInfo(c, c1)), this, callInfo, callState);
                return;
            }

            PhoneCallInfo selectedCall = SelectedCall;
            if (selectedCall == null)
                return;

            if (!selectedCall.Equals(callInfo))
                return;

            switch (callState)
            {
                case CallState.InCall:
                    btnHold.Text = "Hold";
                    btnHold.Enabled = true;
                    videoViewerRemote.Start();
                    break;
                case CallState.LocalHeld:
                    btnHold.Text = "Unhold";
                    break;
                case CallState.RemoteHeld:
                    btnHold.Text = "Holded";
                    btnHold.Enabled = false;
                    break;
                case CallState.Completed:
                    softphoneEngine.StopCamera(callInfo);
                    videoViewerLocal.Stop();
                    videoViewerRemote.Stop();
                    StopRecord();
                    break;
            }

            tbPhoneStatus.Text = "Call " + callInfo.Dial + " is " + callState + ".";
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reject the incoming call described by the information.
        /// </summary>
        /// <param name="callInfo">The associated call info.</param>
        public void RejectCall(PhoneCallInfo callInfo)
        {
            if (disposed)
                return;

            if (callInfo.Direction == CallDirection.Outgoing)
                return;

            IPhoneCall call = null;
            if (incomingCallsBijection.ContainsKey(callInfo))
                call = incomingCallsBijection.Get(callInfo);

            if (call == null)
                return;

            /* Once the SoftPhoneEngine rejects a phone call, that call is not an incoming call anymore, if its state
             * changes, the call_CallStateChanged event handler will activate.
             * */
            incomingCallsBijection.RemoveBijection(callInfo);
            call.Reject();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set the phone call to be active.
        /// </summary>
        /// <param name="callInfo">The associated call info.</param>
        /// <remarks>
        /// The active call has the focus of sound devices.
        /// </remarks>
        public void SetActiveCall(PhoneCallInfo callInfo)
        {
            if (disposed)
                return;

            if (!phoneCallsBijection.ContainsKey(callInfo))
                return;

            IPhoneCall call = phoneCallsBijection.Get(callInfo);

            if (call == null)
                return;

            SetActiveCall(call);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Hang up the call associated to given information.
        /// </summary>
        /// <param name="callInfo">Provided information about phone call.</param>
        public void HangUpCall(PhoneCallInfo callInfo)
        {
            if (disposed)
                return;

            IPhoneCall call = null;
            if (!phoneCallsBijection.ContainsKey(callInfo))
                return;

            call = phoneCallsBijection.Get(callInfo);
            if (call == null)
                return;

            /* Ask the call to hang up, there are many thing here to do,
             * once when it is successful the engine will get an event of the call
             * and the call_CallStateChanged event handler will activate.
             * */
            call.HangUp();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Hold the described call.
        /// </summary>
        /// <param name="callInfo">Provided information about phone call.</param>
        public void HoldCall(PhoneCallInfo callInfo)
        {
            IPhoneCall call = phoneCallsBijection.Get(callInfo);
            if (call == null)
                return;

            call.ToggleHold();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Transfer call described by the information.
        /// </summary>
        /// <param name="callInfo">The associated call info.</param>
        /// <param name="target"></param>
        public void BlindTransfer(PhoneCallInfo callInfo, string target)
        {
            if (!phoneCallsBijection.ContainsKey(callInfo))
                return;

            var call = phoneCallsBijection.Get(callInfo);

            call.BlindTransfer(target);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get the state of call.
        /// </summary>
        /// <param name="callInfo">The call object.</param>
        /// <returns>Null if the call couldn't be found, otherwise its state.</returns>
        public CallState? GetCallState(PhoneCallInfo callInfo)
        {
            IPhoneCall call = phoneCallsBijection.Get(callInfo);
            if (call == null)
                return null;

            return call.CallState;
        }
Exemplo n.º 12
0
        public void AttendedTransfer(PhoneCallInfo callInfo, PhoneCallInfo targetInfo)
        {
            if(!phoneCallsBijection.ContainsKey(callInfo))
               return;

            if(!phoneCallsBijection.ContainsKey(targetInfo))
                return;

            var call = phoneCallsBijection.Get(callInfo);

            var target = phoneCallsBijection.Get(targetInfo);

            call.AttendedTransfer(target);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Adds some information about the call to the call history
 /// </summary>
 /// <param name="info">The specified information</param>
 public void AddCallToHistory(PhoneCallInfo info)
 {
     callHistory.Add(info);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Ends DTMF signal transmitting
        /// </summary>
        /// <param name="callInfo">The phone call.</param>
        /// <param name="dtmf">The DTMF signal</param>
        public void StopDTMFSignal(PhoneCallInfo callInfo, int dtmf)
        {
            IPhoneCall call = phoneCallsBijection.Get(callInfo);
            if (call == null)
                return;

            call.StopDTMFSignal((DtmfNamedEvents)dtmf);
        }
Exemplo n.º 15
0
        public void StopCamera(PhoneCallInfo callInfo)
        {
            if (disposed || camera == null)
                return;
            camera.Stop();

            if (callInfo== null)
                return;
            IPhoneCall call = null;
            if (!phoneCallsBijection.ContainsKey(callInfo))
                return;

            call = phoneCallsBijection.Get(callInfo);
            if (call == null)
                return;
            activeVideoCallListener.Stop();

            call.ModifyCallType(CallType.Audio);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Starts a call on the phone line described by phone line info.
        /// </summary>
        /// <param name="phoneLineInfo">The information about the phone line.</param>
        /// <param name="dial">The dialed number.</param>
        public void StartCall(PhoneLineInfo phoneLineInfo, string dial)
        {
            if (disposed)
                return;

            PhoneCallInfo callInfo = new PhoneCallInfo(phoneLineInfo, dial, CallDirection.Outgoing);
            if (phoneCallsBijection.ContainsKey(callInfo))
                return;

            if (!PhoneLinesBijection.ContainsKey(phoneLineInfo))
                return;

            IPhoneLine line = PhoneLinesBijection.Get(phoneLineInfo);
            if (line == null)
                return;

            /* When a call is created and started, the state of call is going to
             * change over time. The SoftphoneEngine needs to subscribe
             * itself to this component before start the call.
             * */
            IPhoneCall call = softPhone.CreateCallObject(line, dial);
            call.CallStateChanged += call_CallStateChanged;
            call.CallErrorOccured += call_CallErrorOccured;
            call.Start();
        }