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);
85 static void system_setting_vconf_event_cb0(keynode_t *node, void *event_data)
87 system_settings_key_e pkey = (system_settings_key_e)event_data;
90 system_setting_h system_setting_item;
92 if (system_settings_get_item(pkey, &system_setting_item)) {
93 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
96 void *user_data = NULL;
97 user_data = system_setting_item->user_data;
98 system_setting_item->changed_cb(pkey, user_data);
102 static void system_setting_vconf_event_cb1(keynode_t *node, void *event_data)
104 system_settings_key_e pkey = (system_settings_key_e)event_data;
107 system_setting_h system_setting_item;
109 if (system_settings_get_item(pkey, &system_setting_item)) {
110 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
113 void *user_data = NULL;
114 user_data = system_setting_item->user_data;
115 system_setting_item->changed_cb(pkey, user_data);
119 static void system_setting_vconf_event_cb2(keynode_t *node, void *event_data)
121 system_settings_key_e pkey = (system_settings_key_e)event_data;
124 system_setting_h system_setting_item;
126 if (system_settings_get_item(pkey, &system_setting_item)) {
127 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
130 void *user_data = NULL;
131 user_data = system_setting_item->user_data;
132 system_setting_item->changed_cb(pkey, user_data);
136 static void system_setting_vconf_event_cb3(keynode_t *node, void *event_data)
138 system_settings_key_e pkey = (system_settings_key_e)event_data;
141 system_setting_h system_setting_item;
143 if (system_settings_get_item(pkey, &system_setting_item)) {
144 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
147 void *user_data = NULL;
148 user_data = system_setting_item->user_data;
149 system_setting_item->changed_cb(pkey, user_data);
153 static void system_setting_vconf_event_cb4(keynode_t *node, void *event_data)
155 system_settings_key_e pkey = (system_settings_key_e)event_data;
158 system_setting_h system_setting_item;
160 if (system_settings_get_item(pkey, &system_setting_item)) {
161 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
164 void *user_data = NULL;
165 user_data = system_setting_item->user_data;
166 system_setting_item->changed_cb(pkey, user_data);
170 static void system_setting_vconf_event_cb100(keynode_t *node, void *event_data)
172 system_settings_key_e pkey = (system_settings_key_e)event_data;
175 system_setting_h system_setting_item;
177 if (system_settings_get_item(pkey, &system_setting_item)) {
178 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
181 void *user_data = NULL;
182 user_data = system_setting_item->user_data;
183 system_setting_item->changed_cb(pkey, user_data);
190 static system_setting_vconf_event_cb system_setting_vconf_get_event_cb_slot(int slot)
194 return system_setting_vconf_event_cb0;
197 return system_setting_vconf_event_cb1;
200 return system_setting_vconf_event_cb2;
203 return system_setting_vconf_event_cb3;
206 return system_setting_vconf_event_cb4;
208 return system_setting_vconf_event_cb100;
215 int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot, void *user_data)
217 system_setting_vconf_event_cb vconf_event_cb;
219 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
221 if (vconf_event_cb == NULL) {
222 LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_event_cb == 0");
223 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
227 if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key))
229 if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)user_data))
232 LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_notify_key_changed error");
233 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
236 return SYSTEM_SETTINGS_ERROR_NONE;
239 int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot)
241 system_setting_vconf_event_cb vconf_event_cb;
243 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
245 if (vconf_event_cb != NULL) {
246 vconf_ignore_key_changed(vconf_key, vconf_event_cb);
249 return SYSTEM_SETTINGS_ERROR_NONE;