mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-11 04:50:31 +01:00
bluez: track adapter address in NMBluezDevice
We'll need it for bluez5 DUN support. [lkundrak@v3.sk: Turn the addresses to strings from guint8[ETH_ALEN], as that is what rest of NetworkManager uses for MAC addresses and what Bluez utility functions expect as well.]
This commit is contained in:
parent
5254ac456e
commit
384ec86064
4 changed files with 32 additions and 6 deletions
|
|
@ -53,6 +53,7 @@ typedef struct {
|
|||
gboolean usable;
|
||||
NMBluetoothCapabilities connection_bt_type;
|
||||
|
||||
char *adapter_address;
|
||||
char *address;
|
||||
char *name;
|
||||
guint32 capabilities;
|
||||
|
|
@ -263,7 +264,7 @@ check_emit_usable (NMBluezDevice *self)
|
|||
new_usable = (priv->initialized && priv->capabilities && priv->name &&
|
||||
((priv->bluez_version == 4) ||
|
||||
(priv->bluez_version == 5 && priv->adapter5 && priv->adapter_powered) ) &&
|
||||
priv->dbus_connection && priv->address);
|
||||
priv->dbus_connection && priv->address && priv->adapter_address);
|
||||
|
||||
if (!new_usable)
|
||||
goto END;
|
||||
|
|
@ -548,6 +549,18 @@ nm_bluez_device_connect_finish (NMBluezDevice *self,
|
|||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
set_adapter_address (NMBluezDevice *self, const char *address)
|
||||
{
|
||||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
g_return_if_fail (address);
|
||||
|
||||
if (priv->adapter_address)
|
||||
g_free (priv->adapter_address);
|
||||
priv->adapter_address = g_strdup (address);
|
||||
}
|
||||
|
||||
static guint32
|
||||
convert_uuids_to_capabilities (const char **strings, int bluez_version)
|
||||
{
|
||||
|
|
@ -735,6 +748,10 @@ adapter5_on_acquired (GObject *object, GAsyncResult *res, NMBluezDevice *self)
|
|||
if (v)
|
||||
g_variant_unref (v);
|
||||
|
||||
v = g_dbus_proxy_get_cached_property (priv->adapter5, "Address");
|
||||
if (VARIANT_IS_OF_TYPE_STRING (v))
|
||||
set_adapter_address (self, g_variant_get_string (v, NULL));
|
||||
|
||||
priv->initialized = TRUE;
|
||||
g_signal_emit (self, signals[INITIALIZED], 0, TRUE);
|
||||
|
||||
|
|
@ -940,7 +957,10 @@ on_bus_acquired (GObject *object, GAsyncResult *res, NMBluezDevice *self)
|
|||
/********************************************************************/
|
||||
|
||||
NMBluezDevice *
|
||||
nm_bluez_device_new (const char *path, NMConnectionProvider *provider, int bluez_version)
|
||||
nm_bluez_device_new (const char *path,
|
||||
const char *adapter_address,
|
||||
NMConnectionProvider *provider,
|
||||
int bluez_version)
|
||||
{
|
||||
NMBluezDevice *self;
|
||||
NMBluezDevicePrivate *priv;
|
||||
|
|
@ -961,8 +981,10 @@ nm_bluez_device_new (const char *path, NMConnectionProvider *provider, int bluez
|
|||
priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
priv->bluez_version = bluez_version;
|
||||
|
||||
priv->provider = provider;
|
||||
g_return_val_if_fail (bluez_version == 5 || (bluez_version == 4 && adapter_address), NULL);
|
||||
if (adapter_address)
|
||||
set_adapter_address (self, adapter_address);
|
||||
|
||||
g_signal_connect (priv->provider,
|
||||
NM_CP_SIGNAL_CONNECTION_ADDED,
|
||||
|
|
@ -1054,6 +1076,7 @@ finalize (GObject *object)
|
|||
nm_log_dbg (LOGD_BT, "bluez[%s]: finalize NMBluezDevice", priv->path);
|
||||
|
||||
g_free (priv->path);
|
||||
g_free (priv->adapter_address);
|
||||
g_free (priv->address);
|
||||
g_free (priv->name);
|
||||
g_free (priv->bt_iface);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,10 @@ typedef struct {
|
|||
|
||||
GType nm_bluez_device_get_type (void);
|
||||
|
||||
NMBluezDevice *nm_bluez_device_new (const char *path, NMConnectionProvider *provider, int bluez_version);
|
||||
NMBluezDevice *nm_bluez_device_new (const char *path,
|
||||
const char *adapter_address,
|
||||
NMConnectionProvider *provider,
|
||||
int bluez_version);
|
||||
|
||||
const char *nm_bluez_device_get_path (NMBluezDevice *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ device_created (DBusGProxy *proxy, const char *path, gpointer user_data)
|
|||
NMBluez4AdapterPrivate *priv = NM_BLUEZ4_ADAPTER_GET_PRIVATE (self);
|
||||
NMBluezDevice *device;
|
||||
|
||||
device = nm_bluez_device_new (path, priv->provider, 4);
|
||||
device = nm_bluez_device_new (path, priv->address, priv->provider, 4);
|
||||
g_signal_connect (device, "initialized", G_CALLBACK (device_initialized), self);
|
||||
g_signal_connect (device, "notify::usable", G_CALLBACK (device_usable), self);
|
||||
g_hash_table_insert (priv->devices, (gpointer) nm_bluez_device_get_path (device), device);
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ device_added (GDBusProxy *proxy, const gchar *path, NMBluez5Manager *self)
|
|||
NMBluez5ManagerPrivate *priv = NM_BLUEZ5_MANAGER_GET_PRIVATE (self);
|
||||
NMBluezDevice *device;
|
||||
|
||||
device = nm_bluez_device_new (path, priv->provider, 5);
|
||||
device = nm_bluez_device_new (path, NULL, priv->provider, 5);
|
||||
g_signal_connect (device, "initialized", G_CALLBACK (device_initialized), self);
|
||||
g_signal_connect (device, "notify::usable", G_CALLBACK (device_usable), self);
|
||||
g_hash_table_insert (priv->devices, (gpointer) nm_bluez_device_get_path (device), device);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue