bearer-list: allow lookup by connected profile id

Some of the operations performed by the profile management interface
will require checking whether the operation is attempted on a profile
for which there is a known connected bearer object.

We introduce a new method to lookup a bearer in the bearer list by its
connected profile id.
This commit is contained in:
Aleksander Morgado
2021-04-03 22:23:34 +02:00
parent e4ef8319ec
commit dd7938b3e4
4 changed files with 32 additions and 7 deletions

View File

@@ -1290,6 +1290,12 @@ mm_base_bearer_get_config (MMBaseBearer *self)
NULL); NULL);
} }
gint
mm_base_bearer_get_profile_id (MMBaseBearer *self)
{
return mm_gdbus_bearer_get_profile_id (MM_GDBUS_BEARER (self));
}
/*****************************************************************************/ /*****************************************************************************/
static void static void

View File

@@ -159,6 +159,7 @@ const gchar *mm_base_bearer_get_path (MMBaseBearer *self);
MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self); MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self);
MMBearerProperties *mm_base_bearer_peek_config (MMBaseBearer *self); MMBearerProperties *mm_base_bearer_peek_config (MMBaseBearer *self);
MMBearerProperties *mm_base_bearer_get_config (MMBaseBearer *self); MMBearerProperties *mm_base_bearer_get_config (MMBaseBearer *self);
gint mm_base_bearer_get_profile_id (MMBaseBearer *self);
void mm_base_bearer_connect (MMBaseBearer *self, void mm_base_bearer_connect (MMBaseBearer *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,

View File

@@ -155,6 +155,22 @@ mm_bearer_list_find_by_path (MMBearerList *self,
return NULL; return NULL;
} }
MMBaseBearer *
mm_bearer_list_find_by_profile_id (MMBearerList *self,
gint profile_id)
{
GList *l;
g_assert (profile_id != MM_3GPP_PROFILE_ID_UNKNOWN);
for (l = self->priv->bearers; l; l = g_list_next (l)) {
if (mm_base_bearer_get_profile_id (MM_BASE_BEARER (l->data)) == profile_id)
return g_object_ref (l->data);
}
return NULL;
}
/*****************************************************************************/ /*****************************************************************************/
typedef struct { typedef struct {

View File

@@ -74,6 +74,8 @@ MMBaseBearer *mm_bearer_list_find_by_properties (MMBearerList *self,
MMBearerProperties *properties); MMBearerProperties *properties);
MMBaseBearer *mm_bearer_list_find_by_path (MMBearerList *self, MMBaseBearer *mm_bearer_list_find_by_path (MMBearerList *self,
const gchar *path); const gchar *path);
MMBaseBearer *mm_bearer_list_find_by_profile_id (MMBearerList *self,
gint profile_id);
void mm_bearer_list_disconnect_all_bearers (MMBearerList *self, void mm_bearer_list_disconnect_all_bearers (MMBearerList *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,