Fix the different issue of Setting's time and Indicator's time and Fix N_SE-13536
authorKairong Yin <kairong78.yin@samsung.com>
Sat, 10 Nov 2012 12:05:33 +0000 (20:05 +0800)
committerKairong Yin <kairong78.yin@samsung.com>
Sat, 10 Nov 2012 12:05:33 +0000 (20:05 +0800)
Change-Id: I6b3815e8db9e4f6d1e16f17df9b6b8c1dd1387ef

setting-time/include/setting-time.h
setting-time/src/setting-time-engine.c
setting-time/src/setting-time-main.c

index 75a6e6f..5597955 100755 (executable)
@@ -69,7 +69,6 @@ struct _SettingTimeUG {
        Ecore_Timer *heynoti_timer;
        Evas_Object *pop_progress;
        Evas_Object *pop;
-       time_t changed_time;
        Eina_Bool is_datefield_selected;
 
        /*  UI   */
index cee9b35..6a1c0fb 100755 (executable)
 /*  To set system time takes some time. It makes some time before firing heynoti of setting_time_changed.*/
 int setting_time_update_cb(void *data)
 {
-       /* time_t time_input = (time_t)data; */
-
+       retv_if(data == NULL, -1);
+       SettingTimeUG *ad = data;
+       /*
        char time_str[SETTING_TIME_ENGINE_TIME_STR_LEN];
        struct tm *ts;
        struct tm ts_ret;
        time_t ctime;
-
-       retv_if(data == NULL, -1);
-       SettingTimeUG *ad = data;
-
        // get time from datefield UI
        ctime = ad->changed_time;
        //ctime = time(NULL);
@@ -40,7 +37,7 @@ int setting_time_update_cb(void *data)
        retv_if(!ts, 1);
        strftime(time_str, SETTING_TIME_ENGINE_TIME_STR_LEN, "%H:%M", &ts_ret);
        SETTING_TRACE("After setting time ::: tm is_dst --> %d", ts_ret.tm_isdst);
-       SETTING_TRACE("After Setting time time_str:%s", time_str);
+       SETTING_TRACE("After Setting time time_str:%s", time_str);*/
 #if SUPPORT_SCREEN_PROTECTED
        pm_unlock_state(LCD_NORMAL, STAY_CUR_STATE);
 #endif
index 5c77d20..c13a78f 100755 (executable)
@@ -50,7 +50,7 @@ static bool get_city_name(char* tzname);
 
 static char* s_result;
 static int query_callback(void *NotUsed, int argc, char **argv, char **azColName);
-
+static bool setting_update_timezone(SettingTimeUG *ad);
 
 static int setting_time_main_create(void *cb);
 static int setting_time_main_destroy(void *cb);
@@ -67,6 +67,12 @@ setting_view setting_view_time_main = {
 static void setting_time_reboot_resp_cb(void *data, Evas_Object *obj,
                                        void *event_info);
 
+bool __update_timezone_idler(SettingTimeUG *ad)
+{
+       setting_update_timezone(ad);
+       ad->update_timezone_idler = NULL;
+       return 0;
+}
 #if TIME_CHANGED_HEYNOTY_CALLBACK
 void time_changed_callback(void *data)
 {
@@ -78,6 +84,7 @@ void time_changed_callback(void *data)
                SETTING_TRACE("FAIL: setting_time_update_db(ad)\n");
        }
 
+       SETTING_TRACE("ad->is_datefield_selected:%d", ad->is_datefield_selected)
        if(EINA_TRUE == ad->is_datefield_selected) {
                /* Timezone is not changed and a selected value of the datefield is already changed */
                SETTING_TRACE("Datefield is selected\n");
@@ -85,11 +92,9 @@ void time_changed_callback(void *data)
        }
 
        tzset();
-
        // vconfset to update timezone
        char pTZPath[__MAX_PATH_SIZE];
        ssize_t nLen = readlink(SETTING_TZONE_SYMLINK_PATH, pTZPath, sizeof(pTZPath)-1);
-
        if (nLen != -1) {
                pTZPath[nLen] = '\0';
        } else {
@@ -101,14 +106,24 @@ void time_changed_callback(void *data)
                SETTING_TRACE("__setting_set_city_tzone ERROR");
                return;
        }
-
-       setting_time_main_update(data);
-
        char *timezone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
        setting_retm_if(timezone == NULL, "get vonf failed");
-
        ICU_set_timezone(timezone);
        FREE(timezone);
+
+       // update timezone
+       if (ad->update_timezone_idler) {
+               ecore_idler_del(ad->update_timezone_idler);
+               ad->update_timezone_idler = NULL;
+       }
+       ad->update_timezone_idler =
+           ecore_idler_add((Ecore_Task_Cb) __update_timezone_idler, ad);
+       // update time
+       if (ad->refresh_time_idler) {
+               ecore_idler_del(ad->refresh_time_idler);
+               ad->refresh_time_idler = NULL;
+       }
+       ad->refresh_time_idler = ecore_idler_add(setting_update_datefield, ad);
 }
 #endif
 
@@ -193,12 +208,6 @@ bool setting_update_timezone(SettingTimeUG *ad)
        return 0;
 }
 
-bool __update_timezone_idler(SettingTimeUG *ad)
-{
-       setting_update_timezone(ad);
-       ad->update_timezone_idler = NULL;
-       return 0;
-}
 
 static void setting_time_main_int_vconf_change_cb(keynode_t *key, void *data)
 {
@@ -310,7 +319,6 @@ static void setting_time_main_datefield_change_cb(void *data, Evas_Object *obj,
 
        /*  local time  -> gmtime */
        time_t the_time = mktime(&_tm); /* represent local time */
-       ad->changed_time = the_time;
 
        if ( (time(NULL)/ONE_MINUTE) == (the_time/ONE_MINUTE) )
        {
@@ -341,7 +349,7 @@ static void setting_time_main_datefield_change_cb(void *data, Evas_Object *obj,
 
 Eina_Bool __refresh_date_timer(void *data)
 {
-       SETTING_TRACE_BEGIN;
+       //SETTING_TRACE_BEGIN;
        SettingTimeUG *ad = data;
        if (ad->data_time) {
                time_t ctime = time(NULL);
@@ -349,10 +357,11 @@ Eina_Bool __refresh_date_timer(void *data)
                struct tm *ts = localtime_r(&ctime, &ts_ret);
                retv_if(!ts, 1);
 
-               time_t diff = abs(ctime - ad->changed_time);
-               if (diff <=1 || diff >= 60) {
-                       diff = 0;
-               } else {
+               struct tm ui_time;
+               elm_datetime_value_get(ad->data_time->eo_check, &ui_time);
+               if ( (ctime/ONE_MINUTE) != (mktime(&ui_time)/ONE_MINUTE) )
+               {
+                       SETTING_TRACE("To refresh the UI element after 1 minute passed.\t in %s", __FUNCTION__);
                        elm_datetime_value_set(ad->data_time->eo_check, &ts_ret);
                }
        }
@@ -1034,7 +1043,13 @@ Eina_Bool setting_update_datefield(void *cb)
        retvm_if(cb == NULL, EINA_FALSE, "Data parameter is NULL");
        SettingTimeUG *ad = (SettingTimeUG *) cb;
 
-       __refresh_date_timer(ad);
+       //__refresh_date_timer(ad);
+       if (ad->data_time) {
+               time_t ctime = time(NULL);
+               struct tm ts_ret;
+               struct tm *ts = localtime_r(&ctime, &ts_ret);
+               if (ts) elm_datetime_value_set(ad->data_time->eo_check, &ts_ret);
+       }
        ad->refresh_time_idler = NULL;
        return 0;
 }