From: Claudio Takahasi <[email protected]>

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.
---
 plugins/hfp_hf_bluez5.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index cd3f9a6..0d6bdd9 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[] = {
-- 
1.8.1.1

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

Reply via email to