From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/4] Enable alphabets in smsutils
Date: Thu, 02 Sep 2010 11:55:04 -0500 [thread overview]
Message-ID: <4C7FD6E8.206@gmail.com> (raw)
In-Reply-To: <1283413960-31490-2-git-send-email-aki.niemi@nokia.com>
[-- Attachment #1: Type: text/plain, Size: 6739 bytes --]
Hi Aki,
On 09/02/2010 02:52 AM, Aki Niemi wrote:
> Add a new function allowing preparing a message list using alphabets.
> ---
> src/smsutil.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
> src/smsutil.h | 14 +++++++
> 2 files changed, 113 insertions(+), 9 deletions(-)
>
> diff --git a/src/smsutil.c b/src/smsutil.c
> index 0de420b..7da7022 100644
> --- a/src/smsutil.c
> +++ b/src/smsutil.c
> @@ -2987,9 +2987,10 @@ 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,
> - gboolean use_delivery_reports)
> +GSList *sms_text_prepare_with_alphabet(const char *utf8, guint16 ref,
> + gboolean use_16bit, int *ref_offset,
> + gboolean use_delivery_reports,
> + enum sms_alphabet alphabet)
> {
> struct sms template;
> int offset = 0;
> @@ -3008,9 +3009,93 @@ 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 */
> + template.submit.udhi = FALSE;
> +
> + /* UDHI, UDL, UD and DCS actually depend on what we have in
> + * the text. For the different GSM dialects, we use only
> + * matching locking and single shift tables. For example,
> + * turkish locking shift with spanish single shift is not
> + * supported. */
> + switch (alphabet) {
> +
An empty line is not really needed here
> + case SMS_ALPHABET_REDUCED:
> + gsm_encoded = convert_utf8_to_gsm_with_translit(utf8, -1, NULL,
> + &written, 0);
> + break;
> +
> + case SMS_ALPHABET_TURKISH:
> + gsm_encoded = convert_utf8_to_gsm_with_lang(utf8, -1, NULL,
> + &written, 0,
> + GSM_DIALECT_TURKISH,
> + GSM_DIALECT_TURKISH);
> +
> + if (!gsm_encoded)
> + break;
> +
> + if (offset == 0)
> + offset = 1;
> +
> + template.submit.udhi = TRUE;
> + template.submit.ud[0] += 6;
> + template.submit.ud[offset] = SMS_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT;
> + template.submit.ud[offset + 1] = 1;
> + template.submit.ud[offset + 2] = GSM_DIALECT_TURKISH;
> + template.submit.ud[offset + 3] = SMS_IEI_NATIONAL_LANGUAGE_LOCKING_SHIFT;
> + template.submit.ud[offset + 4] = 1;
> + template.submit.ud[offset + 5] = GSM_DIALECT_TURKISH;
> +
> + offset += 6;
> + break;
> +
> + case SMS_ALPHABET_SPANISH:
> + gsm_encoded = convert_utf8_to_gsm_with_lang(utf8, -1, NULL,
> + &written, 0,
> + GSM_DIALECT_DEFAULT,
> + GSM_DIALECT_SPANISH);
> +
> + if (!gsm_encoded)
> + break;
> +
> + if (offset == 0)
> + offset = 1;
> +
> + template.submit.udhi = TRUE;
> + template.submit.ud[0] += 3;
> + template.submit.ud[offset] = SMS_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT;
> + template.submit.ud[offset + 1] = 1;
> + template.submit.ud[offset + 2] = GSM_DIALECT_SPANISH;
> +
> + offset += 3;
> + break;
>
> - /* 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);
> + case SMS_ALPHABET_PORTUGUESE:
> + gsm_encoded = convert_utf8_to_gsm_with_lang(utf8, -1, NULL,
> + &written, 0,
> + GSM_DIALECT_PORTUGUESE,
> + GSM_DIALECT_PORTUGUESE);
> +
> + if (!gsm_encoded)
> + break;
> +
> + if (offset == 0)
> + offset = 1;
> +
> + template.submit.udhi = TRUE;
> + template.submit.ud[0] += 6;
> + template.submit.ud[offset] = SMS_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT;
> + template.submit.ud[offset + 1] = 1;
> + template.submit.ud[offset + 2] = GSM_DIALECT_PORTUGUESE;
> + template.submit.ud[offset + 3] = SMS_IEI_NATIONAL_LANGUAGE_LOCKING_SHIFT;
> + template.submit.ud[offset + 4] = 1;
> + template.submit.ud[offset + 5] = GSM_DIALECT_PORTUGUESE;
> +
> + offset += 6;
> + break;
> +
> + case SMS_ALPHABET_DEFAULT:
> + default:
Marcel likes it when the compiler warns of missing enum handlers. So
the default statement should be removed.
> + gsm_encoded = convert_utf8_to_gsm(utf8, -1, NULL, &written, 0);
> + }
>
> if (!gsm_encoded) {
> gsize converted;
> @@ -3028,9 +3113,6 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
> else
> template.submit.dcs = 0x08; /* Class Unspecified, UCS2 */
>
> - if (offset != 0)
> - template.submit.udhi = FALSE;
> -
This part doesn't look right. The check should actually set udhi to
TRUE, since we can be issuing a return in the next if statement...
> if (gsm_encoded && (written <= sms_text_capacity_gsm(160, offset))) {
> if (ref_offset)
> *ref_offset = 0;
> @@ -3056,7 +3138,7 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
>
> template.submit.udhi = TRUE;
>
> - if (!offset)
> + if (offset == 0)
> offset = 1;
>
> if (ref_offset)
> @@ -3150,6 +3232,14 @@ GSList *sms_text_prepare(const char *utf8, guint16 ref,
> return r;
> }
>
> +GSList *sms_text_prepare(const char *utf8, guint16 ref,
> + gboolean use_16bit, int *ref_offset,
> + gboolean use_delivery_reports)
> +{
> + return sms_text_prepare_with_alphabet(utf8, ref, use_16bit, ref_offset,
> + use_delivery_reports, SMS_ALPHABET_DEFAULT);
> +}
> +
> gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls,
> enum sms_charset *charset, gboolean *compressed,
> enum cbs_language *language, gboolean *iso639)
> diff --git a/src/smsutil.h b/src/smsutil.h
> index 3c6b3ae..e58332c 100644
> --- a/src/smsutil.h
> +++ b/src/smsutil.h
> @@ -153,6 +153,15 @@ enum sms_charset {
> SMS_CHARSET_UCS2 = 2,
> };
>
> +enum sms_alphabet {
> + SMS_ALPHABET_DEFAULT = 0,
> + SMS_ALPHABET_TURKISH,
> + SMS_ALPHABET_SPANISH,
> + SMS_ALPHABET_PORTUGUESE,
> + SMS_ALPHABET_REDUCED,
> + SMS_ALHPABET_INVALID,
Why is the INVALID part needed at all?
> +};
> +
> enum sms_mwi_type {
> SMS_MWI_TYPE_VOICE = 0,
> SMS_MWI_TYPE_FAX = 1,
> @@ -516,6 +525,11 @@ void status_report_assembly_expire(struct status_report_assembly *assembly,
> time_t before, GFunc foreach_func,
> gpointer data);
>
> +GSList *sms_text_prepare_with_alphabet(const char *utf8, guint16 ref,
> + gboolean use_16bit, int *ref_offset,
> + gboolean use_delivery_reports,
> + enum sms_alphabet alphabet);
> +
> GSList *sms_text_prepare(const char *utf8, guint16 ref,
> gboolean use_16bit, int *ref_offset,
> gboolean use_delivery_reports);
Do you have time to write unit tests for this as well?
Regards,
-Denis
next prev parent reply other threads:[~2010-09-02 16:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 7:52 [PATCH 1/4] Add so called reduced charset support to SMS Aki Niemi
2010-09-02 7:52 ` [PATCH 2/4] Enable alphabets in smsutils Aki Niemi
2010-09-02 16:55 ` Denis Kenzior [this message]
2010-09-03 12:15 ` Aki Niemi
2010-09-03 14:05 ` Denis Kenzior
2010-09-03 14:12 ` Aki Niemi
2010-09-03 14:40 ` Pekka Pessi
2010-09-03 15:08 ` Denis Kenzior
2010-09-03 17:09 ` Aki Niemi
2010-09-02 7:52 ` [PATCH 3/4] Add alphabet support to SMS atom Aki Niemi
2010-09-02 17:00 ` Denis Kenzior
2010-09-02 7:52 ` [PATCH 4/4] Add documentation for the Alphabet property Aki Niemi
2010-09-02 17:01 ` Denis Kenzior
2010-09-02 18:19 ` Marcel Holtmann
2010-09-02 19:08 ` Aki Niemi
2010-09-02 16:43 ` [PATCH 1/4] Add so called reduced charset support to SMS Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C7FD6E8.206@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.