iface-modem: improve logging of user request to run AT command

This commit is contained in:
Aleksander Morgado
2022-09-12 11:49:27 +00:00
parent ac28a6a1c0
commit aed53fe30a

View File

@@ -999,7 +999,7 @@ 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
@@ -1010,13 +1010,14 @@ command_ready (MMIfaceModem *self,
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);
}
@@ -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,
@@ -1075,7 +1070,7 @@ handle_command (MmGdbusModem *skeleton,
{
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);