+static void __time_auto_update(void *data)
+{
+ setting_retm_if(data == NULL, "Data parameter is NULL");
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+ int err;
+ setting_set_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ SETTING_ON_OFF_BTN_ON, &err);
+ if (ad->data_tz) {
+ setting_disable_genlist_item(ad->data_tz->item);
+ }
+
+ if (ad->data_time) {
+ ad->data_time->isItemDisableFlag = FALSE;
+ setting_disable_evas_object(ad->data_time->eo_check);
+ setting_disable_genlist_item(ad->data_time->item);
+ }
+
+ int ret = 0;
+
+ int t_nitz = 0;
+ int t_offset = 0;
+ ret += vconf_get_int(VCONFKEY_TELEPHONY_NITZ_GMT, &t_nitz);
+ ret += vconf_get_int(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT, &t_offset);
+ char *tzpath = vconf_get_str(VCONFKEY_TELEPHONY_NITZ_ZONE);
+ if (ret != 0 || isEmptyStr(tzpath))
+ {
+ setting_create_simple_popup(ad, ad->win_get,
+ NULL, _("TAPI doesn't support this sim card to update time automatically!"));
+ return;
+ }
+ ret = 0;//reset..
+
+ // a.time zone
+ SETTING_TRACE("tz_path:%s", tzpath);
+
+ char tz_path[MAX_COMMON_BUFFER_LEN / 4 + 1];
+ safeCopyStr(tz_path, SETTING_TIME_ZONEINFO_PATH, MAX_COMMON_BUFFER_LEN / 4);
+ g_strlcat(tz_path, tzpath, sizeof(tz_path));
+ SETTING_TRACE("full tz_path:%s", tz_path);
+ ret = sysman_set_timezone(tz_path);
+ if (ret < 0) {
+ SETTING_TRACE("tzpath is not valid.");
+ return;
+ } else
+ SETTING_TRACE("sysman_set_timezone - successful : %s \n", tz_path);
+ if (!__setting_set_city_tzone(tzpath)) {
+ SETTING_TRACE("__setting_set_city_tzone ERROR")
+ return;
+ }
+ if (get_city_name(tzpath)) {
+ SETTING_TRACE(">>>>>> RESULT : %s", get_city_name_result());
+ }
+ char* city = get_city_name_result();
+ SETTING_TRACE("city:%s", city);
+ ret = vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, city);
+ setting_retm_if(ret != 0, "set vconf failed");
+ setting_update_timezone(ad);
+
+ // b.TIME AND DATE
+ int t_uptime = 0;
+ FILE *fp = fopen("/proc/uptime", "r");
+ fscanf(fp, "%d", &t_uptime);
+ SETTING_TRACE("t_nitz:%d, t_offset:%d, t_uptime:%d", t_nitz, t_offset, t_uptime);
+ time_t t_current = t_nitz + t_uptime - t_offset;
+ SETTING_TRACE("t_current:%d", t_current);
+ ret = sysman_set_datetime(t_current);
+ setting_retm_if(ret == -1, "sysman_set_datetime call failed");
+ //ad->changed_time = t_current;
+ if (ad->data_time) {
+ struct tm ts_ret;
+ struct tm *ts = localtime_r(&t_current, &ts_ret);
+ ret_if(!ts);
+ elm_datetime_value_set(ad->data_time->eo_check, &ts_ret);
+ }
+
+ // event notification
+ static int t_event_val = -1;
+ vconf_set_int (VCONFKEY_SYSTEM_TIME_CHANGED, t_event_val);
+}