core: add modem EquipmentIdentity property to report IMEI/ESN/MEID
This commit is contained in:
committed by
Dan Williams
parent
c95216e575
commit
52929a2c92
@@ -113,6 +113,13 @@
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="EquipmentIdentity" type="s" access="read">
|
||||
<tp:docstring>
|
||||
The EquipmentIdentity of the device. This will be the IMEI number for
|
||||
GSM devices and the hex-format ESN/MEID for CDMA devices.
|
||||
</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
|
||||
|
||||
@@ -290,6 +290,18 @@ check_pin (MMGenericGsm *modem,
|
||||
mm_at_serial_port_queue_command (priv->primary, "+CPIN?", 3, pin_check_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_imei_cb (MMModem *modem,
|
||||
const char *result,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (modem) {
|
||||
mm_modem_base_set_equipment_identity (MM_MODEM_BASE (modem), error ? "" : result);
|
||||
mm_serial_port_close (MM_SERIAL_PORT (MM_GENERIC_GSM_GET_PRIVATE (modem)->primary));
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
@@ -403,6 +415,34 @@ initial_pin_check (MMGenericGsm *self)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
initial_imei_check (MMGenericGsm *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
MMGenericGsmPrivate *priv;
|
||||
|
||||
g_return_if_fail (MM_IS_GENERIC_GSM (self));
|
||||
priv = MM_GENERIC_GSM_GET_PRIVATE (self);
|
||||
|
||||
g_return_if_fail (priv->primary != NULL);
|
||||
|
||||
if (mm_serial_port_open (MM_SERIAL_PORT (priv->primary), &error)) {
|
||||
/* Make sure echoing is off */
|
||||
mm_at_serial_port_queue_command (priv->primary, "E0", 3, NULL, NULL);
|
||||
|
||||
/* Get modem's imei number */
|
||||
mm_modem_gsm_card_get_imei (MM_MODEM_GSM_CARD (self),
|
||||
get_imei_cb,
|
||||
NULL);
|
||||
} else {
|
||||
g_warning ("%s: failed to open serial port: (%d) %s",
|
||||
__func__,
|
||||
error ? error->code : -1,
|
||||
error && error->message ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
owns_port (MMModem *modem, const char *subsys, const char *name)
|
||||
{
|
||||
@@ -456,6 +496,9 @@ mm_generic_gsm_grab_port (MMGenericGsm *self,
|
||||
/* Get modem's initial lock/unlock state */
|
||||
initial_pin_check (self);
|
||||
|
||||
/* Get modem's IMEI number */
|
||||
initial_imei_check (self);
|
||||
|
||||
} else if (ptype == MM_PORT_TYPE_SECONDARY)
|
||||
priv->secondary = MM_AT_SERIAL_PORT (port);
|
||||
} else if (MM_IS_QCDM_SERIAL_PORT (port)) {
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef struct {
|
||||
char *driver;
|
||||
char *plugin;
|
||||
char *device;
|
||||
char *equipment_identity;
|
||||
char *unlock_required;
|
||||
guint32 unlock_retries;
|
||||
guint32 ip_method;
|
||||
@@ -192,6 +193,47 @@ mm_modem_base_get_valid (MMModemBase *self)
|
||||
return MM_MODEM_BASE_GET_PRIVATE (self)->valid;
|
||||
}
|
||||
|
||||
const char *
|
||||
mm_modem_base_get_equipment_identity (MMModemBase *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
|
||||
|
||||
return MM_MODEM_BASE_GET_PRIVATE (self)->equipment_identity;
|
||||
}
|
||||
|
||||
void
|
||||
mm_modem_base_set_equipment_identity (MMModemBase *self, const char *equipment_identity)
|
||||
{
|
||||
MMModemBasePrivate *priv;
|
||||
const char *dbus_path;
|
||||
|
||||
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->equipment_identity == equipment_identity)
|
||||
|| ( priv->equipment_identity
|
||||
&& equipment_identity
|
||||
&& !strcmp (priv->equipment_identity, equipment_identity)))
|
||||
return;
|
||||
|
||||
g_free (priv->equipment_identity);
|
||||
priv->equipment_identity = g_strdup (equipment_identity);
|
||||
|
||||
dbus_path = (const char *) g_object_get_data (G_OBJECT (self), DBUS_PATH_TAG);
|
||||
if (dbus_path) {
|
||||
if (priv->equipment_identity)
|
||||
g_message ("Modem %s: EquipmentIdentity set (%s)", dbus_path, priv->equipment_identity);
|
||||
else
|
||||
g_message ("Modem %s: EquipmentIdentity not set", dbus_path);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (self), MM_MODEM_EQUIPMENT_IDENTITY);
|
||||
}
|
||||
|
||||
const char *
|
||||
mm_modem_base_get_unlock_required (MMModemBase *self)
|
||||
{
|
||||
@@ -523,6 +565,9 @@ mm_modem_base_init (MMModemBase *self)
|
||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||
MM_MODEM_ENABLED,
|
||||
MM_MODEM_DBUS_INTERFACE);
|
||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||
MM_MODEM_EQUIPMENT_IDENTITY,
|
||||
MM_MODEM_DBUS_INTERFACE);
|
||||
mm_properties_changed_signal_register_property (G_OBJECT (self),
|
||||
MM_MODEM_UNLOCK_REQUIRED,
|
||||
MM_MODEM_DBUS_INTERFACE);
|
||||
@@ -577,6 +622,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_EQUIPMENT_IDENTITY:
|
||||
case MM_MODEM_PROP_UNLOCK_REQUIRED:
|
||||
case MM_MODEM_PROP_UNLOCK_RETRIES:
|
||||
break;
|
||||
@@ -620,6 +666,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_EQUIPMENT_IDENTITY:
|
||||
g_value_set_string (value, priv->equipment_identity);
|
||||
break;
|
||||
case MM_MODEM_PROP_UNLOCK_REQUIRED:
|
||||
g_value_set_string (value, priv->unlock_required);
|
||||
break;
|
||||
@@ -644,6 +693,7 @@ finalize (GObject *object)
|
||||
g_free (priv->driver);
|
||||
g_free (priv->plugin);
|
||||
g_free (priv->device);
|
||||
g_free (priv->equipment_identity);
|
||||
g_free (priv->unlock_required);
|
||||
|
||||
G_OBJECT_CLASS (mm_modem_base_parent_class)->finalize (object);
|
||||
@@ -697,6 +747,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_EQUIPMENT_IDENTITY,
|
||||
MM_MODEM_EQUIPMENT_IDENTITY);
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
MM_MODEM_PROP_UNLOCK_REQUIRED,
|
||||
MM_MODEM_UNLOCK_REQUIRED);
|
||||
|
||||
@@ -62,6 +62,11 @@ void mm_modem_base_set_valid (MMModemBase *self,
|
||||
|
||||
gboolean mm_modem_base_get_valid (MMModemBase *self);
|
||||
|
||||
const char *mm_modem_base_get_equipment_identity (MMModemBase *self);
|
||||
|
||||
void mm_modem_base_set_equipment_identity (MMModemBase *self,
|
||||
const char *equipment_identity);
|
||||
|
||||
const char *mm_modem_base_get_unlock_required (MMModemBase *self);
|
||||
|
||||
void mm_modem_base_set_unlock_required (MMModemBase *self,
|
||||
|
||||
@@ -803,6 +803,14 @@ mm_modem_init (gpointer g_iface)
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_string (MM_MODEM_EQUIPMENT_IDENTITY,
|
||||
"EquipmentIdentiy",
|
||||
"The equipment identity of the device",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property
|
||||
(g_iface,
|
||||
g_param_spec_string (MM_MODEM_UNLOCK_REQUIRED,
|
||||
|
||||
+3
-1
@@ -58,8 +58,9 @@ typedef enum {
|
||||
#define MM_MODEM_TYPE "type"
|
||||
#define MM_MODEM_IP_METHOD "ip-method"
|
||||
#define MM_MODEM_ENABLED "enabled"
|
||||
#define MM_MODEM_EQUIPMENT_IDENTITY "equipment-identity"
|
||||
#define MM_MODEM_UNLOCK_REQUIRED "unlock-required"
|
||||
#define MM_MODEM_UNLOCK_RETRIES "unlock-retries"
|
||||
#define MM_MODEM_UNLOCK_RETRIES "unlock-retries"
|
||||
#define MM_MODEM_VALID "valid" /* not exported */
|
||||
#define MM_MODEM_PLUGIN "plugin" /* not exported */
|
||||
#define MM_MODEM_STATE "state" /* not exported */
|
||||
@@ -84,6 +85,7 @@ typedef enum {
|
||||
MM_MODEM_PROP_PLUGIN, /* Not exported */
|
||||
MM_MODEM_PROP_STATE, /* Not exported */
|
||||
MM_MODEM_PROP_ENABLED,
|
||||
MM_MODEM_PROP_EQUIPMENT_IDENTITY,
|
||||
MM_MODEM_PROP_UNLOCK_REQUIRED,
|
||||
MM_MODEM_PROP_UNLOCK_RETRIES
|
||||
} MMModemProp;
|
||||
|
||||
Reference in New Issue
Block a user