diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-07-02 17:53:25 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-07-11 23:21:00 +0200 |
commit | 511b0ff2442f26257be442963ac833f5ba06f80c (patch) | |
tree | 8ce57d58f35f162ebb5d3a5be23cbabc51c20a67 /cli/mmcli-call.c | |
parent | 6f235192393fbc345bf79bcf8205d7279f584f91 (diff) |
api,call: new JoinMultiparty() and LeaveMultiparty() methods
Diffstat (limited to 'cli/mmcli-call.c')
-rw-r--r-- | cli/mmcli-call.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/cli/mmcli-call.c b/cli/mmcli-call.c index f3fd9382..99c8b764 100644 --- a/cli/mmcli-call.c +++ b/cli/mmcli-call.c @@ -50,6 +50,8 @@ static gboolean info_flag; /* set when no action found */ static gboolean start_flag; static gboolean accept_flag; static gchar *deflect_str; +static gboolean join_multiparty_flag; +static gboolean leave_multiparty_flag; static gboolean hangup_flag; static gchar *dtmf_request; @@ -66,6 +68,14 @@ static GOptionEntry entries[] = { "Deflect the incoming call", "[NUMBER]", }, + { "join-multiparty", 0, 0, G_OPTION_ARG_NONE, &join_multiparty_flag, + "Join multiparty call", + NULL, + }, + { "leave-multiparty", 0, 0, G_OPTION_ARG_NONE, &leave_multiparty_flag, + "Leave multiparty call", + NULL, + }, { "hangup", 0, 0, G_OPTION_ARG_NONE, &hangup_flag, "Hang up the call", NULL, @@ -105,6 +115,8 @@ mmcli_call_options_enabled (void) n_actions = (start_flag + accept_flag + !!deflect_str + + join_multiparty_flag + + leave_multiparty_flag + hangup_flag + !!dtmf_request); @@ -262,6 +274,60 @@ deflect_ready (MMCall *call, } static void +join_multiparty_process_reply (gboolean result, + const GError *error) +{ + if (!result) { + g_printerr ("error: couldn't join multiparty call: '%s'\n", + error ? error->message : "unknown error"); + exit (EXIT_FAILURE); + } + + g_print ("successfully joined multiparty call\n"); +} + +static void +join_multiparty_ready (MMCall *call, + GAsyncResult *result, + gpointer nothing) +{ + gboolean operation_result; + GError *error = NULL; + + operation_result = mm_call_join_multiparty_finish (call, result, &error); + join_multiparty_process_reply (operation_result, error); + + mmcli_async_operation_done (); +} + +static void +leave_multiparty_process_reply (gboolean result, + const GError *error) +{ + if (!result) { + g_printerr ("error: couldn't leave multiparty call: '%s'\n", + error ? error->message : "unknown error"); + exit (EXIT_FAILURE); + } + + g_print ("successfully left multiparty call\n"); +} + +static void +leave_multiparty_ready (MMCall *call, + GAsyncResult *result, + gpointer nothing) +{ + gboolean operation_result; + GError *error = NULL; + + operation_result = mm_call_leave_multiparty_finish (call, result, &error); + leave_multiparty_process_reply (operation_result, error); + + mmcli_async_operation_done (); +} + +static void hangup_process_reply (gboolean result, const GError *error) { @@ -357,6 +423,24 @@ get_call_ready (GObject *source, return; } + /* Requesting to join multiparty call? */ + if (join_multiparty_flag) { + mm_call_join_multiparty (ctx->call, + ctx->cancellable, + (GAsyncReadyCallback)join_multiparty_ready, + NULL); + return; + } + + /* Requesting to leave multiparty call? */ + if (leave_multiparty_flag) { + mm_call_leave_multiparty (ctx->call, + ctx->cancellable, + (GAsyncReadyCallback)leave_multiparty_ready, + NULL); + return; + } + /* Requesting to hangup the call? */ if (hangup_flag) { mm_call_hangup (ctx->call, @@ -454,6 +538,28 @@ mmcli_call_run_synchronous (GDBusConnection *connection) return; } + /* Requesting to join multiparty call? */ + if (join_multiparty_flag) { + gboolean operation_result; + + operation_result = mm_call_join_multiparty_sync (ctx->call, + NULL, + &error); + join_multiparty_process_reply (operation_result, error); + return; + } + + /* Requesting to leave multiparty call? */ + if (leave_multiparty_flag) { + gboolean operation_result; + + operation_result = mm_call_leave_multiparty_sync (ctx->call, + NULL, + &error); + leave_multiparty_process_reply (operation_result, error); + return; + } + /* Requesting to hangup the call? */ if (hangup_flag) { gboolean operation_result; |