bluetooth-client: gnome-bluetooth Reference Manual

## bluetooth-client bluetooth-client — Bluetooth client object |

## Stability Level

Stable, unless otherwise indicated

## Functions

BluetoothClient * | bluetooth_client_new ()
GListStore * | bluetooth_client_get_devices ()
void | bluetooth_client_connect_service ()
gboolean | bluetooth_client_connect_service_finish ()
gboolean | bluetooth_client_has_connected_input_devices ()

## Properties

char * | default-adapter | Read
char * | default-adapter-address | Read
char * | default-adapter-name | Read
gboolean | default-adapter-powered | Read / Write
gboolean | default-adapter-setup-mode | Read / Write
BluetoothAdapterState | default-adapter-state | Read
guint | num-adapters | Read

## Signals

void | device-added | Run Last
void | device-removed | Run Last

## Types and Values

#define | BLUETOOTH_TYPE_CLIENT
| BluetoothClient

## Object Hierarchy

        GObject
        ╰── BluetoothClient

## Includes

    #include <bluetooth-client.h>

## Description

The BluetoothClient object is used to query the state of Bluetooth devices and adapters.

## Functions

### bluetooth_client_new ()

    BluetoothClient *
    bluetooth_client_new (void);

Returns a reference to the BluetoothClient singleton. Use `g_object_unref()` when done with the object.

#### Returns

a BluetoothClient object.

[transfer full]

### bluetooth_client_get_devices ()

    GListStore *
    bluetooth_client_get_devices (BluetoothClient *client);

Returns an unfiltered GListStore representing the devices attached to the default Bluetooth adapter.

#### Parameters

client | a BluetoothClient object |

#### Returns

a GListStore.

[transfer full]

### bluetooth_client_connect_service ()

    void
    bluetooth_client_connect_service (BluetoothClient *client,
                                      const char *path,
                                      gboolean connect,
                                      GCancellable *cancellable,
                                      GAsyncReadyCallback callback,
                                      gpointer user_data);

This will start the process of connecting to one of the known-connectable services on the device. This means that it could connect to all the audio services on a headset, but just to the input service on a keyboard.

Broadly speaking, this will only have an effect on devices with audio and HID services, and do nothing if the device doesn't have the "connectable" property set.

When the connection operation is finished, `callback` will be called. You can then call `bluetooth_client_connect_service_finish()` to get the result of the operation.

#### Parameters

client | a BluetoothClient |
path | the object path on which to operate |
connect | Whether try to connect or disconnect from services on a device |
cancellable | optional GCancellable object, `NULL` to ignore |
callback | a GAsyncReadyCallback to call when the connection is complete. | [scope async]
user_data | the data to pass to callback function |

### bluetooth_client_connect_service_finish ()

    gboolean
    bluetooth_client_connect_service_finish
                                   (BluetoothClient *client,
                                    GAsyncResult *res,
                                    GError **error);

Finishes the connection operation. See `bluetooth_client_connect_service()`.

#### Parameters

client | a BluetoothClient |
res | a GAsyncResult |
error | a GError |

#### Returns

`TRUE` if the connection operation succeeded, `FALSE` otherwise.

### bluetooth_client_has_connected_input_devices ()

    gboolean
    bluetooth_client_has_connected_input_devices
                                   (BluetoothClient *client);

Returns whether there are connected devices with the input capability. This can be used by an OS user interface to warn the user before disabling Bluetooth so that the user isn't stranded without any input devices.

#### Parameters

client | a BluetoothClient |

#### Returns

`TRUE` if there are connected input devices.

## Types and Values

### BLUETOOTH_TYPE_CLIENT

    #define BLUETOOTH_TYPE_CLIENT (bluetooth_client_get_type())

### BluetoothClient

    typedef struct _BluetoothClient BluetoothClient;

## Property Details

### The `“default-adapter”` property

      “default-adapter”          char *

The D-Bus path of the default Bluetooth adapter or `NULL`.

Owner: BluetoothClient

Flags: Read

Default value: NULL

### The `“default-adapter-address”` property

      “default-adapter-address”  char *

The address of the default Bluetooth adapter or `NULL`.

Owner: BluetoothClient

Flags: Read

Default value: NULL

### The `“default-adapter-name”` property

      “default-adapter-name”     char *

The name of the default Bluetooth adapter or `NULL`.

Owner: BluetoothClient

Flags: Read

Default value: NULL

### The `“default-adapter-powered”` property

      “default-adapter-powered”  gboolean

`TRUE` if the default Bluetooth adapter is powered.

Owner: BluetoothClient

Flags: Read / Write

Default value: FALSE

### The `“default-adapter-setup-mode”` property

      “default-adapter-setup-mode” gboolean

`TRUE` if the default Bluetooth adapter is in setup mode (discoverable, and discovering).

Owner: BluetoothClient

Flags: Read / Write

Default value: FALSE

### The `“default-adapter-state”` property

      “default-adapter-state”    BluetoothAdapterState

The BluetoothAdapterState of the default Bluetooth adapter. More precise than “default-adapter-powered”.

Owner: BluetoothClient

Flags: Read

Default value: BLUETOOTH_ADAPTER_STATE_ABSENT

### The `“num-adapters”` property

      “num-adapters”             guint

The number of detected Bluetooth adapters.

Owner: BluetoothClient

Flags: Read

Default value: 0

## Signal Details

### The `“device-added”` signal

    void
    user_function (BluetoothClient *client,
                   GObject         *device,
                   gpointer         user_data)

The “device-added” signal is launched when a device gets added to the model.

#### Parameters

client | a BluetoothClient object which received the signal |
device | a BluetoothDevice object |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“device-removed”` signal

    void
    user_function (BluetoothClient *client,
                   char            *device,
                   gpointer         user_data)

The “device-removed” signal is launched when a device gets removed from the model.

Note that “device-removed” will not be called for each individual device as the model is cleared when the “default-adapter” property changes.

#### Parameters

client | a BluetoothClient object which received the signal |
device | the D-Bus object path for the now-removed device |
user_data | user data set when the signal handler was connected. |

Flags: Run Last