}
system_settings_vconf_get_key_string(key, &vconf_string);
+ LOGE("[%s] key = %d %s", __FUNCTION__, key, vconf_string ? vconf_string : "NULL");
/* Store the callback function from application side */
ret = add_multi_callback(&system_setting_item->changed_cb_list, callback, user_data);
system_settings_vconf_get_key_string(key, &vconf_string);
if (vconf_string == NULL)
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
- ret = system_setting_vconf_unset_changed_multi_cb(vconf_string);
+ ret = system_setting_vconf_unset_changed_multi_cb(vconf_string, key);
if (ret == SYSTEM_SETTINGS_ERROR_NONE)
system_setting_item->changed_cb_list.is_registered = 0;
LOGE("Leave [%s]", __FUNCTION__);
}
+static void utc_system_settings_changed_callback_1(system_settings_key_e key, void *user_data)
+{
+ _callback_called = true;
+}
+
+static void utc_system_settings_changed_callback_2(system_settings_key_e key, void *user_data)
+{
+ _callback_called = true;
+}
+
+static void utc_system_settings_add_remove_changed_cb_p1(void)
+{
+ int retcode = 0;
+ int key_idx = 0;
+
+ for (key_idx = SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE; key_idx < SYSTEM_SETTINGS_KEY_MAX ; key_idx++) {
+
+ if (key_idx == SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED + 1)
+ continue; /* skip removed system-setting key */
+
+ if (key_idx == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE)
+ continue; /* skip removed system-setting key */
+
+ retcode = system_settings_add_changed_cb(key_idx,
+ utc_system_settings_changed_callback_1, NULL);
+
+ if (retcode == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) {
+ g_assert_cmpint(retcode, ==, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
+ } else {
+ if (retcode != SYSTEM_SETTINGS_ERROR_NONE)
+ printf("ERROR !! key =%d , ret = %d\n", key_idx, retcode);
+ }
+
+ retcode = system_settings_remove_changed_cb(key_idx,
+ utc_system_settings_changed_callback_1);
+
+ if (retcode == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) {
+ g_assert_cmpint(retcode, ==, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED);
+ } else {
+ if (retcode != SYSTEM_SETTINGS_ERROR_NONE)
+ printf("ERROR !! key =%d , ret = %d\n", key_idx, retcode);
+ }
+
+ retcode = system_settings_add_changed_cb(key_idx,
+ utc_system_settings_changed_callback_1, NULL);
+ my_assert_ret(retcode);
+
+ retcode = system_settings_add_changed_cb(key_idx,
+ utc_system_settings_changed_callback_2, NULL);
+ my_assert_ret(retcode);
+
+ retcode = system_settings_remove_changed_cb(key_idx,
+ utc_system_settings_changed_callback_1);
+ my_assert_ret(retcode);
+
+ retcode = system_settings_remove_changed_cb(key_idx,
+ utc_system_settings_changed_callback_2);
+ my_assert_ret(retcode);
+ }
+
+ return;
+}
+
static void simple_test_case(void)
{
/* a suitable test */
/* hook up your test functions */
g_test_add_func("/API Test Case", simple_test_case);
g_test_add_func("/utc_system_settings_add_changed_cb_p1", utc_system_settings_add_changed_cb_p1);
+ g_test_add_func("/utc_system_settings_add_remove_changed_cb_p1", utc_system_settings_add_remove_changed_cb_p1);
g_test_add_func("/utc_system_settings_get_value_string_p1", utc_system_settings_get_value_string_p1);
g_test_add_func("/utc_system_settings_get_value_string_p2", utc_system_settings_get_value_string_p2);
g_test_add_func("/utc_system_settings_get_value_string_p3", utc_system_settings_get_value_string_p3);
LOGE("Leave [%s]", __FUNCTION__);
}
+static void system_setting_vconf_event_multi_cb_slot_0(keynode_t *node, void *event_data)
+{
+ system_setting_vconf_event_multi_cb(node, event_data);
+}
+
+static void system_setting_vconf_event_multi_cb_slot_1(keynode_t *node, void *event_data)
+{
+ system_setting_vconf_event_multi_cb(node, event_data);
+}
+
+static void system_setting_vconf_event_multi_cb_slot_2(keynode_t *node, void *event_data)
+{
+ system_setting_vconf_event_multi_cb(node, event_data);
+}
+
+static void system_setting_vconf_event_multi_cb_slot_3(keynode_t *node, void *event_data)
+{
+ system_setting_vconf_event_multi_cb(node, event_data);
+}
+
+static system_setting_vconf_event_cb system_setting_vconf_get_event_multi_cb_slot(system_settings_key_e key)
+{
+ int cal = (int) key;
+ int slot = cal % 4;
+
+ switch (slot) {
+ case 0:
+ return system_setting_vconf_event_multi_cb_slot_0;
+
+ case 1:
+ return system_setting_vconf_event_multi_cb_slot_1;
+
+ case 2:
+ return system_setting_vconf_event_multi_cb_slot_2;
+
+ case 3:
+ return system_setting_vconf_event_multi_cb_slot_3;
+
+ default:
+ return NULL;
+ }
+}
+
int system_setting_vconf_set_changed_multi_cb(const char *vconf_key, system_settings_key_e key)
{
LOGE("Enter [%s]", __FUNCTION__);
- if (vconf_notify_key_changed(vconf_key, system_setting_vconf_event_multi_cb, (void *)key)) {
- LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_notify_key_changed error");
+ system_setting_vconf_event_cb vconf_event_cb;
+
+ vconf_event_cb = system_setting_vconf_get_event_multi_cb_slot(key);
+
+ if (vconf_event_cb == NULL)
+ return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+
+ int ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key);
+ if (ret != NULL) {
+ LOGE("[%s] INVALID_error , ret = %d, %s", __FUNCTION__, ret, "vconf_notify_key_changed error");
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}
return SYSTEM_SETTINGS_ERROR_NONE;
}
-int system_setting_vconf_unset_changed_multi_cb(const char *vconf_key)
+int system_setting_vconf_unset_changed_multi_cb(const char *vconf_key, system_settings_key_e key)
{
LOGE("Enter [%s]", __FUNCTION__);
- if (vconf_ignore_key_changed(vconf_key, system_setting_vconf_event_multi_cb)) {
- LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_ignore_key_changed error");
+ system_setting_vconf_event_cb vconf_event_cb;
+
+ vconf_event_cb = system_setting_vconf_get_event_multi_cb_slot(key);
+
+ if (vconf_event_cb == NULL)
+ return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+
+ int ret = vconf_ignore_key_changed(vconf_key, vconf_event_cb);
+ if (ret != NULL) {
+ LOGE("[%s] INVALID_error , ret = %d, %s", __FUNCTION__, ret, "vconf_ignore_key_changed error");
return SYSTEM_SETTINGS_ERROR_IO_ERROR;
}