sms-qmi: handle CDMA SMS messages
This commit is contained in:
@@ -31,6 +31,14 @@ typedef struct _MMSmsPart MMSmsPart;
|
|||||||
|
|
||||||
#define SMS_PART_INVALID_INDEX G_MAXUINT
|
#define SMS_PART_INVALID_INDEX G_MAXUINT
|
||||||
|
|
||||||
|
#define MM_SMS_PART_IS_3GPP(part) \
|
||||||
|
(mm_sms_part_get_pdu_type (part) >= MM_SMS_PDU_TYPE_DELIVER && \
|
||||||
|
mm_sms_part_get_pdu_type (part) <= MM_SMS_PDU_TYPE_STATUS_REPORT)
|
||||||
|
|
||||||
|
#define MM_SMS_PART_IS_CDMA(part) \
|
||||||
|
(mm_sms_part_get_pdu_type (part) >= MM_SMS_PDU_TYPE_CDMA_DELIVER && \
|
||||||
|
mm_sms_part_get_pdu_type (part) <= MM_SMS_PDU_TYPE_CDMA_READ_ACKNOWLEDGEMENT)
|
||||||
|
|
||||||
MMSmsPart *mm_sms_part_new (guint index,
|
MMSmsPart *mm_sms_part_new (guint index,
|
||||||
MMSmsPduType type);
|
MMSmsPduType type);
|
||||||
void mm_sms_part_free (MMSmsPart *part);
|
void mm_sms_part_free (MMSmsPart *part);
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "mm-sms-qmi.h"
|
#include "mm-sms-qmi.h"
|
||||||
#include "mm-base-modem.h"
|
#include "mm-base-modem.h"
|
||||||
#include "mm-sms-part-3gpp.h"
|
#include "mm-sms-part-3gpp.h"
|
||||||
|
#include "mm-sms-part-cdma.h"
|
||||||
#include "mm-log.h"
|
#include "mm-log.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_SMS);
|
G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_SMS);
|
||||||
@@ -160,7 +161,7 @@ static void
|
|||||||
sms_store_next_part (SmsStoreContext *ctx)
|
sms_store_next_part (SmsStoreContext *ctx)
|
||||||
{
|
{
|
||||||
QmiMessageWmsRawWriteInput *input;
|
QmiMessageWmsRawWriteInput *input;
|
||||||
guint8 *pdu;
|
guint8 *pdu = NULL;
|
||||||
guint pdulen = 0;
|
guint pdulen = 0;
|
||||||
guint msgstart = 0;
|
guint msgstart = 0;
|
||||||
GArray *array;
|
GArray *array;
|
||||||
@@ -174,10 +175,22 @@ sms_store_next_part (SmsStoreContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get PDU */
|
/* Get PDU */
|
||||||
pdu = mm_sms_part_3gpp_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &msgstart, &error);
|
if (MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data))
|
||||||
|
pdu = mm_sms_part_3gpp_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &msgstart, &error);
|
||||||
|
else if (MM_SMS_PART_IS_CDMA ((MMSmsPart *)ctx->current->data))
|
||||||
|
pdu = mm_sms_part_cdma_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &error);
|
||||||
|
|
||||||
if (!pdu) {
|
if (!pdu) {
|
||||||
/* 'error' should already be set */
|
if (error)
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
else
|
||||||
|
g_simple_async_result_set_error (ctx->result,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_FAILED,
|
||||||
|
"Unknown or unsupported PDU type in SMS part: %s",
|
||||||
|
mm_sms_pdu_type_get_string (
|
||||||
|
mm_sms_part_get_pdu_type (
|
||||||
|
(MMSmsPart *)ctx->current->data)));
|
||||||
sms_store_context_complete_and_free (ctx);
|
sms_store_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -193,7 +206,9 @@ sms_store_next_part (SmsStoreContext *ctx)
|
|||||||
qmi_message_wms_raw_write_input_set_raw_message_data (
|
qmi_message_wms_raw_write_input_set_raw_message_data (
|
||||||
input,
|
input,
|
||||||
mm_sms_storage_to_qmi_storage_type (ctx->storage),
|
mm_sms_storage_to_qmi_storage_type (ctx->storage),
|
||||||
QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_POINT_TO_POINT,
|
(MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data) ?
|
||||||
|
QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_POINT_TO_POINT :
|
||||||
|
QMI_WMS_MESSAGE_FORMAT_CDMA),
|
||||||
array,
|
array,
|
||||||
NULL);
|
NULL);
|
||||||
qmi_client_wms_raw_write (ctx->client,
|
qmi_client_wms_raw_write (ctx->client,
|
||||||
@@ -326,16 +341,29 @@ static void
|
|||||||
sms_send_generic (SmsSendContext *ctx)
|
sms_send_generic (SmsSendContext *ctx)
|
||||||
{
|
{
|
||||||
QmiMessageWmsRawSendInput *input;
|
QmiMessageWmsRawSendInput *input;
|
||||||
guint8 *pdu;
|
guint8 *pdu = NULL;
|
||||||
guint pdulen = 0;
|
guint pdulen = 0;
|
||||||
guint msgstart = 0;
|
guint msgstart = 0;
|
||||||
GArray *array;
|
GArray *array;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
/* Get PDU */
|
/* Get PDU */
|
||||||
pdu = mm_sms_part_3gpp_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &msgstart, &error);
|
if (MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data))
|
||||||
|
pdu = mm_sms_part_3gpp_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &msgstart, &error);
|
||||||
|
else if (MM_SMS_PART_IS_CDMA ((MMSmsPart *)ctx->current->data))
|
||||||
|
pdu = mm_sms_part_cdma_get_submit_pdu ((MMSmsPart *)ctx->current->data, &pdulen, &error);
|
||||||
|
|
||||||
if (!pdu) {
|
if (!pdu) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
if (error)
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
else
|
||||||
|
g_simple_async_result_set_error (ctx->result,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_FAILED,
|
||||||
|
"Unknown or unsupported PDU type in SMS part: %s",
|
||||||
|
mm_sms_pdu_type_get_string (
|
||||||
|
mm_sms_part_get_pdu_type (
|
||||||
|
(MMSmsPart *)ctx->current->data)));
|
||||||
sms_send_context_complete_and_free (ctx);
|
sms_send_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -347,10 +375,11 @@ sms_send_generic (SmsSendContext *ctx)
|
|||||||
g_free (pdu);
|
g_free (pdu);
|
||||||
|
|
||||||
input = qmi_message_wms_raw_send_input_new ();
|
input = qmi_message_wms_raw_send_input_new ();
|
||||||
|
|
||||||
qmi_message_wms_raw_send_input_set_raw_message_data (
|
qmi_message_wms_raw_send_input_set_raw_message_data (
|
||||||
input,
|
input,
|
||||||
QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_POINT_TO_POINT,
|
(MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data) ?
|
||||||
|
QMI_WMS_MESSAGE_FORMAT_GSM_WCDMA_POINT_TO_POINT :
|
||||||
|
QMI_WMS_MESSAGE_FORMAT_CDMA),
|
||||||
array,
|
array,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
@@ -405,6 +434,8 @@ send_from_storage_ready (QmiClientWms *client,
|
|||||||
} else {
|
} else {
|
||||||
QmiWmsGsmUmtsRpCause rp_cause;
|
QmiWmsGsmUmtsRpCause rp_cause;
|
||||||
QmiWmsGsmUmtsTpCause tp_cause;
|
QmiWmsGsmUmtsTpCause tp_cause;
|
||||||
|
QmiWmsCdmaCauseCode cdma_cause_code;
|
||||||
|
QmiWmsCdmaErrorClass cdma_error_class;
|
||||||
|
|
||||||
if (qmi_message_wms_send_from_memory_storage_output_get_gsm_wcdma_cause_info (
|
if (qmi_message_wms_send_from_memory_storage_output_get_gsm_wcdma_cause_info (
|
||||||
output,
|
output,
|
||||||
@@ -418,6 +449,24 @@ send_from_storage_ready (QmiClientWms *client,
|
|||||||
qmi_wms_gsm_umts_tp_cause_get_string (tp_cause));
|
qmi_wms_gsm_umts_tp_cause_get_string (tp_cause));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qmi_message_wms_send_from_memory_storage_output_get_cdma_cause_code (
|
||||||
|
output,
|
||||||
|
&cdma_cause_code,
|
||||||
|
NULL)) {
|
||||||
|
mm_warn ("Couldn't send SMS; cause code (%u): '%s'",
|
||||||
|
cdma_cause_code,
|
||||||
|
qmi_wms_cdma_cause_code_get_string (cdma_cause_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qmi_message_wms_send_from_memory_storage_output_get_cdma_error_class (
|
||||||
|
output,
|
||||||
|
&cdma_error_class,
|
||||||
|
NULL)) {
|
||||||
|
mm_warn ("Couldn't send SMS; error class (%u): '%s'",
|
||||||
|
cdma_error_class,
|
||||||
|
qmi_wms_cdma_error_class_get_string (cdma_error_class));
|
||||||
|
}
|
||||||
|
|
||||||
g_prefix_error (&error, "Couldn't write SMS part: ");
|
g_prefix_error (&error, "Couldn't write SMS part: ");
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
sms_send_context_complete_and_free (ctx);
|
sms_send_context_complete_and_free (ctx);
|
||||||
@@ -449,7 +498,9 @@ sms_send_from_storage (SmsSendContext *ctx)
|
|||||||
input,
|
input,
|
||||||
mm_sms_storage_to_qmi_storage_type (mm_sms_get_storage (ctx->self)),
|
mm_sms_storage_to_qmi_storage_type (mm_sms_get_storage (ctx->self)),
|
||||||
mm_sms_part_get_index ((MMSmsPart *)ctx->current->data),
|
mm_sms_part_get_index ((MMSmsPart *)ctx->current->data),
|
||||||
QMI_WMS_MESSAGE_MODE_GSM_WCDMA,
|
(MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data) ?
|
||||||
|
QMI_WMS_MESSAGE_MODE_GSM_WCDMA :
|
||||||
|
QMI_WMS_MESSAGE_MODE_CDMA),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
qmi_client_wms_send_from_memory_storage (
|
qmi_client_wms_send_from_memory_storage (
|
||||||
@@ -613,7 +664,9 @@ delete_next_part (SmsDeletePartsContext *ctx)
|
|||||||
NULL);
|
NULL);
|
||||||
qmi_message_wms_delete_input_set_message_mode (
|
qmi_message_wms_delete_input_set_message_mode (
|
||||||
input,
|
input,
|
||||||
QMI_WMS_MESSAGE_MODE_GSM_WCDMA,
|
(MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data) ?
|
||||||
|
QMI_WMS_MESSAGE_MODE_GSM_WCDMA:
|
||||||
|
QMI_WMS_MESSAGE_MODE_CDMA),
|
||||||
NULL);
|
NULL);
|
||||||
qmi_client_wms_delete (ctx->client,
|
qmi_client_wms_delete (ctx->client,
|
||||||
input,
|
input,
|
||||||
|
Reference in New Issue
Block a user