2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <system_settings.h>
25 #include <system_settings_private.h>
31 #define LOG_TAG "TIZEN_N_SYSTEM_SETTINGS"
34 int system_setting_vconf_get_value_int(const char *vconf_key, int *value)
36 return vconf_get_int(vconf_key, value);
39 int system_setting_vconf_get_value_bool(const char *vconf_key, bool *value)
42 int ret = vconf_get_bool(vconf_key, &tempvalue);
52 int system_setting_vconf_get_value_string(const char *vconf_key, char **value)
54 char *str_value = NULL;
56 str_value = vconf_get_str(vconf_key);
58 if (str_value != NULL) {
66 int system_setting_vconf_set_value_int(const char *vconf_key, int value)
68 return vconf_set_int(vconf_key, value);
71 int system_setting_vconf_set_value_bool(const char *vconf_key, bool value)
73 return vconf_set_bool(vconf_key, (int)value);
76 int system_setting_vconf_set_value_string(const char *vconf_key, char *value)
78 return vconf_set_str(vconf_key, value);
81 /*/////////////////////////////////////////////////////////////////////////////////////////// */
83 typedef void (*system_setting_vconf_event_cb)(keynode_t *node, void *event_data);
86 static void system_setting_vconf_event_cb0(keynode_t *node, void *event_data)
88 system_settings_key_e pkey = (system_settings_key_e)event_data;
91 system_setting_h system_setting_item;
93 if (system_settings_get_item(pkey, &system_setting_item)) {
94 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
97 void *user_data = NULL;
98 user_data = system_setting_item->user_data;
99 system_setting_item->changed_cb(pkey, user_data);
104 /* LCOV_EXCL_START */
105 static void system_setting_vconf_event_cb1(keynode_t *node, void *event_data)
107 system_settings_key_e pkey = (system_settings_key_e)event_data;
110 system_setting_h system_setting_item;
112 if (system_settings_get_item(pkey, &system_setting_item)) {
113 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
116 void *user_data = NULL;
117 user_data = system_setting_item->user_data;
118 system_setting_item->changed_cb(pkey, user_data);
123 /* LCOV_EXCL_START */
124 static void system_setting_vconf_event_cb2(keynode_t *node, void *event_data)
126 system_settings_key_e pkey = (system_settings_key_e)event_data;
129 system_setting_h system_setting_item;
131 if (system_settings_get_item(pkey, &system_setting_item)) {
132 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
135 void *user_data = NULL;
136 user_data = system_setting_item->user_data;
137 system_setting_item->changed_cb(pkey, user_data);
142 /* LCOV_EXCL_START */
143 static void system_setting_vconf_event_cb3(keynode_t *node, void *event_data)
145 system_settings_key_e pkey = (system_settings_key_e)event_data;
148 system_setting_h system_setting_item;
150 if (system_settings_get_item(pkey, &system_setting_item)) {
151 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
154 void *user_data = NULL;
155 user_data = system_setting_item->user_data;
156 system_setting_item->changed_cb(pkey, user_data);
161 /* LCOV_EXCL_START */
162 static void system_setting_vconf_event_cb4(keynode_t *node, void *event_data)
164 system_settings_key_e pkey = (system_settings_key_e)event_data;
167 system_setting_h system_setting_item;
169 if (system_settings_get_item(pkey, &system_setting_item)) {
170 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
173 void *user_data = NULL;
174 user_data = system_setting_item->user_data;
175 system_setting_item->changed_cb(pkey, user_data);
180 /* LCOV_EXCL_START */
181 static void system_setting_vconf_event_cb100(keynode_t *node, void *event_data)
183 system_settings_key_e pkey = (system_settings_key_e)event_data;
186 system_setting_h system_setting_item;
188 if (system_settings_get_item(pkey, &system_setting_item)) {
189 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
192 void *user_data = NULL;
193 user_data = system_setting_item->user_data;
194 system_setting_item->changed_cb(pkey, user_data);
200 /* LCOV_EXCL_START */
201 static system_setting_vconf_event_cb system_setting_vconf_get_event_cb_slot(int slot)
205 return system_setting_vconf_event_cb0;
208 return system_setting_vconf_event_cb1;
211 return system_setting_vconf_event_cb2;
214 return system_setting_vconf_event_cb3;
217 return system_setting_vconf_event_cb4;
219 return system_setting_vconf_event_cb100;
227 int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot, void *user_data)
229 system_setting_vconf_event_cb vconf_event_cb;
231 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
233 if (vconf_event_cb == NULL) {
234 LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_event_cb == 0");
235 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
239 if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key))
241 if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)user_data))
244 LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_notify_key_changed error");
245 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
248 return SYSTEM_SETTINGS_ERROR_NONE;
251 int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot)
253 system_setting_vconf_event_cb vconf_event_cb;
255 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
257 if (vconf_event_cb != NULL) {
258 vconf_ignore_key_changed(vconf_key, vconf_event_cb);
261 return SYSTEM_SETTINGS_ERROR_NONE;