[RFCv3 05/20] bluetooth: Implement Handsfree Audio Agent Release()

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

 



From: Jo?o Paulo Rechi Vita <jprvita@xxxxxxxxxxxxx>

This method is used to revoke the agent registration with the manager.
It can only be called by the manager that the agent has previously
registered with, it will be ignored if called by any other process.
---
 src/modules/bluetooth/bluetooth-util.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 5920867..7aeec00 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -2172,6 +2172,27 @@ fail:
     return r;
 }
 
+static DBusMessage *hfagent_release(DBusConnection *c, DBusMessage *m, void *userdata) {
+    DBusMessage *r;
+    const char *sender;
+    pa_bluetooth_discovery *y = userdata;
+
+    pa_assert(y);
+
+    sender = dbus_message_get_sender(m);
+    if (!pa_streq(y->ofono_bus_id, sender)) {
+        pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.NotAllowed", "Operation is not allowed by this sender"));
+        return r;
+    }
+
+    pa_log_debug("HF audio agent has been unregistered by oFono (%s)", y->ofono_bus_id);
+    ofono_done(y);
+
+    pa_assert_se(r = dbus_message_new_method_return(m));
+
+    return r;
+}
+
 static DBusHandlerResult dbus_msg_handler(DBusConnection *c, DBusMessage *m, void *userdata) {
     struct pa_bluetooth_discovery *y = userdata;
     DBusMessage *r = NULL;
@@ -2212,7 +2233,7 @@ static DBusHandlerResult dbus_msg_handler(DBusConnection *c, DBusMessage *m, voi
     else if (dbus_message_is_method_call(m, interface, "ClearConfiguration"))
         r = endpoint_clear_configuration(c, m, userdata);
     else if (dbus_message_is_method_call(m, "org.ofono.HandsfreeAudioAgent", "Release"))
-        pa_assert_se(r = dbus_message_new_method_return(m));
+        r = hfagent_release(c, m, userdata);
     else if (dbus_message_is_method_call(m, "org.ofono.HandsfreeAudioAgent", "NewConnection"))
         pa_assert_se(r = dbus_message_new_method_return(m));
     else
-- 
1.7.11.7



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux