revise handling vconf notification 68/235768/2
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 9 Jun 2020 11:56:39 +0000 (20:56 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 10 Jun 2020 04:14:59 +0000 (13:14 +0900)
Change-Id: I41b802bd3d598797164bec8c2ebf3a8ead912102

src/sst_api.c
src/sst_core.c
src/sst_interface.c
src/sst_interface.h
src/sst_misc.c
src/sst_misc.h
src/sst_vconf.c
src/sst_vconf.h

index e44b775..9d05632 100644 (file)
@@ -151,16 +151,12 @@ API int system_settings_set_changed_cb(system_settings_key_e key, system_setting
                return ret;
        }
 
-       sst_set_changed_cb_fn subscriber = iface->set_changed_cb;
-       if (NULL == subscriber) {
+       if (NULL == iface->vconf_key) {
                ERR("NULL set_changed_cb of key(%d)", key);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
        }
 
-       iface->changed_cb = callback;
-       iface->user_data = user_data;
-
-       return subscriber(iface, user_data);
+       return sst_vconf_set_cb(iface, callback, user_data);
 }
 
 //todo: need to deprecate
@@ -180,16 +176,12 @@ API int system_settings_unset_changed_cb(system_settings_key_e key)
                return ret;
        }
 
-       sst_unset_changed_cb_fn unsubscriber = iface->unset_changed_cb;
-       if (NULL == unsubscriber) {
-               ERR("NULL unset_changed_cb of key(%d)", key);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       if (NULL == iface->vconf_key) {
+               ERR("NULL set_changed_cb of key(%d)", key);
+               return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
        }
 
-       iface->changed_cb = NULL;
-       iface->user_data = NULL;
-
-       return unsubscriber(iface);
+       return sst_vconf_unset_cb(iface);
 }
 
 API int system_settings_foreach_value_string(system_settings_key_e key, system_settings_iter_cb callback, void *value)
@@ -240,28 +232,19 @@ API int system_settings_add_changed_cb(system_settings_key_e key, system_setting
                return ret;
        }
 
-       if (iface->vconf_key == NULL) {
+       if (NULL == iface->vconf_key) {
                ERR("NULL vconf_key of key(%d)", key);
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
 
        INFO("key = %d, %s", key, iface->vconf_key);
 
-       ret = sst_misc_add_multi_cb(&iface->changed_cb_list, callback, user_data);
+       ret = sst_vconf_add_multi_cb(iface, callback, user_data);
        if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-               ERR("sst_misc_add_multi_cb() Fail(%d)", ret);
+               ERR("sst_vconf_add_multi_cb() Fail(%d)", ret);
                return ret;
        }
 
-       if (!iface->changed_cb_list.is_registered) {
-               ret = sst_vconf_set_multi_changed_cb(iface->vconf_key, key);
-               if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-                       ERR("sst_vconf_set_multi_changed_cb(%s) Fail(%d)", iface->vconf_key, ret);
-                       return ret;
-               }
-               iface->changed_cb_list.is_registered = 1;
-       }
-
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
@@ -284,24 +267,11 @@ API int system_settings_remove_changed_cb(system_settings_key_e key, system_sett
                return ret;
        }
 
-       ret = sst_misc_del_multi_cb(&iface->changed_cb_list, callback);
+       ret = sst_vconf_del_multi_cb(iface, callback);
        if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-               ERR("sst_misc_del_multi_cb() Fail(%d)", ret);
+               ERR("sst_vconf_del_multi_cb() Fail(%d)", ret);
                return ret;
        }
 
