summaryrefslogtreecommitdiffstats
path: root/plugins/hfp_hf_bluez5.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2013-02-01 20:33:08 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-14 08:47:10 -0600
commita2b698dc40dcdae827811c0df0a9e0665ce7d699 (patch)
tree76b21b48463b8964149627a51e8e0615e4d690ec /plugins/hfp_hf_bluez5.c
parent22f05f7832239561d80c93f281b3033396d50f68 (diff)
downloadofono-a2b698dc40dcdae827811c0df0a9e0665ce7d699.tar.bz2
hfp_hf_bluez5: Add Profile RequestDisconnection
This patch implements RequestDisconnection method of the Profile1 interface. This method gets called when the profile gets disconnected. The profile implementation needs to cleanup the resources related to the informed device.
Diffstat (limited to 'plugins/hfp_hf_bluez5.c')
-rw-r--r--plugins/hfp_hf_bluez5.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index cd3f9a65..0d6bdd95 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -340,11 +340,40 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
static DBusMessage *profile_disconnection(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
+ struct ofono_modem *modem;
+ struct hfp *hfp;
+ const char *device;
+ struct hfp_slc_info *info;
+ DBusMessageIter entry;
+
DBG("Profile handler RequestDisconnection");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ if (dbus_message_iter_init(msg, &entry) == FALSE)
+ goto error;
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &device);
+
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem == NULL)
+ goto error;
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ hfp = ofono_modem_get_data(modem);
+ info = &hfp->info;
+
+ g_at_chat_unref(info->chat);
+ info->chat = NULL;
+
+ return dbus_message_new_method_return(msg);
+
+error:
+ return g_dbus_create_error(msg,
+ BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static const GDBusMethodTable profile_methods[] = {