When a RequestDisconnect() is received, the socket must be closed.
This way, the related emulator will be freed.
---
 plugins/hfp_ag_bluez5.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index 67b6a8d..4383161 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -163,11 +163,29 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
 static DBusMessage *profile_disconnection(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {
+       DBusMessageIter iter;
+       const char *device;
+
        DBG("Profile handler RequestDisconnection");
 
-       return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
-                                       ".NotImplemented",
-                                       "Implementation not provided");
+       if (!dbus_message_iter_init(msg, &iter))
+               goto invalid;
+
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH)
+               goto invalid;
+
+       dbus_message_iter_get_basic(&iter, &device);
+
+       DBG("%s", device);
+
+       if (!g_hash_table_remove(connection_hash, device))
+               goto invalid;
+
+       return dbus_message_new_method_return(msg);
+
+invalid:
+       return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+                                       "Invalid arguments in method call");
 }
 
 static const GDBusMethodTable profile_methods[] = {
-- 
1.7.9.5

_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to