From: MyoungJune Park Date: Mon, 16 May 2016 13:43:42 +0000 (+0900) Subject: Add Timezone set/notifiers X-Git-Tag: accepted/tizen/common/20160617.121108^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=314208b5e804ff0e250c2c73244378ece8609ffc;p=platform%2Fcore%2Fapi%2Fsystem-settings.git Add Timezone set/notifiers Change-Id: I0313a6369ac69fa83aa9a296931c3872e500ddf5 Signed-off-by: MyoungJune Park --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 56626ff..4984697 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,13 +14,10 @@ SET(LIBDIR "${CMAKE_LIBDIR}") SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(requires "dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info") +SET(requires "dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info alarm-service") SET(pc_requires "capi-base-common") - - - IF(TIZEN_WEARABLE) ADD_DEFINITIONS(-DTIZEN_WEARABLE) ENDIF(TIZEN_WEARABLE) diff --git a/include/system_settings_private.h b/include/system_settings_private.h index 3d11344..80734e7 100644 --- a/include/system_settings_private.h +++ b/include/system_settings_private.h @@ -815,6 +815,39 @@ int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settin * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error */ int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value); + +/** + * @internal + * @since_tizen 3.0 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value); + +/** + * @internal + * @since_tizen 3.0 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); + +/** + * @internal + * @since_tizen 3.0 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key); + + + /** * @internal * @since_tizen 2.3 diff --git a/packaging/capi-system-system-settings.spec b/packaging/capi-system-system-settings.spec index c7f5fd8..66efd50 100755 --- a/packaging/capi-system-system-settings.spec +++ b/packaging/capi-system-system-settings.spec @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(alarm-service) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c index 87d7710..3a0652e 100644 --- a/src/system_setting_platform.c +++ b/src/system_setting_platform.c @@ -1273,24 +1273,43 @@ int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settin int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value) { SETTING_TRACE_BEGIN; -#if 0 - char tzpath[256]; - ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1); - if (len != -1) { - tzpath[len] = '\0'; - } else { - SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH"); - return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - /* "/usr/share/zoneinfo/Asia/Seoul" */ - SETTING_TRACE("tzpath : %s ", &tzpath[20]); - *value = strdup(&tzpath[20]); -#else *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID); -#endif return SYSTEM_SETTINGS_ERROR_NONE; } +int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +{ + SETTING_TRACE_BEGIN; + char *vconf_value = NULL; + vconf_value = (char *)value; + + char tz_path[1024]; + sprintf( tz_path, "/usr/share/zoneinfo/%s", vconf_value); + + int is_load = _is_file_accessible(tz_path); + if (is_load == 0) { + int ret = alarmmgr_set_timezone(tz_path); + + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; + } + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; +} + + + +int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data); +} + +int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4); +} + int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) { SETTING_TRACE_BEGIN; diff --git a/src/system_settings.c b/src/system_settings.c index dfc432e..a93187e 100644 --- a/src/system_settings.c +++ b/src/system_settings.c @@ -189,9 +189,9 @@ system_setting_s system_setting_table[] = { SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, SYSTEM_SETTING_DATA_TYPE_STRING, system_setting_get_locale_timezone, - NULL, - NULL, - NULL, + system_setting_set_locale_timezone, + system_setting_set_changed_callback_locale_timezone, + system_setting_unset_changed_callback_locale_timezone, NULL, NULL /* user data */ },