summaryrefslogtreecommitdiff
path: root/setting-time
diff options
context:
space:
mode:
authorHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:00:54 +0900
committerHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:00:54 +0900
commit38fa070437a220df7736ad36d5dab2a27e415b96 (patch)
treef60bbb1284c00d576c427a806f55da7a83ec330b /setting-time
parent0d9aac50df4b567e19740b8e072e94680c6c4ea0 (diff)
downloadsettings-tizen_2.0.tar.gz
settings-tizen_2.0.tar.bz2
settings-tizen_2.0.zip
Diffstat (limited to 'setting-time')
-rwxr-xr-xsetting-time/CMakeLists.txt35
-rwxr-xr-xsetting-time/include/setting-time-engine.h29
-rwxr-xr-xsetting-time/include/setting-time-main.h64
-rwxr-xr-xsetting-time/include/setting-time.h96
-rwxr-xr-xsetting-time/src/setting-time-engine.c46
-rwxr-xr-xsetting-time/src/setting-time-main.c1781
-rwxr-xr-xsetting-time/src/setting-time.c296
7 files changed, 2347 insertions, 0 deletions
diff --git a/setting-time/CMakeLists.txt b/setting-time/CMakeLists.txt
new file mode 100755
index 0000000..ffd08d3
--- /dev/null
+++ b/setting-time/CMakeLists.txt
@@ -0,0 +1,35 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${SETTING_COMMON}/include)
+
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs_time REQUIRED evas elementary appcore-common appcore-efl ecore tapi ui-gadget-1 capi-appfw-application sysman pmapi icu-i18n icu-io icu-le icu-lx icu-uc)
+
+FOREACH(flag ${pkgs_time_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-fpie")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+ADD_LIBRARY(${SETTING_TIME_UG} SHARED
+ ./src/setting-time.c
+ ./src/setting-time-main.c
+ ./src/setting-time-engine.c
+ )
+
+TARGET_LINK_LIBRARIES(${SETTING_TIME_UG} -L${CMAKE_BINARY_DIR}/${SETTING_COMMON} -lsetting-common)
+TARGET_LINK_LIBRARIES(${SETTING_TIME_UG} ${pkgs_time_LDFLAGS})
+
+INSTALL(TARGETS ${SETTING_TIME_UG} DESTINATION /usr/ug/lib)
diff --git a/setting-time/include/setting-time-engine.h b/setting-time/include/setting-time-engine.h
new file mode 100755
index 0000000..3be7840
--- /dev/null
+++ b/setting-time/include/setting-time-engine.h
@@ -0,0 +1,29 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SETTING_TIME_ENGINE_H__
+#define __SETTING_TIME_ENGINE_H__
+
+#include <setting-time.h>
+#include <sysman.h>
+
+#define SETTING_TIME_ENGINE_TIME_STR_LEN 15
+
+int setting_save_time(time_t _time);
+
+int setting_time_update_cb(void *data);
+
+#endif /* __SETTING_TIME_ENGINE_H__ */
diff --git a/setting-time/include/setting-time-main.h b/setting-time/include/setting-time-main.h
new file mode 100755
index 0000000..5a129e5
--- /dev/null
+++ b/setting-time/include/setting-time-main.h
@@ -0,0 +1,64 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SETTING_TIME_MAIN_H__
+#define __SETTING_TIME_MAIN_H__
+
+#include <setting-time.h>
+#include <setting-time-engine.h>
+
+#define MAX_ARGS 15
+#define CITY_BUF_SIZE 128
+#define GMT_BUF_SIZE 10
+#define __MAX_PATH_SIZE 1024
+
+
+#define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
+#define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
+#define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
+
+void setting_time_main_launch_worldclock_sg(void *data);
+void setting_time_main_close_worldclock_sg(gpointer cb_data, gint argc,
+ gchar **argv);
+
+void setting_time_main_click_softkey_left_cb(void *data, Evas_Object *obj,
+ void *event_info);
+void setting_time_main_click_softkey_caller_exist_left_cb(void *data,
+ Evas_Object *obj,
+ void *event_info);
+void setting_time_main_click_softkey_caller_exist_right_cb(void *data,
+ Evas_Object *obj,
+ void *event_info);
+static void setting_time_main_chk_btn_cb(void *data, Evas_Object *obj,
+ void *event_info);
+void setting_time_main_item_mouse_up_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info);
+static void setting_time_main_mouse_up_Gendial_list_cb(void *data,
+ Evas_Object *obj,
+ void *event_info);
+void setting_time_main_btn_update_ok_cb(void *cb);
+void setting_time_main_btn_update_cancel_cb(void *cb);
+void setting_time_update_time_date_format_string(SettingTimeUG *ad);
+Eina_Bool setting_update_datefield(void *cb);
+int setting_time_check_automatic_time_update_state();
+#if DISABLED_CODE
+static void setting_time_main_controlbar_lbtn_label_set(
+ Evas_Object *controlbar,
+ char *label);
+#endif
+static int __setting_set_city_tzone(const char* pTZPath);
+
+#endif /* __SETTING_TIME_MAIN_H__ */
diff --git a/setting-time/include/setting-time.h b/setting-time/include/setting-time.h
new file mode 100755
index 0000000..3e52b20
--- /dev/null
+++ b/setting-time/include/setting-time.h
@@ -0,0 +1,96 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SETTING_TIME_H__
+#define __SETTING_TIME_H__
+
+#include <stdio.h>
+#include <time.h>
+#include <sys/ioctl.h>
+#include <linux/rtc.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <Elementary.h>
+
+#include <glib-object.h>
+
+#include <setting-common-draw-widget.h>
+#include <setting-common-view.h>
+#define ERR_BIGGER_THAN_2037 "Cannot Set the year bigger than 2037"
+#define AUTO_TIME_UPDATE_ON "Automatic time update is ON!"
+#define SETTING_TIME_AUTO_UPDATE_DESC "IDS_ST_BODY_USE_TIME_PROVIDED_BY_NETWORK"
+#define NOT_SUPPORT_AUTO_UPDATE_DESC "The SIM Card being used doesn't support automatically updating time" //need multi-language support.
+
+#define SETTING_DATAUSAGE_MDM_RESTRICTS_STR "Security policy restricts use of data usage"
+
+typedef struct _SettingTimeUG SettingTimeUG;
+
+/**
+ * Setting Time UG context
+ * all UG function has void* as an agument. this is casted back to SettingTimeUG
+ * and the functions access app context.
+ */
+struct _SettingTimeUG {
+
+ ui_gadget_h ug; /**< ug struct itself */
+
+ /* add more variables here (move your appdata to here) */
+ int noti_fd;
+
+ service_h bundle_data; /**< when loading this UG, bundle is stored */
+ Evas *evas;
+ Evas_Object *win_main_layout;
+ Evas_Object *win_get;
+ Evas_Object *ly_main;
+
+ ui_gadget_h ug_loading;
+
+ Evas_Object *navi_bar;
+ Evas_Object *scrl_main;
+ char *caller;
+
+ Ecore_Timer *update_timer;
+ Evas_Object *pop_progress;
+ Evas_Object *pop;
+ Eina_Bool is_datefield_selected;
+
+ /* UI */
+ Setting_GenGroupItem_Data *data_auto;
+ Setting_GenGroupItem_Data *data_tz;
+ Setting_GenGroupItem_Data *data_dst;
+ Setting_GenGroupItem_Data *data_time;
+ Setting_GenGroupItem_Data *data_time_fmt;
+ Setting_GenGroupItem_Data *data_date_fmt;
+ Setting_GenGroupItem_Data *data_firstday_week_fmt;
+
+ Evas_Object *chk_dst;
+ Evas_Object *chk_auto;
+
+ Elm_Genlist_Item_Class itc_2text_2;
+ Elm_Genlist_Item_Class itc_2text_arrow;
+ Elm_Genlist_Item_Class itc_1text_1icon;
+ Elm_Genlist_Item_Class itc_seperator;
+ Elm_Genlist_Item_Class itc_layout;
+ Elm_Genlist_Item_Class itc_2text_3_parent;
+ Elm_Genlist_Item_Class itc_1icon_1text_sub;
+
+ Ecore_Idler *update_timezone_idler;
+ Ecore_Idler *refresh_time_idler;
+};
+
+extern setting_view setting_view_time_main;
+
+#endif /* __SETTING_TIME_H__ */
diff --git a/setting-time/src/setting-time-engine.c b/setting-time/src/setting-time-engine.c
new file mode 100755
index 0000000..cf0e23d
--- /dev/null
+++ b/setting-time/src/setting-time-engine.c
@@ -0,0 +1,46 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <setting-time-engine.h>
+
+/* To set system time takes some time. It makes some time before firing vconf event */
+int setting_time_update_cb(void *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;
+ // get time from datefield UI
+ ctime = ad->changed_time;
+ //ctime = time(NULL);
+ ts = localtime_r(&ctime, &ts_ret);
+ 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);*/
+#if SUPPORT_SCREEN_PROTECTED
+ pm_unlock_state(LCD_NORMAL, STAY_CUR_STATE);
+#endif
+
+ if (ad->pop_progress) {
+ evas_object_del(ad->pop_progress);
+ ad->pop_progress = NULL;
+ }
+ return 0;
+}
diff --git a/setting-time/src/setting-time-main.c b/setting-time/src/setting-time-main.c
new file mode 100755
index 0000000..cb8319c
--- /dev/null
+++ b/setting-time/src/setting-time-main.c
@@ -0,0 +1,1781 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <setting-time-main.h>
+#include <sysman_managed.h>
+
+#include <stdio.h>
+#include <malloc.h>
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sqlite3.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <unicode/udat.h>
+#include <unicode/ustring.h>
+#include <unicode/uloc.h>
+#include <unicode/ucal.h>
+#include <unicode/utmscale.h>
+
+#define ONE_MINUTE 60
+#define PROGRESS_POPUP_SHOW 0
+
+/* ICU utilities*/
+static UChar *uastrcpy(const char *chars);
+static void ICU_set_timezone(const char *timezone);
+static int get_timezone_isdst(int* isdst);
+static void get_gmt_offset(char *str_buf, int size);
+
+static char* get_timezone_str();
+static char* get_city_name_result();
+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);
+static int setting_time_main_update(void *cb);
+static int setting_time_main_cleanup(void *cb);
+
+setting_view setting_view_time_main = {
+ .create = setting_time_main_create,
+ .destroy = setting_time_main_destroy,
+ .update = setting_time_main_update,
+ .cleanup = setting_time_main_cleanup,
+};
+
+#if UN_SUPPORT_TIME_DYNAMIC_UPDATE
+static void setting_time_reboot_resp_cb(void *data, Evas_Object *obj,
+ void *event_info);
+#endif
+
+bool __update_timezone_idler(SettingTimeUG *ad)
+{
+ setting_update_timezone(ad);
+ ad->update_timezone_idler = NULL;
+ return 0;
+}
+
+void time_changed_callback(keynode_t *key, void *data) {
+
+ SETTING_TRACE_DEBUG("time and timezone have been changed: TIME_CHANGED_HEYNOTY_CALLBACK");
+ SettingTimeUG *ad = (SettingTimeUG *)data;
+
+ int ret = setting_time_update_cb(ad);
+ if (ret != 0) {
+ 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");
+ return ;
+ }
+
+ 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 {
+ SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
+ return;
+ }
+
+ if (!__setting_set_city_tzone(&pTZPath[20])) {
+ SETTING_TRACE("__setting_set_city_tzone ERROR");
+ return;
+ }
+ 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);
+}
+
+void setting_time_update_time_date_format_string(SettingTimeUG *ad)
+{
+ SETTING_TRACE_BEGIN;
+
+ struct tm *ts;
+ struct tm ts_ret;
+ time_t ctime;
+
+ int ret, value, err;
+
+ char time_str[MAX_ARGS];
+
+ ctime = time(NULL);
+ ts = localtime_r(&ctime, &ts_ret);
+ ret_if(!ts);
+
+ /* set time in particular format */
+ ret = setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224, &value, &err);
+ if (ret == SETTING_RETURN_FAIL)
+ value = VCONFKEY_TIME_FORMAT_12;
+
+ switch (value) {
+ case VCONFKEY_TIME_FORMAT_12:
+ {
+ /* Get Time */
+ strftime(time_str, MAX_ARGS, "%l:%M %p ", &ts_ret);
+ }
+ break;
+
+ case VCONFKEY_TIME_FORMAT_24:
+ {
+ strftime(time_str, MAX_ARGS, "%H:%M", &ts_ret);
+ }
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+
+ if (ad->data_time) {
+ elm_object_item_data_set(ad->data_time->item, ad->data_time);
+ elm_genlist_item_update(ad->data_time->item);
+ }
+}
+
+bool setting_update_timezone(SettingTimeUG *ad)
+{
+ /* SETTING_TRACE_BEGIN; */
+ char time_zone_sub_str[CITY_BUF_SIZE + GMT_BUF_SIZE + 3] = { 0, };
+ char *pa_timezone = NULL;
+ char *pa_city = NULL;
+ int ret = 0;
+
+ /* get time zone */
+ pa_city = vconf_get_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT);
+ pa_timezone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_INT);
+
+ //if ((pa_timezone != NULL) && (_(pa_city) != NULL && safeStrCmp(_(pa_city), "NULL"))) {
+ if ((pa_timezone != NULL) && (_(pa_city) != NULL )) {
+ /* SETTING_TRACE_DEBUG("*** timezone: %s *** ", timezone); */
+ /* SETTING_TRACE_DEBUG("*** city: %s *** ", _(city)); */
+ /* SETTING_TRACE_DEBUG("*** ret: %d, dst: %d *** ", ret, dst); */
+
+ ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT %s", _(pa_city), pa_timezone);
+ //ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT %s", pa_timezone, _(pa_city));
+ FREE(pa_city);
+ retv_if(ret < 0, 0);
+ } else {
+ ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT +09", _("IDS_WCL_BODY_CITYNAME_SEOUL"));
+ retv_if(ret < 0, 0);
+ }
+ SETTING_TRACE("ad->data_tz:%p", ad->data_tz);
+
+ if (ad->data_tz) {
+ ad->data_tz->sub_desc = (char *)g_strdup(time_zone_sub_str);
+ elm_object_item_data_set(ad->data_tz->item, ad->data_tz);
+ elm_genlist_item_update(ad->data_tz->item);
+ }
+ return 0;
+}
+
+
+static void setting_time_main_int_vconf_change_cb(keynode_t *key, void *data)
+{
+ /* SETTING_TRACE_BEGIN; */
+ ret_if(NULL == data);
+ SettingTimeUG *ad = data;
+ int status = vconf_keynode_get_int(key);
+ char *vconf_name = vconf_keynode_get_name(key);
+ /* SETTING_TRACE("vconf_name:%s", vconf_name); */
+
+ if (!safeStrCmp(vconf_name, VCONFKEY_REGIONFORMAT_TIME1224)) {
+
+ if (ad->data_time) {
+ /* VCONFKEY_REGIONFORMAT_TIME1224 1:12H 2:24H */
+ if (status <= 2 && status > 0) /* 1, 2 */
+ --status; /* set to 0 or 1 */
+ else
+ status = 0; /* set 12H */
+
+ /* TODO assert 1 or 0 */
+ ad->data_time->chk_status = !status;
+
+ char datefield_format[MAX_DATETIME_FORMAT_LEN + 1] = {0, };
+
+ const char *time_format = NULL;
+ if (ad->data_time->chk_status)//12 hours
+ {
+ time_format = "%I : %M %p";
+ } else { //24 hours
+ time_format = "%H : %M";
+ }
+
+//get date format from datefiled itself, if elm_datetime_add() supports set date-format via ICU.
+#ifdef SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET
+ const char *old_format = elm_datetime_format_get(ad->data_time->eo_check);
+ snprintf(datefield_format, MAX_DATE_FORMAT_LEN + 1, //add one space " "
+ "%s", old_format);
+ safeStrNCat(datefield_format, time_format, MAX_DATETIME_FORMAT_LEN);
+ SETTING_TRACE("datefield_format:%s", datefield_format);
+#else
+ int value = SETTING_DATE_FORMAT_DD_MM_YYYY;
+ int err = -1;
+
+ char *date_format_str[] = { "%d %b %Y", "%b %d %Y", "%Y %b %d", "%Y %d %b" };
+ int ret = setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err);
+ if (ret == SETTING_RETURN_FAIL)
+ value = SETTING_DATE_FORMAT_DD_MM_YYYY;
+
+ snprintf(datefield_format, MAX_DATETIME_FORMAT_LEN,
+ "%s %s", date_format_str[value], time_format);
+#endif
+
+ elm_datetime_format_set(ad->data_time->eo_check, datefield_format);
+ }
+ }
+}
+
+static void __update_time_via_sim_card(void *data)
+{
+ setting_retm_if(data == NULL, "Data parameter is NULL");
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+ 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->ly_main,
+ NULL, _(NOT_SUPPORT_AUTO_UPDATE_DESC));
+ 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);
+ if (city)
+ {
+ ret = vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, city);
+ setting_retm_if(ret != 0, "set vconf[%s] failed", VCONFKEY_SETAPPL_CITYNAME_INDEX_INT);
+ }
+ setting_update_timezone(ad);
+
+ // b.TIME AND DATE
+ int t_uptime = 0;
+ FILE *fp = fopen("/proc/uptime", "r");
+ if (fp) {
+ if (!fscanf(fp, "%d", &t_uptime)) {
+ SETTING_TRACE_ERROR("fscanf error");
+ }
+ fclose(fp);
+ fp = NULL;
+ } else {
+ SETTING_TRACE_ERROR("fopen error");
+ }
+
+ 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");
+ 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);
+ }
+
+ // time change - event
+ static int t_event_val = -1;
+ vconf_set_int (VCONFKEY_SYSTEM_TIME_CHANGED, t_event_val);
+}
+
+static void __sim_time_info_chg_cb(keynode_t *key, void *data)
+{
+ SETTING_TRACE_BEGIN;
+ ret_if(NULL == data);
+ SettingTimeUG *ad = data;
+ char *vconf_name = vconf_keynode_get_name(key);
+ SETTING_TRACE("vconf_name:%s", vconf_name);
+ if (!safeStrCmp(vconf_name, VCONFKEY_TELEPHONY_NITZ_GMT)
+ || !safeStrCmp(vconf_name, VCONFKEY_TELEPHONY_NITZ_EVENT_GMT)
+ || !safeStrCmp(vconf_name, VCONFKEY_TELEPHONY_NITZ_ZONE)) {
+ int value = 0;
+ int err = 0;
+ setting_get_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE, &value,
+ &err);
+ if (value)
+ {
+ 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))
+ {
+ return;
+ }
+ __update_time_via_sim_card(ad);
+ }
+ }
+}
+
+/* ***************************************************
+ *
+ *basic func
+ *
+ ***************************************************/
+static void setting_time_main_datefield_change_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ ret_if(data == NULL);
+ Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
+ SettingTimeUG *ad = list_item->userdata;
+
+ ad->is_datefield_selected = EINA_TRUE;
+
+ if (ad->update_timer) {
+ ecore_timer_reset(ad->update_timer);
+ ecore_timer_freeze(ad->update_timer);
+ }
+
+ // If auto update is on, don't anything while the datefield has been updated (i.e., time runs)
+ if (1 == setting_time_check_automatic_time_update_state()) {
+ SETTING_TRACE("AUTO_TIME ON: no action");
+ if (ad->update_timer) {
+ ecore_timer_thaw(ad->update_timer);
+ }
+ SETTING_TRACE_END;
+ return;
+ } else {
+ // otherwise, we apply a new date which has been changed by a user
+ }
+
+ struct tm _tm;
+ elm_datetime_value_get(obj, &_tm);
+
+ SETTING_TRACE("year : %d, month : %d, day : %d, hour : %d, min : %d",
+ _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min);
+ if (2037 < _tm.tm_year) {
+ setting_create_simple_popup(ad, ad->win_get,
+ NULL, _(ERR_BIGGER_THAN_2037));
+ if (ad->update_timer) {
+ ecore_timer_thaw(ad->update_timer);
+ }
+ return;
+ }
+#if SUPPORT_SCREEN_PROTECTED /* if not lock the current state, after set the time, the screen will become dimmed */
+ pm_lock_state(LCD_NORMAL, STAY_CUR_STATE, 0);
+#endif
+ _tm.tm_sec = 0;
+
+ int isdst;
+ if (get_timezone_isdst(&isdst) == SETTING_RETURN_SUCCESS) {
+ _tm.tm_isdst = isdst;
+ } else {
+ // error
+ SETTING_TRACE_ERROR("get_timezone_isdst() failed");
+ if (ad->update_timer) {
+ ecore_timer_thaw(ad->update_timer);
+ }
+ return;
+ }
+
+ /* local time -> gmtime */
+ time_t the_time = mktime(&_tm); /* represent local time */
+
+ if ( (time(NULL)/ONE_MINUTE) == (the_time/ONE_MINUTE) )
+ {
+ SETTING_TRACE("Time is not changed\n");
+ //current time didn't change
+ if (ad->update_timer) {
+ ecore_timer_thaw(ad->update_timer);
+ }
+ return;
+ }
+
+#if PROGRESS_POPUP_SHOW
+ // remove popup if created
+ if (ad->pop_progress) {
+ evas_object_del(ad->pop_progress);
+ ad->pop_progress = NULL;
+ }
+
+ // create new popup
+ ad->pop_progress =
+ setting_create_popup_with_progressbar(ad, ad->win_get, "pending_list",
+ NULL, NULL, NULL, 0, TRUE, TRUE);
+#endif
+
+ // invoke API to change time
+ int ret = sysman_set_datetime(the_time);
+
+ if (ad->update_timer) {
+ ecore_timer_thaw(ad->update_timer);
+ }
+
+ setting_retm_if(ret == -1, "sysman_set_datetime call failed");
+
+ SETTING_TRACE_END;
+}
+
+Eina_Bool __refresh_date_timer(void *data)
+{
+ //SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = data;
+ if (ad->data_time) {
+ time_t ctime = time(NULL);
+ struct tm ts_ret;
+ struct tm *ts = localtime_r(&ctime, &ts_ret);
+ retv_if(!ts, 1);
+
+ 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);
+ }
+ }
+ return 1;
+}
+
+static void __setting_time_main_exp_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ ret_if(NULL == data || NULL == event_info);
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+ Elm_Object_Item *parentItem = event_info; /* parent item */
+ Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
+ Evas_Object *scroller = elm_object_item_widget_get(parentItem);
+
+ Evas_Object *rgd;
+ if (data_parentItem == ad->data_time_fmt) {
+
+ rgd = elm_radio_add(scroller);
+ elm_radio_value_set(rgd, -1);
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ VCONFKEY_TIME_FORMAT_12,
+ "IDS_COM_BODY_12_HOURS",
+ NULL);
+
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ VCONFKEY_TIME_FORMAT_24,
+ "IDS_ST_BODY_24_HOURS",
+ NULL);
+
+ setting_update_chk_status(rgd,
+ data_parentItem->int_slp_setting_binded);
+
+ } else if (data_parentItem == ad->data_date_fmt) {
+ rgd = elm_radio_add(scroller);
+ elm_radio_value_set(rgd, -1);
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_DATE_FORMAT_DD_MM_YYYY,
+ "IDS_ST_BODY_DDMMYYYY_DOT",
+ NULL);
+
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_DATE_FORMAT_MM_DD_YYYY,
+ "IDS_ST_BODY_MM_DD_YYYY_DOT",
+ NULL);
+
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_DATE_FORMAT_YYYY_MM_DD,
+ "IDS_COM_BODY_YYYYMMDD",
+ NULL);
+
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, NULL, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_DATE_FORMAT_YYYY_DD_MM,
+ "IDS_ST_BODY_YYYY_DD_MM_DOT",
+ NULL);
+
+ setting_update_chk_status(rgd,
+ data_parentItem->int_slp_setting_binded);
+
+ } else if (data_parentItem == ad->data_firstday_week_fmt) {
+ rgd = elm_radio_add(scroller);
+ elm_radio_value_set(rgd, -1);
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, rgd, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_WEEKOFDAY_FORMAT_SUNDAY,
+ "IDS_ST_BODY_SUNDAY", NULL);
+
+ setting_create_Gendial_exp_sub_field(scroller,
+ &(ad->itc_1icon_1text_sub),
+ NULL, rgd, parentItem,
+ SWALLOW_Type_1RADIO, rgd,
+ SETTING_WEEKOFDAY_FORMAT_MONDAY,
+ "IDS_ST_BODY_MONDAY", NULL);
+
+ setting_update_chk_status(rgd,
+ data_parentItem->int_slp_setting_binded);
+ }
+}
+
+/**
+ * layyout create - remove a conformant
+ */
+Evas_Object *setting_create_win_layout2(Evas_Object *win_layout,
+ Evas_Object *win_obj)
+{
+ Evas_Object *layout = NULL;
+ //Evas_Object *conform = elm_conformant_add(win_obj);
+ /* Base Layout */
+ layout = elm_layout_add(win_obj);
+ setting_retvm_if(layout == NULL, FALSE, "layout == NULL");
+
+ elm_layout_theme_set(layout, "layout", "application", "default");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ //elm_win_resize_object_add(win_obj, layout);
+ //elm_win_resize_object_add(win_obj, conform);
+ //elm_object_content_set(conform, layout);
+
+ Evas_Object *bg = setting_create_bg(layout, win_obj, "group_list");
+ elm_object_part_content_set(layout, "elm.swallow.bg", bg);
+ evas_object_show(layout);
+ //evas_object_show(conform);
+ return layout;
+}
+
+
+
+Evas_Object *setting_create_layout_navi_bar2(Evas_Object *win_layout,
+ Evas_Object *win_obj,
+ char *title_str,
+ char *lbutton_str, char *rbutton_str, char *mbutton_str,
+ setting_call_back_func lbutton_click_cb, setting_call_back_func rbutton_click_cb,
+ setting_call_back_func mbutton_click_cb,
+ void *cb_data, Evas_Object *eo_view, /*any container obj constructed on any evas obj */
+ Evas_Object **navi_bar,
+ Evas_Object **titleobj)
+{
+
+ Evas_Object *layout = setting_create_win_layout2(win_layout, win_obj);
+ *navi_bar = setting_create_navi_bar(layout);
+
+ setting_create_navi_bar_buttons(title_str,
+ lbutton_str, rbutton_str, mbutton_str,
+ lbutton_click_cb, rbutton_click_cb,
+ mbutton_click_cb, cb_data, eo_view /*content */ ,
+ *navi_bar, NULL);
+ return layout;
+}
+
+static int setting_time_main_create(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+
+ char *l_btn = NULL;
+ char *r_btn = NULL;
+ char *title = _("IDS_ST_BODY_DATE_AND_TIME");
+ char *caller = NULL;
+ ad->is_datefield_selected = EINA_FALSE;
+
+ setting_call_back_func l_button_cb = NULL;
+ setting_call_back_func r_button_cb = NULL;
+
+ service_h service = ad->bundle_data;
+
+ service_get_extra_data(service, "caller", &caller);
+ service_get_extra_data(service, "lbutton", &l_btn);
+ if(l_btn)
+ l_button_cb = setting_time_main_click_softkey_caller_exist_left_cb;
+ service_get_extra_data(service, "title", &title);
+ service_get_extra_data(service, "rbutton", &r_btn);
+ if(r_btn)
+ r_button_cb = setting_time_main_click_softkey_caller_exist_right_cb;
+
+ Evas_Object *scroller; /* scroller is a genlist */
+
+ ad->caller = caller;
+ if (ad->caller) {
+ /* for setup wizard */
+ char *lbtn_str = (char *)g_strdup(l_btn);
+ bool same_flag = FALSE;
+ if (0 == safeStrCmp(l_btn, _("IDS_COM_BODY_BACK"))) {
+ l_btn = (char *)dgettext("sys_string", "IDS_COM_BODY_BACK");
+ same_flag = TRUE;
+ }
+
+ //Evas_Object *controllbar = NULL;
+
+ scroller = elm_genlist_add(ad->win_main_layout);
+ elm_object_style_set(scroller, "dialogue");
+ if(scroller == NULL) {
+ SETTING_TRACE_ERROR("Cannot set scroller object as contento of layout");
+ // free allocated data before return.
+ FREE(lbtn_str);
+ return SETTING_DRAW_ERR_FAIL_SCROLLER;
+ }
+
+ elm_genlist_clear(scroller);
+ ad->ly_main =
+ setting_create_layout_navi_bar2(ad->win_main_layout,
+ ad->win_get,
+ title,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ ad, scroller,
+ &ad->navi_bar,
+ NULL);
+ /* left button */
+ Evas_Object *lbtn_obj = elm_button_add(ad->win_main_layout);
+ if(lbtn_obj == NULL)
+ return SETTING_DRAW_ERR_FAIL_SCROLLER;
+
+ Evas_Object *licon_obj = elm_icon_add(ad->win_main_layout);
+ if(licon_obj == NULL)
+ return SETTING_DRAW_ERR_FAIL_SCROLLER;
+ elm_icon_file_set(licon_obj, IMG_PREVIOUS, NULL);
+
+ elm_object_style_set(lbtn_obj, "naviframe/toolbar/default");
+ elm_object_text_set(lbtn_obj, l_btn);
+ elm_object_part_content_set(lbtn_obj, "elm.swallow.content", licon_obj);
+ evas_object_smart_callback_add(lbtn_obj, "clicked", l_button_cb, ad);
+
+ /* right button */
+ Evas_Object *rbtn_obj = elm_button_add(ad->win_main_layout);
+ if(rbtn_obj == NULL)
+ return SETTING_DRAW_ERR_FAIL_SCROLLER;
+
+ Evas_Object *ricon_obj = elm_icon_add(ad->win_main_layout);
+ if(ricon_obj == NULL)
+ return SETTING_DRAW_ERR_FAIL_SCROLLER;
+ elm_icon_file_set(ricon_obj, IMG_NEXT, NULL);
+
+ elm_object_style_set(rbtn_obj, "naviframe/toolbar/default");
+ elm_object_text_set(rbtn_obj, r_btn);
+ elm_object_part_content_set(rbtn_obj, "elm.swallow.content", ricon_obj);
+ evas_object_smart_callback_add(rbtn_obj, "clicked", r_button_cb, ad);
+
+ Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
+ if(navi_it)
+ {
+ elm_object_item_part_content_set(navi_it, "toolbar_button1", lbtn_obj);
+ elm_object_item_part_content_set(navi_it, "toolbar_button2", rbtn_obj);
+ }
+ } else {
+ l_btn = _("IDS_COM_BODY_BACK");
+ title = _("IDS_ST_BODY_DATE_AND_TIME");
+ ad->ly_main =
+ setting_create_layout_navi_bar_genlist(ad->win_main_layout,
+ ad->win_get, title,
+ l_btn, NULL,
+ setting_time_main_click_softkey_left_cb,
+ NULL, ad, &scroller,
+ &ad->navi_bar);
+ }
+ ad->scrl_main = scroller;
+
+ int value;
+ int err;
+ int ret = 0;
+ Elm_Object_Item *item;
+
+ item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ setting_get_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE, &value,
+ &err);
+ bool auto_flag = value;
+
+ if(auto_flag) //do special process only when auto mode
+ {
+ //to read TAPI vconfs
+ 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))
+ {
+ //1.to update timezone
+ 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.");
+ } else
+ SETTING_TRACE("sysman_set_timezone - successful : %s \n", tz_path);
+ if (!__setting_set_city_tzone(tzpath)) {
+ SETTING_TRACE("__setting_set_city_tzone ERROR")
+ }
+ 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);
+
+ // 2.to set current time
+ int t_uptime = 0;
+ FILE *fp = fopen("/proc/uptime", "r");
+ if (fp) {
+ if (!fscanf(fp, "%d", &t_uptime)) {
+ SETTING_TRACE_ERROR("fscanf error");
+ }
+ fclose(fp);
+ fp = NULL;
+ } else {
+ SETTING_TRACE_ERROR("fopen error");
+ }
+
+ 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);
+ }
+ }
+
+ /* UI automatic */
+ if (!isEmulBin()) {
+ ad->data_auto =
+ setting_create_Gendial_field_def(scroller, &(ad->itc_1text_1icon),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_1TOGGLE, NULL,
+ NULL, value,
+ "IDS_ST_BODY_AUTOMATIC_UPDATE", NULL,
+ setting_time_main_chk_btn_cb);
+ if (ad->data_auto) {
+ ad->data_auto->userdata = ad;
+ } else {
+ SETTING_TRACE_ERROR("ad->data_auto is NULL");
+ }
+
+ setting_create_Gendial_field_def(scroller, &itc_multiline_text, NULL,
+ ad, SWALLOW_Type_LAYOUT_SPECIALIZTION_X,
+ NULL, NULL, 0, SETTING_TIME_AUTO_UPDATE_DESC, NULL,
+ NULL);
+ elm_genlist_item_select_mode_set(elm_genlist_item_append(scroller, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL),
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+
+ setting_set_i18n("worldclock", SETTING_TIME_SHARE_LOCAL_PATH);
+
+ char time_zone_sub_str[CITY_BUF_SIZE + GMT_BUF_SIZE + 3] = { 0, };
+ char *pa_timezone = NULL;
+ char *pa_city = NULL;
+
+ pa_city = vconf_get_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT); // IDS_WCL_BODY_CITYNAME_SEOUL
+ pa_timezone = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_INT); // "Asia/Seoul"
+
+ if ((pa_timezone != NULL) && (_(pa_city) != NULL)) {
+
+ // don't use hard coded value
+ // get value from current timezone
+
+ char str_buf[GMT_BUF_SIZE] = {0, };
+ get_gmt_offset(str_buf, GMT_BUF_SIZE);
+
+ char* timezone_str = get_timezone_str();
+
+ //ret = get_city_name(timezone_str);
+ //if (ret) {
+ // SETTING_TRACE(">>>>>> RESULT : %s", get_city_name_result());
+ //}
+ //char* cityname_id = _(get_city_name_result());
+ SETTING_TRACE("timezone : %s, cityname_id :%s", timezone_str, pa_city);
+ if (pa_city && 0 != safeStrCmp(_(pa_city), "NULL"))
+ ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT %s", _(pa_city), _(str_buf));
+ else
+ ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT +09", _("IDS_WCL_BODY_CITYNAME_SEOUL"));
+
+ FREE(pa_city);
+ FREE(pa_timezone);
+ retv_if(ret < 0, 0);
+ } else {
+ // default code
+ ret = snprintf(time_zone_sub_str, CITY_BUF_SIZE + GMT_BUF_SIZE + 2, "%s, GMT +09", _("IDS_WCL_BODY_CITYNAME_SEOUL"));
+ retv_if(ret < 0, 0);
+ }
+
+ /* UI create time zone */
+ ad->data_tz =
+ setting_create_Gendial_field_def(scroller, &(ad->itc_2text_2),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_INVALID, NULL,
+ NULL, 0, "IDS_ST_BODY_TIME_ZONE",
+ time_zone_sub_str, NULL);
+ if (ad->data_tz) {
+ ad->data_tz->userdata = ad;
+ } else {
+ SETTING_TRACE_ERROR("ad->data_tz is NULL");
+ }
+
+ /* create DATE_AND_TIME */
+ /* DATE_AND_TIME */
+ ret =
+ setting_get_int_slp_key(INT_SLP_SETTING_REGIONFORMAT_TIME1224,
+ &value, &err);
+ if (ret == SETTING_RETURN_FAIL) {
+ value = VCONFKEY_TIME_FORMAT_12;
+ }
+ bool is_12hours = (value == VCONFKEY_TIME_FORMAT_12 ? TRUE : FALSE);
+ char *date_format_str[] = { "%d %b %Y", "%b %d %Y", "%Y %b %d", "%Y %d %b" };
+ ret =
+ setting_get_int_slp_key(INT_SLP_SETTING_DATE_FORMAT, &value, &err);
+ if (ret == SETTING_RETURN_FAIL)
+ value = SETTING_DATE_FORMAT_DD_MM_YYYY;
+
+ /* UI format string */
+ (void)setting_create_Gendial_field_titleItem(scroller,
+ &(itc_group_item),
+ "IDS_ST_BODY_DATE_AND_TIME", NULL);
+ ad->data_time =
+ setting_create_Gendial_field_def(scroller, &(ad->itc_layout),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_LAYOUT_DATEFIELD,
+ NULL, NULL, is_12hours,
+ NULL,//"IDS_ST_BODY_DATE_AND_TIME",
+ date_format_str[value],
+ setting_time_main_datefield_change_cb);
+ if (ad->data_time) {
+ ad->data_time->userdata = ad;
+ ad->data_time->isItemDisableFlag = auto_flag;
+ elm_genlist_item_select_mode_set(ad->data_time->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ } else {
+ SETTING_TRACE_ERROR("ad->data_time is NULL");
+ }
+ item = elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ /* UI create "Time format" */
+ setting_enable_expandable_genlist(scroller, ad,
+ __setting_time_main_exp_cb, NULL);
+
+ char* pa_time_format = get_pa_time_format_str();
+ ad->data_time_fmt = setting_create_Gendial_exp_parent_field(scroller,
+ &(ad->itc_2text_3_parent),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_INVALID,
+ "IDS_ST_BODY_TIME_FORMAT",
+ pa_time_format);
+ if (ad->data_time_fmt) {
+ ad->data_time_fmt->int_slp_setting_binded =
+ INT_SLP_SETTING_REGIONFORMAT_TIME1224;
+ } else {
+ SETTING_TRACE_ERROR("ad->data_time_fmt is NULL");
+ }
+ G_FREE(pa_time_format);
+
+#if APPLIED_DATATIME_DATA_FORMAT
+ char* pa_date_format = get_pa_date_format_str();
+ ad->data_date_fmt = setting_create_Gendial_exp_parent_field(scroller,
+ &(ad->itc_2text_3_parent),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_INVALID,
+ "IDS_ST_BODY_DATE_FORMAT",
+ pa_time_format);
+ if (ad->data_date_fmt) {
+ ad->data_date_fmt->int_slp_setting_binded =
+ INT_SLP_SETTING_DATE_FORMAT;
+ } else {
+ SETTING_TRACE_ERROR("ad->data_date_fmt is NULL");
+ }
+ G_FREE(pa_date_format);
+#endif
+
+#if APPLIED_DATATIME_FIRSTDAY_WEEK
+ char* pa_week = get_pa_week_format_str();
+ ad->data_firstday_week_fmt =
+ setting_create_Gendial_exp_parent_field(scroller,
+ &(ad->itc_2text_3_parent),
+ setting_time_main_mouse_up_Gendial_list_cb,
+ ad, SWALLOW_Type_INVALID,
+ "IDS_CLD_BODY_FIRST_DAY_OF_WEEK",
+ pa_week);
+ if (ad->data_firstday_week_fmt) {
+ ad->data_firstday_week_fmt->int_slp_setting_binded =
+ INT_SLP_SETTING_WEEK_FORMAT;
+ } else {
+ SETTING_TRACE_ERROR("ad->data_firstday_week_fmt is NULL");
+ }
+ G_FREE(pa_week);
+#endif
+
+ item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ if (auto_flag)
+ {
+ if (ad->data_tz) {
+ setting_disable_genlist_item(ad->data_tz->item);
+ }
+ if (ad->data_time) {
+ setting_disable_genlist_item(ad->data_time->item);
+ }
+ }
+
+ setting_view_time_main.is_create = 1;
+ vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, time_changed_callback, (void *)ad);
+
+ /* register vconf key to get event callback for converting 12/24H */
+ vconf_notify_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, setting_time_main_int_vconf_change_cb, ad);
+ /* register vconf key to get event callback for date format */
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_DATE_FORMAT_INT, setting_time_main_int_vconf_change_cb, ad);
+
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_GMT, __sim_time_info_chg_cb, ad);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT, __sim_time_info_chg_cb, ad);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_ZONE, __sim_time_info_chg_cb, ad);
+
+ /* to avoid update time-diff, every per 3s to update. */
+ ad->update_timer = ecore_timer_add(3, (Ecore_Task_Cb) __refresh_date_timer, ad);
+
+ return SETTING_RETURN_SUCCESS;
+}
+
+static int setting_time_main_destroy(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+
+ if (ad->update_timer) {
+ ecore_timer_del(ad->update_timer);
+ ad->update_timer = NULL;
+ }
+
+#if PROGRESS_POPUP_SHOW
+ if (ad->pop_progress) {
+ evas_object_del(ad->pop_progress);
+ ad->pop_progress = NULL;
+ }
+#endif
+
+ if (ad->update_timezone_idler) {
+ ecore_idler_del(ad->update_timezone_idler);
+ ad->update_timezone_idler = NULL;
+ }
+ if (ad->refresh_time_idler) {
+ ecore_idler_del(ad->refresh_time_idler);
+ ad->refresh_time_idler = NULL;
+ }
+
+ vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED,
+ time_changed_callback);
+
+ vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT_TIME1224,
+ setting_time_main_int_vconf_change_cb);
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_DATE_FORMAT_INT,
+ setting_time_main_int_vconf_change_cb);
+
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_NITZ_GMT, __sim_time_info_chg_cb);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT, __sim_time_info_chg_cb);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_NITZ_ZONE, __sim_time_info_chg_cb);
+
+ if (ad->ly_main != NULL) {
+ evas_object_del(ad->ly_main);
+ setting_view_time_main.is_create = 0;
+ }
+
+ return SETTING_RETURN_SUCCESS;
+}
+
+static int setting_time_main_update(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
+
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+
+ if (ad->ly_main != NULL) {
+ evas_object_show(ad->ly_main);
+ // 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);
+ }
+ return SETTING_RETURN_SUCCESS;
+}
+
+static int setting_time_main_cleanup(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ return SETTING_RETURN_SUCCESS;
+}
+
+
+/* ***************************************************
+ **
+ **general func
+ **
+ ****************************************************/
+
+int setting_time_check_automatic_time_update_state()
+{
+ SETTING_TRACE_BEGIN;
+ int bvalue = 0;
+ int ret = 0;
+ int err = 0;
+
+ ret =
+ setting_get_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ &bvalue, &err);
+
+ return bvalue;
+
+}
+
+static int __setting_set_city_tzone(const char* pTZPath)
+{
+ // let's get city & timezone string from pTZPath
+ // 1. city name
+ char szTimezone[GMT_BUF_SIZE] = {0,};
+ char* pStr = strdup(pTZPath);
+
+ // 2. timezone string +/-<n> ex. +9, -1
+ get_gmt_offset(szTimezone, GMT_BUF_SIZE);
+
+ int ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, szTimezone);
+ if (ret == -1) {
+ FREE(pStr);
+ SETTING_TRACE("set vconf failed");
+ return FALSE;
+ }
+
+ // set timezone_id
+ /** @todo replace with vconf ID */
+ ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, pStr);
+ FREE(pStr);
+
+ return TRUE;
+}
+
+static void
+setting_time_main_launch_worldclock_result_ug_cb(ui_gadget_h ug,
+ service_h result, void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(priv == NULL, "Data parameter is NULL");
+
+ SettingTimeUG *ad = (SettingTimeUG *) priv;
+
+ char *city = NULL;
+ char *tzpath = NULL;
+ service_get_extra_data(result, "city", &city);
+ service_get_extra_data(result, "tzpath", &tzpath);
+
+ if (!tzpath) {
+ SETTING_TRACE("tzpath from worldclock UG is null.");
+ return;
+ } else {
+ SETTING_TRACE("tzpath : %s", tzpath );
+ }
+ SETTING_TRACE("city : %s", city );
+
+ /* --------------------------------------------------------------------- */
+ 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);
+
+ int 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);
+
+ ret = vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, city);
+ setting_retm_if(ret != 0, "set vconf failed");
+
+ // parse city and GMT offset from tzpath and system time property
+ // set the strings in vconf which will be used while updating display of timezone
+ if (!__setting_set_city_tzone(tzpath)) {
+ SETTING_TRACE("__setting_set_city_tzone ERROR")
+ return;
+ }
+
+ // update the display for timezone
+ setting_update_timezone(ad);
+ static int t_event_val = -1;
+ vconf_set_int (VCONFKEY_SYSTEM_TIME_CHANGED, t_event_val);
+ SETTING_TRACE_END;
+}
+
+void setting_time_main_launch_worldclock_destroy_ug_cb(ui_gadget_h ug,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ /* if(ug) ug_destroy(ug); */
+ /* restore the '<-' button on the navigate bar */
+ ret_if(!priv);
+ SettingTimeUG *ad = (SettingTimeUG *) priv;
+ if (ug) {
+ ug_destroy(ug);
+ ad->ug_loading = NULL;
+ }
+ Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->navi_bar);
+ ret_if(!navi_it);
+ Evas_Object *back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
+
+ if (back_btn != NULL) {
+ elm_object_style_set(back_btn, NAVI_BACK_BUTTON_STYLE); /* take into effect */
+ }
+
+}
+
+void setting_time_main_launch_worldclock_layout_ug_cb(ui_gadget_h ug,
+ enum ug_mode mode,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) priv;
+ Evas_Object *base;
+
+ if (!priv)
+ return;
+
+ base = (Evas_Object *) ug_get_layout(ug);
+ if (!base)
+ return;
+
+ switch (mode) {
+ case UG_MODE_FULLVIEW:
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ //elm_win_resize_object_add(ad->win_get, base);
+ evas_object_show(base);
+ break;
+ default:
+ break;
+ }
+ SETTING_TRACE_END;
+}
+
+
+void setting_time_main_launch_worldclock_sg(void *data)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(data == NULL, "Data parameter is NULL");
+
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+
+ struct ug_cbs *cbs = (struct ug_cbs *)calloc(1, sizeof(struct ug_cbs));
+ setting_retm_if(!cbs, "calloc failed");
+ cbs->layout_cb = setting_time_main_launch_worldclock_layout_ug_cb;
+ cbs->result_cb = setting_time_main_launch_worldclock_result_ug_cb;
+ cbs->destroy_cb = setting_time_main_launch_worldclock_destroy_ug_cb;
+ cbs->priv = (void *)ad;
+
+ SETTING_TRACE("to load ug[%s]", "worldclock-efl");
+ ad->ug_loading =
+ ug_create(ad->ug, "worldclock-efl", UG_MODE_FULLVIEW, NULL, cbs);
+ if (NULL == ad->ug_loading) { /* error handling */
+ }
+
+ FREE(cbs);
+ return;
+}
+
+
+Eina_Bool setting_update_datefield(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ retvm_if(cb == NULL, EINA_FALSE, "Data parameter is NULL");
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+
+ //__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;
+}
+
+/* ***************************************************
+ **
+ **call back func
+ **
+ ****************************************************/
+
+void
+setting_time_main_click_softkey_left_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ retm_if(data == NULL, "Data parameter is NULL");
+
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+
+ /* Send destroy request */
+ ug_destroy_me(ad->ug);
+}
+
+/* ***************************************************
+ **
+ **call back func
+ **
+ ****************************************************/
+
+void
+setting_time_main_click_softkey_caller_exist_left_cb(void *data,
+ Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(data == NULL, "Data parameter is NULL");
+
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+
+ /* Create Bundle and send message */
+ service_h svc;
+ if (service_create(&svc))
+ return;
+
+ service_add_extra_data(svc, "result", "lbutton_click");
+ ug_send_result(ad->ug, svc);
+
+ service_destroy(svc);
+
+ /* Send destroy request */
+ ug_destroy_me(ad->ug);
+}
+
+void
+setting_time_main_click_softkey_caller_exist_right_cb(void *data,
+ Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(data == NULL, "Data parameter is NULL");
+
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+
+ /* Create Bundle and send message */
+ service_h svc;
+ if (service_create(&svc))
+ return;
+
+ service_add_extra_data(svc, "result", "rbutton_click");
+ ug_send_result(ad->ug, svc);
+
+ service_destroy(svc);
+
+ /* Send destroy request */
+ ug_destroy_me(ad->ug);
+}
+
+#if UN_SUPPORT_TIME_DYNAMIC_UPDATE
+static void setting_time_reboot_resp_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ int response_type = btn_type(obj);
+ if (POPUP_RESPONSE_OK == response_type) {
+ setting_time_main_btn_update_ok_cb(data);
+ } else if (POPUP_RESPONSE_CANCEL == response_type) {
+ setting_time_main_btn_update_cancel_cb(data);
+ }
+
+ SettingTimeUG *ad = data;
+ if (ad->pop)
+ {
+ evas_object_del(ad->pop);
+ ad->pop = NULL;
+ }
+}
+#endif
+
+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);
+ }
+ __update_time_via_sim_card(ad);
+}
+
+static void
+setting_time_main_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ retm_if(data == NULL, "Data parameter is NULL");
+ SettingTimeUG *ad = NULL;
+ Setting_GenGroupItem_Data *list_item =
+ (Setting_GenGroupItem_Data *) data;
+ ad = list_item->userdata;
+ list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
+ if (ad->data_auto)
+ ad->chk_auto = ad->data_auto->eo_check;
+ if (ad->data_dst)
+ ad->chk_dst = ad->data_dst->eo_check;
+
+ if (ad->data_time) {
+ elm_object_focus_set(ad->data_time->eo_check, EINA_FALSE);
+ }
+
+ int err;
+ if (obj == ad->chk_auto) {
+ int bvalue;
+ setting_get_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ &bvalue, &err);
+ if (bvalue) {
+ (void) setting_set_bool_slp_key (BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE, SETTING_ON_OFF_BTN_OFF, &err);
+ elm_check_state_set(ad->chk_auto, 0);
+
+ if (ad->data_tz) {
+ setting_enable_genlist_item(ad->data_tz->item);
+ }
+
+ if (ad->data_time) {
+ ad->data_time->isItemDisableFlag = FALSE;
+ setting_enable_evas_object(ad->data_time->eo_check);
+ setting_enable_genlist_item(ad->data_time->item);
+ }
+
+ } else {
+#if UN_SUPPORT_TIME_DYNAMIC_UPDATE
+ ad->pop =
+ setting_create_popup_with_btn(ad, ad->win_get, NULL,
+ _("IDS_ST_POP_RESTART_PHONE_TO_USE_AUTOMATIC_UPDATE_Q"),
+ setting_time_reboot_resp_cb,
+ 0, 2,
+ dgettext("sys_string",
+ "IDS_COM_SK_OK"),
+ _("IDS_COM_SK_CANCEL"));
+#else
+ __time_auto_update(ad);
+#endif
+ }
+ }
+}
+static void setting_time_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ /* error check */
+ setting_retm_if(data == NULL, "Data parameter is NULL");
+
+ retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ elm_genlist_item_selected_set(item, 0);
+ Setting_GenGroupItem_Data *list_item =
+ (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
+
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+ SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
+
+ if (ad->data_time && ad->data_time != list_item) {
+ elm_object_focus_set(ad->data_time->eo_check, EINA_FALSE);
+ }
+
+ if (ad->data_tz == list_item) {
+ ad->is_datefield_selected = EINA_FALSE;
+ if (1 == setting_time_check_automatic_time_update_state()) {
+ setting_create_simple_popup(ad, ad->win_get,
+ NULL, _(AUTO_TIME_UPDATE_ON));
+ } else {
+ setting_time_main_launch_worldclock_sg(ad);
+ }
+
+ } else if (ad->data_time == list_item) {
+ ad->is_datefield_selected = EINA_TRUE;
+ if (1 == setting_time_check_automatic_time_update_state()) {
+ setting_create_simple_popup(ad, ad->win_get,
+ NULL, _(AUTO_TIME_UPDATE_ON));
+ } else {
+ /* setting_view_change(&setting_view_time_main, &setting_view_time_time, ad); */
+ }
+ } else if (ad->data_auto == list_item) {
+ ad->is_datefield_selected = EINA_FALSE;
+ int old_status = elm_check_state_get(list_item->eo_check);
+ /* new status */
+ list_item->chk_status = !old_status;
+ elm_check_state_set(list_item->eo_check, list_item->chk_status);
+ int err = 0;
+ if (!list_item->chk_status) {
+ (void)
+ setting_set_bool_slp_key
+ (BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ SETTING_ON_OFF_BTN_OFF, &err);
+
+ if (ad->data_tz) {
+ setting_enable_genlist_item(ad->data_tz->item);
+ }
+
+ if (ad->data_time) {
+ ad->data_time->isItemDisableFlag = FALSE;
+ setting_enable_evas_object(ad->data_time->eo_check);
+ setting_enable_genlist_item(ad->data_time->item);
+ }
+
+ } else {
+ #if UN_SUPPORT_TIME_DYNAMIC_UPDATE
+ ad->pop =
+ setting_create_popup_with_btn(ad, ad->win_get, NULL,
+ _("IDS_ST_POP_RESTART_PHONE_TO_USE_AUTOMATIC_UPDATE_Q"),
+ setting_time_reboot_resp_cb,
+ 0, 2,
+ dgettext("sys_string", "IDS_COM_SK_OK"),
+ _("IDS_COM_SK_CANCEL"));
+ #else
+ __time_auto_update(ad);
+ #endif
+ }
+
+ }
+ else if (ad->data_time_fmt == list_item
+ || ad->data_date_fmt == list_item
+ || ad->data_firstday_week_fmt == list_item) {
+ ad->is_datefield_selected = EINA_FALSE;
+ bool status = !elm_genlist_item_expanded_get(item);
+ elm_genlist_item_expanded_set(item, status);
+ }
+}
+
+
+void setting_time_main_btn_update_ok_cb(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+ int err; /* error check */
+ setting_set_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ SETTING_ON_OFF_BTN_ON, &err);
+ elm_check_state_set(ad->data_auto->eo_check, 1);
+ ad->data_auto->chk_status = 1;
+
+ sysman_request_reboot();
+
+ /* We'd better check return value from sysman_request_reboot() function. */
+ /* It will return 0 on success or -1 if failed. */
+}
+
+
+void setting_time_main_btn_update_cancel_cb(void *cb)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) cb;
+
+ int err; /* error check */
+
+ retm_if(cb == NULL, "Data parameter is NULL");
+ setting_set_bool_slp_key(BOOL_SLP_SETTING_AUTOMATIC_TIME_UPDATE,
+ SETTING_ON_OFF_BTN_OFF, &err);
+ elm_check_state_set(ad->data_auto->eo_check, 0);
+ ad->data_auto->chk_status = 0;
+
+}
+
+
+static UChar *uastrcpy(const char *chars)
+{
+ int len = 0;
+ UChar *str = NULL;
+ len = safeStrLen(chars);
+ str = (UChar *) malloc(sizeof(UChar) *(len + 1));
+ if (!str)
+ return NULL;
+ u_uastrcpy(str, chars);
+ return str;
+}
+
+
+static int get_timezone_isdst(int* isdst)
+{
+ SETTING_TRACE_BEGIN;
+ struct tm *ts;
+ time_t ctime;
+
+ enum { BUFFERSIZE = 1024 };
+ char buf[BUFFERSIZE];
+ ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
+
+ if (len != -1) {
+ buf[len] = '\0';
+ }
+ else {
+ /* handle error condition */
+ }
+
+ ctime = time(NULL);
+ ts = localtime(&ctime);
+ if ( ! ts ) {
+ return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
+ }
+
+ SETTING_TRACE(" == tz_path = %s", buf);
+ SETTING_TRACE(" == isdst = %d\n", ts->tm_isdst);
+ *isdst = ts->tm_isdst;
+
+ return SETTING_RETURN_SUCCESS;
+}
+
+
+static void ICU_set_timezone(const char *timezone)
+{
+ SETTING_TRACE("ICU_set_timezone = %s ", timezone);
+ UErrorCode ec = U_ZERO_ERROR;
+ UChar *str = uastrcpy(timezone);
+
+ ucal_setDefaultTimeZone(str, &ec);
+ if (U_SUCCESS(ec)) {
+ SETTING_TRACE("ucal_setDefaultTimeZone() SUCCESS ");
+ } else {
+ SETTING_TRACE("ucal_setDefaultTimeZone() FAILED : %s ",
+ u_errorName(ec));
+ }
+ FREE(str);
+}
+
+#if DISABLED_CODE
+static void setting_time_main_controlbar_lbtn_label_set(
+ Evas_Object *controlbar,
+ char *label)
+{
+ SETTING_TRACE_BEGIN;
+ setting_retm_if(controlbar == NULL, "controlbar parameter is NULL");
+ setting_retm_if(label == NULL, "label parameter is NULL");
+
+ Evas_Object *eo_lbtn = NULL;
+ Elm_Object_Item *first_item = NULL;
+
+ first_item = elm_toolbar_first_item_get(controlbar);
+ setting_retm_if(first_item == NULL, "get first_item failed");
+
+ eo_lbtn = elm_object_item_part_content_get(first_item, "object");
+ setting_retm_if(eo_lbtn == NULL, "get eo_lbtn failed");
+
+ elm_object_text_set(eo_lbtn, label);
+}
+#endif
+
+/**
+ * ex) timezone : Asia/Seoul --> returns "+09"
+ *
+ * char outstr2[4];
+ */
+static void get_gmt_offset(char *str_buf, int size)
+{
+ // timezone string +/-<n> ex. +9, -1
+ time_t t = time(0); // get unix time. sec.
+
+ struct tm* data;
+ data = localtime(&t); // save time as structure.
+ setting_retm_if(!data, "data is NULL");
+ data->tm_isdst = 0; // summer time, not applied.
+ time_t a = mktime(data);
+
+ data = gmtime(&a);
+ data->tm_isdst = 0; // summer time, not applied.
+ time_t b = mktime(data);
+
+ int gmtoffset_hour = (a-b)/3600; // result : hour.
+ int gmtoffset_min = ((a-b)%3600)/60; // result : min.
+ if(gmtoffset_min != 0) {
+ gmtoffset_min = 30;
+ }
+
+ snprintf(str_buf, size, "%+d:%02u", gmtoffset_hour, gmtoffset_min);
+ SETTING_TRACE("szTimezone is of a valid format: GMT: %s", str_buf);
+}
+
+
+// automatic
+static char* get_timezone_str()
+{
+ SETTING_TRACE_BEGIN;
+
+ enum { BUFFERSIZE = 1024 };
+ char buf[BUFFERSIZE];
+ ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
+
+ if (len != -1) {
+ buf[len] = '\0';
+ }
+ else {
+ /* handle error condition */
+ }
+ return g_strdup(buf+20); //Asia/Seoul
+}
+
+static char* get_city_name_result()
+{
+ return s_result;
+}
+
+
+// in_str = "Asia/Seoul"
+static bool get_city_name(char* tzname)
+{
+ sqlite3 *pSQLite3 = NULL;
+ char *szErrMsg = NULL;
+
+ int rst = sqlite3_open( "/opt/dbspace/.worldclock.db", &pSQLite3);
+ if ( rst )
+ {
+ printf( "Can't open database: %s\n", sqlite3_errmsg( pSQLite3 ));
+ sqlite3_close( pSQLite3 );
+ pSQLite3 = NULL;
+ return false;
+ }
+ else
+ {
+ printf("Database opened!!\n");
+ char query_str[256];
+ snprintf(query_str, 256, "SELECT city FROM city_table where tz_path=\"%s\"", tzname);
+ printf("%s \n", query_str);
+ rst = sqlite3_exec(pSQLite3, query_str, query_callback, 0, &szErrMsg);
+ }
+
+ //객체해제
+ sqlite3_free( szErrMsg );
+ sqlite3_close( pSQLite3 );
+ printf("Database close!!\n");
+ return true;
+}
+
+static int query_callback(void *NotUsed, int argc, char **argv, char **azColName)
+{
+ int i = 0;
+ printf("%s\n", argv[i] ? argv[i] : "NULL");
+ s_result = g_strdup(argv[i] ? argv[i] : "NULL");
+ return 0;
+};
+
+
+#if 0 /* example */
+int main(int argc, char* argv[])
+{
+ g_type_init ();
+ int ret;
+ // exporting - current status
+ if ( (argc == 2) && (0 == strcmp(argv[1], "export"))) {
+ setting_export();
+ }
+ else if ( (argc == 2) && (0 == strcmp(argv[1], "timezone_init"))) {
+
+ //////////////////////////////////////////////////////////////////////////
+ char* tz_path_zone_city = get_timezone_str();
+ bool ret = get_city_name(tz_path_zone_city);
+ if (ret) {
+ printf(">>>>>> RESULT : %s \n", get_city_name_result());
+ }
+ //////////////////////////////////////////////////////////////////////////
+ }
+ else {
+ // cfg create
+ // TRUE or FALSE
+ ret = setting_cfg_create();
+ }
+ return 0;
+}
+#endif
+
+
+
diff --git a/setting-time/src/setting-time.c b/setting-time/src/setting-time.c
new file mode 100755
index 0000000..a6c0642
--- /dev/null
+++ b/setting-time/src/setting-time.c
@@ -0,0 +1,296 @@
+/*
+ * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *@defgroup setting-datetime
+ *UG creation code for setting-datetime
+ *
+ * - Automatic update
+ * - Time zone
+ * - Date and time (elm_datefield)
+ * - Time format (12H/24H)
+ * - First day of week
+ */
+#include <setting-time.h>
+#ifndef UG_MODULE_API
+#define UG_MODULE_API __attribute__ ((visibility("default")))
+#endif
+
+/**
+* @callback handler for EVAS_CALLBACK_RESIZE
+*
+* @param data user data (SettingTimeUG *)
+*/
+static void setting_time_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) data;
+ setting_view_update(&setting_view_time_main, ad);
+}
+
+/**
+* @callback function called first while loading setting-time UG.
+*
+* @param ug ug object itself.
+* @param mode
+* @param data bundle (key, value pair) data as arguments into UG.
+* @param priv SettingTimeUG context
+*
+* @return
+*/
+static void *setting_time_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
+ service_h service, void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ setting_retvm_if((!priv), NULL, "!priv");
+
+ SettingTimeUG *timeUG = priv;
+ timeUG->ug = ug;
+ timeUG->bundle_data = service;
+ timeUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
+ timeUG->win_get = (Evas_Object *) ug_get_window();
+ evas_object_show(timeUG->win_main_layout);
+ timeUG->evas = evas_object_evas_get(timeUG->win_main_layout);
+
+ timeUG->pop_progress = NULL;
+ /* Initialize Caller value */
+ timeUG->caller = NULL;
+
+ setting_retvm_if(timeUG->win_main_layout == NULL, NULL, "cannot get main window ");
+
+ /* --------------------------------------------------------- */
+ char *pa_path = NULL;;
+
+ pa_path = vconf_get_str(VCONFKEY_LANGSET);
+ if (!pa_path) {
+ SETTING_TRACE ("%s*** language setting has no proper value (nil) ***%s", SETTING_FONT_BGREEN, SETTING_FONT_BLACK);
+ return NULL;
+ }
+
+ /* set launguage */
+ setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
+
+ /* register view node table */
+ setting_view_node_table_intialize();
+ setting_view_node_table_register(&setting_view_time_main, NULL);
+
+ setting_create_Gendial_itc("dialogue/2text.3", &(timeUG->itc_2text_2));
+ setting_create_Gendial_itc("dialogue/1text.1icon",
+ &(timeUG->itc_1text_1icon));
+
+ setting_create_Gendial_itc("dialogue/1icon", &(timeUG->itc_layout));
+
+ setting_create_Gendial_itc("dialogue/2text.3/expandable",
+ &(timeUG->itc_2text_3_parent));
+ setting_create_Gendial_itc("dialogue/1text.1icon/expandable2",
+ &(timeUG->itc_1icon_1text_sub));
+
+ timeUG->itc_seperator.item_style = "dialogue/separator";
+ timeUG->itc_seperator.func.text_get = NULL;
+ timeUG->itc_seperator.func.content_get = NULL;
+ timeUG->itc_seperator.func.state_get = NULL;
+ timeUG->itc_seperator.func.del = NULL;
+
+ /* creating a view. */
+ setting_view_node_set_cur_view(&setting_view_time_main);
+ setting_view_create(&setting_view_time_main, (void *)timeUG);
+ evas_object_event_callback_add(timeUG->win_main_layout,
+ EVAS_CALLBACK_RESIZE,
+ setting_time_ug_cb_resize, timeUG);
+ return timeUG->ly_main;
+}
+
+static void setting_time_ug_on_start(ui_gadget_h ug, service_h service,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ /* do nothing */
+}
+
+static void setting_time_ug_on_pause(ui_gadget_h ug, service_h service,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ /* do nothing */
+}
+
+static void setting_time_ug_on_resume(ui_gadget_h ug, service_h service,
+ void *priv)
+{
+ /* do nothing */
+}
+
+static void setting_time_ug_on_destroy(ui_gadget_h ug, service_h service,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ setting_retm_if((!priv), "!priv");
+ SettingTimeUG *timeUG = priv;
+
+ evas_object_event_callback_del(timeUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_time_ug_cb_resize); /* fix flash issue for gallery */
+ timeUG->ug = ug;
+
+ /* delete the allocated objects. */
+ setting_view_destroy(&setting_view_time_main, timeUG);
+
+ if (NULL != ug_get_layout(timeUG->ug)) {
+ evas_object_hide((Evas_Object *) ug_get_layout(timeUG->ug));
+ evas_object_del((Evas_Object *) ug_get_layout(timeUG->ug));
+ }
+
+ SETTING_TRACE_END;
+}
+
+static void setting_time_ug_on_message(ui_gadget_h ug, service_h msg,
+ service_h service, void *priv)
+{
+ SETTING_TRACE_BEGIN;
+}
+
+static void setting_time_ug_on_event(ui_gadget_h ug, enum ug_event event,
+ service_h service, void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ switch (event) {
+ case UG_EVENT_LOW_MEMORY:
+ break;
+ case UG_EVENT_LOW_BATTERY:
+ break;
+ case UG_EVENT_LANG_CHANGE:
+ break;
+ case UG_EVENT_ROTATE_PORTRAIT:
+ break;
+ case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
+ break;
+ case UG_EVENT_ROTATE_LANDSCAPE:
+ break;
+ case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
+ break;
+ case UG_EVENT_REGION_CHANGE:
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* @brief key event handler for UG
+*/
+static void setting_time_ug_on_key_event(ui_gadget_h ug,
+ enum ug_key_event event, service_h service,
+ void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *ad = (SettingTimeUG *) priv;
+
+ switch (event) {
+ case UG_KEY_EVENT_END:
+ {
+ if (0 == safeStrCmp(ad->caller, "pwlock")) {
+ /* Create Bundle and send message */
+
+ service_h svc;
+ if (service_create(&svc))
+ return;
+
+ service_add_extra_data(svc, "result", "lbutton_click");
+ ug_send_result(ad->ug, svc);
+
+ service_destroy(svc);
+ }
+
+ if (elm_naviframe_top_item_get(ad->navi_bar) ==
+ elm_naviframe_bottom_item_get(ad->navi_bar)) {
+ ug_destroy_me(ug);
+ } else {
+ /* elm_naviframe_item_pop(ad->navi_bar); */
+ setting_view_cb_at_endKey(ad);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* @brief UG entry point - create the SettingTimeUG context
+* @return 0
+*/
+UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ SETTING_TRACE_BEGIN;
+ SettingTimeUG *timeUG = calloc(1, sizeof(SettingTimeUG));
+ setting_retvm_if(!timeUG, -1, "Create SettingTimeUG obj failed");
+
+ ops->create = setting_time_ug_on_create;
+ ops->start = setting_time_ug_on_start;
+ ops->pause = setting_time_ug_on_pause;
+ ops->resume = setting_time_ug_on_resume;
+ ops->destroy = setting_time_ug_on_destroy;
+ ops->message = setting_time_ug_on_message;
+ ops->event = setting_time_ug_on_event;
+ ops->key_event = setting_time_ug_on_key_event;
+ ops->priv = timeUG;
+ ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+ return 0;
+}
+
+/**
+* @brief UG finalizer - destroy the SettingTimeUG context
+*/
+UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ SETTING_TRACE_BEGIN;
+ struct SettingTimeUG *timeUG;
+ setting_retm_if(!ops, "ops == NULL");
+
+ timeUG = ops->priv;
+ if (timeUG)
+ FREE(timeUG);
+}
+
+/**
+* Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
+*/
+UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
+{
+ SETTING_TRACE_BEGIN;
+ int ret = 0;
+#if SUPPORT_RUN_SYSTEM_COMMAND
+ ret += excuteCmd(SETTING_POSTINST_FILE, 1, "timeAndData");
+#else
+ if (!isEmulBin()) {
+ ret += vconf_set_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, TRUE);
+ }
+
+ ret += vconf_set_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12);
+ ret += vconf_set_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, SETTING_DATE_FORMAT_DD_MM_YYYY);
+ ret += vconf_set_int(VCONFKEY_SETAPPL_WEEKOFDAY_FORMAT_INT, SETTING_WEEKOFDAY_FORMAT_SUNDAY);
+
+ ret += vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, "+9");
+ ret += vconf_set_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT, "IDS_WCL_BODY_CITYNAME_SEOUL");
+
+ /** @todo replace with vconf ID */
+ ret += vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, "Asia/Seoul");
+
+#endif
+ return ret;
+}
+