Ejemplo n.º 1
0
        private void OnDeviceDetached(JA.IDevice device)
        {
            JabraHeadset headset = (from d in devices where d.device == device select d).SingleOrDefault();

            if (headset != null)
            {
                DeviceRemoved(this, new DeviceEventArgs(headset));
            }
        }
Ejemplo n.º 2
0
 private void AddNewDevice(JA.IDevice ja_device)
 {
     try {
         JabraHeadset device = new JabraHeadset(ja_device);
         devices.Add(device);
         DeviceAdded(this, new DeviceEventArgs(device));
     } catch (System.IO.FileNotFoundException) {
         Utils.PluginLog("Jabra Provider", "Unable to add new device");
     }
 }
Ejemplo n.º 3
0
        private void OnButtonEvent(JA.IDevice device, JA.ButtonEvent button, bool value)
        {
            try {
                switch (button)
                {
                case JA.ButtonEvent.HookSwitch:
                    if (value)
                    {
                        if (!hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Talk));
                        }
                        hook_enabled = true;
                    }
                    else
                    {
                        if (hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                            device.SetHookState(false);
                        }
                        hook_enabled = false;
                    }
                    break;

                case JA.ButtonEvent.MicMute:
                    if (!ignore_next_mute)
                    {
                        StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.ToggleMute));
                    }
                    ignore_next_mute = false;
                    break;

                case JA.ButtonEvent.Flash:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Flash));
                    break;

                case JA.ButtonEvent.RejectCall:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                    break;

                case JA.ButtonEvent.FireAlarm:
                    throw new Exception("WTF");

                case JA.ButtonEvent.Redial:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Redial));
                    break;
                }
            }
            catch (Exception) {}
        }
Ejemplo n.º 4
0
 private void OnStateEvent(JA.IDevice device, JA.State state, bool value)
 {
     switch (state)
     {
     case JA.State.OnLine:
         if (value)
         {
             StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.RadioOpen));
             if (muted)
             {
                 DelayedFunction.DelayedCall("jabra_mute", () => {
                     ignore_next_mute = true;
                     device.SetMicrophoneMute(muted);
                 }, 2500);
             }
         }
         else
         {
             StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.RadioClosed));
         }
         break;
     }
 }
Ejemplo n.º 5
0
 public JabraHeadset(JA.IDevice device)
 {
     this.device = device;
     device_path = device.DeviceHandle.ToString();
     device_name = device.Name;
 }
Ejemplo n.º 6
0
 public JabraHeadset(JA.IDevice device)
 {
     this.device = device;
     device_path = device.DeviceHandle.ToString();
     device_name = device.Name;
 }
Ejemplo n.º 7
0
 private void OnDeviceAttached(JA.IDevice device)
 {
     AddNewDevice(device);
 }
Ejemplo n.º 8
0
        private void OnButtonEvent(JA.IDevice device, JA.ButtonEvent button, bool value)
        {
            try {
                var now = DateTime.Now;
                Debug.WriteLine($"Jabra::OnButtonEvent {now}.{now.Millisecond} {button} {value} is muted: {device.MicrophoneMuted}");                //this gets called twice, at least for bluetooth devices for each event, second event does have right mute state microphone muted, with the
                var diff = DateTime.UtcNow - last_event;
                last_event = DateTime.UtcNow;
                if (diff.TotalMilliseconds < 300)
                {
                    var hash = "" + device.DeviceHandle + button + value;
                    if (hash == last_event_hash)
                    {
                        Debug.WriteLine("Ignoring dupe event within 300 ms of last");
                        return;
                    }
                    last_event_hash = hash;
                }

                switch (button)
                {
                case JA.ButtonEvent.HookSwitch:
                    if (value)
                    {
                        if (!hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Talk));
                        }
                        hook_enabled = true;
                    }
                    else
                    {
                        if (hook_enabled)
                        {
                            StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                            device.SetHookState(false);
                        }
                        hook_enabled = false;
                    }
                    break;

                case JA.ButtonEvent.MicMute:
                    if (!ignore_next_mute)                            //only done on startup event
                    {
                        StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.ToggleMute));
                    }
                    ignore_next_mute = false;
                    break;

                case JA.ButtonEvent.Flash:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Flash));
                    break;

                case JA.ButtonEvent.RejectCall:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup));
                    break;

                case JA.ButtonEvent.FireAlarm:
                    throw new Exception("WTF");

                case JA.ButtonEvent.Redial:
                    StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Redial));
                    break;
                }
            } catch (Exception) { }
        }