2 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
3 * Copyright (C) 2014 Intel Corporation
5 * Author: José Bollo <jose.bollo@open.eurogiciel.org>
6 * Author: Hakjoo Ko <hakjoo.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __VCONF_BUXTON_H__
23 #define __VCONF_BUXTON_H__
25 #define VCONF_BUXTON "1.0"
28 * @addtogroup APPLICATION_FRAMEWORK
31 * @defgroup VCONF VConf
32 * @author Sangjung Woo (sangjung.woo@samsung.com)
34 * @brief A library for reading/writing Configuration Data
36 * @section Header To use Them:
43 * - Guarantee Transaction(db backend only)
44 * - Apply Key-List concept
45 * - Changeable Backend
46 * - Simple Notification based on inotify
48 * @section Backend key has below backend.
49 * - db => use libsqlfs ex) db/a/b
50 * \n Lowest speed, highest robustness, correctly sync
51 * - memory => use tmpfs ex) memory/a/b
52 * \n Highest speed, volitile
53 * - file => use basic file system(not support atomicity) ex) file/a/b
54 * \n Higher speed, lower robustness(Not guarantee atomicity)
56 * @section example Simple Example
61 const char *key1_name="db/test/key1";
63 int main(int argc, char **argv)
67 if(vconf_set_int(key1_name,1))
68 fprintf(stderr, "vconf_set_int FAIL\n");
70 printf("vconf_set_int OK\n");
72 if(vconf_get_int(key1_name, &key1_value))
73 fprintf(stderr, "vconf_get_int FAIL\n");
75 printf("vconf_get_int OK(key1 value is %d)\n", key1_value);
89 #include "vconf-buxton-keys.h"
96 #define VCONF_ERROR -1
97 #define VCONF_ERROR_FILE_NO_ENT -ENOENT
98 #define VCONF_ERROR_FILE_PERM -EPERM
101 * @brief Enumeration for uses of vconf_get().
107 /**< get only keys */
109 /**< get keys and directorys */
111 /**< get only directorys */
113 /**< get only keys */
115 /**< get only keys recursively */
117 /**< get keys and directorys recursively */
119 /**< get only directorys recursively */
123 * @brief Enumeration for Definition for Enumeration type.
127 typedef enum get_option_t get_option_t;
130 * @brief Enumeration for vconf_t.
136 /**< Vconf none type for Error detection */
137 VCONF_TYPE_STRING = 40,
138 /**< Vconf string type */
140 /**< Vconf integer type */
141 VCONF_TYPE_DOUBLE = 42,
142 /**< Vconf double type */
143 VCONF_TYPE_BOOL = 43,
144 /**< Vconf boolean type */
146 /**< Vconf directory type */
151 * @brief The structure type for an opaque type. It must be used via accessor functions.
154 * @see vconf_keynode_get_name()
155 * @see vconf_keynode_get_type()
156 * @see vconf_keynode_get_bool()
157 * @see vconf_keynode_get_dbl()
158 * @see vconf_keynode_get_int()
159 * @see vconf_keynode_get_str()
161 typedef struct _keynode_t keynode_t;
164 * @brief The structure type for opaque type. It must be used via accessor functions.
167 * @see vconf_keylist_new()
168 * @see vconf_keylist_free()
169 * @see vconf_keylist_add_bool()
170 * @see vconf_keylist_add_str()
171 * @see vconf_keylist_add_dbl()
172 * @see vconf_keylist_add_int()
173 * @see vconf_keylist_del()
174 * @see vconf_keylist_add_null()
175 * @see vconf_keylist_lookup()
176 * @see vconf_keylist_nextnode()
177 * @see vconf_keylist_rewind()
179 typedef struct _keylist_t keylist_t;
183 * @brief Called when the key is set handle.
184 * @details This is the signature of a callback function added with vconf_notify_key_changed() handle.
190 typedef void (*vconf_callback_fn) (keynode_t *node, void *user_data);
192 /************************************************
193 * keynode handling APIs *
194 ************************************************/
197 * @brief Gets the key name of a keynode.
201 * @param[in] keynode The Key
203 * @return The key name of the keynode
205 * @see vconf_notify_key_changed()
206 * @see vconf_keynode_get_bool()
207 * @see vconf_keynode_get_type()
208 * @see vconf_keynode_get_str()
209 * @see vconf_keynode_get_int()
210 * @see vconf_keynode_get_dbl()
214 const char *vconf_keynode_get_name(keynode_t *keynode);
217 * @brief Gets the value type of a keynode.
221 * @param[in] keynode The Key
223 * @return The type of the keynode
225 * @see vconf_notify_key_changed()
226 * @see vconf_keynode_get_name()
227 * @see vconf_keynode_get_bool()
228 * @see vconf_keynode_get_str()
229 * @see vconf_keynode_get_int()
230 * @see vconf_keynode_get_dbl()
234 int vconf_keynode_get_type(keynode_t *keynode);
237 * @brief Gets the integer value of a keynode.
241 * @param[in] keynode The Key
243 * @return The integer value,
244 * otherwise @c 0 if no value is obtained
246 * @see vconf_notify_key_changed()
247 * @see vconf_keynode_get_name()
248 * @see vconf_keynode_get_bool()
249 * @see vconf_keynode_get_type()
250 * @see vconf_keynode_get_str()
251 * @see vconf_keynode_get_dbl()
255 int vconf_keynode_get_int(keynode_t *keynode);
258 * @brief Gets the double value of a keynode.
262 * @param[in] keynode The Key
264 * @return The double value,
265 * otherwise @c 0.0 if no value is obtained
267 * @see vconf_notify_key_changed()
268 * @see vconf_keynode_get_name()
269 * @see vconf_keynode_get_bool()
270 * @see vconf_keynode_get_type()
271 * @see vconf_keynode_get_str()
272 * @see vconf_keynode_get_int()
276 double vconf_keynode_get_dbl(keynode_t *keynode);
279 * @brief Gets the boolean value of a keynode.
283 * @param[in] keynode The Key
285 * @return The boolean value,
286 * otherwise @c -1 on error \n
287 * Integer value @c 1 is 'True', and @c 0 is 'False'.
289 * @see vconf_notify_key_changed()
290 * @see vconf_keynode_get_name()
291 * @see vconf_keynode_get_type()
292 * @see vconf_keynode_get_str()
293 * @see vconf_keynode_get_int()
294 * @see vconf_keynode_get_dbl()
298 int vconf_keynode_get_bool(keynode_t *keynode);
301 * @brief Gets the string value of a keynode.
305 * @param[in] keynode The Key
307 * @return The string value,
308 * otherwise @c NULL if no value is obtained
310 * @see vconf_notify_key_changed()
311 * @see vconf_keynode_get_name()
312 * @see vconf_keynode_get_bool()
313 * @see vconf_keynode_get_type()
314 * @see vconf_keynode_get_int()
315 * @see vconf_keynode_get_dbl()
319 char *vconf_keynode_get_str(keynode_t *keynode);
322 /************************************************
323 * keylist handling APIs
324 ************************************************/
327 * @brief Allocates, initializes and returns a new keylist object.
328 * @details You must release the return value keylist_t* pointer using vconf_keylist_free().
332 * @return The pointer of New keylist,
333 * otherwise @c NULL on error
337 * @see vconf_keylist_new()
338 * @see vconf_keylist_free()
340 keylist_t *vconf_keylist_new(void);
343 * @brief Moves the current keynode position to the first item.
347 * @param[in] keylist The Key List
349 * @return @c 0 on success,
350 * otherwise -1 on error
354 * @see vconf_keylist_nextnode()
355 * @see vconf_keylist_rewind()
356 * @see vconf_keylist_nextnode()
361 keylist_t* pKeyList = NULL;
362 pKeyList = vconf_keylist_new();
364 r = vconf_get(pKeyList, KEY_PARENT, VCONF_GET_KEY);
366 tet_infoline("vconf_get() failed in positive test case");
367 tet_result(TET_FAIL);
371 vconf_keylist_nextnode(pKeyList);
372 vconf_keylist_nextnode(pKeyList);
374 // Move first position from KeyList
375 r = vconf_keylist_rewind(pKeyList);
377 tet_infoline("vconf_keylist_rewind() failed in positive test case");
378 tet_result(TET_FAIL);
382 while(vconf_keylist_nextnode(pKeyList)) ;
385 int vconf_keylist_rewind(keylist_t *keylist);
388 * @brief Destroys a keylist.
389 * @details After calling vconf_keylist_new(), you must call this function to release internal memory.
393 * @param[in] keylist The Key List
395 * @return @c 0 on success,
396 * otherwise @c -1 on error
400 * @see vconf_keylist_new()
402 int vconf_keylist_free(keylist_t *keylist);
405 * @brief Looks for a keynode contained in a keylist that matches the keyname.
409 * @param[in] keylist The Key List
410 * @param[in] keyname The key to find
411 * @param[out] return_node The pointer of the keynode to set
413 * @return The type of the found key that is vconf_t enumeration value
428 keylist_t* pKeyList = NULL;
431 pKeyList = vconf_keylist_new();
432 r = vconf_get(pKeyList, KEY_PARENT, VCONF_GET_KEY);
434 printf("vconf_get() failed in positive test case");
438 r = vconf_keylist_lookup(pKeyList, KEY_02, &pKeyNode);
440 printf("vconf_get() failed in positive test case");
444 nResult = vconf_keynode_get_int(pKeyNode);
445 if(nResult !=KEY_02_INT_VALUE)
447 printf("vconf_get() failed in positive test case");
452 vconf_keylist_free(pKeyList);
457 int vconf_keylist_lookup(keylist_t *keylist, const char *keyname,
458 keynode_t **return_node);
461 * @brief Gets the next key in a keylist.
462 * @details The next key is known by the keylist internal cursor.
466 * @param[in] keylist The Key List
468 * @return The next Keynode,
469 * otherwise @c NULL on error
473 * @see vconf_keylist_rewind()
474 * @see vconf_keylist_nextnode()
477 keynode_t *vconf_keylist_nextnode(keylist_t *keylist);
480 * @brief Appends a new keynode containing an integer value to a keylist.
481 * @details If the same keyname exists, the keynode will change.
485 * @param[in] keylist The Key List
486 * @param[in] keyname The key
487 * @param[in] value The integer value
489 * @return The number of keynode included in the keylist,
490 * otherwise @c -1 on error
495 int vconf_keylist_add_int(keylist_t *keylist, const char *keyname,
499 * @brief Appends a new keynode containing a boolean value to a keylist.
500 * @details If the same keyname exist, the keynode will change.
504 * @param[in] keylist The Key List
505 * @param[in] keyname The key
506 * @param[in] value The boolean value
508 * @return The number of keynodes included in the keylist,
509 * otherwise @c -1 on error
513 * @see vconf_keylist_add_int()
514 * @see vconf_keylist_add_str()
515 * @see vconf_keylist_add_dbl()
516 * @see vconf_keylist_add_bool()
517 * @see vconf_keylist_del()
518 * @see vconf_keylist_add_null()
520 int vconf_keylist_add_bool(keylist_t *keylist, const char *keyname,
524 * @brief Appends a new keynode containing a double value to a keylist.
525 * @details If the same keyname exist, the keynode will change.
529 * @param[in] keylist The Key List
530 * @param[in] keyname The key
531 * @param[in] value The double value
533 * @return The number of the keynodes included in the keylist,
534 * otherwise @c -1 on error
538 * @see vconf_keylist_add_int()
539 * @see vconf_keylist_add_str()
540 * @see vconf_keylist_add_dbl()
541 * @see vconf_keylist_add_bool()
542 * @see vconf_keylist_del()
543 * @see vconf_keylist_add_null()
545 int vconf_keylist_add_dbl(keylist_t *keylist, const char *keyname,
549 * @brief Appends a new keynode containing a string to a keylist.
550 * @details If the same keyname exist, the keynode will change.
554 * @remarks The size limit of value is 4K.
556 * @param[in] keylist The Key List
557 * @param[in] keyname The key
558 * @param[in] value The pointer of string value
560 * @return The number of keynodes included in the keylist,
561 * otherwise @c -1 on error
565 * @see vconf_keylist_add_int()
566 * @see vconf_keylist_add_str()
567 * @see vconf_keylist_add_dbl()
568 * @see vconf_keylist_add_bool()
569 * @see vconf_keylist_del()
570 * @see vconf_keylist_add_null()
572 int vconf_keylist_add_str(keylist_t *keylist, const char *keyname,
576 * @brief Appends a new keynode to a keylist without a value.
577 * @details Uses for vconf_get().
581 * @param[in] keylist The Key List
582 * @param[in] keyname The key
584 * @return The number of the keynodes included in the keylist,
585 * otherwise @c -1 on error
589 * @see vconf_keylist_add_int()
590 * @see vconf_keylist_add_str()
591 * @see vconf_keylist_add_dbl()
592 * @see vconf_keylist_add_bool()
593 * @see vconf_keylist_del()
594 * @see vconf_keylist_add_null()
596 int vconf_keylist_add_null(keylist_t *keylist, const char *keyname);
599 * @brief Removes the keynode that matches the given keyname.
603 * @param[in] keylist The keylist containing the keyname
604 * @param[in] keyname The key
606 * @return @c 0 on success,
607 * @c -1 if invalid parameter),
608 * otherwise @c -2 (Not exist keyname in keylist) on error
612 * @see vconf_keylist_add_int()
613 * @see vconf_keylist_add_str()
614 * @see vconf_keylist_add_dbl()
615 * @see vconf_keylist_add_bool()
616 * @see vconf_keylist_del()
617 * @see vconf_keylist_add_null()
619 int vconf_keylist_del(keylist_t *keylist, const char *keyname);
621 /************************************************
623 ************************************************/
626 * @brief Sets the keys included in a keylist.
627 * @details If you use DB backend, the keylist is handled as one transaction.
631 * @param[in] keylist The keylist which should contain changed keys
633 * @return @c 0 on success,
634 * otherwise @c -1 on error
638 * @see vconf_keylist_add_int()
639 * @see vconf_keylist_add_str()
640 * @see vconf_keylist_add_dbl()
641 * @see vconf_keylist_add_bool()
642 * @see vconf_keylist_del()
643 * @see vconf_keylist_add_null()
653 const char *keyname_list[3]={"db/test/key1", "db/test/key2", "db/test/key3"};
655 // Transaction Test(all or nothing is written)
656 kl = vconf_keylist_new();
658 vconf_keylist_add_int(kl, keyname_list[0], 1);
659 vconf_keylist_add_str(kl, keyname_list[1], "transaction Test");
660 vconf_keylist_add_dbl(kl, keyname_list[2], 0.3);
662 fprintf(stderr, "nothing is written\n");
664 printf("everything is written\n");
666 vconf_keylist_free(kl);
668 // You can set items which have different backend.
669 kl = vconf_keylist_new();
671 vconf_keylist_add_int(kl, "memory/a/xxx1", 4);
672 vconf_keylist_add_str(kl, "file/a/xxx2", "test 3");
673 vconf_keylist_add_dbl(kl, "db/a/xxx3", 0.3);
676 vconf_keylist_free(kl);
681 int vconf_set(keylist_t *keylist);
684 * @brief Sets the integer value of the given key.
688 * @param[in] in_key The key
689 * @param[in] intval The integer value to set \n
690 * @c 0 is also allowed as a value.
692 * @return @c 0 on success,
693 * otherwise @c -1 on error
695 * @see vconf_set_bool()
696 * @see vconf_set_dbl()
697 * @see vconf_set_str()
699 int vconf_set_int(const char *in_key, const int intval);
702 * @brief Sets the boolean value of the given key.
706 * @param[in] in_key The key
707 * @param[in] boolval The Boolean value( @c 1 or @c 0) to set
708 * Integer value @c 1 is 'True', and @c 0 is 'False'.
710 * @return @c 0 on success,
711 * otherwise @c -1 on error
713 * @see vconf_set_int()
714 * @see vconf_set_dbl()
715 * @see vconf_set_str()
722 const char *key1_name="memory/test/key1";
724 int main(int argc, char **argv)
728 if(vconf_set_bool(key1_name, 1))
729 fprintf(stderr, "vconf_set_bool FAIL\n");
731 printf("vconf_set_bool OK\n");
733 if(vconf_get_bool(key1_name, &key1_value))
734 fprintf(stderr, "vconf_get_bool FAIL\n");
736 printf("vconf_get_bool OK(key1 value is %d)\n", key1_value);
742 int vconf_set_bool(const char *in_key, const int boolval);
745 * @brief Sets the double value of the given key.
749 * @param[in] in_key The key
750 * @param[in] dblval The double value to set \n
751 * @c 0.0 is also allowed as a value.
753 * @return @c 0 on success,
754 * otherwise @c -1 on error
756 * @see vconf_set_int()
757 * @see vconf_set_bool()
758 * @see vconf_set_str()
760 int vconf_set_dbl(const char *in_key, const double dblval);
763 * @brief Sets the string value of the given key.
767 * @remarks The size limit of value is 4K.
769 * @param[in] in_key The key
770 * @param[in] strval The string value to set
772 * @return @c 0 on success,
773 * otherwise -1 on error
775 * @see vconf_set_bool()
776 * @see vconf_set_dbl()
777 * @see vconf_set_int()
779 int vconf_set_str(const char *in_key, const char *strval);
782 * @brief Gets the keys or subdirectory in in_parentDIR.
783 * @details If the keylist has any key information, vconf only retrieves the keys.
784 * This is not recursive.
788 * @param[in] keylist The keylist created by vconf_keylist_new()
789 * @param[in] in_parentDIR The parent DIRECTORY of needed keys
790 * @param[in] option The options \n
791 * VCONF_GET_KEY|VCONF_GET_DIR|VCONF_GET_ALL
793 * @return @c 0 on success,
794 * otherwise @c -1 on error
804 keynode_t *temp_node;
805 const char *vconfkeys1="db/test/key1";
806 const char *parent_dir="db/test";
808 kl = vconf_keylist_new();
809 if(vconf_get(kl, parent_dir, 0))
810 fprintf(stderr, "vconf_get FAIL(%s)", vconfkeys1);
812 printf("vconf_get OK(%s)", vconfkeys1);
814 while((temp_node = vconf_keylist_nextnode(kl))) {
815 switch(vconf_keynode_get_type(temp_node)) {
817 printf("key = %s, value = %d\n",
818 vconf_keynode_get_name(temp_node), vconf_keynode_get_int(temp_node));
820 case VCONF_TYPE_BOOL:
821 printf("key = %s, value = %d\n",
822 vconf_keynode_get_name(temp_node), vconf_keynode_get_bool(temp_node));
824 case VCONF_TYPE_DOUBLE:
825 printf("key = %s, value = %f\n",
826 vconf_keynode_get_name(temp_node), vconf_keynode_get_dbl(temp_node));
828 case VCONF_TYPE_STRING:
829 printf("key = %s, value = %s\n",
830 vconf_keynode_get_name(temp_node), vconf_keynode_get_str(temp_node));
833 printf("Unknown Type\n");
836 vconf_keylist_free(kl);
840 int vconf_get(keylist_t *keylist, const char *in_parentDIR, get_option_t option);
843 * @brief Gets the integer value of the given key.
847 * @param[in] in_key The key
848 * @param[out] intval The output buffer
850 * @return @c 0 on success,
851 * otherwise @c -1 on error
853 * @see vconf_get_bool()
854 * @see vconf_get_dbl()
855 * @see vconf_get_str()
862 const char *key1_name="db/test/key1";
864 int main(int argc, char **argv)
868 if(vconf_set_int(key1_name,1))
869 fprintf(stderr, "vconf_set_int FAIL\n");
871 printf("vconf_set_int OK\n");
873 if(vconf_get_int(key1_name, &key1_value))
874 fprintf(stderr, "vconf_get_int FAIL\n");
876 printf("vconf_get_int OK(key1 value is %d)\n", key1_value);
882 int vconf_get_int(const char *in_key, int *intval);
885 * @brief Gets the boolean value (@c 1 or @c 0) of the given key.
889 * @param[in] in_key The key
890 * @param[out] boolval The output buffer
892 * @return @c 0 on success,
893 * otherwise @c -1 on error
895 * @see vconf_get_int()
896 * @see vconf_get_dbl()
897 * @see vconf_get_str()
899 int vconf_get_bool(const char *in_key, int *boolval);
902 * @brief Gets the double value of the given key.
906 * @param[in] in_key The key
907 * @param[out] dblval The output buffer
909 * @return @c 0 on success,
910 * otherwise @c -1 on error
912 * @see vconf_get_int()
913 * @see vconf_get_bool()
914 * @see vconf_get_str()
916 int vconf_get_dbl(const char *in_key, double *dblval);
919 * @brief Gets the string value of the given key.
920 * @details You have to free this returned value.
924 * @param[in] in_key The key
926 * @return The allocated pointer of key value on success,
927 * otherwise @c NULL on error
929 * @see vconf_get_int()
930 * @see vconf_get_dbl()
931 * @see vconf_get_bool()
938 char *get_str=vconf_get_str("db/test/test1");
940 printf("vconf_get_str OK(value = %s)", get_str);
943 fprintf(stderr, "vconf_get_str FAIL");
946 char *vconf_get_str(const char *in_key);
949 * @brief Deletes the given key from the backend system.
953 * @param[in] in_key The key
955 * @return @c 0 on success,
956 * otherwise @c -1 on error
958 int vconf_unset(const char *in_key);
961 * @brief Synchronizes the given key (only file backend) with the storage device.
965 * @param[in] in_key The key
967 * @return @c 0 on success,
968 * otherwise @c -1 on error
972 if(vconf_set_int("file/test/key1",1))
973 fprintf(stderr, "vconf_set_int FAIL\n");
975 printf("vconf_set_int OK\n");
976 vconf_sync_key("file/test/key1");
980 int vconf_sync_key(const char *in_key);
983 * @brief Deletes all keys and directories below the given directory from the backend system.
987 * @param[in] in_dir The directory name for removal
989 * @return @c 0 on success,
990 * otherwise @c -1 on error
994 vconf_set_int("db/test/key1",1);
995 vconf_set_int("db/test/test1/key1",1);
996 vconf_set_int("db/test/test2/key1",1);
997 vconf_set_int("db/test/key2",1);
999 if(vconf_unset_recursive("db/test"))
1000 fprintf(stderr, "vconf_unset_recursive FAIL\n");
1002 printf("vconf_unset_recursive OK(deleted db/test\n");
1006 int vconf_unset_recursive(const char *in_dir);
1009 * @brief Adds a change callback for the given key, which is called when the key is set or unset.
1010 * @details The changed information (#keynode_t) of the key is delivered to #vconf_callback_fn,
1011 * or if the key is deleted, the @link #keynode_t keynode @endlink has #VCONF_TYPE_NONE as type.
1013 * @details Multiple vconf_callback_fn functions may exist for one key.
1015 * @details The callback is issued in the context of the glib main loop.
1019 * @remarks: This callback mechanism DOES NOT GUARANTEE consistency of data change. For example,
1020 * When you have a callback for a certain key, assume that two or more processes are trying to
1021 * change the value of the key competitively. In this case, the callback function will always
1022 * get the 'CURRENT' value, not the value which raised the notification and caused the callback call.
1023 * So, do not use vconf callback when competitive write for a key is happening. In such case, use
1024 * socket-based IPC (dbus or something else) instead.
1026 * @param[in] in_key The key
1027 * @param[in] cb The callback function
1028 * @param[in] user_data The callback data
1030 * @return @c 0 on success,
1031 * otherwise @c -1 on error
1033 * @see vconf_ignore_key_changed
1037 void test_cb(keynode_t *key, void* data)
1039 switch(vconf_keynode_get_type(key))
1041 case VCONF_TYPE_INT:
1042 printf("key = %s, value = %d(int)\n",
1043 vconf_keynode_get_name(key), vconf_keynode_get_int(key));
1045 case VCONF_TYPE_BOOL:
1046 printf("key = %s, value = %d(bool)\n",
1047 vconf_keynode_get_name(key), vconf_keynode_get_bool(key));
1049 case VCONF_TYPE_DOUBLE:
1050 printf("key = %s, value = %f(double)\n",
1051 vconf_keynode_get_name(key), vconf_keynode_get_dbl(key));
1053 case VCONF_TYPE_STRING:
1054 printf("key = %s, value = %s(string)\n",
1055 vconf_keynode_get_name(key), vconf_keynode_get_str(key));
1058 fprintf(stderr, "Unknown Type(%d)\n", vconf_keynode_get_type(key));
1067 GMainLoop *event_loop;
1071 vconf_notify_key_changed("db/test/test1", test_cb, NULL);
1073 event_loop = g_main_loop_new(NULL, FALSE);
1074 g_main_loop_run(event_loop);
1076 vconf_ignore_key_changed("db/test/test1", test_cb);
1081 int vconf_notify_key_changed(const char *in_key, vconf_callback_fn cb,
1085 * @brief Removes a change callback for the given key,
1086 * which was added by vconf_notify_key_changed().
1090 * @param[in] in_key The key
1091 * @param[in] cb The callback function
1093 * @return @c 0 on success,
1094 * otherwise @c -1 on error
1096 * @see vconf_notify_key_changed()
1098 int vconf_ignore_key_changed(const char *in_key, vconf_callback_fn cb);
1101 * This function sorts the list in alphabetical order (with LANG=C)
1102 * @param[in] keylist Key List
1103 * @return 0 if done, -1 on error
1108 int vconf_keylist_sort(keylist_t * keylist);
1111 * This function retrieves the keys or subdirectory in in_parentDIR.<br>
1112 * @param[in] keylist keylist created by vconf_keylist_new(), MUST be empty
1113 * @param[in] in_parentDIR parent DIRECTORY of needed keys
1114 * @param[in] option VCONF_GET_KEY|VCONF_GET_DIR|VCONF_GET_ALL|VCONF_GET_KEY_REC|VCONF_GET_DIR_REC|VCONF_GET_ALL_REC
1115 * @return 0 on success, -1 on error
1127 keynode_t *temp_node;
1128 const char *vconfkeys1="db/test/key1";
1129 const char *parent_dir="db/test";
1131 kl = vconf_keylist_new();
1132 if(vconf_scan(kl, parent_dir, VCONF_GET_KEY))
1133 fprintf(stderr, "vconf_get FAIL(%s)", vconfkeys1);
1135 printf("vconf_get OK(%s)", vconfkeys1);
1137 while((temp_node = vconf_keylist_nextnode(kl))) {
1138 switch(vconf_keynode_get_type(temp_node)) {
1139 case VCONF_TYPE_INT:
1140 printf("key = %s, value = %d\n",
1141 vconf_keynode_get_name(temp_node), vconf_keynode_get_int(temp_node));
1143 case VCONF_TYPE_BOOL:
1144 printf("key = %s, value = %d\n",
1145 vconf_keynode_get_name(temp_node), vconf_keynode_get_bool(temp_node));
1147 case VCONF_TYPE_DOUBLE:
1148 printf("key = %s, value = %f\n",
1149 vconf_keynode_get_name(temp_node), vconf_keynode_get_dbl(temp_node));
1151 case VCONF_TYPE_STRING:
1152 printf("key = %s, value = %s\n",
1153 vconf_keynode_get_name(temp_node), vconf_keynode_get_str(temp_node));
1156 printf("Unknown Type\n");
1159 vconf_keylist_free(kl);
1163 int vconf_scan(keylist_t * keylist,
1164 const char *in_parentDIR,
1165 get_option_t option);
1168 * This function reads the database to refresh the values of
1169 * the keys in 'keylist'.
1170 * @param[in] keylist the keylist whose values have to be refreshed
1171 * @return 0 on success, -1 on error
1172 * @see vconf_keylist_lookup, vconf_keylist_nextnode, vconf_keylist_rewind
1174 int vconf_refresh(keylist_t * keylist);
1177 * This function set the smack label of its keys
1178 * @param[in] keylist Key List
1179 * @param[in] label The label to set
1180 * @return 0 if done, -1 on error
1186 int vconf_set_labels(keylist_t * keylist, const char *label);
1189 * This function set the smack label of its keys
1190 * @param[in] keylist Key List
1191 * @param[in] label The label to set
1192 * @return 0 if done, -1 on error
1197 int vconf_set_label(const char *keyname, const char *label);
1200 * Set the default group of key lists created using vconf_keylist_new.
1201 * @param[in] groupname The name of the default group to bind to
1202 * @return 0 in case of success or -1 in case of error of allocation
1203 * @see vconf_keylist_new()
1205 int vconf_set_default_group(const char *groupname);
1208 * This function checks if the given key exists from backend system.
1209 * @param[in] keyname key
1210 * @return 0 on success: exists, -1 on error or not existing
1212 int vconf_exists(const char *keyname);
1215 * This function returns result of last api call
1216 * @return The result of last api call
1217 * @retval #VCONF_OK Successful
1218 * @retval #VCONF_ERROR General error
1219 * @retval #VCONF_ERROR_FILE_NO_ENT No such key
1220 * @retval #VCONF_ERROR_FILE_PERM Permission denied
1222 int vconf_get_ext_errno(void);
1231 #endif /* __VCONF_BUXTON_H__ */