private void handle_key_action(char key)
        {
            if (txtNumber.IsReadOnly == false && txtNumber.IsKeyboardFocused)
            {
                int ind = txtNumber.CaretIndex;
                if (txtNumber.SelectionStart >= 0)
                {
                    status.dial_str = status.dial_str.Remove(txtNumber.SelectionStart, txtNumber.SelectionLength);
                }
                status.dial_str      = status.dial_str.Insert(ind, key.ToString());
                txtNumber.CaretIndex = ind + 1;
            }
            else
            {
                status.dial_str += key;
            }
            //status.dial_str += key;
            if (key != '*' && key != '#' && (key < '0' || key > '9') && (key < 'A' || key > 'D'))
            {
                return;
            }

            if (Call.active_call != null && Call.active_call.state == Call.CALL_STATE.Answered)
            {
                Call.active_call.send_dtmf(key.ToString());
            }
            else
            {
#if !NO_FS
                PortAudio.PlayDTMF(key, null, true);
                DelayedFunction.DelayedCall("PortAudioLastDigitHitStreamClose", close_streams, 5000);
#endif
            }
        }
 private void close_streams()
 {
     if (broker.active_calls == 0)
     {
         PortAudio.CloseStreams();
     }
 }
Exemple #3
0
 public void switch_to()
 {
     if (active_call != this)
     {
         PortAudio.SwitchTo(portaudio_id);
     }
 }
Exemple #4
0
 public void unhold()
 {
     if (state == CALL_STATE.Hold)
     {
         PortAudio.SwitchTo(portaudio_id);
     }
 }
Exemple #5
0
        public void CreateCall(String number)
        {
            if (!enabled)
            {
                return;
            }
            Broker.get_instance().BringToFront(false);
            String var_str = "origination_caller_id_name='" + caller_id_name + "',origination_caller_id_number='" + caller_id_number + "'";

            if (secure_media)
            {
                var_str += ",sip_secure_media=true";
            }

            if (Broker.get_instance().DirectSipDial)
            {
                if (sip_regex == null)
                {
                    sip_regex = new Regex(@"^sip:(.+)$", RegexOptions.Compiled);
                }
                Match match = sip_regex.Match(number);
                if (match.Success)
                {
                    string sip_uri = match.Groups[1].Value;
                    PortAudio.Call("{" + var_str + ",gw_ref='" + gateway_id + "'}sofia/softphone/" + sip_uri);
                    return;
                }
            }
            PortAudio.Call("{" + var_str + "}sofia/gateway/" + gateway_id + "/" + number);
        }
Exemple #6
0
 public void hold()
 {
     if (state == CALL_STATE.Answered || (state == CALL_STATE.Ringing && this == active_call && is_outgoing))
     {
         PortAudio.HoldAll();
     }
 }
Exemple #7
0
        private void DeviceAdded(object sender, IHeadsetPlugin.DeviceEventArgs e)
        {
            IHeadsetPlugin plugin = sender as IHeadsetPlugin;
            DeviceData     data   = new DeviceData {
                device = e.device, host = new IDeviceHost(), active = false, in_use = false
            };

            data.plugin = (from p in plugins where p.plugin == plugin select p).Single();
            try {
                lock (devices_lock) {
                    devices.Add(data);
                }
                data.device.StatusChanged += DeviceStatusChanged;
                data.limitations           = data.device.Initalize(data.host);
                data.device.GetModel();
                if ((active_device_name == null && data.device.GetName() == last_active_device_name) || active_device_name == data.device.GetName())
                {
                    SetActiveDevice(data.device.GetName());
                    PortAudio.refresh_devices();
                }
            }
            catch (Exception exp) {
                HandleError(new PluginError {
                    device = data, exception = exp
                });
            }
        }
Exemple #8
0
        private static void HandleDTMFEvent(FSEvent evt, string uuid)
        {
            String digit = evt.get_header("DTMF-Digit");
            var    call  = (from c in calls where (c.leg_a_uuid == uuid || c.leg_b_uuid == uuid) && c.call_ended == false select c).SingleOrDefault();

            if (call != null && call.state == CALL_STATE.Answered && digit.Length == 1)
            {
                PortAudio.PlayDTMF(digit[0], call.leg_a_uuid);
            }
        }
Exemple #9
0
 private void activateCurrentDevs()
 {
     if (SpeakerphoneActive)
     {
         PortAudio.SetInAndOutDev(SpeakerInDev, SpeakerOutDev);
     }
     else
     {
         PortAudio.SetInAndOutDev(HeadsetInDev, HeadsetOutDev);
     }
 }
Exemple #10
0
 public void reload_audio_devices(bool and_settings, bool no_save)
 {
     if (active_calls > 0)
     {
         MessageBox.Show("Unable to reload audio devices while calls are active");
         return;
     }
     if (and_settings && !no_save)
     {
         SaveAudioSettings();
     }
     audio_devices = PortAudio.get_devices(true);
     if (and_settings)
     {
         LoadAudioSettings();
     }
     activateCurrentDevs();
 }
Exemple #11
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;");
     }
 }
 public void SetOutDev()
 {
     PortAudio.SetOutDev(guid);
 }
Exemple #13
0
 public void hangup()
 {
     PortAudio.Hangup(portaudio_id);
 }
Exemple #14
0
 public void answer()
 {
     PortAudio.Answer(portaudio_id);
 }
 public void SetRingDev()
 {
     PortAudio.SetRingDev(guid);
 }
Exemple #16
0
 public void send_dtmf(string dtmf)
 {
     dtmfs += dtmf;
     PortAudio.SendDTMF(dtmf);
 }
 public void SetInDev()
 {
     PortAudio.SetInDev(guid);
 }