iface-modem: improve logging of user request to delete bearer
This commit is contained in:
@@ -1088,51 +1088,53 @@ handle_command (MmGdbusModem *skeleton,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MmGdbusModem *skeleton;
|
MmGdbusModem *skeleton;
|
||||||
GDBusMethodInvocation *invocation;
|
GDBusMethodInvocation *invocation;
|
||||||
MMIfaceModem *self;
|
MMIfaceModem *self;
|
||||||
MMBearerList *list;
|
MMBearerList *list;
|
||||||
gchar *bearer_path;
|
gchar *bearer_path;
|
||||||
MMBaseBearer *bearer;
|
MMBaseBearer *bearer;
|
||||||
} HandleDeleteBearerContext;
|
} HandleDeleteBearerContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
|
handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->bearer)
|
|
||||||
g_object_unref (ctx->bearer);
|
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_object_unref (ctx->invocation);
|
g_object_unref (ctx->invocation);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
if (ctx->list)
|
g_clear_object (&ctx->bearer);
|
||||||
g_object_unref (ctx->list);
|
g_clear_object (&ctx->list);
|
||||||
g_free (ctx->bearer_path);
|
g_free (ctx->bearer_path);
|
||||||
g_free (ctx);
|
g_slice_free (HandleDeleteBearerContext, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
delete_bearer_disconnect_ready (MMBaseBearer *bearer,
|
delete_bearer_disconnect_ready (MMBaseBearer *bearer,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
HandleDeleteBearerContext *ctx)
|
HandleDeleteBearerContext *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 disconnecting bearer '%s' before deleting: %s", ctx->bearer_path, error->message);
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
handle_delete_bearer_context_free (ctx);
|
handle_delete_bearer_context_free (ctx);
|
||||||
return;
|
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);
|
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);
|
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
||||||
|
}
|
||||||
handle_delete_bearer_context_free (ctx);
|
handle_delete_bearer_context_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_delete_bearer_auth_ready (MMBaseModem *self,
|
handle_delete_bearer_auth_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
HandleDeleteBearerContext *ctx)
|
HandleDeleteBearerContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
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)) {
|
if (!g_str_has_prefix (ctx->bearer_path, MM_DBUS_BEARER_PREFIX)) {
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||||
MM_CORE_ERROR,
|
"Invalid path '%s'", ctx->bearer_path);
|
||||||
MM_CORE_ERROR_INVALID_ARGS,
|
|
||||||
"Cannot delete bearer: invalid path '%s'",
|
|
||||||
ctx->bearer_path);
|
|
||||||
handle_delete_bearer_context_free (ctx);
|
handle_delete_bearer_context_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->bearer = mm_bearer_list_find_by_path (ctx->list, ctx->bearer_path);
|
ctx->bearer = mm_bearer_list_find_by_path (ctx->list, ctx->bearer_path);
|
||||||
if (!ctx->bearer) {
|
if (!ctx->bearer) {
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS,
|
||||||
MM_CORE_ERROR,
|
"No bearer found with path '%s'", ctx->bearer_path);
|
||||||
MM_CORE_ERROR_INVALID_ARGS,
|
|
||||||
"Cannot delete bearer: no bearer found with path '%s'",
|
|
||||||
ctx->bearer_path);
|
|
||||||
handle_delete_bearer_context_free (ctx);
|
handle_delete_bearer_context_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mm_obj_info (self, "processing user request to delete bearer '%s'...", ctx->bearer_path);
|
||||||
mm_base_bearer_disconnect (ctx->bearer,
|
mm_base_bearer_disconnect (ctx->bearer,
|
||||||
(GAsyncReadyCallback)delete_bearer_disconnect_ready,
|
(GAsyncReadyCallback)delete_bearer_disconnect_ready,
|
||||||
ctx);
|
ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_delete_bearer (MmGdbusModem *skeleton,
|
handle_delete_bearer (MmGdbusModem *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
const gchar *bearer,
|
const gchar *bearer,
|
||||||
MMIfaceModem *self)
|
MMIfaceModem *self)
|
||||||
{
|
{
|
||||||
HandleDeleteBearerContext *ctx;
|
HandleDeleteBearerContext *ctx;
|
||||||
|
|
||||||
ctx = g_new (HandleDeleteBearerContext, 1);
|
ctx = g_slice_new0 (HandleDeleteBearerContext);
|
||||||
ctx->skeleton = g_object_ref (skeleton);
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
ctx->invocation = g_object_ref (invocation);
|
ctx->invocation = g_object_ref (invocation);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
|
Reference in New Issue
Block a user