-       if (iface->changed_cb_list.list == NULL) {
-               if (iface->vconf_key == NULL) {
-                       ERR("NULL vconf_key");
-                       return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
-               }
-               ret = sst_vconf_unset_multi_changed_cb(iface->vconf_key, key);
-               if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-                       ERR("sst_vconf_unset_multi_changed_cb(%s) Fail(%d)", iface->vconf_key, ret);
-                       return ret;
-               }
-               iface->changed_cb_list.is_registered = 0;
-       }
-
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
index fb1eeb0..6dd9ad8 100644 (file)
@@ -146,7 +146,7 @@ int sst_add_value(system_settings_key_e key, sst_interface_data_type data_type,
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
 
-       sst_add_value_fn        adder = iface->add_value_cb;
+       sst_add_value_fn adder = iface->add_value_cb;
        if (NULL == adder) {
                ERR("No adder for key(%d)", key);
                return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
index 0161dce..896091f 100644 (file)
@@ -35,15 +35,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_ringtone_get_incoming_call,
                sst_ringtone_set_incoming_call,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                sst_ringtone_add_incoming_call, /* ADD */
                sst_ringtone_del_incoming_call, /* DEL */
                sst_ringtone_list_incoming_call,        /* LIST */
                sst_feature_check_incoming_call,                /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -52,15 +47,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_vconf_get,
                sst_screen_set_home_wallpaper,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_home_screen,          /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -69,15 +59,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_vconf_get,
                sst_screen_set_lock_wallpaper,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_lock_screen,          /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -86,15 +71,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_vconf_get,
                sst_font_set_size,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_font,         /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -103,15 +83,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_vconf_get,
                sst_font_set_type,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_font,         /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -120,15 +95,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -137,15 +107,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_ringtone_get_email_alert,
                sst_ringtone_set_email_alert,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_notification_email,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED,
@@ -153,15 +118,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED,
@@ -169,15 +129,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        //{ /* Deprecated */
        //      -5, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, { NULL, 0 }, NULL
@@ -188,15 +143,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_screen_get_lockscreen,
                sst_screen_set_lockscreen,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_lock_screen,          /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE,
@@ -204,15 +154,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_font_get_default_type,
                NULL,
-               NULL,
-               NULL,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_font,         /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY,
@@ -220,15 +165,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_locale_get_country,
                sst_locale_set_country,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE,
@@ -236,15 +176,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_locale_get_language,
                sst_locale_set_language,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
@@ -252,15 +187,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_locale_get_timeformat_24hour,
                sst_locale_set_timeformat_24hour,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE,
@@ -268,15 +198,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_locale_get_timezone,
                sst_locale_set_timezone,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_TIME_CHANGED,
@@ -284,15 +209,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_time_get_changed,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SOUND_LOCK,
@@ -300,15 +220,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE,
@@ -316,15 +231,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_get_sound_silent_mode,
                sst_set_sound_silent_mode,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SOUND_TOUCH,
@@ -332,15 +242,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO,
@@ -348,15 +253,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_DEVICE_NAME,
@@ -364,15 +264,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_vconf_get,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_MOTION_ENABLED,
@@ -380,15 +275,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION,
@@ -396,15 +286,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_get_network_wifi_notification,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_wifi,         /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE,
@@ -412,15 +297,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME,
@@ -428,15 +308,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_vconf_get,
                sst_screen_set_backlight_time,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION,
@@ -444,15 +319,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_vconf_get,
                sst_set_sound_notification,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_incoming_call,                /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD,
@@ -460,15 +330,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_LOCK_STATE,
@@ -476,15 +341,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* add */
                NULL,           /* del */
                NULL,           /* list */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ADS_ID,
@@ -492,15 +352,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                sst_get_ads_id,
                sst_set_ads_id,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* add */
                NULL,           /* del */
                NULL,           /* list */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
 
        {
@@ -509,15 +364,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_INT,
                sst_get_uds_state,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* add */
                NULL,           /* del */
                NULL,           /* list */
                sst_feature_check_telephony,            /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST,
@@ -525,15 +375,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_STRING,
                NULL,
                NULL,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* add */
                NULL,           /* del */
                NULL,           /* list */
                sst_feature_check_telephony,            /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS,
@@ -541,15 +386,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_VIBRATION,
@@ -557,15 +397,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE,
@@ -573,15 +408,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_telephony,            /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE,
@@ -589,15 +419,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                NULL,           /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE,
@@ -605,15 +430,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_accessibility_grayscale,              /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR,
@@ -621,15 +441,10 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_accessibility_negative,               /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
                SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED,
@@ -637,18 +452,13 @@ struct _system_setting_s system_setting_table[] = {
                SYSTEM_SETTING_DATA_TYPE_BOOL,
                sst_vconf_get,
                sst_vconf_set,
-               sst_vconf_set_changed_cb,
-               sst_vconf_unset_changed_cb,
-               NULL,
                NULL,           /* ADD */
                NULL,           /* DEL */
                NULL,           /* LIST */
                sst_feature_check_rotary,               /* feature check */
-               { NULL, 0 }, /* changed callabck list */
-               NULL,           /* user data */
        },
        {
-               SYSTEM_SETTINGS_MAX, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, { NULL, 0 }, NULL
+               SYSTEM_SETTINGS_MAX, NULL, -1, NULL, NULL, NULL, NULL, NULL, NULL
        }
 };
 
index 031e243..61eece1 100644 (file)
@@ -22,10 +22,8 @@ typedef enum {
        SYSTEM_SETTING_DATA_TYPE_STRING,        /**< string */
        SYSTEM_SETTING_DATA_TYPE_INT,           /**< integer */
        SYSTEM_SETTING_DATA_TYPE_BOOL,          /**< boolean */
-#if 0
-       /*SYSTEM_SETTING_DATA_TYPE_FLOAT, */
-       /*SYSTEM_SETTING_DATA_TYPE_DOULBE, */
-#endif
+       //SYSTEM_SETTING_DATA_TYPE_FLOAT,
+       //SYSTEM_SETTING_DATA_TYPE_DOULBE,
 } sst_interface_data_type;
 
 typedef struct _system_setting_s sst_interface;
@@ -37,13 +35,6 @@ typedef int (*sst_del_value_fn)(system_settings_key_e key, void *value);
 typedef int (*sst_list_value_cb)(system_settings_key_e key, system_settings_iter_cb callback, void *user_data);
 
 typedef int (*sst_check_feature_fn)(void *value);
-typedef int (*sst_set_changed_cb_fn)(sst_interface *iface, void *user_data);
-typedef int (*sst_unset_changed_cb_fn)(sst_interface *iface);
-
-typedef struct __st_multi_callback_list_ {
-       GList *list;
-       int is_registered;
-} callback_list;
 
 struct _system_setting_s {
        system_settings_key_e key;
@@ -53,19 +44,11 @@ struct _system_setting_s {
        sst_get_value_fn get_value_cb;
        sst_set_value_fn set_value_cb;
 
-    sst_set_changed_cb_fn set_changed_cb;
-       sst_unset_changed_cb_fn unset_changed_cb;
-       system_settings_changed_cb changed_cb;          /* registered by user application */
-
        sst_add_value_fn add_value_cb;
        sst_del_value_fn del_value_cb;
        sst_list_value_cb list_value_cb;
 
        sst_check_feature_fn feature_check_cb;
-
-       callback_list changed_cb_list;
-
-       void *user_data;
 };
 
 int sst_get_interface(system_settings_key_e key, sst_interface **iface);
index 8730dfb..064c228 100644 (file)
 
 #include <unistd.h>
 #include <errno.h>
-#include <glib.h>
 #include "sst.h"
 
-typedef struct __st_multi_callback_node_ {
-       system_settings_changed_cb callback;
-       void *user_data;
-} callback_node;
-
-static gint _compare_cb(gconstpointer a, gconstpointer b)
-{
-       const callback_node *node = a;
-
-       RETV_IF(NULL == a, 1);
-       RETV_IF(NULL == b, 1);
-
-       if (node->callback == b)
-               return 0;
-       else
-               return 1;
-}
-
-int sst_misc_add_multi_cb(callback_list *handle, system_settings_changed_cb cb, void *user_data)
-{
-       RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
-
-       GList *found = g_list_find_custom(handle->list, cb, _compare_cb);
-       if (found) {
-               ERR("callback Already Exist");
-               return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
-       }
-
-       callback_node *node = calloc(1, sizeof(callback_node));
-       if (NULL == node) {
-               ERR("calloc() Fail(%d)", errno);
-               return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
-       }
-
-       node->callback = cb;
-       node->user_data = user_data;
-
-       handle->list = g_list_append(handle->list, node);
-
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
-
-int sst_misc_del_multi_cb(callback_list *handle, system_settings_changed_cb cb)
-{
-       RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
-
-       GList *found = g_list_find_custom(handle->list, cb, _compare_cb);
-       if (NULL == found) {
-               ERR("No callback");
-               return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
-       }
-
-       handle->list = g_list_remove_link(handle->list, found);
-       free(found->data);
-       g_list_free(found);
-
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
-
-int sst_misc_invoke_cb_list(callback_list *handle, system_settings_key_e key)
-{
-       RETV_IF(NULL == handle, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
-
-       GList *it;
-       for (it = handle->list; it; it = it->next) {
-               callback_node *node = it->data;
-               if (node && node->callback)
-                       node->callback(key, node->user_data);
-       }
-
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
-
 bool sst_misc_exist(const char *path)
 {
        if (0 != access(path, R_OK)) {
index c6969aa..2b2ec94 100644 (file)
@@ -18,8 +18,4 @@
 #include <stdbool.h>
 #include "sst_interface.h"
 
-int sst_misc_add_multi_cb(callback_list *handle, system_settings_changed_cb ptr, void *user_data);
-int sst_misc_del_multi_cb(callback_list *handle, system_settings_changed_cb ptr);
-int sst_misc_invoke_cb_list(callback_list *handle, system_settings_key_e key);
-
 bool sst_misc_exist(const char *path);
index 3d3277c..9597d20 100644 (file)
 #include "sst_misc.h"
 #include "sst_interface.h"
 
-typedef enum {
-       SYSTEM_SETTING_CALLBACK_SLOT_0 = 0,
-       SYSTEM_SETTING_CALLBACK_SLOT_1 = 1,
-       SYSTEM_SETTING_CALLBACK_SLOT_2 = 2,
-       SYSTEM_SETTING_CALLBACK_SLOT_3 = 3,
-       SYSTEM_SETTING_CALLBACK_SLOT_4 = 4,
-       SYSTEM_SETTING_CALLBACK_SLOT_5 = 5
-} sst_vconf_cb_slot_e;
+static GHashTable *sst_vconf_map_org = NULL;
+static GHashTable *sst_vconf_map = NULL;
+
+struct sst_vconf_info_s {
+       system_settings_key_e key;
+       system_settings_changed_cb cb;
+       void *cb_data;
+};
+
+int sst_vconf_set(sst_interface *iface, void *value)
+{
+       char *vconf_char;
+       int vconf_int;
+       bool vconf_bool;
+
+       switch (iface->data_type) {
+       case SYSTEM_SETTING_DATA_TYPE_STRING:
+               vconf_char = (char*)value;
+               if (vconf_set_str(iface->vconf_key, vconf_char))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               break;
+       case SYSTEM_SETTING_DATA_TYPE_INT:
+               //todo: change double pointer to valide data type
+               vconf_int = **(int**)value;
+               if (vconf_set_int(iface->vconf_key, vconf_int))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               break;
+       case SYSTEM_SETTING_DATA_TYPE_BOOL:
+               vconf_bool = *(bool*)value;
+               if (vconf_set_bool(iface->vconf_key, vconf_bool))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               break;
+       default:
+               ERR("Unknown type(%d)", iface->data_type);
+               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       }
+
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
+
+int sst_vconf_get(sst_interface *iface, void **value)
+{
+       char *vconf_char;
+       int vconf_int;
+       int **val = (int**)value;
+       bool vconf_bool;
+
+       switch (iface->data_type) {
+       case SYSTEM_SETTING_DATA_TYPE_STRING:
+               if (sst_vconf_get_string(iface->vconf_key, &vconf_char))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               *value = vconf_char;
+               break;
+       case SYSTEM_SETTING_DATA_TYPE_INT:
+               if (vconf_get_int(iface->vconf_key, &vconf_int))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               **val = vconf_int;
+               break;
+       case SYSTEM_SETTING_DATA_TYPE_BOOL:
+               if (sst_vconf_get_real_bool(iface->vconf_key, &vconf_bool))
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               *value = (void*)vconf_bool;
+               break;
+       default:
+               ERR("Unknown type(%d)", iface->data_type);
+               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       }
+
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
 
 int sst_vconf_get_real_bool(const char *vconf_key, bool *value)
 {
@@ -59,257 +121,218 @@ int sst_vconf_get_string(const char *vconf_key, char **value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-static void _vconf_event_cb0(keynode_t *node, void *event_data)
+static inline GHashTable* _map_erase(GHashTable *hash_table, const char *key)
 {
-       system_settings_key_e pkey = (system_settings_key_e)event_data;
-
-       RET_IF(NULL == node);
-
-       sst_interface *iface = NULL;
-       int ret = sst_get_interface(pkey, &iface);
-       if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-               ERR("sst_get_interface(%d) Fail(%d)", pkey, ret);
-               return;
+       g_hash_table_remove(hash_table, key);
+       if (0 == g_hash_table_size(hash_table)) {
+               g_hash_table_unref(hash_table);
+               return NULL;
        }
-
-       iface->changed_cb(pkey, iface->user_data);
+       return hash_table;
 }
 
-static void _vconf_event_cb1(keynode_t *node, void *event_data)
+static void _callback_fn_org(keynode_t *node, void *user_data)
 {
-       _vconf_event_cb0(node, event_data);
+       RET_IF(NULL == sst_vconf_map_org);
+
+       GList *list = g_hash_table_lookup(sst_vconf_map_org, node->keyname);
+       GList *it;
+       for (it = list; it; it = it->next) {
+               struct sst_vconf_info_s *info = it->data;
+               if (info && info->cb)
+                       info->cb(info->key, info->cb_data);
+       }
 }
 
-static void _vconf_event_cb2(keynode_t *node, void *event_data)
+static gint _compare_key(gconstpointer a, gconstpointer b)
 {
-       _vconf_event_cb0(node, event_data);
-}
+       const struct sst_vconf_info_s *info = a;
 
-static void _vconf_event_cb3(keynode_t *node, void *event_data)
-{
-       _vconf_event_cb0(node, event_data);
-}
+       RETV_IF(NULL == a, 1);
 
-static void _vconf_event_cb4(keynode_t *node, void *event_data)
-{
-       _vconf_event_cb0(node, event_data);
-}
-static vconf_callback_fn _get_event_cb_slot(sst_vconf_cb_slot_e slot)
-{
-       switch (slot) {
-       case SYSTEM_SETTING_CALLBACK_SLOT_0:
-               return _vconf_event_cb0;
-       case SYSTEM_SETTING_CALLBACK_SLOT_1:
-               return _vconf_event_cb1;
-       case SYSTEM_SETTING_CALLBACK_SLOT_2:
-               return _vconf_event_cb2;
-       case SYSTEM_SETTING_CALLBACK_SLOT_3:
-               return _vconf_event_cb3;
-       case SYSTEM_SETTING_CALLBACK_SLOT_4:
-               return _vconf_event_cb4;
-       default:
-               return NULL;
-       }
+       if (info->key == GPOINTER_TO_INT(b))
+               return 0;
+       else
+               return 1;
 }
 
-static int _vconf_unset_changed_cb(const char *vconf_key, sst_vconf_cb_slot_e slot)
+int sst_vconf_set_cb(sst_interface *iface, system_settings_changed_cb cb, void *user_data)
 {
-       vconf_callback_fn vconf_event_cb = _get_event_cb_slot(slot);
-       if (NULL == vconf_event_cb) {
-               ERR("_get_event_cb_slot(%d) Fail(NULL)", slot);
-               return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+       GList *list = NULL;
+
+       RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+
+       if (sst_vconf_map_org) {
+               list = g_hash_table_lookup(sst_vconf_map_org, iface->vconf_key);
+               GList *found = g_list_find_custom(list, GINT_TO_POINTER(iface->key), _compare_key);
+               if (found) {
+                       ERR("callback Already Exist");
+                       return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               sst_vconf_map_org = g_hash_table_new(g_str_hash, g_str_equal);
        }
 
-       int ret = vconf_ignore_key_changed(vconf_key, vconf_event_cb);
-       if (VCONF_OK != ret) {
-               ERR("vconf_ignore_key_changed(%s, %d) Fail(%d)", vconf_key, slot, ret);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       struct sst_vconf_info_s *info = malloc(sizeof(struct sst_vconf_info_s));
+       if (NULL == info) {
+               ERR("malloc() Fail(%d)", errno);
+               return SYSTEM_SETTINGS_ERROR_OUT_OF_MEMORY;
+       }
+       info->key = iface->key;
+       info->cb = cb;
+       info->cb_data = user_data;
+
+       GList *new_list = g_list_append(list, info);
+       g_hash_table_replace(sst_vconf_map_org, (char*)iface->vconf_key, new_list);
+
+       if (NULL == list) {
+               int ret = vconf_notify_key_changed(iface->vconf_key, _callback_fn_org, NULL);
+               if (VCONF_OK != ret) {
+                       ERR("vconf_notify_key_changed(%s) Fail", iface->vconf_key);
+                       new_list = g_list_remove(new_list, info);
+                       if (NULL == new_list)
+                               sst_vconf_map_org = _map_erase(sst_vconf_map_org, iface->vconf_key);
+                       free(info);
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               }
        }
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_vconf_unset_changed_cb(sst_interface *iface)
+int sst_vconf_unset_cb(sst_interface *iface)
 {
-       return _vconf_unset_changed_cb(iface->vconf_key, (iface->key) % 4);
-}
+       RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == sst_vconf_map_org, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
 
-static int _vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, sst_vconf_cb_slot_e slot, void *user_data)
-{
-       vconf_callback_fn vconf_event_cb = _get_event_cb_slot(slot);
-       if (NULL == vconf_event_cb) {
-               ERR("_get_event_cb_slot(%d) Fail(NULL)", slot);
+       GList *list = g_hash_table_lookup(sst_vconf_map_org, iface->vconf_key);
+       GList *found = g_list_find_custom(list, GINT_TO_POINTER(iface->key), _compare_key);
+       if (NULL == found) {
+               ERR("No callback");
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void*)key);
-       if (VCONF_OK != ret) {
-               ERR("vconf_notify_key_changed(%s, %d) Fail(%d)", vconf_key, slot, ret);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       if (1 == g_list_length(list)) {
+               int ret = vconf_ignore_key_changed(iface->vconf_key, _callback_fn_org);
+               if (VCONF_OK != ret) {
+                       ERR("vconf_ignore_key_changed(%s) Fail", iface->vconf_key);
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               }
        }
 
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
+       list = g_list_remove_link(list, found);
+       if (list)
+               g_hash_table_replace(sst_vconf_map_org, (char*)iface->vconf_key, list);
+       else
+               sst_vconf_map_org = _map_erase(sst_vconf_map_org, iface->vconf_key);
 
-int sst_vconf_set_changed_cb(sst_interface *iface, void *user_data)
-{
-       return _vconf_set_changed_cb(iface->vconf_key, iface->key, (iface->key) % 4, user_data);
-}
-
-static void _vconf_event_multi_cb(keynode_t *node, void *event_data)
-{
-       int ret;
-       system_settings_key_e pkey = (system_settings_key_e)event_data;
-
-       RET_IF(NULL == node);
+       free(found->data);
+       g_list_free(found);
 
-       sst_interface *iface = NULL;
-       ret = sst_get_interface(pkey, &iface);
-       if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
-               ERR("sst_get_interface(%d) Fail(%d)", pkey, ret);
-               return;
-       }
-
-       ret = sst_misc_invoke_cb_list(&iface->changed_cb_list, pkey);
-       if (SYSTEM_SETTINGS_ERROR_NONE != ret)
-               ERR("sst_misc_invoke_cb_list(%d) Fail(%d)", pkey, ret);
+       return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-static void _vconf_event_multi_cb_slot_0(keynode_t *node, void *event_data)
+static void _callback_fn(keynode_t *node, void *user_data)
 {
-       _vconf_event_multi_cb(node, event_data);
+       RET_IF(NULL == sst_vconf_map);
+
+       GList *list = g_hash_table_lookup(sst_vconf_map, node->keyname);
+       GList *it;
+       for (it = list; it; it = it->next) {
+               struct sst_vconf_info_s *info = it->data;
+               if (info && info->cb)
+                       info->cb(info->key, info->cb_data);
+       }
 }
 
-static void _vconf_event_multi_cb_slot_1(keynode_t *node, void *event_data)
+static gint _compare_cb(gconstpointer a, gconstpointer b)
 {
-       _vconf_event_multi_cb(node, event_data);
-}
+       const struct sst_vconf_info_s *info = a;
 
-static void _vconf_event_multi_cb_slot_2(keynode_t *node, void *event_data)
-{
-       _vconf_event_multi_cb(node, event_data);
-}
+       RETV_IF(NULL == a, 1);
+       RETV_IF(NULL == b, 1);
 
-static void _vconf_event_multi_cb_slot_3(keynode_t *node, void *event_data)
-{
-       _vconf_event_multi_cb(node, event_data);
+       if (info->cb == b)
+               return 0;
+       else
+               return 1;
 }
 
-static vconf_callback_fn _get_event_multi_cb_slot(system_settings_key_e key)
+int sst_vconf_add_multi_cb(sst_interface *iface, system_settings_changed_cb cb, void *user_data)
 {
-       int cal = (int)key;
-       int slot = cal % 4;
-
-       switch (slot) {
-       case 0:
-               return _vconf_event_multi_cb_slot_0;
-
-       case 1:
-               return _vconf_event_multi_cb_slot_1;
-
-       case 2:
-               return _vconf_event_multi_cb_slot_2;
-
-       case 3:
-               return _vconf_event_multi_cb_slot_3;
-
-       default:
-               return NULL;
+       GList *list = NULL;
+
+       RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+
+       if (sst_vconf_map) {
+               list = g_hash_table_lookup(sst_vconf_map, iface->vconf_key);
+               GList *found = g_list_find_custom(list, cb, _compare_cb);
+               if (found) {
+                       ERR("callback Already Exist");
+                       return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+               }
+       } else {
+               sst_vconf_map = g_hash_table_new(g_str_hash, g_str_equal);
        }
-}
 
-int sst_vconf_set_multi_changed_cb(const char *vconf_key, system_settings_key_e key)
-{
-       vconf_callback_fn vconf_event_cb = _get_event_multi_cb_slot(key);
-       if (NULL == vconf_event_cb) {
-               ERR("_get_event_multi_cb_slot(%d) Fail(NULL)", key);
-               return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+       struct sst_vconf_info_s *info = malloc(sizeof(struct sst_vconf_info_s));
+       if (NULL == info) {
+               ERR("malloc() Fail(%d)", errno);
+               return SYSTEM_SETTINGS_ERROR_OUT_OF_MEMORY;
        }
-
-       int ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void*)key);
-       if (VCONF_OK != ret) {
-               ERR("vconf_notify_key_changed(%s) Fail(%d)", vconf_key, ret);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       info->key = iface->key;
+       info->cb = cb;
+       info->cb_data = user_data;
+
+       GList *new_list = g_list_append(list, info);
+       g_hash_table_replace(sst_vconf_map, (char*)iface->vconf_key, new_list);
+
+       if (NULL == list) {
+               int ret = vconf_notify_key_changed(iface->vconf_key, _callback_fn, NULL);
+               if (VCONF_OK != ret) {
+                       ERR("vconf_notify_key_changed(%s) Fail", iface->vconf_key);
+                       new_list = g_list_remove(new_list, info);
+                       if (NULL == new_list)
+                               sst_vconf_map = _map_erase(sst_vconf_map, iface->vconf_key);
+                       free(info);
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               }
        }
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_vconf_unset_multi_changed_cb(const char *vconf_key, system_settings_key_e key)
+int sst_vconf_del_multi_cb(sst_interface *iface, system_settings_changed_cb cb)
 {
-       vconf_callback_fn vconf_event_cb = _get_event_multi_cb_slot(key);
-       if (NULL == vconf_event_cb) {
-               ERR("_get_event_multi_cb_slot(%d) Fail(NULL)", key);
+       RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == sst_vconf_map, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+
+       GList *list = g_hash_table_lookup(sst_vconf_map, iface->vconf_key);
+       GList *found = g_list_find_custom(list, cb, _compare_cb);
+       if (NULL == found) {
+               ERR("No callback");
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
 
-       int ret = vconf_ignore_key_changed(vconf_key, vconf_event_cb);
-       if (VCONF_OK != ret) {
-               ERR("vconf_ignore_key_changed(%s, %d) Fail(%d)", vconf_key, key, ret);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-       }
-
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
-
-int sst_vconf_get(sst_interface *iface, void **value)
-{
-       char *vconf_char;
-       int vconf_int;
-       int **val = (int**)value;
-       bool vconf_bool;
-
-       switch (iface->data_type) {
-       case SYSTEM_SETTING_DATA_TYPE_STRING:
-               if (sst_vconf_get_string(iface->vconf_key, &vconf_char))
+       if (1 == g_list_length(list)) {
+               int ret = vconf_ignore_key_changed(iface->vconf_key, _callback_fn);
+               if (VCONF_OK != ret) {
+                       ERR("vconf_ignore_key_changed(%s) Fail", iface->vconf_key);
                        return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               *value = vconf_char;
-               break;
-       case SYSTEM_SETTING_DATA_TYPE_INT:
-               if (vconf_get_int(iface->vconf_key, &vconf_int))
-                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               **val = vconf_int;
-               break;
-       case SYSTEM_SETTING_DATA_TYPE_BOOL:
-               if (sst_vconf_get_real_bool(iface->vconf_key, &vconf_bool))
-                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               *value = (void*)vconf_bool;
-               break;
-       default:
-               ERR("Unknown type(%d)", iface->data_type);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               }
        }
 
-       return SYSTEM_SETTINGS_ERROR_NONE;
-}
-
-int sst_vconf_set(sst_interface *iface, void *value)
-{
-       char *vconf_char;
-       int vconf_int;
-       bool vconf_bool;
+       list = g_list_remove_link(list, found);
+       if (list)
+               g_hash_table_replace(sst_vconf_map, (char*)iface->vconf_key, list);
+       else
+               sst_vconf_map = _map_erase(sst_vconf_map, iface->vconf_key);
 
-       switch (iface->data_type) {
-       case SYSTEM_SETTING_DATA_TYPE_STRING:
-               vconf_char = (char*)value;
-               if (vconf_set_str(iface->vconf_key, vconf_char))
-                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               break;
-       case SYSTEM_SETTING_DATA_TYPE_INT:
-               //todo: change double pointer to valide data type
-               vconf_int = **(int**)value;
-               if (vconf_set_int(iface->vconf_key, vconf_int))
-                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               break;
-       case SYSTEM_SETTING_DATA_TYPE_BOOL:
-               vconf_bool = *(bool*)value;
-               if (vconf_set_bool(iface->vconf_key, vconf_bool))
-                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-               break;
-       default:
-               ERR("Unknown type(%d)", iface->data_type);
-               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
-       }
+       free(found->data);
+       g_list_free(found);
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
index 2b0a01d..2a4a1e7 100644 (file)
@@ -23,7 +23,8 @@ int sst_vconf_get_string(const char *vconf_key, char **value);
 int sst_vconf_get(sst_interface *iface, void **value);
 int sst_vconf_set(sst_interface *iface, void *value);
 
-int sst_vconf_set_changed_cb(sst_interface *iface, void *user_data);
-int sst_vconf_unset_changed_cb(sst_interface *iface);
-int sst_vconf_set_multi_changed_cb(const char *vconf_key, system_settings_key_e key);
-int sst_vconf_unset_multi_changed_cb(const char *vconf_key, system_settings_key_e key);
+int sst_vconf_set_cb(sst_interface *iface, system_settings_changed_cb cb, void *user_data);
+int sst_vconf_unset_cb(sst_interface *iface);
+
+int sst_vconf_add_multi_cb(sst_interface *iface, system_settings_changed_cb cb, void *user_data);
+int sst_vconf_del_multi_cb(sst_interface *iface, system_settings_changed_cb cb);
\ No newline at end of file