iface-modem-3gpp-profile-manager: support 'apn-type' as index field

The modem may report the 'apn-type' field is the one to be used as
index; if that's the case, allow setting and deleting profiles based
on the given 'apn-type' field.

This change also makes the internal profile management operations use
one index field or another, based on what the protocol implements.
This commit is contained in:
Aleksander Morgado
2021-12-26 10:12:11 +01:00
parent 0d0ad722d9
commit 853aa29be8
13 changed files with 355 additions and 210 deletions
+13 -3
View File
@@ -1954,15 +1954,21 @@ store_profile_context_free (StoreProfileContext *ctx)
static gint
modem_3gpp_profile_manager_store_profile_finish (MMIfaceModem3gppProfileManager *self,
GAsyncResult *res,
gint *out_profile_id,
MMBearerApnType *out_apn_type,
GError **error)
{
StoreProfileContext *ctx;
if (!g_task_propagate_boolean (G_TASK (res), error))
return MM_3GPP_PROFILE_ID_UNKNOWN;
return FALSE;
ctx = g_task_get_task_data (G_TASK (res));
return ctx->profile_id;
if (out_profile_id)
*out_profile_id = ctx->profile_id;
if (out_apn_type)
*out_apn_type = MM_BEARER_APN_TYPE_NONE;
return TRUE;
}
static void profile_manager_store_profile_auth_settings (GTask *task);
@@ -2076,7 +2082,7 @@ profile_manager_parent_store_profile_ready (MMIfaceModem3gppProfileManager *self
{
GError *error = NULL;
if (iface_modem_3gpp_profile_manager_parent->store_profile_finish (self, res, &error) == MM_3GPP_PROFILE_ID_UNKNOWN) {
if (!iface_modem_3gpp_profile_manager_parent->store_profile_finish (self, res, NULL, NULL, &error)) {
g_task_return_error (task, error);
g_object_unref (task);
return;
@@ -2088,12 +2094,15 @@ profile_manager_parent_store_profile_ready (MMIfaceModem3gppProfileManager *self
static void
modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *self,
MM3gppProfile *profile,
const gchar *index_field,
GAsyncReadyCallback callback,
gpointer user_data)
{
StoreProfileContext *ctx;
GTask *task;
g_assert (g_strcmp0 (index_field, "profile-id") == 0);
task = g_task_new (self, NULL, callback, user_data);
ctx = g_slice_new0 (StoreProfileContext);
ctx->profile = g_object_ref (profile);
@@ -2104,6 +2113,7 @@ modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *self,
iface_modem_3gpp_profile_manager_parent->store_profile (
self,
profile,
index_field,
(GAsyncReadyCallback)profile_manager_parent_store_profile_ready,
task);
}