iface-modem-simple: improve logging of user request to disconnect modem
This commit is contained in:
@@ -815,12 +815,12 @@ handle_connect (MmGdbusModemSimple *skeleton,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMIfaceModemSimple *self;
|
MMIfaceModemSimple *self;
|
||||||
MmGdbusModemSimple *skeleton;
|
MmGdbusModemSimple *skeleton;
|
||||||
GDBusMethodInvocation *invocation;
|
GDBusMethodInvocation *invocation;
|
||||||
gchar *bearer_path;
|
gchar *bearer_path;
|
||||||
GList *bearers;
|
GList *bearers;
|
||||||
MMBaseBearer *current;
|
MMBaseBearer *current;
|
||||||
} DisconnectionContext;
|
} DisconnectionContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -830,22 +830,23 @@ 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);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_ready (MMBaseBearer *bearer,
|
disconnect_ready (MMBaseBearer *bearer,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DisconnectionContext *ctx)
|
DisconnectionContext *ctx)
|
||||||
{
|
{
|
||||||
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,13 +872,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
build_connected_bearer_list (MMBaseBearer *bearer,
|
build_connected_bearer_list (MMBaseBearer *bearer,
|
||||||
DisconnectionContext *ctx)
|
DisconnectionContext *ctx)
|
||||||
{
|
{
|
||||||
if (!ctx->bearer_path ||
|
if (!ctx->bearer_path ||
|
||||||
@@ -886,13 +888,13 @@ build_connected_bearer_list (MMBaseBearer *bearer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_auth_ready (MMBaseModem *self,
|
disconnect_auth_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
DisconnectionContext *ctx)
|
DisconnectionContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
g_autoptr(MMBearerList) list = NULL;
|
||||||
MMBearerList *list = NULL;
|
GError *error = NULL;
|
||||||
Private *priv;
|
Private *priv;
|
||||||
|
|
||||||
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, 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,
|
||||||
@@ -943,14 +949,14 @@ disconnect_auth_ready (MMBaseModem *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_disconnect (MmGdbusModemSimple *skeleton,
|
handle_disconnect (MmGdbusModemSimple *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
const gchar *bearer_path,
|
const gchar *bearer_path,
|
||||||
MMIfaceModemSimple *self)
|
MMIfaceModemSimple *self)
|
||||||
{
|
{
|
||||||
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,
|
||||||
|
Reference in New Issue
Block a user