3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef MO_DATABASE_HANDLER_H_
19 #define MO_DATABASE_HANDLER_H_
21 #include "device-manager/mo_error.h"
22 #include "device-manager/mo_struct.h"
24 #include "data-adapter/common.h"
30 #endif /* __cplusplus */
33 * @file mo_database_handler.h
34 * @brief Definition of framework codes for device manager module
37 /** @addtogroup device_manager
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;
49 * API to Alloc th mo db handler manager
50 * @remarks This function is use to alloc th mo db handler
55 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
57 * @pre This function should be called if need to alloc th mo db handler
63 * @see __process_device_manage(xmlNode *device_manage_node)
66 sync_agent_dm_mo_error_e dm_mo_alloc_modb_handler_mgr(void);
69 * API to Free th mo db handler manager
70 * @remarks This function is use to free th mo db handler
75 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
77 * @pre This function should be called if need to free th mo db handler
86 sync_agent_dm_mo_error_e dm_mo_free_modb_handler_mgr(void);
89 * API to Open th mo db
90 * @remarks This function is use to open the mo db handler
94 * @param[in] database_path database path
96 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
98 * @pre This function should be called if need to open the mo db handler
107 sync_agent_dm_mo_error_e dm_mo_open(char *database_path);
110 * API to Close th mo db
111 * @remarks This function is use to close the mo db handler
117 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
119 * @pre This function should be called if need to close the mo db handler
128 sync_agent_dm_mo_error_e dm_mo_close(void);
131 * API to Create mo table
132 * @remarks This function is use to create the mo table
138 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
140 * @pre This function should be called if need to close the mo db handler
149 sync_agent_dm_mo_error_e dm_mo_create_mo_table_wraper(void);
152 * API to Begin transaction mo table
153 * @remarks This function is use to begin transaction mo table
159 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
161 * @pre This function should be called if need to begin transaction mo table
170 sync_agent_dm_mo_error_e dm_mo_begin_transaction_wraper(void);
173 * API to End transaction mo table
174 * @remarks This function is use to end transaction mo table
178 * @param[in] transaction transaction type (SYNC_AGENT_DA_TRANSACTION_COMMIT, SYNC_AGENT_DA_TRANSACTION_ROLLBACK)
180 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
182 * @pre This function should be called if need to end transaction mo table
191 sync_agent_dm_mo_error_e dm_mo_end_transaction_wraper(sync_agent_da_transaction_e transaction);
194 * API to Add mo node to mo db
195 * @remarks This function is use to add mo node to mo db
199 * @param[in] mo_type mo type (dmacc, devinfo...)
200 * @param[in] mo_node mo node struct
203 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
205 * @pre This function should be called if need to add mo n ode to mo db
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);
217 * API to Delete mo node in mo db
218 * @remarks This function is use to delete mo node in mo db
221 * @param[in] mo_node_id db id
224 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
226 * @pre This function should be called if need to delete mo node in mo db
235 sync_agent_dm_mo_error_e dm_mo_delete_node_wraper(int mo_node_id);
238 * API to Update mo node in mo db
239 * @remarks This function is use to update mo node in mo db
242 * @param[in] mo_type mo type (dmacc, devinfo...)
243 * @param[in] path mo node path
244 * @param[in] mo_node mo node struct
248 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
250 * @pre This function should be called if need to delete mo node in mo db
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);
262 * API to Get mo node in mo db
263 * @remarks This function is use to get mo node in mo db
267 * @param[in] path mo node path
268 * @param[out] mo_node mo node struct
272 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
274 * @pre This function should be called if need to get mo node in mo db
282 sync_agent_dm_mo_error_e dm_mo_get_node_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
285 * API to Get mo nodes in mo db
286 * @remarks This function is use to get mo nodes in mo db
290 * @param[in] path mo node path
291 * @param[out] mo_node mo node struct
295 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
297 * @pre This function should be called if need to get mo nodes in mo db
305 sync_agent_dm_mo_error_e dm_mo_get_nodes_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
308 * API to Check exist mo node in mo db
309 * @remarks This function is use to check exist mo node in mo db
313 * @param[in] path mo node path
317 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
319 * @pre This function should be called if need to check exist mo node in mo db
327 sync_agent_dm_mo_error_e dm_mo_is_exist_node_wraper(const char *path);
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
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
342 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
344 * @pre This function should be called if need to get mo node's child node in mo db
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);
355 * API to Delete all node in mo db
356 * @remarks This function is use to delete all node in mo db
362 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
364 * @pre This function should be called if need to delete all node in mo db
372 sync_agent_dm_mo_error_e dm_mo_delete_all_node_wraper(void);
375 * API to Get mo node's mo type
376 * @remarks This function is use to get mo node's mo type
380 * @param[in] mo_full_path mo node path
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
387 * @pre This function should be called if need to get mo node's mo type
395 sync_agent_dm_mo_type_e dm_mo_get_mo_type_wraper(const char *mo_full_path);
398 * API to Get node from db id
399 * @remarks This function is use to get node from db id
402 * @param[in] node_id db node id
403 * @param[out] mo_node mo node struct
406 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
408 * @pre This function should be called if need to get node from db id
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);
419 * API to Get dmacc struct
420 * @remarks This function is use to get dmacc struct
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
429 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
431 * @pre This function should be called if need to get dmacc struct
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)
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);
442 * API to Set dmacc struct
443 * @remarks This function is use to set dmacc struct
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
452 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
454 * @pre This function should be called if need to set dmacc struct
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)
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);
465 * API to Get server id list
466 * @remarks This function is use to get server id list
469 * @param[in] server_id server id
470 * @param[out] server_info server info struct
473 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
475 * @pre This function should be called if need to get server id list
481 * @see sync_agent_get_serverinfo(sync_agent_dm_server_info_s **server_info)
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);
486 * API to Get root path
487 * @remarks This function is use to get root path
490 * @param[in] mo_full_path mo node path
491 * @param[out] root_path node's root path
494 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
496 * @pre This function should be called if need to get root path
504 sync_agent_dm_mo_error_e dm_mo_get_root_path_wraper(const char *mo_full_path, char **root_path);
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
511 * @param[in] mo_node_id mo db id
512 * @param[in] framework_property mo node framework property struct
515 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
517 * @pre This function should be called if need to add mo node's framework property to mo db
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);
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
532 * @param[in] mo_node_id mo db id
535 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
537 * @pre This function should be called if need to delete mo node's framework property in mo db
545 sync_agent_dm_mo_error_e dm_mo_delete_framework_property_wraper(int mo_node_id);
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
552 * @param[in] mo_node_id mo db id
553 * @param[in] framework_property mo node framework property struct
556 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
558 * @pre This function should be called if need to update mo node's framework property in mo db
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);
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
573 * @param[in] mo_node_id mo db id
574 * @param[out] framework_property mo node framework property struct
577 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
579 * @pre This function should be called if need to get mo node's framework property in mo db
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);
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
596 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
598 * @pre This function should be called if need to delete all mo node's framework property in mo db
606 sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property_wraper(void);
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
613 * @param[in] mo_node_id mo db id
614 * @param[in] runtime_property mo node runtime property struct
617 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
619 * @pre This function should be called if need to add mo node's runtime property to mo db
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);
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
634 * @param[in] mo_node_id mo db id
637 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
639 * @pre This function should be called if need to delete mo node's runtime property in mo db
647 sync_agent_dm_mo_error_e dm_mo_delete_runtime_property_wraper(int mo_node_id);
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
654 * @param[in] mo_node_id mo db id
655 * @param[in] runtime_property mo node runtime property struct
658 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
660 * @pre This function should be called if need to update mo node's runtime property in mo db
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);
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
675 * @param[in] mo_node_id mo db id
676 * @param[out] runtime mo node runtime property struct
679 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
681 * @pre This function should be called if need to get mo node's runtime property in mo db
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);
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
698 * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
700 * @pre This function should be called if need to delete all mo node's runtime property in mo db
708 sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property_wraper(void);
716 #endif /* __cplusplus */
717 #endif /* MO_DATABASE_HANDLER_H_ */