base-call: refactoring of error handling when call starts
This commit is contained in:

committed by
Aleksander Morgado

parent
bf416045df
commit
40fae5fcba
@@ -60,13 +60,25 @@ call_start_ready (MMBaseModem *modem,
|
|||||||
response = mm_base_modem_at_command_finish (modem, res, &error);
|
response = mm_base_modem_at_command_finish (modem, res, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
|
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
/* something is wrong, serial timeout could never occurs */
|
||||||
call_start_context_complete_and_free (ctx);
|
}
|
||||||
return;
|
|
||||||
|
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) ||
|
||||||
|
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(ctx->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);
|
||||||
g_error_free (error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
call_start_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -495,13 +495,25 @@ call_start_ready (MMBaseModem *modem,
|
|||||||
response = mm_base_modem_at_command_finish (modem, res, &error);
|
response = mm_base_modem_at_command_finish (modem, res, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
|
if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
/* something is wrong, serial timeout could never occurs */
|
||||||
call_start_context_complete_and_free (ctx);
|
}
|
||||||
return;
|
|
||||||
|
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) ||
|
||||||
|
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(ctx->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);
|
||||||
g_error_free (error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
call_start_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,15 +522,13 @@ call_start_ready (MMBaseModem *modem,
|
|||||||
g_set_error (&error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
g_set_error (&error, 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);
|
||||||
|
|
||||||
/* Update state */
|
/* Update state */
|
||||||
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
|
mm_base_call_change_state(ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_REFUSED_OR_BUSY);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Update state */
|
/* Update state */
|
||||||
mm_base_call_change_state(ctx->self, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
|
mm_base_call_change_state(ctx->self, MM_CALL_STATE_ACTIVE, MM_CALL_STATE_REASON_ACCEPTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
call_start_context_complete_and_free (ctx);
|
call_start_context_complete_and_free (ctx);
|
||||||
|
Reference in New Issue
Block a user