aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem-qmi.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index c8451032..63d210b6 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -407,6 +407,108 @@ modem_load_revision (MMIfaceModem *self,
}
/*****************************************************************************/
+/* Equipment Identifier loading (Modem interface) */
+
+static gchar *
+modem_load_equipment_identifier_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ gchar *equipment_identifier;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
+ return NULL;
+
+ equipment_identifier = g_strdup (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+ mm_dbg ("loaded equipment identifier: %s", equipment_identifier);
+ return equipment_identifier;
+}
+
+static void
+dms_get_ids_ready (QmiClientDms *client,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ QmiMessageDmsGetIdsOutput *output = NULL;
+ GError *error = NULL;
+
+ output = qmi_client_dms_get_ids_finish (client, res, &error);
+ if (!output) {
+ g_prefix_error (&error, "QMI operation failed: ");
+ g_simple_async_result_take_error (simple, error);
+ } else if (!qmi_message_dms_get_ids_output_get_result (output, &error)) {
+ g_prefix_error (&error, "Couldn't get IDs: ");
+ g_simple_async_result_take_error (simple, error);
+ } else {
+ const gchar *str = NULL;
+
+ /* In order:
+ * If we have a IMEI, use it...
+ * Otherwise, if we have a ESN, use it...
+ * Otherwise, if we have a MEID, use it...
+ * Otherwise, 'unknown'
+ */
+
+ if (qmi_message_dms_get_ids_output_get_imei (output, &str, NULL)) {
+ if (str && (str[0] == '\0' || str[0] == '0'))
+ str = NULL;
+ }
+
+ if (!str &&
+ qmi_message_dms_get_ids_output_get_esn (output, &str, NULL)) {
+ if (str && (str[0] == '\0' || str[0] == '0'))
+ str = NULL;
+ }
+
+ if (!str &&
+ qmi_message_dms_get_ids_output_get_meid (output, &str, NULL)) {
+ if (str && (str[0] == '\0' || str[0] == '0'))
+ str = NULL;
+ }
+
+ if (!str)
+ str = "unknown";
+
+ g_simple_async_result_set_op_res_gpointer (simple,
+ g_strdup (str),
+ (GDestroyNotify)g_free);
+ }
+
+ if (output)
+ qmi_message_dms_get_ids_output_unref (output);
+
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+static void
+modem_load_equipment_identifier (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+ QmiClient *client = NULL;
+
+ if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
+ QMI_SERVICE_DMS, &client,
+ callback, user_data))
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ modem_load_equipment_identifier);
+
+ mm_dbg ("loading equipment identifier...");
+ qmi_client_dms_get_ids (QMI_CLIENT_DMS (client),
+ NULL,
+ 5,
+ NULL,
+ (GAsyncReadyCallback)dms_get_ids_ready,
+ result);
+}
+
+/*****************************************************************************/
/* First initialization step */
typedef struct {
@@ -609,6 +711,8 @@ iface_modem_init (MMIfaceModem *iface)
iface->load_model_finish = modem_load_model_finish;
iface->load_revision = modem_load_revision;
iface->load_revision_finish = modem_load_revision_finish;
+ iface->load_equipment_identifier = modem_load_equipment_identifier;
+ iface->load_equipment_identifier_finish = modem_load_equipment_identifier_finish;
}
static void