diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-04-01 20:36:31 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-04-01 20:36:31 +0000 |
commit | f1de5c126e4f7fb10de9f2dac688887018312c51 (patch) | |
tree | a7bb87db1b063762a9707503f6663233c680e752 /audio | |
parent | c08ade22068fc1003f1900a6e0989c212bbb5dd6 (diff) |
Implement IsConnected method
Diffstat (limited to 'audio')
-rw-r--r-- | audio/headset.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/audio/headset.c b/audio/headset.c index ad97172f..d1ee5032 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1162,6 +1162,30 @@ static DBusHandlerResult hs_disconnect(struct headset *hs, DBusMessage *msg) return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult hs_is_connected(struct headset *hs, DBusMessage *msg) +{ + DBusMessage *reply; + dbus_bool_t connected; + + assert(hs); + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + if (hs->state >= HEADSET_STATE_CONNECTED) + connected = TRUE; + else + connected = FALSE; + + dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &connected, + DBUS_TYPE_INVALID); + + send_message_and_unref(connection, reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + static void get_handles_reply(DBusPendingCall *call, void *data) { DBusMessage *msg = NULL, *reply; @@ -1561,6 +1585,9 @@ static DBusHandlerResult hs_message(DBusConnection *conn, if (strcmp(member, "Disconnect") == 0) return hs_disconnect(hs, msg); + if (strcmp(member, "IsConnected") == 0) + return hs_is_connected(hs, msg); + if (strcmp(member, "IndicateCall") == 0) return hs_ring(hs, msg); |