[Internal: merge sync-agent]
[platform/core/system/sync-agent.git] / src / framework / data-adapter / agent.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef AGENT_H_
19 #define AGENT_H_
20
21 #include "data-adapter/common.h"
22 #include "data-adapter/common_internal.h"
23
24 #include "account/manager.h"
25
26 /**
27  * @file                agent.h
28  * @brief       Internal API to manage sync-agent-framework database
29  */
30
31 /** @addtogroup data_adapter
32  *      @{
33  */
34
35 /*
36  * =============================================================================================================================
37  * Database Open & Close & Delete Account Data
38  * =============================================================================================================================
39  */
40
41 /**
42  * @brief Start Agent database transaction
43  * @param[in]   daci_handler sqlite3 handler pointer about thread
44  * @return Operation result
45  * @retval SYNC_AGENT_DA_SUCCESS success
46  * @retval SYNC_AGENT_DA_ERR_TRANSACTION_FAILED error
47  */
48 sync_agent_da_return_e da_begin_transaction(SYNC_AGENT_DA_HANDLER * daci_handler);
49
50 /**
51  * @brief Finish Agent database transaction
52  * @param[in]   daci_handler sqlite3 handler pointer about thread
53  * @param[in]   transaction commit or rollback transaction
54  * @return Operation result
55  * @retval SYNC_AGENT_DA_SUCCESS success
56  * @retval SYNC_AGENT_DA_ERR_TRANSACTION_FAILED error
57  */
58 sync_agent_da_return_e da_end_transaction(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_transaction_e transaction);
59
60 /**
61  * @brief Set agent db file path
62  * @param[in]   file_path agent db file path
63  */
64 void da_set_agent_db_file_path(char *file_path);
65
66 /**
67  * @brief Open Agent database
68  * @param[in]   daci_handler sqlite3 handler pointer about thread
69  * @return Operation result
70  * @retval SYNC_AGENT_DA_SUCCESS success
71  * @retval SYNC_AGENT_DA_ERR_OPEN_FAILED error
72  */
73 sync_agent_da_return_e da_open_agent(SYNC_AGENT_DA_HANDLER ** daci_handler);
74
75 /**
76  * @brief Close Agent database
77  * @param[in]   daci_handler sqlite3 handler pointer about thread
78  * @return Operation result
79  * @retval SYNC_AGENT_DA_SUCCESS success
80  * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
81  */
82 sync_agent_da_return_e da_close_Agent(SYNC_AGENT_DA_HANDLER * daci_handler);
83
84 /**
85  * @brief Create Agent database
86  * @param[in] daci_handler sqlite3 handler pointer about thread
87  * @return Operation result
88  * @retval SYNC_AGENT_DA_SUCCESS success
89  * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
90  */
91 sync_agent_da_return_e da_create_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler);
92
93 /**
94  * @brief Empty Agent database table
95  * @param[in] daci_handler sqlite3 handler pointer about thread
96  * @return Operation result
97  * @retval SYNC_AGENT_DA_SUCCESS success
98  * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
99  */
100 sync_agent_da_return_e da_empty_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_table_name_e table_name);
101
102 /**
103  * @brief Empty all Agent database tables
104  * @param[in]   daci_handler sqlite3 handler pointer about thread
105  * @return Operation result
106  * @retval SYNC_AGENT_DA_SUCCESS success
107  * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
108  */
109 sync_agent_da_return_e da_empty_all_agent_table(SYNC_AGENT_DA_HANDLER * daci_handler);
110
111 /*
112  * =============================================================================================================================
113  * account_tb
114  * =============================================================================================================================
115  */
116
117 /**
118  * @brief       Insert account into account_tbl
119  * @param[in]   daci_handler sqlite3 handler pointer about thread
120  * @param[in]   sync_agent_fw_account_s account info
121  * @return Operation result
122  * @retval account id (positive number) success
123  * @retval -1 error
124  */
125 int da_add_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account);
126
127 /**
128  * @brief Update account into account_tbl
129  * @param[in]   daci_handler sqlite3 handler pointer about thread
130  * @param[in]   sync_agent_fw_account_s account info
131  * @return Operation result
132  * @retval SYNC_AGENT_DA_SUCCESS success
133  * @retval negative value error
134  */
135 sync_agent_da_return_e da_update_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account);
136
137 /**
138  * @brief Delete account data from Agent database
139  * @param[in]   daci_handler sqlite3 handler pointer about thread
140  * @param[in]   account_id account id
141  * @return Operation result
142  * @retval SYNC_AGENT_DA_SUCCESS success
143  * @retval negative value error
144  */
145 sync_agent_da_return_e da_delete_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
146
147 /**
148  * @brief Get account data from Agent database
149  * @param[in]   daci_handler sqlite3 handler pointer about thread
150  * @param[in]   account_id account id
151  * @param[in]   account as returned by da_get_fw_account() - account info
152  * @return Operation result
153  * @retval SYNC_AGENT_DA_SUCCESS success
154  * @retval negative value error
155  */
156 sync_agent_da_return_e da_get_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_fw_account_s ** account);
157
158 /**
159  * @brief Get all account data from Agent database
160  * @param[in]   daci_handler sqlite3 handler pointer about thread
161  * @param[in] list list of sync_agent_fw_account_s
162  * @return Operation result
163  * @retval SYNC_AGENT_DA_SUCCESS success
164  * @retval negative value error
165  */
166 sync_agent_da_return_e da_get_all_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, GList ** list);
167
168 /**
169  * @brief Get account data by access name from Agent database
170  * @param[in]   daci_handler sqlite3 handler pointer about thread
171  * @param[in]   access_name db access name
172  * @param[in]   list as returned by da_get_fw_account_by_access_name() - list of sync_agent_fw_account_s
173  * @return Operation result
174  * @retval SYNC_AGENT_DA_SUCCESS success
175  * @retval negative value error
176  */
177 sync_agent_da_return_e da_get_fw_account_by_access_name(SYNC_AGENT_DA_HANDLER * daci_handler, char *access_name, GList ** list);
178
179 /**
180  * @brief Get all account id from account_tbl
181  * @param[in]   daci_handler sqlite3 handler pointer about thread
182  * @param[in]   count as returned by da_get_account_account_id_list() - count of account id
183  * @return Operation result
184  * @retval array of account id success
185  * @retval NULL error
186  */
187 int *da_get_account_account_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, int *count);
188
189 /**
190  * @brief Checking whether the account id exist in account_tbl
191  * @param[in]   daci_handler sqlite3 handler pointer about thread
192  * @param[in]   account_id account id
193  * @return Checking result
194  * @retval 1 exist
195  * @retval 0 error or not exist
196  */
197 int da_is_exist_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
198
199 /**
200  * @brief Get account id list from account_tbl by access name
201  * @remarks     Caller should free return value
202  * @param[in]   daci_handler sqlite3 handler pointer about thread
203  * @param[in]   access_name db access name
204  * @param[in]   accountId_count as returned by da_get_account_id_list_by_access_name() - count of account id
205  * @return Operation result
206  * @retval account id list success
207  * @retval NULL error
208  */
209 int *da_get_account_id_list_by_access_name(SYNC_AGENT_DA_HANDLER * daci_handler, char *access_name, int *accountId_count);
210
211 /**
212  * @brief Get account count
213  * @param[in]   daci_handler sqlite3 handler pointer about thread
214  * @return Checking result
215  * @retval 1 exist
216  * @retval 0 error or not exist
217  */
218 int da_get_account_count(SYNC_AGENT_DA_HANDLER * daci_handler);
219
220 /*
221  * =============================================================================================================================
222  * folder_tbl
223  * =============================================================================================================================
224  */
225
226 /**
227  * @brief Insert folder into folder_tbl - currently unused function
228  * @param[in]   daci_handler sqlite3 handler pointer about thread
229  * @param[in]   folder array of folder info
230  * @param[in]   count count of folder info
231  * @return Operation result
232  * @retval SYNC_AGENT_DA_SUCCESS success
233  * @retval negative value error
234  */
235 sync_agent_da_return_e da_add_folder(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_folder_s * folder, int count);
236
237 /**
238  * @brief Insert folder into folder_tbl
239  * @param[in]   daci_handler sqlite3 handler pointer about thread
240  * @param[in]   folder array of folder info
241  * @param[in]   count count of folder info
242  * @param[in] folder_id as returned by da_add_folder_new() - id of newly added folder
243  * @return Operation result
244  * @retval SYNC_AGENT_DA_SUCCESS success
245  * @retval negative value error
246  */
247 sync_agent_da_return_e da_add_folder_new(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_folder_s * folder, int count, char **folder_id);
248
249 /**
250  * @brief Delete folder from folder_tbl by folderId
251  * @param[in]   daci_handler sqlite3 handler pointer about thread
252  * @param[in]   folder_id folder id
253  * @return Operation result
254  * @retval SYNC_AGENT_DA_SUCCESS success
255  * @retval negative value error
256  */
257 sync_agent_da_return_e da_delete_folder_by_folder_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id);
258
259 /**
260  * @brief Get folderId from folder_tbl
261  * @param[in]   daci_handler sqlite3 handler pointer about thread
262  * @param[in]   account_id account id
263  * @param[in]   item_type_id item type id
264  * @param[in]   service_id service id
265  * @param[in]   folder_type_id folder type id
266  * @return Operation result
267  * @retval folder id success
268  * @retval NULL error
269  */
270 char *da_get_folder_folder_id_by_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, char *service_id, int folder_type_id);
271
272 /**
273  * @brief Get folderId from folder_tbl by folder  type id - currently unused function
274  * @param[in]   daci_handler sqlite3 handler pointer about thread
275  * @param[in]   account_id account id
276  * @param[in] item_type_id item type id
277  * @param[in]   folder_type_id folder type id
278  * @return Operation result
279  * @retval folder id success
280  * @retval NULL error
281  */
282 sync_agent_da_id_list_s *da_get_folder_folder_id_by_folder_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int folder_type_id);
283
284 /**
285  * @brief Get folderId from folder_tbl by folder  type id
286  * @param[in]   daci_handler sqlite3 handler pointer about thread
287  * @param[in]   account_id account id
288  * @param[in] item_type_id item type id
289  * @param[in]   folder_type_id folder type id
290  * @param[in] list as returned by da_get_folder_folder_id_by_folder_type_id_new() - list of folder id
291  * @return Operation result
292  * @retval SYNC_AGENT_DA_SUCCESS success
293  * @retval negative value error
294  */
295 sync_agent_da_return_e da_get_folder_folder_id_by_folder_type_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int folder_type_id, GList ** list);
296
297 /**
298  * @brief Get serviceId from folder_tbl
299  * @param[in] daci_handler sqlite3 handler pointer about thread
300  * @param[in]   folder_id folder id
301  * @return Operation result
302  * @retval service id success
303  * @retval NULL error
304  */
305 char *da_get_folder_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id);
306
307 /**
308  * @brief Get all folder_id_list from folder_tbl by data_store_id - currently unused function
309  *                              Get all the folders in account and data store
310  * @param[in]   daci_handler sqlite3 handler pointer about thread
311  * @param[in]   account_id account id
312  * @param[in]   item_type_id item type id
313  * @return Operation result
314  * @retval array of folder id success
315  * @retval NULL error
316  */
317 sync_agent_da_id_list_s *da_get_folder_folder_id_list_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
318
319 /**
320  * @brief Get all folder_id_list from folder_tbl by data_store_id
321  *                              Get all the folders in account and data store
322  * @param[in]   daci_handler sqlite3 handler pointer about thread
323  * @param[in]   account_id account id
324  * @param[in]   item_type_id item type id
325  * @param[in] list as returned by da_get_folder_folder_id_list_by_item_type_id_new() - list of folder id
326  * @return Operation result
327  * @retval SYNC_AGENT_DA_SUCCESS success
328  * @retval negative value error
329  */
330 sync_agent_da_return_e da_get_folder_folder_id_list_by_item_type_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, GList ** list);
331
332 /**
333  * @brief Get item from folder_tbl - currently unused function
334  *                              Belonging to different account of folder get folder with the same service_id
335  * @param[in]   daci_handler sqlite3 handler pointer about thread
336  * @param[in]   account_id account id
337  * @param[in]   folder_id folder id
338  * @param[in]   count   as returned by da_get_folder_mapping_service_id() -     count of item info
339  * @return Operation result
340  * @retval array of folder info success
341  * @retval NULL error
342  */
343 sync_agent_da_folder_s *da_get_folder_mapping_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id, int *count);
344
345 /**
346  * @brief Get item from folder_tbl
347  *                              Belonging to different account of folder get folder with the same service_id
348  * @param[in]   daci_handler sqlite3 handler pointer about thread
349  * @param[in]   account_id account id
350  * @param[in]   folder_id folder id
351  * @param[in]   list    as returned by da_get_folder_mapping_service_id() -     list of item info
352  * @return Operation result
353  * @retval SYNC_AGENT_DA_SUCCESS success
354  * @retval negative value error
355  */
356 sync_agent_da_return_e da_get_folder_mapping_service_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id, GList ** list);
357
358 /**
359  * @brief Get folder info from folder_tbl by folder id
360  * @param[in] daci_handler sqlite3 handler pointer about thread
361  * @param[in] folder_id folder id
362  * @param[in] sync_agent_folder as returned by da_get_folder_by_folder_id() - folder info
363  * @return Operation result
364  * @retval SYNC_AGENT_DA_SUCCESS success
365  * @retval negative value error
366  */
367 sync_agent_da_return_e da_get_folder_by_folder_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id, sync_agent_da_folder_s ** sync_agent_folder);
368
369 /**
370  * @brief Checking whether the folderId exist in folder_tbl
371  * @param[in]   daci_handler sqlite3 handler pointer about thread
372  * @param[in]   account_id account id
373  * @param[in]   folder_id folder id
374  * @return Checking result
375  * @retval 1 exist
376  * @retval 0 error or not exist
377  */
378 int da_is_exist_folder(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id);
379
380 /*
381  * =============================================================================================================================
382  * item_tbl
383  * =============================================================================================================================
384  */
385
386 /**
387  * @brief       Insert item into item_tbl
388  * @param[in]   daci_handler sqlite3 handler pointer about thread
389  * @param[in]   item array of item info
390  * @param[in]   count count of item info
391  * @return Operation result
392  * @retval SYNC_AGENT_DA_SUCCESS success
393  * @retval negative value error
394  */
395 sync_agent_da_return_e da_add_item(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_item_s * item, int count);
396
397 /**
398  * @brief       Insert item into item_tbl
399  * @param[in]   daci_handler    sqlite3 handler pointer about thread
400  * @param[in]   fw_id            framework id
401  * @param[in]   parent_id                parent service id of fw_id item
402  * @return Operation result
403  * @retval SYNC_AGENT_DA_SUCCESS success
404  * @retval negative value error
405  */
406 sync_agent_da_return_e da_update_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *fw_id, char *parent_id);
407
408 /**
409  * @brief       Insert item into item_tbl
410  * @param[in]   daci_handler sqlite3 handler pointer about thread
411  * @param[in]   item array of item info
412  * @param[in]   count count of item info
413  * @param[in] item_id - id of newly added item
414  * @return Operation result
415  * @retval SYNC_AGENT_DA_SUCCESS success
416  * @retval negative value error
417  */
418 sync_agent_da_return_e da_add_item_new(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_item_s * item, int count, char **item_id);
419
420 /**
421  * @brief Delete item from item_tbl by item id
422  * @param[in]   daci_handler sqlite3 handler pointer about thread
423  * @param[in]   item_id item id
424  * @return Operation result
425  * @retval SYNC_AGENT_DA_SUCCESS success
426  * @retval negative value error
427  */
428 sync_agent_da_return_e da_delete_item_by_Item_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
429
430 /**
431  * @brief Delete item from item_tbl by account id and item type id - currently unused function
432  * @param[in]   daci_handler sqlite3 handler pointer about thread
433  * @param[in]   account_id account id
434  * @param[in]   item_type_id item type id
435  * @return Operation result
436  * @retval SYNC_AGENT_DA_SUCCESS success
437  * @retval negative value error
438  */
439 sync_agent_da_return_e da_delete_item_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
440
441 /**
442  * @brief Delete child item from item_tbl by parent service id
443  * @param[in]   daci_handler sqlite3 handler pointer about thread
444  * @param[in]   parent_service_id       parent service id
445  * @return Operation result
446  * @retval SYNC_AGENT_DA_SUCCESS success
447  * @retval negative value error
448  */
449 sync_agent_da_return_e da_delete_all_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id);
450
451 /**
452  * @brief Delete child item from item_tbl by parent service id
453  * @param[in]   daci_handler sqlite3 handler pointer about thread
454  * @param[in]   parent_service_id       parent service id
455  * @return Operation result
456  * @retval SYNC_AGENT_DA_SUCCESS success
457  * @retval negative value error
458  */
459 sync_agent_da_return_e da_delete_child_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *parent_service_id, char *child_service_id);
460
461
462 /**
463  * @brief Delete item from item_tbl by account id and item type id
464  * @param[in]   daci_handler sqlite3 handler pointer about thread
465  * @param[in]   account_id account id
466  * @param[in]   item_type_id item type id
467  * @return Operation result
468  * @retval SYNC_AGENT_DA_SUCCESS success
469  * @retval negative value error
470  */
471 sync_agent_da_return_e da_delete_item_by_item_type_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
472
473 /**
474  * @brief Delete item from item_tbl by account id and item type id and row that checked delete from changelog tbl
475  * @param[in]   daci_handler sqlite3 handler pointer about thread
476  * @param[in]   account_id account id
477  * @param[in]   item_type_id item type id
478  * @return Operation result
479  * @retval SYNC_AGENT_DA_SUCCESS success
480  * @retval negative value error
481  */
482 sync_agent_da_return_e da_delete_item_by_item_type_id_and_delete_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
483
484 /**
485  * @brief Get item id from item_tbl - currently unused function
486  * @param[in]   daci_handler sqlite3 handler pointer about thread
487  * @param[in]   account_id account id
488  * @param[in]   service_id service id
489  * @param[in]   item_type_id item type id
490  * @return Operation result
491  * @retval item id success
492  * @retval NULL error
493  */
494 char *da_get_item_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *service_id, int item_type_id);
495
496 /**
497  * @brief Get item id from item_tbl
498  * @param[in]   daci_handler sqlite3 handler pointer about thread
499  * @param[in]   account_id account id
500  * @param[in]   service_id service id
501  * @param[in]   item_type_id item type id
502  * @param[in] item_id as returned by da_get_item_item_id_new() - id of newly added item
503  * @return Operation result
504  * @retval SYNC_AGENT_DA_SUCCESS success
505  * @retval negative value error
506  */
507 sync_agent_da_return_e da_get_item_item_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *service_id, int item_type_id, char **item_id);
508
509 /**
510  * @brief Get service id from item_tbl
511  * @param[in]   daci_handler sqlite3 handler pointer about thread
512  * @param[in]   item_id item id
513  * @return Operation result
514  * @retval service id success
515  * @retval NULL error
516  */
517 char *da_get_item_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
518
519 /**
520  * @brief Get item from item_tbl - currently unused function
521  * @param[in]   daci_handler sqlite3 handler pointer about thread
522  * @param[in]   item_id item id
523  * @return Operation result
524  * @retval item info success
525  * @retval NULL error
526  */
527 sync_agent_da_item_s *da_get_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
528
529 /**
530  * @brief Get item from item_tbl
531  * @param[in]   daci_handler sqlite3 handler pointer about thread
532  * @param[in]   item_id item id
533  * @param[in] sync_agent_item as returned by da_get_item_new() - item info
534  * @return Operation result
535  * @retval SYNC_AGENT_DA_SUCCESS success
536  * @retval negative value error
537  */
538 sync_agent_da_return_e da_get_item_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
539
540 /**
541  * @brief Get data_store item id from item_tbl
542  * @param[in]   daci_handler sqlite3 handler pointer about thread
543  * @param[in]   item_id item id
544  * @param[in] sync_agent_item as returned by da_get_item_new() - item info
545  * @return Operation result
546  * @retval SYNC_AGENT_DA_SUCCESS success
547  * @retval negative value error
548  */
549 sync_agent_da_return_e da_get_item_data_store_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
550
551 /**
552  * @brief Get account item id from item_tbl
553  * @param[in]   daci_handler sqlite3 handler pointer about thread
554  * @param[in]   item_id item id
555  * @param[in] sync_agent_item as returned by da_get_item_new() - item info
556  * @return Operation result
557  * @retval SYNC_AGENT_DA_SUCCESS success
558  * @retval negative value error
559  */
560 sync_agent_da_return_e da_get_item_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id, sync_agent_da_item_s ** sync_agent_item);
561
562 /**
563  * @brief Get all item id from item_tbl
564  * @param[in]   daci_handler sqlite3 handler pointer about thread
565  * @return Operation result
566  * @retval array of item id success
567  * @retval NULL error
568  */
569 sync_agent_da_id_list_s *da_get_all_item_id(SYNC_AGENT_DA_HANDLER * daci_handler);
570
571 /**
572  * @brief Get all id in folder from item_tbl - currently unused function
573  * @param[in]   daci_handler sqlite3 handler pointer about thread
574  * @param[in]   folder_id folder id
575  * @param[in]   column_name column name (SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID or SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID)
576  * @return Operation result
577  * @retval array of item id success
578  * @retval NULL error
579  */
580 sync_agent_da_id_list_s *da_get_item_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id, sync_agent_da_column_name_e column_name);
581
582 /**
583  * @brief Get all id in folder from item_tbl
584  * @param[in]   daci_handler sqlite3 handler pointer about thread
585  * @param[in]   folder_id folder id
586  * @param[in]   column_name column name (SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID or SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID)
587  * @param[in] list as returned by da_get_item_id_list_new() - list of item id
588  * @return Operation result
589  * @retval SYNC_AGENT_DA_SUCCESS success
590  * @retval negative value error
591  */
592 sync_agent_da_return_e da_get_item_id_list_new(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id, sync_agent_da_column_name_e column_name, GList ** list);
593
594 /**
595  * @brief Get item from item_tbl by accountId - currently unused function
596  *                              Get all the items in account
597  * @param[in]   daci_handler sqlite3 handler pointer about thread
598  * @param[in]   account_id account id
599  * @param[in]   item_type_id item type id
600  * @param[in]   count as returned by da_get_item_by_account_id() - count of item info
601  * @return Operation result
602  * @retval array of item info success
603  * @retval NULL error
604  */
605 sync_agent_da_item_s *da_get_item_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int *count);
606
607 /**
608  * @brief Get item from item_tbl by accountId
609  *                              Get all the items in account
610  * @param[in]   daci_handler sqlite3 handler pointer about thread
611  * @param[in]   account_id account id
612  * @param[in]   item_type_id item type id
613  * @param[in]   list as returned by da_get_item_by_account_id() - list of item info
614  * @return Operation result
615  * @retval SYNC_AGENT_DA_SUCCESS success
616  * @retval negative value error
617  */
618 sync_agent_da_return_e da_get_item_by_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, GList ** list);
619
620 /**
621  * @brief Get item data from item_tbl and account_item_changelog_tbl
622  *                              Among the items that belong to the item type id, Search for item info belong to the changelog
623  * @param[in]   daci_handler sqlite3 handler pointer about thread
624  * @param[in]   account_id account id
625  * @param[in]   item_type_id item type id
626  * @param[in]   count   as returned by da_get_item_info_by_item_type_id() - count of item data
627  * @return Operation result
628  * @retval array of item data success
629  * @retval NULL error
630  */
631 sync_agent_da_item_info_s *da_get_item_info_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int *count);
632
633 /*
634  * @brief Get item data from item_tbl and account_item_changelog_tbl - currently unused function
635  *                              Among the items that belong to the item type id, Search for item info belong to the changelog
636  * @param[in]   daci_handler sqlite3 handler pointer about thread
637  * @param[in]   account_id account id
638  * @param[in]   item_type_id item type id
639  * @param[in] operation_id operation id
640  * @param[in]   count   as returned by da_get_item_info_by_item_type_id_and_operation_id() - count of item data
641  * @return Operation result
642  * @retval array of item data success
643  * @retval NULL error
644  */
645 sync_agent_da_item_info_s *da_get_item_info_by_item_type_id_and_operation_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int operation_id, int *count);
646
647 /**
648  * @brief Get item data from item_tbl and account_item_changelog_tbl
649  *                              Among the items that belong to the item type id, Search for item info belong to the changelog
650  * @param[in]   daci_handler sqlite3 handler pointer about thread
651  * @param[in]   account_id account id
652  * @param[in]   item_type_id item type id
653  * @param[in] operation_id operation id
654  * @param[in]   list    as returned by da_get_item_info_by_item_type_id_and_operation_id() - list of item data
655  * @return Operation result
656  * @retval SYNC_AGENT_DA_SUCCESS success
657  * @retval negative value error
658  */
659 sync_agent_da_return_e da_get_item_info_by_item_type_id_and_operation_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int operation_id, GList ** list);
660
661 /**
662  * @brief Get item from item_tbl - currently unused function
663  *                              Belonging to different account of item get item with the same service id
664  * @param[in]   daci_handler sqlite3 handler pointer about thread
665  * @param[in]   account_id account id
666  * @param[in]   item_id item id
667  * @param[in]   count as returned by da_get_item_mapping_service_id() - count of item info
668  * @return Operation result
669  * @retval array of item info success
670  * @retval NULL error
671  */
672 sync_agent_da_item_s *da_get_item_mapping_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id, int *count);
673
674 /**
675  * @brief Get item from item_tbl
676  *                              Belonging to different account of item get item with the same service id
677  * @param[in]   daci_handler sqlite3 handler pointer about thread
678  * @param[in]   account_id account id
679  * @param[in]   item_id item id
680  * @param[in]   list as returned by da_get_item_mapping_service_id() - list of item info
681  * @return Operation result
682  * @retval SYNC_AGENT_DA_SUCCESS success
683  * @retval negative value error
684  */
685 sync_agent_da_return_e da_get_item_mapping_service_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id, GList ** list);
686
687 /**
688  * @brief Get all item id from item_tbl by data store id - currently unused function
689  * @param[in]   daci_handler sqlite3 handler pointer about thread
690  * @param[in]   data_store_id data store id
691  * @return Operation result
692  * @retval array of item id success
693  * @retval NULL error
694  */
695 sync_agent_da_id_list_s *da_get_item_id_list_by_datastore_id(SYNC_AGENT_DA_HANDLER * daci_handler, int data_store_id);
696
697 /**
698  * @brief Get all item id from item_tbl by data store id
699  * @param[in]   daci_handler sqlite3 handler pointer about thread
700  * @param[in]   data_store_id data store id
701  * @param[in] list as returned by da_get_item_id_list_by_datastore_id_new() - list of item id
702  * @return Operation result
703  * @retval SYNC_AGENT_DA_SUCCESS success
704  * @retval negative value error
705  */
706 sync_agent_da_return_e da_get_item_id_list_by_datastore_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int data_store_id, GList ** list);
707
708 /**
709  * @brief Get item id list from item_tbl by data store id and account id - currently unused function
710  * @param[in]   daci_handler sqlite3 handler pointer about thread
711  * @param[in]   account_id sync-agent-framework account id
712  * @param[in]   data_store_id data store id
713  * @return Operation result
714  * @retval array of item id success
715  * @retval NULL error or not exist
716  */
717 sync_agent_da_id_list_s *da_get_item_id_list_by_datastore_id_with_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int data_store_id);
718
719 /**
720  * @brief Get item id list from item_tbl by data store id and account id
721  * @param[in]   daci_handler sqlite3 handler pointer about thread
722  * @param[in]   account_id sync-agent-framework account id
723  * @param[in]   data_store_id data store id
724  * @param[in] list as returned by da_get_item_id_list_by_datastore_id_with_account_id_new() - list of item id
725  * @return Operation result
726  * @retval SYNC_AGENT_DA_SUCCESS success
727  * @retval negative value error
728  */
729 sync_agent_da_return_e da_get_item_id_list_by_datastore_id_with_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int data_store_id, GList ** list);
730
731 /**
732  * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id  - currently unused function
733  *                              Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id
734  * @param[in]   daci_handler sqlite3 handler pointer about thread
735  * @param[in]   account_id account id
736  * @param[in]   data_store_id data store id
737  * @param[in]   operation_id operation id
738  * @return Operation result
739  * @retval array of item id success
740  * @retval NULL error
741  */
742 sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int data_store_id, int operation_id);
743
744 /**
745  * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id
746  *                              Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id
747  * @param[in]   daci_handler sqlite3 handler pointer about thread
748  * @param[in]   account_id account id
749  * @param[in]   data_store_id data store id
750  * @param[in]   operation_id operation id
751  * @param[in] list as returned by da_get_item_id_list_by_operation_id_new() - list of item id
752  * @return Operation result
753  * @retval SYNC_AGENT_DA_SUCCESS success
754  * @retval negative value error
755  */
756 sync_agent_da_return_e da_get_item_id_list_by_operation_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int data_store_id, int operation_id, GList ** list);
757
758 /**
759  * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id and folder id - currently unused function
760  *                              Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
761  * @param[in]   daci_handler sqlite3 handler pointer about thread
762  * @param[in]   account_id account id
763  * @param[in] folder_id folder id
764  * @param[in]   data_store_id data store id
765  * @param[in]   operation_id operation id
766  * @return Operation result
767  * @retval array of item id success
768  * @retval NULL error
769  */
770 sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id_and_folder_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id, int data_store_id, int operation_id);
771
772 /**
773  * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id and folder id
774  *                              Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
775  * @param[in]   daci_handler sqlite3 handler pointer about thread
776  * @param[in]   account_id account id
777  * @param[in] folder_id folder id
778  * @param[in]   data_store_id data store id
779  * @param[in]   operation_id operation id
780  * @param[in] list as returned by da_get_item_id_list_by_operation_id_and_folder_id_new() - list of item id
781  * @return Operation result
782  * @retval SYNC_AGENT_DA_SUCCESS success
783  * @retval negative value error
784  */
785 sync_agent_da_return_e da_get_item_id_list_by_operation_id_and_folder_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id, int data_store_id, int operation_id, GList ** list);
786
787 /**
788  * @brief Get item id list from item_tbl and account_item_changelog_tbl by account id and folder id
789  *                              Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
790  * @param[in]   daci_handler sqlite3 handler pointer about thread
791  * @param[in]   account_id account id
792  * @param[in]   folder_id folder id
793  * @param[out] list as returned by da_get_item_id_list_by_operation_id_and_folder_id_new() - list of item id
794  * @return Operation result
795  * @retval SYNC_AGENT_DA_SUCCESS success
796  * @retval negative value error
797  */
798 sync_agent_da_return_e da_get_item_id_list_by_folder_id_and_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id, GList ** list);
799
800 /**
801  * @brief Checking whether the itemId exist in item_tbl
802  * @param[in]   daci_handler sqlite3 handler pointer about thread
803  * @param[in]   item_id item id
804  * @return Checking result
805  * @retval 1 exist
806  * @retval 0 error or not exist
807  */
808 int da_is_exist_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
809
810 /*
811  * =============================================================================================================================
812  * config_tbl
813  * =============================================================================================================================
814  */
815
816 /**
817  * @brief       Insert config into config_tbl
818  * @param[in]   daci_handler sqlite3 handler pointer about thread
819  * @param[in]   config config info
820  * @return Operation result
821  * @retval SYNC_AGENT_DA_SUCCESS success
822  * @retval negative value error
823  */
824 sync_agent_da_return_e da_add_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
825
826 /**
827  * @brief       Insert config list into config_tbl
828  * @param[in]   daci_handler sqlite3 handler pointer about thread
829  * @param[in]   config_list list list of config info
830  * @return Operation result
831  * @retval SYNC_AGENT_DA_SUCCESS success
832  * @retval negative value error
833  */
834 sync_agent_da_return_e da_add_config_list(SYNC_AGENT_DA_HANDLER * daci_handler, GList * config_list);
835
836 /**
837  * @brief Delete config from config_tbl by key
838  * @param[in]   daci_handler sqlite3 handler pointer about thread
839  * @param[in]   config_id config id
840  * @param[in]   key key value
841  * @return Operation result
842  * @retval SYNC_AGENT_DA_SUCCESS success
843  * @retval negative value error
844  */
845 sync_agent_da_return_e da_delete_config_by_key(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key);
846
847 /**
848  * @brief Get list of config info from config_tbl by account id
849  *                              Get all the config in account
850  * @param[in]   daci_handler sqlite3 handler pointer about thread
851  * @param[in]   account_id account id
852  * @param[in]   list as returned by da_get_config_by_account_id() - list of config info
853  * @return Operation result
854  * @retval SYNC_AGENT_DA_SUCCESS success
855  * @retval negative value error
856  */
857 sync_agent_da_return_e da_get_config_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list);
858
859 /**
860  * @brief Get config info from config_tbl by key
861  * @param[in]   daci_handler sqlite3 handler pointer about thread
862  * @param[in]   config_id config id
863  * @param[in] key key value
864  * @param[in]   config as returned by da_get_config_by_key() - config info (account id, key, value, type)
865  * @return Operation result
866  * @retval SYNC_AGENT_DA_SUCCESS success
867  * @retval negative value error
868  */
869 sync_agent_da_return_e da_get_config_by_key(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key, sync_agent_da_config_s ** config);
870
871 /**
872  * @brief Checking whether account of the config exist in config_tbl
873  * @param[in]   daci_handler sqlite3 handler pointer about thread
874  * @param[in]   config_id config id
875  * @param[in]   key key value
876  * @param[in]   exist   as returned by da_is_exist_config() -   whether exist or not
877  * @return Operation result
878  * @retval SYNC_AGENT_DA_SUCCESS success
879  * @retval negative value error
880  */
881 sync_agent_da_return_e da_is_exist_config(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key, int *exist);
882
883 /**
884  * @brief       Insert or update config into config_tbl
885  *                              checking whether the config exist in config_tbl
886  *                              If it does not exist, insert config into config_tbl
887  *                              If it existed, update config into config_tbl
888  * @param[in]   daci_handler sqlite3 handler pointer about thread
889  * @param[in]   config config info
890  * @return Operation result
891  * @retval SYNC_AGENT_DA_SUCCESS success
892  * @retval negative value error
893  */
894 sync_agent_da_return_e da_update_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
895
896 /**
897  * @brief       Update config into config_tbl
898  * @param[in]   daci_handler sqlite3 handler pointer about thread
899  * @param[in]   config config info
900  * @return Operation result
901  * @retval SYNC_AGENT_DA_SUCCESS success
902  * @retval negative value error
903  */
904 sync_agent_da_return_e da_set_config_value(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
905
906 /*
907  * =============================================================================================================================
908  * account_item_changelog_tbl
909  * =============================================================================================================================
910  */
911
912 /**
913  * @brief       Insert itemChangelog into account_item_changelog_tbl
914  * @param[in]   daci_handler sqlite3 handler pointer about thread
915  * @param[in] account_id account id
916  * @param[in]   itemChangelog array of itemChangelog info
917  * @param[in]   count count of itemChangelog info
918  * @return Operation result
919  * @retval SYNC_AGENT_DA_SUCCESS success
920  * @retval negative value error
921  */
922 sync_agent_da_return_e da_add_item_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_da_item_changelog_s * item_changelog, int count);
923
924 /**
925  * @brief Delete itemChangelog from account_item_changelog_tbl by item id
926  * @param[in]   daci_handler sqlite3 handler pointer about thread
927  * @param[in]   account_id account id
928  * @param[in]   item_id item id
929  * @return Operation result
930  * @retval SYNC_AGENT_DA_SUCCESS success
931  * @retval negative value error
932  */
933 sync_agent_da_return_e da_delete_item_changelog_by_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id);
934
935 /**
936  * @brief Delete itemChangelog from account_item_changelog_tbl by item id list
937  * @param[in]   daci_handler sqlite3 handler pointer about thread
938  * @param[in]   account_id account id
939  * @param[in]   item_id_list array of item id
940  * @param[in]   count count of item id
941  * @return Operation result
942  * @retval SYNC_AGENT_DA_SUCCESS success
943  * @retval negative value error
944  */
945 sync_agent_da_return_e da_delete_item_changelog_by_item_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char **item_id_list, int count);
946
947 /**
948  * @brief Delete itemChangelog from account_item_changelog_tbl by item type id
949  * @param[in]   daci_handler sqlite3 handler pointer about thread
950  * @param[in]   account_id account id
951  * @param[in]   item_type_id item type id
952  * @return Operation result
953  * @retval SYNC_AGENT_DA_SUCCESS success
954  * @retval negative value error
955  */
956 sync_agent_da_return_e da_delete_item_changelog_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
957
958 /**
959  * @brief Set operation id and sync status to account_item_changelog_tbl
960  * @param[in]   daci_handler sqlite3 handler pointer about thread
961  * @param[in]   account_id account id
962  * @param[in]   item_changelog itemChangelog info (operationId, syncStatus, accessName, itemId)
963  * @return Operation result
964  * @retval SYNC_AGENT_DA_SUCCESS success
965  * @retval negative value error
966  */
967 sync_agent_da_return_e da_set_item_changelog_operation_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_da_item_changelog_s * item_changelog);
968
969 /**
970  * @brief Set sync status to account_item_changelog_tbl
971  * @param[in]   daci_handler sqlite3 handler pointer about thread
972  * @param[in]   account_id account id
973  * @param[in]   item_changelog itemChangelog info (syncStatus, accessName, itemId)
974  * @return Operation result
975  * @retval SYNC_AGENT_DA_SUCCESS success
976  * @retval negative value error
977  */
978 sync_agent_da_return_e da_set_item_changelog_sync_status(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_da_item_changelog_s * item_changelog);
979
980 /**
981  * @brief Set SYNC_WAIT to account_item_changelog_tbl
982  *                              Among the items that match to the itemTypeId and belong to the folder
983  *                              If it existed in account_item_changelog_tbl, set SYNC_WAIT to account_item_changelog_tbl
984  * @param[in]   daci_handler sqlite3 handler pointer about thread
985  * @param[in]   account_id account id
986  * @param[in]   folder_id_list list of folder id
987  * @param[in]   folder_id_count count of folder id
988  * @param[in]   item_type_id_list list of item type id
989  * @param[in]   item_type_id_count count of item type id
990  * @return Operation result
991  * @retval SYNC_AGENT_DA_SUCCESS success
992  * @retval negative value error
993  */
994 sync_agent_da_return_e da_set_item_changelog_wait_status(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char **folder_id_list, int folder_id_count, int *item_type_id_list, int item_type_id_count);
995
996 /**
997  * @brief Get itemChangelog info from account_item_changelog_tbl by item id - currently unused function
998  * @remarks Item id that is included in sync_agent_da_item_changelog_s must be set by user when call this function
999  * @param[in]   daci_handler sqlite3 handler pointer about thread
1000  * @param[in]   account_id account id
1001  * @param[in]   item_changelog as returned by da_get_item_changelog_by_item_id() - itemChangelog info (itemId, operationId, syncStatus, accessName)
1002  * @return Operation result
1003  * @retval SYNC_AGENT_DA_SUCCESS success
1004  * @retval negative value error
1005  */
1006 sync_agent_da_return_e da_get_item_changelog_by_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_da_item_changelog_s * item_changelog);
1007
1008 /**
1009  * @brief Get itemChangelog info from account_item_changelog_tbl by item id
1010  * @param[in]   daci_handler sqlite3 handler pointer about thread
1011  * @param[in]   account_id account id
1012  * @param[in] item_id item id
1013  * @param[in]   sync_agent_item as returned by da_get_item_changelog_by_item_id() - itemChangelog info (itemId, operationId, syncStatus, accessName)
1014  * @return Operation result
1015  * @retval SYNC_AGENT_DA_SUCCESS success
1016  * @retval negative value error
1017  */
1018 sync_agent_da_return_e da_get_item_changelog_by_item_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id, sync_agent_da_item_changelog_s ** sync_agent_item);
1019
1020 /**
1021  * @brief Get itemChangelog info from account_item_changelog_tbl by item type id
1022  * @param[in]   daci_handler sqlite3 handler pointer about thread
1023  * @param[in]   account_id account id
1024  * @param[in] item_type_id item type id
1025  * @param[in] list as returned by da_get_item_changelog_by_item_type_id() - list of itemChangelog info
1026  * @return Operation result
1027  * @retval SYNC_AGENT_DA_SUCCESS success
1028  * @retval negative value error
1029  */
1030 sync_agent_da_return_e da_get_item_changelog_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, GList ** list);
1031
1032 /**
1033  * @brief Checking whether the item id exist in account_item_changelog_tbl
1034  * @param[in]   daci_handler sqlite3 handler pointer about thread
1035  * @param[in]   account_id account id
1036  * @param[in]   item_id item id
1037  * @return Checking result
1038  * @retval 1 exist
1039  * @retval 0 error or not exist
1040  */
1041 int da_is_exist_item_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id);
1042
1043 /*
1044  * =============================================================================================================================
1045  * last_anchor_tbl
1046  * =============================================================================================================================
1047  */
1048
1049 /**
1050  * @brief       Insert anchor into last_anchor_tbl
1051  * @param[in]   daci_handler sqlite3 handler pointer about thread
1052  * @param[in]   last_anchor last anchor info
1053  * @return Operation result
1054  * @retval SYNC_AGENT_DA_SUCCESS success
1055  * @retval negative value error
1056  */
1057 sync_agent_da_return_e da_add_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor);
1058
1059 /**
1060  * @brief Delete anchor from last_anchor_tbl by account id
1061  *                              Delete all the anchor in account
1062  * @param[in]   daci_handler sqlite3 handler pointer about thread
1063  * @param[in]   account_id account id
1064  * @return Operation result
1065  * @retval SYNC_AGENT_DA_SUCCESS success
1066  * @retval negative value error
1067  */
1068 sync_agent_da_return_e da_delete_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
1069
1070 /**
1071  * @brief Delete anchor from last_anchor_tbl by item type id
1072  *                              Delete all the anchor in account and item type id
1073  * @param[in]   daci_handler sqlite3 handler pointer about thread
1074  * @param[in]   account_id account id
1075  * @param[in]   item_type_id item type id
1076  * @return Operation result
1077  * @retval SYNC_AGENT_DA_SUCCESS success
1078  * @retval negative value error
1079  */
1080 sync_agent_da_return_e da_delete_last_anchor_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
1081
1082 /**
1083  * @brief Set last_anchor_server and last_anchor_client to last_anchor_tbl
1084  * @param[in]   daci_handler sqlite3 handler pointer about thread
1085  * @param[in]   last_anchor last anchor info
1086  * @return Operation result
1087  * @retval SYNC_AGENT_DA_SUCCESS success
1088  * @retval negative value error
1089  */
1090 sync_agent_da_return_e da_set_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor);
1091
1092 /**
1093  * @brief Get all last anchor in account from last_anchor_tbl
1094  * @param[in]   daci_handler sqlite3 handler pointer about thread
1095  * @param[in]   account_id account id
1096  * @param[in]   count as returned by da_get_last_anchor_by_account_id() -       count of last anchor info
1097  * @return Operation result
1098  * @retval array of last anchor info success
1099  * @retval NULL error
1100  */
1101 sync_agent_da_last_anchor_s *da_get_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count);
1102
1103 /**
1104  * @brief Get last_anchor_server and last_anchor_client from last_anchor_tbl by item type id - currently unused function
1105  * @param[in]   daci_handler sqlite3 handler pointer about thread
1106  * @param[in]   account_id                                                                              accountId
1107  * @param[in]   item_type_id                                                                            itemTypeId
1108  * @param[in]   count   as returned by da_get_last_anchor_by_item_type_id() - count of last anchor info
1109  * @return Operation result
1110  * @retval last anchor info success
1111  * @retval NULL error
1112  */
1113 sync_agent_da_last_anchor_s *da_get_last_anchor_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, int *count);
1114
1115 /**
1116  * @brief Get last_anchor_server and last_anchor_client from last_anchor_tbl by item type id
1117  * @param[in]   daci_handler sqlite3 handler pointer about thread
1118  * @param[in]   account_id                                                                              accountId
1119  * @param[in]   item_type_id                                                                            itemTypeId
1120  * @param[in]   list    as returned by da_get_last_anchor_by_item_type_id() - list of last anchor info
1121  * @return Operation result
1122  * @retval SYNC_AGENT_DA_SUCCESS success
1123  * @retval negative value error
1124  */
1125 sync_agent_da_return_e da_get_last_anchor_by_item_type_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id, GList ** list);
1126
1127 /**
1128  * @brief Checking whether item type id of the anchor exist in last_anchor_tbl
1129  * @param[in]   daci_handler sqlite3 handler pointer about thread
1130  * @param[in]   account_id account id
1131  * @param[in]   item_type_id item type id
1132  * @return Checking result
1133  * @retval 1 exist
1134  * @retval 0 error or not exist
1135  */
1136 int da_is_exist_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
1137
1138 /*
1139  * =============================================================================================================================
1140  * mapping_tbl
1141  * =============================================================================================================================
1142  */
1143
1144 /**
1145  * @brief       Insert mapping into mapping_tbl
1146  * @param[in]   daci_handler sqlite3 handler pointer about thread
1147  * @param[in]   mapping mapping info
1148  * @return Operation result
1149  * @retval SYNC_AGENT_DA_SUCCESS success
1150  * @retval negative value error
1151  */
1152 sync_agent_da_return_e da_add_mapping(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_mapping_s * mapping);
1153
1154 /**
1155  * @brief Delete mapping from mapping_tbl by account id
1156  *                              Delete all the mapping in account
1157  * @param[in]   daci_handler sqlite3 handler pointer about thread
1158  * @param[in]   account_id account id
1159  * @return Operation result
1160  * @retval SYNC_AGENT_DA_SUCCESS success
1161  * @retval negative value error
1162  */
1163 sync_agent_da_return_e da_delete_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
1164
1165 /**
1166  * @brief Delete mapping from mapping_tbl by luid
1167  * @param[in]   daci_handler sqlite3 handler pointer about thread
1168  * @param[in]   account_id account id
1169  * @param[in]   luid luid
1170  * @return Operation result
1171  * @retval SYNC_AGENT_DA_SUCCESS success
1172  * @retval negative value error
1173  */
1174 sync_agent_da_return_e da_delete_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
1175
1176 /**
1177  * @brief Get all mapping info from mapping_tbl by account id - currently unused function
1178  *                              Get all the mapping info in account
1179  * @param[in]   daci_handler sqlite3 handler pointer about thread
1180  * @param[in]   account_id account id
1181  * @param[in]   count as returned by da_get_mapping_by_account_id() - count of mapping info
1182  * @return Operation result
1183  * @retval array of mapping info success
1184  * @retval NULL error
1185  */
1186 sync_agent_da_mapping_s *da_get_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count);
1187
1188 /**
1189  * @brief Get all mapping info from mapping_tbl by account id
1190  *                              Get all the mapping info in account
1191  * @param[in]   daci_handler sqlite3 handler pointer about thread
1192  * @param[in]   account_id account id
1193  * @param[in]   list as returned by da_get_mapping_by_account_id() - list of mapping info
1194  * @return Operation result
1195  * @retval SYNC_AGENT_DA_SUCCESS success
1196  * @retval negative value error
1197  */
1198 sync_agent_da_return_e da_get_mapping_by_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list);
1199
1200 /**
1201  * @brief Get luid from mapping_tbl by guid - currently unused function
1202  * @param[in]   daci_handler sqlite3 handler pointer about thread
1203  * @param[in]   account_id account id
1204  * @param[in]   luid luid
1205  * @return Operation result
1206  * @retval guid success
1207  * @retval NULL error
1208  */
1209 char *da_get_mapping_guid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
1210
1211 /**
1212  * @brief Get luid from mapping_tbl by guid
1213  * @param[in]   daci_handler sqlite3 handler pointer about thread
1214  * @param[in]   account_id account id
1215  * @param[in]   luid luid
1216  * @param[in] sync_agent_mapping as returned by da_get_mapping_guid_new() - mapping info
1217  * @return Operation result
1218  * @retval SYNC_AGENT_DA_SUCCESS success
1219  * @retval negative value error
1220  */
1221 sync_agent_da_return_e da_get_mapping_guid_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid, sync_agent_da_mapping_s ** sync_agent_mapping);
1222
1223 /**
1224  * @brief Checking whether account exist in mapping_tbl
1225  * @param[in]   daci_handler sqlite3 handler pointer about thread
1226  * @param[in]   account_id account id
1227  * @return Checking result
1228  * @retval 1 exist
1229  * @retval 0 error or not exist
1230  */
1231 int da_is_exist_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
1232
1233 /**
1234  * @brief Checking whether the account and item tpe id of the item type id exist in mapping_tbl
1235  * @param[in]   daci_handler sqlite3 handler pointer about thread
1236  * @param[in]   account_id account id
1237  * @param[in]   luid luid
1238  * @return Checking result
1239  * @retval 1 exist
1240  * @retval 0 error or not exist
1241  */
1242 int da_is_exist_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
1243
1244 /*
1245  * =============================================================================================================================
1246  * id_provider_tbl, id_page_tbl
1247  * =============================================================================================================================
1248  */
1249
1250 /**
1251  * @brief       Insert id_provider into id_provider_tbl
1252  * @param[in]   daci_handler sqlite3 handler pointer about thread
1253  * @param[in]   id_provider id provider info
1254  * @return Operation result
1255  * @retval SYNC_AGENT_DA_SUCCESS success
1256  * @retval negative value error
1257  */
1258 sync_agent_da_return_e da_add_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider);
1259
1260 /**
1261  * @brief Get id_provider from id_provider_tbl
1262  * @param[in]   daci_handler sqlite3 handler pointer about thread
1263  * @param[in]   id_provider_code id provider code
1264  * @param[in]   id_provider     as returned by da_get_id_provider() - id provider info
1265  * @return Operation result
1266  * @retval SYNC_AGENT_DA_SUCCESS success
1267  * @retval negative value error
1268  */
1269 sync_agent_da_return_e da_get_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, sync_agent_da_id_provider_s ** id_provider);
1270
1271 /**
1272  * @brief Update id provider in id_provider_tbl
1273  * @param[in]   daci_handler sqlite3 handler pointer about thread
1274  * @param[in]   id_provider id provider info
1275  * @return Operation result
1276  * @retval SYNC_AGENT_DA_SUCCESS success
1277  * @retval negative value error
1278  */
1279 sync_agent_da_return_e da_update_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider);
1280
1281 /**
1282  * @brief       Insert id page into id_page_tbl
1283  * @param[in]   daci_handler sqlite3 handler pointer about thread
1284  * @param[in]   id_page id page info
1285  * @param[in] page_byte_size page byte size
1286  * @return Operation result
1287  * @retval SYNC_AGENT_DA_SUCCESS success
1288  * @retval negative value error
1289  */
1290 sync_agent_da_return_e da_add_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_page_s * id_page, unsigned int page_byte_size);
1291
1292 /**
1293  * @brief Delete id page from id_page_tbl by page index
1294  * @param[in]   daci_handler sqlite3 handler pointer about thread
1295  * @param[in]   id_provider_code id provider code
1296  * @param[in]   page_index page index
1297  * @return Operation result
1298  * @retval SYNC_AGENT_DA_SUCCESS success
1299  * @retval negative value error
1300  */
1301 sync_agent_da_return_e da_delete_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, unsigned int page_index);
1302
1303 /**
1304  * @brief       Insert id page into id_page_tbl
1305  * @param[in]   daci_handler sqlite3 handler pointer about thread
1306  * @param[in]   id_provider_code id provider code
1307  * @param[in]   page_index page index
1308  * @param[in]   page_bit as returned by da_get_id_page() - page bit
1309  * @return Operation result
1310  * @retval SYNC_AGENT_DA_SUCCESS success
1311  * @retval negative value error
1312  */
1313 sync_agent_da_return_e da_get_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, unsigned int page_index, char **page_bit);
1314
1315 /**
1316  * @brief       Get id of page index
1317  * @param[in]   daci_handler sqlite3 handler pointer about thread
1318  * @param[in]   id_provider_code id provider code
1319  * @param[in]   count   as returned by da_get_id_page_index() - count of page index
1320  * @return Operation result
1321  * @retval SYNC_AGENT_DA_SUCCESS success
1322  * @retval negative value error
1323  */
1324 sync_agent_da_return_e da_get_id_page_index(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, int *count);
1325
1326 /**
1327  * @brief Insert id page into id_page_tbl
1328  * @param[in]   daci_handler sqlite3 handler pointer about thread
1329  * @param[in]   id_page id page info
1330  * @param[in]   page_byte_size page byte size
1331  * @return Operation result
1332  * @retval SYNC_AGENT_DA_SUCCESS success
1333  * @retval negative value error
1334  */
1335 sync_agent_da_return_e da_update_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_page_s * id_page, unsigned int page_byte_size);
1336
1337 /*
1338  * @brief       get item count with data store id
1339  * @param[in]           daci_handler                                                                    sqlite3 handler pointer about thread
1340  * @param[in]           data_store_id                                                                   data store id
1341  * @param[in]           fw_account_id                                                                   account id
1342  * @param[out]  item_count                                                                      item count
1343  * @return              operation result
1344  * @retval              SYNC_AGENT_DA_SUCCESS                                           success
1345  * @retval              error value                                                                     fail
1346  */
1347 sync_agent_da_return_e da_get_item_count_by_datastore_id(SYNC_AGENT_DA_HANDLER *daci_handler, int data_store_id, int fw_account_id, int *item_count);
1348
1349 /*
1350  * @brief       get updated_exdate_item count with parent item's framework id
1351  * @param[in]           daci_handler                                                                    sqlite3 handler pointer about thread
1352  * @param[in]           fw_id                                                                           framework id of the parent item
1353  * @param[in]           list                                                                                    list as returned updated exdate item_id list
1354  * @return              sync_agent_da_return_e
1355  * @retval              SYNC_AGENT_DA_SUCCESS                                           success
1356  * @retval              error value                                                                     fail
1357  */
1358 sync_agent_da_return_e da_get_updated_exdate_item_id_list(SYNC_AGENT_DA_HANDLER *daci_handler, char *fw_id, GList ** list);
1359
1360 /*
1361  * =============================================================================================================================
1362  * Testing
1363  * =============================================================================================================================
1364  */
1365
1366 /**
1367  * @brief Drop database table for list of account id
1368  * @param[in] daci_handler sqlite3 handler pointer about thread
1369  * @param[in] account_id_list list of account id
1370  * @param[in] account_count count of account id
1371  */
1372 void da_drop_table(SYNC_AGENT_DA_HANDLER * daci_handler, int *account_id_list, int account_count);
1373
1374 /*
1375  * For ID_Provider todo i should remove this rutine!!!!
1376  */
1377 /**
1378  * @breif Get daci file path
1379  * @return Operation result
1380  * @retval daci file path success
1381  * @retval NULL error
1382  */
1383 char *da_get_daci_file_path(void);
1384
1385 #endif                          /* AGENT_H_ */