api,call: new JoinMultiparty() and LeaveMultiparty() methods

This commit is contained in:
Aleksander Morgado
2019-07-02 17:53:25 +02:00
parent 6f23519239
commit 511b0ff244
8 changed files with 801 additions and 0 deletions

View File

@@ -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;