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 <runtime_info.h>
25 #include <runtime_info_private.h>
31 #define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO"
33 #define CHECK_VCONF_RESULT(ret) \
36 ret = vconf_get_ext_errno(); \
37 if (ret == VCONF_ERROR_FILE_NO_ENT) \
38 ret = RUNTIME_INFO_ERROR_NOT_SUPPORTED; \
40 ret = RUNTIME_INFO_ERROR_IO_ERROR; \
42 ret = RUNTIME_INFO_ERROR_NONE; \
46 int runtime_info_vconf_get_value_int(const char *vconf_key, int *value)
48 int ret = vconf_get_int(vconf_key, value);
49 CHECK_VCONF_RESULT(ret);
53 int runtime_info_vconf_get_value_bool(const char *vconf_key, int *value)
55 int ret = vconf_get_bool(vconf_key, value);
56 CHECK_VCONF_RESULT(ret);
60 //LCOV_EXCL_START : not called callback
61 typedef void (*runtime_info_vconf_event_cb)(keynode_t *node, void *event_data);
63 static void runtime_info_vconf_event_cb0(keynode_t *node, void *event_data)
66 runtime_info_updated((runtime_info_key_e)event_data);
69 static void runtime_info_vconf_event_cb1(keynode_t *node, void *event_data)
72 runtime_info_updated((runtime_info_key_e)event_data);
75 static void runtime_info_vconf_event_cb2(keynode_t *node, void *event_data)
78 runtime_info_updated((runtime_info_key_e)event_data);
81 static void runtime_info_vconf_event_cb3(keynode_t *node, void *event_data)
84 runtime_info_updated((runtime_info_key_e)event_data);
87 static void runtime_info_vconf_event_cb4(keynode_t *node, void *event_data)
90 runtime_info_updated((runtime_info_key_e)event_data);
93 static runtime_info_vconf_event_cb runtime_info_vconf_get_event_cb_slot(int slot)
97 return runtime_info_vconf_event_cb0;
100 return runtime_info_vconf_event_cb1;
103 return runtime_info_vconf_event_cb2;
106 return runtime_info_vconf_event_cb3;
109 return runtime_info_vconf_event_cb4;
117 int runtime_info_vconf_set_event_cb(const char *vconf_key, runtime_info_key_e runtime_info_key, int slot)
119 runtime_info_vconf_event_cb vconf_event_cb;
122 vconf_event_cb = runtime_info_vconf_get_event_cb_slot(slot);
124 if (vconf_event_cb == NULL)
125 return RUNTIME_INFO_ERROR_IO_ERROR;
127 ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)runtime_info_key);
128 CHECK_VCONF_RESULT(ret);
132 void runtime_info_vconf_unset_event_cb(const char *vconf_key, int slot)
134 runtime_info_vconf_event_cb vconf_event_cb;
136 vconf_event_cb = runtime_info_vconf_get_event_cb_slot(slot);
138 if (vconf_event_cb != NULL)
139 vconf_ignore_key_changed(vconf_key, vconf_event_cb);