diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-23 18:38:20 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:48 +0200 |
commit | 82b79618934398bb65af4e7afb9056d744e48d1c (patch) | |
tree | b49e53be110d55acb566e2a165cfd44cad2fc74c /src | |
parent | b1c7ec249bf5ca2dbaf2eddb4c30be150ab055d3 (diff) | |
download | external_libqmi-82b79618934398bb65af4e7afb9056d744e48d1c.zip external_libqmi-82b79618934398bb65af4e7afb9056d744e48d1c.tar.gz external_libqmi-82b79618934398bb65af4e7afb9056d744e48d1c.tar.bz2 |
message: new helpers to check whether a given message is a response or an indication
Diffstat (limited to 'src')
-rw-r--r-- | src/qmi-device.c | 2 | ||||
-rw-r--r-- | src/qmi-message.c | 56 | ||||
-rw-r--r-- | src/qmi-message.h | 6 |
3 files changed, 41 insertions, 23 deletions
diff --git a/src/qmi-device.c b/src/qmi-device.c index a847a16..345d2e7 100644 --- a/src/qmi-device.c +++ b/src/qmi-device.c @@ -415,7 +415,7 @@ parse_response (QmiDevice *self) else { /* Received message is a response in a transaction; handle QMI protocol * errors */ - if (!qmi_message_get_result (message, &error)) { + if (!qmi_message_get_response_result (message, &error)) { transaction_complete_and_free (tr, NULL, error); g_error_free (error); } else { diff --git a/src/qmi-message.c b/src/qmi-message.c index ad0c981..7ec9355 100644 --- a/src/qmi-message.c +++ b/src/qmi-message.c @@ -148,6 +148,34 @@ qmi_message_get_qmi_flags (QmiMessage *self) return self->buf->qmi.service.header.flags; } +gboolean +qmi_message_is_response (QmiMessage *self) +{ + if (qmi_message_is_control (self)) { + if (self->buf->qmi.control.header.flags & QMI_CTL_FLAG_RESPONSE) + return TRUE; + } else { + if (self->buf->qmi.service.header.flags & QMI_SERVICE_FLAG_RESPONSE) + return TRUE; + } + + return FALSE; +} + +gboolean +qmi_message_is_indication (QmiMessage *self) +{ + if (qmi_message_is_control (self)) { + if (self->buf->qmi.control.header.flags & QMI_CTL_FLAG_INDICATION) + return TRUE; + } else { + if (self->buf->qmi.service.header.flags & QMI_SERVICE_FLAG_INDICATION) + return TRUE; + } + + return FALSE; +} + guint16 qmi_message_get_transaction_id (QmiMessage *self) { @@ -679,31 +707,19 @@ enum { }; gboolean -qmi_message_get_result (QmiMessage *self, - GError **error) +qmi_message_get_response_result (QmiMessage *self, + GError **error) { struct qmi_result msg_result; g_assert (self != NULL); - if (qmi_message_get_service (self) == QMI_SERVICE_CTL) { - if (!(qmi_message_get_qmi_flags (self) & QMI_CTL_FLAG_RESPONSE)) { - g_set_error (error, - QMI_CORE_ERROR, - QMI_CORE_ERROR_INVALID_MESSAGE, - "Cannot get result code from non-response CTL message"); - return FALSE; - } - /* CTL response, keep on */ - } else { - if (!(qmi_message_get_qmi_flags (self) & QMI_SERVICE_FLAG_RESPONSE)) { - g_set_error (error, - QMI_CORE_ERROR, - QMI_CORE_ERROR_INVALID_MESSAGE, - "Cannot get result code from non-response SVC message"); - return FALSE; - } - /* SVC response, keep on */ + if (!qmi_message_is_response (self)) { + g_set_error (error, + QMI_CORE_ERROR, + QMI_CORE_ERROR_INVALID_MESSAGE, + "Cannot get result code from non-response message"); + return FALSE; } if (!qmi_message_tlv_get (self, diff --git a/src/qmi-message.h b/src/qmi-message.h index 3340f5a..23d368d 100644 --- a/src/qmi-message.h +++ b/src/qmi-message.h @@ -90,8 +90,10 @@ gchar *qmi_message_get_printable (QmiMessage *self); gboolean qmi_message_check (QmiMessage *self, GError **error); -gboolean qmi_message_get_result (QmiMessage *self, - GError **error); +gboolean qmi_message_is_response (QmiMessage *self); +gboolean qmi_message_is_indication (QmiMessage *self); +gboolean qmi_message_get_response_result (QmiMessage *self, + GError **error); G_END_DECLS |