Esempio n. 1
0
        public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
        {
            switch (te)
            {
            case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
                addtolist("call notification event has occured");
                ITCallNotificationEvent notify;
                notify = (ITCallNotificationEvent)eobj;
                ITCallInfo newcall;
                newcall = notify.Call;
                ITBasicCallControl call_control;                        //=f1.call_control;
                call_control = (ITBasicCallControl)newcall;
                string callerid = newcall.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);                                 if (MessageBox.Show("calling from " + callerid + "\n\n Press Ok to Attend Call    /   Cancel to Reject the Call\n", "Answer", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    IEnumStream     enum_stream;
                    ITStreamControl pstream_control;
                    pstream_control = (ITStreamControl)call_control;
                    pstream_control.EnumerateStreams(out enum_stream);
                    ITStream p_stream;
                    uint     a11 = 0;
                    enum_stream.Next(1, out p_stream, ref a11);
                    int imedia;
                    imedia = p_stream.MediaType;
                    TERMINAL_DIRECTION dir;
                    dir = p_stream.Direction;
                    ITTerminal termi, termi1;

                    ITTerminalSupport term_support = (ITTerminalSupport)Form1.call_address;
                    termi = term_support.GetDefaultStaticTerminal(imedia, dir);

                    p_stream.SelectTerminal(termi);

                    enum_stream.Next(1, out p_stream, ref a11);
                    termi1 = term_support.GetDefaultStaticTerminal(imedia, TERMINAL_DIRECTION.TD_CAPTURE);

                    p_stream.SelectTerminal(termi1);

                    call_control.Answer();
                }

                else
                {
                    call_control.Disconnect(DISCONNECT_CODE.DC_REJECTED);
                }
                ///////
                break;

            case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
                TAPI3Lib.ITDigitDetectionEvent dd = (TAPI3Lib.ITDigitDetectionEvent)eobj;
                addtolist("Dialed digit" + dd.ToString());
                break;

            case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
                TAPI3Lib.ITDigitGenerationEvent dg = (TAPI3Lib.ITDigitGenerationEvent)eobj;
                addtolist("Dialed digit" + dg.ToString());
                break;

            case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
                addtolist("A phone event!");
                break;

            case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
                addtolist("Gather digit event!");
                break;

            case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
                TAPI3Lib.ITCallStateEvent a = (TAPI3Lib.ITCallStateEvent)eobj;
                TAPI3Lib.ITCallInfo       b = a.Call;
                switch (b.CallState)
                {
                case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
                    addtolist("dialing");
                    break;

                case TAPI3Lib.CALL_STATE.CS_CONNECTED:
                    addtolist("Connected");
                    break;

                case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
                    addtolist("Disconnected");
                    break;

                case TAPI3Lib.CALL_STATE.CS_OFFERING:
                    addtolist("A party wants to communicate with you!");
                    break;

                case TAPI3Lib.CALL_STATE.CS_IDLE:
                    addtolist("Call is created!");
                    break;
                }
                break;
            }
        }
        private void CallStateEvent()
        {
            // here we should check to see call state and handle connects and disconnects

            try
            {
                switch (CallStateObject.State)
                {
                case CALL_STATE.CS_IDLE:

                    break;

                case CALL_STATE.CS_INPROGRESS:
                    //TAPI3Lib.ITCallInfo bi = CallStateObject.Call;
                    //if (bi.CallState == TAPI3Lib.CALL_STATE.CS_INPROGRESS)
                    //{


                    //}
                    break;

                case CALL_STATE.CS_OFFERING:
                    //     break;
                    // a call is offering so if you dont want it then pass it


                    if (ReceiveNotificationOnConnected == false)
                    {
                        TAPI3Lib.ITCallInfo b = CallStateObject.Call;

                        if (b.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING)
                        {
                            System.Threading.Thread.Sleep(2000);


                            string callerid = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                            string line     = b.Address.AddressName;


                            if (OnInComingCallNotification != null)
                            {
                                OnInComingCallNotification(callerid, line, false);
                            }
                        }
                    }
                    break;


                case CALL_STATE.CS_CONNECTED:


                    //if (ReceiveNotificationOnConnected)
                    //{
                    //    try
                    //    {

                    //        //TAPI3Lib.ITCallInfo bi3 = CallStateObject.Call;

                    //        new TaxiDataContext().stp_AddLog("Last Call Connected on : " + CallStateObject.Call.Address.AddressName.ToString(),"","");

                    //        //if (bi3.CallState == TAPI3Lib.CALL_STATE.CS_CONNECTED)
                    //        //{
                    //        //    System.Threading.Thread.Sleep(500);


                    //        //    string callerid = bi3.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                    //        //    string line = bi3.Address.AddressName;
                    //        //    if (OnInComingCallNotification != null)
                    //        //    {
                    //        //        OnInComingCallNotification(callerid, line, true);
                    //        //    }

                    //        //}
                    //    }
                    //    catch (Exception ex)
                    //    {


                    //    }
                    //}
                    break;


                // call is connected

                case CALL_STATE.CS_QUEUED:
                    break;
                // call is beeing queued

                case CALL_STATE.CS_HOLD:
                    break;
                // call is on hold

                case CALL_STATE.CS_DISCONNECTED:

                    if (ReceiveNotificationOnConnected)
                    {
                        try
                        {
                            TAPI3Lib.ITCallInfo bi4 = CallStateObject.Call;

                            //   System.Threading.Thread.Sleep(500);


                            string callerid = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                            string line     = bi4.Address.AddressName;
                            if (OnInComingCallNotification != null)
                            {
                                OnInComingCallNotification(callerid, line, true);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    break;
                    // call is disconnected
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
                //   Application.Exit();
            }
        }
Esempio n. 3
0
        private void CallStateEvent()
        {
            // here we should check to see call state and handle connects and disconnects

            try
            {
                switch (CallStateObject.State)
                {
                case CALL_STATE.CS_IDLE:

                    break;

                case CALL_STATE.CS_INPROGRESS:
                    break;

                case CALL_STATE.CS_OFFERING:



                    TAPI3Lib.ITCallInfo b = CallStateObject.Call;

                    if (b.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING)
                    {
                        System.Threading.Thread.Sleep(2000);


                        string callerid     = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                        string line         = b.Address.DialableAddress.ToStr().Trim();
                        string calledNumber = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
                        //    string calledNumber = string.Empty;

                        if (OnInComingCallNotification != null)
                        {
                            OnInComingCallNotification(callerid, line, false, "ring", calledNumber);
                        }
                    }

                    break;


                case CALL_STATE.CS_CONNECTED:


                    if (ReceiveNotificationOnConnected)
                    {
                        try
                        {
                            TAPI3Lib.ITCallInfo bi4 = CallStateObject.Call;
                            string callerid         = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER);
                            string line             = bi4.Address.DialableAddress.ToStr().Trim();
                            string calledNumber     = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
                            //    string calledNumber = string.Empty;

                            if (OnInComingCallNotification != null)
                            {
                                OnInComingCallNotification(callerid, line, true, "answer", calledNumber);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    break;


                // call is connected

                case CALL_STATE.CS_QUEUED:
                    break;
                // call is beeing queued

                case CALL_STATE.CS_HOLD:
                    break;
                // call is on hold

                case CALL_STATE.CS_DISCONNECTED:


                    break;
                    // call is disconnected
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
                //   Application.Exit();
            }
        }