4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JuHak Park <juhaki.park@samsung.com>,
7 * JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8 * SunBong Ha <sunbong.ha@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
28 * For any sort of issue you concern as to this software,
29 * you may use following point of contact.
30 * All resources contributed on this software
31 * are orinigally written by S-Core Inc., a member of Samsung Group.
33 * JungWook Ryu <jungwook.ryu@samsung.com>,
34 * Heeyoung Hwang <heeyoung1008.hwang@samsung.com>
37 #ifndef DACI_COMMON_H_
38 #define DACI_COMMON_H_
51 #include "EXT_DACI_Errors.h"
55 #endif /* __cplusplus */
59 * @brief Common factor of Framework common database
62 #define MO_HANDLER sqlite3
64 #define DACI_HANDLER sqlite3
66 #define DACI_RETRY_COUNT 10
68 #define DACI_MAX_QUERY_LENGTH 2048
70 #define DACI_MAX_ACCOUNT 10
72 #define DACI_FOLDER_TYPE_COUNT 19
74 #define DACI_ITEM_TYPE_COUNT 6
76 #define DACI_OPERATION_TYPE_COUNT 3
78 #define DACI_MEMORY_SET(ptr) memset(ptr, 0x00, sizeof(ptr));
80 #define DACI_MEMORY_MALLOC(type, size, count) (type)malloc(size*count)
82 #define DACI_MEMORY_CALLOC(type, size, count) (type)calloc(count, size)
84 #define DACI_MEMORY_FREE(src) \
90 #define DACI_STRDUP(src) (src == NULL) ? NULL : strdup(src);
92 #define DACI_ATOI(src) (src == NULL) ? 0 : atoi(src);
94 #define DACI_GET_THREAD_ID pthread_self()
97 * @brief rename sqlite3 connection
99 typedef sqlite3_stmt *daci_stmt;
102 * @brief Enumerations of database peak type
105 PEAK_TYPE_ON = 601, /**< peak type on */
106 PEAK_TYPE_ON_N_OFF, /**< peak type N off */
107 PEAK_TYPE_OFF /**< peak type off */
111 * @brief Enumerations of database transaction
114 TRANSACTION_COMMIT, /**< means commit */
116 /**< means rollback */
120 * @brief Enumerations of common db's table list
123 TABLE_NAME_ACCOUNT, /**< means account_tbl */
124 TABLE_NAME_FOLDER, /**< means folder_tbl */
125 TABLE_NAME_ITEM, /**< means item_tbl */
126 TABLE_NAME_CONFIG, /**< means config_tbl */
127 TABLE_NAME_ACCOUNT_ITEM_CHANGELOG, /**< means account_item_changelog_tbl */
128 TABLE_NAME_LAST_ANCHOR, /**< means last_anchor_tbl */
129 TABLE_NAME_MAPPING, /**< means mapping_tbl */
130 TABLE_NAME_ID_PROVIDER, /**< means id_provider_tbl */
131 TABLE_NAME_ID_PAGE, /**< means id_page_tbl */
133 TABLE_NAME_MAX /**< count of common database's tables */
137 * @brief Enumerations of common column
140 COLUMN_NAME_ACCOUNT_ID, /**< means column, account_id */
141 COLUMN_NAME_ITEM_ID, /**< means column, item_id */
142 COLUMN_NAME_SERVICE_ID, /**< means column, service_id */
143 COLUMN_NAME_ACCESS_NAME, /**< means column, access_name */
145 COLUMN_NAME_MAX /**< count of common columns */
149 * @brief Enumerations of structure type concern of DACI
152 STRUCT_TYPE_ACCOUNT, /**< means structure, daci_account */
153 STRUCT_TYPE_FOLDER, /**< means structure, daci_folder */
154 STRUCT_TYPE_ITEM, /**< means structure, daci_item */
155 STRUCT_TYPE_CONFIG, /**< means structure, daci_config */
156 STRUCT_TYPE_ITEM_CHANGELOG, /**< means structure, daci_item_changelog */
157 STRUCT_TYPE_LAST_ANCHOR, /**< means structure, daci_last_anchor */
158 STRUCT_TYPE_MAPPING, /**< means structure, daci_mapping */
159 STRUCT_TYPE_ITEM_INFO, /**< means structure, daci_item_info */
160 STRUCT_TYPE_ID_LIST, /**< means structure, daci_id_list */
162 STRUCT_TYPE_MAX /**< count of enumeration */
166 * @brief Structure of table - mapped column of account_tbl
169 int account_id; /**< account_id */
170 char *email_address; /**< email_address */
171 char *password; /**< password */
172 bool enable; /**< enable */
174 /**< name of accessor */
178 * @brief Structure of table - mapped column of folder_tbl
181 char *folder_id; /**< F/W folder id */
183 /**< service data connector pluIn's ID described in F/W config file */
184 int account_id; /**< F/W account id */
186 /**< data connector plugIn has this folder type id */
188 /**< service folder id */
189 char *parent_folder_id;
190 /**< parent folder id if exist hierarchy */
192 /**< name of accessor */
196 * @brief Structure of table - mapped column of item_tbl
199 char *item_id; /**< F/W item id */
201 /**< service data connector pluIn's ID described in F/W config file */
202 int account_id; /**< F/W account id */
203 char *folder_id; /**< F/W folder id */
205 /**< service item id */
206 char *access_name; /**< name of accessor */
210 * @brief Structure of table - mapped column of config_tbl
213 int config_id; /**< configuration id, this means account id */
214 char *key; /**< configuration key */
215 char *value; /**< configuration value */
216 char *type; /**< configuration type */
217 char *access_name; /**< name of accessor */
221 * @brief Structure of table - mapped column of account_item_changelog_tbl
224 char *item_id; /**< F/W item id */
225 int operation_id; /**< operation id - add, delete, update */
226 char *status; /**< user defined status of item */
227 char *access_name; /**< name of accessor */
228 } daci_item_changelog;
231 * @brief Structure of table - mapped column of last_anchor_tbl
234 int account_id; /**< F/W account id */
235 int data_store_id; /**< service data connector pluIn's ID described in F/W config file */
236 char *last_anchor_server; /**< last anchor that server has */
237 char *last_anchor_client; /**< last anchor that client has */
238 char *access_name; /**< name of accessor */
242 * @brief Structure of table - mapped column of mapping_tbl
245 int account_id; /**< F/W account id */
246 int data_store_id; /**< service data connector pluIn's ID described in F/W config file */
247 char *luid; /**< Locally unique identifier */
249 /**< Globally unique identifier */
250 char *access_name; /**< name of accessor */
254 * @brief Structure of Item information
257 char *itemId; /**< F/W item id */
258 int itemTypeId; /**< service data connector pluIn's ID described in F/W config file */
259 char *serviceId; /**< service item id */
260 int operationId; /**< operation type - add, delete, update */
261 char *syncStatus; /**< user defined status of item */
265 * @brief Structure of Item id's container
268 int count; /**< count of id */
269 char **id; /**< real id list */
273 * @brief Structure of table - mapped column of id_provider_tbl
276 unsigned int id_provider_code; /**< ID of id provider - this described in F/W configuration file */
277 unsigned int id_capacity; /**< max ID count possible id provider generate - this described in F/W configuration file */
278 unsigned int bit_per_page;
279 /**< most number of bit per one page */
280 unsigned int last_id; /**< current last provided ID */
281 unsigned int free_bit_cnt;
282 /**< the number of IDs that can be issued */
286 * @brief Structure of table - mapped column of id_page_tbl
289 unsigned int page_index;/**< index of page */
290 unsigned int id_provider_code; /**< ID of id provider - this described in F/W configuration file */
291 char *page_bit; /**< real construction of ID issued */
295 * @brief free memory daci_account structure
296 * @param[in] account daci_account structure
297 * @param[in] count structure count
299 void DACI_Free_Memory_Account(daci_account *account, int count);
302 * @brief free memory daci_folder structure
303 * @param[in] folder daci_folder structure
304 * @param[in] count structure count
306 void DACI_Free_Memory_Folder(daci_folder *folder, int count);
309 * @brief free memory daci_item structure
310 * @param[in] item daci_item structure
311 * @param[in] count structure count
313 void DACI_Free_Memory_Item(daci_item *item, int count);
316 * @brief free memory daci_config structure
317 * @param[in] config daci_config structure
318 * @param[in] count structure count
320 void DACI_Free_Memory_Config(daci_config *config, int count);
323 * @brief free memory daci_item_changelog structure
324 * @param[in] itemChangelog daci_item_changelog structure
325 * @param[in] count structure count
327 void DACI_Free_Memory_Item_Changelog(daci_item_changelog *itemChangelog, int count);
330 * @brief free memory daci_last_anchor structure
331 * @param[in] lastAnchor daci_last_anchor structure
332 * @param[in] count structure count
334 void DACI_Free_Memory_Last_Anchor(daci_last_anchor *lastAnchor, int count);
337 * @brief free memory daci_mapping structure
338 * @param[in] mapping daci_mapping structure
339 * @param[in] count structure count
341 void DACI_Free_Memory_Mapping(daci_mapping *mapping, int count);
344 * @brief free memory daci_item_info structure
345 * @param[in] itemInfo daci_item_info structure
346 * @param[in] count structure count
348 void DACI_Free_Memory_Item_Info(daci_item_info *itemInfo, int count);
351 * @brief free memory daci_id_list structure
352 * @param[in] idList daci_id_list structure
354 void DACI_Free_Memory_Id_List(daci_id_list *idList);
358 #endif /* __cplusplus */
359 #endif /* DACI_COMMON_H_ */