From 4ded8fa0f244259f9901012fecdaa9ba99fbe267 Mon Sep 17 00:00:00 2001 From: Jeesun Kim Date: Fri, 26 Apr 2013 10:12:04 +0900 Subject: [PATCH] [issue#]N_SE-35479 [problem] Not working alarm when system time changed. [cause] System doesn't apply its changed time immediately. [solution] Get changed time using VCONF key which already calculated. --- native/cal_db_plugin_event.c | 2 +- server/cal_server_alarm.c | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/native/cal_db_plugin_event.c b/native/cal_db_plugin_event.c index 8ea63ad..749a556 100644 --- a/native/cal_db_plugin_event.c +++ b/native/cal_db_plugin_event.c @@ -867,7 +867,7 @@ static int __cal_db_event_add_exdate(calendar_record_h record) } // add recurrence id to end of the exdate of original event. - const unsigned char *temp; + const unsigned char *temp = NULL; int len = 0; char *exdate = NULL; if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) diff --git a/server/cal_server_alarm.c b/server/cal_server_alarm.c index 5c5a316..426c8f3 100644 --- a/server/cal_server_alarm.c +++ b/server/cal_server_alarm.c @@ -805,6 +805,10 @@ static int __cal_server_alarm_register_next_normal(long long int now_utime, GLis _cal_time_utoi(mod_alarm_utime, tzid, &alarm_date.year, &alarm_date.month, &alarm_date.day, &alarm_date.hour, &alarm_date.min, &alarm_date.sec); + DBG("tzid[%s] datetime(%04d/%02d/%02d %02d:%02d:%02d", tzid, + alarm_date.year, alarm_date.month, alarm_date.day, + alarm_date.hour, alarm_date.min, alarm_date.sec); + alarmmgr_set_time(alarm_info, alarm_date); ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id); if (tzid) free(tzid); @@ -903,7 +907,7 @@ static gint __cal_server_alarm_allday_sort_cb(gconstpointer a, gconstpointer b) return p1->alarm_datetime - p2->alarm_datetime > 0 ? 1 : -1; } -static int __cal_server_alarm_register_with_alarmmgr(void) +static int __cal_server_alarm_register_with_alarmmgr(long long int now_utime) { GList *normal_list = NULL; GList *allday_list = NULL; @@ -914,9 +918,7 @@ static int __cal_server_alarm_register_with_alarmmgr(void) gettimeofday(&stv, NULL); // check time // for normal - long long int now_utime; long long int from_utime, to_utime; - now_utime = _cal_time_get_now(); event_count = 0; todo_count = 0; @@ -956,7 +958,7 @@ static int __cal_server_alarm_register_with_alarmmgr(void) time_t from_timet, to_timet; int from_datetime, to_datetime; struct tm datetime_tm; - now_timet = time(NULL); + now_timet = (time_t)now_utime; event_count = 0; todo_count = 0; @@ -1080,14 +1082,24 @@ static int _alert_cb(alarm_id_t alarm_id, void *data) allday_list = NULL; } - __cal_server_alarm_register_with_alarmmgr(); + __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now()); return 0; } //////////////////////////////////////////////////////////////////// static void __cal_server_alarm_timechange_cb(keynode_t *node, void *data) { - __cal_server_alarm_register_with_alarmmgr(); + time_t t; + if (node) { + t = vconf_keynode_get_int(node); + } + else + { + vconf_get_int(VCONFKEY_SYSTEM_TIMECHANGE, (int *)&t); + } + + DBG("systme changed time(%ld)", t); + __cal_server_alarm_register_with_alarmmgr((long long int)t); } int __cal_server_alarm_set_timechange(void) @@ -1106,7 +1118,7 @@ int __cal_server_alarm_set_timechange(void) static void __changed_cb(const char* view_uri, void* data) { - __cal_server_alarm_register_with_alarmmgr(); + __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now()); } static int __cal_server_alarm_set_inotify(calendar_db_changed_cb callback) @@ -1129,7 +1141,7 @@ int _cal_server_alarm(void) ret = alarmmgr_set_cb(_alert_cb, NULL); retvm_if(ret < 0, ret, "alarmmgr_set_cb() failed"); - __cal_server_alarm_register_with_alarmmgr(); + __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now()); return CALENDAR_ERROR_NONE; } -- 2.7.4