iface-modem: explicitly disconnect bearer before removing it
https://bugs.freedesktop.org/show_bug.cgi?id=90408
This commit is contained in:
@@ -105,15 +105,6 @@ mm_bearer_list_delete_bearer (MMBearerList *self,
|
|||||||
{
|
{
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
if (!g_str_has_prefix (path, MM_DBUS_BEARER_PREFIX)) {
|
|
||||||
g_set_error (error,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_INVALID_ARGS,
|
|
||||||
"Cannot delete bearer: invalid path '%s'",
|
|
||||||
path);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (l = self->priv->bearers; l; l = g_list_next (l)) {
|
for (l = self->priv->bearers; l; l = g_list_next (l)) {
|
||||||
if (g_str_equal (path, mm_base_bearer_get_path (MM_BASE_BEARER (l->data)))) {
|
if (g_str_equal (path, mm_base_bearer_get_path (MM_BASE_BEARER (l->data)))) {
|
||||||
g_object_unref (l->data);
|
g_object_unref (l->data);
|
||||||
@@ -169,6 +160,20 @@ mm_bearer_list_find_by_properties (MMBearerList *self,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMBaseBearer *
|
||||||
|
mm_bearer_list_find_by_path (MMBearerList *self,
|
||||||
|
const gchar *path)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = self->priv->bearers; l; l = g_list_next (l)) {
|
||||||
|
if (g_str_equal (path, mm_base_bearer_get_path (MM_BASE_BEARER (l->data))))
|
||||||
|
return g_object_ref (l->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@@ -74,6 +74,8 @@ void mm_bearer_list_foreach (MMBearerList *self,
|
|||||||
|
|
||||||
MMBaseBearer *mm_bearer_list_find_by_properties (MMBearerList *self,
|
MMBaseBearer *mm_bearer_list_find_by_properties (MMBearerList *self,
|
||||||
MMBearerProperties *properties);
|
MMBearerProperties *properties);
|
||||||
|
MMBaseBearer *mm_bearer_list_find_by_path (MMBearerList *self,
|
||||||
|
const gchar *path);
|
||||||
|
|
||||||
void mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
|
void mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
|
@@ -760,11 +760,14 @@ typedef struct {
|
|||||||
MMIfaceModem *self;
|
MMIfaceModem *self;
|
||||||
MMBearerList *list;
|
MMBearerList *list;
|
||||||
gchar *bearer_path;
|
gchar *bearer_path;
|
||||||
|
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);
|
||||||
@@ -774,6 +777,26 @@ handle_delete_bearer_context_free (HandleDeleteBearerContext *ctx)
|
|||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_bearer_disconnect_ready (MMBaseBearer *bearer,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleDeleteBearerContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_base_bearer_disconnect_finish (bearer, res, &error)) {
|
||||||
|
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))
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
else
|
||||||
|
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
||||||
|
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,
|
||||||
@@ -787,14 +810,30 @@ handle_delete_bearer_auth_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->list)
|
if (!g_str_has_prefix (ctx->bearer_path, MM_DBUS_BEARER_PREFIX)) {
|
||||||
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
else if (!mm_bearer_list_delete_bearer (ctx->list, ctx->bearer_path, &error))
|
MM_CORE_ERROR,
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
MM_CORE_ERROR_INVALID_ARGS,
|
||||||
else
|
"Cannot delete bearer: invalid path '%s'",
|
||||||
mm_gdbus_modem_complete_delete_bearer (ctx->skeleton, ctx->invocation);
|
ctx->bearer_path);
|
||||||
|
handle_delete_bearer_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
handle_delete_bearer_context_free (ctx);
|
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);
|
||||||
|
handle_delete_bearer_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm_base_bearer_disconnect (ctx->bearer,
|
||||||
|
(GAsyncReadyCallback)delete_bearer_disconnect_ready,
|
||||||
|
ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Reference in New Issue
Block a user