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);
}
gint
mm_base_bearer_get_profile_id (MMBaseBearer *self)
{
return mm_gdbus_bearer_get_profile_id (MM_GDBUS_BEARER (self));
}
/*****************************************************************************/
static void

View File

@@ -155,10 +155,11 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMBaseBearer, g_object_unref)
void mm_base_bearer_export (MMBaseBearer *self);
const gchar *mm_base_bearer_get_path (MMBaseBearer *self);
MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self);
MMBearerProperties *mm_base_bearer_peek_config (MMBaseBearer *self);
MMBearerProperties *mm_base_bearer_get_config (MMBaseBearer *self);
const gchar *mm_base_bearer_get_path (MMBaseBearer *self);
MMBearerStatus mm_base_bearer_get_status (MMBaseBearer *self);
MMBearerProperties *mm_base_bearer_peek_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,
GAsyncReadyCallback callback,

View File

@@ -155,6 +155,22 @@ mm_bearer_list_find_by_path (MMBearerList *self,
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 {

View File

@@ -70,10 +70,12 @@ void mm_bearer_list_foreach (MMBearerList *self,
MMBearerListForeachFunc func,
gpointer user_data);
MMBaseBearer *mm_bearer_list_find_by_properties (MMBearerList *self,
MMBaseBearer *mm_bearer_list_find_by_properties (MMBearerList *self,
MMBearerProperties *properties);
MMBaseBearer *mm_bearer_list_find_by_path (MMBearerList *self,
const gchar *path);
MMBaseBearer *mm_bearer_list_find_by_path (MMBearerList *self,
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,
GAsyncReadyCallback callback,