core: add an UnlockRequired property that provides lock status (bgo #604551)
Clients can check the property to determine lock/unlock status and thus unlock the modem before trying to connect if required. Bits of the patch by dcbw (see the bug).
This commit is contained in:

committed by
Dan Williams

parent
649b7e25a0
commit
3d0f2ecf12
@@ -113,6 +113,18 @@
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="UnlockRequired" type="s" access="read">
|
||||
<tp:docstring>
|
||||
Empty if the device is usable without an unlock code or has already
|
||||
been unlocked. If the device needs to be unlocked before becoming usable this
|
||||
property contains the specific unlock code required. Valid unlock code values
|
||||
are "" (blank), "sim-pin", "sim-puk", "ph-sim-pin", "ph-fsim-pin",
|
||||
"ph-fsim-puk", "sim-pin2", "sim-puk2", "ph-net-pin", "ph-net-puk",
|
||||
"ph-netsub-pin", "ph-netsub-puk", "ph-sp-pin", "ph-sp-puk", "ph-corp-pin", and
|
||||
"ph-corp-puk".
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="IpMethod" type="u" access="read" tp:type="MM_MODEM_IP_METHOD">
|
||||
<tp:docstring>
|
||||
The IP configuration method.
|
||||
|
@@ -39,6 +39,7 @@ typedef struct {
|
||||
char *driver;
|
||||
char *plugin;
|
||||
char *device;
|
||||
char *unlock_required;
|
||||
guint32 ip_method;
|
||||
gboolean valid;
|
||||
MMModemState state;
|
||||
@@ -169,6 +170,26 @@ mm_modem_base_get_valid (MMModemBase *self)
|
||||
return MM_MODEM_BASE_GET_PRIVATE (self)->valid;
|
||||
}
|
||||
|
||||
void mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required)
|
||||
{
|
||||
MMModemBasePrivate *priv;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (MM_IS_MODEM_BASE (self));
|
||||
|
||||
priv = MM_MODEM_BASE_GET_PRIVATE (self);
|
||||
|
||||
/* Only do something if the value changes */
|
||||
if (priv->unlock_required == unlock_required
|
||||
|| (priv->unlock_required && unlock_required
|
||||
&& !strcmp(priv->unlock_required, unlock_required)))
|
||||
return;
|
||||
|
||||
g_free (priv->unlock_required);
|
||||
priv->unlock_required = g_strdup (unlock_required);
|
||||
g_object_notify (G_OBJECT (self), MM_MODEM_UNLOCK_REQUIRED);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
@@ -227,6 +248,7 @@ set_property (GObject *object, guint prop_id,
|
||||
case MM_MODEM_PROP_VALID:
|
||||
case MM_MODEM_PROP_TYPE:
|
||||
case MM_MODEM_PROP_ENABLED:
|
||||
case MM_MODEM_PROP_UNLOCK_REQUIRED:
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@@ -268,6 +290,9 @@ get_property (GObject *object, guint prop_id,
|
||||
case MM_MODEM_PROP_ENABLED:
|
||||
g_value_set_boolean (value, is_enabled (priv->state));
|
||||
break;
|
||||
case MM_MODEM_PROP_UNLOCK_REQUIRED:
|
||||
g_value_set_string (value, priv->unlock_required);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -284,6 +309,7 @@ finalize (GObject *object)
|
||||
g_free (priv->driver);
|
||||
g_free (priv->plugin);
|
||||
g_free (priv->device);
|
||||
g_free (priv->unlock_required);
|
||||
|
||||
G_OBJECT_CLASS (mm_modem_base_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -336,6 +362,10 @@ mm_modem_base_class_init (MMModemBaseClass *klass)
|
||||
MM_MODEM_PROP_ENABLED,
|
||||
MM_MODEM_ENABLED);
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
MM_MODEM_PROP_UNLOCK_REQUIRED,
|
||||
MM_MODEM_UNLOCK_REQUIRED);
|
||||
|
||||
mm_properties_changed_signal_new (object_class);
|
||||
}
|
||||
|
||||
|
@@ -60,5 +60,8 @@ void mm_modem_base_set_valid (MMModemBase *self,
|
||||
|
||||
gboolean mm_modem_base_get_valid (MMModemBase *self);
|
||||
|
||||
void mm_modem_base_set_unlock_required (MMModemBase *self,
|
||||
const char *unlock_required);
|
||||
|
||||
#endif /* MM_MODEM_BASE_H */
|
||||
|
||||
|
@@ -694,6 +694,15 @@ mm_modem_init (gpointer g_iface)
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_string (MM_MODEM_UNLOCK_REQUIRED,
|
||||
"UnlockRequired",
|
||||
"Whether or not the modem requires an unlock "
|
||||
"code to become usable, and if so, which unlock code is required",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* Signals */
|
||||
g_signal_new ("state-changed",
|
||||
iface_type,
|
||||
|
@@ -55,6 +55,7 @@ typedef enum {
|
||||
#define MM_MODEM_TYPE "type"
|
||||
#define MM_MODEM_IP_METHOD "ip-method"
|
||||
#define MM_MODEM_ENABLED "enabled"
|
||||
#define MM_MODEM_UNLOCK_REQUIRED "unlock-required"
|
||||
#define MM_MODEM_VALID "valid" /* not exported */
|
||||
#define MM_MODEM_PLUGIN "plugin" /* not exported */
|
||||
#define MM_MODEM_STATE "state" /* not exported */
|
||||
@@ -78,7 +79,8 @@ typedef enum {
|
||||
MM_MODEM_PROP_VALID, /* Not exported */
|
||||
MM_MODEM_PROP_PLUGIN, /* Not exported */
|
||||
MM_MODEM_PROP_STATE, /* Not exported */
|
||||
MM_MODEM_PROP_ENABLED
|
||||
MM_MODEM_PROP_ENABLED,
|
||||
MM_MODEM_PROP_UNLOCK_REQUIRED
|
||||
} MMModemProp;
|
||||
|
||||
typedef struct _MMModem MMModem;
|
||||
|
Reference in New Issue
Block a user