Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / device-manager / mo_database_handler.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 MO_DATABASE_HANDLER_H_
19 #define MO_DATABASE_HANDLER_H_
20
21 #include "device-manager/mo_error.h"
22 #include "device-manager/mo_struct.h"
23
24 #include "data-adapter/common.h"
25
26 #include <glib.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif                          /* __cplusplus */
31
32 /**
33  * @file        mo_database_handler.h
34  * @brief       Definition of framework codes for device manager module
35  */
36
37 /** @addtogroup device_manager
38  *      @{
39  */
40
41         typedef struct {
42                 GHashTable *mo_handlerTable;
43                                      /**< agent db handler hash table */
44                 pthread_mutex_t *mo_handlerTable_mutex;
45                                                /**< mutex for agent db handler hash table */
46         } dm_mo_handler_mgr_s;
47
48 /**
49  * API to Alloc th mo db handler manager
50  * @remarks This function is use to alloc th mo db handler
51  *
52  * @par Usage:
53  *
54  *
55  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
56  *
57  * @pre  This function should be called if need to alloc th mo db handler
58  * @post
59  *
60  * @par Since:
61  *
62  *
63  * @see __process_device_manage(xmlNode *device_manage_node)
64  *
65  */
66         sync_agent_dm_mo_error_e dm_mo_alloc_modb_handler_mgr(void);
67
68 /**
69  * API to Free th mo db handler manager
70  * @remarks This function is use to free th mo db handler
71  *
72  * @par Usage:
73  *
74  *
75  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
76  *
77  * @pre  This function should be called if need to free th mo db handler
78  * @post
79  *
80  * @par Since:
81  *
82  *
83  * @see
84  *
85  */
86         sync_agent_dm_mo_error_e dm_mo_free_modb_handler_mgr(void);
87
88 /**
89  * API to Open th mo db
90  * @remarks This function is use to open the mo db handler
91  *
92  * @par Usage:
93  *
94  *      @param[in] database_path database path
95  *
96  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
97  *
98  * @pre  This function should be called if need to open the mo db handler
99  * @post
100  *
101  * @par Since:
102  *
103  *
104  * @see
105  *
106  */
107         sync_agent_dm_mo_error_e dm_mo_open(char *database_path);
108
109 /**
110  * API to Close th mo db
111  * @remarks This function is use to close the mo db handler
112  *
113  * @par Usage:
114  *
115  *
116  *
117  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
118  *
119  * @pre  This function should be called if need to close the mo db handler
120  * @post
121  *
122  * @par Since:
123  *
124  *
125  * @see
126  *
127  */
128         sync_agent_dm_mo_error_e dm_mo_close(void);
129
130 /**
131  * API to Create mo table
132  * @remarks This function is use to create the mo table
133  *
134  * @par Usage:
135  *
136  *
137  *
138  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
139  *
140  * @pre  This function should be called if need to close the mo db handler
141  * @post
142  *
143  * @par Since:
144  *
145  *
146  * @see
147  *
148  */
149         sync_agent_dm_mo_error_e dm_mo_create_mo_table_wraper(void);
150
151 /**
152  * API to Begin transaction mo table
153  * @remarks This function is use to begin transaction mo table
154  *
155  * @par Usage:
156  *
157  *
158  *
159  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
160  *
161  * @pre  This function should be called if need to begin transaction mo table
162  * @post
163  *
164  * @par Since:
165  *
166  *
167  * @see
168  *
169  */
170         sync_agent_dm_mo_error_e dm_mo_begin_transaction_wraper(void);
171
172 /**
173  * API to End transaction mo table
174  * @remarks This function is use to end transaction mo table
175  *
176  * @par Usage:
177  *
178  *      @param[in] transaction transaction type (SYNC_AGENT_DA_TRANSACTION_COMMIT, SYNC_AGENT_DA_TRANSACTION_ROLLBACK)
179  *
180  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
181  *
182  * @pre  This function should be called if need to end transaction mo table
183  * @post
184  *
185  * @par Since:
186  *
187  *
188  * @see
189  *
190  */
191         sync_agent_dm_mo_error_e dm_mo_end_transaction_wraper(sync_agent_da_transaction_e transaction);
192
193 /**
194  * API to Add mo node to mo db
195  * @remarks This function is use to add mo node to mo db
196  *
197  * @par Usage:
198  *
199  * @param[in] mo_type mo type (dmacc, devinfo...)
200  * @param[in] mo_node mo node struct
201  *
202  *
203  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
204  *
205  * @pre  This function should be called if need to add mo n ode to mo db
206  * @post
207  *
208  * @par Since:
209  *
210  *
211  * @see
212  *
213  */
214         sync_agent_dm_mo_error_e dm_mo_add_node_wraper(sync_agent_dm_mo_type_e mo_type, sync_agent_dm_mo_node_s * mo_node);
215
216 /**
217  * API to Delete mo node in mo db
218  * @remarks This function is use to delete mo node in mo db
219  *
220  * @par Usage:
221  * @param[in] mo_node_id db id
222  *
223  *
224  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
225  *
226  * @pre  This function should be called if need to delete mo node in mo db
227  * @post
228  *
229  * @par Since:
230  *
231  *
232  * @see
233  *
234  */
235         sync_agent_dm_mo_error_e dm_mo_delete_node_wraper(int mo_node_id);
236
237 /**
238  * API to Update mo node in mo db
239  * @remarks This function is use to update mo node in mo db
240  *
241  * @par Usage:
242  * @param[in] mo_type mo type (dmacc, devinfo...)
243  * @param[in] path mo node path
244  * @param[in] mo_node mo node struct
245  *
246  *
247  *
248  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
249  *
250  * @pre  This function should be called if need to delete mo node in mo db
251  * @post
252  *
253  * @par Since:
254  *
255  *
256  * @see
257  *
258  */
259         sync_agent_dm_mo_error_e dm_mo_update_node_wraper(sync_agent_dm_mo_type_e mo_type, const char *path, const sync_agent_dm_mo_node_s * mo_node);
260
261 /**
262  * API to Get mo node in mo db
263  * @remarks This function is use to get mo node in mo db
264  *
265  * @par Usage:
266  *
267  * @param[in] path mo node path
268  * @param[out] mo_node mo node struct
269  *
270  *
271  *
272  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
273  *
274  * @pre  This function should be called if need to get mo node in mo db
275  * @post
276  *
277  * @par Since:
278  *
279  *
280  * @see
281  */
282         sync_agent_dm_mo_error_e dm_mo_get_node_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
283
284 /**
285  * API to Get mo nodes in mo db
286  * @remarks This function is use to get mo nodes in mo db
287  *
288  * @par Usage:
289  *
290  * @param[in] path mo node path
291  * @param[out] mo_node mo node struct
292  *
293  *
294  *
295  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
296  *
297  * @pre  This function should be called if need to get mo nodes in mo db
298  * @post
299  *
300  * @par Since:
301  *
302  *
303  * @see
304  */
305         sync_agent_dm_mo_error_e dm_mo_get_nodes_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
306
307 /**
308  * API to Check exist mo node in mo db
309  * @remarks This function is use to check exist  mo node in mo db
310  *
311  * @par Usage:
312  *
313  * @param[in] path mo node path
314  *
315  *
316  *
317  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
318  *
319  * @pre  This function should be called if need to check exist  mo node in mo db
320  * @post
321  *
322  * @par Since:
323  *
324  *
325  * @see
326  */
327         sync_agent_dm_mo_error_e dm_mo_is_exist_node_wraper(const char *path);
328
329 /**
330  * API to Get mo node's child node in mo db
331  * @remarks This function is use to get mo node's child node in mo db
332  *
333  * @par Usage:
334  *
335  * @param[in] mo_type mo type
336  * @param[in] path mo node path
337  * @param[out] mo_node child mo nodes
338  * @param[out] count child node count
339  *
340  *
341  *
342  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
343  *
344  * @pre  This function should be called if need to get mo node's child node in mo db
345  * @post
346  *
347  * @par Since:
348  *
349  *
350  * @see
351  */
352         sync_agent_dm_mo_error_e dm_mo_get_child_node_wraper(sync_agent_dm_mo_type_e mo_type, const char *path, sync_agent_dm_mo_node_s ** mo_node, int *count);
353
354 /**
355  * API to Delete all node in mo db
356  * @remarks This function is use to delete all node in mo db
357  *
358  * @par Usage:
359  *
360  *
361  *
362  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
363  *
364  * @pre  This function should be called if need to delete all node in mo db
365  * @post
366  *
367  * @par Since:
368  *
369  *
370  * @see
371  */
372         sync_agent_dm_mo_error_e dm_mo_delete_all_node_wraper(void);
373
374 /**
375  * API to Get mo node's mo type
376  * @remarks This function is use to get mo node's mo type
377  *
378  * @par Usage:
379  *
380  *      @param[in] mo_full_path mo node path
381  *
382  *
383  * @return      SYNC_AGENT_DM_MO_TYPE_DMACC, SYNC_AGENT_DM_MO_TYPE_DEVINFO, SYNC_AGENT_DM_MO_TYPE_DEVDETAIL,
384                                 SYNC_AGENT_DM_MO_TYPE_FUMO, SYNC_AGENT_DM_MO_TYPE_LAWMO, SYNC_AGENT_DM_MO_TYPE_SCOMO,
385                                 SYNC_AGENT_DM_MO_TYPE_NO_TYPE
386  *
387  * @pre  This function should be called if need to get mo node's mo type
388  * @post
389  *
390  * @par Since:
391  *
392  *
393  * @see
394  */
395         sync_agent_dm_mo_type_e dm_mo_get_mo_type_wraper(const char *mo_full_path);
396
397 /**
398  * API to Get node from db id
399  * @remarks This function is use to get node from db id
400  *
401  * @par Usage:
402  * @param[in] node_id db node id
403  * @param[out] mo_node mo node struct
404  *
405  *
406  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
407  *
408  * @pre  This function should be called if need to get node from db id
409  * @post
410  *
411  * @par Since:
412  *
413  *
414  * @see
415  */
416         sync_agent_dm_mo_error_e dm_mo_get_node_from_id_wraper(int node_id, sync_agent_dm_mo_node_s ** mo_node);
417
418 /**
419  * API to Get dmacc struct
420  * @remarks This function is use to get dmacc struct
421  *
422  * @par Usage:
423  * @param[in] server_id server id
424  * @param[in] server_id_string "ServerID"
425  * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
426  * @param[out] acc_info acc info struct
427  *
428  *
429  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
430  *
431  * @pre  This function should be called if need to get dmacc struct
432  * @post
433  *
434  * @par Since:
435  *
436  *
437  * @see sync_agent_get_mo_acc_item (sync_agent_dm_mo_acc_item_info_s *sync_agent_mo_acc_info_item, sync_agent_dm_acc_info_s **acc_info)
438  */
439         sync_agent_dm_mo_error_e dm_mo_get_acc_info_wraper(const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s ** acc_info);
440
441 /**
442  * API to Set dmacc struct
443  * @remarks This function is use to set dmacc struct
444  *
445  * @par Usage:
446  * @param[in] server_id server id
447  * @param[in] server_id_string "ServerID"
448  * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
449  * @param[in] acc_info acc info struct
450  *
451  *
452  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
453  *
454  * @pre  This function should be called if need to set dmacc struct
455  * @post
456  *
457  * @par Since:
458  *
459  *
460  * @see sync_agent_set_mo_acc_item (sync_agent_dm_mo_acc_item_info_s *sync_agent_mo_acc_info_item, sync_agent_dm_acc_info_s **acc_info)
461  */
462         sync_agent_dm_mo_error_e dm_mo_set_acc_info_wraper(const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s * acc_info);
463
464 /**
465  * API to Get server id list
466  * @remarks This function is use to get server id list
467  *
468  * @par Usage:
469  * @param[in] server_id server id
470  * @param[out] server_info server info struct
471  *
472  *
473  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
474  *
475  * @pre  This function should be called if need to get server id list
476  * @post
477  *
478  * @par Since:
479  *
480  *
481  * @see sync_agent_get_serverinfo(sync_agent_dm_server_info_s **server_info)
482  */
483         sync_agent_dm_mo_error_e dm_mo_get_server_id_list_wraper(const char *server_id_string, sync_agent_dm_server_info_s ** server_info);
484
485 /**
486  * API to Get root path
487  * @remarks This function is use to get root path
488  *
489  * @par Usage:
490  * @param[in] mo_full_path mo node path
491  * @param[out] root_path node's root path
492  *
493  *
494  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
495  *
496  * @pre  This function should be called if need to get root path
497  * @post
498  *
499  * @par Since:
500  *
501  *
502  * @see
503  */
504         sync_agent_dm_mo_error_e dm_mo_get_root_path_wraper(const char *mo_full_path, char **root_path);
505
506 /**
507  * API to Add mo node's framework property to mo db
508  * @remarks This function is use to add mo node's framework property to mo db
509  *
510  * @par Usage:
511  * @param[in] mo_node_id mo db id
512  * @param[in] framework_property mo node framework property struct
513  *
514  *
515  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
516  *
517  * @pre  This function should be called if need to add mo node's framework property to mo db
518  * @post
519  *
520  * @par Since:
521  *
522  *
523  * @see
524  */
525         sync_agent_dm_mo_error_e dm_mo_add_framework_property_wraper(int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property);
526
527 /**
528  * API to Delete mo node's framework property in mo db
529  * @remarks This function is use to delete mo node's framework property in mo db
530  *
531  * @par Usage:
532  * @param[in] mo_node_id mo db id
533  *
534  *
535  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
536  *
537  * @pre  This function should be called if need to delete mo node's framework property in mo db
538  * @post
539  *
540  * @par Since:
541  *
542  *
543  * @see
544  */
545         sync_agent_dm_mo_error_e dm_mo_delete_framework_property_wraper(int mo_node_id);
546
547 /**
548  * API to Update mo node's framework property in mo db
549  * @remarks This function is use to update mo node's framework property in mo db
550  *
551  * @par Usage:
552  * @param[in] mo_node_id mo db id
553  * @param[in] framework_property mo node framework property struct
554  *
555  *
556  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
557  *
558  * @pre  This function should be called if need to update mo node's framework property in mo db
559  * @post
560  *
561  * @par Since:
562  *
563  *
564  * @see
565  */
566         sync_agent_dm_mo_error_e dm_mo_update_framework_property_wraper(int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property);
567
568 /**
569  * API to Get mo node's framework property in mo db
570  * @remarks This function is use to get mo node's framework property in mo db
571  *
572  * @par Usage:
573  * @param[in] mo_node_id mo db id
574  * @param[out] framework_property mo node framework property struct
575  *
576  *
577  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
578  *
579  * @pre  This function should be called if need to get mo node's framework property in mo db
580  * @post
581  *
582  * @par Since:
583  *
584  *
585  * @see
586  */
587         sync_agent_dm_mo_error_e dm_mo_get_framework_property_wraper(int mo_node_id, sync_agent_dm_mo_framework_property_s ** framework_property);
588
589 /**
590  * API to Delete all mo node's framework property in mo db
591  * @remarks This function is use to delete all mo node's framework property in mo db
592  *
593  * @par Usage:
594  *
595  *
596  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
597  *
598  * @pre  This function should be called if need to delete all mo node's framework property in mo db
599  * @post
600  *
601  * @par Since:
602  *
603  *
604  * @see
605  */
606         sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property_wraper(void);
607
608 /**
609  * API to Add mo node's runtime property to mo db
610  * @remarks This function is use to add mo node's runtime property to mo db
611  *
612  * @par Usage:
613  * @param[in] mo_node_id mo db id
614  * @param[in] runtime_property mo node runtime property struct
615  *
616  *
617  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
618  *
619  * @pre  This function should be called if need to add mo node's runtime property to mo db
620  * @post
621  *
622  * @par Since:
623  *
624  *
625  * @see
626  */
627         sync_agent_dm_mo_error_e dm_mo_add_runtime_property_wraper(int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property);
628
629 /**
630  * API to Delete mo node's runtime property in mo db
631  * @remarks This function is use to delete mo node's runtime property in mo db
632  *
633  * @par Usage:
634  * @param[in] mo_node_id mo db id
635  *
636  *
637  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
638  *
639  * @pre  This function should be called if need to delete mo node's runtime property in mo db
640  * @post
641  *
642  * @par Since:
643  *
644  *
645  * @see
646  */
647         sync_agent_dm_mo_error_e dm_mo_delete_runtime_property_wraper(int mo_node_id);
648
649 /**
650  * API to Update mo node's runtime property in mo db
651  * @remarks This function is use to update mo node's runtime property in mo db
652  *
653  * @par Usage:
654  * @param[in] mo_node_id mo db id
655  * @param[in] runtime_property mo node runtime property struct
656  *
657  *
658  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
659  *
660  * @pre  This function should be called if need to update mo node's runtime property in mo db
661  * @post
662  *
663  * @par Since:
664  *
665  *
666  * @see
667  */
668         sync_agent_dm_mo_error_e dm_mo_update_runtime_property_wraper(int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property);
669
670 /**
671  * API to Get mo node's runtime property in mo db
672  * @remarks This function is use to get mo node's runtime property in mo db
673  *
674  * @par Usage:
675  * @param[in] mo_node_id mo db id
676  * @param[out] runtime mo node runtime property struct
677  *
678  *
679  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
680  *
681  * @pre  This function should be called if need to get mo node's runtime property in mo db
682  * @post
683  *
684  * @par Since:
685  *
686  *
687  * @see
688  */
689         sync_agent_dm_mo_error_e dm_mo_get_runtime_property_wraper(int mo_node_id, sync_agent_dm_mo_runtime_property_s ** runtime_property);
690
691 /**
692  * API to Delete all mo node's runtime property in mo db
693  * @remarks This function is use to delete all mo node's runtime property in mo db
694  *
695  * @par Usage:
696  *
697  *
698  * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
699  *
700  * @pre  This function should be called if need to delete all mo node's runtime property in mo db
701  * @post
702  *
703  * @par Since:
704  *
705  *
706  * @see
707  */
708         sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property_wraper(void);
709
710 /**
711  *      @}
712  */
713
714 #ifdef __cplusplus
715 }
716 #endif                          /* __cplusplus */
717 #endif                          /* MO_DATABASE_HANDLER_H_ */