diff --git a/src/bluez-manager/nm-bluez-manager.c b/src/bluez-manager/nm-bluez-manager.c index 78a41f8527..81dfe940ae 100644 --- a/src/bluez-manager/nm-bluez-manager.c +++ b/src/bluez-manager/nm-bluez-manager.c @@ -61,6 +61,7 @@ static void emit_bdaddr_added (NMBluezManager *self, NMBluezDevice *device) { g_signal_emit (self, signals[BDADDR_ADDED], 0, + device, nm_bluez_device_get_address (device), nm_bluez_device_get_name (device), nm_bluez_device_get_path (device), @@ -370,7 +371,8 @@ nm_bluez_manager_class_init (NMBluezManagerClass *klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (NMBluezManagerClass, bdaddr_added), NULL, NULL, NULL, - G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); + G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT); signals[BDADDR_REMOVED] = g_signal_new (NM_BLUEZ_MANAGER_BDADDR_REMOVED, diff --git a/src/devices/nm-device-bt.c b/src/devices/nm-device-bt.c index 09c1284c42..ae8707bf53 100644 --- a/src/devices/nm-device-bt.c +++ b/src/devices/nm-device-bt.c @@ -29,6 +29,7 @@ #include "nm-glib-compat.h" #include "nm-bluez-common.h" +#include "nm-bluez-device.h" #include "nm-dbus-manager.h" #include "nm-device-bt.h" #include "nm-device-private.h" @@ -61,6 +62,8 @@ typedef struct { guint mm_watch_id; gboolean mm_running; + NMBluezDevice *bt_device; + char *bdaddr; char *name; guint32 capabilities; @@ -82,6 +85,7 @@ enum { PROP_0, PROP_BT_NAME, PROP_BT_CAPABILITIES, + PROP_BT_DEVICE, LAST_PROP }; @@ -1111,7 +1115,8 @@ mm_name_owner_changed (NMDBusManager *dbus_mgr, /*****************************************************************************/ NMDevice * -nm_device_bt_new (const char *udi, +nm_device_bt_new (NMBluezDevice *bt_device, + const char *udi, const char *bdaddr, const char *name, guint32 capabilities) @@ -1120,12 +1125,14 @@ nm_device_bt_new (const char *udi, g_return_val_if_fail (bdaddr != NULL, NULL); g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (capabilities != NM_BT_CAPABILITY_NONE, NULL); + g_return_val_if_fail (NM_IS_BLUEZ_DEVICE (bt_device), NULL); return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BT, NM_DEVICE_UDI, udi, NM_DEVICE_IFACE, bdaddr, NM_DEVICE_DRIVER, "bluez", NM_DEVICE_HW_ADDRESS, bdaddr, + NM_DEVICE_BT_DEVICE, bt_device, NM_DEVICE_BT_NAME, name, NM_DEVICE_BT_CAPABILITIES, capabilities, NM_DEVICE_TYPE_DESC, "Bluetooth", @@ -1185,6 +1192,10 @@ set_property (GObject *object, guint prop_id, /* Construct only */ priv->capabilities = g_value_get_uint (value); break; + case PROP_BT_DEVICE: + /* Construct only */ + priv->bt_device = g_value_dup_object (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1204,6 +1215,9 @@ get_property (GObject *object, guint prop_id, case PROP_BT_CAPABILITIES: g_value_set_uint (value, priv->capabilities); break; + case PROP_BT_DEVICE: + g_value_set_object (value, priv->bt_device); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1229,6 +1243,7 @@ dispose (GObject *object) g_clear_object (&priv->type_proxy); g_clear_object (&priv->dev_proxy); g_clear_object (&priv->modem); + g_clear_object (&priv->bt_device); G_OBJECT_CLASS (nm_device_bt_parent_class)->dispose (object); } @@ -1289,6 +1304,14 @@ nm_device_bt_class_init (NMDeviceBtClass *klass) NM_BT_CAPABILITY_NONE, G_MAXUINT, NM_BT_CAPABILITY_NONE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property + (object_class, PROP_BT_DEVICE, + g_param_spec_object (NM_DEVICE_BT_DEVICE, + "NMBluezDevice object for the Device", + "NMBluezDevice object for the Device", + NM_TYPE_BLUEZ_DEVICE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + /* Signals */ signals[PPP_STATS] = g_signal_new ("ppp-stats", diff --git a/src/devices/nm-device-bt.h b/src/devices/nm-device-bt.h index bcc9f822bc..d983285fb7 100644 --- a/src/devices/nm-device-bt.h +++ b/src/devices/nm-device-bt.h @@ -22,6 +22,7 @@ #define NM_DEVICE_BT_H #include +#include "nm-bluez-device.h" #include "nm-modem.h" G_BEGIN_DECLS @@ -41,6 +42,7 @@ typedef enum { #define NM_DEVICE_BT_NAME "name" #define NM_DEVICE_BT_CAPABILITIES "bt-capabilities" +#define NM_DEVICE_BT_DEVICE "bt-device" typedef struct { NMDevice parent; @@ -55,7 +57,8 @@ typedef struct { GType nm_device_bt_get_type (void); -NMDevice *nm_device_bt_new (const char *udi, +NMDevice *nm_device_bt_new (NMBluezDevice *bt_device, + const char *udi, const char *bdaddr, const char *name, guint32 capabilities); diff --git a/src/nm-manager.c b/src/nm-manager.c index 11e3b5e0b1..f395f03302 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -139,6 +139,7 @@ static void impl_manager_check_connectivity (NMManager *manager, #include "nm-manager-glue.h" static void bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr, + NMBluezDevice *bt_device, const char *bdaddr, const char *name, const char *object_path, @@ -2184,6 +2185,7 @@ add_device (NMManager *self, NMDevice *device) static void bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr, + NMBluezDevice *bt_device, const char *bdaddr, const char *name, const char *object_path, @@ -2198,12 +2200,13 @@ bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr, g_return_if_fail (name != NULL); g_return_if_fail (object_path != NULL); g_return_if_fail (capabilities != NM_BT_CAPABILITY_NONE); + g_return_if_fail (NM_IS_BLUEZ_DEVICE (bt_device)); /* Make sure the device is not already in the device list */ if (nm_manager_get_device_by_udi (manager, object_path)) return; - device = nm_device_bt_new (object_path, bdaddr, name, capabilities); + device = nm_device_bt_new (bt_device, object_path, bdaddr, name, capabilities); if (device) { nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)", name,