* [PATCH 1/3] smsutil: Change the range of time zone
@ 2010-11-30 10:44 Yang Gu
2010-11-30 10:44 ` [PATCH 2/3] Make timezone an optional field Yang Gu
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Yang Gu @ 2010-11-30 10:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]
---
src/smsutil.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/smsutil.c b/src/smsutil.c
index b06e9bf..644e3e0 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -51,6 +51,13 @@
#define SMS_ADDR_FMT "%24[0-9A-F]"
#define SMS_MSGID_FMT "%40[0-9A-F]"
+/*
+ * Time zone accounts for daylight saving time, and the two extreme time
+ * zones on earth are UTC-12 and UTC+14.
+ */
+#define MAX_TIMEZONE 56
+#define MIN_TIMEZONE -48
+
static GSList *sms_assembly_add_fragment_backup(struct sms_assembly *assembly,
const struct sms *sms, time_t ts,
const struct sms_address *addr,
@@ -339,7 +346,7 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu,
if (in->second > 59)
return FALSE;
- if ((in->timezone > 12*4-1) || (in->timezone < -(12*4-1)))
+ if ((in->timezone > MAX_TIMEZONE) || (in->timezone < MIN_TIMEZONE))
return FALSE;
pdu = pdu + *offset;
@@ -426,7 +433,7 @@ gboolean sms_decode_scts(const unsigned char *pdu, int len,
if (oct & 0x08)
out->timezone = out->timezone * -1;
- if ((out->timezone > 12*4-1) || (out->timezone < -(12*4-1)))
+ if ((out->timezone > MAX_TIMEZONE) || (out->timezone < MIN_TIMEZONE))
return FALSE;
return TRUE;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] Make timezone an optional field
2010-11-30 10:44 [PATCH 1/3] smsutil: Change the range of time zone Yang Gu
@ 2010-11-30 10:44 ` Yang Gu
2010-12-08 14:05 ` Denis Kenzior
2010-11-30 10:44 ` [PATCH 3/3] stk: Handle provide local info proactive command Yang Gu
2010-12-07 13:39 ` [PATCH 1/3] smsutil: Change the range of time zone Denis Kenzior
2 siblings, 1 reply; 8+ messages in thread
From: Yang Gu @ 2010-11-30 10:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2893 bytes --]
---
src/smsutil.c | 11 ++++++++++-
src/smsutil.h | 1 +
src/stkutil.c | 13 ++-----------
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/smsutil.c b/src/smsutil.c
index 644e3e0..20af30a 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -346,7 +346,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;
@@ -358,6 +359,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);
@@ -365,6 +371,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;
@@ -436,6 +443,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;
}
diff --git a/src/smsutil.h b/src/smsutil.h
index 4b05313..4b6159f 100644
--- a/src/smsutil.h
+++ b/src/smsutil.h
@@ -223,6 +223,7 @@ struct sms_scts {
guint8 hour;
guint8 minute;
guint8 second;
+ gboolean has_timezone;
gint8 timezone;
};
diff --git a/src/stkutil.c b/src/stkutil.c
index a211462..01a0021 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -4548,7 +4548,6 @@ static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
{
const struct sms_scts *scts = data;
- struct sms_scts timestamp;
unsigned char value[7];
int offset = 0;
unsigned char tag = STK_DATA_OBJECT_TYPE_DATETIME_TIMEZONE;
@@ -4556,16 +4555,8 @@ static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv,
if (scts->month == 0 && scts->day == 0)
return TRUE;
- /* Time zone information is optional */
- if (scts->timezone == (gint8) 0xff) {
- memcpy(×tamp, scts, sizeof(timestamp));
- timestamp.timezone = 0;
- if (sms_encode_scts(×tamp, value, &offset) != TRUE)
- return FALSE;
- value[6] = 0xff;
- } else
- if (sms_encode_scts(scts, value, &offset) != TRUE)
- return FALSE;
+ if (sms_encode_scts(scts, value, &offset) != TRUE)
+ return FALSE;
return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
stk_tlv_builder_append_bytes(tlv, value, 7) &&
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] stk: Handle provide local info proactive command
2010-11-30 10:44 [PATCH 1/3] smsutil: Change the range of time zone Yang Gu
2010-11-30 10:44 ` [PATCH 2/3] Make timezone an optional field Yang Gu
@ 2010-11-30 10:44 ` Yang Gu
2010-11-30 20:43 ` Jeevaka.Badrappan
2010-12-08 14:05 ` Denis Kenzior
2010-12-07 13:39 ` [PATCH 1/3] smsutil: Change the range of time zone Denis Kenzior
2 siblings, 2 replies; 8+ messages in thread
From: Yang Gu @ 2010-11-30 10:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2814 bytes --]
---
src/stk.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/src/stk.c b/src/stk.c
index a4abb7d..08353f2 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -26,6 +26,7 @@
#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <stdint.h>
#include <glib.h>
@@ -1995,6 +1996,77 @@ static gboolean handle_command_refresh(const struct stk_command *cmd,
return TRUE;
}
+static void get_time(struct stk_response *rsp)
+{
+ time_t now;
+ struct tm *t;
+
+ time(&now);
+ t = localtime(&now);
+
+ rsp->result.type = STK_RESULT_TYPE_SUCCESS;
+
+ if (t->tm_year > 100)
+ rsp->provide_local_info.datetime.year = t->tm_year - 100;
+ else
+ rsp->provide_local_info.datetime.year = t->tm_year;
+
+ rsp->provide_local_info.datetime.month = t->tm_mon + 1;
+ rsp->provide_local_info.datetime.day = t->tm_mday;
+ rsp->provide_local_info.datetime.hour = t->tm_hour;
+ rsp->provide_local_info.datetime.minute = t->tm_min;
+ rsp->provide_local_info.datetime.second = t->tm_sec;
+ rsp->provide_local_info.datetime.timezone = t->tm_gmtoff / 900;
+ rsp->provide_local_info.datetime.has_timezone = TRUE;
+
+ return;
+}
+
+static void get_lang(struct stk_response *rsp, struct ofono_stk *stk)
+{
+ char *l;
+ char lang[3];
+ struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE };
+
+ l = getenv("LANG");
+ if (l == NULL) {
+ rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+ goto out;
+ }
+
+ memcpy(lang, l, 2);
+ lang[2] = '\0';
+
+ rsp->result.type = STK_RESULT_TYPE_SUCCESS;
+ rsp->provide_local_info.language = lang;
+
+out:
+ if (stk_respond(stk, rsp, stk_command_cb))
+ stk_command_cb(&failure, stk);
+}
+
+static gboolean handle_command_provide_local_info(const struct stk_command *cmd,
+ struct stk_response *rsp, struct ofono_stk *stk)
+{
+ switch (cmd->qualifier) {
+ case 3:
+ DBG("Date, time and time zone");
+ get_time(rsp);
+ return TRUE;
+
+ case 4:
+ DBG("Language setting");
+ get_lang(rsp, stk);
+ return FALSE;
+
+ default:
+ ofono_info("Unsupported Provide Local Info qualifier: %d",
+ cmd->qualifier);
+ rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
+ return TRUE;
+ }
+}
+
static void send_dtmf_cancel(struct ofono_stk *stk)
{
struct ofono_voicecall *vc = NULL;
@@ -2427,6 +2499,11 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
&rsp, stk);
break;
+ case STK_COMMAND_TYPE_PROVIDE_LOCAL_INFO:
+ respond = handle_command_provide_local_info(stk->pending_cmd,
+ &rsp, stk);
+ break;
+
case STK_COMMAND_TYPE_SEND_DTMF:
respond = handle_command_send_dtmf(stk->pending_cmd,
&rsp, stk);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH 3/3] stk: Handle provide local info proactive command
2010-11-30 10:44 ` [PATCH 3/3] stk: Handle provide local info proactive command Yang Gu
@ 2010-11-30 20:43 ` Jeevaka.Badrappan
2010-12-01 2:03 ` Gu, Yang
2010-12-08 14:05 ` Denis Kenzior
1 sibling, 1 reply; 8+ messages in thread
From: Jeevaka.Badrappan @ 2010-11-30 20:43 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
Hi Yang,
>
> +static void get_time(struct stk_response *rsp) {
> + time_t now;
> + struct tm *t;
> +
> + time(&now);
> + t = localtime(&now);
> +
> + rsp->result.type = STK_RESULT_TYPE_SUCCESS;
> +
> + if (t->tm_year > 100)
> + rsp->provide_local_info.datetime.year =
> t->tm_year - 100;
> + else
> + rsp->provide_local_info.datetime.year = t->tm_year;
> +
Incase of error, localtime shall return a null pointer. I think its
better to add the NULL check.
Regards,
Jeevaka
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH 3/3] stk: Handle provide local info proactive command
2010-11-30 20:43 ` Jeevaka.Badrappan
@ 2010-12-01 2:03 ` Gu, Yang
0 siblings, 0 replies; 8+ messages in thread
From: Gu, Yang @ 2010-12-01 2:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
Hi Jeevaka,
>-----Original Message-----
>From: ofono-bounces(a)ofono.org [mailto:ofono-bounces(a)ofono.org] On Behalf Of
>Jeevaka.Badrappan(a)elektrobit.com
>Sent: Wednesday, December 01, 2010 4:43 AM
>To: ofono(a)ofono.org
>Subject: RE: [PATCH 3/3] stk: Handle provide local info proactive command
>
>
>Hi Yang,
>
>>
>> +static void get_time(struct stk_response *rsp) {
>> + time_t now;
>> + struct tm *t;
>> +
>> + time(&now);
>> + t = localtime(&now);
>> +
>> + rsp->result.type = STK_RESULT_TYPE_SUCCESS;
>> +
>> + if (t->tm_year > 100)
>> + rsp->provide_local_info.datetime.year =
>> t->tm_year - 100;
>> + else
>> + rsp->provide_local_info.datetime.year = t->tm_year;
>> +
>
>Incase of error, localtime shall return a null pointer. I think its
>better to add the NULL check.
Thanks for the comment. I have sent out the modified version.
Regards,
-Yang
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] smsutil: Change the range of time zone
2010-11-30 10:44 [PATCH 1/3] smsutil: Change the range of time zone Yang Gu
2010-11-30 10:44 ` [PATCH 2/3] Make timezone an optional field Yang Gu
2010-11-30 10:44 ` [PATCH 3/3] stk: Handle provide local info proactive command Yang Gu
@ 2010-12-07 13:39 ` Denis Kenzior
2 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2010-12-07 13:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
Hi Yang,
On 11/30/2010 04:44 AM, Yang Gu wrote:
> ---
> src/smsutil.c | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] Make timezone an optional field
2010-11-30 10:44 ` [PATCH 2/3] Make timezone an optional field Yang Gu
@ 2010-12-08 14:05 ` Denis Kenzior
0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2010-12-08 14:05 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 276 bytes --]
Hi Yang,
On 11/30/2010 04:44 AM, Yang Gu wrote:
> ---
> src/smsutil.c | 11 ++++++++++-
> src/smsutil.h | 1 +
> src/stkutil.c | 13 ++-----------
> 3 files changed, 13 insertions(+), 12 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] stk: Handle provide local info proactive command
2010-11-30 10:44 ` [PATCH 3/3] stk: Handle provide local info proactive command Yang Gu
2010-11-30 20:43 ` Jeevaka.Badrappan
@ 2010-12-08 14:05 ` Denis Kenzior
1 sibling, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2010-12-08 14:05 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
Hi Yang,
On 11/30/2010 04:44 AM, Yang Gu wrote:
> ---
> src/stk.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 77 insertions(+), 0 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-12-08 14:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-30 10:44 [PATCH 1/3] smsutil: Change the range of time zone Yang Gu
2010-11-30 10:44 ` [PATCH 2/3] Make timezone an optional field Yang Gu
2010-12-08 14:05 ` Denis Kenzior
2010-11-30 10:44 ` [PATCH 3/3] stk: Handle provide local info proactive command Yang Gu
2010-11-30 20:43 ` Jeevaka.Badrappan
2010-12-01 2:03 ` Gu, Yang
2010-12-08 14:05 ` Denis Kenzior
2010-12-07 13:39 ` [PATCH 1/3] smsutil: Change the range of time zone Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox