aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-04-23 14:48:17 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-03 16:08:48 +0200
commitf150ec1449a1eaa69d8933e65309821ae074b88e (patch)
treeb9c40098e7c12ff5bf4278cbc141ff0a771eceef /src
parentf15f0c09e89a1d94dee1d5962a742513eab0523a (diff)
downloadexternal_libqmi-f150ec1449a1eaa69d8933e65309821ae074b88e.zip
external_libqmi-f150ec1449a1eaa69d8933e65309821ae074b88e.tar.gz
external_libqmi-f150ec1449a1eaa69d8933e65309821ae074b88e.tar.bz2
message-dms: only fail get_ids_finish() if none of the expected outputs was retrieved
Not every device will report all three ESN, IMEI and MEID.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/qmi-message-dms.c55
2 files changed, 38 insertions, 18 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9ea4f7a..df92fd1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,6 +42,7 @@ qmi-client.c: qmi-error-types.h qmi-enum-types.h
qmi-client-ctl.c: qmi-error-types.h qmi-enum-types.h
qmi-message.c: qmi-error-types.h
qmi-message-ctl.c: qmi-error-types.h
+qmi-message-dms.c: qmi-error-types.h
libqmi_glib_la_SOURCES = \
libqmi-glib.h \
diff --git a/src/qmi-message-dms.c b/src/qmi-message-dms.c
index 95d26d2..36f5eea 100644
--- a/src/qmi-message-dms.c
+++ b/src/qmi-message-dms.c
@@ -23,6 +23,7 @@
#include "qmi-message-dms.h"
#include "qmi-enums.h"
+#include "qmi-error-types.h"
/*****************************************************************************/
/* Get IDs */
@@ -50,30 +51,48 @@ qmi_message_dms_get_ids_reply_parse (QmiMessage *self,
gchar **meid,
GError **error)
{
- gchar *str;
+ gchar *got_esn;
+ gchar *got_imei;
+ gchar *got_meid;
g_assert (qmi_message_get_message_id (self) == QMI_DMS_MESSAGE_GET_IDS);
- g_assert (esn != NULL);
- g_assert (imei != NULL);
- g_assert (meid != NULL);
- *esn = qmi_message_tlv_get_string (self,
- QMI_DMS_TLV_GET_IDS_ESN,
- error);
- if (!*esn)
- return FALSE;
+ got_esn = qmi_message_tlv_get_string (self,
+ QMI_DMS_TLV_GET_IDS_ESN,
+ NULL);
+ got_imei = qmi_message_tlv_get_string (self,
+ QMI_DMS_TLV_GET_IDS_IMEI,
+ NULL);
+ got_meid = qmi_message_tlv_get_string (self,
+ QMI_DMS_TLV_GET_IDS_MEID,
+ NULL);
- *imei = qmi_message_tlv_get_string (self,
- QMI_DMS_TLV_GET_IDS_IMEI,
- error);
- if (!*imei)
+ /* Only return error if none of the outputs was read */
+ if (!got_esn && !got_imei && !got_meid) {
+ g_set_error (error,
+ QMI_CORE_ERROR,
+ QMI_CORE_ERROR_TLV_NOT_FOUND,
+ "None of the expected outputs (ESN, IMEI, MEID) "
+ "was found in the message");
return FALSE;
+ }
- *meid = qmi_message_tlv_get_string (self,
- QMI_DMS_TLV_GET_IDS_MEID,
- error);
- if (!*meid)
- return FALSE;
+ /* Set requested outputs */
+
+ if (esn)
+ *esn = got_esn;
+ else
+ g_free (got_esn);
+
+ if (imei)
+ *imei = got_imei;
+ else
+ g_free (got_imei);
+
+ if (meid)
+ *meid = got_meid;
+ else
+ g_free (got_meid);
return TRUE;
}