aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-call.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-10-26 10:54:17 +0000
committerAleksander Morgado <aleksander@aleksander.es>2023-10-27 11:34:26 +0200
commit1f9a04268f6de7e9aa11073f0bf363aadc2ca29b (patch)
tree64519e385d67a5a9353681ddd39b15e979d5ead0 /src/mm-base-call.c
parent9569b99f4197ca4de57a97840a573304389fbc11 (diff)
core: ensure all errors returned in DBus operations are normalized
We want to ensure that all errors reported via DBus operations are normalized to MM-specific errors. We don't want to return QMI or MBIM specific errors, as those are protocol specific and we don't want DBus clients to need to rely on knowing which is the protocol in use by the device.
Diffstat (limited to 'src/mm-base-call.c')
-rw-r--r--src/mm-base-call.c90
1 files changed, 35 insertions, 55 deletions
diff --git a/src/mm-base-call.c b/src/mm-base-call.c
index 69ce8985..8037c102 100644
--- a/src/mm-base-call.c
+++ b/src/mm-base-call.c
@@ -182,7 +182,7 @@ handle_start_ready (MMBaseCall *self,
else
mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_UNKNOWN);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_start_context_free (ctx);
return;
}
@@ -212,7 +212,7 @@ handle_start_auth_ready (MMBaseModem *modem,
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
mm_base_call_change_state (ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_UNKNOWN);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_start_context_free (ctx);
return;
}
@@ -221,10 +221,8 @@ handle_start_auth_ready (MMBaseModem *modem,
state = mm_gdbus_call_get_state (MM_GDBUS_CALL (ctx->self));
if (state != MM_CALL_STATE_UNKNOWN) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "This call was not in unknown state, cannot start it");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "This call was not in unknown state, cannot start it");
handle_start_context_free (ctx);
return;
}
@@ -234,7 +232,7 @@ handle_start_auth_ready (MMBaseModem *modem,
/* Disallow non-emergency calls when in emergency-only state */
if (!mm_iface_modem_voice_authorize_outgoing_call (MM_IFACE_MODEM_VOICE (modem), ctx->self, &error)) {
mm_base_call_change_state (ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_UNKNOWN);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_start_context_free (ctx);
return;
}
@@ -243,10 +241,8 @@ handle_start_auth_ready (MMBaseModem *modem,
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->start ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->start_finish) {
mm_base_call_change_state (ctx->self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_UNKNOWN);
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Starting call is not supported by this modem");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Starting call is not supported by this modem");
handle_start_context_free (ctx);
return;
}
@@ -311,7 +307,7 @@ handle_accept_ready (MMBaseCall *self,
if (!MM_BASE_CALL_GET_CLASS (self)->accept_finish (self, res, &error)) {
mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_accept_context_free (ctx);
return;
}
@@ -336,7 +332,7 @@ handle_accept_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_accept_context_free (ctx);
return;
}
@@ -345,10 +341,8 @@ handle_accept_auth_ready (MMBaseModem *modem,
/* We can only accept incoming call in ringing state */
if (state != MM_CALL_STATE_RINGING_IN) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "This call was not ringing, cannot accept");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "This call was not ringing, cannot accept");
handle_accept_context_free (ctx);
return;
}
@@ -358,10 +352,8 @@ handle_accept_auth_ready (MMBaseModem *modem,
/* Check if we do support doing it */
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->accept ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->accept_finish) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Accepting call is not supported by this modem");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Accepting call is not supported by this modem");
handle_accept_context_free (ctx);
return;
}
@@ -421,7 +413,7 @@ handle_deflect_ready (MMBaseCall *self,
if (!MM_BASE_CALL_GET_CLASS (self)->deflect_finish (self, res, &error)) {
mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_ERROR);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_deflect_context_free (ctx);
return;
}
@@ -441,7 +433,7 @@ handle_deflect_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_deflect_context_free (ctx);
return;
}
@@ -450,10 +442,8 @@ handle_deflect_auth_ready (MMBaseModem *modem,
/* We can only deflect incoming call in ringing or waiting state */
if (state != MM_CALL_STATE_RINGING_IN && state != MM_CALL_STATE_WAITING) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "This call was not ringing/waiting, cannot deflect");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "This call was not ringing/waiting, cannot deflect");
handle_deflect_context_free (ctx);
return;
}
@@ -463,10 +453,8 @@ handle_deflect_auth_ready (MMBaseModem *modem,
/* Check if we do support doing it */
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->deflect ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->deflect_finish) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Deflecting call is not supported by this modem");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Deflecting call is not supported by this modem");
handle_deflect_context_free (ctx);
return;
}
@@ -526,7 +514,7 @@ modem_voice_join_multiparty_ready (MMIfaceModemVoice *modem,
GError *error = NULL;
if (!mm_iface_modem_voice_join_multiparty_finish (modem, res, &error))
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
else
mm_gdbus_call_complete_join_multiparty (MM_GDBUS_CALL (ctx->self), ctx->invocation);
handle_join_multiparty_context_free (ctx);
@@ -540,7 +528,7 @@ handle_join_multiparty_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_join_multiparty_context_free (ctx);
return;
}
@@ -601,7 +589,7 @@ modem_voice_leave_multiparty_ready (MMIfaceModemVoice *modem,
GError *error = NULL;
if (!mm_iface_modem_voice_leave_multiparty_finish (modem, res, &error))
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
else
mm_gdbus_call_complete_leave_multiparty (MM_GDBUS_CALL (ctx->self), ctx->invocation);
@@ -616,7 +604,7 @@ handle_leave_multiparty_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_leave_multiparty_context_free (ctx);
return;
}
@@ -680,7 +668,7 @@ handle_hangup_ready (MMBaseCall *self,
mm_base_call_change_state (self, MM_CALL_STATE_TERMINATED, MM_CALL_STATE_REASON_TERMINATED);
if (!MM_BASE_CALL_GET_CLASS (self)->hangup_finish (self, res, &error))
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
else {
/* note: timeouts are already removed when setting state as TERMINATED */
mm_gdbus_call_complete_hangup (MM_GDBUS_CALL (ctx->self), ctx->invocation);
@@ -698,7 +686,7 @@ handle_hangup_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_hangup_context_free (ctx);
return;
}
@@ -707,10 +695,8 @@ handle_hangup_auth_ready (MMBaseModem *modem,
/* We can only hangup call in a valid state */
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");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "This call was not active, cannot hangup");
handle_hangup_context_free (ctx);
return;
}
@@ -720,10 +706,8 @@ handle_hangup_auth_ready (MMBaseModem *modem,
/* Check if we do support doing it */
if (!MM_BASE_CALL_GET_CLASS (ctx->self)->hangup ||
!MM_BASE_CALL_GET_CLASS (ctx->self)->hangup_finish) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Hanging up call is not supported by this modem");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Hanging up call is not supported by this modem");
handle_hangup_context_free (ctx);
return;
}
@@ -782,7 +766,7 @@ handle_send_dtmf_ready (MMBaseCall *self,
GError *error = NULL;
if (!MM_BASE_CALL_GET_CLASS (self)->send_dtmf_finish (self, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
} else {
mm_gdbus_call_complete_send_dtmf (MM_GDBUS_CALL (ctx->self), ctx->invocation);
}
@@ -799,7 +783,7 @@ handle_send_dtmf_auth_ready (MMBaseModem *modem,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (modem, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_send_dtmf_context_free (ctx);
return;
}
@@ -809,20 +793,16 @@ handle_send_dtmf_auth_ready (MMBaseModem *modem,
/* Check if we do support doing it */
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 dtmf is not supported by this modem");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Sending dtmf is not supported by this modem");
handle_send_dtmf_context_free (ctx);
return;
}
/* 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 dtmf");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "This call was not active, cannot send dtmf");
handle_send_dtmf_context_free (ctx);
return;
}