summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPaulo Borges <paulo.borges@openbossa.org>2013-04-19 19:19:05 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-04-22 03:55:21 -0500
commit7b56ca27300ee1db445ffa2c140dba09ee53bb26 (patch)
treedb6ac31b98a1a5df6c2382bdcc8db644313d70b6 /plugins
parent9332299bb7de7534e8e0d37ae3d1580d45f29b48 (diff)
downloadofono-7b56ca27300ee1db445ffa2c140dba09ee53bb26.tar.bz2
hfp_ag_bluez5: Implement RequestDisconnection()
When a RequestDisconnect() is received, the socket must be closed. This way, the related emulator will be freed.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hfp_ag_bluez5.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/plugins/hfp_ag_bluez5.c b/plugins/hfp_ag_bluez5.c
index a0203b13..59e84d21 100644
--- a/plugins/hfp_ag_bluez5.c
+++ b/plugins/hfp_ag_bluez5.c
@@ -162,11 +162,35 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
static DBusMessage *profile_disconnection(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
+ DBusMessageIter iter;
+ const char *device;
+ gpointer fd;
+
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);
+
+ fd = g_hash_table_lookup(connection_hash, device);
+ if (fd == NULL)
+ goto invalid;
+
+ shutdown(GPOINTER_TO_INT(fd), SHUT_RDWR);
+
+ g_hash_table_remove(connection_hash, device);
+
+ 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[] = {