diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-06-27 14:03:19 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-07-11 23:20:59 +0200 |
commit | c713c2c5f9ef8b1e674833932e9b91fbcca97050 (patch) | |
tree | fbee69ad36b2a4950597bedd0bd713854b0e23b1 /cli/mmcli-modem-voice.c | |
parent | 5de3c4893fd0dc5b36a9a13c8d2bf8bdb682c9fe (diff) |
api,voice: new HoldAndAccept() method
This method will put the currently active call on hold, and right away
accept the next available call.
The user of the API does not need to specify explicitly which is the
next call to accept, because that is decided automatically:
* If there is any waiting call, it will accept it right away.
* If there is no waiting call but there is a held call, it will make
the held call active again.
Diffstat (limited to 'cli/mmcli-modem-voice.c')
-rw-r--r-- | cli/mmcli-modem-voice.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cli/mmcli-modem-voice.c b/cli/mmcli-modem-voice.c index f1d24e16..e1f1426a 100644 --- a/cli/mmcli-modem-voice.c +++ b/cli/mmcli-modem-voice.c @@ -50,6 +50,7 @@ static Context *ctx; static gboolean list_flag; static gchar *create_str; static gchar *delete_str; +static gboolean hold_and_accept_flag; static gboolean hangup_and_accept_flag; static GOptionEntry entries[] = { @@ -65,6 +66,10 @@ static GOptionEntry entries[] = { "Delete a call from a given modem", "[PATH|INDEX]" }, + { "voice-hold-and-accept", 0, 0, G_OPTION_ARG_NONE, &hold_and_accept_flag, + "Places all active calls in hold and accepts the next waiting or held call", + NULL + }, { "voice-hangup-and-accept", 0, 0, G_OPTION_ARG_NONE, &hangup_and_accept_flag, "Hangs up all active calls and accepts the next waiting or held call", NULL @@ -99,6 +104,7 @@ mmcli_modem_voice_options_enabled (void) n_actions = (list_flag + !!create_str + !!delete_str + + hold_and_accept_flag + hangup_and_accept_flag); if (n_actions > 1) { @@ -207,6 +213,31 @@ hangup_and_accept_ready (MMModemVoice *modem, } static void +hold_and_accept_process_reply (const GError *error) +{ + if (error) { + g_printerr ("error: couldn't hold and accept: '%s'\n", + error->message); + exit (EXIT_FAILURE); + } + + g_print ("operation successful\n"); +} + +static void +hold_and_accept_ready (MMModemVoice *modem, + GAsyncResult *result, + gpointer nothing) +{ + GError *error = NULL; + + mm_modem_voice_hold_and_accept_finish (modem, result, &error); + hold_and_accept_process_reply (error); + + mmcli_async_operation_done (); +} + +static void list_process_reply (GList *result, const GError *error) { @@ -365,6 +396,16 @@ get_modem_ready (GObject *source, return; } + /* Request to hold and accept? */ + if (hold_and_accept_flag) { + g_debug ("Asynchronously holding and accepting next call..."); + mm_modem_voice_hold_and_accept (ctx->modem_voice, + ctx->cancellable, + (GAsyncReadyCallback)hold_and_accept_ready, + NULL); + return; + } + /* Request to hangup and accept? */ if (hangup_and_accept_flag) { g_debug ("Asynchronously hanging up and accepting next call..."); @@ -471,6 +512,14 @@ mmcli_modem_voice_run_synchronous (GDBusConnection *connection) return; } + /* Request to hold and accept? */ + if (hold_and_accept_flag) { + g_debug ("Synchronously holding and accepting call..."); + mm_modem_voice_hold_and_accept_sync (ctx->modem_voice, NULL, &error); + hold_and_accept_process_reply (error); + return; + } + /* Request to hangup and accept? */ if (hangup_and_accept_flag) { g_debug ("Synchronously hanging up and accepting call..."); |