aboutsummaryrefslogtreecommitdiff
path: root/src/mm-iface-modem-messaging.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-iface-modem-messaging.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-iface-modem-messaging.c')
-rw-r--r--src/mm-iface-modem-messaging.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c
index 48e05984..e5021058 100644
--- a/src/mm-iface-modem-messaging.c
+++ b/src/mm-iface-modem-messaging.c
@@ -20,6 +20,7 @@
#include "mm-iface-modem.h"
#include "mm-iface-modem-messaging.h"
#include "mm-sms-list.h"
+#include "mm-error-helpers.h"
#include "mm-log-object.h"
#define SUPPORT_CHECKED_TAG "messaging-support-checked-tag"
@@ -168,7 +169,7 @@ handle_delete_ready (MMSmsList *list,
if (!mm_sms_list_delete_sms_finish (list, res, &error)) {
mm_obj_warn (ctx->self, "failed deleting SMS message '%s': %s", ctx->path, error->message);
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
} else {
mm_obj_info (ctx->self, "deleted SMS message '%s'", ctx->path);
mm_gdbus_modem_messaging_complete_delete (ctx->skeleton, ctx->invocation);
@@ -185,7 +186,7 @@ handle_delete_auth_ready (MMBaseModem *self,
GError *error = NULL;
if (!mm_base_modem_authorize_finish (self, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_delete_context_free (ctx);
return;
}
@@ -206,10 +207,8 @@ handle_delete_auth_ready (MMBaseModem *self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
if (!list) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot delete SMS: missing SMS list");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE,
+ "Cannot delete SMS: missing SMS list");
handle_delete_context_free (ctx);
return;
}
@@ -273,7 +272,7 @@ handle_create_auth_ready (MMBaseModem *self,
g_autoptr(MMBaseSms) sms = NULL;
if (!mm_base_modem_authorize_finish (self, res, &error)) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_create_context_free (ctx);
return;
}
@@ -288,14 +287,14 @@ handle_create_auth_ready (MMBaseModem *self,
/* Parse input properties */
properties = mm_sms_properties_new_from_dictionary (ctx->dictionary, &error);
if (!properties) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_create_context_free (ctx);
return;
}
sms = mm_base_sms_new_from_properties (MM_BASE_MODEM (self), properties, &error);
if (!sms) {
- g_dbus_method_invocation_take_error (ctx->invocation, error);
+ mm_dbus_method_invocation_take_error (ctx->invocation, error);
handle_create_context_free (ctx);
return;
}
@@ -304,10 +303,8 @@ handle_create_auth_ready (MMBaseModem *self,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
if (!list) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot create SMS: missing SMS list");
+ mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE,
+ "Cannot create SMS: missing SMS list");
handle_create_context_free (ctx);
return;
}
@@ -362,10 +359,8 @@ handle_list (MmGdbusModemMessaging *skeleton,
MM_IFACE_MODEM_MESSAGING_SMS_LIST, &list,
NULL);
if (!list) {
- g_dbus_method_invocation_return_error (invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot list SMS: missing SMS list");
+ mm_dbus_method_invocation_return_error_literal (invocation, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE,
+ "Cannot list SMS: missing SMS list");
return TRUE;
}