core,voice: minor coding style fixes

This commit is contained in:
Aleksander Morgado
2015-05-23 17:31:19 +02:00
parent 61562fbe8b
commit e75d888b51
5 changed files with 214 additions and 215 deletions

View File

@@ -74,8 +74,8 @@ handle_start_context_free (HandleStartContext *ctx)
static void
handle_start_ready (MMBaseCall *self,
GAsyncResult *res,
HandleStartContext *ctx)
GAsyncResult *res,
HandleStartContext *ctx)
{
GError *error = NULL;
@@ -84,9 +84,8 @@ handle_start_ready (MMBaseCall *self,
} else {
/* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_UNKNOWN ) {
/* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_DIALING, MM_CALL_STATE_REASON_OUTGOING_STARTED);
mm_base_call_change_state (self, MM_CALL_STATE_DIALING, MM_CALL_STATE_REASON_OUTGOING_STARTED);
}
mm_gdbus_call_complete_start (MM_GDBUS_CALL (ctx->self), ctx->invocation);
}
@@ -96,8 +95,8 @@ handle_start_ready (MMBaseCall *self,
static void
handle_start_auth_ready (MMBaseModem *modem,
GAsyncResult *res,
HandleStartContext *ctx)
GAsyncResult *res,
HandleStartContext *ctx)
{
MMCallState state;
GError *error = NULL;
@@ -110,8 +109,8 @@ handle_start_auth_ready (MMBaseModem *modem,
/* We can only start call created by the user */
state = mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self));
if (state != MM_CALL_STATE_UNKNOWN ){
if (state != MM_CALL_STATE_UNKNOWN) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
@@ -130,15 +129,15 @@ handle_start_auth_ready (MMBaseModem *modem,
handle_start_context_free (ctx);
return;
}
MM_BASE_CALL_GET_CLASS (ctx->self)->start (ctx->self,
(GAsyncReadyCallback)handle_start_ready,
ctx);
(GAsyncReadyCallback)handle_start_ready,
ctx);
}
static gboolean
handle_start (MMBaseCall *self,
GDBusMethodInvocation *invocation)
GDBusMethodInvocation *invocation)
{
HandleStartContext *ctx;
@@ -158,7 +157,6 @@ handle_start (MMBaseCall *self,
}
/*****************************************************************************/
/* Accept call (DBus call handling) */
typedef struct {
@@ -188,9 +186,8 @@ handle_accept_ready (MMBaseCall *self,
} else {
/* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_RINGING_IN) {
/* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
mm_base_call_change_state (self, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
}
mm_gdbus_call_complete_accept (MM_GDBUS_CALL (ctx->self), ctx->invocation);
}
@@ -200,8 +197,8 @@ handle_accept_ready (MMBaseCall *self,
static void
handle_accept_auth_ready (MMBaseModem *modem,
GAsyncResult *res,
HandleAcceptContext *ctx)
GAsyncResult *res,
HandleAcceptContext *ctx)
{
MMCallState state;
GError *error = NULL;
@@ -213,9 +210,9 @@ handle_accept_auth_ready (MMBaseModem *modem,
}
state = mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self));
/* We can only accept incoming call in ringing state */
if (state != MM_CALL_STATE_RINGING_IN ){
if (state != MM_CALL_STATE_RINGING_IN) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
@@ -236,13 +233,13 @@ handle_accept_auth_ready (MMBaseModem *modem,
}
MM_BASE_CALL_GET_CLASS (ctx->self)->accept (ctx->self,
(GAsyncReadyCallback)handle_accept_ready,
ctx);
(GAsyncReadyCallback)handle_accept_ready,
ctx);
}
static gboolean
handle_accept (MMBaseCall *self,
GDBusMethodInvocation *invocation)
GDBusMethodInvocation *invocation)
{
HandleAcceptContext *ctx;
@@ -282,8 +279,8 @@ handle_hangup_context_free (HandleHangupContext *ctx)
static void
handle_hangup_ready (MMBaseCall *self,
GAsyncResult *res,
HandleHangupContext *ctx)
GAsyncResult *res,
HandleHangupContext *ctx)
{
GError *error = NULL;
@@ -292,10 +289,9 @@ handle_hangup_ready (MMBaseCall *self,
} else {
/* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) != MM_CALL_STATE_TERMINATED ||
mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) != MM_CALL_STATE_UNKNOWN ){
mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) != MM_CALL_STATE_UNKNOWN) {
/* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
}
mm_gdbus_call_complete_hangup (MM_GDBUS_CALL (ctx->self), ctx->invocation);
}
@@ -305,8 +301,8 @@ handle_hangup_ready (MMBaseCall *self,
static void
handle_hangup_auth_ready (MMBaseModem *modem,
GAsyncResult *res,
HandleHangupContext *ctx)
GAsyncResult *res,
HandleHangupContext *ctx)
{
MMCallState state;
GError *error = NULL;
@@ -318,13 +314,13 @@ handle_hangup_auth_ready (MMBaseModem *modem,
}
state = mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self));
/* We can only hangup call in a valid state */
if (state == MM_CALL_STATE_TERMINATED || state == MM_CALL_STATE_UNKNOWN ){
if (state == MM_CALL_STATE_TERMINATED || state == MM_CALL_STATE_UNKNOWN) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"This call was not active, cannot hangup ");
"This call was not active, cannot hangup");
handle_hangup_context_free (ctx);
return;
}
@@ -341,13 +337,13 @@ handle_hangup_auth_ready (MMBaseModem *modem,
}
MM_BASE_CALL_GET_CLASS (ctx->self)->hangup (ctx->self,
(GAsyncReadyCallback)handle_hangup_ready,
ctx);
(GAsyncReadyCallback)handle_hangup_ready,
ctx);
}
static gboolean
handle_hangup (MMBaseCall *self,
GDBusMethodInvocation *invocation)
GDBusMethodInvocation *invocation)
{
HandleHangupContext *ctx;
@@ -367,7 +363,6 @@ handle_hangup (MMBaseCall *self,
}
/*****************************************************************************/
/* Send tone (DBus call handling) */
typedef struct {
@@ -405,8 +400,8 @@ handle_send_tone_ready (MMBaseCall *self,
static void
handle_send_tone_auth_ready (MMBaseModem *modem,
GAsyncResult *res,
HandleSendToneContext *ctx)
GAsyncResult *res,
HandleSendToneContext *ctx)
{
MMCallState state;
GError *error = NULL;
@@ -425,7 +420,7 @@ handle_send_tone_auth_ready (MMBaseModem *modem,
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"SendToneing call is not supported by this modem");
"Sending tone is not supported by this modem");
handle_send_tone_context_free (ctx);
return;
}
@@ -435,15 +430,14 @@ handle_send_tone_auth_ready (MMBaseModem *modem,
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"This call was not active, cannot send_tone ");
"This call was not active, cannot send tone");
handle_send_tone_context_free (ctx);
return;
}
mm_dbg("[%s:%d] Tone string: '%s'", __func__, __LINE__, ctx->tone);
MM_BASE_CALL_GET_CLASS (ctx->self)->send_tone (ctx->self, ctx->tone,
(GAsyncReadyCallback)handle_send_tone_ready,
ctx);
(GAsyncReadyCallback)handle_send_tone_ready,
ctx);
}
static gboolean
@@ -457,7 +451,6 @@ handle_send_tone (MMBaseCall *self,
ctx->self = g_object_ref (self);
ctx->invocation = g_object_ref (invocation);
mm_dbg("[%s:%d] Tone string: '%s'", __func__, __LINE__, tone);
ctx->tone = g_strdup(tone);
g_object_get (self,
MM_BASE_CALL_MODEM, &ctx->modem,
@@ -551,7 +544,7 @@ void
mm_base_call_change_state(MMBaseCall *self, MMCallState new_state, MMCallStateReason reason)
{
int old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self));
g_object_set (self,
"state", new_state,
"state-reason", reason,
@@ -559,8 +552,8 @@ mm_base_call_change_state(MMBaseCall *self, MMCallState new_state, MMCallStateRe
mm_gdbus_call_set_state (MM_GDBUS_CALL (self), new_state);
mm_gdbus_call_set_state_reason(MM_GDBUS_CALL (self), reason);
mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (self),
mm_gdbus_call_emit_state_changed(MM_GDBUS_CALL (self),
old_state,
new_state,
reason);
@@ -611,13 +604,13 @@ call_start_ready (MMBaseModem *modem,
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
/* something is wrong, serial timeout could never occurs */
}
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_DIALTONE)) {
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
}
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_BUSY) ||
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_BUSY) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_ANSWER) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER) )
{
@@ -630,9 +623,9 @@ call_start_ready (MMBaseModem *modem,
call_start_context_complete_and_free (ctx);
return;
}
/* check response for error */
if( response && strlen(response) > 0 ) {
if (response && strlen (response) > 0 ) {
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't start the call: "
"Modem response '%s'", response);
@@ -648,7 +641,7 @@ call_start_ready (MMBaseModem *modem,
call_start_context_complete_and_free (ctx);
return;
}
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
call_start_context_complete_and_free (ctx);
}
@@ -677,7 +670,7 @@ call_start (MMBaseCall *self,
FALSE,
(GAsyncReadyCallback)call_start_ready,
ctx);
/* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED);
g_free (cmd);
@@ -705,16 +698,16 @@ call_accept_context_complete_and_free (CallAcceptContext *ctx)
static gboolean
call_accept_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
static void
call_accept_ready (MMBaseModem *modem,
GAsyncResult *res,
CallAcceptContext *ctx)
GAsyncResult *res,
CallAcceptContext *ctx)
{
GError *error = NULL;
const gchar *response;
@@ -731,35 +724,35 @@ call_accept_ready (MMBaseModem *modem,
g_error_free (error);
return;
}
/* check response for error */
if( response && strlen(response) > 0 ) {
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't accept the call: "
"Unhandled response '%s'", response);
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
} else {
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
}
if (error) {
g_simple_async_result_take_error (ctx->result, error);
call_accept_context_complete_and_free (ctx);
return;
}
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
call_accept_context_complete_and_free (ctx);
}
static void
call_accept (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
CallAcceptContext *ctx;
gchar *cmd;
@@ -831,24 +824,24 @@ call_hangup_ready (MMBaseModem *modem,
g_error_free (error);
return;
}
/* Update state */
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
if (error) {
g_simple_async_result_take_error (ctx->result, error);
call_hangup_context_complete_and_free (ctx);
return;
}
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
call_hangup_context_complete_and_free (ctx);
}
static void
call_hangup (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
CallHangupContext *ctx;
gchar *cmd;
@@ -893,16 +886,16 @@ call_send_tone_context_complete_and_free (CallSendToneContext *ctx)
static gboolean
call_send_tone_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
static void
call_send_tone_ready (MMBaseModem *modem,
GAsyncResult *res,
CallSendToneContext *ctx)
GAsyncResult *res,
CallSendToneContext *ctx)
{
GError *error = NULL;
const gchar *response = NULL;
@@ -937,8 +930,7 @@ call_send_tone (MMBaseCall *self,
ctx->self = g_object_ref (self);
ctx->modem = g_object_ref (self->priv->modem);
mm_dbg("[%s:%d] Tone string: '%s'", __func__, __LINE__, tone);
cmd = g_strdup_printf ("AT+VTS=%c",tone[0]);
cmd = g_strdup_printf ("AT+VTS=%c", tone[0]);
mm_base_modem_at_command (ctx->modem,
cmd,
3,
@@ -1044,7 +1036,7 @@ mm_base_call_new_from_properties (MMBaseModem *modem,
{
MMBaseCall *self;
const gchar *number;
MMCallDirection direction;
MMCallDirection direction;
g_assert (MM_IS_IFACE_MODEM_VOICE (modem));
@@ -1059,7 +1051,7 @@ mm_base_call_new_from_properties (MMBaseModem *modem,
"Cannot create call: mandatory parameter 'number' is missing");
return NULL;
}
/* if no direction is specified force to outgoing */
if(direction == MM_CALL_DIRECTION_UNKNOWN ) {
direction = MM_CALL_DIRECTION_OUTGOING;

View File

@@ -35,9 +35,9 @@ typedef struct _MMBaseCall MMBaseCall;
typedef struct _MMBaseCallClass MMBaseCallClass;
typedef struct _MMBaseCallPrivate MMBaseCallPrivate;
#define MM_BASE_CALL_PATH "call-path"
#define MM_BASE_CALL_CONNECTION "call-connection"
#define MM_BASE_CALL_MODEM "call-modem"
#define MM_BASE_CALL_PATH "call-path"
#define MM_BASE_CALL_CONNECTION "call-connection"
#define MM_BASE_CALL_MODEM "call-modem"
struct _MMBaseCall {
MmGdbusCallSkeleton parent;
@@ -48,31 +48,31 @@ struct _MMBaseCallClass {
MmGdbusCallSkeletonClass parent;
/* Start the call */
void (* start) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
void (* start) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* start_finish) (MMBaseCall *self,
GAsyncResult *res,
GError **error);
GAsyncResult *res,
GError **error);
/* Accept the call */
void (* accept) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
void (* accept) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* accept_finish) (MMBaseCall *self,
GAsyncResult *res,
GError **error);
GAsyncResult *res,
GError **error);
/* Hangup the call */
void (* hangup) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
void (* hangup) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* hangup_finish) (MMBaseCall *self,
GAsyncResult *res,
GError **error);
GAsyncResult *res,
GError **error);
/* Send a DTMF tone */
void (* send_tone) (MMBaseCall *self,
void (* send_tone) (MMBaseCall *self,
const gchar *tone,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -81,9 +81,9 @@ struct _MMBaseCallClass {
GError **error);
/* Delete the call */
void (* delete) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
void (* delete) (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* delete_finish) (MMBaseCall *self,
GAsyncResult *res,
GError **error);
@@ -94,20 +94,23 @@ GType mm_base_call_get_type (void);
/* This one can be overriden by plugins */
MMBaseCall *mm_base_call_new (MMBaseModem *modem);
MMBaseCall *mm_base_call_new_from_properties (MMBaseModem *modem,
MMCallProperties *properties,
GError **error);
MMCallProperties *properties,
GError **error);
void mm_base_call_export (MMBaseCall *self);
void mm_base_call_unexport (MMBaseCall *self);
const gchar *mm_base_call_get_path (MMBaseCall *self);
void mm_base_call_change_state (MMBaseCall *self, MMCallState new_state, MMCallStateReason reason);
void mm_base_call_received_dtmf (MMBaseCall *self, gchar *tone);
void mm_base_call_export (MMBaseCall *self);
void mm_base_call_unexport (MMBaseCall *self);
const gchar *mm_base_call_get_path (MMBaseCall *self);
void mm_base_call_change_state (MMBaseCall *self,
MMCallState new_state,
MMCallStateReason reason);
void mm_base_call_received_dtmf (MMBaseCall *self,
gchar *tone);
void mm_base_call_delete (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_base_call_delete_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error);
void mm_base_call_delete (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_base_call_delete_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error);
#endif /* MM_BASE_CALL_H */

View File

@@ -6212,12 +6212,12 @@ modem_messaging_create_sms (MMIfaceModemMessaging *self)
}
/*****************************************************************************/
/* Check if Voice supported (Voice interface) */
static gboolean
modem_voice_check_support_finish (MMIfaceModemVoice *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -6255,7 +6255,7 @@ modem_voice_check_support (MMIfaceModemVoice *self,
user_data,
modem_voice_check_support);
/* We assume that all modems has voice capabilities, but ... */
/* We assume that all modems have voice capabilities, but ... */
/* Check ATH support */
mm_base_modem_at_command (MM_BASE_MODEM (self),
@@ -6282,10 +6282,8 @@ ring_received (MMPortSerialAt *port,
GMatchInfo *info,
MMBroadbandModem *self)
{
//Do not match anything from regex
(void)info;
mm_iface_modem_voice_create_incoming_call(MM_IFACE_MODEM_VOICE(self));
mm_dbg ("Ringing");
mm_iface_modem_voice_create_incoming_call (MM_IFACE_MODEM_VOICE (self));
}
static void
@@ -6294,11 +6292,15 @@ cring_received (MMPortSerialAt *port,
MMBroadbandModem *self)
{
/* The match info gives us in which storage the index applies */
gchar *str = mm_get_string_unquoted_from_match_info (info, 1);
//TODO: In str you could have "VOICE" or "DATA". Now consider only "VOICE"
gchar *str;
/* We could have "VOICE" or "DATA". Now consider only "VOICE" */
str = mm_get_string_unquoted_from_match_info (info, 1);
mm_dbg ("Ringing (%s)", str);
g_free (str);
mm_iface_modem_voice_create_incoming_call(MM_IFACE_MODEM_VOICE(self));
mm_iface_modem_voice_create_incoming_call (MM_IFACE_MODEM_VOICE (self));
}
static void
@@ -6307,20 +6309,22 @@ clip_received (MMPortSerialAt *port,
MMBroadbandModem *self)
{
/* The match info gives us in which storage the index applies */
gchar *str = mm_get_string_unquoted_from_match_info (info, 1);
gchar *str;
if( str ) {
str = mm_get_string_unquoted_from_match_info (info, 1);
if (str) {
guint validity = 0;
guint type = 0;
mm_get_uint_from_match_info (info, 2, &type);
mm_get_uint_from_match_info (info, 3, &validity);
mm_dbg ("[%s:%d] CLIP regex => number:'%s', type:'%d', validity:'%d'", __func__, __LINE__, str, type, validity);
mm_dbg ("Caller ID received: number '%s', type '%d', validity '%d'", str, type, validity);
mm_iface_modem_voice_update_incoming_call_number(MM_IFACE_MODEM_VOICE(self), str, type, validity);
mm_iface_modem_voice_update_incoming_call_number (MM_IFACE_MODEM_VOICE (self), str, type, validity);
g_free(str);
g_free (str);
}
}
@@ -6329,11 +6333,8 @@ nocarrier_received (MMPortSerialAt *port,
GMatchInfo *info,
MMBroadbandModem *self)
{
//Do not match anything from regex
(void)info;
mm_dbg ("[%s:%d]", __func__, __LINE__);
mm_iface_modem_voice_network_hangup(MM_IFACE_MODEM_VOICE(self));
mm_dbg ("No carrier");
mm_iface_modem_voice_network_hangup (MM_IFACE_MODEM_VOICE (self));
}
static void
@@ -6466,7 +6467,6 @@ ring_response_processor (MMBaseModem *self,
static const MMBaseModemAtCommand ring_sequence[] = {
/* Show caller number on RING. */
{ "+CLIP=1", 3, FALSE, ring_response_processor },
/* Show difference between data call and voice call */
{ "+CRC=1", 3, FALSE, ring_response_processor },
{ NULL }

View File

@@ -49,19 +49,18 @@ mm_iface_modem_voice_create_call (MMIfaceModemVoice *self)
MMBaseCall *
mm_iface_modem_voice_create_incoming_call (MMIfaceModemVoice *self)
{
MMBaseCall *call = NULL;
MMCallList *list = NULL;
MMBaseCall *call = NULL;
MMCallList *list = NULL;
g_object_get (MM_BASE_MODEM (self),
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
if (list) {
call = mm_call_list_get_new_incoming (list);
call = mm_call_list_get_new_incoming(list);
if( !call ) {
mm_dbg("[%s:%d] Incoming call does not exist; create it", __func__, __LINE__);
if (!call) {
mm_dbg("Incoming call does not exist; create it");
call = mm_base_call_new (MM_BASE_MODEM (self));
g_object_set (call,
@@ -72,13 +71,10 @@ mm_iface_modem_voice_create_incoming_call (MMIfaceModemVoice *self)
/* Only export once properly created */
mm_base_call_export (call);
mm_dbg ("[%s:%d] New call exported to DBUS", __func__, __LINE__);
mm_dbg ("New call exported to DBus");
mm_call_list_add_call(list, call);
mm_dbg ("[%s:%d] Call added to list", __func__, __LINE__);
} else {
// mm_dbg("[%s:%d] Incoming call already exist. Do nothing", __func__, __LINE__);
mm_call_list_add_call (list, call);
mm_dbg ("Call added to the list");
}
g_object_unref (list);
@@ -87,7 +83,11 @@ mm_iface_modem_voice_create_incoming_call (MMIfaceModemVoice *self)
return call;
}
gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *self, gchar *number, guint type, guint validity)
gboolean
mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *self,
gchar *number,
guint type,
guint validity)
{
gboolean updated = FALSE;
MMBaseCall *call = NULL;
@@ -97,27 +97,30 @@ gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *se
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
if (list) {
call = mm_call_list_get_new_incoming (list);
call = mm_call_list_get_new_incoming(list);
if( call ) {
if (call) {
g_object_set (call, "number", number, NULL);
mm_gdbus_call_set_number(MM_GDBUS_CALL (call), number);
mm_gdbus_call_set_number (MM_GDBUS_CALL (call), number);
//TODO: Maybe also this parameters should be used
(void)type;
(void)validity;
/*
* TODO: Maybe also this parameters should be used:
* - type
* - validity
*/
updated = TRUE;
} else {
mm_dbg("[%s:%d] Incoming call does not exist yet", __func__, __LINE__);
mm_dbg ("Incoming call does not exist yet");
}
}
return updated;
}
gboolean mm_iface_modem_voice_call_dialing_to_ringing(MMIfaceModemVoice *self)
gboolean
mm_iface_modem_voice_call_dialing_to_ringing (MMIfaceModemVoice *self)
{
gboolean updated = FALSE;
MMBaseCall *call = NULL;
@@ -127,22 +130,22 @@ gboolean mm_iface_modem_voice_call_dialing_to_ringing(MMIfaceModemVoice *self)
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
call = mm_call_list_get_first_outgoing_dialing_call(list);
if( call ) {
mm_base_call_change_state(call, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED);
if (list) {
call = mm_call_list_get_first_outgoing_dialing_call (list);
if (call) {
mm_base_call_change_state (call, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED);
updated = TRUE;
} else {
mm_dbg("[%s:%d] Outgoing dialing call does not exist", __func__, __LINE__);
mm_dbg ("Outgoing dialing call does not exist");
}
}
return updated;
}
gboolean mm_iface_modem_voice_call_ringing_to_active(MMIfaceModemVoice *self)
gboolean
mm_iface_modem_voice_call_ringing_to_active (MMIfaceModemVoice *self)
{
gboolean updated = FALSE;
MMBaseCall *call = NULL;
@@ -152,22 +155,22 @@ gboolean mm_iface_modem_voice_call_ringing_to_active(MMIfaceModemVoice *self)
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
call = mm_call_list_get_first_ringing_call(list);
if( call ) {
mm_base_call_change_state(call, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
if (list) {
call = mm_call_list_get_first_ringing_call (list);
if (call) {
mm_base_call_change_state (call, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
updated = TRUE;
} else {
mm_dbg("[%s:%d] Ringing call does not exist", __func__, __LINE__);
mm_dbg ("Ringing call does not exist");
}
}
return updated;
}
gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self)
gboolean
mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self)
{
gboolean updated = FALSE;
MMBaseCall *call = NULL;
@@ -177,22 +180,23 @@ gboolean mm_iface_modem_voice_network_hangup (MMIfaceModemVoice *self)
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
call = mm_call_list_get_first_non_terminated_call(list);
if( call ) {
mm_base_call_change_state(call, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
if (list) {
call = mm_call_list_get_first_non_terminated_call (list);
if (call) {
mm_base_call_change_state (call, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
updated = TRUE;
} else {
mm_dbg("[%s:%d] No call to hangup", __func__, __LINE__);
mm_dbg ("No call to hangup");
}
}
return updated;
}
gboolean mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self, gchar *tone)
gboolean
mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self,
gchar *tone)
{
gboolean updated = FALSE;
MMCallList *list = NULL;
@@ -201,8 +205,8 @@ gboolean mm_iface_modem_voice_received_dtmf (MMIfaceModemVoice *self, gchar *ton
MM_IFACE_MODEM_VOICE_CALL_LIST, &list,
NULL);
if( list ) {
updated = mm_call_list_send_dtmf_to_active_calls(list, tone);
if (list) {
updated = mm_call_list_send_dtmf_to_active_calls (list, tone);
}
return updated;
@@ -369,8 +373,8 @@ handle_create_auth_ready (MMBaseModem *self,
}
call = mm_base_call_new_from_properties (MM_BASE_MODEM (self),
properties,
&error);
properties,
&error);
if (!call) {
g_object_unref (properties);
g_dbus_method_invocation_take_error (ctx->invocation, error);
@@ -397,8 +401,8 @@ handle_create_auth_ready (MMBaseModem *self,
/* Complete the DBus call */
mm_gdbus_modem_voice_complete_create_call (ctx->skeleton,
ctx->invocation,
mm_base_call_get_path (call));
ctx->invocation,
mm_base_call_get_path (call));
g_object_unref (call);
g_object_unref (properties);
@@ -466,9 +470,9 @@ handle_list (MmGdbusModemVoice *skeleton,
}
paths = mm_call_list_get_paths (list);
mm_gdbus_modem_voice_complete_list_calls(skeleton,
invocation,
(const gchar *const *)paths);
mm_gdbus_modem_voice_complete_list_calls (skeleton,
invocation,
(const gchar *const *)paths);
g_strfreev (paths);
g_object_unref (list);
return TRUE;
@@ -483,7 +487,7 @@ update_message_list (MmGdbusModemVoice *skeleton,
gchar **paths;
paths = mm_call_list_get_paths (list);
mm_gdbus_modem_voice_set_calls(skeleton, (const gchar *const *)paths);
mm_gdbus_modem_voice_set_calls (skeleton, (const gchar *const *)paths);
g_strfreev (paths);
}
@@ -494,7 +498,7 @@ call_added (MMCallList *list,
{
mm_dbg ("Added CALL at '%s'", call_path);
update_message_list (skeleton, list);
mm_gdbus_modem_voice_emit_call_added(skeleton, call_path);
mm_gdbus_modem_voice_emit_call_added (skeleton, call_path);
}
static void
@@ -504,7 +508,7 @@ call_deleted (MMCallList *list,
{
mm_dbg ("Deleted CALL at '%s'", call_path);
update_message_list (skeleton, list);
mm_gdbus_modem_voice_emit_call_deleted(skeleton, call_path);
mm_gdbus_modem_voice_emit_call_deleted (skeleton, call_path);
}
/*****************************************************************************/
@@ -539,8 +543,8 @@ disabling_context_complete_and_free (DisablingContext *ctx)
gboolean
mm_iface_modem_voice_disable_finish (MMIfaceModemVoice *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -634,8 +638,8 @@ interface_disabling_step (DisablingContext *ctx)
void
mm_iface_modem_voice_disable (MMIfaceModemVoice *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
DisablingContext *ctx;
@@ -710,8 +714,8 @@ enabling_context_complete_and_free_if_cancelled (EnablingContext *ctx)
gboolean
mm_iface_modem_voice_enable_finish (MMIfaceModemVoice *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
@@ -823,9 +827,9 @@ interface_enabling_step (EnablingContext *ctx)
void
mm_iface_modem_voice_enable (MMIfaceModemVoice *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
EnablingContext *ctx;
@@ -905,8 +909,8 @@ check_support_ready (MMIfaceModemVoice *self,
GError *error = NULL;
if (!MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->check_support_finish (self,
res,
&error)) {
res,
&error)) {
if (error) {
/* This error shouldn't be treated as critical */
mm_dbg ("Voice support check failed: '%s'", error->message);
@@ -1003,7 +1007,7 @@ interface_initialization_step (InitializationContext *ctx)
/* Finally, export the new interface */
mm_gdbus_object_skeleton_set_modem_voice (MM_GDBUS_OBJECT_SKELETON (ctx->self),
MM_GDBUS_MODEM_VOICE (ctx->skeleton));
MM_GDBUS_MODEM_VOICE (ctx->skeleton));
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
initialization_context_complete_and_free (ctx);
@@ -1015,17 +1019,17 @@ interface_initialization_step (InitializationContext *ctx)
gboolean
mm_iface_modem_voice_initialize_finish (MMIfaceModemVoice *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
void
mm_iface_modem_voice_initialize (MMIfaceModemVoice *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
InitializationContext *ctx;
MmGdbusModemVoice *skeleton = NULL;
@@ -1110,9 +1114,9 @@ mm_iface_modem_voice_get_type (void)
};
iface_modem_voice_type = g_type_register_static (G_TYPE_INTERFACE,
"MMIfaceModemVoice",
&info,
0);
"MMIfaceModemVoice",
&info,
0);
g_type_interface_add_prerequisite (iface_modem_voice_type, MM_TYPE_IFACE_MODEM);
}

View File

@@ -85,10 +85,10 @@ GArray *mm_filter_supported_capabilities (MMModemCapability all,
/*****************************************************************************/
/* VOICE specific helpers and utilities */
/*****************************************************************************/
GRegex *mm_voice_ring_regex_get (void);
GRegex *mm_voice_cring_regex_get(void);
GRegex *mm_voice_clip_regex_get (void);
GRegex *mm_voice_nocarrier_regex_get (void);
GRegex *mm_voice_ring_regex_get (void);
GRegex *mm_voice_cring_regex_get(void);
GRegex *mm_voice_clip_regex_get (void);
GRegex *mm_voice_nocarrier_regex_get (void);
/*****************************************************************************/
/* 3GPP specific helpers and utilities */