From 511b0ff2442f26257be442963ac833f5ba06f80c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 2 Jul 2019 17:53:25 +0200 Subject: [PATCH] api,call: new JoinMultiparty() and LeaveMultiparty() methods --- cli/mmcli-call.c | 106 +++++++ .../libmm-glib/libmm-glib-sections.txt | 14 + .../org.freedesktop.ModemManager1.Call.xml | 27 ++ libmm-glib/mm-call.c | 150 ++++++++++ libmm-glib/mm-call.h | 25 ++ src/mm-base-call.c | 159 ++++++++++ src/mm-iface-modem-voice.c | 282 ++++++++++++++++++ src/mm-iface-modem-voice.h | 38 +++ 8 files changed, 801 insertions(+) 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); @@ -261,6 +273,60 @@ deflect_ready (MMCall *call, mmcli_async_operation_done (); } +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; diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt index dc92cec5..690db8b4 100644 --- a/docs/reference/libmm-glib/libmm-glib-sections.txt +++ b/docs/reference/libmm-glib/libmm-glib-sections.txt @@ -1349,6 +1349,12 @@ mm_call_send_dtmf_sync mm_call_deflect mm_call_deflect_finish mm_call_deflect_sync +mm_call_join_multiparty +mm_call_join_multiparty_finish +mm_call_join_multiparty_sync +mm_call_leave_multiparty +mm_call_leave_multiparty_finish +mm_call_leave_multiparty_sync MMCallClass MMCallPrivate @@ -3264,6 +3270,12 @@ mm_gdbus_call_call_send_dtmf_sync mm_gdbus_call_call_deflect mm_gdbus_call_call_deflect_finish mm_gdbus_call_call_deflect_sync +mm_gdbus_call_call_join_multiparty +mm_gdbus_call_call_join_multiparty_finish +mm_gdbus_call_call_join_multiparty_sync +mm_gdbus_call_call_leave_multiparty +mm_gdbus_call_call_leave_multiparty_finish +mm_gdbus_call_call_leave_multiparty_sync mm_gdbus_call_set_direction mm_gdbus_call_set_number @@ -3277,6 +3289,8 @@ mm_gdbus_call_complete_hangup mm_gdbus_call_complete_send_dtmf mm_gdbus_call_complete_start mm_gdbus_call_complete_deflect +mm_gdbus_call_complete_join_multiparty +mm_gdbus_call_complete_leave_multiparty mm_gdbus_call_interface_info mm_gdbus_call_override_properties mm_gdbus_call_emit_dtmf_received diff --git a/introspection/org.freedesktop.ModemManager1.Call.xml b/introspection/org.freedesktop.ModemManager1.Call.xml index d32b0836..34c01aac 100644 --- a/introspection/org.freedesktop.ModemManager1.Call.xml +++ b/introspection/org.freedesktop.ModemManager1.Call.xml @@ -52,6 +52,33 @@ + + + + + +