diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-01-08 15:28:10 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-01-08 15:28:10 +0000 |
commit | 706c30bdf5498c3fce7fae788ee6e3927fba53f6 (patch) | |
tree | acd9270d22c54d8f662007367d4d064b2f2bfedd /audio | |
parent | 89bb414fbdefa9b17872b652b1b71bc11edb2947 (diff) |
Implement SetupCall method
Diffstat (limited to 'audio')
-rw-r--r-- | audio/headset.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/audio/headset.c b/audio/headset.c index 86286b45..b14261ce 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1397,6 +1397,56 @@ static DBusHandlerResult hs_set_mic_gain(DBusConnection *conn, return hs_set_gain(conn, msg, data, HEADSET_GAIN_MICROPHONE); } +static DBusHandlerResult hf_setup_call(DBusConnection *conn, + DBusMessage *msg, + void *data) +{ + struct device *device = data; + struct headset *hs = device->headset; + DBusMessage *reply; + DBusError derr; + const char *value; + int err; + + if (!hs->hfp_active) + return error_not_supported(device->conn, msg); + + if (hs->state < HEADSET_STATE_CONNECTED) + return error_not_connected(conn, msg); + + dbus_error_init(&derr); + dbus_message_get_args(msg, &derr, DBUS_TYPE_STRING, &value, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&derr)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + + reply = dbus_message_new_method_return(msg); + if (!reply) + return DBUS_HANDLER_RESULT_NEED_MEMORY; + + if (!strncmp(value, "incoming", 8)) + err = headset_send(hs, "\r\n+CIEV:3, 1\r\n"); + else if (!strncmp(value, "outgoing", 8)) + err = headset_send(hs, "\r\n+CIEV:3, 2\r\n"); + else if (!strncmp(value, "remote", 6)) + err = headset_send(hs, "\r\n+CIEV:3, 3\r\n"); + else + err = -EINVAL; + + if (err < 0) { + dbus_message_unref(reply); + return error_failed_errno(conn, msg, -err); + } + + send_message_and_unref(conn, reply); + + return DBUS_HANDLER_RESULT_HANDLED; +} + static DBusMethodVTable headset_methods[] = { { "Connect", hs_connect, "", "" }, { "Disconnect", hs_disconnect, "", "" }, @@ -1410,6 +1460,7 @@ static DBusMethodVTable headset_methods[] = { { "GetMicrophoneGain", hs_get_mic_gain, "", "q" }, { "SetSpeakerGain", hs_set_speaker_gain, "q", "" }, { "SetMicrophoneGain", hs_set_mic_gain, "q", "" }, + { "SetupCall", hf_setup_call, "s", "" }, { NULL, NULL, NULL, NULL } }; |