api,modem: new Modem3gpp.ProfileManager interface
This new interface allows modems to expose the list of available connection profiles stored in the device and edit or delete them; as long as the underlying device/protocol allows it.
This commit is contained in:
@@ -19,6 +19,7 @@ mmcli_SOURCES = \
|
||||
mmcli-manager.c \
|
||||
mmcli-modem.c \
|
||||
mmcli-modem-3gpp.c \
|
||||
mmcli-modem-3gpp-profile-manager.c \
|
||||
mmcli-modem-3gpp-ussd.c \
|
||||
mmcli-modem-cdma.c \
|
||||
mmcli-modem-simple.c \
|
||||
|
373
cli/mmcli-modem-3gpp-profile-manager.c
Normal file
373
cli/mmcli-modem-3gpp-profile-manager.c
Normal file
@@ -0,0 +1,373 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* mmcli -- Control modem status & access information from the command line
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
|
||||
* Copyright (C) 2021 Google, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MMCLI
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mmcli.h"
|
||||
#include "mmcli-common.h"
|
||||
#include "mmcli-output.h"
|
||||
|
||||
/* Context */
|
||||
typedef struct {
|
||||
MMManager *manager;
|
||||
GCancellable *cancellable;
|
||||
MMObject *object;
|
||||
MMModem3gppProfileManager *modem_3gpp_profile_manager;
|
||||
} Context;
|
||||
static Context *ctx;
|
||||
|
||||
/* Options */
|
||||
static gboolean list_flag;
|
||||
static gchar *set_str;
|
||||
static gint delete_int = MM_3GPP_PROFILE_ID_UNKNOWN;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "3gpp-profile-manager-list", 0, 0, G_OPTION_ARG_NONE, &list_flag,
|
||||
"List available profiles",
|
||||
NULL
|
||||
},
|
||||
{ "3gpp-profile-manager-set", 0, 0, G_OPTION_ARG_STRING, &set_str,
|
||||
"Create or update a profile with the given settings.",
|
||||
"[\"key=value,...\"]"
|
||||
},
|
||||
{ "3gpp-profile-manager-delete", 0, 0, G_OPTION_ARG_INT, &delete_int,
|
||||
"Delete the profile with the given ID",
|
||||
"[Profile ID]"
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
GOptionGroup *
|
||||
mmcli_modem_3gpp_profile_manager_get_option_group (void)
|
||||
{
|
||||
GOptionGroup *group;
|
||||
|
||||
group = g_option_group_new ("3gpp-profile-manager",
|
||||
"3GPP profile management options:",
|
||||
"Show 3GPP profile management related options",
|
||||
NULL,
|
||||
NULL);
|
||||
g_option_group_add_entries (group, entries);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mmcli_modem_3gpp_profile_manager_options_enabled (void)
|
||||
{
|
||||
static guint n_actions = 0;
|
||||
static gboolean checked = FALSE;
|
||||
|
||||
if (checked)
|
||||
return !!n_actions;
|
||||
|
||||
n_actions = (list_flag +
|
||||
!!set_str +
|
||||
(delete_int != MM_3GPP_PROFILE_ID_UNKNOWN));
|
||||
|
||||
if (n_actions > 1) {
|
||||
g_printerr ("error: too many 3GPP profile management actions requested\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
checked = TRUE;
|
||||
return !!n_actions;
|
||||
}
|
||||
|
||||
static void
|
||||
context_free (void)
|
||||
{
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
if (ctx->cancellable)
|
||||
g_object_unref (ctx->cancellable);
|
||||
if (ctx->modem_3gpp_profile_manager)
|
||||
g_object_unref (ctx->modem_3gpp_profile_manager);
|
||||
if (ctx->object)
|
||||
g_object_unref (ctx->object);
|
||||
if (ctx->manager)
|
||||
g_object_unref (ctx->manager);
|
||||
g_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_modem_3gpp_profile_manager (void)
|
||||
{
|
||||
if (mm_modem_get_state (mm_object_peek_modem (ctx->object)) < MM_MODEM_STATE_ENABLED) {
|
||||
g_printerr ("error: modem not enabled yet\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!ctx->modem_3gpp_profile_manager) {
|
||||
g_printerr ("error: modem has no 3GPP profile management capabilities\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_modem_3gpp_profile_manager_shutdown (void)
|
||||
{
|
||||
context_free ();
|
||||
}
|
||||
|
||||
static void
|
||||
delete_process_reply (gboolean result,
|
||||
const GError *error)
|
||||
{
|
||||
if (error) {
|
||||
g_printerr ("error: couldn't delete profile: '%s'\n", error->message);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
g_print ("successfully deleted the profile\n");
|
||||
}
|
||||
|
||||
static void
|
||||
delete_ready (MMModem3gppProfileManager *modem_3gpp_profile_manager,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
gboolean operation_result;
|
||||
GError *error = NULL;
|
||||
|
||||
operation_result = mm_modem_3gpp_profile_manager_delete_finish (modem_3gpp_profile_manager, result, &error);
|
||||
delete_process_reply (operation_result, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
set_process_reply (MM3gppProfile *stored,
|
||||
const GError *error)
|
||||
{
|
||||
if (error) {
|
||||
g_printerr ("error: couldn't set profile: '%s'\n", error->message);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mmcli_output_profile_set (stored);
|
||||
mmcli_output_dump ();
|
||||
|
||||
g_object_unref (stored);
|
||||
}
|
||||
|
||||
static void
|
||||
set_ready (MMModem3gppProfileManager *modem_3gpp_profile_manager,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
MM3gppProfile *stored;
|
||||
GError *error = NULL;
|
||||
|
||||
stored = mm_modem_3gpp_profile_manager_set_finish (modem_3gpp_profile_manager, result, &error);
|
||||
set_process_reply (stored, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
list_process_reply (GList *result,
|
||||
const GError *error)
|
||||
{
|
||||
if (error) {
|
||||
g_printerr ("error: couldn't list profiles: '%s'\n", error->message);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mmcli_output_profile_list (result);
|
||||
mmcli_output_dump ();
|
||||
|
||||
g_list_free_full (result, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
list_ready (MMModem3gppProfileManager *modem_3gpp_profile_manager,
|
||||
GAsyncResult *result)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GList *profiles = NULL;
|
||||
|
||||
mm_modem_3gpp_profile_manager_list_finish (modem_3gpp_profile_manager, result, &profiles, &error);
|
||||
list_process_reply (profiles, error);
|
||||
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
get_modem_ready (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer none)
|
||||
{
|
||||
ctx->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||
ctx->modem_3gpp_profile_manager = mm_object_get_modem_3gpp_profile_manager (ctx->object);
|
||||
|
||||
/* Setup operation timeout */
|
||||
if (ctx->modem_3gpp_profile_manager)
|
||||
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp_profile_manager));
|
||||
|
||||
ensure_modem_3gpp_profile_manager ();
|
||||
|
||||
/* Request to list? */
|
||||
if (list_flag) {
|
||||
g_debug ("Asynchronously listing profiles...");
|
||||
mm_modem_3gpp_profile_manager_list (ctx->modem_3gpp_profile_manager,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)list_ready,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to set? */
|
||||
if (set_str) {
|
||||
GError *error = NULL;
|
||||
g_autoptr(MM3gppProfile) requested = NULL;
|
||||
|
||||
g_debug ("Asynchronously setting profiles...");
|
||||
requested = mm_3gpp_profile_new_from_string (set_str, &error);
|
||||
if (!requested) {
|
||||
g_printerr ("Error parsing profile string: '%s'\n", error->message);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mm_modem_3gpp_profile_manager_set (ctx->modem_3gpp_profile_manager,
|
||||
requested,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)set_ready,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to delete? */
|
||||
if (delete_int != MM_3GPP_PROFILE_ID_UNKNOWN) {
|
||||
g_autoptr(MM3gppProfile) profile = NULL;
|
||||
|
||||
g_debug ("Asynchronously deleting profile...");
|
||||
profile = mm_3gpp_profile_new ();
|
||||
mm_3gpp_profile_set_profile_id (profile, delete_int);
|
||||
mm_modem_3gpp_profile_manager_delete (ctx->modem_3gpp_profile_manager,
|
||||
profile,
|
||||
ctx->cancellable,
|
||||
(GAsyncReadyCallback)delete_ready,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_modem_3gpp_profile_manager_run_asynchronous (GDBusConnection *connection,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
/* Initialize context */
|
||||
ctx = g_new0 (Context, 1);
|
||||
if (cancellable)
|
||||
ctx->cancellable = g_object_ref (cancellable);
|
||||
|
||||
/* Get proper modem */
|
||||
mmcli_get_modem (connection,
|
||||
mmcli_get_common_modem_string (),
|
||||
cancellable,
|
||||
(GAsyncReadyCallback)get_modem_ready,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_modem_3gpp_profile_manager_run_synchronous (GDBusConnection *connection)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
/* Initialize context */
|
||||
ctx = g_new0 (Context, 1);
|
||||
ctx->object = mmcli_get_modem_sync (connection,
|
||||
mmcli_get_common_modem_string (),
|
||||
&ctx->manager);
|
||||
ctx->modem_3gpp_profile_manager = mm_object_get_modem_3gpp_profile_manager (ctx->object);
|
||||
|
||||
/* Setup operation timeout */
|
||||
if (ctx->modem_3gpp_profile_manager)
|
||||
mmcli_force_operation_timeout (G_DBUS_PROXY (ctx->modem_3gpp_profile_manager));
|
||||
|
||||
ensure_modem_3gpp_profile_manager ();
|
||||
|
||||
/* Request to list? */
|
||||
if (list_flag) {
|
||||
GList *profiles;
|
||||
|
||||
g_debug ("Synchronously listing profiles...");
|
||||
mm_modem_3gpp_profile_manager_list_sync (ctx->modem_3gpp_profile_manager,
|
||||
ctx->cancellable,
|
||||
&profiles,
|
||||
&error);
|
||||
list_process_reply (profiles, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to set? */
|
||||
if (set_str) {
|
||||
g_autoptr(MM3gppProfile) requested = NULL;
|
||||
MM3gppProfile *stored;
|
||||
|
||||
g_debug ("Synchronously setting profile...");
|
||||
requested = mm_3gpp_profile_new_from_string (set_str, &error);
|
||||
if (!requested) {
|
||||
g_printerr ("Error parsing profile string: '%s'\n", error->message);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
stored = mm_modem_3gpp_profile_manager_set_sync (ctx->modem_3gpp_profile_manager,
|
||||
requested,
|
||||
ctx->cancellable,
|
||||
&error);
|
||||
set_process_reply (stored, error);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to delete? */
|
||||
if (delete_int != MM_3GPP_PROFILE_ID_UNKNOWN) {
|
||||
g_autoptr(MM3gppProfile) profile = NULL;
|
||||
gboolean result;
|
||||
|
||||
g_debug ("Synchronously deleting profile...");
|
||||
profile = mm_3gpp_profile_new ();
|
||||
mm_3gpp_profile_set_profile_id (profile, delete_int);
|
||||
result = mm_modem_3gpp_profile_manager_delete_sync (ctx->modem_3gpp_profile_manager,
|
||||
profile,
|
||||
ctx->cancellable,
|
||||
&error);
|
||||
delete_process_reply (result, error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
@@ -45,6 +45,7 @@ static SectionInfo section_infos[] = {
|
||||
[MMC_S_MODEM_3GPP_EPS] = { "3GPP EPS" },
|
||||
[MMC_S_MODEM_3GPP_SCAN] = { "3GPP scan" },
|
||||
[MMC_S_MODEM_3GPP_USSD] = { "3GPP USSD" },
|
||||
[MMC_S_MODEM_3GPP_PROFILE_MANAGER] = { "3GPP profile manager" },
|
||||
[MMC_S_MODEM_CDMA] = { "CDMA" },
|
||||
[MMC_S_MODEM_SIM] = { "SIM" },
|
||||
[MMC_S_MODEM_BEARER] = { "Bearer" },
|
||||
@@ -140,6 +141,8 @@ static FieldInfo field_infos[] = {
|
||||
[MMC_F_3GPP_USSD_STATUS] = { "modem.3gpp.ussd.status", "status", MMC_S_MODEM_3GPP_USSD, },
|
||||
[MMC_F_3GPP_USSD_NETWORK_REQUEST] = { "modem.3gpp.ussd.network-request", "network request", MMC_S_MODEM_3GPP_USSD, },
|
||||
[MMC_F_3GPP_USSD_NETWORK_NOTIFICATION] = { "modem.3gpp.ussd.network-notification", "network notification", MMC_S_MODEM_3GPP_USSD, },
|
||||
[MMC_F_3GPP_PROFILE_MANAGER_LIST] = { "modem.3gpp.profile-manager.list", "list", MMC_S_MODEM_3GPP_PROFILE_MANAGER, },
|
||||
[MMC_F_3GPP_PROFILE_MANAGER_SET] = { "modem.3gpp.profile-manager.set", "set", MMC_S_MODEM_3GPP_PROFILE_MANAGER, },
|
||||
[MMC_F_CDMA_MEID] = { "modem.cdma.meid", "meid", MMC_S_MODEM_CDMA, },
|
||||
[MMC_F_CDMA_ESN] = { "modem.cdma.esn", "esn", MMC_S_MODEM_CDMA, },
|
||||
[MMC_F_CDMA_SID] = { "modem.cdma.sid", "sid", MMC_S_MODEM_CDMA, },
|
||||
@@ -839,6 +842,150 @@ mmcli_output_preferred_networks (GList *preferred_nets_list)
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* (Custom) Profile list output */
|
||||
|
||||
static void
|
||||
build_profile_human (GPtrArray *array,
|
||||
MM3gppProfile *profile)
|
||||
{
|
||||
const gchar *aux;
|
||||
MMBearerAllowedAuth allowed_auth;
|
||||
MMBearerIpFamily ip_type;
|
||||
MMBearerApnType apn_type;
|
||||
|
||||
g_ptr_array_add (array, g_strdup_printf ("profile-id: %u", mm_3gpp_profile_get_profile_id (profile)));
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
||||
g_ptr_array_add (array, g_strdup_printf (" apn: %s", aux));
|
||||
|
||||
allowed_auth = mm_3gpp_profile_get_allowed_auth (profile);
|
||||
if (allowed_auth != MM_BEARER_ALLOWED_AUTH_NONE) {
|
||||
g_autofree gchar *allowed_auth_str = NULL;
|
||||
|
||||
allowed_auth_str = mm_bearer_allowed_auth_build_string_from_mask (allowed_auth);
|
||||
g_ptr_array_add (array, g_strdup_printf (" allowed-auth: %s", allowed_auth_str));
|
||||
}
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_user (profile)) != NULL)
|
||||
g_ptr_array_add (array, g_strdup_printf (" user: %s", aux));
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_password (profile)) != NULL)
|
||||
g_ptr_array_add (array, g_strdup_printf (" password: %s", aux));
|
||||
|
||||
ip_type = mm_3gpp_profile_get_ip_type (profile);
|
||||
if (ip_type != MM_BEARER_IP_FAMILY_NONE) {
|
||||
g_autofree gchar *ip_type_str = NULL;
|
||||
|
||||
ip_type_str = mm_bearer_ip_family_build_string_from_mask (ip_type);
|
||||
g_ptr_array_add (array, g_strdup_printf (" ip-type: %s", ip_type_str));
|
||||
}
|
||||
|
||||
apn_type = mm_3gpp_profile_get_apn_type (profile);
|
||||
if (apn_type != MM_BEARER_APN_TYPE_NONE) {
|
||||
g_autofree gchar *apn_type_str = NULL;
|
||||
|
||||
apn_type_str = mm_bearer_apn_type_build_string_from_mask (apn_type);
|
||||
g_ptr_array_add (array, g_strdup_printf (" apn-type: %s", apn_type_str));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
build_profile_keyvalue (GPtrArray *array,
|
||||
MM3gppProfile *profile)
|
||||
{
|
||||
GString *str;
|
||||
const gchar *aux;
|
||||
MMBearerAllowedAuth allowed_auth;
|
||||
MMBearerIpFamily ip_type;
|
||||
MMBearerApnType apn_type;
|
||||
|
||||
str = g_string_new ("");
|
||||
g_string_append_printf (str, "profile-id: %u", mm_3gpp_profile_get_profile_id (profile));
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_apn (profile)) != NULL)
|
||||
g_string_append_printf (str, ", apn: %s", aux);
|
||||
|
||||
allowed_auth = mm_3gpp_profile_get_allowed_auth (profile);
|
||||
if (allowed_auth != MM_BEARER_ALLOWED_AUTH_NONE) {
|
||||
g_autofree gchar *allowed_auth_str = NULL;
|
||||
|
||||
allowed_auth_str = mm_bearer_allowed_auth_build_string_from_mask (allowed_auth);
|
||||
g_string_append_printf (str, ", allowed-auth: %s", allowed_auth_str);
|
||||
}
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_user (profile)) != NULL)
|
||||
g_string_append_printf (str, ", user: %s", aux);
|
||||
|
||||
if ((aux = mm_3gpp_profile_get_password (profile)) != NULL)
|
||||
g_string_append_printf (str, ", password: %s", aux);
|
||||
|
||||
ip_type = mm_3gpp_profile_get_ip_type (profile);
|
||||
if (ip_type != MM_BEARER_IP_FAMILY_NONE) {
|
||||
g_autofree gchar *ip_type_str = NULL;
|
||||
|
||||
ip_type_str = mm_bearer_ip_family_build_string_from_mask (ip_type);
|
||||
g_string_append_printf (str, ", ip-type: %s", ip_type_str);
|
||||
}
|
||||
|
||||
apn_type = mm_3gpp_profile_get_apn_type (profile);
|
||||
if (apn_type != MM_BEARER_APN_TYPE_NONE) {
|
||||
g_autofree gchar *apn_type_str = NULL;
|
||||
|
||||
apn_type_str = mm_bearer_apn_type_build_string_from_mask (apn_type);
|
||||
g_string_append_printf (str, ", apn-type: %s", apn_type_str);
|
||||
}
|
||||
|
||||
g_ptr_array_add (array, g_string_free (str, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
output_profile_list (MmcF field,
|
||||
GList *profile_list)
|
||||
{
|
||||
gchar **profiles = NULL;
|
||||
|
||||
if (profile_list) {
|
||||
GPtrArray *aux;
|
||||
GList *l;
|
||||
|
||||
aux = g_ptr_array_new ();
|
||||
for (l = profile_list; l; l = g_list_next (l)) {
|
||||
MM3gppProfile *profile = (MM3gppProfile *)(l->data);
|
||||
|
||||
if (selected_type == MMC_OUTPUT_TYPE_HUMAN)
|
||||
build_profile_human (aux, profile);
|
||||
else
|
||||
build_profile_keyvalue (aux, profile);
|
||||
}
|
||||
g_ptr_array_add (aux, NULL);
|
||||
profiles = (gchar **) g_ptr_array_free (aux, FALSE);
|
||||
}
|
||||
|
||||
/* When printing human result, we want to show some result even if no profiles
|
||||
* are found, so we force a explicit string result. */
|
||||
if (selected_type == MMC_OUTPUT_TYPE_HUMAN && !profiles)
|
||||
output_item_new_take_single (field, g_strdup ("n/a"));
|
||||
else
|
||||
output_item_new_take_multiple (field, profiles, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_output_profile_list (GList *profile_list)
|
||||
{
|
||||
output_profile_list (MMC_F_3GPP_PROFILE_MANAGER_LIST, profile_list);
|
||||
}
|
||||
|
||||
void
|
||||
mmcli_output_profile_set (MM3gppProfile *profile)
|
||||
{
|
||||
GList *profile_list = NULL;
|
||||
|
||||
profile_list = g_list_append (profile_list, profile);
|
||||
output_profile_list (MMC_F_3GPP_PROFILE_MANAGER_SET, profile_list);
|
||||
g_list_free (profile_list);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* Human-friendly output */
|
||||
|
||||
|
@@ -42,6 +42,7 @@ typedef enum {
|
||||
MMC_S_MODEM_3GPP_EPS,
|
||||
MMC_S_MODEM_3GPP_SCAN,
|
||||
MMC_S_MODEM_3GPP_USSD,
|
||||
MMC_S_MODEM_3GPP_PROFILE_MANAGER,
|
||||
MMC_S_MODEM_CDMA,
|
||||
MMC_S_MODEM_SIM,
|
||||
MMC_S_MODEM_BEARER,
|
||||
@@ -140,6 +141,9 @@ typedef enum {
|
||||
MMC_F_3GPP_EPS_BEARER_SETTINGS_PASSWORD,
|
||||
/* 3GPP scan section */
|
||||
MMC_F_3GPP_SCAN_NETWORKS,
|
||||
/* 3GPP profile management section */
|
||||
MMC_F_3GPP_PROFILE_MANAGER_LIST,
|
||||
MMC_F_3GPP_PROFILE_MANAGER_SET,
|
||||
/* USSD section */
|
||||
MMC_F_3GPP_USSD_STATUS,
|
||||
MMC_F_3GPP_USSD_NETWORK_REQUEST,
|
||||
@@ -356,6 +360,8 @@ void mmcli_output_firmware_list (GList *firmware_list,
|
||||
MMFirmwareProperties *selected);
|
||||
void mmcli_output_pco_list (GList *pco_list);
|
||||
void mmcli_output_preferred_networks (GList *preferred_nets_list);
|
||||
void mmcli_output_profile_list (GList *profile_list);
|
||||
void mmcli_output_profile_set (MM3gppProfile *profile);
|
||||
|
||||
/******************************************************************************/
|
||||
/* Dump output */
|
||||
|
11
cli/mmcli.c
11
cli/mmcli.c
@@ -211,6 +211,8 @@ main (gint argc, gchar **argv)
|
||||
mmcli_modem_get_option_group ());
|
||||
g_option_context_add_group (context,
|
||||
mmcli_modem_3gpp_get_option_group ());
|
||||
g_option_context_add_group (context,
|
||||
mmcli_modem_3gpp_profile_manager_get_option_group ());
|
||||
g_option_context_add_group (context,
|
||||
mmcli_modem_3gpp_ussd_get_option_group ());
|
||||
g_option_context_add_group (context,
|
||||
@@ -337,6 +339,13 @@ main (gint argc, gchar **argv)
|
||||
else
|
||||
mmcli_modem_3gpp_run_synchronous (connection);
|
||||
}
|
||||
/* Modem 3GPP profile manager options? */
|
||||
else if (mmcli_modem_3gpp_profile_manager_options_enabled ()) {
|
||||
if (async_flag)
|
||||
mmcli_modem_3gpp_profile_manager_run_asynchronous (connection, cancellable);
|
||||
else
|
||||
mmcli_modem_3gpp_profile_manager_run_synchronous (connection);
|
||||
}
|
||||
/* Modem 3GPP USSD options? */
|
||||
else if (mmcli_modem_3gpp_ussd_options_enabled ()) {
|
||||
if (async_flag)
|
||||
@@ -431,6 +440,8 @@ main (gint argc, gchar **argv)
|
||||
mmcli_manager_shutdown ();
|
||||
} else if (mmcli_modem_3gpp_options_enabled ()) {
|
||||
mmcli_modem_3gpp_shutdown ();
|
||||
} else if (mmcli_modem_3gpp_profile_manager_options_enabled ()) {
|
||||
mmcli_modem_3gpp_profile_manager_shutdown ();
|
||||
} else if (mmcli_modem_3gpp_ussd_options_enabled ()) {
|
||||
mmcli_modem_3gpp_ussd_shutdown ();
|
||||
} else if (mmcli_modem_cdma_options_enabled ()) {
|
||||
|
@@ -61,6 +61,14 @@ void mmcli_modem_3gpp_ussd_run_asynchronous (GDBusConnection *connect
|
||||
void mmcli_modem_3gpp_ussd_run_synchronous (GDBusConnection *connection);
|
||||
void mmcli_modem_3gpp_ussd_shutdown (void);
|
||||
|
||||
/* 3GPP profile manager group */
|
||||
GOptionGroup *mmcli_modem_3gpp_profile_manager_get_option_group (void);
|
||||
gboolean mmcli_modem_3gpp_profile_manager_options_enabled (void);
|
||||
void mmcli_modem_3gpp_profile_manager_run_asynchronous (GDBusConnection *connection,
|
||||
GCancellable *cancellable);
|
||||
void mmcli_modem_3gpp_profile_manager_run_synchronous (GDBusConnection *connection);
|
||||
void mmcli_modem_3gpp_profile_manager_shutdown (void);
|
||||
|
||||
/* CDMA group */
|
||||
GOptionGroup *mmcli_modem_cdma_get_option_group (void);
|
||||
gboolean mmcli_modem_cdma_options_enabled (void);
|
||||
|
@@ -71,6 +71,7 @@ expand_content_files = \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Oma.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml \
|
||||
$(top_builddir)/libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Signal.xml \
|
||||
|
@@ -130,6 +130,7 @@
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml"/>
|
||||
<xi:include href="../../../../libmm-glib/generated/mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Messaging.xml"/>
|
||||
|
@@ -105,6 +105,7 @@
|
||||
</section>
|
||||
<section>
|
||||
<title>Profile management support</title>
|
||||
<xi:include href="xml/mm-modem-3gpp-profile-manager.xml"/>
|
||||
<xi:include href="xml/mm-3gpp-profile.xml"/>
|
||||
</section>
|
||||
<section>
|
||||
@@ -197,6 +198,10 @@
|
||||
<xi:include href="xml/MmGdbusModem3gppProxy.xml"/>
|
||||
<xi:include href="xml/MmGdbusModem3gppSkeleton.xml"/>
|
||||
|
||||
<xi:include href="xml/MmGdbusModem3gppProfileManager.xml"/>
|
||||
<xi:include href="xml/MmGdbusModem3gppProfileManagerProxy.xml"/>
|
||||
<xi:include href="xml/MmGdbusModem3gppProfileManagerSkeleton.xml"/>
|
||||
|
||||
<xi:include href="xml/MmGdbusModem3gppUssd.xml"/>
|
||||
<xi:include href="xml/MmGdbusModem3gppUssdProxy.xml"/>
|
||||
<xi:include href="xml/MmGdbusModem3gppUssdSkeleton.xml"/>
|
||||
|
@@ -85,6 +85,8 @@ mm_object_peek_modem
|
||||
mm_object_get_modem
|
||||
mm_object_peek_modem_3gpp
|
||||
mm_object_get_modem_3gpp
|
||||
mm_object_peek_modem_3gpp_profile_manager
|
||||
mm_object_get_modem_3gpp_profile_manager
|
||||
mm_object_peek_modem_3gpp_ussd
|
||||
mm_object_get_modem_3gpp_ussd
|
||||
mm_object_peek_modem_cdma
|
||||
@@ -1575,6 +1577,34 @@ MM_TYPE_3GPP_PROFILE
|
||||
mm_3gpp_profile_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>mm-modem-3gpp-profile-manager</FILE>
|
||||
<TITLE>MMModem3gppProfileManager</TITLE>
|
||||
MMModem3gppProfileManager
|
||||
<SUBSECTION Getters>
|
||||
mm_modem_3gpp_profile_manager_get_path
|
||||
mm_modem_3gpp_profile_manager_dup_path
|
||||
<SUBSECTION Methods>
|
||||
mm_modem_3gpp_profile_manager_list
|
||||
mm_modem_3gpp_profile_manager_list_finish
|
||||
mm_modem_3gpp_profile_manager_list_sync
|
||||
mm_modem_3gpp_profile_manager_set
|
||||
mm_modem_3gpp_profile_manager_set_finish
|
||||
mm_modem_3gpp_profile_manager_set_sync
|
||||
mm_modem_3gpp_profile_manager_delete
|
||||
mm_modem_3gpp_profile_manager_delete_finish
|
||||
mm_modem_3gpp_profile_manager_delete_sync
|
||||
<SUBSECTION Standard>
|
||||
MMModem3gppProfileManagerClass
|
||||
MM_IS_MODEM_3GPP_PROFILE_MANAGER
|
||||
MM_IS_MODEM_3GPP_PROFILE_MANAGER_CLASS
|
||||
MM_MODEM_3GPP_PROFILE_MANAGER
|
||||
MM_MODEM_3GPP_PROFILE_MANAGER_CLASS
|
||||
MM_MODEM_3GPP_PROFILE_MANAGER_GET_CLASS
|
||||
MM_TYPE_MODEM_3GPP_PROFILE_MANAGER
|
||||
mm_modem_3gpp_profile_manager_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>mm-enums-types</FILE>
|
||||
<TITLE>Flags and Enumerations</TITLE>
|
||||
@@ -2137,6 +2167,77 @@ MmGdbusModem3gppUssdSkeletonPrivate
|
||||
mm_gdbus_modem3gpp_ussd_skeleton_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>MmGdbusModem3gppProfileManager</FILE>
|
||||
<TITLE>MmGdbusModem3gppProfileManager</TITLE>
|
||||
MmGdbusModem3gppProfileManager
|
||||
MmGdbusModem3gppProfileManagerIface
|
||||
<SUBSECTION Methods>
|
||||
mm_gdbus_modem3gpp_profile_manager_call_delete
|
||||
mm_gdbus_modem3gpp_profile_manager_call_delete_finish
|
||||
mm_gdbus_modem3gpp_profile_manager_call_delete_sync
|
||||
mm_gdbus_modem3gpp_profile_manager_call_list
|
||||
mm_gdbus_modem3gpp_profile_manager_call_list_finish
|
||||
mm_gdbus_modem3gpp_profile_manager_call_list_sync
|
||||
mm_gdbus_modem3gpp_profile_manager_call_set
|
||||
mm_gdbus_modem3gpp_profile_manager_call_set_finish
|
||||
mm_gdbus_modem3gpp_profile_manager_call_set_sync
|
||||
<SUBSECTION Private>
|
||||
mm_gdbus_modem3gpp_profile_manager_emit_updated
|
||||
mm_gdbus_modem3gpp_profile_manager_complete_delete
|
||||
mm_gdbus_modem3gpp_profile_manager_complete_list
|
||||
mm_gdbus_modem3gpp_profile_manager_complete_set
|
||||
mm_gdbus_modem3gpp_profile_manager_interface_info
|
||||
mm_gdbus_modem3gpp_profile_manager_override_properties
|
||||
<SUBSECTION Standard>
|
||||
MM_GDBUS_IS_MODEM3GPP_PROFILE_MANAGER
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_GET_IFACE
|
||||
MM_GDBUS_TYPE_MODEM3GPP_PROFILE_MANAGER
|
||||
mm_gdbus_modem3gpp_profile_manager_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>MmGdbusModem3gppProfileManagerProxy</FILE>
|
||||
<TITLE>MmGdbusModem3gppProfileManagerProxy</TITLE>
|
||||
MmGdbusModem3gppProfileManagerProxy
|
||||
<SUBSECTION New>
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new_finish
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new_for_bus
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new_for_bus_finish
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new_for_bus_sync
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_new_sync
|
||||
<SUBSECTION Standard>
|
||||
MmGdbusModem3gppProfileManagerProxyClass
|
||||
MM_GDBUS_IS_MODEM3GPP_PROFILE_MANAGER_PROXY
|
||||
MM_GDBUS_IS_MODEM3GPP_PROFILE_MANAGER_PROXY_CLASS
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_PROXY
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_PROXY_CLASS
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_PROXY_GET_CLASS
|
||||
MM_GDBUS_TYPE_MODEM3GPP_PROFILE_MANAGER_PROXY
|
||||
MmGdbusModem3gppProfileManagerProxyPrivate
|
||||
mm_gdbus_modem3gpp_profile_manager_proxy_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>MmGdbusModem3gppProfileManagerSkeleton</FILE>
|
||||
<TITLE>MmGdbusModem3gppProfileManagerSkeleton</TITLE>
|
||||
MmGdbusModem3gppProfileManagerSkeleton
|
||||
<SUBSECTION New>
|
||||
mm_gdbus_modem3gpp_profile_manager_skeleton_new
|
||||
<SUBSECTION Standard>
|
||||
MmGdbusModem3gppProfileManagerSkeletonClass
|
||||
MM_GDBUS_IS_MODEM3GPP_PROFILE_MANAGER_SKELETON
|
||||
MM_GDBUS_IS_MODEM3GPP_PROFILE_MANAGER_SKELETON_CLASS
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_SKELETON
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_SKELETON_CLASS
|
||||
MM_GDBUS_MODEM3GPP_PROFILE_MANAGER_SKELETON_GET_CLASS
|
||||
MM_GDBUS_TYPE_MODEM3GPP_PROFILE_MANAGER_SKELETON
|
||||
MmGdbusModem3gppProfileManagerSkeletonPrivate
|
||||
mm_gdbus_modem3gpp_profile_manager_skeleton_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>MmGdbusModem</FILE>
|
||||
<TITLE>MmGdbusModem</TITLE>
|
||||
@@ -3166,6 +3267,8 @@ mm_gdbus_object_peek_modem3gpp
|
||||
mm_gdbus_object_get_modem3gpp
|
||||
mm_gdbus_object_peek_modem3gpp_ussd
|
||||
mm_gdbus_object_get_modem3gpp_ussd
|
||||
mm_gdbus_object_peek_modem3gpp_profile_manager
|
||||
mm_gdbus_object_get_modem3gpp_profile_manager
|
||||
mm_gdbus_object_peek_modem_cdma
|
||||
mm_gdbus_object_get_modem_cdma
|
||||
mm_gdbus_object_peek_modem_location
|
||||
@@ -3224,6 +3327,7 @@ mm_gdbus_object_skeleton_new
|
||||
mm_gdbus_object_skeleton_set_modem
|
||||
mm_gdbus_object_skeleton_set_modem3gpp
|
||||
mm_gdbus_object_skeleton_set_modem3gpp_ussd
|
||||
mm_gdbus_object_skeleton_set_modem3gpp_profile_manager
|
||||
mm_gdbus_object_skeleton_set_modem_cdma
|
||||
mm_gdbus_object_skeleton_set_modem_firmware
|
||||
mm_gdbus_object_skeleton_set_modem_oma
|
||||
|
@@ -22,6 +22,7 @@ xml_DATA = \
|
||||
org.freedesktop.ModemManager1.Modem.Voice.xml \
|
||||
org.freedesktop.ModemManager1.Call.xml \
|
||||
org.freedesktop.ModemManager1.Modem.Sar.xml \
|
||||
org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
@@ -10,6 +10,7 @@
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.Voice.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.Modem3gpp.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.ModemCdma.xml"/>
|
||||
<xi:include href="org.freedesktop.ModemManager1.Modem.Messaging.xml"/>
|
||||
|
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!--
|
||||
ModemManager 1.0 Interface Specification
|
||||
|
||||
Copyright (C) 2021 Google Inc.
|
||||
Copyright (C) 2021 Aleksander Morgado
|
||||
-->
|
||||
|
||||
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
|
||||
|
||||
<!--
|
||||
org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager:
|
||||
@short_description: The ModemManager 3GPP profile management interface.
|
||||
|
||||
This interface provides access to actions with connection profiles.
|
||||
|
||||
This interface will only be available once the modem is ready to be
|
||||
registered in the cellular network. 3GPP devices will require a valid
|
||||
unlocked SIM card before any of the features in the interface can be
|
||||
used.
|
||||
|
||||
The user of the interface can optionally choose to use the new profile
|
||||
management methods to manage the connection setup, e.g by using the new
|
||||
<literal>"profile-id"</literal> setting in either the
|
||||
<link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem.CreateBearer">CreateBearer</link>
|
||||
or the
|
||||
<link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem-Simple.Connect">Connect</link>
|
||||
methods. If that's the case, it is suggested that the legacy approach of
|
||||
not using the profiles is completely avoided. If both approaches are
|
||||
used at the same time, it may happen that a connection attempt not using
|
||||
the <literal>"profile-id"</literal> implicitly updates a given profile
|
||||
(without emitting
|
||||
<link linkend="gdbus-signal-org-freedesktop-ModemManager1-Modem-Modem3gpp-ProfileManager.Updated">Updated</link>),
|
||||
as the amount of profiles implemented in modems may be fixed.
|
||||
-->
|
||||
<interface name="org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager">
|
||||
|
||||
<!--
|
||||
List:
|
||||
@profiles: An array of dictionaries containing the properties of the provisioned profiles.
|
||||
|
||||
Lists the available profiles or contexts provisioned on the modem.
|
||||
|
||||
Profiles are represented as dictionaries of properties, and any of the
|
||||
3GPP-specific properties defined in the
|
||||
<link linkend="gdbus-property-org-freedesktop-ModemManager1-Bearer.Properties">bearer properties</link>
|
||||
are allowed.
|
||||
|
||||
Depending on the implementation, the settings applicable to the initial
|
||||
EPS bearer given in
|
||||
<link linkend="gdbus-property-org-freedesktop-ModemManager1-Modem-Modem3gpp.InitialEpsBearerSettings">bearer properties</link>
|
||||
may also be reported as an item in the returned list, identified by the
|
||||
%MM_BEARER_APN_TYPE_INITIAL <literal>"apn-type"</literal> flag.
|
||||
|
||||
Since: 1.18
|
||||
-->
|
||||
<method name="List">
|
||||
<arg name="profiles" type="aa{sv}" direction="out" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
Set:
|
||||
@requested_properties: the requested profile properties.
|
||||
@stored_properties: the stored profile properties.
|
||||
|
||||
Creates or updates a connection profile on this modem. If
|
||||
<literal>"profile-id"</literal> is not given, a new profile will be
|
||||
created; otherwise, the profile with the given ID will be updated.
|
||||
|
||||
Profiles are represented as dictionaries of properties, and any of the
|
||||
3GPP-specific properties defined in the
|
||||
<link linkend="gdbus-property-org-freedesktop-ModemManager1-Bearer.Properties">bearer properties</link>
|
||||
are allowed. The real list of supported properties really depends on the
|
||||
underlying protocol and implementation, though; e.g. in AT-based modems
|
||||
setting <literal>"apn-type"</literal> won't be supported, and instead the
|
||||
user should give that setting explicitly when creating the bearer object.
|
||||
|
||||
The operation may fail if it is attempting to update an existing
|
||||
profile for which connected bearer objects already exist. In this case,
|
||||
the user should make sure these bearer objects are already disconnected
|
||||
before attempting to change the profile settings.
|
||||
|
||||
The operation may also fail if it is attempting to update the profile
|
||||
associated to the settings of the initial EPS bearer, identified by the
|
||||
%MM_BEARER_APN_TYPE_INITIAL <literal>"apn-type"</literal> flag. In this
|
||||
case, <link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem-Modem3gpp.SetInitialEpsBearerSettings">SetInitialEpsBearerSettings()</link>
|
||||
should be used instead.
|
||||
|
||||
The output @stored_properties will contain the settings that were
|
||||
successfully stored, including the new <literal>"profile-id"</literal>
|
||||
if the operation was creating a new profile.
|
||||
|
||||
Since: 1.18
|
||||
-->
|
||||
<method name="Set">
|
||||
<arg name="requested_properties" type="a{sv}" direction="in" />
|
||||
<arg name="stored_properties" type="a{sv}" direction="out" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
Delete:
|
||||
@properties: the profile properties.
|
||||
|
||||
Deletes the profile with the <literal>"profile-id"</literal> given in @properties.
|
||||
|
||||
If additional settings are given in @properties they are ignored. This
|
||||
allows the user to easily request the deletion of a profile that has been
|
||||
provided in the List() operation.
|
||||
|
||||
This method may just clear the existing profiles (i.e. reseting all the
|
||||
properties to defaults) instead of fully removing them if the profiles
|
||||
cannot be fully removed. In this case, the method will succeed, but the
|
||||
size of the list of profiles will not change.
|
||||
|
||||
This method will fail if <literal>"profile-id"</literal> is not given.
|
||||
|
||||
The operation may fail if it is attempting to delete a profile
|
||||
for which connected bearer objects already exist. In this case,
|
||||
the user should make sure these bearer objects are already disconnected
|
||||
before attempting to delete the profile.
|
||||
|
||||
The operation may also fail if it is attempting to delete the profile
|
||||
associated to the settings of the initial EPS bearer, identified by the
|
||||
%MM_BEARER_APN_TYPE_INITIAL <literal>"apn-type"</literal> flag. In this
|
||||
case, <link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem-Modem3gpp.SetInitialEpsBearerSettings">SetInitialEpsBearerSettings()</link>
|
||||
may be used instead to clear these settings.
|
||||
|
||||
Since: 1.18
|
||||
-->
|
||||
<method name="Delete">
|
||||
<arg name="properties" type="a{sv}" direction="in" />
|
||||
</method>
|
||||
|
||||
<!--
|
||||
Updated:
|
||||
|
||||
Emitted when the profiles are updated by the network through OTA
|
||||
procedures.
|
||||
|
||||
Since: 1.18
|
||||
-->
|
||||
<signal name="Updated" />
|
||||
|
||||
</interface>
|
||||
</node>
|
@@ -18,6 +18,8 @@ libmm_glib_la_SOURCES = \
|
||||
mm-modem.c \
|
||||
mm-modem-3gpp.h \
|
||||
mm-modem-3gpp.c \
|
||||
mm-modem-3gpp-profile-manager.h \
|
||||
mm-modem-3gpp-profile-manager.c \
|
||||
mm-modem-3gpp-ussd.h \
|
||||
mm-modem-3gpp-ussd.c \
|
||||
mm-modem-cdma.h \
|
||||
@@ -129,6 +131,7 @@ include_HEADERS = \
|
||||
mm-object.h \
|
||||
mm-modem.h \
|
||||
mm-modem-3gpp.h \
|
||||
mm-modem-3gpp-profile-manager.h \
|
||||
mm-modem-3gpp-ussd.h \
|
||||
mm-modem-cdma.h \
|
||||
mm-modem-messaging.h \
|
||||
|
@@ -44,6 +44,7 @@ GENERATED_DOC = \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Oma.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Sar.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml \
|
||||
@@ -119,6 +120,7 @@ mm_gdbus_modem_generated = \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Oma.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.ModemCdma.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Sar.xml \
|
||||
mm-gdbus-doc-org.freedesktop.ModemManager1.Modem.Simple.xml \
|
||||
@@ -134,6 +136,7 @@ mm_gdbus_modem_deps = \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Oma.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.ModemCdma.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Sar.xml \
|
||||
$(top_srcdir)/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml \
|
||||
@@ -149,6 +152,7 @@ mm-gdbus-modem.c: $(mm_gdbus_modem_deps)
|
||||
--annotate "org.freedesktop.ModemManager1.Modem.ModemCdma" org.gtk.GDBus.C.Name ModemCdma \
|
||||
--annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp" org.gtk.GDBus.C.Name Modem3gpp \
|
||||
--annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd" org.gtk.GDBus.C.Name Modem3gppUssd \
|
||||
--annotate "org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager" org.gtk.GDBus.C.Name Modem3gppProfileManager \
|
||||
$^ \
|
||||
$(NULL)
|
||||
$(filter-out mm-gdbus-modem.c, $(mm_gdbus_modem_generated)): $(mm_gdbus_modem_deps) mm-gdbus-modem.c
|
||||
|
@@ -40,6 +40,7 @@
|
||||
# include <mm-bearer.h>
|
||||
# include <mm-modem.h>
|
||||
# include <mm-modem-3gpp.h>
|
||||
# include <mm-modem-3gpp-profile-manager.h>
|
||||
# include <mm-modem-3gpp-ussd.h>
|
||||
# include <mm-modem-cdma.h>
|
||||
# include <mm-modem-simple.h>
|
||||
|
@@ -75,6 +75,7 @@ get_proxy_type (GDBusObjectManagerClient *manager,
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Oma", GSIZE_TO_POINTER (MM_TYPE_MODEM_OMA));
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.ModemCdma", GSIZE_TO_POINTER (MM_TYPE_MODEM_CDMA));
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Modem3gpp", GSIZE_TO_POINTER (MM_TYPE_MODEM_3GPP));
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Modem3gpp.ProfileManager", GSIZE_TO_POINTER (MM_TYPE_MODEM_3GPP_PROFILE_MANAGER));
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd", GSIZE_TO_POINTER (MM_TYPE_MODEM_3GPP_USSD));
|
||||
g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Simple", GSIZE_TO_POINTER (MM_TYPE_MODEM_SIMPLE));
|
||||
/* g_hash_table_insert (lookup_hash, "org.freedesktop.ModemManager1.Modem.Contacts", GSIZE_TO_POINTER (MM_GDBUS_TYPE_MODEM_CONTACTS_PROXY)); */
|
||||
|
489
libmm-glib/mm-modem-3gpp-profile-manager.c
Normal file
489
libmm-glib/mm-modem-3gpp-profile-manager.c
Normal file
@@ -0,0 +1,489 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
|
||||
* Copyright (C) 2021 Google, Inc.
|
||||
*/
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "mm-helpers.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-modem-3gpp-profile-manager.h"
|
||||
|
||||
/**
|
||||
* SECTION: mm-modem-3gpp-profile-manager
|
||||
* @title: MMModem3gppProfileManager
|
||||
* @short_description: The 3GPP profile manager interface
|
||||
*
|
||||
* The #MMModem3gppProfileManager is an object providing access to the methods
|
||||
* and signals of the 3GPP Profile Manager interface.
|
||||
*
|
||||
* This interface is only exposed when the 3GPP modem is known to handle profile
|
||||
* management operations.
|
||||
*/
|
||||
|
||||
G_DEFINE_TYPE (MMModem3gppProfileManager, mm_modem_3gpp_profile_manager, MM_GDBUS_TYPE_MODEM3GPP_PROFILE_MANAGER_PROXY)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_get_path:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
*
|
||||
* Gets the DBus path of the #MMObject which implements this interface.
|
||||
*
|
||||
* Returns: (transfer none): The DBus path of the #MMObject object.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
const gchar *
|
||||
mm_modem_3gpp_profile_manager_get_path (MMModem3gppProfileManager *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), NULL);
|
||||
|
||||
RETURN_NON_EMPTY_CONSTANT_STRING (
|
||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY (self)));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_dup_path:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
*
|
||||
* Gets a copy of the DBus path of the #MMObject object which implements this
|
||||
* interface.
|
||||
*
|
||||
* Returns: (transfer full): The DBus path of the #MMObject. The returned value
|
||||
* should be freed with g_free().
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gchar *
|
||||
mm_modem_3gpp_profile_manager_dup_path (MMModem3gppProfileManager *self)
|
||||
{
|
||||
gchar *value;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), NULL);
|
||||
|
||||
g_object_get (G_OBJECT (self),
|
||||
"g-object-path", &value,
|
||||
NULL);
|
||||
RETURN_NON_EMPTY_STRING (value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
build_list_results (GVariant *dictionaries,
|
||||
GList **out_profiles,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GError) saved_error = NULL;
|
||||
GVariantIter iter;
|
||||
guint n;
|
||||
GList *profiles = NULL;
|
||||
|
||||
if (out_profiles)
|
||||
*out_profiles = NULL;
|
||||
|
||||
if (!dictionaries)
|
||||
return TRUE;
|
||||
|
||||
/* Parse array of dictionaries */
|
||||
g_variant_iter_init (&iter, dictionaries);
|
||||
n = g_variant_iter_n_children (&iter);
|
||||
|
||||
if (n > 0) {
|
||||
g_autoptr(GVariant) dictionary = NULL;
|
||||
|
||||
while ((dictionary = g_variant_iter_next_value (&iter))) {
|
||||
MM3gppProfile *profile = NULL;
|
||||
g_autoptr(GError) inner_error = NULL;
|
||||
|
||||
profile = mm_3gpp_profile_new_from_dictionary (dictionary, &inner_error);
|
||||
if (!profile) {
|
||||
g_warning ("Couldn't create 3GPP profile: %s", inner_error->message);
|
||||
if (!saved_error)
|
||||
saved_error = g_steal_pointer (&inner_error);
|
||||
} else
|
||||
profiles = g_list_append (profiles, profile);
|
||||
}
|
||||
}
|
||||
|
||||
if (saved_error && !profiles) {
|
||||
g_propagate_error (error, g_steal_pointer (&saved_error));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (out_profiles)
|
||||
*out_profiles = profiles;
|
||||
else
|
||||
g_list_free_full (profiles, g_object_unref);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_list_finish:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_3gpp_profile_manager_list().
|
||||
* @profiles: (out) (allow-none) (transfer full) (element-type ModemManager.3gppProfile):
|
||||
* A list of #MM3gppProfile objects available in the device. The returned value
|
||||
* should be freed with g_list_free_full() using g_object_unref() as
|
||||
* #GDestroyNotify.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_3gpp_profile_manager_list().
|
||||
*
|
||||
* Returns: %TRUE if the list was correctly retrieved, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_profile_manager_list_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GList **profiles,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GVariant) dictionaries = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), FALSE);
|
||||
|
||||
if (!mm_gdbus_modem3gpp_profile_manager_call_list_finish (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
&dictionaries,
|
||||
res,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
return build_list_results (dictionaries, profiles, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_list:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or
|
||||
* %NULL.
|
||||
* @user_data: User data to pass to @callback.
|
||||
*
|
||||
* Asynchronously gets the list of available connection profiles.
|
||||
*
|
||||
* When the operation is finished, @callback will be invoked in the
|
||||
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
|
||||
* of the thread you are calling this method from. You can then call
|
||||
* mm_modem_3gpp_profile_manager_list_finish() to get the result of the
|
||||
* operation.
|
||||
*
|
||||
* See mm_modem_3gpp_profile_manager_list_sync() for the synchronous, blocking
|
||||
* version of this method.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
mm_modem_3gpp_profile_manager_list (MMModem3gppProfileManager *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self));
|
||||
|
||||
mm_gdbus_modem3gpp_profile_manager_call_list (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_list_sync:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @profiles: (out) (allow-none) (transfer full) (element-type ModemManager.3gppProfile):
|
||||
* A list of #MM3gppProfile objects available in the device. The returned value
|
||||
* should be freed with g_list_free_full() using g_object_unref() as
|
||||
* #GDestroyNotify.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Synchronously gets the list of available connection profiles.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_3gpp_profile_manager_list() for the asynchronous version of this
|
||||
* method.
|
||||
*
|
||||
* Returns: %TRUE if the list was correctly retrieved, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_profile_manager_list_sync (MMModem3gppProfileManager *self,
|
||||
GCancellable *cancellable,
|
||||
GList **profiles,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GVariant) dictionaries = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), FALSE);
|
||||
|
||||
if (!mm_gdbus_modem3gpp_profile_manager_call_list_sync (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
&dictionaries,
|
||||
cancellable,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
return build_list_results (dictionaries, profiles, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_set_finish:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_3gpp_profile_manager_set().
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_3gpp_profile_manager_set().
|
||||
*
|
||||
* Returns: (transfer full): A #MM3gppProfile with the stored settings, or %NULL if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
MM3gppProfile *
|
||||
mm_modem_3gpp_profile_manager_set_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GVariant) stored_dictionary = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), NULL);
|
||||
|
||||
if (!mm_gdbus_modem3gpp_profile_manager_call_set_finish (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
&stored_dictionary,
|
||||
res,
|
||||
error))
|
||||
return NULL;
|
||||
|
||||
return mm_3gpp_profile_new_from_dictionary (stored_dictionary, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_set:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @requested: A #MM3gppProfile with the requested settings.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or
|
||||
* %NULL.
|
||||
* @user_data: User data to pass to @callback.
|
||||
*
|
||||
* Asynchronously updates a connection profile with the settings
|
||||
* given in @profile.
|
||||
*
|
||||
* If @profile does not have an explicit profile ID set, a new profile will
|
||||
* be created.
|
||||
*
|
||||
* When the operation is finished, @callback will be invoked in the
|
||||
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
|
||||
* of the thread you are calling this method from. You can then call
|
||||
* mm_modem_3gpp_profile_manager_set_finish() to get the result of the
|
||||
* operation.
|
||||
*
|
||||
* See mm_modem_3gpp_profile_manager_set_sync() for the synchronous, blocking
|
||||
* version of this method.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
mm_modem_3gpp_profile_manager_set (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *requested,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GVariant) requested_dictionary = NULL;
|
||||
|
||||
g_return_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self));
|
||||
|
||||
requested_dictionary = mm_3gpp_profile_get_dictionary (requested);
|
||||
mm_gdbus_modem3gpp_profile_manager_call_set (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
requested_dictionary,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_set_sync:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @requested: A #MM3gppProfile with the requested settings.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Synchronously updates a connection profile with the settings
|
||||
* given in @profile.
|
||||
*
|
||||
* If @profile does not have an explicit profile ID set, a new profile will
|
||||
* be created.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_3gpp_profile_manager_set() for the asynchronous version of this
|
||||
* method.
|
||||
*
|
||||
* Returns: (transfer full): A #MM3gppProfile with the stored settings, or %NULL if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
MM3gppProfile *
|
||||
mm_modem_3gpp_profile_manager_set_sync (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *requested,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GVariant) requested_dictionary = NULL;
|
||||
g_autoptr(GVariant) stored_dictionary = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), NULL);
|
||||
|
||||
requested_dictionary = mm_3gpp_profile_get_dictionary (requested);
|
||||
|
||||
if (!mm_gdbus_modem3gpp_profile_manager_call_set_sync (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
requested_dictionary,
|
||||
&stored_dictionary,
|
||||
cancellable,
|
||||
error))
|
||||
return NULL;
|
||||
|
||||
return mm_3gpp_profile_new_from_dictionary (stored_dictionary, error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_delete_finish:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_3gpp_profile_manager_delete().
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_3gpp_profile_manager_delete().
|
||||
*
|
||||
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_profile_manager_delete_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), FALSE);
|
||||
|
||||
return mm_gdbus_modem3gpp_profile_manager_call_delete_finish (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self), res, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_delete:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @profile: A #MM3gppProfile.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or
|
||||
* %NULL.
|
||||
* @user_data: User data to pass to @callback.
|
||||
*
|
||||
* Asynchronously deletes the connection profile.
|
||||
*
|
||||
* The @profile should have at least the profile ID set for the delete operation
|
||||
* to succeed.
|
||||
*
|
||||
* When the operation is finished, @callback will be invoked in the
|
||||
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
|
||||
* of the thread you are calling this method from. You can then call
|
||||
* mm_modem_3gpp_profile_manager_delete_finish() to get the result of the
|
||||
* operation.
|
||||
*
|
||||
* See mm_modem_3gpp_profile_manager_delete_sync() for the synchronous, blocking
|
||||
* version of this method.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
void
|
||||
mm_modem_3gpp_profile_manager_delete (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *profile,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GVariant) profile_dictionary = NULL;
|
||||
|
||||
g_return_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self));
|
||||
|
||||
profile_dictionary = mm_3gpp_profile_get_dictionary (profile);
|
||||
mm_gdbus_modem3gpp_profile_manager_call_delete (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
profile_dictionary,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_3gpp_profile_manager_delete_sync:
|
||||
* @self: A #MMModem3gppProfileManager.
|
||||
* @profile: A #MM3gppProfile.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Synchronously deletes the connection profile.
|
||||
*
|
||||
* The @profile should have at least the profile ID set for the delete operation
|
||||
* to succeed.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_3gpp_profile_manager_delete() for the asynchronous version of this
|
||||
* method.
|
||||
*
|
||||
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_3gpp_profile_manager_delete_sync (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *profile,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GVariant) profile_dictionary = NULL;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_3GPP_PROFILE_MANAGER (self), FALSE);
|
||||
|
||||
profile_dictionary = mm_3gpp_profile_get_dictionary (profile);
|
||||
return mm_gdbus_modem3gpp_profile_manager_call_delete_sync (MM_GDBUS_MODEM3GPP_PROFILE_MANAGER (self),
|
||||
profile_dictionary,
|
||||
cancellable,
|
||||
error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_modem_3gpp_profile_manager_init (MMModem3gppProfileManager *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_modem_3gpp_profile_manager_class_init (MMModem3gppProfileManagerClass *modem_class)
|
||||
{
|
||||
}
|
112
libmm-glib/mm-modem-3gpp-profile-manager.h
Normal file
112
libmm-glib/mm-modem-3gpp-profile-manager.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
|
||||
* Copyright (C) 2021 Google, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _MM_MODEM_3GPP_PROFILE_MANAGER_H_
|
||||
#define _MM_MODEM_3GPP_PROFILE_MANAGER_H_
|
||||
|
||||
#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION)
|
||||
#error "Only <libmm-glib.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <ModemManager.h>
|
||||
|
||||
#include "mm-3gpp-profile.h"
|
||||
#include "mm-gdbus-modem.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MM_TYPE_MODEM_3GPP_PROFILE_MANAGER (mm_modem_3gpp_profile_manager_get_type ())
|
||||
#define MM_MODEM_3GPP_PROFILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_3GPP_PROFILE_MANAGER, MMModem3gppProfileManager))
|
||||
#define MM_MODEM_3GPP_PROFILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_3GPP_PROFILE_MANAGER, MMModem3gppProfileManagerClass))
|
||||
#define MM_IS_MODEM_3GPP_PROFILE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_3GPP_PROFILE_MANAGER))
|
||||
#define MM_IS_MODEM_3GPP_PROFILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_3GPP_PROFILE_MANAGER))
|
||||
#define MM_MODEM_3GPP_PROFILE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_3GPP_PROFILE_MANAGER, MMModem3gppProfileManagerClass))
|
||||
|
||||
typedef struct _MMModem3gppProfileManager MMModem3gppProfileManager;
|
||||
typedef struct _MMModem3gppProfileManagerClass MMModem3gppProfileManagerClass;
|
||||
|
||||
/**
|
||||
* MMModem3gppProfileManager:
|
||||
*
|
||||
* The #MMModem3gppProfileManager structure contains private data and should only be accessed
|
||||
* using the provided API.
|
||||
*/
|
||||
struct _MMModem3gppProfileManager {
|
||||
/*< private >*/
|
||||
MmGdbusModem3gppProfileManagerProxy parent;
|
||||
gpointer unused;
|
||||
};
|
||||
|
||||
struct _MMModem3gppProfileManagerClass {
|
||||
/*< private >*/
|
||||
MmGdbusModem3gppProfileManagerProxyClass parent;
|
||||
};
|
||||
|
||||
GType mm_modem_3gpp_profile_manager_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMModem3gppProfileManager, g_object_unref)
|
||||
|
||||
const gchar *mm_modem_3gpp_profile_manager_get_path (MMModem3gppProfileManager *self);
|
||||
gchar *mm_modem_3gpp_profile_manager_dup_path (MMModem3gppProfileManager *self);
|
||||
|
||||
void mm_modem_3gpp_profile_manager_list (MMModem3gppProfileManager *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_modem_3gpp_profile_manager_list_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GList **profiles,
|
||||
GError **error);
|
||||
gboolean mm_modem_3gpp_profile_manager_list_sync (MMModem3gppProfileManager *self,
|
||||
GCancellable *cancellable,
|
||||
GList **profiles,
|
||||
GError **error);
|
||||
|
||||
void mm_modem_3gpp_profile_manager_set (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *requested,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MM3gppProfile *mm_modem_3gpp_profile_manager_set_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
MM3gppProfile *mm_modem_3gpp_profile_manager_set_sync (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *requested,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void mm_modem_3gpp_profile_manager_delete (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *profile,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_modem_3gpp_profile_manager_delete_finish (MMModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
gboolean mm_modem_3gpp_profile_manager_delete_sync (MMModem3gppProfileManager *self,
|
||||
MM3gppProfile *profile,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _MM_MODEM_3GPP_PROFILE_MANAGER_H_ */
|
@@ -183,6 +183,52 @@ mm_object_peek_modem_3gpp (MMObject *self)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_object_get_modem_3gpp_profile_manager:
|
||||
* @self: A #MMObject.
|
||||
*
|
||||
* Gets the #MMModem3gppProfileManager instance for the D-Bus interface
|
||||
* org.freedesktop.ModemManager1.Modem.Modem3gpp-ProfileManager on @self, if any.
|
||||
*
|
||||
* Returns: (transfer full): A #MMModem3gppProfileManager that must be freed with
|
||||
* g_object_unref() or %NULL if @self does not implement the interface.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
MMModem3gppProfileManager *
|
||||
mm_object_get_modem_3gpp_profile_manager (MMObject *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
||||
|
||||
return (MMModem3gppProfileManager *)mm_gdbus_object_get_modem3gpp_profile_manager (MM_GDBUS_OBJECT (self));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_object_peek_modem_3gpp_profile_manager: (skip)
|
||||
* @self: A #MMObject.
|
||||
*
|
||||
* Like mm_object_get_modem_3gpp_profile_manager() but doesn't increase the reference count
|
||||
* on the returned object.
|
||||
*
|
||||
* <warning>It is not safe to use the returned object if you are on another
|
||||
* thread than the one where the #MMManager is running.</warning>
|
||||
*
|
||||
* Returns: (transfer none): A #MMModem3gppProfileManager or %NULL if @self does not
|
||||
* implement the interface. Do not free the returned object, it is owned by
|
||||
* @self.
|
||||
*
|
||||
* Since: 1.18
|
||||
*/
|
||||
MMModem3gppProfileManager *
|
||||
mm_object_peek_modem_3gpp_profile_manager (MMObject *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
||||
|
||||
return (MMModem3gppProfileManager *)mm_gdbus_object_peek_modem3gpp_profile_manager (MM_GDBUS_OBJECT (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_object_get_modem_3gpp_ussd:
|
||||
* @self: A #MMObject.
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "mm-gdbus-modem.h"
|
||||
#include "mm-modem.h"
|
||||
#include "mm-modem-3gpp.h"
|
||||
#include "mm-modem-3gpp-profile-manager.h"
|
||||
#include "mm-modem-3gpp-ussd.h"
|
||||
#include "mm-modem-cdma.h"
|
||||
#include "mm-modem-simple.h"
|
||||
@@ -81,6 +82,7 @@ gchar *mm_object_dup_path (MMObject *self);
|
||||
|
||||
MMModem *mm_object_get_modem (MMObject *self);
|
||||
MMModem3gpp *mm_object_get_modem_3gpp (MMObject *self);
|
||||
MMModem3gppProfileManager *mm_object_get_modem_3gpp_profile_manager (MMObject *self);
|
||||
MMModem3gppUssd *mm_object_get_modem_3gpp_ussd (MMObject *self);
|
||||
MMModemCdma *mm_object_get_modem_cdma (MMObject *self);
|
||||
MMModemSimple *mm_object_get_modem_simple (MMObject *self);
|
||||
@@ -94,6 +96,7 @@ MMModemOma *mm_object_get_modem_oma (MMObject *self);
|
||||
|
||||
MMModem *mm_object_peek_modem (MMObject *self);
|
||||
MMModem3gpp *mm_object_peek_modem_3gpp (MMObject *self);
|
||||
MMModem3gppProfileManager *mm_object_peek_modem_3gpp_profile_manager (MMObject *self);
|
||||
MMModem3gppUssd *mm_object_peek_modem_3gpp_ussd (MMObject *self);
|
||||
MMModemCdma *mm_object_peek_modem_cdma (MMObject *self);
|
||||
MMModemSimple *mm_object_peek_modem_simple (MMObject *self);
|
||||
|
Reference in New Issue
Block a user