aboutsummaryrefslogtreecommitdiff
path: root/cli/mmcli-modem-voice.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2019-06-27 12:02:36 +0200
committerAleksander Morgado <aleksander@aleksander.es>2019-07-11 23:20:59 +0200
commitd56d1b265625ba94c1308f6c0aa43201bab83db3 (patch)
tree6b888264418884202f083b2255fb9ca30b1f2847 /cli/mmcli-modem-voice.c
parentf994982cce641cb770d28c7172ecf09a8a25b124 (diff)
api,voice: new HangupAndAccept() method
This method will hangup the currently active call 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.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/cli/mmcli-modem-voice.c b/cli/mmcli-modem-voice.c
index 089523ef..f1d24e16 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 hangup_and_accept_flag;
static GOptionEntry entries[] = {
{ "voice-list-calls", 0, 0, G_OPTION_ARG_NONE, &list_flag,
@@ -64,6 +65,10 @@ static GOptionEntry entries[] = {
"Delete a call from a given modem",
"[PATH|INDEX]"
},
+ { "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
+ },
{ NULL }
};
@@ -93,7 +98,8 @@ mmcli_modem_voice_options_enabled (void)
n_actions = (list_flag +
!!create_str +
- !!delete_str);
+ !!delete_str +
+ hangup_and_accept_flag);
if (n_actions > 1) {
g_printerr ("error: too many Voice actions requested\n");
@@ -176,6 +182,31 @@ output_call_info (MMCall *call)
}
static void
+hangup_and_accept_process_reply (const GError *error)
+{
+ if (error) {
+ g_printerr ("error: couldn't hangup and accept: '%s'\n",
+ error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("operation successful\n");
+}
+
+static void
+hangup_and_accept_ready (MMModemVoice *modem,
+ GAsyncResult *result,
+ gpointer nothing)
+{
+ GError *error = NULL;
+
+ mm_modem_voice_hangup_and_accept_finish (modem, result, &error);
+ hangup_and_accept_process_reply (error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
list_process_reply (GList *result,
const GError *error)
{
@@ -334,6 +365,16 @@ get_modem_ready (GObject *source,
return;
}
+ /* Request to hangup and accept? */
+ if (hangup_and_accept_flag) {
+ g_debug ("Asynchronously hanging up and accepting next call...");
+ mm_modem_voice_hangup_and_accept (ctx->modem_voice,
+ ctx->cancellable,
+ (GAsyncReadyCallback)hangup_and_accept_ready,
+ NULL);
+ return;
+ }
+
g_warn_if_reached ();
}
@@ -430,5 +471,13 @@ mmcli_modem_voice_run_synchronous (GDBusConnection *connection)
return;
}
+ /* Request to hangup and accept? */
+ if (hangup_and_accept_flag) {
+ g_debug ("Synchronously hanging up and accepting call...");
+ mm_modem_voice_hangup_and_accept_sync (ctx->modem_voice, NULL, &error);
+ hangup_and_accept_process_reply (error);
+ return;
+ }
+
g_warn_if_reached ();
}