Diff between a0cbbd2b8ab2a1424f33ac99baa7cca68255bd8b and 1f921e01c700151bcac3dc9477d85bfff36e05d3

Changed Files

File Additions Deletions Status
src/device.c +8 -0 modified
src/device.h +1 -0 modified
src/event.c +2 -7 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index 271c14c..4ffc124 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2434,3 +2434,11 @@ void btd_device_unref(struct btd_device *device)
 
 	g_free(path);
 }
+
+void device_set_class(struct btd_device *device, uint32_t value)
+{
+	DBusConnection *conn = get_dbus_connection();
+
+	emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Class",
+				DBUS_TYPE_UINT32, &value);
+}
diff --git a/src/device.h b/src/device.h
index d59b8eb..ad7350a 100644
--- a/src/device.h
+++ b/src/device.h
@@ -99,6 +99,7 @@ guint device_add_disconnect_watch(struct btd_device *device,
 				disconnect_watch watch, void *user_data,
 				GDestroyNotify destroy);
 void device_remove_disconnect_watch(struct btd_device *device, guint id);
+void device_set_class(struct btd_device *device, uint32_t value);
 
 #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
 
diff --git a/src/event.c b/src/event.c
index 2643a87..6be7ea2 100644
--- a/src/event.c
+++ b/src/event.c
@@ -346,11 +346,9 @@ void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
 
 void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class)
 {
-	uint32_t old_class = 0;
 	struct btd_adapter *adapter;
 	struct btd_device *device;
-	const gchar *dev_path;
-	DBusConnection *conn = get_dbus_connection();
+	uint32_t old_class = 0;
 
 	read_remote_class(local, peer, &old_class);
 
@@ -365,10 +363,7 @@ void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class)
 	if (!device)
 		return;
 
-	dev_path = device_get_path(device);
-
-	emit_property_changed(conn, dev_path, DEVICE_INTERFACE, "Class",
-				DBUS_TYPE_UINT32, &class);
+	device_set_class(device, class);
 }
 
 void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status,