From 4a13bc8fec66efc6f74055c4778e569cf830ac5b Mon Sep 17 00:00:00 2001 From: Marco Bascetta Date: Fri, 8 May 2015 13:54:40 +0200 Subject: mmcli: added --send-tone option --- cli/mmcli-call.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'cli/mmcli-call.c') diff --git a/cli/mmcli-call.c b/cli/mmcli-call.c index e8c18bdf..871d37ee 100644 --- a/cli/mmcli-call.c +++ b/cli/mmcli-call.c @@ -49,6 +49,7 @@ static gboolean info_flag; /* set when no action found */ static gboolean start_flag; static gboolean accept_flag; static gboolean hangup_flag; +static gchar *tone_request; static GOptionEntry entries[] = { { "start", 0, 0, G_OPTION_ARG_NONE, &start_flag, @@ -63,6 +64,10 @@ static GOptionEntry entries[] = { "Hangup the call", NULL, }, + { "send-tone", 0, 0, G_OPTION_ARG_STRING, &tone_request, + "Send specified DTMF tone", + "[0-9A-D*#]" + }, { NULL } }; @@ -93,7 +98,8 @@ mmcli_call_options_enabled (void) n_actions = (start_flag + accept_flag + - hangup_flag ); + hangup_flag + + !!tone_request); if (n_actions == 0 && mmcli_get_common_call_string ()) { /* default to info */ @@ -238,6 +244,33 @@ hangup_ready (MMCall *call, mmcli_async_operation_done (); } +static void +send_tone_process_reply (gboolean result, + const GError *error) +{ + if (!result) { + g_printerr ("error: couldn't send_tone to call: '%s'\n", + error ? error->message : "unknown error"); + exit (EXIT_FAILURE); + } + + g_print ("successfully send tone\n"); +} + +static void +send_tone_ready (MMCall *call, + GAsyncResult *result, + gpointer nothing) +{ + gboolean operation_result; + GError *error = NULL; + + operation_result = mm_call_send_tone_finish (call, result, &error); + send_tone_process_reply (operation_result, error); + + mmcli_async_operation_done (); +} + static void get_call_ready (GObject *source, GAsyncResult *result, @@ -279,6 +312,18 @@ get_call_ready (GObject *source, return; } + /* Requesting to send tone the call? */ + if (tone_request) { + mm_call_send_tone(ctx->call, + tone_request, + ctx->cancellable, + (GAsyncReadyCallback)send_tone_ready, + NULL); + return; + } + + + g_warn_if_reached (); } @@ -354,5 +399,17 @@ mmcli_call_run_synchronous (GDBusConnection *connection) return; } + /* Requesting to send a tone? */ + if (tone_request) { + gboolean operation_result; + + operation_result = mm_call_send_tone_sync (ctx->call, + tone_request, + NULL, + &error); + send_tone_process_reply (operation_result, error); + return; + } + g_warn_if_reached (); } -- cgit v1.2.3-70-g09d2