base-call: minor coding style fixes

This commit is contained in:
Aleksander Morgado
2017-07-06 11:11:20 +02:00
parent 4e5ad5585a
commit da45d0c5b2

View File

@@ -79,9 +79,9 @@ handle_start_ready (MMBaseCall *self,
{ {
GError *error = NULL; GError *error = NULL;
if (!MM_BASE_CALL_GET_CLASS (self)->start_finish (self, res, &error)) { if (!MM_BASE_CALL_GET_CLASS (self)->start_finish (self, res, &error))
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
} else { else {
/* Transition from Unknown->Dialing */ /* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_UNKNOWN ) { if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_UNKNOWN ) {
/* Update state */ /* Update state */
@@ -181,9 +181,9 @@ handle_accept_ready (MMBaseCall *self,
{ {
GError *error = NULL; GError *error = NULL;
if (!MM_BASE_CALL_GET_CLASS (self)->accept_finish (self, res, &error)) { if (!MM_BASE_CALL_GET_CLASS (self)->accept_finish (self, res, &error))
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
} else { else {
/* Transition from Unknown->Dialing */ /* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_RINGING_IN) { if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_RINGING_IN) {
/* Update state */ /* Update state */
@@ -284,9 +284,9 @@ handle_hangup_ready (MMBaseCall *self,
{ {
GError *error = NULL; GError *error = NULL;
if (!MM_BASE_CALL_GET_CLASS (self)->hangup_finish (self, res, &error)) { if (!MM_BASE_CALL_GET_CLASS (self)->hangup_finish (self, res, &error))
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
} else { else {
/* Transition from Unknown->Dialing */ /* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) != MM_CALL_STATE_TERMINATED || 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) {
@@ -512,7 +512,6 @@ call_dbus_export (MMBaseCall *self)
G_CALLBACK (handle_send_dtmf), G_CALLBACK (handle_send_dtmf),
NULL); NULL);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self), if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
self->priv->connection, self->priv->connection,
self->priv->path, self->priv->path,
@@ -541,27 +540,33 @@ mm_base_call_get_path (MMBaseCall *self)
} }
void void
mm_base_call_change_state(MMBaseCall *self, MMCallState new_state, MMCallStateReason reason) mm_base_call_change_state (MMBaseCall *self,
MMCallState new_state,
MMCallStateReason reason)
{ {
int old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self)); int old_state;
old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self));
g_object_set (self, g_object_set (self,
"state", new_state, "state", new_state,
"state-reason", reason, "state-reason", reason,
NULL); NULL);
mm_gdbus_call_set_state (MM_GDBUS_CALL (self), new_state); 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_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, old_state,
new_state, new_state,
reason); reason);
} }
void mm_base_call_received_dtmf (MMBaseCall *self, gchar *dtmf) void
mm_base_call_received_dtmf (MMBaseCall *self,
gchar *dtmf)
{ {
mm_gdbus_call_emit_dtmf_received(MM_GDBUS_CALL (self), dtmf); mm_gdbus_call_emit_dtmf_received (MM_GDBUS_CALL (self), dtmf);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -594,14 +599,14 @@ call_start_ready (MMBaseModem *modem,
if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_DIALTONE)) { if (g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_DIALTONE)) {
/* Update state */ /* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR); mm_base_call_change_state (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_ANSWER) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER)) { g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER)) {
/* Update state */ /* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY); mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
} }
mm_dbg ("Couldn't start call : '%s'", error->message); mm_dbg ("Couldn't start call : '%s'", error->message);
@@ -611,7 +616,7 @@ call_start_ready (MMBaseModem *modem,
} }
/* check response for error */ /* check response for error */
if (response && strlen (response) > 0 ) { if (response && response[0]) {
error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't start the call: " "Couldn't start the call: "
"Modem response '%s'", response); "Modem response '%s'", response);
@@ -651,7 +656,7 @@ call_start (MMBaseCall *self,
task); task);
/* Update state */ /* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED); mm_base_call_change_state (self, MM_CALL_STATE_RINGING_OUT, MM_CALL_STATE_REASON_OUTGOING_STARTED);
g_free (cmd); g_free (cmd);
} }
@@ -692,17 +697,16 @@ call_accept_ready (MMBaseModem *modem,
} }
/* check response for error */ /* check response for error */
if( response && strlen(response) > 0 ) { if (response && response[0]) {
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't accept the call: " "Couldn't accept the call: "
"Unhandled response '%s'", response); "Unhandled response '%s'", response);
/* Update state */ /* Update state */
mm_base_call_change_state(self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR); mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
} else { } else {
/* Update state */ /* 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);
} }
if (error) { if (error) {
@@ -738,16 +742,16 @@ call_accept (MMBaseCall *self,
static gboolean static gboolean
call_hangup_finish (MMBaseCall *self, call_hangup_finish (MMBaseCall *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
return g_task_propagate_boolean (G_TASK (res), error); return g_task_propagate_boolean (G_TASK (res), error);
} }
static void static void
call_hangup_ready (MMBaseModem *modem, call_hangup_ready (MMBaseModem *modem,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBaseCall *self; MMBaseCall *self;
GError *error = NULL; GError *error = NULL;
@@ -769,7 +773,7 @@ call_hangup_ready (MMBaseModem *modem,
} }
/* Update state */ /* 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);
if (error) { if (error) {
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -855,8 +859,8 @@ call_send_dtmf (MMBaseCall *self,
static void static void
call_delete (MMBaseCall *self, call_delete (MMBaseCall *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
@@ -867,8 +871,8 @@ call_delete (MMBaseCall *self,
static gboolean static gboolean
call_delete_finish (MMBaseCall *self, call_delete_finish (MMBaseCall *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
return g_task_propagate_boolean (G_TASK (res), error); return g_task_propagate_boolean (G_TASK (res), error);
} }
@@ -886,7 +890,7 @@ mm_base_call_delete_finish (MMBaseCall *self,
deleted = MM_BASE_CALL_GET_CLASS (self)->delete_finish (self, res, error); deleted = MM_BASE_CALL_GET_CLASS (self)->delete_finish (self, res, error);
if (deleted) if (deleted)
/* We do change the state of this call back to UNKNOWN */ /* We do change the state of this call back to UNKNOWN */
mm_base_call_change_state(self, MM_CALL_STATE_UNKNOWN, MM_CALL_STATE_REASON_UNKNOWN); mm_base_call_change_state (self, MM_CALL_STATE_UNKNOWN, MM_CALL_STATE_REASON_UNKNOWN);
return deleted; return deleted;
} }
@@ -919,14 +923,14 @@ MMBaseCall *
mm_base_call_new (MMBaseModem *modem) mm_base_call_new (MMBaseModem *modem)
{ {
return MM_BASE_CALL (g_object_new (MM_TYPE_BASE_CALL, return MM_BASE_CALL (g_object_new (MM_TYPE_BASE_CALL,
MM_BASE_CALL_MODEM, modem, MM_BASE_CALL_MODEM, modem,
NULL)); NULL));
} }
MMBaseCall * MMBaseCall *
mm_base_call_new_from_properties (MMBaseModem *modem, mm_base_call_new_from_properties (MMBaseModem *modem,
MMCallProperties *properties, MMCallProperties *properties,
GError **error) GError **error)
{ {
MMBaseCall *self; MMBaseCall *self;
const gchar *number; const gchar *number;
@@ -934,11 +938,11 @@ mm_base_call_new_from_properties (MMBaseModem *modem,
g_assert (MM_IS_IFACE_MODEM_VOICE (modem)); g_assert (MM_IS_IFACE_MODEM_VOICE (modem));
number = mm_call_properties_get_number (properties); number = mm_call_properties_get_number (properties);
direction = mm_call_properties_get_direction(properties); direction = mm_call_properties_get_direction (properties);
/* Don't create CALL from properties if either number is missing */ /* Don't create CALL from properties if either number is missing */
if ( !number ) { if (!number) {
g_set_error (error, g_set_error (error,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_INVALID_ARGS, MM_CORE_ERROR_INVALID_ARGS,
@@ -947,17 +951,16 @@ mm_base_call_new_from_properties (MMBaseModem *modem,
} }
/* if no direction is specified force to outgoing */ /* if no direction is specified force to outgoing */
if(direction == MM_CALL_DIRECTION_UNKNOWN ) { if (direction == MM_CALL_DIRECTION_UNKNOWN)
direction = MM_CALL_DIRECTION_OUTGOING; direction = MM_CALL_DIRECTION_OUTGOING;
}
/* Create a call object as defined by the interface */ /* Create a call object as defined by the interface */
self = mm_iface_modem_voice_create_call (MM_IFACE_MODEM_VOICE (modem)); self = mm_iface_modem_voice_create_call (MM_IFACE_MODEM_VOICE (modem));
g_object_set (self, g_object_set (self,
"state", mm_call_properties_get_state(properties), "state", mm_call_properties_get_state(properties),
"state-reason", mm_call_properties_get_state_reason(properties), "state-reason", mm_call_properties_get_state_reason(properties),
"direction", direction, "direction", direction,
"number", number, "number", number,
NULL); NULL);
/* Only export once properly created */ /* Only export once properly created */
@@ -1043,7 +1046,6 @@ mm_base_call_init (MMBaseCall *self)
{ {
/* Initialize private data */ /* Initialize private data */
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BASE_CALL, MMBaseCallPrivate); self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BASE_CALL, MMBaseCallPrivate);
/* Defaults */
} }
static void static void