diff options
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 |