Advertisement
tuxor

snippet from bluetooth-killswitch.c

Nov 26th, 2011
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. void
  2. bluetooth_killswitch_set_state (BluetoothKillswitch *killswitch,
  3.                 KillswitchState state)
  4. {
  5.     BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
  6.     struct rfkill_event event;
  7.     ssize_t len;
  8.  
  9.     g_return_if_fail (state != KILLSWITCH_STATE_HARD_BLOCKED);
  10.  
  11.     memset (&event, 0, sizeof(event));
  12.     event.op = RFKILL_OP_CHANGE_ALL;
  13.     event.type = RFKILL_TYPE_BLUETOOTH;
  14.     if (state == KILLSWITCH_STATE_SOFT_BLOCKED)
  15.         event.soft = 1;
  16.     else if (state == KILLSWITCH_STATE_UNBLOCKED)
  17.         event.soft = 0;
  18.     else
  19.         g_assert_not_reached ();
  20.  
  21.     len = write (priv->fd, &event, sizeof(event));
  22.     if (len < 0)
  23.         g_warning ("Failed to change RFKILL state: %s",
  24.                g_strerror (errno));
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement