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.
This commit is contained in:
Claudio Takahasi 2013-02-01 20:33:08 -03:00 committed by Denis Kenzior
parent 22f05f7832
commit a2b698dc40
1 changed files with 32 additions and 3 deletions

View File

@ -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[] = {