From 8d8863af139af28941f143fde05ec958b0612da9 Mon Sep 17 00:00:00 2001 From: MyoungJune Park Date: Fri, 7 Oct 2016 20:18:39 +0900 Subject: [PATCH] add SYSTEM_SETTINGS_KEY_ADS_ID key - append Since 3.0 as adviced Change-Id: I87559316d648eaecef79da171076df766773c30a Signed-off-by: MyoungJune Park --- CMakeLists.txt | 2 +- include/system_settings.h | 7 +--- include/system_settings_private.h | 41 +++++++++++++++++++ packaging/capi-system-system-settings.spec | 1 + src/system_setting_platform.c | 66 ++++++++++++++++++++++++++++++ src/system_settings.c | 10 +++++ 6 files changed, 120 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31eff6d..7aa94cf 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ SET(LIBDIR "${CMAKE_LIBDIR}") SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(requires "dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info alarm-service") +SET(requires "dlog vconf fontconfig libxml-2.0 pkgmgr pkgmgr-info alarm-service uuid") SET(pc_requires "capi-base-common") diff --git a/include/system_settings.h b/include/system_settings.h index da12fcc..4fee4a2 100644 --- a/include/system_settings.h +++ b/include/system_settings.h @@ -63,36 +63,31 @@ typedef enum { SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, /**< (string) The file path of the current lock screen wallpaper */ SYSTEM_SETTINGS_KEY_FONT_SIZE, /**< (int) The current system font size */ SYSTEM_SETTINGS_KEY_FONT_TYPE, /**< (string) The current system font type */ - SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, /**< (bool) Indicates whether the motion service is activated */ SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, /**< (string) The file path of the current email alert ringtone */ SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, /**< (bool) Indicates whether the USB debugging is enabled (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif) */ SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, /**< bool) Indicates whether the 3G data network is enabled (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif) */ SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP = SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED+2, /**< (string) Indicates lockscreen app pkg name */ - SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE,/**< (string) The current system default font type (only support Get) */ SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, /**< (string) Indicates the current country setting in the _ syntax. The country setting is in the ISO 639-2 format, and the region setting is in the ISO 3166-1 alpha-2 format */ SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, /**< (string) Indicates the current language setting in the _ syntax. The language setting is in the ISO 639-2 format and the region setting is in the ISO 3166-1 alpha-2 format. */ SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, /**< (bool) Indicates whether the 24-hour clock is used. If the value is @c false, the 12-hour clock is used. */ SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, /**< (string) Indicates the current time zone. */ - SYSTEM_SETTINGS_KEY_TIME_CHANGED, /**< (int) Once System changes time, this event occurs to notify time change. */ SYSTEM_SETTINGS_KEY_SOUND_LOCK, /**< GET (bool) Indicates whether the screen lock sound is enabled on the device. ex) LCD on/off sound */ SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, /**< GET (bool) Indicates whether the device is in the silent mode. */ SYSTEM_SETTINGS_KEY_SOUND_TOUCH, /**< GET (bool) Indicates whether the screen touch sound is enabled on the device. */ SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, /**< GET (bool) Indicates whether rotation control is automatic.*/ - SYSTEM_SETTINGS_KEY_DEVICE_NAME, /**< GET (string) Indicates device name. */ SYSTEM_SETTINGS_KEY_MOTION_ENABLED, /**< GET (bool) Indicates whether the device user has enabled the motion feature. */ SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, /**< GET (bool) Indicates whether Wi-Fi-related notifications are enabled on the device. */ SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, /**< GET (bool) Indicates whether the device is in the flight mode. */ SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, /**< (int) Indicates the backlight time (in seconds). @internal The following values can be used: 15, 30, 60, 120, 300, and 600. */ - SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, /**< (string) Indicates the file path of the current notification tone set by the user. */ SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, /**< (int) Indicates the time period for notification repetitions. */ SYSTEM_SETTINGS_KEY_LOCK_STATE, /**< (int) Indicates the current lock state */ + SYSTEM_SETTINGS_KEY_ADS_ID, /**< (string) Indicates Ads ID for each device (Since 3.0) */ SYSTEM_SETTINGS_KEY_MAX, - } system_settings_key_e; /** diff --git a/include/system_settings_private.h b/include/system_settings_private.h index 80734e7..1972e91 100644 --- a/include/system_settings_private.h +++ b/include/system_settings_private.h @@ -1272,6 +1272,47 @@ int system_setting_set_changed_callback_lock_state(system_settings_key_e key, sy */ int system_setting_unset_changed_callback_lock_state(system_settings_key_e key); +/** + * @internal + * @brief get current ADS ID + * @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_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value); + +/** + * @internal + * @brief set ADS ID + * @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_ads_id(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_ads_id(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_ads_id(system_settings_key_e key); /*// */ diff --git a/packaging/capi-system-system-settings.spec b/packaging/capi-system-system-settings.spec index 66efd50..3de6801 100755 --- a/packaging/capi-system-system-settings.spec +++ b/packaging/capi-system-system-settings.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(alarm-service) +BuildRequires: pkgconfig(uuid) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c index 5e3bdaa..863d029 100644 --- a/src/system_setting_platform.c +++ b/src/system_setting_platform.c @@ -1879,4 +1879,70 @@ int system_setting_unset_changed_callback_lock_state(system_settings_key_e key) } /* LCOV_EXCL_STOP */ +//---------------------------------------------------------------------------------------------------------------------------- + +#define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000" + +int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +{ + SETTING_TRACE_BEGIN; + int optout_value = 0; + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + if (optout_value == 1) { + *value = strdup(DEFAULT_ADS_ID); + return SYSTEM_SETTINGS_ERROR_NONE; + } + + char *vconf_value = NULL; + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + *value = vconf_value; + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +#if 0 +void make_ad_id(void) +{ + uuid_t uuid_value; + char uuid_unparsed[50] = {0}; + uuid_generate(uuid_value); + uuid_unparse(uuid_value, uuid_unparsed); + system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value +} +#endif +/* LCOV_EXCL_START */ +int system_setting_set_ads_id(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; + + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) + { + SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed"); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + +int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data); +} + +int system_setting_unset_changed_callback_ads_id(system_settings_key_e key) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0); +} + diff --git a/src/system_settings.c b/src/system_settings.c index ebcd240..4130032 100644 --- a/src/system_settings.c +++ b/src/system_settings.c @@ -326,6 +326,16 @@ system_setting_s system_setting_table[] = { NULL /* user data */ }, { + SYSTEM_SETTINGS_KEY_ADS_ID, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_ads_id, + system_setting_set_ads_id, + system_setting_set_changed_callback_ads_id, + system_setting_unset_changed_callback_ads_id, + NULL, + NULL /* user data */ + }, + { SYSTEM_SETTINGS_MAX, -1, NULL, NULL, NULL, NULL, NULL, NULL } }; -- 2.7.4