aboutsummaryrefslogtreecommitdiff
path: root/cli/mmcli-modem-3gpp.c
diff options
context:
space:
mode:
authorMichal Mazur <mkm@semihalf.com>2020-12-11 14:15:11 +0100
committerAleksander Morgado <aleksander@aleksander.es>2021-04-30 18:40:29 +0000
commit25ffe4211afa37a68274535d64a12670fd5ceebc (patch)
treef2e0dbefefdf8979137c40ca5fa39d725f5063ba /cli/mmcli-modem-3gpp.c
parentb1dde0aec39089161268452b54ea92737ae00aa5 (diff)
api,libmm-glib,cli: add command to disable facility lock
Diffstat (limited to 'cli/mmcli-modem-3gpp.c')
-rw-r--r--cli/mmcli-modem-3gpp.c100
1 files changed, 98 insertions, 2 deletions
diff --git a/cli/mmcli-modem-3gpp.c b/cli/mmcli-modem-3gpp.c
index d498eb62..8ea82efd 100644
--- a/cli/mmcli-modem-3gpp.c
+++ b/cli/mmcli-modem-3gpp.c
@@ -51,6 +51,7 @@ static gboolean register_home_flag;
static gchar *register_in_operator_str;
static gchar *set_eps_ue_mode_operation_str;
static gchar *set_initial_eps_bearer_settings_str;
+static gchar *disable_facility_lock_str;
static GOptionEntry entries[] = {
{ "3gpp-scan", 0, 0, G_OPTION_ARG_NONE, &scan_flag,
@@ -73,6 +74,10 @@ static GOptionEntry entries[] = {
"Set the initial EPS bearer settings",
"[\"key=value,...\"]"
},
+ { "3gpp-disable-facility-lock", 0, 0, G_OPTION_ARG_STRING, &disable_facility_lock_str,
+ "Disable facility personalization",
+ "[facility,key]"
+ },
{ NULL }
};
@@ -104,7 +109,8 @@ mmcli_modem_3gpp_options_enabled (void)
register_home_flag +
!!register_in_operator_str +
!!set_eps_ue_mode_operation_str +
- !!set_initial_eps_bearer_settings_str);
+ !!set_initial_eps_bearer_settings_str +
+ !!disable_facility_lock_str);
if (n_actions > 1) {
g_printerr ("error: too many 3GPP actions requested\n");
@@ -138,13 +144,19 @@ context_free (void)
}
static void
-ensure_modem_3gpp (void)
+ensure_modem_enabled (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);
}
+ /* Success */
+}
+
+static void
+ensure_modem_3gpp (void)
+{
if (!ctx->modem_3gpp) {
g_printerr ("error: modem has no 3GPP capabilities\n");
exit (EXIT_FAILURE);
@@ -280,6 +292,33 @@ parse_eps_ue_mode_operation (MMModem3gppEpsUeModeOperation *uemode)
}
static void
+disable_facility_lock_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't disable facility lock: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("successfully disabled facility lock\n");
+}
+
+static void
+disable_facility_lock_ready (MMModem3gpp *modem_3gpp,
+ GAsyncResult *result,
+ gpointer nothing)
+{
+ gboolean operation_result;
+ GError *error = NULL;
+
+ operation_result = mm_modem_3gpp_disable_facility_lock_finish (modem_3gpp, result, &error);
+ disable_facility_lock_process_reply (operation_result, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
get_modem_ready (GObject *source,
GAsyncResult *result)
{
@@ -292,6 +331,34 @@ get_modem_ready (GObject *source,
ensure_modem_3gpp ();
+ /* Request to disable facility lock */
+ if (disable_facility_lock_str) {
+ gchar **properties;
+ gchar *control_key;
+ MMModem3gppFacility facility;
+
+ properties = g_strsplit (disable_facility_lock_str, ",", -1);
+ if (!properties[0] || !(control_key = properties[1]) ||
+ !(facility = mm_common_get_3gpp_facility_from_string (properties[0], NULL))) {
+ g_printerr ("Error parsing properties string.\n");
+ g_free (properties[0]);
+ g_free (properties[1]);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Disable facility lock...");
+ mm_modem_3gpp_disable_facility_lock (ctx->modem_3gpp,
+ facility,
+ control_key,
+ ctx->cancellable,
+ (GAsyncReadyCallback)disable_facility_lock_ready,
+ NULL);
+ g_strfreev (properties);
+ return;
+ }
+
+ ensure_modem_enabled ();
+
/* Request to scan networks? */
if (scan_flag) {
g_debug ("Asynchronously scanning for networks...");
@@ -391,6 +458,35 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection)
if (scan_flag)
g_assert_not_reached ();
+ /* Request to remove carrier lock */
+ if (disable_facility_lock_str) {
+ gchar **properties;
+ gchar *control_key;
+ MMModem3gppFacility facility;
+ gboolean result;
+
+ properties = g_strsplit (disable_facility_lock_str, ",", -1);
+ if (!properties[0] || !(control_key = properties[1]) ||
+ !(facility = mm_common_get_3gpp_facility_from_string (properties[0], NULL))) {
+ g_printerr ("Error parsing properties string.\n");
+ g_free (properties[0]);
+ g_free (properties[1]);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Disable facility lock...");
+ result = mm_modem_3gpp_disable_facility_lock_sync (ctx->modem_3gpp,
+ facility,
+ control_key,
+ NULL,
+ &error);
+ g_strfreev (properties);
+ disable_facility_lock_process_reply (result, error);
+ return;
+ }
+
+ ensure_modem_enabled ();
+
/* Request to register the modem? */
if (register_in_operator_str || register_home_flag) {
gboolean result;