Inheritance: ObservableClass
 public static void ShowCallNotification(Call call)
 {
     IncomingCallNotification notifier = new IncomingCallNotification();
     notifier.call = call;
     windows.Add(notifier);
     notifier.Show();
 }
Exemple #2
0
 public CallPropertyEventArgs(Call call, string property_name)
 {
     this.call = call;
     this.property_name = property_name;
 }
Exemple #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 && c.call_ended == false 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);
         if (call.other_party_number == "fsc_conference"){
             call.visibility = Visibility.Collapsed;
             Conference.instance.our_conference_call = call;
             call.is_conference_call = true;
         }
         calls.Add(call);
         call.UpdateCallState(call.is_conference_call ? CALL_STATE.Answered : 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 && c.call_ended == false 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);
     }
 }
Exemple #4
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");
            }
        }
Exemple #5
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;");



		}
Exemple #6
0
        private static void HandleChannelAnswerEvent(FSEvent evt, String uuid)
        {
            Call call = (from c in calls where c.leg_b_uuid == uuid && c.call_ended == false select c).SingleOrDefault();
            if (call == null){
                String orig_dest = evt.get_header("Other-Leg-Destination-Number");
                if (orig_dest != "auto_answer")
                    return;
                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, call);
            }
            if (call.state == CALL_STATE.Answered)
                return;

            if (call.state == CALL_STATE.Ringing || (call.state == CALL_STATE.Hold_Ringing && !call.is_outgoing))
                call.UpdateCallState(CALL_STATE.Answered, (call.is_outgoing || call.is_conference_call) ? active_call : call);
            else if (call.state == CALL_STATE.Hold_Ringing)
                call.UpdateCallState(CALL_STATE.Hold, active_call);
            else
                throw new Exception("Unknown state, call answered but was not in a state of hold_ring or ringing");
        }
		protected override Task<string> EditAliasAsync(Call c, string number, string default_value) {
			var res = EditAlias(c, number, default_value);
			return Task.FromResult(res);
		}
 public abstract void CallRightClickMenu(Call call, ContextMenu menu);
		public override void XFERRightClickMenu(Call call, ContextMenu menu) {
			MenuItem item;
			bool on_call = call != null;
			foreach (KeyValuePair<string, string> kvp in number_to_xfer) {
				item = new MenuItem();
				String num = kvp.Key;
				if (on_call) {
					item.Click += (s, e) => {
						menu.IsOpen = false;
						call.Transfer(num);
					};
				}
				item.Header = kvp.Value + " (" + num + ")";
				menu.Items.Add(item);


				MenuItem sub_item = new MenuItem();
				if (!on_call) {
					sub_item.Click += edit_xfer_click;
					sub_item.Header = "Edit Alias";
					sub_item.DataContext = kvp;
					item.Items.Add(sub_item);
					if (CanDeleteXFER()) {
						sub_item = new MenuItem();
						sub_item.Click += del_xfer_click;
						sub_item.Header = "Delete Alias";
						sub_item.DataContext = kvp;
						item.Items.Add(sub_item);
					}
				}
			}
			if (!on_call) {
				item = new MenuItem();
				item.Click += add_xfer_click;
				item.Header = "Add Transfer Alias";
				menu.Items.Add(item);
			}
			ModifyXFERRightClickMenu(call, menu);
		}
		protected virtual string EditAlias(Call c, String number, String default_value) {
			return base.EditAliasAsync(c, number, default_value).Result;
		}
		public override void CallRightClickMenu(Call call, ContextMenu menu) {
			MenuItem item = new MenuItem();
			item.Click += item_Click;
			item.Header = "Edit Contact";
			menu.Items.Add(item);
			ModifyRightClickMenu(call, menu);
		}
		protected virtual string DefaultEditValue(Call call) {
			if (call.other_party_name != call.other_party_number)
				return call.other_party_name;
			return "";
		}
Exemple #13
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);
				}
				else if (IncomingKeyboardFocus)
					Utils.SetForegroundWindow(MainWindow.get_instance());
			}
			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);
		}
 private void broker_xferMenuOpened(Call active_call, ContextMenu menu)
 {
     if (active_plugin == null)
         return;
     active_plugin.contact_plugin.XFERRightClickMenu(active_call, menu);
 }
		protected virtual Task<string> EditAliasAsync(Call c, String number, String default_value) {
			var res = InputBox.GetInput("Editing Contact", "Edit alias for number: " + number, default_value);
			return Task.FromResult(res);
		}
 private void calls_RightClickMenuShowing(object sender, Call.CallRightClickEventArgs e)
 {
     if (active_plugin == null)
         return;
     active_plugin.contact_plugin.CallRightClickMenu(e.call, e.menu);
 }
		protected virtual void ModifyXFERRightClickMenu(Call call, ContextMenu menu) {
			return;
		}
 public virtual void XFERRightClickMenu(Call call, ContextMenu menu)
 {
 }
 protected virtual void ModifyXFERRightClickMenu(Call call, ContextMenu menu)
 {
     return;
 }