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);
88 #include "vconf-buxton-keys.h"
95 * @brief Enumeration for uses of vconf_get().
101 /**< get only keys */
103 /**< get keys and directorys */
105 /**< get only directorys */
107 /**< get only keys */
109 /**< get only keys recursively */
111 /**< get keys and directorys recursively */
113 /**< get only directorys recursively */
117 * @brief Enumeration for Definition for Enumeration type.
121 typedef enum get_option_t get_option_t;
124 * @brief Enumeration for vconf_t.
130 /**< Vconf none type for Error detection */
131 VCONF_TYPE_STRING = 40,
132 /**< Vconf string type */
134 /**< Vconf integer type */
135 VCONF_TYPE_DOUBLE = 42,
136 /**< Vconf double type */
137 VCONF_TYPE_BOOL = 43,
138 /**< Vconf boolean type */
140 /**< Vconf directory type */
145 * @brief The structure type for an opaque type. It must be used via accessor functions.
148 * @see vconf_keynode_get_name()
149 * @see vconf_keynode_get_type()
150 * @see vconf_keynode_get_bool()
151 * @see vconf_keynode_get_dbl()
152 * @see vconf_keynode_get_int()
153 * @see vconf_keynode_get_str()
155 typedef struct _keynode_t keynode_t;
158 * @brief The structure type for opaque type. It must be used via accessor functions.
161 * @see vconf_keylist_new()
162 * @see vconf_keylist_free()
163 * @see vconf_keylist_add_bool()
164 * @see vconf_keylist_add_str()
165 * @see vconf_keylist_add_dbl()
166 * @see vconf_keylist_add_int()
167 * @see vconf_keylist_del()
168 * @see vconf_keylist_add_null()
169 * @see vconf_keylist_lookup()
170 * @see vconf_keylist_nextnode()
171 * @see vconf_keylist_rewind()
173 typedef struct _keylist_t keylist_t;
177 * @brief Called when the key is set handle.
178 * @details This is the signature of a callback function added with vconf_notify_key_changed() handle.
184 typedef void (*vconf_callback_fn) (keynode_t *node, void *user_data);
186 /************************************************
187 * keynode handling APIs *
188 ************************************************/
191 * @brief Gets the key name of a keynode.
195 * @param[in] keynode The Key
197 * @return The key name of the keynode
199 * @see vconf_notify_key_changed()
200 * @see vconf_keynode_get_bool()
201 * @see vconf_keynode_get_type()
202 * @see vconf_keynode_get_str()
203 * @see vconf_keynode_get_int()
204 * @see vconf_keynode_get_dbl()
208 const char *vconf_keynode_get_name(keynode_t *keynode);
211 * @brief Gets the value type of a keynode.
215 * @param[in] keynode The Key
217 * @return The type of the keynode
219 * @see vconf_notify_key_changed()
220 * @see vconf_keynode_get_name()
221 * @see vconf_keynode_get_bool()
222 * @see vconf_keynode_get_str()
223 * @see vconf_keynode_get_int()
224 * @see vconf_keynode_get_dbl()
228 int vconf_keynode_get_type(keynode_t *keynode);
231 * @brief Gets the integer value of a keynode.
235 * @param[in] keynode The Key
237 * @return The integer value,
238 * otherwise @c 0 if no value is obtained
240 * @see vconf_notify_key_changed()
241 * @see vconf_keynode_get_name()
242 * @see vconf_keynode_get_bool()
243 * @see vconf_keynode_get_type()
244 * @see vconf_keynode_get_str()
245 * @see vconf_keynode_get_dbl()
249 int vconf_keynode_get_int(keynode_t *keynode);
252 * @brief Gets the double value of a keynode.
256 * @param[in] keynode The Key
258 * @return The double value,
259 * otherwise @c 0.0 if no value is obtained
261 * @see vconf_notify_key_changed()
262 * @see vconf_keynode_get_name()
263 * @see vconf_keynode_get_bool()
264 * @see vconf_keynode_get_type()
265 * @see vconf_keynode_get_str()
266 * @see vconf_keynode_get_int()
270 double vconf_keynode_get_dbl(keynode_t *keynode);
273 * @brief Gets the boolean value of a keynode.
277 * @param[in] keynode The Key
279 * @return The boolean value,
280 * otherwise @c -1 on error \n
281 * Integer value @c 1 is 'True', and @c 0 is 'False'.
283 * @see vconf_notify_key_changed()
284 * @see vconf_keynode_get_name()
285 * @see vconf_keynode_get_type()
286 * @see vconf_keynode_get_str()
287 * @see vconf_keynode_get_int()
288 * @see vconf_keynode_get_dbl()
292 int vconf_keynode_get_bool(keynode_t *keynode);
295 * @brief Gets the string value of a keynode.
299 * @param[in] keynode The Key
301 * @return The string value,
302 * otherwise @c NULL if no value is obtained
304 * @see vconf_notify_key_changed()
305 * @see vconf_keynode_get_name()
306 * @see vconf_keynode_get_bool()
307 * @see vconf_keynode_get_type()
308 * @see vconf_keynode_get_int()
309 * @see vconf_keynode_get_dbl()
313 char *vconf_keynode_get_str(keynode_t *keynode);
316 /************************************************
317 * keylist handling APIs
318 ************************************************/
321 * @brief Allocates, initializes and returns a new keylist object.
322 * @details You must release the return value keylist_t* pointer using vconf_keylist_free().
326 * @return The pointer of New keylist,
327 * otherwise @c NULL on error
331 * @see vconf_keylist_new()
332 * @see vconf_keylist_free()
334 keylist_t *vconf_keylist_new(void);
337 * @brief Moves the current keynode position to the first item.
341 * @param[in] keylist The Key List
343 * @return @c 0 on success,
344 * otherwise -1 on error
348 * @see vconf_keylist_nextnode()
349 * @see vconf_keylist_rewind()
350 * @see vconf_keylist_nextnode()
355 keylist_t* pKeyList = NULL;
356 pKeyList = vconf_keylist_new();
358 r = vconf_get(pKeyList, KEY_PARENT, VCONF_GET_KEY);
360 tet_infoline("vconf_get() failed in positive test case");
361 tet_result(TET_FAIL);
365 vconf_keylist_nextnode(pKeyList);
366 vconf_keylist_nextnode(pKeyList);
368 // Move first position from KeyList
369 r = vconf_keylist_rewind(pKeyList);
371 tet_infoline("vconf_keylist_rewind() failed in positive test case");
372 tet_result(TET_FAIL);
376 while(vconf_keylist_nextnode(pKeyList)) ;
379 int vconf_keylist_rewind(keylist_t *keylist);
382 * @brief Destroys a keylist.
383 * @details After calling vconf_keylist_new(), you must call this function to release internal memory.
387 * @param[in] keylist The Key List
389 * @return @c 0 on success,
390 * otherwise @c -1 on error
394 * @see vconf_keylist_new()
396 int vconf_keylist_free(keylist_t *keylist);
399 * @brief Looks for a keynode contained in a keylist that matches the keyname.
403 * @param[in] keylist The Key List
404 * @param[in] keyname The key to find
405 * @param[out] return_node The pointer of the keynode to set
407 * @return The type of the found key that is vconf_t enumeration value
422 keylist_t* pKeyList = NULL;
425 pKeyList = vconf_keylist_new();
426 r = vconf_get(pKeyList, KEY_PARENT, VCONF_GET_KEY);
428 printf("vconf_get() failed in positive test case");
432 r = vconf_keylist_lookup(pKeyList, KEY_02, &pKeyNode);
434 printf("vconf_get() failed in positive test case");
438 nResult = vconf_keynode_get_int(pKeyNode);
439 if(nResult !=KEY_02_INT_VALUE)
441 printf("vconf_get() failed in positive test case");
446 vconf_keylist_free(pKeyList);
451 int vconf_keylist_lookup(keylist_t *keylist, const char *keyname,
452 keynode_t **return_node);
455 * @brief Gets the next key in a keylist.
456 * @details The next key is known by the keylist internal cursor.
460 * @param[in] keylist The Key List
462 * @return The next Keynode,
463 * otherwise @c NULL on error
467 * @see vconf_keylist_rewind()
468 * @see vconf_keylist_nextnode()
471 keynode_t *vconf_keylist_nextnode(keylist_t *keylist);
474 * @brief Appends a new keynode containing an integer value to a keylist.
475 * @details If the same keyname exists, the keynode will change.
479 * @param[in] keylist The Key List
480 * @param[in] keyname The key
481 * @param[in] value The integer value
483 * @return The number of keynode included in the keylist,
484 * otherwise @c -1 on error
489 int vconf_keylist_add_int(keylist_t *keylist, const char *keyname,
493 * @brief Appends a new keynode containing a boolean value to a keylist.
494 * @details If the same keyname exist, the keynode will change.
498 * @param[in] keylist The Key List
499 * @param[in] keyname The key
500 * @param[in] value The boolean value
502 * @return The number of keynodes included in the keylist,
503 * otherwise @c -1 on error
507 * @see vconf_keylist_add_int()
508 * @see vconf_keylist_add_str()
509 * @see vconf_keylist_add_dbl()
510 * @see vconf_keylist_add_bool()
511 * @see vconf_keylist_del()
512 * @see vconf_keylist_add_null()
514 int vconf_keylist_add_bool(keylist_t *keylist, const char *keyname,
518 * @brief Appends a new keynode containing a double value to a keylist.
519 * @details If the same keyname exist, the keynode will change.
523 * @param[in] keylist The Key List
524 * @param[in] keyname The key
525 * @param[in] value The double value
527 * @return The number of the keynodes included in the keylist,
528 * otherwise @c -1 on error
532 * @see vconf_keylist_add_int()
533 * @see vconf_keylist_add_str()
534 * @see vconf_keylist_add_dbl()
535 * @see vconf_keylist_add_bool()
536 * @see vconf_keylist_del()
537 * @see vconf_keylist_add_null()
539 int vconf_keylist_add_dbl(keylist_t *keylist, const char *keyname,
543 * @brief Appends a new keynode containing a string to a keylist.
544 * @details If the same keyname exist, the keynode will change.
548 * @remarks The size limit of value is 4K.
550 * @param[in] keylist The Key List
551 * @param[in] keyname The key
552 * @param[in] value The pointer of string value
554 * @return The number of keynodes included in the keylist,
555 * otherwise @c -1 on error
559 * @see vconf_keylist_add_int()
560 * @see vconf_keylist_add_str()
561 * @see vconf_keylist_add_dbl()
562 * @see vconf_keylist_add_bool()
563 * @see vconf_keylist_del()
564 * @see vconf_keylist_add_null()
566 int vconf_keylist_add_str(keylist_t *keylist, const char *keyname,
570 * @brief Appends a new keynode to a keylist without a value.
571 * @details Uses for vconf_get().
575 * @param[in] keylist The Key List
576 * @param[in] keyname The key
578 * @return The number of the keynodes included in the keylist,
579 * otherwise @c -1 on error
583 * @see vconf_keylist_add_int()
584 * @see vconf_keylist_add_str()
585 * @see vconf_keylist_add_dbl()
586 * @see vconf_keylist_add_bool()
587 * @see vconf_keylist_del()
588 * @see vconf_keylist_add_null()
590 int vconf_keylist_add_null(keylist_t *keylist, const char *keyname);
593 * @brief Removes the keynode that matches the given keyname.
597 * @param[in] keylist The keylist containing the keyname
598 * @param[in] keyname The key
600 * @return @c 0 on success,
601 * @c -1 if invalid parameter),
602 * otherwise @c -2 (Not exist keyname in keylist) on error
606 * @see vconf_keylist_add_int()
607 * @see vconf_keylist_add_str()
608 * @see vconf_keylist_add_dbl()
609 * @see vconf_keylist_add_bool()
610 * @see vconf_keylist_del()
611 * @see vconf_keylist_add_null()
613 int vconf_keylist_del(keylist_t *keylist, const char *keyname);
615 /************************************************
617 ************************************************/
620 * @brief Sets the keys included in a keylist.
621 * @details If you use DB backend, the keylist is handled as one transaction.
625 * @param[in] keylist The keylist which should contain changed keys
627 * @return @c 0 on success,
628 * otherwise @c -1 on error
632 * @see vconf_keylist_add_int()
633 * @see vconf_keylist_add_str()
634 * @see vconf_keylist_add_dbl()
635 * @see vconf_keylist_add_bool()
636 * @see vconf_keylist_del()
637 * @see vconf_keylist_add_null()
647 const char *keyname_list[3]={"db/test/key1", "db/test/key2", "db/test/key3"};
649 // Transaction Test(all or nothing is written)
650 kl = vconf_keylist_new();
652 vconf_keylist_add_int(kl, keyname_list[0], 1);
653 vconf_keylist_add_str(kl, keyname_list[1], "transaction Test");
654 vconf_keylist_add_dbl(kl, keyname_list[2], 0.3);
656 fprintf(stderr, "nothing is written\n");
658 printf("everything is written\n");
660 vconf_keylist_free(kl);
662 // You can set items which have different backend.
663 kl = vconf_keylist_new();
665 vconf_keylist_add_int(kl, "memory/a/xxx1", 4);
666 vconf_keylist_add_str(kl, "file/a/xxx2", "test 3");
667 vconf_keylist_add_dbl(kl, "db/a/xxx3", 0.3);
670 vconf_keylist_free(kl);
675 int vconf_set(keylist_t *keylist);
678 * @brief Sets the integer value of the given key.
682 * @param[in] in_key The key
683 * @param[in] intval The integer value to set \n
684 * @c 0 is also allowed as a value.
686 * @return @c 0 on success,
687 * otherwise @c -1 on error
689 * @see vconf_set_bool()
690 * @see vconf_set_dbl()
691 * @see vconf_set_str()
693 int vconf_set_int(const char *in_key, const int intval);
696 * @brief Sets the boolean value of the given key.
700 * @param[in] in_key The key
701 * @param[in] boolval The Boolean value( @c 1 or @c 0) to set
702 * Integer value @c 1 is 'True', and @c 0 is 'False'.
704 * @return @c 0 on success,
705 * otherwise @c -1 on error
707 * @see vconf_set_int()
708 * @see vconf_set_dbl()
709 * @see vconf_set_str()
716 const char *key1_name="memory/test/key1";
718 int main(int argc, char **argv)
722 if(vconf_set_bool(key1_name, 1))
723 fprintf(stderr, "vconf_set_bool FAIL\n");
725 printf("vconf_set_bool OK\n");
727 if(vconf_get_bool(key1_name, &key1_value))
728 fprintf(stderr, "vconf_get_bool FAIL\n");
730 printf("vconf_get_bool OK(key1 value is %d)\n", key1_value);
736 int vconf_set_bool(const char *in_key, const int boolval);
739 * @brief Sets the double value of the given key.
743 * @param[in] in_key The key
744 * @param[in] dblval The double value to set \n
745 * @c 0.0 is also allowed as a value.
747 * @return @c 0 on success,
748 * otherwise @c -1 on error
750 * @see vconf_set_int()
751 * @see vconf_set_bool()
752 * @see vconf_set_str()
754 int vconf_set_dbl(const char *in_key, const double dblval);
757 * @brief Sets the string value of the given key.
761 * @remarks The size limit of value is 4K.
763 * @param[in] in_key The key
764 * @param[in] strval The string value to set
766 * @return @c 0 on success,
767 * otherwise -1 on error
769 * @see vconf_set_bool()
770 * @see vconf_set_dbl()
771 * @see vconf_set_int()
773 int vconf_set_str(const char *in_key, const char *strval);
776 * @brief Gets the keys or subdirectory in in_parentDIR.
777 * @details If the keylist has any key information, vconf only retrieves the keys.
778 * This is not recursive.
782 * @param[in] keylist The keylist created by vconf_keylist_new()
783 * @param[in] in_parentDIR The parent DIRECTORY of needed keys
784 * @param[in] option The options \n
785 * VCONF_GET_KEY|VCONF_GET_DIR|VCONF_GET_ALL
787 * @return @c 0 on success,
788 * otherwise @c -1 on error
798 keynode_t *temp_node;
799 const char *vconfkeys1="db/test/key1";
800 const char *parent_dir="db/test";
802 kl = vconf_keylist_new();
803 if(vconf_get(kl, parent_dir, 0))
804 fprintf(stderr, "vconf_get FAIL(%s)", vconfkeys1);
806 printf("vconf_get OK(%s)", vconfkeys1);
808 while((temp_node = vconf_keylist_nextnode(kl))) {
809 switch(vconf_keynode_get_type(temp_node)) {
811 printf("key = %s, value = %d\n",
812 vconf_keynode_get_name(temp_node), vconf_keynode_get_int(temp_node));
814 case VCONF_TYPE_BOOL:
815 printf("key = %s, value = %d\n",
816 vconf_keynode_get_name(temp_node), vconf_keynode_get_bool(temp_node));
818 case VCONF_TYPE_DOUBLE:
819 printf("key = %s, value = %f\n",
820 vconf_keynode_get_name(temp_node), vconf_keynode_get_dbl(temp_node));
822 case VCONF_TYPE_STRING:
823 printf("key = %s, value = %s\n",
824 vconf_keynode_get_name(temp_node), vconf_keynode_get_str(temp_node));
827 printf("Unknown Type\n");
830 vconf_keylist_free(kl);
834 int vconf_get(keylist_t *keylist, const char *in_parentDIR, get_option_t option);
837 * @brief Gets the integer value of the given key.
841 * @param[in] in_key The key
842 * @param[out] intval The output buffer
844 * @return @c 0 on success,
845 * otherwise @c -1 on error
847 * @see vconf_get_bool()
848 * @see vconf_get_dbl()
849 * @see vconf_get_str()
856 const char *key1_name="db/test/key1";
858 int main(int argc, char **argv)
862 if(vconf_set_int(key1_name,1))
863 fprintf(stderr, "vconf_set_int FAIL\n");
865 printf("vconf_set_int OK\n");
867 if(vconf_get_int(key1_name, &key1_value))
868 fprintf(stderr, "vconf_get_int FAIL\n");
870 printf("vconf_get_int OK(key1 value is %d)\n", key1_value);
876 int vconf_get_int(const char *in_key, int *intval);
879 * @brief Gets the boolean value (@c 1 or @c 0) of the given key.
883 * @param[in] in_key The key
884 * @param[out] boolval The output buffer
886 * @return @c 0 on success,
887 * otherwise @c -1 on error
889 * @see vconf_get_int()
890 * @see vconf_get_dbl()
891 * @see vconf_get_str()
893 int vconf_get_bool(const char *in_key, int *boolval);
896 * @brief Gets the double value of the given key.
900 * @param[in] in_key The key
901 * @param[out] dblval The output buffer
903 * @return @c 0 on success,
904 * otherwise @c -1 on error
906 * @see vconf_get_int()
907 * @see vconf_get_bool()
908 * @see vconf_get_str()
910 int vconf_get_dbl(const char *in_key, double *dblval);
913 * @brief Gets the string value of the given key.
914 * @details You have to free this returned value.
918 * @param[in] in_key The key
920 * @return The allocated pointer of key value on success,
921 * otherwise @c NULL on error
923 * @see vconf_get_int()
924 * @see vconf_get_dbl()
925 * @see vconf_get_bool()
932 char *get_str=vconf_get_str("db/test/test1");
934 printf("vconf_get_str OK(value = %s)", get_str);
937 fprintf(stderr, "vconf_get_str FAIL");
940 char *vconf_get_str(const char *in_key);
943 * @brief Deletes the given key from the backend system.
947 * @param[in] in_key The key
949 * @return @c 0 on success,
950 * otherwise @c -1 on error
952 int vconf_unset(const char *in_key);
955 * @brief Synchronizes the given key (only file backend) with the storage device.
959 * @param[in] in_key The key
961 * @return @c 0 on success,
962 * otherwise @c -1 on error
966 if(vconf_set_int("file/test/key1",1))
967 fprintf(stderr, "vconf_set_int FAIL\n");
969 printf("vconf_set_int OK\n");
970 vconf_sync_key("file/test/key1");
974 int vconf_sync_key(const char *in_key);
977 * @brief Deletes all keys and directories below the given directory from the backend system.
981 * @param[in] in_dir The directory name for removal
983 * @return @c 0 on success,
984 * otherwise @c -1 on error
988 vconf_set_int("db/test/key1",1);
989 vconf_set_int("db/test/test1/key1",1);
990 vconf_set_int("db/test/test2/key1",1);
991 vconf_set_int("db/test/key2",1);
993 if(vconf_unset_recursive("db/test"))
994 fprintf(stderr, "vconf_unset_recursive FAIL\n");
996 printf("vconf_unset_recursive OK(deleted db/test\n");
1000 int vconf_unset_recursive(const char *in_dir);
1003 * @brief Adds a change callback for the given key, which is called when the key is set or unset.
1004 * @details The changed information (#keynode_t) of the key is delivered to #vconf_callback_fn,
1005 * or if the key is deleted, the @link #keynode_t keynode @endlink has #VCONF_TYPE_NONE as type.
1007 * @details Multiple vconf_callback_fn functions may exist for one key.
1009 * @details The callback is issued in the context of the glib main loop.
1013 * @remarks: This callback mechanism DOES NOT GUARANTEE consistency of data change. For example,
1014 * When you have a callback for a certain key, assume that two or more processes are trying to
1015 * change the value of the key competitively. In this case, the callback function will always
1016 * get the 'CURRENT' value, not the value which raised the notification and caused the callback call.
1017 * So, do not use vconf callback when competitive write for a key is happening. In such case, use
1018 * socket-based IPC (dbus or something else) instead.
1020 * @param[in] in_key The key
1021 * @param[in] cb The callback function
1022 * @param[in] user_data The callback data
1024 * @return @c 0 on success,
1025 * otherwise @c -1 on error
1027 * @see vconf_ignore_key_changed
1031 void test_cb(keynode_t *key, void* data)
1033 switch(vconf_keynode_get_type(key))
1035 case VCONF_TYPE_INT:
1036 printf("key = %s, value = %d(int)\n",
1037 vconf_keynode_get_name(key), vconf_keynode_get_int(key));
1039 case VCONF_TYPE_BOOL:
1040 printf("key = %s, value = %d(bool)\n",
1041 vconf_keynode_get_name(key), vconf_keynode_get_bool(key));
1043 case VCONF_TYPE_DOUBLE:
1044 printf("key = %s, value = %f(double)\n",
1045 vconf_keynode_get_name(key), vconf_keynode_get_dbl(key));
1047 case VCONF_TYPE_STRING:
1048 printf("key = %s, value = %s(string)\n",
1049 vconf_keynode_get_name(key), vconf_keynode_get_str(key));
1052 fprintf(stderr, "Unknown Type(%d)\n", vconf_keynode_get_type(key));
1061 GMainLoop *event_loop;
1065 vconf_notify_key_changed("db/test/test1", test_cb, NULL);
1067 event_loop = g_main_loop_new(NULL, FALSE);
1068 g_main_loop_run(event_loop);
1070 vconf_ignore_key_changed("db/test/test1", test_cb);
1075 int vconf_notify_key_changed(const char *in_key, vconf_callback_fn cb,
1079 * @brief Removes a change callback for the given key,
1080 * which was added by vconf_notify_key_changed().
1084 * @param[in] in_key The key
1085 * @param[in] cb The callback function
1087 * @return @c 0 on success,
1088 * otherwise @c -1 on error
1090 * @see vconf_notify_key_changed()
1092 int vconf_ignore_key_changed(const char *in_key, vconf_callback_fn cb);
1095 * This function sorts the list in alphabetical order (with LANG=C)
1096 * @param[in] keylist Key List
1097 * @return 0 if done, -1 on error
1102 int vconf_keylist_sort(keylist_t * keylist);
1105 * This function retrieves the keys or subdirectory in in_parentDIR.<br>
1106 * @param[in] keylist keylist created by vconf_keylist_new(), MUST be empty
1107 * @param[in] in_parentDIR parent DIRECTORY of needed keys
1108 * @param[in] option VCONF_GET_KEY|VCONF_GET_DIR|VCONF_GET_ALL|VCONF_GET_KEY_REC|VCONF_GET_DIR_REC|VCONF_GET_ALL_REC
1109 * @return 0 on success, -1 on error
1121 keynode_t *temp_node;
1122 const char *vconfkeys1="db/test/key1";
1123 const char *parent_dir="db/test";
1125 kl = vconf_keylist_new();
1126 if(vconf_scan(kl, parent_dir, VCONF_GET_KEY))
1127 fprintf(stderr, "vconf_get FAIL(%s)", vconfkeys1);
1129 printf("vconf_get OK(%s)", vconfkeys1);
1131 while((temp_node = vconf_keylist_nextnode(kl))) {
1132 switch(vconf_keynode_get_type(temp_node)) {
1133 case VCONF_TYPE_INT:
1134 printf("key = %s, value = %d\n",
1135 vconf_keynode_get_name(temp_node), vconf_keynode_get_int(temp_node));
1137 case VCONF_TYPE_BOOL:
1138 printf("key = %s, value = %d\n",
1139 vconf_keynode_get_name(temp_node), vconf_keynode_get_bool(temp_node));
1141 case VCONF_TYPE_DOUBLE:
1142 printf("key = %s, value = %f\n",
1143 vconf_keynode_get_name(temp_node), vconf_keynode_get_dbl(temp_node));
1145 case VCONF_TYPE_STRING:
1146 printf("key = %s, value = %s\n",
1147 vconf_keynode_get_name(temp_node), vconf_keynode_get_str(temp_node));
1150 printf("Unknown Type\n");
1153 vconf_keylist_free(kl);
1157 int vconf_scan(keylist_t * keylist,
1158 const char *in_parentDIR,
1159 get_option_t option);
1162 * This function reads the database to refresh the values of
1163 * the keys in 'keylist'.
1164 * @param[in] keylist the keylist whose values have to be refreshed
1165 * @return 0 on success, -1 on error
1166 * @see vconf_keylist_lookup, vconf_keylist_nextnode, vconf_keylist_rewind
1168 int vconf_refresh(keylist_t * keylist);
1171 * This function set the smack label of its keys
1172 * @param[in] keylist Key List
1173 * @param[in] label The label to set
1174 * @return 0 if done, -1 on error
1180 int vconf_set_labels(keylist_t * keylist, const char *label);
1183 * This function set the smack label of its keys
1184 * @param[in] keylist Key List
1185 * @param[in] label The label to set
1186 * @return 0 if done, -1 on error
1191 int vconf_set_label(const char *keyname, const char *label);
1194 * Set the default group of key lists created using vconf_keylist_new.
1195 * @param[in] groupname The name of the default group to bind to
1196 * @return 0 in case of success or -1 in case of error of allocation
1197 * @see vconf_keylist_new()
1199 int vconf_set_default_group(const char *groupname);
1202 * This function checks if the given key exists from backend system.
1203 * @param[in] keyname key
1204 * @return 0 on success: exists, -1 on error or not existing
1206 int vconf_exists(const char *keyname);
1216 #endif /* __VCONF_BUXTON_H__ */