diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2022-09-12 11:49:27 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2022-11-04 13:12:57 +0000 |
commit | aed53fe30a51c385629549ee209aabd137d52238 (patch) | |
tree | 21e94381853be40718354c108a3d3072cf2f4b1f /src/mm-iface-modem.c | |
parent | ac28a6a1c009e4226b83133842e5060e63e36d64 (diff) |
iface-modem: improve logging of user request to run AT command
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r-- | src/mm-iface-modem.c | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 47724f33..49f4ad67 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -985,11 +985,11 @@ handle_create_bearer (MmGdbusModem *skeleton, /*****************************************************************************/ typedef struct { - MmGdbusModem *skeleton; + MmGdbusModem *skeleton; GDBusMethodInvocation *invocation; - MMIfaceModem *self; - gchar *cmd; - guint timeout; + MMIfaceModem *self; + gchar *cmd; + guint timeout; } HandleCommandContext; static void @@ -999,31 +999,32 @@ handle_command_context_free (HandleCommandContext *ctx) g_object_unref (ctx->invocation); g_object_unref (ctx->self); g_free (ctx->cmd); - g_free (ctx); + g_slice_free (HandleCommandContext, ctx); } static void -command_ready (MMIfaceModem *self, - GAsyncResult *res, +command_ready (MMIfaceModem *self, + GAsyncResult *res, HandleCommandContext *ctx) { - GError *error = NULL; + GError *error = NULL; const gchar *result; - result = MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish (self, - res, - &error); - if (error) + result = MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish (self, res, &error); + if (error) { + mm_obj_dbg (self, "failed running AT command '%s': %s", ctx->cmd, error->message); g_dbus_method_invocation_take_error (ctx->invocation, error); - else + } else { + mm_obj_dbg (self, "AT command '%s' run: %s", ctx->cmd, result); mm_gdbus_modem_complete_command (ctx->skeleton, ctx->invocation, result); + } handle_command_context_free (ctx); } static void -handle_command_auth_ready (MMBaseModem *self, - GAsyncResult *res, +handle_command_auth_ready (MMBaseModem *self, + GAsyncResult *res, HandleCommandContext *ctx) { GError *error = NULL; @@ -1037,28 +1038,22 @@ handle_command_auth_ready (MMBaseModem *self, #if ! defined WITH_AT_COMMAND_VIA_DBUS /* If we are not in Debug mode, report an error */ if (!mm_context_get_debug ()) { - g_dbus_method_invocation_return_error (ctx->invocation, - MM_CORE_ERROR, - MM_CORE_ERROR_UNAUTHORIZED, - "Cannot send AT command to modem: " - "operation only allowed in debug mode"); + g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNAUTHORIZED, + "Operation only allowed in debug mode"); handle_command_context_free (ctx); return; } #endif /* If command is not implemented, report an error */ - if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command || - !MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) { - g_dbus_method_invocation_return_error (ctx->invocation, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED, - "Cannot send AT command to modem: " - "operation not supported"); + if (!MM_IFACE_MODEM_GET_INTERFACE (self)->command || !MM_IFACE_MODEM_GET_INTERFACE (self)->command_finish) { + g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, + "Operation not supported"); handle_command_context_free (ctx); return; } + mm_obj_dbg (self, "processing user request to run AT command '%s'...", ctx->cmd); MM_IFACE_MODEM_GET_INTERFACE (self)->command (ctx->self, ctx->cmd, ctx->timeout, @@ -1067,15 +1062,15 @@ handle_command_auth_ready (MMBaseModem *self, } static gboolean -handle_command (MmGdbusModem *skeleton, +handle_command (MmGdbusModem *skeleton, GDBusMethodInvocation *invocation, - const gchar *cmd, - guint timeout, - MMIfaceModem *self) + const gchar *cmd, + guint timeout, + MMIfaceModem *self) { HandleCommandContext *ctx; - ctx = g_new (HandleCommandContext, 1); + ctx = g_slice_new0 (HandleCommandContext); ctx->skeleton = g_object_ref (skeleton); ctx->invocation = g_object_ref (invocation); ctx->self = g_object_ref (self); |