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:
@@ -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),
|
||||
|
||||
+11
-9
@@ -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;
|
||||
|
||||
+2
-2
@@ -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