Example #1
0
 public CallPropertyEventArgs(Call call, string property_name)
 {
     this.call = call;
     this.property_name = property_name;
 }
Example #2
0
        private void UpdateCallState(CALL_STATE new_state, Call new_active_call)
        {
            bool actually_make_active = active_call != new_active_call;
            bool actually_update_state = state != new_state;
            bool set_call_ended = new_state != CALL_STATE.Answered && new_state != CALL_STATE.Ringing && new_state != CALL_STATE.Hold && new_state != CALL_STATE.Hold_Ringing && call_ended == false;
            ActiveCallChangedArgs args = null;

            if (actually_update_state)
                _state = new_state;
            if (actually_make_active) {
                args = new ActiveCallChangedArgs { new_active_call = new_active_call, old_active_call = active_call };
                active_call = new_active_call;
            }
            if (set_call_ended) {
                call_ended = true;
                _end_time = DateTime.Now;
            }

            if (args != null)
                ActiveCallChanged(null, args);

            if (actually_update_state)
                RaisePropertyChanged("state");
            if (set_call_ended) {
                RaisePropertyChanged("call_ended");
                RaisePropertyChanged("end_time");
            }
        }
Example #3
0
 private static void HandleCustomEvent(FSEvent evt, string uuid)
 {
     if (evt.subclass_name == "portaudio::ringing") {
         Utils.DebugEventDump(evt);
         if ((from c in calls where c._leg_a_uuid == uuid select c).Count() > 0)//only care about first ring
             return;
         Call call = new Call();
         call.SetCallInfoFromEvent(evt);
         String gw_id = (from c in channels where c.Key == call.leg_b_uuid select c.Value.gateway_id).SingleOrDefault();
         call.account = (from a in Account.accounts where a.gateway_id == gw_id select a).SingleOrDefault();
         calls.Add(call);
         call.UpdateCallState(CALL_STATE.Ringing, active_call ?? call);
     }
     else if (evt.subclass_name == "portaudio::makecall") {
         Utils.DebugEventDump(evt);
         if (evt.get_header("fail") == "true") {
             MessageBox.Show("Make Call failed!!!, came from portaudio not sure why");
             return;
         }
         Call call = new Call();
         call.is_outgoing = true;
         call.SetCallInfoFromEvent(evt);
         calls.Add(call);
         call.UpdateCallState(CALL_STATE.Ringing, call);
     }
     else if (evt.subclass_name == "portaudio::callheld" || evt.subclass_name == "portaudio::callresumed") {
         String paid_str = evt.get_header("variable_pa_call_id");
         if (String.IsNullOrEmpty(paid_str))
             return;
         int portaudio_id = Int32.Parse(paid_str);
         Call call = (from c in calls where c.portaudio_id == portaudio_id select c).SingleOrDefault();
         if (call == null)
             return;
         if (evt.subclass_name == "portaudio::callresumed")
             call.UpdateCallState(CALL_STATE.Answered, call);
         else
             call.UpdateCallState(call.state == CALL_STATE.Ringing ? CALL_STATE.Hold_Ringing : CALL_STATE.Hold, call == active_call ? null : active_call);
     }
 }
Example #4
0
 private void HandleCallWaiting(Timer timer, Call c)
 {
     if (c.state != Call.CALL_STATE.Ringing || Call.active_call == c) {
         if (timer != null) {
             timer.Stop();
             timer.Dispose();
             return;
         }
     }
     if (timer == null) {
         timer = new Timer(4000);
         timer.Elapsed += (s, e) => HandleCallWaiting(timer, c);
         timer.Start();
     }
     if (Call.active_call != null && Call.active_call.state == Call.CALL_STATE.Answered)
         PortAudio.PlayInUUID(Call.active_call.leg_a_uuid, "tone_stream://%(200,100,440);loops=2;");
 }
Example #5
0
        private void CallStateChangedHandler(object sender, Call.CallPropertyEventArgs args)
        {
            if (args.call.state == Call.CALL_STATE.Ringing && !args.call.is_outgoing) {
                if (IncomingTopMost) {
                    MainWindow.get_instance().BringToFront();
                }
                if (IncomingBalloons && !DND) {
                    IncomingCallNotification.ShowCallNotification(args.call);
                    if (Call.active_call != args.call && Call.active_call != null)
                        HandleCallWaiting(null, args.call);
                }
            }
            if (DND && args.call != null && args.call.is_outgoing == false && args.call.state == Call.CALL_STATE.Ringing)
                args.call.hangup("Call ignored due to DND");
            if (args.call != null && args.call.call_ended && ClearDTMFS)
                args.call.dtmfs = "";

            DelayedFunction.DelayedCall("broker_updatestatus", UpdateStatus, 500);
        }
Example #6
0
 private void ActiveCallChanged(object sender, Call.ActiveCallChangedArgs e)
 {
     if (Call.active_call != null)
         cur_dial_str = Call.active_call.dtmfs;
     else
         cur_dial_str = "";
 }