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)
41 return vconf_get_bool(vconf_key, (int*)value);
44 int system_setting_vconf_get_value_double(const char *vconf_key, double *value)
46 return vconf_get_dbl(vconf_key, value);
49 int system_setting_vconf_get_value_string(const char *vconf_key, char **value)
51 char *str_value = NULL;
53 str_value = vconf_get_str(vconf_key);
55 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_double(const char *vconf_key, double value)
78 return vconf_set_dbl(vconf_key, value);
81 int system_setting_vconf_set_value_string(const char *vconf_key, char *value)
83 return vconf_set_str(vconf_key, value);
87 /////////////////////////////////////////////////////////////////////////////////////////////
89 typedef void (*system_setting_vconf_event_cb)(keynode_t *node, void *event_data);
91 static void system_setting_vconf_event_cb0(keynode_t *node, void *event_data)
93 system_settings_key_e pkey = (system_settings_key_e)event_data;
97 system_setting_h system_setting_item;
99 if (system_settings_get_item(pkey, &system_setting_item))
101 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
103 system_setting_item->changed_cb(pkey, NULL);
107 static void system_setting_vconf_event_cb1(keynode_t *node, void *event_data)
109 system_settings_key_e pkey = (system_settings_key_e)event_data;
110 //printf("*** system_setting_vconf_event_cb1 : %d \n",pkey );
114 system_setting_h system_setting_item;
116 if (system_settings_get_item(pkey, &system_setting_item))
118 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
120 system_setting_item->changed_cb(pkey, NULL);
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;
127 //printf("*** system_setting_vconf_event_cb2 : %d \n",pkey );
131 system_setting_h system_setting_item;
133 if (system_settings_get_item(pkey, &system_setting_item))
135 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
137 system_setting_item->changed_cb(pkey, NULL);
141 static void system_setting_vconf_event_cb3(keynode_t *node, void *event_data)
143 system_settings_key_e pkey = (system_settings_key_e)event_data;
144 //printf("*** system_setting_vconf_event_cb3 : %d \n",pkey );
148 system_setting_h system_setting_item;
150 if (system_settings_get_item(pkey, &system_setting_item))
152 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
154 system_setting_item->changed_cb(pkey, NULL);
158 static void system_setting_vconf_event_cb4(keynode_t *node, void *event_data)
160 system_settings_key_e pkey = (system_settings_key_e)event_data;
161 //printf("*** system_setting_vconf_event_cb4 : %d \n",pkey );
165 system_setting_h system_setting_item;
167 if (system_settings_get_item(pkey, &system_setting_item))
169 LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
171 system_setting_item->changed_cb(pkey, NULL);
176 static system_setting_vconf_event_cb system_setting_vconf_get_event_cb_slot(int slot)
181 return system_setting_vconf_event_cb0;
184 return system_setting_vconf_event_cb1;
187 return system_setting_vconf_event_cb2;
190 return system_setting_vconf_event_cb3;
193 return system_setting_vconf_event_cb4;
200 int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot)
202 system_setting_vconf_event_cb vconf_event_cb;
204 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
206 if (vconf_event_cb == NULL)
208 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
211 if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void*)key))
213 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
216 return SYSTEM_SETTINGS_ERROR_NONE;
219 int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot)
221 system_setting_vconf_event_cb vconf_event_cb;
223 vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot);
225 if (vconf_event_cb != NULL)
227 vconf_ignore_key_changed(vconf_key, vconf_event_cb);
230 return SYSTEM_SETTINGS_ERROR_NONE;