iface-modem-simple: improve logging of user request to disconnect modem

This commit is contained in:
Aleksander Morgado
2022-09-13 14:02:17 +00:00
parent 794386d490
commit ec5eb6c3ac

View File

@@ -830,10 +830,9 @@ disconnection_context_free (DisconnectionContext *ctx)
g_object_unref (ctx->invocation); g_object_unref (ctx->invocation);
g_object_unref (ctx->self); g_object_unref (ctx->self);
g_free (ctx->bearer_path); g_free (ctx->bearer_path);
if (ctx->current) g_clear_object (&ctx->current);
g_object_unref (ctx->current);
g_list_free_full (ctx->bearers, g_object_unref); g_list_free_full (ctx->bearers, g_object_unref);
g_free (ctx); g_slice_free (DisconnectionContext, ctx);
} }
static void disconnect_next_bearer (DisconnectionContext *ctx); static void disconnect_next_bearer (DisconnectionContext *ctx);
@@ -846,6 +845,8 @@ disconnect_ready (MMBaseBearer *bearer,
GError *error = NULL; GError *error = NULL;
if (!mm_base_bearer_disconnect_finish (bearer, res, &error)) { if (!mm_base_bearer_disconnect_finish (bearer, res, &error)) {
mm_obj_warn (ctx->self, "failed to disconnect bearer '%s': %s",
mm_base_bearer_get_path (bearer), error->message);
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
disconnection_context_free (ctx); disconnection_context_free (ctx);
return; return;
@@ -862,8 +863,8 @@ disconnect_next_bearer (DisconnectionContext *ctx)
/* No more bearers? all done! */ /* No more bearers? all done! */
if (!ctx->bearers) { if (!ctx->bearers) {
mm_gdbus_modem_simple_complete_disconnect (ctx->skeleton, mm_obj_info (ctx->self, "all requested bearers disconnected");
ctx->invocation); mm_gdbus_modem_simple_complete_disconnect (ctx->skeleton, ctx->invocation);
disconnection_context_free (ctx); disconnection_context_free (ctx);
return; return;
} }
@@ -871,6 +872,7 @@ disconnect_next_bearer (DisconnectionContext *ctx)
ctx->current = MM_BASE_BEARER (ctx->bearers->data); ctx->current = MM_BASE_BEARER (ctx->bearers->data);
ctx->bearers = g_list_delete_link (ctx->bearers, ctx->bearers); ctx->bearers = g_list_delete_link (ctx->bearers, ctx->bearers);
mm_obj_info (ctx->self, "disconnecting bearer '%s'...", mm_base_bearer_get_path (ctx->current));
mm_base_bearer_disconnect (ctx->current, mm_base_bearer_disconnect (ctx->current,
(GAsyncReadyCallback)disconnect_ready, (GAsyncReadyCallback)disconnect_ready,
ctx); ctx);
@@ -890,8 +892,8 @@ disconnect_auth_ready (MMBaseModem *self,
GAsyncResult *res, GAsyncResult *res,
DisconnectionContext *ctx) DisconnectionContext *ctx)
{ {
g_autoptr(MMBearerList) list = NULL;
GError *error = NULL; GError *error = NULL;
MMBearerList *list = NULL;
Private *priv; Private *priv;
if (!mm_base_modem_authorize_finish (self, res, &error)) { if (!mm_base_modem_authorize_finish (self, res, &error)) {
@@ -921,13 +923,17 @@ disconnect_auth_ready (MMBaseModem *self,
return; return;
} }
if (ctx->bearer_path)
mm_obj_info (self, "processing user request to disconnect modem: bearer '%s'", ctx->bearer_path);
else
mm_obj_info (self, "processing user request to disconnect modem: all bearers");
mm_bearer_list_foreach (list, mm_bearer_list_foreach (list,
(MMBearerListForeachFunc)build_connected_bearer_list, (MMBearerListForeachFunc)build_connected_bearer_list,
ctx); ctx);
g_object_unref (list);
if (ctx->bearer_path && if (ctx->bearer_path && !ctx->bearers) {
!ctx->bearers) { mm_obj_warn (self, "failed to disconnect bearer '%s': not found", ctx->bearer_path);
g_dbus_method_invocation_return_error ( g_dbus_method_invocation_return_error (
ctx->invocation, ctx->invocation,
MM_CORE_ERROR, MM_CORE_ERROR,
@@ -950,7 +956,7 @@ handle_disconnect (MmGdbusModemSimple *skeleton,
{ {
DisconnectionContext *ctx; DisconnectionContext *ctx;
ctx = g_new0 (DisconnectionContext, 1); ctx = g_slice_new0 (DisconnectionContext);
ctx->skeleton = g_object_ref (skeleton); ctx->skeleton = g_object_ref (skeleton);
ctx->self = g_object_ref (self); ctx->self = g_object_ref (self);
ctx->invocation = g_object_ref (invocation); ctx->invocation = g_object_ref (invocation);
@@ -962,11 +968,8 @@ handle_disconnect (MmGdbusModemSimple *skeleton,
* *
* We will detect the '/' string and set the bearer path as NULL in the * We will detect the '/' string and set the bearer path as NULL in the
* context if so, and otherwise use the given input string as path */ * context if so, and otherwise use the given input string as path */
if (g_strcmp0 (bearer_path, "/") != 0) { if (g_strcmp0 (bearer_path, "/") != 0)
mm_obj_dbg (self, "user request to disconnect modem (bearer '%s')", bearer_path);
ctx->bearer_path = g_strdup (bearer_path); ctx->bearer_path = g_strdup (bearer_path);
} else
mm_obj_dbg (self, "user request to disconnect modem (all bearers)");
mm_base_modem_authorize (MM_BASE_MODEM (self), mm_base_modem_authorize (MM_BASE_MODEM (self),
invocation, invocation,