api: `UnlockRetries' will reply a list of per-lock retry counts
Equivalent to `PinRetryCount' in the previous API. We don't have an additional property for the retry count of the current lock, as it really is duplicating information.
This commit is contained in:
@@ -263,9 +263,7 @@ print_bearer_short_info (MMBearer *bearer)
|
||||
static void
|
||||
print_modem_info (void)
|
||||
{
|
||||
MMModemLock unlock_required;
|
||||
gchar *prefixed_revision;
|
||||
gchar *unlock;
|
||||
gchar *capabilities_string;
|
||||
gchar *access_technologies_string;
|
||||
gchar *supported_modes_string;
|
||||
@@ -273,7 +271,9 @@ print_modem_info (void)
|
||||
gchar *preferred_mode_string;
|
||||
gchar *supported_bands_string;
|
||||
gchar *bands_string;
|
||||
gchar *unlock_retries_string;
|
||||
MMModemBand *bands = NULL;
|
||||
MMUnlockRetries *unlock_retries;
|
||||
guint n_bands = 0;
|
||||
|
||||
/* Not the best thing to do, as we may be doing _get() calls twice, but
|
||||
@@ -283,22 +283,6 @@ print_modem_info (void)
|
||||
#undef VALIDATE_PATH
|
||||
#define VALIDATE_PATH(str) ((str && !g_str_equal (str, "/")) ? str : "none")
|
||||
|
||||
/* Strings with mixed properties */
|
||||
unlock_required = mm_modem_get_unlock_required (ctx->modem);
|
||||
switch (unlock_required) {
|
||||
case MM_MODEM_LOCK_NONE:
|
||||
unlock = g_strdup ("not required");
|
||||
break;
|
||||
case MM_MODEM_LOCK_UNKNOWN:
|
||||
unlock = g_strdup ("unknown");
|
||||
break;
|
||||
default:
|
||||
unlock = g_strdup_printf ("%s (%u retries)",
|
||||
mm_modem_lock_get_string (unlock_required),
|
||||
mm_modem_get_unlock_retries (ctx->modem));
|
||||
break;
|
||||
}
|
||||
|
||||
/* Strings in heap */
|
||||
capabilities_string = mm_modem_capability_build_string_from_mask (
|
||||
mm_modem_get_modem_capabilities (ctx->modem));
|
||||
@@ -317,6 +301,10 @@ print_modem_info (void)
|
||||
supported_modes_string = mm_modem_mode_build_string_from_mask (
|
||||
mm_modem_get_supported_modes (ctx->modem));
|
||||
|
||||
unlock_retries = mm_modem_get_unlock_retries (ctx->modem);
|
||||
unlock_retries_string = mm_unlock_retries_build_string (unlock_retries);
|
||||
g_object_unref (unlock_retries);
|
||||
|
||||
/* Rework possible multiline strings */
|
||||
prefixed_revision = prefix_newlines (" | ",
|
||||
mm_modem_get_revision (ctx->modem));
|
||||
@@ -351,10 +339,12 @@ print_modem_info (void)
|
||||
|
||||
/* Status related stuff */
|
||||
g_print (" -------------------------\n"
|
||||
" Status | unlock: '%s'\n"
|
||||
" Status | lock: '%s'\n"
|
||||
" | unlock retries: '%s'\n"
|
||||
" | state: '%s'\n"
|
||||
" | access tech: '%s'\n",
|
||||
VALIDATE_UNKNOWN (unlock),
|
||||
mm_modem_lock_get_string (mm_modem_get_unlock_required (ctx->modem)),
|
||||
VALIDATE_UNKNOWN (unlock_retries_string),
|
||||
VALIDATE_UNKNOWN (mm_modem_state_get_string (mm_modem_get_state (ctx->modem))),
|
||||
VALIDATE_UNKNOWN (access_technologies_string));
|
||||
|
||||
@@ -446,7 +436,7 @@ print_modem_info (void)
|
||||
g_free (allowed_modes_string);
|
||||
g_free (preferred_mode_string);
|
||||
g_free (supported_modes_string);
|
||||
g_free (unlock);
|
||||
g_free (unlock_retries_string);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -315,22 +315,13 @@
|
||||
<!--
|
||||
UnlockRetries:
|
||||
|
||||
The number of unlock retries remaining for the lock code given by the
|
||||
UnlockRequired property (if any), or 999 if the device does not support reporting
|
||||
unlock retries.
|
||||
-->
|
||||
<property name="UnlockRetries" type="u" access="read" />
|
||||
|
||||
<!--
|
||||
PinRetryCounts:
|
||||
|
||||
A dictionary in which the keys are <link linkend="MMModemLock">MMModemLock</link>
|
||||
flags, and the values are integers giving the number of PIN tries remaining
|
||||
before the code becomes blocked (requiring a PUK) or permanently blocked. Dictionary
|
||||
entries exist only for the codes for which the modem is able to report retry
|
||||
counts.
|
||||
-->
|
||||
<property name="PinRetryCounts" type="a{uu}" access="read" />
|
||||
<property name="UnlockRetries" type="a{uu}" access="read" />
|
||||
|
||||
<!--
|
||||
State:
|
||||
|
@@ -517,18 +517,22 @@ mm_modem_get_unlock_required (MMModem *self)
|
||||
* mm_modem_get_unlock_retries:
|
||||
* @self: A #MMModem.
|
||||
*
|
||||
* Gets the number of unlock retries remaining for the lock code given by the
|
||||
* UnlockRequired property (if any), or 999 if the device does not support reporting
|
||||
* unlock retries.
|
||||
* TODO
|
||||
*
|
||||
* Returns: The number of unlock retries.
|
||||
* Returns: a new reference to a #MMUnlockRetries object.
|
||||
*/
|
||||
guint
|
||||
MMUnlockRetries *
|
||||
mm_modem_get_unlock_retries (MMModem *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), 0);
|
||||
MMUnlockRetries *unlock_retries;
|
||||
GVariant *dictionary;
|
||||
|
||||
return mm_gdbus_modem_get_unlock_retries (self);
|
||||
g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), NULL);
|
||||
|
||||
dictionary = mm_gdbus_modem_get_unlock_retries (self);
|
||||
unlock_retries = mm_unlock_retries_new_from_dictionary (dictionary);
|
||||
|
||||
return unlock_retries;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -63,7 +63,7 @@ gchar *mm_modem_dup_plugin (MMModem *self);
|
||||
const gchar *mm_modem_get_equipment_identifier (MMModem *self);
|
||||
gchar *mm_modem_dup_equipment_identifier (MMModem *self);
|
||||
MMModemLock mm_modem_get_unlock_required (MMModem *self);
|
||||
guint mm_modem_get_unlock_retries (MMModem *self);
|
||||
MMUnlockRetries *mm_modem_get_unlock_retries (MMModem *self);
|
||||
MMModemState mm_modem_get_state (MMModem *self);
|
||||
MMModemAccessTechnology mm_modem_get_access_technologies (MMModem *self);
|
||||
guint mm_modem_get_signal_quality (MMModem *self,
|
||||
|
@@ -2164,6 +2164,106 @@ mm_iface_modem_unlock_check (MMIfaceModem *self,
|
||||
unlock_check_context_free (ctx);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Unlock retry count */
|
||||
|
||||
gboolean
|
||||
mm_iface_modem_update_unlock_retries_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||
return FALSE;
|
||||
|
||||
return g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res));
|
||||
}
|
||||
|
||||
static void
|
||||
update_unlock_retries (MMIfaceModem *self,
|
||||
MMUnlockRetries *unlock_retries)
|
||||
{
|
||||
MmGdbusModem *skeleton = NULL;
|
||||
GError *error = NULL;
|
||||
GVariant *previous_dictionary;
|
||||
MMUnlockRetries *previous_unlock_retries;
|
||||
|
||||
g_object_get (self,
|
||||
MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
|
||||
NULL);
|
||||
|
||||
previous_dictionary = mm_gdbus_modem_get_unlock_retries (skeleton);
|
||||
previous_unlock_retries = mm_unlock_retries_new_from_dictionary (previous_dictionary);
|
||||
|
||||
if (error) {
|
||||
mm_warn ("Couldn't build previous unlock retries: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
} else {
|
||||
/* If they are different, update */
|
||||
if (!mm_unlock_retries_cmp (unlock_retries, previous_unlock_retries)) {
|
||||
GVariant *new_dictionary;
|
||||
|
||||
new_dictionary = mm_unlock_retries_get_dictionary (unlock_retries);
|
||||
mm_gdbus_modem_set_unlock_retries (skeleton, new_dictionary);
|
||||
g_variant_unref (new_dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (previous_unlock_retries);
|
||||
g_object_unref (skeleton);
|
||||
}
|
||||
|
||||
static void
|
||||
unlock_retries_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GSimpleAsyncResult *simple)
|
||||
{
|
||||
GError *error = NULL;
|
||||
MMUnlockRetries *unlock_retries;
|
||||
|
||||
unlock_retries = MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_retries_finish (self, res, &error);
|
||||
if (!unlock_retries) {
|
||||
g_simple_async_result_take_error (simple, error);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the dictionary in the DBus interface */
|
||||
update_unlock_retries (self, unlock_retries);
|
||||
g_object_unref (unlock_retries);
|
||||
|
||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
|
||||
void
|
||||
mm_iface_modem_update_unlock_retries (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSimpleAsyncResult *result;
|
||||
|
||||
result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback,
|
||||
user_data,
|
||||
mm_iface_modem_update_unlock_retries);
|
||||
|
||||
if (MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_retries &&
|
||||
MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_retries_finish) {
|
||||
MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_retries (
|
||||
self,
|
||||
(GAsyncReadyCallback)unlock_retries_ready,
|
||||
result);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Return FALSE when we cannot load unlock retries */
|
||||
g_simple_async_result_set_op_res_gboolean (result, FALSE);
|
||||
g_simple_async_result_complete_in_idle (result);
|
||||
g_object_unref (result);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MODEM DISABLING */
|
||||
|
||||
@@ -3043,7 +3143,23 @@ load_unlock_required_ready (MMIfaceModem *self,
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
UINT_REPLY_READY_FN (unlock_retries, "Unlock Retries")
|
||||
static void
|
||||
update_unlock_retries_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
InitializationContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
mm_iface_modem_update_unlock_retries_finish (self, res, &error);
|
||||
if (error) {
|
||||
mm_warn ("couldn't update unlock retries: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Go on to next step */
|
||||
ctx->step++;
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
sim_new_ready (GAsyncInitable *initable,
|
||||
@@ -3298,24 +3414,10 @@ interface_initialization_step (InitializationContext *ctx)
|
||||
ctx->step++;
|
||||
|
||||
case INITIALIZATION_STEP_UNLOCK_RETRIES:
|
||||
if ((MMModemLock)mm_gdbus_modem_get_unlock_required (ctx->skeleton) == MM_MODEM_LOCK_NONE) {
|
||||
/* Default to 0 when unlocked */
|
||||
mm_gdbus_modem_set_unlock_retries (ctx->skeleton, 0);
|
||||
} else {
|
||||
if (MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_unlock_retries &&
|
||||
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_unlock_retries_finish) {
|
||||
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_unlock_retries (
|
||||
ctx->self,
|
||||
(GAsyncReadyCallback)load_unlock_retries_ready,
|
||||
ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Default to 999 when we cannot check it */
|
||||
mm_gdbus_modem_set_unlock_retries (ctx->skeleton, 999);
|
||||
}
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
mm_iface_modem_update_unlock_retries (ctx->self,
|
||||
(GAsyncReadyCallback)update_unlock_retries_ready,
|
||||
ctx);
|
||||
return;
|
||||
|
||||
case INITIALIZATION_STEP_SIM:
|
||||
/* If the modem doesn't need any SIM, skip */
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include <libmm-common.h>
|
||||
|
||||
#include "mm-charsets.h"
|
||||
#include "mm-at-serial-port.h"
|
||||
#include "mm-bearer.h"
|
||||
@@ -108,9 +110,9 @@ struct _MMIfaceModem {
|
||||
void (*load_unlock_retries) (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MMModemLock (*load_unlock_retries_finish) (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
MMUnlockRetries * (*load_unlock_retries_finish) (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Loading of the SupportedModes property */
|
||||
void (*load_supported_modes) (MMIfaceModem *self,
|
||||
@@ -335,6 +337,14 @@ MMModemLock mm_iface_modem_unlock_check_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Check unlock retries */
|
||||
void mm_iface_modem_update_unlock_retries (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_iface_modem_update_unlock_retries_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Request signal quality check update.
|
||||
* It will not only return the signal quality status, but also set the property
|
||||
* values in the DBus interface. */
|
||||
|
Reference in New Issue
Block a user