diff options
author | Yang Gu <yang.gu@intel.com> | 2010-11-30 18:44:49 +0800 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-12-08 07:53:30 -0600 |
commit | f6b037661b297ccafddae03af61c9b5c3ea79bd9 (patch) | |
tree | ea1cda27ca15df637a56a4fa6d088ce9f38e87b3 /src/smsutil.c | |
parent | 7784c5ed62a2b98051d69c3ac05b62d4f529141b (diff) | |
download | ofono-f6b037661b297ccafddae03af61c9b5c3ea79bd9.tar.bz2 |
smsutil: Make timezone an optional field
Diffstat (limited to 'src/smsutil.c')
-rw-r--r-- | src/smsutil.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/smsutil.c b/src/smsutil.c index 3153a37b..5e1d233b 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -351,7 +351,8 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, if (in->second > 59) return FALSE; - if ((in->timezone > MAX_TIMEZONE) || (in->timezone < MIN_TIMEZONE)) + if ((in->timezone > MAX_TIMEZONE || in->timezone < MIN_TIMEZONE) && + in->has_timezone == TRUE) return FALSE; pdu = pdu + *offset; @@ -363,6 +364,11 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, pdu[4] = ((in->minute / 10) & 0x0f) | (((in->minute % 10) & 0x0f) << 4); pdu[5] = ((in->second / 10) & 0x0f) | (((in->second % 10) & 0x0f) << 4); + if (in->has_timezone == FALSE) { + pdu[6] = 0xff; + goto out; + } + timezone = abs(in->timezone); pdu[6] = ((timezone / 10) & 0x07) | (((timezone % 10) & 0x0f) << 4); @@ -370,6 +376,7 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, if (in->timezone < 0) pdu[6] |= 0x8; +out: *offset += 7; return TRUE; @@ -441,6 +448,8 @@ gboolean sms_decode_scts(const unsigned char *pdu, int len, if ((out->timezone > MAX_TIMEZONE) || (out->timezone < MIN_TIMEZONE)) return FALSE; + out->has_timezone = TRUE; + return TRUE; } |