[PATCH 29/32] Call the agent when a new Health Link is created

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 health/hdp.c       |   27 ++++++++++++++++++++++++---
 src/bluetooth.conf |    1 +
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/health/hdp.c b/health/hdp.c
index 58d0394..1fc1cb9 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -760,14 +760,35 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
 {
 	struct hdp_instance *hdpi = data;
 	struct hdp_link *hdpl;
+	DBusMessage* message;
 	GError *err = NULL;
 
 	DBG("mcl_connected");
+
+	message = dbus_message_new_method_call(hdpi->aname, hdpi->apath,
+						HEALTH_AGENT, "LinkConnected");
+	if (!message) {
+		error("Couldn't allocate D-Bus message");
+		return;
+	}
+
 	hdpl = create_health_link(hdpi, mcl, &err);
-	if (err)
+	if (err) {
+		dbus_message_unref(message);
 		return;
-	/* TODO: Send the notification to the Agent */
-	hdpi->hlink = g_slist_prepend(hdpi->hlink, hdpl);
+	}
+
+	dbus_message_append_args(message,
+				DBUS_TYPE_OBJECT_PATH, &hdpl->path,
+				DBUS_TYPE_INVALID);
+
+	if (g_dbus_send_message(hdpi->adapter->conn, message)) {
+		hdpi->hlink = g_slist_prepend(hdpi->hlink, hdpl);
+		return;
+	}
+	error("D-Bus send failed");
+	health_link_free(hdpl);
+	dbus_message_unref(message);
 }
 
 static void mcl_reconnected(struct mcap_mcl *mcl, gpointer data)
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 56e7a83..4471da5 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -12,6 +12,7 @@
     <allow send_destination="org.bluez"/>
     <allow send_interface="org.bluez.Agent"/>
     <allow send_interface="org.bluez.HandsfreeAgent"/>
+    <allow send_interface="org.bluez.HealthAgent"/>
   </policy>
 
   <policy at_console="true">
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux