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;
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);
} else {
else {
/* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_UNKNOWN ) {
/* Update state */
@@ -181,9 +181,9 @@ handle_accept_ready (MMBaseCall *self,
{
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);
} else {
else {
/* Transition from Unknown->Dialing */
if (mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self)) == MM_CALL_STATE_RINGING_IN) {
/* Update state */
@@ -284,9 +284,9 @@ handle_hangup_ready (MMBaseCall *self,
{
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);
} else {
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) {
@@ -512,7 +512,6 @@ call_dbus_export (MMBaseCall *self)
G_CALLBACK (handle_send_dtmf),
NULL);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self),
self->priv->connection,
self->priv->path,
@@ -541,27 +540,33 @@ mm_base_call_get_path (MMBaseCall *self)
}
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,
"state", new_state,
"state-reason", reason,
"state", new_state,
"state-reason", reason,
NULL);
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),
old_state,
new_state,
reason);
mm_gdbus_call_emit_state_changed (MM_GDBUS_CALL (self),
old_state,
new_state,
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)) {
/* 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) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_ANSWER) ||
g_error_matches (error, MM_CONNECTION_ERROR, MM_CONNECTION_ERROR_NO_CARRIER)) {
/* 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);
@@ -611,7 +616,7 @@ call_start_ready (MMBaseModem *modem,
}
/* check response for error */
if (response && strlen (response) > 0 ) {
if (response && response[0]) {
error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't start the call: "
"Modem response '%s'", response);
@@ -651,7 +656,7 @@ call_start (MMBaseCall *self,
task);
/* 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);
}
@@ -692,17 +697,16 @@ call_accept_ready (MMBaseModem *modem,
}
/* check response for error */
if( response && strlen(response) > 0 ) {
if (response && response[0]) {
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't accept the call: "
"Unhandled response '%s'", response);
"Couldn't accept the call: "
"Unhandled response '%s'", response);
/* 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 {
/* 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) {
@@ -738,16 +742,16 @@ call_accept (MMBaseCall *self,
static gboolean
call_hangup_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **error)
{
return g_task_propagate_boolean (G_TASK (res), error);
}
static void
call_hangup_ready (MMBaseModem *modem,
GAsyncResult *res,
GTask *task)
GAsyncResult *res,
GTask *task)
{
MMBaseCall *self;
GError *error = NULL;
@@ -769,7 +773,7 @@ call_hangup_ready (MMBaseModem *modem,
}
/* 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) {
g_task_return_error (task, error);
@@ -855,8 +859,8 @@ call_send_dtmf (MMBaseCall *self,
static void
call_delete (MMBaseCall *self,
GAsyncReadyCallback callback,
gpointer user_data)
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
@@ -867,8 +871,8 @@ call_delete (MMBaseCall *self,
static gboolean
call_delete_finish (MMBaseCall *self,
GAsyncResult *res,
GError **error)
GAsyncResult *res,
GError **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);
if (deleted)
/* 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;
}
@@ -919,14 +923,14 @@ MMBaseCall *
mm_base_call_new (MMBaseModem *modem)
{
return MM_BASE_CALL (g_object_new (MM_TYPE_BASE_CALL,
MM_BASE_CALL_MODEM, modem,
NULL));
MM_BASE_CALL_MODEM, modem,
NULL));
}
MMBaseCall *
mm_base_call_new_from_properties (MMBaseModem *modem,
MMCallProperties *properties,
GError **error)
MMCallProperties *properties,
GError **error)
{
MMBaseCall *self;
const gchar *number;
@@ -934,11 +938,11 @@ mm_base_call_new_from_properties (MMBaseModem *modem,
g_assert (MM_IS_IFACE_MODEM_VOICE (modem));
number = mm_call_properties_get_number (properties);
direction = mm_call_properties_get_direction(properties);
number = mm_call_properties_get_number (properties);
direction = mm_call_properties_get_direction (properties);
/* Don't create CALL from properties if either number is missing */
if ( !number ) {
if (!number) {
g_set_error (error,
MM_CORE_ERROR,
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(direction == MM_CALL_DIRECTION_UNKNOWN ) {
if (direction == MM_CALL_DIRECTION_UNKNOWN)
direction = MM_CALL_DIRECTION_OUTGOING;
}
/* Create a call object as defined by the interface */
self = mm_iface_modem_voice_create_call (MM_IFACE_MODEM_VOICE (modem));
g_object_set (self,
"state", mm_call_properties_get_state(properties),
"state-reason", mm_call_properties_get_state_reason(properties),
"direction", direction,
"number", number,
"state", mm_call_properties_get_state(properties),
"state-reason", mm_call_properties_get_state_reason(properties),
"direction", direction,
"number", number,
NULL);
/* Only export once properly created */
@@ -1043,7 +1046,6 @@ mm_base_call_init (MMBaseCall *self)
{
/* Initialize private data */
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BASE_CALL, MMBaseCallPrivate);
/* Defaults */
}
static void