aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2022-09-12 12:02:49 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2022-11-04 13:12:57 +0000
commit4fa773d2344b2f85f7df1461f96acf4902c0cdcc (patch)
tree9c86ab6478f76d7d438f9096ad42936b63ad9470
parentaed53fe30a51c385629549ee209aabd137d52238 (diff)
iface-modem: improve logging of user request to delete bearer
-rw-r--r--src/mm-iface-modem.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 49f4ad67..142dc14e 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -1088,51 +1088,53 @@ handle_command (MmGdbusModem *skeleton,
/*****************************************************************************/
typedef struct {
- MmGdbusModem *skeleton;
+ MmGdbusModem *skeleton;
GDBusMethodInvocation *invocation;
- MMIfaceModem *self;
- MMBearerList *list;
- gchar *bearer_path;
- MMBaseBearer *bearer;
+ MMIfaceModem *self;
+ MMBearerList *list;
+ gchar *bearer_path;
+ MMBaseBearer *bearer;
} HandleDeleteBearerContext;
static void
handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
{
- if (ctx->bearer)
- g_object_unref (ctx->bearer);
g_object_unref (ctx->skeleton);
g_object_unref (ctx->invocation);
g_object_unref (ctx->self);
- if (ctx->list)
- g_object_unref (ctx->list);
+ g_clear_object (&ctx->bearer);
+ g_clear_object (&ctx->list);
g_free (ctx->bearer_path);
- g_free (ctx);
+ g_slice_free (HandleDeleteBearerContext, ctx);
}
static void
-delete_bearer_disconnect_ready (MMBaseBearer *bearer,
- GAsyncResult *res,
+delete_bearer_disconnect_ready (MMBaseBearer *bearer,
+ GAsyncResult *res,
HandleDeleteBearerContext *ctx)
{
GError *error = NULL;
if (!mm_base_bearer_disconnect_finish (bearer, res, &error)) {
+ mm_obj_warn (ctx->self, "failed disconnecting bearer '%s' before deleting: %s", ctx->bearer_path, error->message);
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_delete_bearer_context_free (ctx);
return;
}
- if (!mm_bearer_list_delete_bearer (ctx->list, ctx->bearer_path, &error))
+ if (!mm_bearer_list_delete_bearer (ctx->list, ctx->bearer_path, &error)) {
+ mm_obj_warn (ctx->self, "failed deleting bearer '%s': %s", ctx->bearer_path, error->message);
g_dbus_method_invocation_take_error (ctx->invocation, error);
- else
+ } else {
+ mm_obj_info (ctx->self, "deleted bearer '%s'", ctx->bearer_path);
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
+ }
handle_delete_bearer_context_free (ctx);
}
static void
-handle_delete_bearer_auth_ready (MMBaseModem *self,
- GAsyncResult *res,
+handle_delete_bearer_auth_ready (MMBaseModem *self,
+ GAsyncResult *res,
HandleDeleteBearerContext *ctx)
{
GError *error = NULL;
@@ -1149,40 +1151,35 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
}
if (!g_str_has_prefix (ctx->bearer_path, MM_DBUS_BEARER_PREFIX)) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_INVALID_ARGS,
- "Cannot delete bearer: invalid path '%s'",
- ctx->bearer_path);
+ g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
+ "Invalid path '%s'", ctx->bearer_path);
handle_delete_bearer_context_free (ctx);
return;
}
ctx->bearer = mm_bearer_list_find_by_path (ctx->list, ctx->bearer_path);
if (!ctx->bearer) {
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_INVALID_ARGS,
- "Cannot delete bearer: no bearer found with path '%s'",
- ctx->bearer_path);
+ g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
+ "No bearer found with path '%s'", ctx->bearer_path);
handle_delete_bearer_context_free (ctx);
return;
}
+ mm_obj_info (self, "processing user request to delete bearer '%s'...", ctx->bearer_path);
mm_base_bearer_disconnect (ctx->bearer,
(GAsyncReadyCallback)delete_bearer_disconnect_ready,
ctx);
}
static gboolean
-handle_delete_bearer (MmGdbusModem *skeleton,
+handle_delete_bearer (MmGdbusModem *skeleton,
GDBusMethodInvocation *invocation,
- const gchar *bearer,
- MMIfaceModem *self)
+ const gchar *bearer,
+ MMIfaceModem *self)
{
HandleDeleteBearerContext *ctx;
- ctx = g_new (HandleDeleteBearerContext, 1);
+ ctx = g_slice_new0 (HandleDeleteBearerContext);
ctx->skeleton = g_object_ref (skeleton);
ctx->invocation = g_object_ref (invocation);
ctx->self = g_object_ref (self);