smsutil: Get rid of ref_offset in sms_text_prepare
authorDenis Kenzior <denkenz@gmail.com>
Tue, 2 Nov 2010 18:37:29 +0000 (13:37 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 2 Nov 2010 19:58:21 +0000 (14:58 -0500)
The reason for this parameter has ceased to exist quite a while ago.
Namely when the API allowed multiple SMS recipients.  We prepared a
single set of segments and then reset the to address and reference.  We
no longer allow multiple recipients and none of this is now needed.

src/smsutil.c
src/smsutil.h

index bc4f13c..ff19be3 100644 (file)
@@ -3146,8 +3146,8 @@ static inline GSList *sms_list_append(GSList *l, const struct sms *in)
  * @use_delivery_reports: value for the Status-Report-Request field
  *     (23.040 3.2.9, 9.2.2.2)
  */
-GSList *sms_text_prepare(const char *utf8, guint16 ref,
-                               gboolean use_16bit, int *ref_offset,
+GSList *sms_text_prepare(const char *to, const char *utf8, guint16 ref,
+                               gboolean use_16bit,
                                gboolean use_delivery_reports)
 {
        struct sms template;
@@ -3167,6 +3167,7 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
        template.submit.srr = use_delivery_reports;
        template.submit.mr = 0;
        template.submit.vp.relative = 0xA7; /* 24 Hours */
+       sms_address_from_string(&template.submit.daddr, to);
 
        /* UDHI, UDL, UD and DCS actually depend on what we have in the text */
        gsm_encoded = convert_utf8_to_gsm(utf8, -1, NULL, &written, 0);
@@ -3191,9 +3192,6 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
                template.submit.udhi = FALSE;
 
        if (gsm_encoded && (written <= sms_text_capacity_gsm(160, offset))) {
-               if (ref_offset)
-                       *ref_offset = 0;
-
                template.submit.udl = written + (offset * 8 + 6) / 7;
                pack_7bit_own_buf(gsm_encoded, written, offset, FALSE, NULL,
                                        0, template.submit.ud + offset);
@@ -3203,9 +3201,6 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
        }
 
        if (ucs2_encoded && (written <= (140 - offset))) {
-               if (ref_offset)
-                       *ref_offset = 0;
-
                template.submit.udl = written + offset;
                memcpy(template.submit.ud + offset, ucs2_encoded, written);
 
@@ -3218,9 +3213,6 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
        if (!offset)
                offset = 1;
 
-       if (ref_offset)
-               *ref_offset = offset + 2;
-
        if (use_16bit) {
                template.submit.ud[0] += 6;
                template.submit.ud[offset] = SMS_IEI_CONCATENATED_16BIT;
index 6cf273e..dd6c0ad 100644 (file)
@@ -516,8 +516,8 @@ void status_report_assembly_add_fragment(struct status_report_assembly
 void status_report_assembly_expire(struct status_report_assembly *assembly,
                                        time_t before);
 
-GSList *sms_text_prepare(const char *utf8, guint16 ref,
-                               gboolean use_16bit, int *ref_offset,
+GSList *sms_text_prepare(const char *to, const char *utf8, guint16 ref,
+                               gboolean use_16bit,
                                gboolean use_delivery_reports);
 
 gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls,