core,libmm-glib,cli,voice: Replaced 'SendTone' method and 'ToneReceived' signal with 'SendDtmf' and 'DtmfReceived'

This commit is contained in:
Marco Bascetta
2015-08-02 10:39:48 +02:00
committed by Aleksander Morgado
parent 2ac5d620c4
commit 74325b547a
10 changed files with 111 additions and 111 deletions
+19 -19
View File
@@ -49,7 +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 gchar *dtmf_request;
static GOptionEntry entries[] = {
{ "start", 0, 0, G_OPTION_ARG_NONE, &start_flag,
@@ -64,7 +64,7 @@ static GOptionEntry entries[] = {
"Hangup the call",
NULL,
},
{ "send-tone", 0, 0, G_OPTION_ARG_STRING, &tone_request,
{ "send-dtmf", 0, 0, G_OPTION_ARG_STRING, &dtmf_request,
"Send specified DTMF tone",
"[0-9A-D*#]"
},
@@ -99,7 +99,7 @@ mmcli_call_options_enabled (void)
n_actions = (start_flag +
accept_flag +
hangup_flag +
!!tone_request);
!!dtmf_request);
if (n_actions == 0 && mmcli_get_common_call_string ()) {
/* default to info */
@@ -245,28 +245,28 @@ hangup_ready (MMCall *call,
}
static void
send_tone_process_reply (gboolean result,
send_dtmf_process_reply (gboolean result,
const GError *error)
{
if (!result) {
g_printerr ("error: couldn't send_tone to call: '%s'\n",
g_printerr ("error: couldn't send_dtmf to call: '%s'\n",
error ? error->message : "unknown error");
exit (EXIT_FAILURE);
}
g_print ("successfully send tone\n");
g_print ("successfully send dtmf\n");
}
static void
send_tone_ready (MMCall *call,
send_dtmf_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);
operation_result = mm_call_send_dtmf_finish (call, result, &error);
send_dtmf_process_reply (operation_result, error);
mmcli_async_operation_done ();
}
@@ -312,12 +312,12 @@ get_call_ready (GObject *source,
return;
}
/* Requesting to send tone the call? */
if (tone_request) {
mm_call_send_tone (ctx->call,
tone_request,
/* Requesting to send dtmf the call? */
if (dtmf_request) {
mm_call_send_dtmf (ctx->call,
dtmf_request,
ctx->cancellable,
(GAsyncReadyCallback)send_tone_ready,
(GAsyncReadyCallback)send_dtmf_ready,
NULL);
return;
}
@@ -399,15 +399,15 @@ mmcli_call_run_synchronous (GDBusConnection *connection)
return;
}
/* Requesting to send a tone? */
if (tone_request) {
/* Requesting to send a dtmf? */
if (dtmf_request) {
gboolean operation_result;
operation_result = mm_call_send_tone_sync (ctx->call,
tone_request,
operation_result = mm_call_send_dtmf_sync (ctx->call,
dtmf_request,
NULL,
&error);
send_tone_process_reply (operation_result, error);
send_dtmf_process_reply (operation_result, error);
return;
}
@@ -48,25 +48,25 @@
<method name="Hangup"/>
<!--
SendTone:
@tone: Tone identifier. (Admitter chars are [0-9A-D*#])
SendDtmf:
@dtmf: DTMF tone identifier. (Admitter chars are [0-9A-D*#])
Send a DTMF tone (Dual Tone Multi-Frequency) (only on supported modem).
Applicable only if state is <link linkend="MM-CALL-STATE-ACTIVE:CAPS"><constant>MM_CALL_STATE_ACTIVE</constant></link>.
-->
<method name="SendTone">
<arg name="tone" type="s" direction="in"/>
<method name="SendDtmf">
<arg name="dtmf" type="s" direction="in"/>
</method>
<!--
ToneReceived:
@tone: Tone identifier. (Admitter chars are [0-9A-D*#])
DtmfReceived:
@dtmf: DTMF tone identifier. (Admitter chars are [0-9A-D*#])
Emitted when a DTMF tone is received (only on supported modem)
-->
<signal name="ToneReceived">
<arg name="tone" type="s" />
<signal name="DtmfReceived">
<arg name="dtmf" type="s" />
</signal>
<!--
+20 -20
View File
@@ -414,82 +414,82 @@ mm_call_hangup_sync (MMCall *self,
/*****************************************************************************/
/**
* mm_call_send_tone_finish:
* mm_call_send_dtmf_finish:
* @self: A #MMCall.
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_call_send_tone().
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_call_send_dtmf().
* @error: Return location for error or %NULL.
*
* Finishes an operation started with mm_call_send_tone().
* Finishes an operation started with mm_call_send_dtmf().
*
* Returns: %TRUE if the operation succeded, %FALSE if @error is set.
*/
gboolean
mm_call_send_tone_finish (MMCall *self,
mm_call_send_dtmf_finish (MMCall *self,
GAsyncResult *res,
GError **error)
{
g_return_val_if_fail (MM_IS_CALL (self), FALSE);
return mm_gdbus_call_call_send_tone_finish (MM_GDBUS_CALL (self), res, error);
return mm_gdbus_call_call_send_dtmf_finish (MM_GDBUS_CALL (self), res, error);
}
/**
* mm_call_send_tone:
* mm_call_send_dtmf:
* @self: A #MMCall.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
* @user_data: User data to pass to @callback.
*
* Asynchronously requests to send tone the call.
* Asynchronously requests to send a DTMF tone the call.
*
* Call objects can only be executed once.
*
* When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
* You can then call mm_call_send_tone_finish() to get the result of the operation.
* You can then call mm_call_send_dtmf_finish() to get the result of the operation.
*
* See mm_call_send_tone_sync() for the synchronous, blocking version of this method.
* See mm_call_send_dtmf_sync() for the synchronous, blocking version of this method.
*/
void
mm_call_send_tone (MMCall *self,
const gchar *tone,
mm_call_send_dtmf (MMCall *self,
const gchar *dtmf,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (MM_IS_CALL (self));
mm_gdbus_call_call_send_tone (MM_GDBUS_CALL (self),
tone,
mm_gdbus_call_call_send_dtmf (MM_GDBUS_CALL (self),
dtmf,
cancellable,
callback,
user_data);
}
/**
* mm_call_send_tone_sync:
* mm_call_send_dtmf_sync:
* @self: A #MMCall.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
* Synchronously requests to send tone the call.
* Synchronously requests to send a DTMF tone the call.
*
* Call objects can only be sent once.
*
* The calling thread is blocked until an incoming call is ready.
* See mm_call_send_tone() for the asynchronous version of this method.
* See mm_call_send_dtmf() for the asynchronous version of this method.
*
* Returns: %TRUE if the operation succeded, %FALSE if @error is set.
*/
gboolean
mm_call_send_tone_sync (MMCall *self,
const gchar *tone,
mm_call_send_dtmf_sync (MMCall *self,
const gchar *dtmf,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (MM_IS_CALL (self), FALSE);
return mm_gdbus_call_call_send_tone_sync (MM_GDBUS_CALL (self),
tone,
return mm_gdbus_call_call_send_dtmf_sync (MM_GDBUS_CALL (self),
dtmf,
cancellable,
error);
}
+5 -5
View File
@@ -115,18 +115,18 @@ gboolean mm_call_hangup_sync (MMCall *self,
GError **error);
void mm_call_send_tone (MMCall *self,
const gchar *tone,
void mm_call_send_dtmf (MMCall *self,
const gchar *dtmf,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_call_send_tone_finish (MMCall *self,
gboolean mm_call_send_dtmf_finish (MMCall *self,
GAsyncResult *res,
GError **error);
gboolean mm_call_send_tone_sync (MMCall *self,
const gchar *tone,
gboolean mm_call_send_dtmf_sync (MMCall *self,
const gchar *dtmf,
GCancellable *cancellable,
GError **error);
+49 -49
View File
@@ -363,95 +363,95 @@ handle_hangup (MMBaseCall *self,
}
/*****************************************************************************/
/* Send tone (DBus call handling) */
/* Send dtmf (DBus call handling) */
typedef struct {
MMBaseCall *self;
MMBaseModem *modem;
GDBusMethodInvocation *invocation;
gchar *tone;
} HandleSendToneContext;
gchar *dtmf;
} HandleSendDtmfContext;
static void
handle_send_tone_context_free (HandleSendToneContext *ctx)
handle_send_dtmf_context_free (HandleSendDtmfContext *ctx)
{
g_object_unref (ctx->invocation);
g_object_unref (ctx->modem);
g_object_unref (ctx->self);
g_free(ctx->tone);
g_free(ctx->dtmf);
g_free (ctx);
}
static void
handle_send_tone_ready (MMBaseCall *self,
handle_send_dtmf_ready (MMBaseCall *self,
GAsyncResult *res,
HandleSendToneContext *ctx)
HandleSendDtmfContext *ctx)
{
GError *error = NULL;
if (!MM_BASE_CALL_GET_CLASS (self)->send_tone_finish (self, res, &error)) {
if (!MM_BASE_CALL_GET_CLASS (self)->send_dtmf_finish (self, res, &error)) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
} else {
mm_gdbus_call_complete_send_tone (MM_GDBUS_CALL (ctx->self), ctx->invocation);
mm_gdbus_call_complete_send_dtmf (MM_GDBUS_CALL (ctx->self), ctx->invocation);
}
handle_send_tone_context_free (ctx);
handle_send_dtmf_context_free (ctx);
}
static void
handle_send_tone_auth_ready (MMBaseModem *modem,
handle_send_dtmf_auth_ready (MMBaseModem *modem,
GAsyncResult *res,
HandleSendToneContext *ctx)
HandleSendDtmfContext *ctx)
{
MMCallState state;
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_send_tone_context_free (ctx);
handle_send_dtmf_context_free (ctx);
return;
}
state = mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self));
/* Check if we do support doing it */
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->send_tone ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->send_tone_finish) {
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->send_dtmf ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->send_dtmf_finish) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Sending tone is not supported by this modem");
handle_send_tone_context_free (ctx);
"Sending dtmf is not supported by this modem");
handle_send_dtmf_context_free (ctx);
return;
}
/* We can only send_tone when call is in ACTIVE state */
/* We can only send_dtmf when call is in ACTIVE state */
if (state != MM_CALL_STATE_ACTIVE ){
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"This call was not active, cannot send tone");
handle_send_tone_context_free (ctx);
"This call was not active, cannot send dtmf");
handle_send_dtmf_context_free (ctx);
return;
}
MM_BASE_CALL_GET_CLASS (ctx->self)->send_tone (ctx->self, ctx->tone,
(GAsyncReadyCallback)handle_send_tone_ready,
MM_BASE_CALL_GET_CLASS (ctx->self)->send_dtmf (ctx->self, ctx->dtmf,
(GAsyncReadyCallback)handle_send_dtmf_ready,
ctx);
}
static gboolean
handle_send_tone (MMBaseCall *self,
handle_send_dtmf (MMBaseCall *self,
GDBusMethodInvocation *invocation,
const gchar *tone)
const gchar *dtmf)
{
HandleSendToneContext *ctx;
HandleSendDtmfContext *ctx;
ctx = g_new0 (HandleSendToneContext, 1);
ctx = g_new0 (HandleSendDtmfContext, 1);
ctx->self = g_object_ref (self);
ctx->invocation = g_object_ref (invocation);
ctx->tone = g_strdup(tone);
ctx->dtmf = g_strdup(dtmf);
g_object_get (self,
MM_BASE_CALL_MODEM, &ctx->modem,
NULL);
@@ -459,7 +459,7 @@ handle_send_tone (MMBaseCall *self,
mm_base_modem_authorize (ctx->modem,
invocation,
MM_AUTHORIZATION_VOICE,
(GAsyncReadyCallback)handle_send_tone_auth_ready,
(GAsyncReadyCallback)handle_send_dtmf_auth_ready,
ctx);
return TRUE;
}
@@ -508,8 +508,8 @@ call_dbus_export (MMBaseCall *self)
G_CALLBACK (handle_hangup),
NULL);
g_signal_connect (self,
"handle-send-tone",
G_CALLBACK (handle_send_tone),
"handle-send-dtmf",
G_CALLBACK (handle_send_dtmf),
NULL);
@@ -559,9 +559,9 @@ mm_base_call_change_state(MMBaseCall *self, MMCallState new_state, MMCallStateRe
reason);
}
void mm_base_call_received_dtmf (MMBaseCall *self, gchar *tone)
void mm_base_call_received_dtmf (MMBaseCall *self, gchar *dtmf)
{
mm_gdbus_call_emit_tone_received(MM_GDBUS_CALL (self), tone);
mm_gdbus_call_emit_dtmf_received(MM_GDBUS_CALL (self), dtmf);
}
/*****************************************************************************/
@@ -872,10 +872,10 @@ typedef struct {
MMBaseCall *self;
MMBaseModem *modem;
GSimpleAsyncResult *result;
} CallSendToneContext;
} CallSendDtmfContext;
static void
call_send_tone_context_complete_and_free (CallSendToneContext *ctx)
call_send_dtmf_context_complete_and_free (CallSendDtmfContext *ctx)
{
g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result);
@@ -885,7 +885,7 @@ call_send_tone_context_complete_and_free (CallSendToneContext *ctx)
}
static gboolean
call_send_tone_finish (MMBaseCall *self,
call_send_dtmf_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error)
{
@@ -893,49 +893,49 @@ call_send_tone_finish (MMBaseCall *self,
}
static void
call_send_tone_ready (MMBaseModem *modem,
call_send_dtmf_ready (MMBaseModem *modem,
GAsyncResult *res,
CallSendToneContext *ctx)
CallSendDtmfContext *ctx)
{
GError *error = NULL;
const gchar *response = NULL;
response = mm_base_modem_at_command_finish (modem, res, &error);
if (error) {
mm_dbg ("Couldn't send_tone: '%s'", error->message);
mm_dbg ("Couldn't send_dtmf: '%s'", error->message);
g_simple_async_result_take_error (ctx->result, error);
call_send_tone_context_complete_and_free (ctx);
call_send_dtmf_context_complete_and_free (ctx);
return;
}
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
call_send_tone_context_complete_and_free (ctx);
call_send_dtmf_context_complete_and_free (ctx);
}
static void
call_send_tone (MMBaseCall *self,
const gchar *tone,
call_send_dtmf (MMBaseCall *self,
const gchar *dtmf,
GAsyncReadyCallback callback,
gpointer user_data)
{
CallSendToneContext *ctx;
CallSendDtmfContext *ctx;
gchar *cmd;
/* Setup the context */
ctx = g_new0 (CallSendToneContext, 1);
ctx = g_new0 (CallSendDtmfContext, 1);
ctx->result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
call_send_tone);
call_send_dtmf);
ctx->self = g_object_ref (self);
ctx->modem = g_object_ref (self->priv->modem);
cmd = g_strdup_printf ("AT+VTS=%c", tone[0]);
cmd = g_strdup_printf ("AT+VTS=%c", dtmf[0]);
mm_base_modem_at_command (ctx->modem,
cmd,
3,
FALSE,
(GAsyncReadyCallback)call_send_tone_ready,
(GAsyncReadyCallback)call_send_dtmf_ready,
ctx);
g_free (cmd);
@@ -1200,8 +1200,8 @@ mm_base_call_class_init (MMBaseCallClass *klass)
klass->hangup_finish = call_hangup_finish;
klass->delete = call_delete;
klass->delete_finish = call_delete_finish;
klass->send_tone = call_send_tone;
klass->send_tone_finish = call_send_tone_finish;
klass->send_dtmf = call_send_dtmf;
klass->send_dtmf_finish = call_send_dtmf_finish;
properties[PROP_CONNECTION] =
+4 -4
View File
@@ -72,11 +72,11 @@ struct _MMBaseCallClass {
GError **error);
/* Send a DTMF tone */
void (* send_tone) (MMBaseCall *self,
const gchar *tone,
void (* send_dtmf) (MMBaseCall *self,
const gchar *dtmf,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* send_tone_finish) (MMBaseCall *self,
gboolean (* send_dtmf_finish) (MMBaseCall *self,
GAsyncResult *res,
GError **error);
@@ -104,7 +104,7 @@ void mm_base_call_change_state (MMBaseCall *self,
MMCallState new_state,
MMCallStateReason reason);
void mm_base_call_received_dtmf (MMBaseCall *self,
gchar *tone);
gchar *dtmf);
void mm_base_call_delete (MMBaseCall *self,
GAsyncReadyCallback callback,
+2 -2
View File
@@ -189,7 +189,7 @@ MMBaseCall* mm_call_list_get_first_non_terminated_call(MMCallList *self)
return call;
}
gboolean mm_call_list_send_dtmf_to_active_calls(MMCallList *self, gchar *tone)
gboolean mm_call_list_send_dtmf_to_active_calls(MMCallList *self, gchar *dtmf)
{
gboolean signaled = FALSE;
GList *l;
@@ -205,7 +205,7 @@ gboolean mm_call_list_send_dtmf_to_active_calls(MMCallList *self, gchar *tone)
if( state == MM_CALL_STATE_ACTIVE ) {
signaled = TRUE;
mm_base_call_received_dtmf(MM_BASE_CALL (l->data), tone);
mm_base_call_received_dtmf(MM_BASE_CALL (l->data), dtmf);
}
}
+1 -1
View File
@@ -77,6 +77,6 @@ MMBaseCall* mm_call_list_get_first_ringing_call (MMCallList *self);
MMBaseCall* mm_call_list_get_first_outgoing_dialing_call(MMCallList *self);
MMBaseCall* mm_call_list_get_first_non_terminated_call (MMCallList *self);
gboolean mm_call_list_send_dtmf_to_active_calls (MMCallList *self,
gchar *tone);
gchar *dtmf);
#endif /* MM_CALL_LIST_H */
+2 -2
View File
@@ -196,7 +196,7 @@ mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self)
gboolean
mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self,
gchar *tone)
gchar *dtmf)
{
gboolean updated = FALSE;
MMCallList *list = NULL;
@@ -206,7 +206,7 @@ mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self,
NULL);
if (list) {
updated = mm_call_list_send_dtmf_to_active_calls (list, tone);
updated = mm_call_list_send_dtmf_to_active_calls (list, dtmf);
}
return updated;
+1 -1
View File
@@ -127,7 +127,7 @@ gboolean mm_iface_modem_voice_call_dialing_to_ringing (MMIfaceModemVoi
gboolean mm_iface_modem_voice_call_ringing_to_active (MMIfaceModemVoice *self);
gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self);
gboolean mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self,
gchar *tone);
gchar *dtmf);
/* Look for a new valid multipart reference */
guint8 mm_iface_modem_voice_get_local_multipart_reference (MMIfaceModemVoice *self,