sms: add support for message class
We need to redefine the message class property to int since class 0 is a valid message class. Thus -1 now means "unspecified class".
This commit is contained in:
@@ -122,11 +122,12 @@
|
||||
<!--
|
||||
Class:
|
||||
|
||||
3GPP message class (0..3).
|
||||
3GPP message class (-1..3). -1 means class is not available or
|
||||
is not used for this message, otherwise the 3GPP SMS message class.
|
||||
|
||||
Always 0 for 3GPP2/CDMA.
|
||||
Always -1 for 3GPP2/CDMA.
|
||||
-->
|
||||
<property name="Class" type="u" access="read" />
|
||||
<property name="Class" type="i" access="read" />
|
||||
|
||||
<!--
|
||||
DeliveryReportRequest:
|
||||
|
@@ -51,8 +51,7 @@ struct _MMSmsPropertiesPrivate {
|
||||
gchar *smsc;
|
||||
MMSmsValidityType validity_type;
|
||||
guint validity_relative;
|
||||
gboolean class_set;
|
||||
guint class;
|
||||
gint class;
|
||||
gboolean delivery_report_request_set;
|
||||
gboolean delivery_report_request;
|
||||
};
|
||||
@@ -319,17 +318,16 @@ mm_sms_properties_get_validity_relative (MMSmsProperties *self)
|
||||
/**
|
||||
* mm_sms_properties_set_class:
|
||||
* @self: A #MMSmsProperties.
|
||||
* @class: The message class.
|
||||
* @class: The message class, or -1 for invalid/unset class.
|
||||
*
|
||||
* Sets the 3GPP message class of the SMS.
|
||||
*/
|
||||
void
|
||||
mm_sms_properties_set_class (MMSmsProperties *self,
|
||||
guint class)
|
||||
gint class)
|
||||
{
|
||||
g_return_if_fail (MM_IS_SMS_PROPERTIES (self));
|
||||
|
||||
self->priv->class_set = TRUE;
|
||||
self->priv->class = class;
|
||||
}
|
||||
|
||||
@@ -339,12 +337,12 @@ mm_sms_properties_set_class (MMSmsProperties *self,
|
||||
*
|
||||
* Gets the 3GPP message class of the SMS.
|
||||
*
|
||||
* Returns: the message class.
|
||||
* Returns: the message class, or -1 for invalid/unset class.
|
||||
*/
|
||||
guint
|
||||
gint
|
||||
mm_sms_properties_get_class (MMSmsProperties *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), 0);
|
||||
g_return_val_if_fail (MM_IS_SMS_PROPERTIES (self), -1);
|
||||
|
||||
return self->priv->class;
|
||||
}
|
||||
@@ -435,11 +433,11 @@ mm_sms_properties_get_dictionary (MMSmsProperties *self)
|
||||
PROPERTY_VALIDITY,
|
||||
g_variant_new ("(uv)", MM_SMS_VALIDITY_TYPE_RELATIVE, g_variant_new_uint32 (self->priv->validity_relative)));
|
||||
|
||||
if (self->priv->class_set)
|
||||
if (self->priv->class >= 0)
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
PROPERTY_CLASS,
|
||||
g_variant_new_uint32 (self->priv->class));
|
||||
g_variant_new_int32 (self->priv->class));
|
||||
|
||||
if (self->priv->delivery_report_request_set)
|
||||
g_variant_builder_add (&builder,
|
||||
@@ -517,12 +515,14 @@ consume_string (MMSmsProperties *self,
|
||||
|
||||
mm_sms_properties_set_validity_relative (self, n);
|
||||
} else if (g_str_equal (key, PROPERTY_CLASS)) {
|
||||
GError *inner_error = NULL;
|
||||
guint n;
|
||||
gint n = 0;
|
||||
|
||||
n = parse_uint (value, &inner_error);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
if (!mm_get_int_from_str (value, &n)) {
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_INVALID_ARGS,
|
||||
"Invalid properties string, cannot parse '%s' as int",
|
||||
value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -642,7 +642,7 @@ consume_variant (MMSmsProperties *properties,
|
||||
} else if (g_str_equal (key, PROPERTY_CLASS))
|
||||
mm_sms_properties_set_class (
|
||||
properties,
|
||||
g_variant_get_uint32 (value));
|
||||
g_variant_get_int32 (value));
|
||||
else if (g_str_equal (key, PROPERTY_DELIVERY_REPORT_REQUEST))
|
||||
mm_sms_properties_set_delivery_report_request (
|
||||
properties,
|
||||
@@ -746,6 +746,7 @@ mm_sms_properties_init (MMSmsProperties *self)
|
||||
MM_TYPE_SMS_PROPERTIES,
|
||||
MMSmsPropertiesPrivate);
|
||||
self->priv->validity_type = MM_SMS_VALIDITY_TYPE_UNKNOWN;
|
||||
self->priv->class = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -71,7 +71,7 @@ void mm_sms_properties_set_smsc (MMSmsProperties *self,
|
||||
void mm_sms_properties_set_validity_relative (MMSmsProperties *self,
|
||||
guint validity);
|
||||
void mm_sms_properties_set_class (MMSmsProperties *self,
|
||||
guint class);
|
||||
gint class);
|
||||
void mm_sms_properties_set_delivery_report_request (MMSmsProperties *self,
|
||||
gboolean request);
|
||||
|
||||
@@ -84,7 +84,7 @@ const gchar *mm_sms_properties_get_number (MMSmsProperties *se
|
||||
const gchar *mm_sms_properties_get_smsc (MMSmsProperties *self);
|
||||
MMSmsValidityType mm_sms_properties_get_validity_type (MMSmsProperties *self);
|
||||
guint mm_sms_properties_get_validity_relative (MMSmsProperties *self);
|
||||
guint mm_sms_properties_get_class (MMSmsProperties *self);
|
||||
gint mm_sms_properties_get_class (MMSmsProperties *self);
|
||||
gboolean mm_sms_properties_get_delivery_report_request (MMSmsProperties *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@@ -445,12 +445,12 @@ mm_sms_get_validity_relative (MMSms *self)
|
||||
*
|
||||
* Gets the 3GPP message class of the SMS.
|
||||
*
|
||||
* Returns: the message class.
|
||||
* Returns: the message class, or -1 for invalid/unset class.
|
||||
*/
|
||||
guint
|
||||
gint
|
||||
mm_sms_get_class (MMSms *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_SMS (self), 0);
|
||||
g_return_val_if_fail (MM_IS_SMS (self), -1);
|
||||
|
||||
return mm_gdbus_sms_get_class (MM_GDBUS_SMS (self));
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ gchar *mm_sms_dup_discharge_timestamp (MMSms *self);
|
||||
MMSmsValidityType mm_sms_get_validity_type (MMSms *self);
|
||||
guint mm_sms_get_validity_relative (MMSms *self);
|
||||
|
||||
guint mm_sms_get_class (MMSms *self);
|
||||
gint mm_sms_get_class (MMSms *self);
|
||||
|
||||
guint mm_sms_get_message_reference (MMSms *self);
|
||||
|
||||
|
@@ -5828,7 +5828,7 @@ sms_text_part_list_ready (MMBroadbandModem *self,
|
||||
mm_sms_part_take_timestamp (part, timestamp);
|
||||
mm_sms_part_take_text (part, text);
|
||||
mm_sms_part_take_data (part, raw);
|
||||
mm_sms_part_set_class (part, 0);
|
||||
mm_sms_part_set_class (part, -1);
|
||||
|
||||
mm_dbg ("Correctly parsed SMS list entry (%d)", idx);
|
||||
mm_iface_modem_messaging_take_part (MM_IFACE_MODEM_MESSAGING (self),
|
||||
|
@@ -325,7 +325,7 @@ struct _MMSmsPart {
|
||||
gchar *text;
|
||||
MMSmsEncoding encoding;
|
||||
GByteArray *data;
|
||||
guint class;
|
||||
gint class;
|
||||
guint validity_relative;
|
||||
gboolean delivery_report_request;
|
||||
guint message_reference;
|
||||
@@ -403,8 +403,8 @@ PART_GET_FUNC (const gchar *, text)
|
||||
PART_SET_TAKE_STR_FUNC (text)
|
||||
PART_GET_FUNC (MMSmsEncoding, encoding)
|
||||
PART_SET_FUNC (MMSmsEncoding, encoding)
|
||||
PART_GET_FUNC (guint, class)
|
||||
PART_SET_FUNC (guint, class)
|
||||
PART_GET_FUNC (gint, class)
|
||||
PART_SET_FUNC (gint, class)
|
||||
PART_GET_FUNC (guint, validity_relative)
|
||||
PART_SET_FUNC (guint, validity_relative)
|
||||
PART_GET_FUNC (gboolean, delivery_report_request)
|
||||
@@ -461,6 +461,7 @@ mm_sms_part_new (guint index,
|
||||
sms_part->pdu_type = pdu_type;
|
||||
sms_part->encoding = MM_SMS_ENCODING_UNKNOWN;
|
||||
sms_part->delivery_state = MM_SMS_DELIVERY_STATE_UNKNOWN;
|
||||
sms_part->class = -1;
|
||||
|
||||
return sms_part;
|
||||
}
|
||||
@@ -917,12 +918,7 @@ mm_sms_part_encode_address (const gchar *address,
|
||||
/**
|
||||
* mm_sms_part_get_submit_pdu:
|
||||
*
|
||||
* @number: the subscriber number to send this message to
|
||||
* @text: the body of this SMS
|
||||
* @smsc: if given, the SMSC address
|
||||
* @validity: minutes until the SMS should expire in the SMSC, or 0 for a
|
||||
* suitable default
|
||||
* @class: unused
|
||||
* @part: the SMS message part
|
||||
* @out_pdulen: on success, the size of the returned PDU in bytes
|
||||
* @out_msgstart: on success, the byte index in the returned PDU where the
|
||||
* message starts (ie, skipping the SMSC length byte and address, if present)
|
||||
@@ -1023,6 +1019,12 @@ mm_sms_part_get_submit_pdu (MMSmsPart *part,
|
||||
/* ----------- TP-DCS (1 byte) ----------- */
|
||||
pdu[offset] = 0x00;
|
||||
|
||||
if (part->class >= 0 && part->class <= 3) {
|
||||
mm_dbg (" using class %d...", part->class);
|
||||
pdu[offset] |= SMS_DCS_CLASS_VALID;
|
||||
pdu[offset] |= part->class;
|
||||
}
|
||||
|
||||
if (part->encoding == MM_SMS_ENCODING_UCS2) {
|
||||
mm_dbg (" using UCS2 encoding...");
|
||||
pdu[offset] |= SMS_DCS_CODING_UCS2;
|
||||
|
@@ -96,9 +96,9 @@ MMSmsEncoding mm_sms_part_get_encoding (MMSmsPart *part);
|
||||
void mm_sms_part_set_encoding (MMSmsPart *part,
|
||||
MMSmsEncoding encoding);
|
||||
|
||||
guint mm_sms_part_get_class (MMSmsPart *part);
|
||||
gint mm_sms_part_get_class (MMSmsPart *part);
|
||||
void mm_sms_part_set_class (MMSmsPart *part,
|
||||
guint class);
|
||||
gint class);
|
||||
|
||||
guint mm_sms_part_get_validity_relative (MMSmsPart *part);
|
||||
void mm_sms_part_set_validity_relative (MMSmsPart *part,
|
||||
|
@@ -512,7 +512,7 @@ common_test_create_pdu (const gchar *smsc,
|
||||
const gchar *number,
|
||||
const gchar *text,
|
||||
guint validity,
|
||||
guint class,
|
||||
gint class,
|
||||
const guint8 *expected,
|
||||
gsize expected_size,
|
||||
guint expected_msgstart)
|
||||
@@ -537,7 +537,7 @@ common_test_create_pdu (const gchar *smsc,
|
||||
}
|
||||
if (validity > 0)
|
||||
mm_sms_part_set_validity_relative (part, validity);
|
||||
if (class > 0)
|
||||
if (class >= 0)
|
||||
mm_sms_part_set_class (part, class);
|
||||
|
||||
pdu = mm_sms_part_get_submit_pdu (part,
|
||||
@@ -576,7 +576,7 @@ test_create_pdu_ucs2_with_smsc (void)
|
||||
number,
|
||||
text,
|
||||
5, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
8); /* expected_msgstart */
|
||||
@@ -601,7 +601,7 @@ test_create_pdu_ucs2_no_smsc (void)
|
||||
number,
|
||||
text,
|
||||
5, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
1); /* expected_msgstart */
|
||||
@@ -626,7 +626,7 @@ test_create_pdu_gsm_with_smsc (void)
|
||||
number,
|
||||
text,
|
||||
5, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
8); /* expected_msgstart */
|
||||
@@ -650,7 +650,7 @@ test_create_pdu_gsm_no_smsc (void)
|
||||
number,
|
||||
text,
|
||||
5, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
1); /* expected_msgstart */
|
||||
@@ -678,7 +678,7 @@ test_create_pdu_gsm_3 (void)
|
||||
number,
|
||||
text,
|
||||
5, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
1); /* expected_msgstart */
|
||||
@@ -699,7 +699,7 @@ test_create_pdu_gsm_no_validity (void)
|
||||
number,
|
||||
text,
|
||||
0, /* validity */
|
||||
0, /* class */
|
||||
-1, /* class */
|
||||
expected,
|
||||
sizeof (expected),
|
||||
1); /* expected_msgstart */
|
||||
|
Reference in New Issue
Block a user