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.
18 #ifndef __TIZEN_APPFW_PREFERENCE_INTERNAL_H__
19 #define __TIZEN_APPFW_PREFERENCE_INTERNAL_H__
25 #include "app_preference_log.h"
26 #include "linux/limits.h"
28 #define BUF_LEN (4096)
29 #define PREF_DIR ".pref/"
31 #define PREFERENCE_KEY_PATH_LEN 1024
34 #define PREF_DB_NAME ".pref.db"
35 #define PREF_TBL_NAME "pref"
36 #define PREF_F_KEY_NAME "pref_key"
37 #define PREF_F_TYPE_NAME "pref_type"
38 #define PREF_F_DATA_NAME "pref_data"
41 #define PREF_KEYNAME_C_PAD '='
42 #define PREF_KEYNAME_C_PLUS '+'
43 #define PREF_KEYNAME_C_SLASH '/'
45 #define PREF_KEYNAME_C_DOT '.'
46 #define PREF_KEYNAME_C_UNDERSCORE '_'
47 #define PREF_KEYNAME_C_HYPHEN '-'
50 * @brief Definition for PREFERENCE_ERROR_WRONG_PREFIX.
52 #define PREFERENCE_ERROR_WRONG_PREFIX -2
55 * @brief Definition for PREFERENCE_ERROR_WRONG_TYPE.
57 #define PREFERENCE_ERROR_WRONG_TYPE -3
60 * @brief Definition for PREFERENCE_ERROR_FILE_OPEN.
62 #define PREFERENCE_ERROR_FILE_OPEN -21
65 * @brief Definition for PREFERENCE_ERROR_FILE_FREAD.
67 #define PREFERENCE_ERROR_FILE_FREAD -22
70 * @brief Definition for PREFERENCE_ERROR_FILE_FGETS.
72 #define PREFERENCE_ERROR_FILE_FGETS -23
75 * @brief Definition for PREFERENCE_ERROR_FILE_WRITE.
77 #define PREFERENCE_ERROR_FILE_WRITE -24
80 * @brief Definition for PREFERENCE_ERROR_FILE_SYNC.
82 #define PREFERENCE_ERROR_FILE_SYNC -25
85 * @brief Definition for PREFERENCE_ERROR_FILE_CHMOD.
87 #define PREFERENCE_ERROR_FILE_CHMOD -28
90 * @brief Definition for PREFERENCE_ERROR_FILE_LOCK.
92 #define PREFERENCE_ERROR_FILE_LOCK -29
96 PREFERENCE_TYPE_NONE = 0,
97 PREFERENCE_TYPE_STRING,
99 PREFERENCE_TYPE_DOUBLE,
100 PREFERENCE_TYPE_BOOLEAN,
103 typedef struct _pref_changed_cb_node_t{
105 preference_changed_cb cb;
107 struct _pref_changed_cb_node_t *prev;
108 struct _pref_changed_cb_node_t *next;
109 } pref_changed_cb_node_t;
111 typedef struct _keynode_t {
112 char *keyname; /**< Keyname for keynode */
113 int type; /**< Keynode type */
115 int i; /**< Integer type */
116 int b; /**< Bool type */
117 double d; /**< Double type */
118 char *s; /**< String type */
119 } value; /**< Value for keynode */
120 struct _keynode_t *next; /**< Next keynode */
124 * @brief The structure type for opaque type. It must be used via accessor functions.
125 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
127 typedef struct _keylist_t {
128 int num; /**< Number of list */
129 keynode_t *head; /**< Head node */
130 keynode_t *cursor; /**< Cursor node */
134 int _preference_kdb_add_notify
135 (keynode_t *keynode, preference_changed_cb cb, void *data);
136 int _preference_kdb_del_notify
137 (keynode_t *keynode);
139 int _preference_get_key_path(keynode_t *keynode, char *path);
140 int _preference_get_key(keynode_t *keynode);
142 int _preference_keynode_set_keyname(keynode_t *keynode, const char *keyname);
143 inline void _preference_keynode_set_null(keynode_t *keynode);
144 inline keynode_t *_preference_keynode_new(void);
145 inline void _preference_keynode_free(keynode_t *keynode);
152 #endif /* __TIZEN_APPFW_PREFERENCE_INTERNAL_H__ */