Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:51:58 +0000 (01:51 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:51:58 +0000 (01:51 +0900)
485 files changed:
AUTHORS [new file with mode: 0755]
BuildFlags.cmake [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2 [new file with mode: 0755]
NOTICE [new file with mode: 0755]
TC/.gitignore [new file with mode: 0644]
TC/_export_env.sh [new file with mode: 0644]
TC/_export_target_env.sh [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/clean.sh [new file with mode: 0755]
TC/config [new file with mode: 0644]
TC/config.default [new file with mode: 0644]
TC/execute.sh [new file with mode: 0755]
TC/testcase/Makefile [new file with mode: 0644]
TC/testcase/fw-test-cfg/eventconfig_fw_test [new file with mode: 0644]
TC/testcase/fw-test-cfg/eventconfig_fw_test_omadm [new file with mode: 0644]
TC/testcase/fw-test-cfg/eventconfig_fw_test_omads [new file with mode: 0644]
TC/testcase/fw-test-cfg/noticonfig_fw_test [new file with mode: 0644]
TC/testcase/fw-test-cfg/noticonfig_fw_test_omadm [new file with mode: 0644]
TC/testcase/fw-test-cfg/noticonfig_fw_test_omads [new file with mode: 0644]
TC/testcase/fw-test-cfg/test_fw_config.xml [new file with mode: 0644]
TC/testcase/fw-test-cfg/test_fw_config_omadm.xml [new file with mode: 0644]
TC/testcase/fw-test-cfg/test_fw_config_omads.xml [new file with mode: 0644]
TC/testcase/fw-test-file/sample_xml [new file with mode: 0644]
TC/testcase/fw-test-file/target_compress [new file with mode: 0755]
TC/testcase/fw-test-file/target_uncompress.tar [new file with mode: 0644]
TC/testcase/fw-test-file/tnds_sample.txt [new file with mode: 0644]
TC/testcase/tslist [new file with mode: 0644]
TC/testcase/utc_sync_agent_framework_account.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_data_adapter.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_device.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_device_manager.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_engine_controller.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_account_reg.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_admin.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_alert.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_cp.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_dmacc.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_fota.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omadm_noti.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_event_omads.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_fsapi.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_initialization.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_network_access.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_platform_monitor.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_protocol_binder.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_security_assistant.c [new file with mode: 0755]
TC/testcase/utc_sync_agent_framework_utility.c [new file with mode: 0755]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
common-public-plugins.manifest [new file with mode: 0644]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0755]
debian/control [new file with mode: 0755]
debian/control.slp [new file with mode: 0755]
debian/dirs [new file with mode: 0755]
debian/libsync-agent-framework-dev.install [new file with mode: 0755]
debian/libsync-agent-framework-dev.postinst [new file with mode: 0755]
debian/libsync-agent-framework.install [new file with mode: 0755]
debian/rules [new file with mode: 0755]
debian/unit_test.sh [new file with mode: 0755]
doc/Doxyfile [new file with mode: 0644]
doc/DoxygenLayout.xml [new file with mode: 0644]
doc/appendix_configuration.dox [new file with mode: 0644]
doc/appendix_plugin.dox [new file with mode: 0644]
doc/groups.dox [new file with mode: 0644]
doc/groups_account.dox [new file with mode: 0644]
doc/groups_data_adapter.dox [new file with mode: 0644]
doc/groups_device.dox [new file with mode: 0644]
doc/groups_device_manager.dox [new file with mode: 0644]
doc/groups_engine_controller.dox [new file with mode: 0644]
doc/groups_event.dox [new file with mode: 0644]
doc/groups_file_system.dox [new file with mode: 0644]
doc/groups_initialization.dox [new file with mode: 0644]
doc/groups_network_access.dox [new file with mode: 0644]
doc/groups_platform_monitor.dox [new file with mode: 0644]
doc/groups_plugin_interface.dox [new file with mode: 0644]
doc/groups_protocol_binder.dox [new file with mode: 0644]
doc/groups_security_assistant.dox [new file with mode: 0644]
doc/groups_utility.dox [new file with mode: 0644]
doc/images/overview_account.png [new file with mode: 0644]
doc/images/overview_data_adapter.png [new file with mode: 0644]
doc/images/overview_device.png [new file with mode: 0644]
doc/images/overview_device_manager.png [new file with mode: 0644]
doc/images/overview_engine_controller.png [new file with mode: 0644]
doc/images/overview_event.png [new file with mode: 0644]
doc/images/overview_file_system.png [new file with mode: 0644]
doc/images/overview_initialization.png [new file with mode: 0644]
doc/images/overview_network_access.png [new file with mode: 0644]
doc/images/overview_platform_monitor.png [new file with mode: 0644]
doc/images/overview_plugin_interface.png [new file with mode: 0644]
doc/images/overview_protocol_binder.png [new file with mode: 0644]
doc/images/overview_security_assistant.png [new file with mode: 0644]
doc/images/overview_sync_agent_framework.png [new file with mode: 0644]
doc/images/overview_utility.png [new file with mode: 0644]
doc/images/tizen_logo.png [new file with mode: 0644]
doc/mainpage.dox [new file with mode: 0644]
doc/sample_client.xml [new file with mode: 0644]
doc/sample_client_ui.xml [new file with mode: 0644]
include/account/account.h [new file with mode: 0755]
include/account/manager.h [new file with mode: 0755]
include/account/service.h [new file with mode: 0755]
include/data-adapter/agent_handler_manager.h [new file with mode: 0755]
include/data-adapter/agent_manager.h [new file with mode: 0755]
include/data-adapter/common.h [new file with mode: 0755]
include/data-adapter/converter.h [new file with mode: 0755]
include/data-adapter/data_adapter.h [new file with mode: 0755]
include/data-adapter/error.h [new file with mode: 0755]
include/data-adapter/interface_changelog.h [new file with mode: 0755]
include/data-adapter/interface_config.h [new file with mode: 0755]
include/data-adapter/interface_folder.h [new file with mode: 0755]
include/data-adapter/interface_item.h [new file with mode: 0755]
include/data-adapter/interface_last_anchor.h [new file with mode: 0755]
include/data-adapter/interface_mapping.h [new file with mode: 0755]
include/data-adapter/interface_service_item.h [new file with mode: 0755]
include/data-adapter/luid.h [new file with mode: 0755]
include/device-manager/device_manager.h [new file with mode: 0755]
include/device-manager/interface.h [new file with mode: 0755]
include/device-manager/mdm_control_code.h [new file with mode: 0755]
include/device-manager/mdm_error.h [new file with mode: 0755]
include/device-manager/mdm_type.h [new file with mode: 0755]
include/device-manager/mo_accessor.h [new file with mode: 0755]
include/device-manager/mo_error.h [new file with mode: 0755]
include/device-manager/mo_executor.h [new file with mode: 0755]
include/device-manager/mo_struct.h [new file with mode: 0755]
include/device/common.h [new file with mode: 0755]
include/device/device.h [new file with mode: 0755]
include/device/error.h [new file with mode: 0755]
include/device/executor.h [new file with mode: 0755]
include/device/information.h [new file with mode: 0755]
include/engine-controller/define.h [new file with mode: 0755]
include/engine-controller/engine_controller.h [new file with mode: 0755]
include/engine-controller/fundamental_type.h [new file with mode: 0755]
include/engine-controller/interface.h [new file with mode: 0755]
include/engine-controller/param.h [new file with mode: 0755]
include/engine-controller/param_spec.h [new file with mode: 0755]
include/engine-controller/param_value.h [new file with mode: 0755]
include/engine-controller/queuing_rule_spec.h [new file with mode: 0755]
include/engine-controller/task_error.h [new file with mode: 0755]
include/engine-controller/task_process.h [new file with mode: 0755]
include/engine-controller/task_spec.h [new file with mode: 0755]
include/event/data_accessor.h [new file with mode: 0755]
include/event/error.h [new file with mode: 0755]
include/event/event.h [new file with mode: 0755]
include/event/handler.h [new file with mode: 0755]
include/event/oma_dm_admin_api.h [new file with mode: 0755]
include/event/oma_dm_alert_api.h [new file with mode: 0755]
include/event/oma_dm_api_common.h [new file with mode: 0755]
include/event/oma_dm_cp_api.h [new file with mode: 0755]
include/event/oma_dm_dmacc_control_api.h [new file with mode: 0755]
include/event/oma_dm_fota_api.h [new file with mode: 0755]
include/event/oma_dm_noti_api.h [new file with mode: 0755]
include/event/oma_dm_registration_api.h [new file with mode: 0755]
include/event/oma_ds_api.h [new file with mode: 0755]
include/event/ui_api.h [new file with mode: 0755]
include/fsapi/fsapi.h [new file with mode: 0755]
include/fsapi/operation.h [new file with mode: 0755]
include/initialization/error.h [new file with mode: 0755]
include/initialization/initialization.h [new file with mode: 0755]
include/initialization/interface.h [new file with mode: 0755]
include/network-access/common.h [new file with mode: 0755]
include/network-access/error.h [new file with mode: 0755]
include/network-access/external.h [new file with mode: 0755]
include/network-access/interface.h [new file with mode: 0755]
include/network-access/network_access.h [new file with mode: 0755]
include/network-access/network_status.h [new file with mode: 0755]
include/network-access/property.h [new file with mode: 0755]
include/network-access/status.h [new file with mode: 0755]
include/platform-monitor/common.h [new file with mode: 0755]
include/platform-monitor/error.h [new file with mode: 0755]
include/platform-monitor/interface.h [new file with mode: 0755]
include/platform-monitor/platform_monitor.h [new file with mode: 0755]
include/plugin/account_interface.h [new file with mode: 0755]
include/plugin/data_connector_interface.h [new file with mode: 0755]
include/plugin/data_connector_resource.h [new file with mode: 0755]
include/plugin/data_converter_interface.h [new file with mode: 0755]
include/plugin/data_converter_resource.h [new file with mode: 0755]
include/plugin/device_info_interface.h [new file with mode: 0755]
include/plugin/device_manager_interface.h [new file with mode: 0755]
include/plugin/mo_interface.h [new file with mode: 0755]
include/plugin/network_access_interface.h [new file with mode: 0755]
include/plugin/platform_monitor_interface.h [new file with mode: 0755]
include/plugin/platform_monitor_resource.h [new file with mode: 0755]
include/plugin/plugin_interface.h [new file with mode: 0755]
include/protocol-binder/common.h [new file with mode: 0755]
include/protocol-binder/definition.h [new file with mode: 0755]
include/protocol-binder/error.h [new file with mode: 0755]
include/protocol-binder/interface.h [new file with mode: 0755]
include/protocol-binder/protocol_binder.h [new file with mode: 0755]
include/protocol-binder/util.h [new file with mode: 0755]
include/security-assistant/encryption_decryption.h [new file with mode: 0755]
include/security-assistant/security_assistant.h [new file with mode: 0755]
include/sync_agent.h [new file with mode: 0755]
include/utility/fw_assert.h [new file with mode: 0755]
include/utility/fw_async_queue.h [new file with mode: 0755]
include/utility/fw_compress.h [new file with mode: 0755]
include/utility/fw_file.h [new file with mode: 0755]
include/utility/fw_mainloop.h [new file with mode: 0755]
include/utility/fw_ref.h [new file with mode: 0755]
include/utility/fw_time.h [new file with mode: 0755]
include/utility/sync_util.h [new file with mode: 0755]
include/utility/utility.h [new file with mode: 0755]
packaging/sync-agent.spec [new file with mode: 0755]
src/framework/CMakeLists.txt [new file with mode: 0644]
src/framework/account/manager.c [new file with mode: 0755]
src/framework/account/service.c [new file with mode: 0755]
src/framework/account/util.c [new file with mode: 0755]
src/framework/account/util_internal.h [new file with mode: 0755]
src/framework/data-adapter/agent.c [new file with mode: 0755]
src/framework/data-adapter/agent.h [new file with mode: 0755]
src/framework/data-adapter/agent_handler_manager.c [new file with mode: 0755]
src/framework/data-adapter/agent_handler_manager_internal.h [new file with mode: 0755]
src/framework/data-adapter/agent_manager.c [new file with mode: 0755]
src/framework/data-adapter/agent_manager_internal.h [new file with mode: 0755]
src/framework/data-adapter/changelog.c [new file with mode: 0755]
src/framework/data-adapter/changelog.h [new file with mode: 0755]
src/framework/data-adapter/changelog_internal.h [new file with mode: 0755]
src/framework/data-adapter/common.c [new file with mode: 0755]
src/framework/data-adapter/common_internal.h [new file with mode: 0755]
src/framework/data-adapter/converter.c [new file with mode: 0755]
src/framework/data-adapter/interface_changelog.c [new file with mode: 0755]
src/framework/data-adapter/interface_config.c [new file with mode: 0755]
src/framework/data-adapter/interface_folder.c [new file with mode: 0755]
src/framework/data-adapter/interface_item.c [new file with mode: 0755]
src/framework/data-adapter/interface_last_anchor.c [new file with mode: 0755]
src/framework/data-adapter/interface_mapping.c [new file with mode: 0755]
src/framework/data-adapter/interface_service_item.c [new file with mode: 0755]
src/framework/data-adapter/luid.c [new file with mode: 0755]
src/framework/data-adapter/service.c [new file with mode: 0755]
src/framework/data-adapter/service_internal.h [new file with mode: 0755]
src/framework/device-manager/interface.c [new file with mode: 0755]
src/framework/device-manager/interface_internal.h [new file with mode: 0755]
src/framework/device-manager/mo_accessor.c [new file with mode: 0755]
src/framework/device-manager/mo_accessor_internal.h [new file with mode: 0755]
src/framework/device-manager/mo_database.c [new file with mode: 0755]
src/framework/device-manager/mo_database.h [new file with mode: 0755]
src/framework/device-manager/mo_database_handler.c [new file with mode: 0755]
src/framework/device-manager/mo_database_handler.h [new file with mode: 0755]
src/framework/device-manager/mo_ddf_parser.c [new file with mode: 0755]
src/framework/device-manager/mo_ddf_parser.h [new file with mode: 0755]
src/framework/device-manager/mo_executor.c [new file with mode: 0755]
src/framework/device-manager/mo_parser_properties.c [new file with mode: 0755]
src/framework/device-manager/mo_parser_properties.h [new file with mode: 0755]
src/framework/device-manager/mo_tnds_processor.c [new file with mode: 0755]
src/framework/device-manager/mo_tnds_processor.h [new file with mode: 0755]
src/framework/device/executor.c [new file with mode: 0755]
src/framework/device/information.c [new file with mode: 0755]
src/framework/device/information_internal.h [new file with mode: 0755]
src/framework/engine-controller/graph_edge_pool.c [new file with mode: 0755]
src/framework/engine-controller/graph_edge_pool.h [new file with mode: 0755]
src/framework/engine-controller/hash_set.c [new file with mode: 0755]
src/framework/engine-controller/hash_set.h [new file with mode: 0755]
src/framework/engine-controller/interface.c [new file with mode: 0755]
src/framework/engine-controller/interface_internal.h [new file with mode: 0755]
src/framework/engine-controller/internal.h [new file with mode: 0755]
src/framework/engine-controller/message.c [new file with mode: 0755]
src/framework/engine-controller/message.h [new file with mode: 0755]
src/framework/engine-controller/param.c [new file with mode: 0755]
src/framework/engine-controller/param_internal.h [new file with mode: 0755]
src/framework/engine-controller/param_spec.c [new file with mode: 0755]
src/framework/engine-controller/param_spec_internal.h [new file with mode: 0755]
src/framework/engine-controller/param_value.c [new file with mode: 0755]
src/framework/engine-controller/param_value_internal.h [new file with mode: 0755]
src/framework/engine-controller/queuing_rule_spec.c [new file with mode: 0755]
src/framework/engine-controller/queuing_rule_spec_internal.h [new file with mode: 0755]
src/framework/engine-controller/queuing_rule_spec_pool.c [new file with mode: 0755]
src/framework/engine-controller/queuing_rule_spec_pool.h [new file with mode: 0755]
src/framework/engine-controller/task.c [new file with mode: 0755]
src/framework/engine-controller/task.h [new file with mode: 0755]
src/framework/engine-controller/task_cancel_info.c [new file with mode: 0755]
src/framework/engine-controller/task_cancel_info.h [new file with mode: 0755]
src/framework/engine-controller/task_error.c [new file with mode: 0755]
src/framework/engine-controller/task_error_internal.h [new file with mode: 0755]
src/framework/engine-controller/task_info_pool.c [new file with mode: 0755]
src/framework/engine-controller/task_info_pool.h [new file with mode: 0755]
src/framework/engine-controller/task_message.c [new file with mode: 0755]
src/framework/engine-controller/task_message.h [new file with mode: 0755]
src/framework/engine-controller/task_pool.c [new file with mode: 0755]
src/framework/engine-controller/task_pool.h [new file with mode: 0755]
src/framework/engine-controller/task_process.c [new file with mode: 0755]
src/framework/engine-controller/task_spec.c [new file with mode: 0755]
src/framework/engine-controller/task_spec_internal.h [new file with mode: 0755]
src/framework/engine-controller/thread_pool.c [new file with mode: 0755]
src/framework/engine-controller/thread_pool.h [new file with mode: 0755]
src/framework/event/config.c [new file with mode: 0755]
src/framework/event/config.h [new file with mode: 0755]
src/framework/event/data_accessor.c [new file with mode: 0755]
src/framework/event/data_accessor_internal.h [new file with mode: 0755]
src/framework/event/handler.c [new file with mode: 0755]
src/framework/event/oma_dm_admin_api.c [new file with mode: 0755]
src/framework/event/oma_dm_alert_api.c [new file with mode: 0755]
src/framework/event/oma_dm_api_common_internal.h [new file with mode: 0755]
src/framework/event/oma_dm_cp_api.c [new file with mode: 0755]
src/framework/event/oma_dm_dmacc_control_api.c [new file with mode: 0755]
src/framework/event/oma_dm_fota_api.c [new file with mode: 0755]
src/framework/event/oma_dm_noti_api.c [new file with mode: 0755]
src/framework/event/oma_dm_registration_api.c [new file with mode: 0755]
src/framework/event/oma_ds_api.c [new file with mode: 0755]
src/framework/event/spec.h [new file with mode: 0755]
src/framework/event/ui_api.c [new file with mode: 0755]
src/framework/event/util.c [new file with mode: 0755]
src/framework/event/util.h [new file with mode: 0755]
src/framework/fsapi/operation.c [new file with mode: 0755]
src/framework/fsapi/operation_internal.h [new file with mode: 0755]
src/framework/fsapi/util.c [new file with mode: 0755]
src/framework/fsapi/util.h [new file with mode: 0755]
src/framework/initialization/interface.c [new file with mode: 0755]
src/framework/initialization/parser.c [new file with mode: 0755]
src/framework/initialization/parser.h [new file with mode: 0755]
src/framework/network-access/callbacks.c [new file with mode: 0755]
src/framework/network-access/callbacks.h [new file with mode: 0755]
src/framework/network-access/interface.c [new file with mode: 0755]
src/framework/network-access/interface_internal.h [new file with mode: 0755]
src/framework/network-access/session_manager.c [new file with mode: 0755]
src/framework/network-access/session_manager.h [new file with mode: 0755]
src/framework/platform-monitor/interface.c [new file with mode: 0755]
src/framework/plugin/account_plugin.c [new file with mode: 0755]
src/framework/plugin/account_plugin.h [new file with mode: 0755]
src/framework/plugin/data_connector_plugin.c [new file with mode: 0755]
src/framework/plugin/data_connector_plugin.h [new file with mode: 0755]
src/framework/plugin/data_converter_plugin.c [new file with mode: 0755]
src/framework/plugin/data_converter_plugin.h [new file with mode: 0755]
src/framework/plugin/device_info_plugin.c [new file with mode: 0755]
src/framework/plugin/device_info_plugin.h [new file with mode: 0755]
src/framework/plugin/device_manager_plugin.c [new file with mode: 0755]
src/framework/plugin/device_manager_plugin.h [new file with mode: 0755]
src/framework/plugin/error.h [new file with mode: 0755]
src/framework/plugin/manager.c [new file with mode: 0755]
src/framework/plugin/manager.h [new file with mode: 0755]
src/framework/plugin/mo_plugin.c [new file with mode: 0755]
src/framework/plugin/mo_plugin.h [new file with mode: 0755]
src/framework/plugin/network_access_plugin.c [new file with mode: 0755]
src/framework/plugin/network_access_plugin.h [new file with mode: 0755]
src/framework/plugin/platform_monitor_plugin.c [new file with mode: 0755]
src/framework/plugin/platform_monitor_plugin.h [new file with mode: 0755]
src/framework/plugin/struct.h [new file with mode: 0755]
src/framework/protocol-binder/interface.c [new file with mode: 0755]
src/framework/protocol-binder/interface_internal.h [new file with mode: 0755]
src/framework/protocol-binder/internal.h [new file with mode: 0755]
src/framework/protocol-binder/util.c [new file with mode: 0755]
src/framework/protocol-binder/util_internal.h [new file with mode: 0755]
src/framework/security-assistant/cryptograhic_hash_function.c [new file with mode: 0755]
src/framework/security-assistant/cryptograhic_hash_function.h [new file with mode: 0755]
src/framework/security-assistant/encryption_decryption.c [new file with mode: 0755]
src/framework/security-assistant/encryption_decryption_internal.h [new file with mode: 0755]
src/framework/security-assistant/md5.c [new file with mode: 0755]
src/framework/security-assistant/md5.h [new file with mode: 0755]
src/framework/sync-agent.pc.in [new file with mode: 0644]
src/framework/test/include/suites/unit_test_fw_alloc_suite.h [new file with mode: 0755]
src/framework/test/include/suites/unit_test_fw_log_suite.h [new file with mode: 0755]
src/framework/test/include/suites/unit_test_fw_sequential_id_provider_suite.h [new file with mode: 0755]
src/framework/test/include/suites/unit_test_protocol_binder_suite.h [new file with mode: 0755]
src/framework/test/include/suites/unit_test_sample_suite.h [new file with mode: 0755]
src/framework/test/include/unit_test_common.h [new file with mode: 0755]
src/framework/test/include/unit_test_run.h [new file with mode: 0755]
src/framework/test/include/unit_test_suites.h [new file with mode: 0755]
src/framework/test/src/fw_test_main.c [new file with mode: 0755]
src/framework/test/src/suites/unit_test_fw_alloc_suite.c [new file with mode: 0755]
src/framework/test/src/suites/unit_test_fw_log_suite.c [new file with mode: 0755]
src/framework/test/src/suites/unit_test_fw_sequential_id_provider_suite.c [new file with mode: 0755]
src/framework/test/src/suites/unit_test_protocol_binder.c [new file with mode: 0755]
src/framework/test/src/suites/unit_test_sample_suite.c [new file with mode: 0755]
src/framework/test/src/unit_test_run.c [new file with mode: 0755]
src/framework/utility/fw_alloc.c [new file with mode: 0755]
src/framework/utility/fw_alloc.h [new file with mode: 0755]
src/framework/utility/fw_alloc_internal.h [new file with mode: 0755]
src/framework/utility/fw_async_queue.c [new file with mode: 0755]
src/framework/utility/fw_async_queue_internal.h [new file with mode: 0755]
src/framework/utility/fw_cache.c [new file with mode: 0755]
src/framework/utility/fw_cache.h [new file with mode: 0755]
src/framework/utility/fw_common.h [new file with mode: 0755]
src/framework/utility/fw_compress.c [new file with mode: 0755]
src/framework/utility/fw_file.c [new file with mode: 0755]
src/framework/utility/fw_list.c [new file with mode: 0755]
src/framework/utility/fw_list.h [new file with mode: 0755]
src/framework/utility/fw_log.c [new file with mode: 0755]
src/framework/utility/fw_log.h [new file with mode: 0755]
src/framework/utility/fw_mainloop.c [new file with mode: 0755]
src/framework/utility/fw_mainloop_internal.h [new file with mode: 0755]
src/framework/utility/fw_ref.c [new file with mode: 0755]
src/framework/utility/fw_sequential_id_provider.c [new file with mode: 0755]
src/framework/utility/fw_sequential_id_provider.h [new file with mode: 0755]
src/framework/utility/fw_sequential_id_provider_internal.h [new file with mode: 0755]
src/framework/utility/fw_thread.c [new file with mode: 0755]
src/framework/utility/fw_thread.h [new file with mode: 0755]
src/framework/utility/fw_time.c [new file with mode: 0755]
src/framework/utility/fw_timer.c [new file with mode: 0755]
src/framework/utility/fw_timer.h [new file with mode: 0755]
src/framework/utility/sync_util.c [new file with mode: 0755]
src/fw-plugins/CMakeLists.sub [new file with mode: 0644]
src/fw-plugins/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-private/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/account/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/account/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/calendar/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/calendar/include/ext_datastore_info_calendar.h [new file with mode: 0755]
src/fw-plugins/common-public/calendar/include/extern_info.h [new file with mode: 0755]
src/fw-plugins/common-public/calendar/include/in_datastore_info_calendar.h [new file with mode: 0755]
src/fw-plugins/common-public/calendar/include/item_change_info.h [new file with mode: 0755]
src/fw-plugins/common-public/calendar/src/item_change_info.c [new file with mode: 0755]
src/fw-plugins/common-public/calendar/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/call-log/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/call-log/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/contact/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/contact/include/ext_datastore_info_contact.h [new file with mode: 0755]
src/fw-plugins/common-public/contact/include/extern_info.h [new file with mode: 0755]
src/fw-plugins/common-public/contact/include/in_datastore_info_contact.h [new file with mode: 0755]
src/fw-plugins/common-public/contact/include/item_change_info.h [new file with mode: 0755]
src/fw-plugins/common-public/contact/src/item_change_info.c [new file with mode: 0755]
src/fw-plugins/common-public/contact/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/http/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/http/include/http_status.h [new file with mode: 0755]
src/fw-plugins/common-public/http/include/na_external.h [new file with mode: 0755]
src/fw-plugins/common-public/http/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/memo/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/memo/include/extern_info.h [new file with mode: 0755]
src/fw-plugins/common-public/memo/include/item_change_info.h [new file with mode: 0755]
src/fw-plugins/common-public/memo/src/item_change_info.c [new file with mode: 0755]
src/fw-plugins/common-public/memo/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/include/plugin_slp_device.h [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/include/slp_device_info.h [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/src/plugin_interface_devexe.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/src/plugin_interface_devinfo.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-device/src/slp_device_info.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-alarm/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-alarm/include/plugin_slp_sysnoti_alarm.h [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-alarm/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-network-connection/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-network-connection/include/plugin_slp_sysnoti_network_connection.h [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-network-connection/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-wap-push/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-wap-push/include/plugin_slp_sysnoti_wap_push.h [new file with mode: 0755]
src/fw-plugins/common-public/slp-sysnoti-wap-push/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/vcalendar/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/vcalendar/include/encoding_util.h [new file with mode: 0755]
src/fw-plugins/common-public/vcalendar/include/in_datastore_info_vcalendar.h [new file with mode: 0755]
src/fw-plugins/common-public/vcalendar/src/encoding_util.c [new file with mode: 0755]
src/fw-plugins/common-public/vcalendar/src/plugin_interface.c [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/CMakeLists.txt [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-errors.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-provider.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-struct.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/include/cals-internal.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.c [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-ical-utils.c [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-ical.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-provider.c [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-typedef.h [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-utils.c [new file with mode: 0755]
src/fw-plugins/common-public/vobject-tizen/src/cals-utils.h [new file with mode: 0755]
sync-agent.manifest [new file with mode: 0644]
test/client/dummy/dummy_client.c [new file with mode: 0755]
test/client/dummy/makefile [new file with mode: 0644]
test/client/oma-dm/makefile [new file with mode: 0644]
test/client/oma-dm/oma_dm_client.c [new file with mode: 0755]
test/client/oma-ds/makefile [new file with mode: 0644]
test/client/oma-ds/oma_ds_client.c [new file with mode: 0755]
test/dummy_project/BuildFlags.cmake [new file with mode: 0644]
test/dummy_project/CMakeLists.txt [new file with mode: 0644]
test/dummy_project/debian/changelog [new file with mode: 0644]
test/dummy_project/dummy-agent.manifest [new file with mode: 0644]
test/dummy_project/dummy-cfg/dummy_client_fw_config.xml [new file with mode: 0644]
test/dummy_project/dummy-cfg/dummy_fw_config.xml [new file with mode: 0644]
test/dummy_project/dummy-cfg/eventconfig_dummy [new file with mode: 0644]
test/dummy_project/dummy-cfg/noticonfig_dummy [new file with mode: 0644]
test/dummy_project/dummy-plugins.manifest [new file with mode: 0644]
test/dummy_project/packaging/dummy-agent.spec [new file with mode: 0755]
test/dummy_project/src/agent/CMakeLists.txt [new file with mode: 0644]
test/dummy_project/src/agent/main/main.c [new file with mode: 0755]
test/dummy_project/src/plugins/CMakeLists.sub [new file with mode: 0644]
test/dummy_project/src/plugins/CMakeLists.txt [new file with mode: 0644]
test/dummy_project/src/plugins/dummy/CMakeLists.txt [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/da-dummy/CMakeLists.txt [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/da-dummy/src/plugin_interface.c [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/di-dummy/CMakeLists.txt [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devexe.c [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devinfo.c [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/pm-dummy/CMakeLists.txt [new file with mode: 0755]
test/dummy_project/src/plugins/dummy/pm-dummy/src/plugin_interface.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100755 (executable)
index 0000000..b5328d5
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+WooJin Yun <suhoangel9 at samsung dot com>\r
+JooHark Park <juhaki.park at samsung dot com>\r
+SangHyuk Ko <sanghyuk.ko at samsung dot com>   \r
+JunHyung Park <jruss.park at samsung dot com>\r
diff --git a/BuildFlags.cmake b/BuildFlags.cmake
new file mode 100644 (file)
index 0000000..70c7b2d
--- /dev/null
@@ -0,0 +1,32 @@
+# Set default build flags
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF()
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Werror -Wno-deprecated-declarations -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
+
+MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+MESSAGE(STATUS "Compile flags: ${CMAKE_C_FLAGS}")
+MESSAGE(STATUS "Exe linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
+MESSAGE(STATUS "Module linker flags: ${CMAKE_MODULE_LINKER_FLAGS}")
+MESSAGE(STATUS "Shared linker flags: ${CMAKE_SHARED_LINKER_FLAGS}")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+       ADD_DEFINITIONS("-DDEBUG")
+ENDIF()
+
+MACRO(get_version _file _ver _ver_maj)
+       FILE(STRINGS ${_file} __log LIMIT_COUNT 1 REGEX "(.*)")
+       STRING(REGEX REPLACE ".*\\(\([0-9]+:\)*\([0-9a-zA-Z.]*\).*\\).*" "\\2" __ver ${__log})
+       STRING(REGEX REPLACE "^\([0-9]+\)\\..*" "\\1" __ver_maj ${__ver})
+       SET(${_ver} ${__ver})
+       SET(${_ver_maj} ${__ver_maj})
+ENDMACRO(get_version)
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cb5028e
--- /dev/null
@@ -0,0 +1,27 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+INCLUDE(BuildFlags.cmake)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(PLUGINDIR "${PREFIX}/lib/${PROJECT_NAME}")
+
+# get library version from debian/changelog
+get_version(debian/changelog VERSION VERSION_MAJOR)
+MESSAGE(STATUS "Package version is ${VERSION} (major: ${VERSION_MAJOR}) from changelog")
+
+# pass macro defition to source files
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPLUGINDIR=\"${PLUGINDIR}\"")
+
+# log tag integration
+ADD_DEFINITIONS("-DCOMPONENT_TAG=SYSTEM")
+ADD_DEFINITIONS("-DSYNC_AGENT_LOG")
+ADD_DEFINITIONS("-DLOG_TAG=\"SYNC_AGENT\"")
+
+# include source files
+ADD_SUBDIRECTORY(src/framework)
+ADD_SUBDIRECTORY(src/fw-plugins)
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755 (executable)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100755 (executable)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/TC/.gitignore b/TC/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/TC/_export_env.sh b/TC/_export_env.sh
new file mode 100644 (file)
index 0000000..72a11ec
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh
new file mode 100644 (file)
index 0000000..5ddaa53
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./config
+export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..6be8d56
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+. ./_export_env.sh                              # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
\ No newline at end of file
diff --git a/TC/clean.sh b/TC/clean.sh
new file mode 100755 (executable)
index 0000000..3eec83a
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. ./_export_env.sh                              # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./                                # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
+
+cd testcase
+make clean
\ No newline at end of file
diff --git a/TC/config b/TC/config
new file mode 100644 (file)
index 0000000..d0fff6b
--- /dev/null
+++ b/TC/config
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/home/abuild/test/tetware/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/tetware/TETware
diff --git a/TC/config.default b/TC/config.default
new file mode 100644 (file)
index 0000000..48acda6
--- /dev/null
@@ -0,0 +1,2 @@
+TET_INSTALL_HOST_PATH=/tetware/TETware
+TET_INSTALL_TARGET_PATH=/mnt/nfs/obs/srcs/tetware/TETware
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..215ad6c
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+. ./_export_target_env.sh                    # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+#grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
+
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
new file mode 100644 (file)
index 0000000..f9bee34
--- /dev/null
@@ -0,0 +1,25 @@
+CC ?= gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = libwbxml2 sync-agent dlog glib-2.0
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+#TARGETS = $(C_FILES:%.c=tc-%)
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TCS)
diff --git a/TC/testcase/fw-test-cfg/eventconfig_fw_test b/TC/testcase/fw-test-cfg/eventconfig_fw_test
new file mode 100644 (file)
index 0000000..a09df94
--- /dev/null
@@ -0,0 +1 @@
+1, 1, 0, 30, FW_TEST_EVENT
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/eventconfig_fw_test_omadm b/TC/testcase/fw-test-cfg/eventconfig_fw_test_omadm
new file mode 100644 (file)
index 0000000..17284ff
--- /dev/null
@@ -0,0 +1,15 @@
+1, 1, 0, 30, EVENT_SOFTWARE_UPDATE
+2, 1, 0, 30, EVENT_CANCEL
+3, 1, 0, 30, EVENT_DOWNLOAD
+4, 1, 0, 30, EVENT_INSTALL
+5, 1, 0, 30, EVENT_SET_INTERVAL
+6, 1, 0, 30, EVENT_ACCOUNT_REGISTRATION
+7, 1, 0, 30, EVENT_GET_FUMO_CONFIG
+8, 1, 0, 30, EVENT_SET_FUMO_CONFIG
+9, 1, 0, 30, EVENT_GET_PROFILE
+10, 1, 0, 30, EVENT_SET_PROFILE
+11, 1, 0, 30, EVENT_RESET_PROFILE
+12, 1, 0, 30, EVENT_UIC_ALERT
+13, 1, 0, 30, EVENT_CHECK_PIN_CODE
+14, 1, 0, 30, EVENT_ADD_DMACC
+15, 1, 0, 30,  EVENT_REMOVE_DMACC 
diff --git a/TC/testcase/fw-test-cfg/eventconfig_fw_test_omads b/TC/testcase/fw-test-cfg/eventconfig_fw_test_omads
new file mode 100644 (file)
index 0000000..f8988c5
--- /dev/null
@@ -0,0 +1,12 @@
+1, 1, 0, 30, addprofile
+2, 1, 0, 30, editprofile
+3, 1, 0, 30, deleteprofile
+4, 1, 0, 30, requestsync
+5, 1, 0, 30, cancelsync
+6, 1, 0, 30, getprofiledata
+7, 1, 0, 30, getprofilesynccategory
+8, 1, 0, 30, getprofilestatistics
+9, 1, 0, 30, getprofilesdata
+10, 1, 0, 30, addprofilecp
+11, 1, 0, 30, requestcalllogsync
+12, 1, 0, 30, resetalldata
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/noticonfig_fw_test b/TC/testcase/fw-test-cfg/noticonfig_fw_test
new file mode 100644 (file)
index 0000000..d53fc20
--- /dev/null
@@ -0,0 +1 @@
+1, 0, 0, 30, FW_TEST_NOTI
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/noticonfig_fw_test_omadm b/TC/testcase/fw-test-cfg/noticonfig_fw_test_omadm
new file mode 100644 (file)
index 0000000..e18abf2
--- /dev/null
@@ -0,0 +1,14 @@
+1, 0, 3, 30, NOTI_DOWNLOAD
+2, 0, 3, 30, NOTI_INSTALL
+3, 0, 0, 30, NOTI_DOWNLOAD_INFO
+4, 0, 3, 30, NOTI_ENGINE_START
+5, 0, 0, 30, NOTI_ENGINE_FAIL
+6, 0, 0, 30, NOTI_WIFI_ONLY_DOWNLOAD_FAIL
+7, 0, 0, 30, NOTI_MEMORY_FULL
+8, 0, 3, 30, NOTI_OVER_BIG_SIZE
+9, 0, 0, 30, NOTI_LOW_BATTERY
+10, 0, 3, 30, NOTI_ALERT_DISPLAY
+11, 0, 3, 30, NOTI_ALERT_CONFIRMATION
+12, 0, 3, 30, NOTI_ALERT_INPUTEXT
+13, 0, 3, 30, NOTI_ALERT_SINGLE_CHOICE
+14, 0, 3, 30, NOTI_ALERT_MULTIPLE_CHOICE
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/noticonfig_fw_test_omads b/TC/testcase/fw-test-cfg/noticonfig_fw_test_omads
new file mode 100644 (file)
index 0000000..389f69f
--- /dev/null
@@ -0,0 +1,2 @@
+1, 0, 0, 30, sessionprocess
+2, 0, 0, 30, processupdate
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/test_fw_config.xml b/TC/testcase/fw-test-cfg/test_fw_config.xml
new file mode 100644 (file)
index 0000000..1045bad
--- /dev/null
@@ -0,0 +1,175 @@
+<?xml  version="1.0" encoding="UTF-8" ?>\r
+<INIT>\r
+       <Agent-Key>fw_test</Agent-Key>\r
+       <MainLoop>1</MainLoop> \r
+       <Event>\r
+               <Event-Key>fw_test_event</Event-Key>\r
+               <Event-Config>../../../testcase/fw-test-cfg/eventconfig_fw_test</Event-Config>\r
+               <RunEventHandler>1</RunEventHandler>\r
+       </Event>\r
+       <Noti>\r
+               <Noti-Key>fw_test_noti</Noti-Key>\r
+               <Noti-Config>../../../testcase/fw-test-cfg/noticonfig_fw_test</Noti-Config>\r
+       </Noti>\r
+       <EngineController>\r
+               <Max-Thread>5</Max-Thread>\r
+       </EngineController>\r
+       <FrameworkDB use="1">\r
+               <Path>/opt/dbspace/.fw_test.db</Path>\r
+       </FrameworkDB>\r
+       <ID-Provider>\r
+               <Code>1</Code>\r
+               <MaxID>4000000000</MaxID>\r
+               <PageSize>5</PageSize>\r
+       </ID-Provider>\r
+       <PlugIn-Mgr>\r
+               <Domain name="Account" count="1">       \r
+                       <Plug-In>\r
+                               <ID>1</ID>      \r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-account.so</Path>     \r
+                               <Description>SLP Account Accessor</Description>         \r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="DataConnector" count="1">\r
+                       <Plug-In>\r
+                               <ID>0</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-da-calendar.so</Path>\r
+                               <Description>SLP Calendar Access PlugIn</Description>\r
+                               <DataConverter-PlugIn>1</DataConverter-PlugIn>          \r
+                               <Handle-ChangeNoti>1</Handle-ChangeNoti>        \r
+                               <Use-MainLoop>1</Use-MainLoop>          \r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/kies-private/libplugin-da-sms.so</Path>\r
+                               <Description>SLP SMS Access PlugIn</Description>\r
+                               <DataConverter-PlugIn>2</DataConverter-PlugIn>\r
+                               <Handle-ChangeNoti>1</Handle-ChangeNoti>\r
+                               <Use-MainLoop>1</Use-MainLoop>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>2</ID>\r
+                               <Path>/usr/lib/sync-agent/kies-private/libplugin-da-bookmark.so</Path>\r
+                               <Description>SLP Bookmark Access PlugIn</Description>\r
+                               <DataConverter-PlugIn>0</DataConverter-PlugIn>\r
+                               <Handle-ChangeNoti>0</Handle-ChangeNoti>\r
+                               <Use-MainLoop>0</Use-MainLoop>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="DataConverter" count="1">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-dc-vcalendar.so</Path>\r
+                               <Description>SLP Calendar Converter</Description>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>2</ID>\r
+                               <Path>/usr/lib/sync-agent/kies-private/libplugin-dc-msg.so</Path>\r
+                               <Description>SLP SMS Converter</Description>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="NetworkAccess" count="1">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-na-http.so</Path>\r
+                               <Description>Http Protocol</Description>\r
+                               <UseNetwork>1</UseNetwork>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="DeviceInfo" count="2">    \r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-di-slp-device.so</Path>\r
+                               <Description>SLP Device Accessor</Description>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>2</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-di-slp-device-dm.so</Path>\r
+                               <Description>SLP Device Accessor for DM</Description>\r
+                               <DependsOn>1</DependsOn>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="MO">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-public/libplugin-mo-devdetail.so</Path>\r
+                               <Description>about device detail information</Description>\r
+                               <Type>DEVDETAIL</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>2</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-public/libplugin-mo-devinfo.so</Path>\r
+                               <Description>about device information</Description>\r
+                               <Type>DEVINFO</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>3</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-fumo.so</Path>\r
+                               <Description>Firmware Update</Description>\r
+                               <Type>FUMO</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>4</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-dmacc-gcf.so</Path>\r
+                               <Description>gcf Server</Description>\r
+                               <Type>DMACC</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>5</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-dmacc-mscserver.so</Path>\r
+                               <Description>MSCServer</Description>\r
+                               <Type>DMACC</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>6</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-dmacc-msctestserver.so</Path>\r
+                               <Description>MSCTestServer</Description>\r
+                               <Type>DMACC</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>7</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-lawmo.so</Path>\r
+                               <Description>Lock and Wipe</Description>\r
+                               <Type>LAWMO</Type>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>8</ID>\r
+                               <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-multiapps.so</Path>\r
+                               <Description>Multiple Applications</Description>\r
+                               <Type>MULTIAPPS</Type>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="PlatformMonitor" count="1">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-pm-slp-sysnoti-alarm.so</Path>\r
+                               <Description>monitoring Alarm Event from SLP Platform</Description>\r
+                               <Use-MainLoop>0</Use-MainLoop>\r
+                               <Register-Data count="1">\r
+                                       <Data>          \r
+                                               <Pkg-Name>fw-test-agent</Pkg-Name>\r
+                                               <Additional-Data>-</Additional-Data>\r
+                                       </Data>\r
+                               </Register-Data>\r
+                       </Plug-In>\r
+                       <Plug-In>\r
+                               <ID>2</ID>\r
+                               <Path>/usr/lib/sync-agent/common-public/libplugin-pm-slp-sysnoti-network-connection.so</Path>\r
+                               <Description>monitoring Network Connection Event from SLP Platform</Description>\r
+                               <Use-MainLoop>0</Use-MainLoop>\r
+                               <Register-Data count="0">-</Register-Data>\r
+                       </Plug-In>                      \r
+               </Domain>\r
+               <Domain name="DeviceManager" count="1">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/common-private/libplugin-mdm-slp-device.so</Path>\r
+                               <Description>SLP Mobile Device Manager</Description>\r
+                       </Plug-In>\r
+               </Domain>\r
+       </PlugIn-Mgr>\r
+       <DeviceManage>\r
+               <MO-DB-Path>/opt/dbspace/.mo_test.db</MO-DB-Path>\r
+               <DependentDevInfoID>2</DependentDevInfoID>\r
+       </DeviceManage>\r
+</INIT>\r
diff --git a/TC/testcase/fw-test-cfg/test_fw_config_omadm.xml b/TC/testcase/fw-test-cfg/test_fw_config_omadm.xml
new file mode 100644 (file)
index 0000000..525fb37
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml  version="1.0" encoding="UTF-8" ?>
+<INIT>
+       <Agent-Key>fw_test_omadm</Agent-Key>
+       <Event>
+               <Event-Key>omadm</Event-Key>
+               <Event-Config>../../../testcase/fw-test-cfg/eventconfig_fw_test_omadm</Event-Config>
+               <RunEventHandler>1</RunEventHandler>
+       </Event>
+       <Noti>
+               <Noti-Key>omadm_fota_ui</Noti-Key>
+               <Noti-Config>../../../testcase/fw-test-cfg/noticonfig_fw_test_omadm</Noti-Config>
+       </Noti>
+       <Noti>
+               <Noti-Key>omadm_noti_ui</Noti-Key>
+               <Noti-Config>../../../testcase/fw-test-cfg/noticonfig_fw_test_omadm</Noti-Config>
+       </Noti>
+       <Noti>
+               <Noti-Key>omadm_alert_ui</Noti-Key>
+               <Noti-Config>../../../testcase/fw-test-cfg/noticonfig_fw_test_omadm</Noti-Config>
+       </Noti>
+</INIT>
\ No newline at end of file
diff --git a/TC/testcase/fw-test-cfg/test_fw_config_omads.xml b/TC/testcase/fw-test-cfg/test_fw_config_omads.xml
new file mode 100644 (file)
index 0000000..ad1f54f
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml  version="1.0" encoding="UTF-8" ?>
+<INIT>
+       <Agent-Key>fw_test_omads</Agent-Key>
+       <MainLoop>1</MainLoop>
+       <Event>
+               <Event-Key>omads</Event-Key>
+               <Event-Config>../../../testcase/fw-test-cfg/eventconfig_fw_test_omads</Event-Config>
+               <RunEventHandler>1</RunEventHandler>
+       </Event>
+       <Noti>
+               <Noti-Key>omads</Noti-Key>
+               <Noti-Config>../../../testcase/fw-test-cfg/noticonfig_fw_test_omads</Noti-Config>
+       </Noti>
+</INIT>
\ No newline at end of file
diff --git a/TC/testcase/fw-test-file/sample_xml b/TC/testcase/fw-test-file/sample_xml
new file mode 100644 (file)
index 0000000..edba9d3
--- /dev/null
@@ -0,0 +1,492 @@
+<?xml version="1.0"?>
+<!DOCTYPE SyncML PUBLIC "-//SYNCML//DTD SyncML 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/OMA-TS-SyncML_RepPro_DTD-V1_2.dtd">
+<SyncML xmlns="SYNCML:SYNCML1.2">
+    <SyncHdr>
+        <VerDTD>1.2</VerDTD>
+        <VerProto>SyncML/1.2</VerProto>
+        <SessionID>0000000000</SessionID>
+        <MsgID>1</MsgID>
+        <Target>
+            <LocURI>IMEI:123456789012345</LocURI>
+        </Target>
+        <Source>
+            <LocURI>http://my.funambol.com/sync</LocURI>
+        </Source>
+        <RespURI>http://my.funambol.com/sync;jsessionid=00000000000000000000000000000000.DS00</RespURI>
+    </SyncHdr>
+    <SyncBody>
+        <Status>
+            <CmdID>1</CmdID>
+            <MsgRef>1</MsgRef>
+            <CmdRef>0</CmdRef>
+            <Cmd>SyncHdr</Cmd>
+            <TargetRef>http://my.funambol.com/sync</TargetRef>
+            <SourceRef>IMEI:123456789012345</SourceRef>
+            <Data>212</Data>
+        </Status>
+        <Status>
+            <CmdID>2</CmdID>
+            <MsgRef>1</MsgRef>
+            <CmdRef>1</CmdRef>
+            <Cmd>Put</Cmd>
+            <SourceRef>./devinf12</SourceRef>
+            <Data>200</Data>
+        </Status>
+        <Status>
+            <CmdID>3</CmdID>
+            <MsgRef>1</MsgRef>
+            <CmdRef>2</CmdRef>
+            <Cmd>Get</Cmd>
+            <TargetRef>./devinf12</TargetRef>
+            <Data>200</Data>
+        </Status>
+        <Status>
+            <CmdID>4</CmdID>
+            <MsgRef>1</MsgRef>
+            <CmdRef>3</CmdRef>
+            <Cmd>Alert</Cmd>
+            <TargetRef>card</TargetRef>
+            <SourceRef>Contacts</SourceRef>
+            <Data>200</Data>
+            <Item>
+                <Data>
+                    <Anchor xmlns="syncml:metinf">
+                        <Next>1355548820</Next>
+                    </Anchor>
+                </Data>
+            </Item>
+        </Status>
+        <Results>
+            <CmdID>5</CmdID>
+            <MsgRef>1</MsgRef>
+            <CmdRef>2</CmdRef>
+            <Meta>
+                <Type xmlns="syncml:metinf">application/vnd.syncml-devinf+xml</Type>
+            </Meta>
+            <Item>
+                <Source>
+                    <LocURI>./devinf12</LocURI>
+                </Source>
+                <Data>                <DevInf xmlns="syncml:devinf">
+                    <VerDTD>1.2</VerDTD>
+                    <Man>Funambol</Man>
+                    <Mod>DS Server CarEd</Mod>
+                    <OEM>-</OEM>
+                    <FwV>-</FwV>
+                    <SwV>11.2.4-p104</SwV>
+                    <HwV>-</HwV>
+                    <DevID>funambol</DevID>
+                    <DevTyp>server</DevTyp>
+                    <UTC/>
+                    <SupportLargeObjs/>
+                    <SupportNumberOfChanges/>
+                    <DataStore>
+                        <SourceRef>cal</SourceRef>
+                        <DisplayName>cal</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Rx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Rx>
+                        <Tx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <Tx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Tx>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>calllog</SourceRef>
+                        <DisplayName>calllog</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vCallLog</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-vCallLog</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>card</SourceRef>
+                        <DisplayName>card</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vcard</CTType>
+                            <VerCT>2.1</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-vcard</CTType>
+                            <VerCT>2.1</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>configuration</SourceRef>
+                        <DisplayName>configuration</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>event</SourceRef>
+                        <DisplayName>event</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Rx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Rx>
+                        <Tx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <Tx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Tx>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>file</SourceRef>
+                        <DisplayName>file</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>group</SourceRef>
+                        <DisplayName>group</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vcard</CTType>
+                            <VerCT>2.1</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-vcard</CTType>
+                            <VerCT>2.1</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>note</SourceRef>
+                        <DisplayName>note</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>picture</SourceRef>
+                        <DisplayName>picture</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>sapi</SourceRef>
+                        <DisplayName>sapi</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/plain</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>scal</SourceRef>
+                        <DisplayName>scal</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-s4j-sife</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-s4j-sife</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>scard</SourceRef>
+                        <DisplayName>scard</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-s4j-sifc</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-s4j-sifc</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>snote</SourceRef>
+                        <DisplayName>snote</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-s4j-sifn</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-s4j-sifn</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>stask</SourceRef>
+                        <DisplayName>stask</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-s4j-sift</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>text/x-s4j-sift</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>task</SourceRef>
+                        <DisplayName>task</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Rx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Rx>
+                        <Tx-Pref>
+                            <CTType>text/x-vcalendar</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <Tx>
+                            <CTType>text/calendar</CTType>
+                            <VerCT>2.0</VerCT>
+                        </Tx>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <DataStore>
+                        <SourceRef>video</SourceRef>
+                        <DisplayName>video</DisplayName>
+                        <MaxGUIDSize>32</MaxGUIDSize>
+                        <Rx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Rx-Pref>
+                        <Tx-Pref>
+                            <CTType>application/vnd.omads-file+xml</CTType>
+                            <VerCT>1.0</VerCT>
+                        </Tx-Pref>
+                        <SyncCap>
+                            <SyncType>1</SyncType>
+                            <SyncType>2</SyncType>
+                            <SyncType>3</SyncType>
+                            <SyncType>4</SyncType>
+                            <SyncType>5</SyncType>
+                            <SyncType>6</SyncType>
+                            <SyncType>7</SyncType>
+                        </SyncCap>
+                    </DataStore>
+                    <Ext>
+                        <XNam>X-funambol-smartslow</XNam>
+                    </Ext>
+                    <Ext>
+                        <XNam>X-funambol-media-http-upload</XNam>
+                    </Ext>
+                    <Ext>
+                        <XNam>X-funambol-msu</XNam>
+                    </Ext>
+                </DevInf>
+</Data>
+            </Item>
+        </Results>
+        <Alert>
+            <CmdID>6</CmdID>
+            <Data>205</Data>
+            <Item>
+                <Target>
+                    <LocURI>Contacts</LocURI>
+                </Target>
+                <Source>
+                    <LocURI>card</LocURI>
+                </Source>
+                <Meta>
+                    <Anchor xmlns="syncml:metinf">
+                        <Last>1355317910462</Last>
+                        <Next>1355548846186</Next>
+                    </Anchor>
+                </Meta>
+            </Item>
+        </Alert>
+        <Final/>
+    </SyncBody>
+</SyncML>
diff --git a/TC/testcase/fw-test-file/target_compress b/TC/testcase/fw-test-file/target_compress
new file mode 100755 (executable)
index 0000000..a8d5f28
--- /dev/null
@@ -0,0 +1,57 @@
+SCCS: @(#)Licence      1.7 (2006/03/10) TET Release 3.7
+
+
+
++++++++++++++TET END USER LICENCE+++++++++++
+
+
+BY RETRIEVING THIS DISTRIBUTION OF TET, YOU ARE CONSENTING TO BE BOUND BY
+THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT,
+DO NOT INSTALL THE PRODUCT, AND DESTROY YOUR COPY.
+
+
+               
+TET RELEASE 3.7 END USER LICENCE
+_________________________________
+
+Copyright (c) 1996-2006 X/Open Company Ltd trading as The Open Group
+All rights reserved.
+
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the "Artistic License" which comes with this
+Kit.
+
+
+THE OPEN GROUP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+
+You should have received a copy of the Artistic License with this
+Kit, in the file named "Artistic".  If not, we'll be glad to provide one.
+
+Portions of this work contain code derived from other versions
+of the Test Environment Toolkit, which contain the following
+copyrights:
+
+Copyright 1990,1992 Open Software Foundation
+Copyright 1990,1992 Unix International
+Copyright 1990,1992 X/Open Company Ltd.
+Copyright 1991 Hewlett-Packard Co.
+Copyright 1993 Information-Technology Promotion Agency, Japan
+Copyright 1993 Sunsoft, Inc.
+Copyright 1993 UNIX System Laboratories, Inc., a subsidiary of Novell Inc.
+Copyright 1994,1995 UniSoft Ltd.
+
+The unmodified source code of those works is freely available from
+ftp.xopen.org.  The modified code contained in this work
+restricts the usage of that code as per this licence.
+
+The contrib distribution is now bundled within the "contrib" directory.
+This is subject to the individual copyrights contained within
+those files.
diff --git a/TC/testcase/fw-test-file/target_uncompress.tar b/TC/testcase/fw-test-file/target_uncompress.tar
new file mode 100644 (file)
index 0000000..beed206
Binary files /dev/null and b/TC/testcase/fw-test-file/target_uncompress.tar differ
diff --git a/TC/testcase/fw-test-file/tnds_sample.txt b/TC/testcase/fw-test-file/tnds_sample.txt
new file mode 100644 (file)
index 0000000..8eb822c
--- /dev/null
@@ -0,0 +1,478 @@
+<MgmtTree xmlns="syncml:dmddf1.2">
+    <VerDTD>1.2</VerDTD>
+    <Node>
+        <NodeName>DMAcc</NodeName>
+        <RTProperties>
+            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+            <Format>
+                <node/>
+            </Format>
+            <Title>A collection of all SyncML DM accounts</Title>
+            <TStamp>20121217T192705Z</TStamp>
+            <Type>
+                <DDFName></DDFName>
+            </Type>
+            <VerNo>0</VerNo>
+        </RTProperties>
+        <Node>
+            <NodeName>gcf</NodeName>
+            <RTProperties>
+                <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                <Format>
+                    <node/>
+                </Format>
+                <Title>The &quot;name&quot; node for a management account sub tree</Title>
+                <TStamp>20121217T192705Z</TStamp>
+                <Type>
+                    <DDFName></DDFName>
+                </Type>
+                <VerNo>0</VerNo>
+            </RTProperties>
+            <Node>
+                <NodeName>AppID</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <chr/>
+                    </Format>
+                    <Title>Application ID for DM Account MO.</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <MIME>text/plain</MIME>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value>w7</Value>
+            </Node>
+            <Node>
+                <NodeName>ServerID</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <chr/>
+                    </Format>
+                    <Title>Server Identifier.</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <MIME>text/plain</MIME>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value>RSate</Value>
+            </Node>
+            <Node>
+                <NodeName>Name</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <chr/>
+                    </Format>
+                    <Title>Displayable name for the Management Server.</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <MIME>text/plain</MIME>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value>gcf</Value>
+            </Node>
+            <Node>
+                <NodeName>PrefConRef</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <chr/>
+                    </Format>
+                    <Title>Reference to preferred connectivity</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <MIME>text/plain</MIME>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value></Value>
+            </Node>
+            <Node>
+                <NodeName>ToConRef</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <node/>
+                    </Format>
+                    <Title>A collection of references to connectivity definitions</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type/>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Node>
+                    <NodeName>gcf_ConRef</NodeName>
+                    <RTProperties>
+                        <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                        <Format>
+                            <node/>
+                        </Format>
+                        <Title>The &quot;name&quot; node for a management account sub tree</Title>
+                        <TStamp>20121217T192705Z</TStamp>
+                        <Type>
+                            <DDFName></DDFName>
+                        </Type>
+                        <VerNo>0</VerNo>
+                    </RTProperties>
+                    <Node>
+                        <NodeName>ConRef</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>&gt;Linkage to connectivity parameters</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value></Value>
+                    </Node>
+                </Node>
+            </Node>
+            <Node>
+                <NodeName>AppAddr</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <node/>
+                    </Format>
+                    <Title>A collection of all references to AppAddr objects</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type/>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Node>
+                    <NodeName>gcf_AppAddr</NodeName>
+                    <RTProperties>
+                        <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                        <Format>
+                            <node/>
+                        </Format>
+                        <Title>The &quot;name&quot; node for a management account sub tree</Title>
+                        <TStamp>20121217T192705Z</TStamp>
+                        <Type>
+                            <DDFName></DDFName>
+                        </Type>
+                        <VerNo>0</VerNo>
+                    </RTProperties>
+                    <Node>
+                        <NodeName>Addr</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Management Server Address</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>http://mfiop12.gcf.com/oma/iop</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AddrType</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Management Server Address Type</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>IPv4</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>Port</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <node/>
+                            </Format>
+                            <Title>A collection of all Port objects</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type/>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Node>
+                            <NodeName>gcf_Port</NodeName>
+                            <RTProperties>
+                                <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                                <Format>
+                                    <node/>
+                                </Format>
+                                <Title></Title>
+                                <TStamp>20121217T192705Z</TStamp>
+                                <Type/>
+                                <VerNo>0</VerNo>
+                            </RTProperties>
+                            <Node>
+                                <NodeName>PortNbr</NodeName>
+                                <RTProperties>
+                                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                                    <Format>
+                                        <chr/>
+                                    </Format>
+                                    <Title>Port.</Title>
+                                    <TStamp>20121217T192705Z</TStamp>
+                                    <Type>
+                                        <MIME>text/plain</MIME>
+                                    </Type>
+                                    <VerNo>0</VerNo>
+                                </RTProperties>
+                                <Value>80</Value>
+                            </Node>
+                        </Node>
+                    </Node>
+                </Node>
+            </Node>
+            <Node>
+                <NodeName>AAuthPref</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <chr/>
+                    </Format>
+                    <Title>AApplication Authentication Type preference</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <MIME>text/plain</MIME>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value></Value>
+            </Node>
+            <Node>
+                <NodeName>AppAuth</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <node/>
+                    </Format>
+                    <Title>A collection of all references to multiple Application Authentication objects.</Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type/>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Node>
+                    <NodeName>ServerAppAuth</NodeName>
+                    <RTProperties>
+                        <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                        <Format>
+                            <node/>
+                        </Format>
+                        <Title></Title>
+                        <TStamp>20121217T192705Z</TStamp>
+                        <Type>
+                            <DDFName></DDFName>
+                        </Type>
+                        <VerNo>0</VerNo>
+                    </RTProperties>
+                    <Node>
+                        <NodeName>AAuthLevel</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication level</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>SRVCRED</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthType</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Type</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>DIGEST</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthName</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Name</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>RSate</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthSecret</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Secret</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>xxxx</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthData</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <bin/>
+                            </Format>
+                            <Title>Application Authentication Data</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>11111</Value>
+                    </Node>
+                </Node>
+                <Node>
+                    <NodeName>ClientAppAuth</NodeName>
+                    <RTProperties>
+                        <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                        <Format>
+                            <node/>
+                        </Format>
+                        <Title></Title>
+                        <TStamp>20121217T192705Z</TStamp>
+                        <Type>
+                            <DDFName></DDFName>
+                        </Type>
+                        <VerNo>0</VerNo>
+                    </RTProperties>
+                    <Node>
+                        <NodeName>AAuthLevel</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication level</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>CLCRED</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthType</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Type</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>DIGEST</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthName</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Name</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>xxxxx</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthSecret</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <chr/>
+                            </Format>
+                            <Title>Application Authentication Secret</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>xxxxx</Value>
+                    </Node>
+                    <Node>
+                        <NodeName>AAuthData</NodeName>
+                        <RTProperties>
+                            <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                            <Format>
+                                <bin/>
+                            </Format>
+                            <Title>Application Authentication Data</Title>
+                            <TStamp>20121217T192705Z</TStamp>
+                            <Type>
+                                <MIME>text/plain</MIME>
+                            </Type>
+                            <VerNo>0</VerNo>
+                        </RTProperties>
+                        <Value>11111</Value>
+                    </Node>
+                </Node>
+            </Node>
+            <Node>
+                <NodeName>Ext</NodeName>
+                <RTProperties>
+                    <ACL>Add=RSate&amp;Delete=RSate&amp;Get=RSate&amp;Replace=RSate</ACL>
+                    <Format>
+                        <node/>
+                    </Format>
+                    <Title></Title>
+                    <TStamp>20121217T192705Z</TStamp>
+                    <Type>
+                        <DDFName></DDFName>
+                    </Type>
+                    <VerNo>0</VerNo>
+                </RTProperties>
+                <Value></Value>
+            </Node>
+        </Node>
+    </Node>
+</MgmtTree>
\ No newline at end of file
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
new file mode 100644 (file)
index 0000000..17e3db7
--- /dev/null
@@ -0,0 +1,21 @@
+/testcase/utc_sync_agent_framework_account
+/testcase/utc_sync_agent_framework_data_adapter
+/testcase/utc_sync_agent_framework_device
+/testcase/utc_sync_agent_framework_device_manager
+/testcase/utc_sync_agent_framework_engine_controller
+/testcase/utc_sync_agent_framework_event
+/testcase/utc_sync_agent_framework_event_omadm_account_reg
+/testcase/utc_sync_agent_framework_event_omadm_admin
+/testcase/utc_sync_agent_framework_event_omadm_alert
+/testcase/utc_sync_agent_framework_event_omadm_cp
+/testcase/utc_sync_agent_framework_event_omadm_dmacc
+/testcase/utc_sync_agent_framework_event_omadm_fota
+/testcase/utc_sync_agent_framework_event_omadm_noti
+/testcase/utc_sync_agent_framework_event_omads
+/testcase/utc_sync_agent_framework_fsapi
+/testcase/utc_sync_agent_framework_initialization
+/testcase/utc_sync_agent_framework_network_access
+/testcase/utc_sync_agent_framework_platform_monitor
+/testcase/utc_sync_agent_framework_protocol_binder
+/testcase/utc_sync_agent_framework_security_assistant
+/testcase/utc_sync_agent_framework_utility
\ No newline at end of file
diff --git a/TC/testcase/utc_sync_agent_framework_account.c b/TC/testcase/utc_sync_agent_framework_account.c
new file mode 100755 (executable)
index 0000000..4501125
--- /dev/null
@@ -0,0 +1,609 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+#define API_NAME_SYNC_AGENT_CREATE_FW_ACCOUNT  "sync_agent_create_fw_account"
+#define API_NAME_SYNC_AGENT_ADD_FW_ACCOUNT "sync_agent_add_fw_account"
+#define API_NAME_SYNC_AGENT_UPDATE_FW_ACCOUNT "sync_agent_update_fw_account"
+#define API_NAME_SYNC_AGENT_GET_FW_ACCOUNT "sync_agent_get_fw_account"
+#define API_NAME_SYNC_AGENT_DELETE_FW_ACCOUNT "sync_agent_delete_fw_account"
+#define API_NAME_SYNC_AGENT_QUERY_FW_ACCOUNT "sync_agent_query_fw_account"
+//#define API_NAME_SYNC_AGENT_FREE_FW_ACCOUNT "sync_agent_free_fw_account"
+//#define API_NAME_SYNC_AGENT_FREE_FW_ACCOUNT_LIST "sync_agent_free_fw_account_list"
+
+#define API_NAME_SYNC_AGENT_CONSTRUCT_ACCOUNT_TBL_FROM_SERVICE "sync_agent_construct_account_tbl_from_service"
+#define API_NAME_SYNC_AGENT_CREATE_SERVICE_ACCOUNT_INFO "sync_agent_create_service_account_info"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_ACCOUNT "sync_agent_get_service_account"
+//#define API_NAME_SYNC_AGENT_FREE_SERVICE_ACCOUNT_INFO "sync_agent_free_service_account_info"
+
+static void utc_sync_agent_framework_sync_agent_create_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_add_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_add_fw_account_n(void);
+static void utc_sync_agent_framework_sync_agent_update_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_update_fw_account_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_fw_account_n(void);
+static void utc_sync_agent_framework_sync_agent_get_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_query_fw_account_p(void);
+static void utc_sync_agent_framework_sync_agent_query_fw_account_n(void);
+//static void utc_sync_agent_framework_sync_agent_free_fw_account_p(void);
+//static void utc_sync_agent_framework_sync_agent_free_fw_account_list_p(void);
+static void utc_sync_agent_framework_sync_agent_construct_account_tbl_from_service_p(void);
+static void utc_sync_agent_framework_sync_agent_create_service_account_info_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_account_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_account_n(void);
+//static void utc_sync_agent_framework_sync_agent_free_service_account_info_p(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_create_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_fw_account_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_fw_account_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_fw_account_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_fw_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_fw_account_n, NEGATIVE_TC_IDX},
+//      {       utc_sync_agent_framework_sync_agent_free_fw_account_p, POSITIVE_TC_IDX },
+//      {       utc_sync_agent_framework_sync_agent_free_fw_account_list_p, POSITIVE_TC_IDX },
+       {utc_sync_agent_framework_sync_agent_construct_account_tbl_from_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_service_account_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_account_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_account_n, NEGATIVE_TC_IDX},
+//      {       utc_sync_agent_framework_sync_agent_free_service_account_info_p, POSITIVE_TC_IDX },
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       da_err = sync_agent_empty_all_agent_default_table();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_empty_all_agent_default_table : %d", da_err);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       da_err = sync_agent_open_agent();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_open_agent : %d", da_err);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       sync_agent_close_agent();
+}
+
+static void utc_sync_agent_framework_sync_agent_create_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               sync_agent_free_fw_account(fw_account);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+
+       sync_agent_fw_account_s *fw_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("add_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_fw_account_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+
+       sync_agent_fw_account_s *fw_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("add_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(NULL, &account_id);
+       sync_agent_free_fw_account(fw_account);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+       sync_agent_fw_account_s *fw_update_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("update_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_create_fw_account(&fw_update_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_update_account->account_id = account_id;
+       fw_update_account->email = strdup("update_account1@email.com");
+       fw_update_account->password = strdup("123456");
+       fw_update_account->enable = 1;
+       fw_update_account->access_name = strdup("TC");
+
+       account_err = sync_agent_update_fw_account(fw_update_account);
+       sync_agent_free_fw_account(fw_update_account);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_update_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_fw_account_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+       sync_agent_fw_account_s *fw_update_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       fw_account->email = strdup("update_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       account_err = sync_agent_create_fw_account(&fw_update_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       fw_update_account->account_id = account_id;
+       fw_update_account->email = strdup("update_account1@email.com");
+       fw_update_account->password = strdup("123456");
+       fw_update_account->enable = 1;
+       fw_update_account->access_name = strdup("TC");
+
+       account_err = sync_agent_update_fw_account(NULL);
+       sync_agent_free_fw_account(fw_update_account);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_update_fw_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("delete_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_delete_fw_account(account_id);
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_delete_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_fw_account_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       fw_account->email = strdup("delete_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       account_err = sync_agent_delete_fw_account(-100);
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_delete_fw_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_s *fw_account = NULL;
+       sync_agent_fw_account_s *fw_get_account = NULL;
+       int account_id = 0;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("get_account@email.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &account_id);
+       sync_agent_free_fw_account(fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_create_fw_account(&fw_get_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_get_fw_account(account_id, &fw_get_account);
+       sync_agent_free_fw_account(fw_get_account);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_fw_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_query_s query;
+       GList *account_info_list = NULL;
+
+       query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+       query.access_name = strdup("TC");
+
+       account_err = sync_agent_query_fw_account(&query, &account_info_list);
+
+       if (query.access_name != NULL)
+               free(query.access_name);
+       sync_agent_free_fw_account_list(account_info_list);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_query_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_fw_account_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_FW_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_fw_account_query_s query;
+       GList *account_info_list = NULL;
+
+       query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+       query.access_name = strdup("TC");
+
+       account_err = sync_agent_query_fw_account(NULL, &account_info_list);
+
+       if (query.access_name != NULL)
+               free(query.access_name);
+       sync_agent_free_fw_account_list(account_info_list);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_query_fw_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+//static void utc_sync_agent_framework_sync_agent_free_fw_account_p(void)
+//{
+//      sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+//      char* api_name = API_NAME_SYNC_AGENT_FREE_FW_ACCOUNT;
+//      sync_agent_fw_account_s *fw_account = NULL;
+//
+//      account_err = sync_agent_create_fw_account(&fw_account);
+//      if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+//              dts_pass(api_name);
+//      } else {
+//              dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+//              dts_fail(api_name);
+//      }
+//
+//      sync_agent_free_fw_account(fw_account);
+//}
+//
+//static void utc_sync_agent_framework_sync_agent_free_fw_account_list_p(void)
+//{
+//      sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+//      char* api_name = API_NAME_SYNC_AGENT_FREE_FW_ACCOUNT_LIST;
+//      sync_agent_fw_account_query_s query;
+//      GList *account_info_list = NULL;
+//
+//      query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+//      query.access_name = strdup("TC");
+//
+//      account_err = sync_agent_query_fw_account(&query, &account_info_list);
+//      if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+//              dts_pass(api_name);
+//      } else {
+//              dts_message(api_name, "sync_agent_query_fw_account : %d", account_err);
+//              dts_fail(api_name);
+//      }
+//
+//      if (query.access_name != NULL)
+//              free(query.access_name);
+//
+//      sync_agent_free_fw_account_list(account_info_list);
+//}
+
+static void utc_sync_agent_framework_sync_agent_construct_account_tbl_from_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_ACCOUNT_TBL_FROM_SERVICE;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+
+       account_err = sync_agent_construct_account_tbl_from_service();
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_construct_account_tbl_from_service : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_service_account_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_SERVICE_ACCOUNT_INFO;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_service_account_info_s *account_info = NULL;
+
+       account_err = sync_agent_create_service_account_info(&account_info);
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               sync_agent_free_service_account_info(account_info);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_service_account_info : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_account_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_service_account_info_s *account_info = NULL;
+
+       account_err = sync_agent_construct_account_tbl_from_service();
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_construct_account_tbl_from_service : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_create_service_account_info(&account_info);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_service_account_info : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_err = sync_agent_get_service_account(1, 1, &account_info);
+       sync_agent_free_service_account_info(account_info);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_service_account : %d", account_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_account_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ACCOUNT;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_service_account_info_s *account_info = NULL;
+
+       account_err = sync_agent_construct_account_tbl_from_service();
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_construct_account_tbl_from_service : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       account_err = sync_agent_create_service_account_info(&account_info);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_service_account_info : %d", account_err);
+               dts_pass(api_name);
+       }
+
+       account_err = sync_agent_get_service_account(-100, 1, &account_info);
+       sync_agent_free_service_account_info(account_info);
+
+       if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_service_account : %d", account_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+//static void utc_sync_agent_framework_sync_agent_free_service_account_info_p(void)
+//{
+//      sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+//      char* api_name = API_NAME_SYNC_AGENT_FREE_SERVICE_ACCOUNT_INFO;
+//      sync_agent_service_account_info_s *account_info = NULL;
+//
+//
+//      account_err = sync_agent_create_service_account_info(&account_info);
+//      if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+//              dts_pass(api_name);
+//      } else {
+//              dts_message(api_name, "sync_agent_create_service_account_info : %d", account_err);
+//              dts_fail(api_name);
+//      }
+//
+//      account_err = sync_agent_get_service_account(account_id, 1, &account_info);
+//      if (account_err == SYNC_AGENT_ACC_SUCCESS) {
+//              dts_pass(api_name);
+//      } else {
+//              dts_message(api_name, "sync_agent_get_service_account : %d", account_err);
+//              dts_fail(api_name);
+//      }
+//
+//      sync_agent_free_service_account_info(account_info);
+//}
diff --git a/TC/testcase/utc_sync_agent_framework_data_adapter.c b/TC/testcase/utc_sync_agent_framework_data_adapter.c
new file mode 100755 (executable)
index 0000000..f461fe3
--- /dev/null
@@ -0,0 +1,3902 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_AGENT_OPEN_AGENT "sync_agent_open_agent"
+#define API_NAME_SYNC_AGENT_CLOSE_AGENT        "sync_agent_close_agent"
+#define API_NAME_SYNC_AGENT_EMPTY_AGENT_DEFAULT_TABLE  "sync_agent_empty_agent_default_table"
+#define API_NAME_SYNC_AGENT_EMPTY_ALL_AGENT_DEFAULT_TABLE      "sync_agent_empty_all_agent_default_table"
+#define API_NAME_SYNC_AGENT_BEGIN_TRANSACTION  "sync_agent_begin_transaction"
+#define API_NAME_SYNC_AGENT_END_TRANSACTION    "sync_agent_end_transaction"
+
+#define API_NAME_SYNC_AGENT_CONSTRUCT_ITEM_TBL_FROM_SERVICE    "sync_agent_construct_item_tbl_from_service"
+#define API_NAME_SYNC_AGENT_CONSTRUCT_FOLDER_TBL_FROM_SERVICE  "sync_agent_construct_folder_tbl_from_service"
+#define API_NAME_SYNC_AGENT_REFRESH_ITEM_TBL_FROM_SERVICE      "sync_agent_refresh_item_tbl_from_service"
+#define API_NAME_SYNC_AGENT_SET_SERVICE_CHANGE_POINT   "sync_agent_set_service_change_point"
+
+#define API_NAME_SYNC_AGENT_ALLOC_OBJ "sync_agent_alloc_obj"
+#define API_NAME_SYNC_AGENT_FREE_OBJ "sync_agent_free_obj"
+#define API_NAME_SYNC_AGENT_SET_VALUE_TO_OBJ "sync_agent_set_value_to_obj"
+#define API_NAME_SYNC_AGENT_GET_VALUE_TO_OBJ "sync_agent_get_value_to_obj"
+#define API_NAME_SYNC_AGENT_GET_OBJ_INFO "sync_agent_get_obj_info"
+#define API_NAME_SYNC_AGENT_FREE_OBJ_INFO "sync_agent_free_obj_info"
+
+#define API_NAME_SYNC_AGENT_CREATE_CHANGELOG "sync_agent_create_changelog"
+#define API_NAME_SYNC_AGENT_UPDATE_CHANGELOG "sync_agent_update_changelog"
+#define API_NAME_SYNC_AGENT_DELETE_CHANGELOG "sync_agent_delete_changelog"
+#define API_NAME_SYNC_AGENT_GET_CHANGELOG "sync_agent_get_changelog"
+#define API_NAME_SYNC_AGENT_GET_CHANGELOG_LIST "sync_agent_get_changelog_list"
+#define API_NAME_SYNC_AGENT_FREE_CHANGELOG "sync_agent_free_changelog"
+#define API_NAME_SYNC_AGENT_FREE_CHANGELOG_LIST "sync_agent_free_changelog_list"
+
+#define API_NAME_SYNC_AGENT_CREATE_CONFIG "sync_agent_create_config"
+#define API_NAME_SYNC_AGENT_ADD_CONFIG "sync_agent_add_config"
+#define API_NAME_SYNC_AGENT_ADD_CONFIG_LIST "sync_agent_add_config_list"
+#define API_NAME_SYNC_AGENT_UPDATE_CONFIG "sync_agent_update_config"
+#define API_NAME_SYNC_AGENT_DELETE_CONFIG "sync_agent_delete_config"
+#define API_NAME_SYNC_AGENT_IS_EXIST_CONFIG "sync_agent_is_exist_config"
+#define API_NAME_SYNC_AGENT_GET_CONFIG "sync_agent_get_config"
+#define API_NAME_SYNC_AGENT_GET_CONFIG_LIST "sync_agent_get_config_list"
+
+#define API_NAME_SYNC_AGENT_CREATE_FOLDER "sync_agent_create_folder"
+#define API_NAME_SYNC_AGENT_ADD_FOLDER "sync_agent_add_folder"
+#define API_NAME_SYNC_AGENT_GET_FOLDER "sync_agent_get_folder"
+#define API_NAME_SYNC_AGENT_GET_FOLDER_LIST "sync_agent_get_folder_list"
+#define API_NAME_SYNC_AGENT_GET_FOLDER_ID_LIST "sync_agent_get_folder_id_list"
+#define API_NAME_SYNC_AGENT_FREE_FOLDER "sync_agent_free_folder"
+#define API_NAME_SYNC_AGENT_FREE_FOLDER_LIST "sync_agent_free_folder_list"
+#define API_NAME_SYNC_AGENT_FREE_FOLDER_ID "sync_agent_free_folder_id"
+#define API_NAME_SYNC_AGENT_FREE_FOLDER_ID_LIST "sync_agent_free_folder_id_list"
+
+#define API_SYNC_AGENT_CREATE_ITEM "sync_agent_create_item"
+#define API_SYNC_AGENT_ADD_ITEM "sync_agent_add_item"
+#define API_SYNC_AGENT_UPDATE_ITEM "sync_agent_update_item"
+#define API_SYNC_AGENT_DELETE_ITEM "sync_agent_delete_item"
+#define API_SYNC_AGENT_QUERY_DELETE_ITEM "sync_agent_query_delete_item"
+#define API_SYNC_AGENT_GET_ITEM "sync_agent_get_item"
+#define API_SYNC_AGENT_GET_ITEM_LIST "sync_agent_get_item_list"
+#define API_SYNC_AGENT_GET_ITEM_ID "sync_agent_get_item_id"
+#define API_SYNC_AGENT_GET_ITEM_ID_LIST "sync_agent_get_item_id_list"
+#define API_SYNC_AGENT_FREE_ITEM "sync_agent_free_item"
+#define API_SYNC_AGENT_FREE_ITEM_LIST "sync_agent_free_item_list"
+#define API_SYNC_AGENT_FREE_ITEM_ID "sync_agent_free_item_id"
+#define API_SYNC_AGENT_FREE_ITEM_ID_LIST "sync_agent_free_item_id_list"
+#define API_SYNC_AGENT_GET_ITEM_COUNT "sync_agent_get_item_count"
+
+#define API_NAME_SYNC_AGENT_CREATE_LAST_ANCHOR "sync_agent_create_last_anchor"
+#define API_NAME_SYNC_AGENT_ADD_LAST_ANCHOR "sync_agent_add_last_anchor"
+#define API_NAME_SYNC_AGENT_UPDATE_LAST_ANCHOR "sync_agent_update_last_anchor"
+#define API_NAME_SYNC_AGENT_GET_LAST_ANCHOR_LIST "sync_agent_get_last_anchor_list"
+#define API_NAME_SYNC_AGENT_FREE_LAST_ANCHOR "sync_agent_free_last_anchor"
+
+#define API_NAME_SYNC_AGENT_CREATE_MAPPING "sync_agent_create_mapping"
+#define API_NAME_SYNC_AGENT_ADD_MAPPING "sync_agent_add_mapping"
+#define API_NAME_SYNC_AGENT_DELETE_MAPPING "sync_agent_delete_mapping"
+#define API_NAME_SYNC_AGENT_GET_MAPPING "sync_agent_get_mapping"
+#define API_NAME_SYNC_AGENT_GET_MAPPING_LIST "sync_agent_get_mapping_list"
+#define API_NAME_SYNC_AGENT_FREE_MAPPING "sync_agent_free_mapping"
+#define API_NAME_SYNC_AGENT_FREE_MAPPING_LIST "sync_agent_free_mapping_list"
+#define API_NAME_SYNC_AGENT_IS_EXIST_MAPPING_BY_ACCOUNT_ID "sync_agent_is_exist_mapping_by_account_id"
+
+#define API_NAME_SYNC_AGENT_OPEN_SERVICE "sync_agent_open_service"
+#define API_NAME_SYNC_AGENT_CLOSE_SERVICE "sync_agent_close_service"
+#define API_NAME_SYNC_AGENT_BEGIN_SERVICE "sync_agent_begin_service"
+#define API_NAME_SYNC_AGENT_END_SERVICE "sync_agent_end_service"
+#define API_NAME_SYNC_AGENT_CREATE_SERVICE_ITEM "sync_agent_create_service_item"
+#define API_NAME_SYNC_AGENT_CREATE_SERVICE_FOLDER "sync_agent_create_service_folder"
+#define API_NAME_SYNC_AGENT_FREE_SERVICE_ITEM "sync_agent_free_service_item"
+#define API_NAME_SYNC_AGENT_FREE_SERVICE_FOLDER "sync_agent_free_service_folder"
+#define API_NAME_SYNC_AGENT_ADD_SERVICE_ITEM "sync_agent_add_service_item"
+#define API_NAME_SYNC_AGENT_UPDATE_SERVICE_ITEM "sync_agent_update_service_item"
+#define API_NAME_SYNC_AGENT_DELETE_SERVICE_ITEM "sync_agent_delete_service_item"
+#define API_NAME_SYNC_AGENT_QUERY_DELETE_SERVICE_ITEMS "sync_agent_query_delete_service_items"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_ITEM "sync_agent_get_service_item"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER "sync_agent_get_service_folder"
+#define API_NAME_SYNC_AGENT_EXECUTE_SERVICE "sync_agent_execute_service"
+#define API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT "sync_agent_get_used_service_item_count"
+#define API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT_FOR_FOLDER "sync_agent_get_used_service_item_count_for_folder"
+#define API_NAME_SYNC_AGENT_BACKUP_SERVICE_ITEMS_TO_FILE "sync_agent_backup_service_items_to_file"
+#define API_NAME_SYNC_AGENT_RESTORE_SERVICE_ITEMS_FROM_FILE "sync_agent_restore_service_items_from_file"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_ITEM_ID "sync_agent_get_service_item_id"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER_ID "sync_agent_get_service_folder_id"
+
+#define API_NAME_SYNC_AGENT_GENERATE_ITEM_LUID "sync_agent_generate_item_luid"
+#define API_NAME_SYNC_AGENT_GENERATE_FOLDER_LUID "sync_agent_generate_folder_luid"
+
+static void utc_sync_agent_framework_sync_agent_open_agent_p(void);
+static void utc_sync_agent_framework_sync_agent_open_agent(void);
+static void utc_sync_agent_framework_sync_agent_close_agent_p(void);
+static void utc_sync_agent_framework_sync_agent_close_agent(void);
+static void utc_sync_agent_framework_sync_agent_begin_transaction_p(void);
+static void utc_sync_agent_framework_sync_agent_end_transaction_p(void);
+
+static void utc_sync_agent_framework_sync_agent_empty_agent_default_table_p(void);
+static void utc_sync_agent_framework_sync_agent_empty_agent_default_table_n(void);
+static void utc_sync_agent_framework_sync_agent_empty_all_agent_default_table_p(void);
+static void utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_p(void);
+static void utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_n(void);
+static void utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_p(void);
+static void utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_n(void);
+static void utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_p(void);
+static void utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_n(void);
+static void utc_sync_agent_framework_sync_agent_set_service_change_point_p(void);
+
+static void utc_sync_agent_framework_sync_agent_alloc_obj_p(void);
+static void utc_sync_agent_framework_sync_agent_free_obj_p(void);
+static void utc_sync_agent_framework_sync_agent_free_obj_n(void);
+static void utc_sync_agent_framework_sync_agent_set_value_to_obj_p(void);
+static void utc_sync_agent_framework_sync_agent_set_value_to_obj_n(void);
+static void utc_sync_agent_framework_sync_agent_get_value_to_obj_p(void);
+static void utc_sync_agent_framework_sync_agent_get_value_to_obj_n(void);
+static void utc_sync_agent_framework_sync_agent_get_obj_info_p(void);
+static void utc_sync_agent_framework_sync_agent_get_obj_info_n(void);
+static void utc_sync_agent_framework_sync_agent_free_obj_info_p(void);
+static void utc_sync_agent_framework_sync_agent_free_obj_info_n(void);
+
+static void utc_sync_agent_framework_sync_agent_create_changelog_p(void);
+static void utc_sync_agent_framework_sync_agent_update_changelog_p(void);
+static void utc_sync_agent_framework_sync_agent_update_changelog_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_changelog_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_changelog_n(void);
+static void utc_sync_agent_framework_sync_agent_get_changelog_n(void);
+static void utc_sync_agent_framework_sync_agent_get_changelog_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_changelog_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_changelog_p(void);
+static void utc_sync_agent_framework_sync_agent_free_changelog_list_p(void);
+
+static void utc_sync_agent_framework_sync_agent_create_config_p(void);
+static void utc_sync_agent_framework_sync_agent_add_config_p(void);
+static void utc_sync_agent_framework_sync_agent_add_config_n(void);
+static void utc_sync_agent_framework_sync_agent_add_config_list_p(void);
+static void utc_sync_agent_framework_sync_agent_add_config_list_n(void);
+static void utc_sync_agent_framework_sync_agent_update_config_p(void);
+static void utc_sync_agent_framework_sync_agent_update_config_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_config_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_config_n(void);
+static void utc_sync_agent_framework_sync_agent_is_exist_config_p(void);
+static void utc_sync_agent_framework_sync_agent_is_exist_config_n(void);
+static void utc_sync_agent_framework_sync_agent_get_config_p(void);
+static void utc_sync_agent_framework_sync_agent_get_config_n(void);
+static void utc_sync_agent_framework_sync_agent_get_config_list_p(void);
+
+static void utc_sync_agent_framework_sync_agent_create_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_add_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_add_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_list_n(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_id_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_folder_id_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_list_p(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_id_p(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_id_n(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_id_list_p(void);
+static void utc_sync_agent_framework_sync_agent_free_folder_id_list_n(void);
+
+static void utc_sync_agent_framework_sync_agent_create_item_p(void);
+static void utc_sync_agent_framework_sync_agent_add_item_p(void);
+static void utc_sync_agent_framework_sync_agent_add_item_n(void);
+static void utc_sync_agent_framework_sync_agent_update_item_p(void);
+static void utc_sync_agent_framework_sync_agent_update_item_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_item_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_item_n(void);
+static void utc_sync_agent_framework_sync_agent_query_delete_item_p(void);
+static void utc_sync_agent_framework_sync_agent_query_delete_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_item_p(void);
+static void utc_sync_agent_framework_sync_agent_get_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_item_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_item_list_n(void);
+static void utc_sync_agent_framework_sync_agent_get_item_id_p(void);
+static void utc_sync_agent_framework_sync_agent_get_item_id_n(void);
+static void utc_sync_agent_framework_sync_agent_get_item_id_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_item_id_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_item_p(void);
+static void utc_sync_agent_framework_sync_agent_free_item_n(void);
+static void utc_sync_agent_framework_sync_agent_free_item_list_p(void);
+static void utc_sync_agent_framework_sync_agent_free_item_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_item_id_p(void);
+static void utc_sync_agent_framework_sync_agent_free_item_id_n(void);
+static void utc_sync_agent_framework_sync_agent_free_item_id_list_p(void);
+static void utc_sync_agent_framework_sync_agent_free_item_id_list_n(void);
+static void utc_sync_agent_framework_sync_agent_get_item_count_p(void);
+
+static void utc_sync_agent_framework_sync_agent_create_last_anchor_p(void);
+static void utc_sync_agent_framework_sync_agent_add_last_anchor_p(void);
+static void utc_sync_agent_framework_sync_agent_add_last_anchor_n(void);
+static void utc_sync_agent_framework_sync_agent_update_last_anchor_p(void);
+static void utc_sync_agent_framework_sync_agent_update_last_anchor_n(void);
+static void utc_sync_agent_framework_sync_agent_get_last_anchor_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_last_anchor_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_last_anchor_p(void);
+static void utc_sync_agent_framework_sync_agent_free_last_anchor_n(void);
+
+static void utc_sync_agent_framework_sync_agent_create_mapping_p(void);
+static void utc_sync_agent_framework_sync_agent_add_mapping_p(void);
+static void utc_sync_agent_framework_sync_agent_add_mapping_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_mapping_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_mapping_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mapping_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mapping_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mapping_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mapping_list_n(void);
+static void utc_sync_agent_framework_sync_agent_free_mapping_p(void);
+static void utc_sync_agent_framework_sync_agent_free_mapping_n(void);
+static void utc_sync_agent_framework_sync_agent_free_mapping_list_p(void);
+static void utc_sync_agent_framework_sync_agent_free_mapping_list_n(void);
+static void utc_sync_agent_framework_sync_agent_is_exist_mapping_by_account_id_p(void);
+
+static void utc_sync_agent_framework_sync_agent_open_service_p(void);
+static void utc_sync_agent_framework_sync_agent_open_service_n(void);
+static void utc_sync_agent_framework_sync_agent_close_service_p(void);
+static void utc_sync_agent_framework_sync_agent_close_service_n(void);
+static void utc_sync_agent_framework_sync_agent_begin_service_p(void);
+static void utc_sync_agent_framework_sync_agent_begin_service_n(void);
+static void utc_sync_agent_framework_sync_agent_end_service_p(void);
+static void utc_sync_agent_framework_sync_agent_end_service_n(void);
+static void utc_sync_agent_framework_sync_agent_create_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_create_service_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_free_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_free_service_item_n(void);
+static void utc_sync_agent_framework_sync_agent_free_service_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_free_service_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_add_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_add_service_item_n(void);
+static void utc_sync_agent_framework_sync_agent_update_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_update_service_item_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_service_item_n(void);
+static void utc_sync_agent_framework_sync_agent_query_delete_service_items_p(void);
+static void utc_sync_agent_framework_sync_agent_query_delete_service_items_n(void);
+static void utc_sync_agent_framework_sync_agent_get_service_item_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_service_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_execute_service_n(void);
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_p(void);
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_n(void);
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_n(void);
+static void utc_sync_agent_framework_sync_agent_backup_service_items_to_file_p(void);
+static void utc_sync_agent_framework_sync_agent_backup_service_items_to_file_n(void);
+static void utc_sync_agent_framework_sync_agent_restore_service_items_from_file_p(void);
+static void utc_sync_agent_framework_sync_agent_restore_service_items_from_file_n(void);
+static void utc_sync_agent_framework_sync_agent_get_service_item_id_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_item_id_n(void);
+static void utc_sync_agent_framework_sync_agent_get_service_folder_id_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_folder_id_n(void);
+
+static void utc_sync_agent_framework_sync_agent_generate_item_luid_p(void);
+static void utc_sync_agent_framework_sync_agent_generate_item_luid_n(void);
+static void utc_sync_agent_framework_sync_agent_generate_folder_luid_p(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_open_agent_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_open_agent, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_begin_transaction_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_end_transaction_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_empty_agent_default_table_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_empty_agent_default_table_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_empty_all_agent_default_table_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_service_change_point_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_alloc_obj_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_obj_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_obj_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_value_to_obj_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_value_to_obj_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_value_to_obj_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_value_to_obj_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_obj_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_obj_info_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_obj_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_obj_info_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_changelog_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_changelog_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_changelog_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_changelog_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_changelog_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_changelog_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_changelog_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_changelog_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_changelog_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_changelog_list_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_config_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_config_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_config_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_config_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_config_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_exist_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_exist_config_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_config_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_config_list_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_id_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_folder_id_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_id_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_id_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_id_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_folder_id_list_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_delete_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_delete_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_id_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_id_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_id_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_id_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_id_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_id_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_id_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_item_id_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_item_count_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_last_anchor_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_last_anchor_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_last_anchor_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_last_anchor_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_last_anchor_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_last_anchor_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_last_anchor_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_last_anchor_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_last_anchor_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_mapping_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_mapping_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_mapping_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mapping_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mapping_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mapping_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mapping_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mapping_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mapping_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mapping_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mapping_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mapping_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mapping_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_exist_mapping_by_account_id_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_service_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_service_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_service_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_service_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_service_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_service_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_service_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_delete_service_items_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_delete_service_items_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_execute_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_used_service_item_count_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_used_service_item_count_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_backup_service_items_to_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_backup_service_items_to_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_restore_service_items_from_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_restore_service_items_from_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_item_id_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_item_id_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_folder_id_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_folder_id_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_open_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_open_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_begin_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_begin_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_end_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_end_service_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_generate_item_luid_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_generate_item_luid_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_generate_folder_luid_p, POSITIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_close_agent_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_agent, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static int account_id;
+static char *item_id;
+static char *service_id;
+static char *saved_file_path;
+
+typedef enum {
+       TYPE_CALENDAR = 0,
+       TYPE_SMS = 1,
+       TYPE_BOOKMARK = 2
+} service_type_e;
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       sync_agent_da_return_e da_err = sync_agent_empty_all_agent_default_table();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(API_NAME_SYNC_START_UP);
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_empty_agent_default_table : %d", da_err);
+       }
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_open_agent_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_AGENT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_open_agent();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_open_agent : %d", da_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_open_agent(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_AGENT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_open_agent();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_open_agent : %d", da_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_agent_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_AGENT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_close_agent();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_framework : %d", da_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_agent(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_AGENT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_close_agent();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_framework : %d", da_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_begin_transaction_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_BEGIN_TRANSACTION;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_transaction_e transaction = SYNC_AGENT_DA_TRANSACTION_COMMIT;
+
+       da_err = sync_agent_begin_transaction();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_begin_transaction : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_end_transaction_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_END_TRANSACTION;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_transaction_e transaction = SYNC_AGENT_DA_TRANSACTION_COMMIT;
+
+       da_err = sync_agent_end_transaction(transaction);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_end_transaction : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_empty_agent_default_table_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EMPTY_AGENT_DEFAULT_TABLE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_table_name_e table = SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR;
+
+       da_err = sync_agent_empty_agent_default_table(table);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_empty_agent_default_table : %d", da_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_empty_agent_default_table_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EMPTY_AGENT_DEFAULT_TABLE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_table_name_e table = SYNC_AGENT_DA_TABLE_NAME_MAX;
+
+       da_err = sync_agent_empty_agent_default_table(table);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+               dts_message(api_name, "sync_agent_empty_agent_default_table : %d", da_err);
+       } else {
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_empty_all_agent_default_table_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EMPTY_ALL_AGENT_DEFAULT_TABLE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_empty_all_agent_default_table();
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_empty_all_agent_default_table : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_ITEM_TBL_FROM_SERVICE;
+       sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_fw_account_s *fw_account = NULL;
+       sync_agent_da_folder_s *folder = NULL;
+       int new_account_id = 0;
+       char *folder_id = NULL;
+       char *new_folder_id = NULL;
+
+       account_err = sync_agent_create_fw_account(&fw_account);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       fw_account->email = strdup("1234@gmail.com");
+       fw_account->password = strdup("1234");
+       fw_account->enable = 0;
+       fw_account->access_name = strdup("TC");
+
+       account_err = sync_agent_add_fw_account(fw_account, &new_account_id);
+       if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_fw_account : %d", account_err);
+               dts_fail(api_name);
+       }
+
+       account_id = new_account_id;
+
+       folder_id = sync_agent_generate_folder_luid();
+       if (folder_id == NULL) {
+               dts_message(api_name, "sync_agent_generate_folder_luid");
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       folder->account_id = new_account_id;
+       folder->folder_id = strdup(folder_id);
+       folder->data_store_id = TYPE_CALENDAR;
+       folder->folder_type_id = 0;
+       folder->parent_folder_id = NULL;
+       folder->service_id = strdup("0");
+       folder->access_name = strdup("EventHandler");
+
+       da_err = sync_agent_add_folder(folder, &new_folder_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_construct_item_tbl_from_service(new_account_id, TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_construct_item_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_item_tbl_from_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_ITEM_TBL_FROM_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       int wrong_account_id = -1;
+
+       da_err = sync_agent_construct_item_tbl_from_service(wrong_account_id, TYPE_CALENDAR);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_construct_item_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_FOLDER_TBL_FROM_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_construct_folder_tbl_from_service(TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_construct_folder_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_folder_tbl_from_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_FOLDER_TBL_FROM_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       int wrong_service_type = 2;
+
+       da_err = sync_agent_construct_folder_tbl_from_service(wrong_service_type);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_construct_folder_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_REFRESH_ITEM_TBL_FROM_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_refresh_item_tbl_from_service(account_id, TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_refresh_item_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_refresh_item_tbl_from_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_REFRESH_ITEM_TBL_FROM_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       int wrong_account_id = -1;
+
+       da_err = sync_agent_refresh_item_tbl_from_service(wrong_account_id, TYPE_CALENDAR);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_refresh_item_tbl_from_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_service_change_point_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_SERVICE_CHANGE_POINT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_set_service_change_point(account_id, TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_set_service_change_point : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_obj_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_OBJ;
+       void *result = NULL;
+
+       result = sync_agent_alloc_obj(TYPE_SMS);
+       if (result != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_alloc_obj");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_obj_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+
+       result = sync_agent_alloc_obj(TYPE_SMS);
+       if (result == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_alloc_obj");
+       }
+
+       da_err = sync_agent_free_obj(TYPE_SMS, result);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_obj : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_obj_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+
+       da_err = sync_agent_free_obj(TYPE_SMS, result);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_obj : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_value_to_obj_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_VALUE_TO_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+
+       result = sync_agent_alloc_obj(TYPE_SMS);
+       if (result == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_alloc_obj");
+       }
+
+       result = sync_agent_set_value_to_obj(TYPE_SMS, result, 1, 0, (void *)(1));
+       if (result != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_set_value_to_obj");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_value_to_obj_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_VALUE_TO_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+
+       result = sync_agent_set_value_to_obj(TYPE_SMS, result, 1, 0, (void *)(1));
+       if (result == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_set_value_to_obj");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_value_to_obj_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_VALUE_TO_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+       char *body = strdup("abc");
+       char *return_body = NULL;
+
+       result = sync_agent_alloc_obj(TYPE_SMS);
+       if (result == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_alloc_obj");
+       }
+
+       result = sync_agent_set_value_to_obj(TYPE_SMS, result, 9, 0, (void *)body);
+       if (result == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_set_value_to_obj");
+       }
+
+       return_body = sync_agent_get_value_to_obj(TYPE_SMS, result, 9, 0);
+       if (return_body != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_value_to_obj");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_value_to_obj_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_VALUE_TO_OBJ;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;
+       char *return_body = NULL;
+
+       return_body = sync_agent_get_value_to_obj(TYPE_SMS, result, 9, 0);
+       if (return_body == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_value_to_obj");
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_obj_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_OBJ_INFO;
+
+       sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(TYPE_CALENDAR);
+       if (datastore != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_obj_info");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_obj_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_OBJ_INFO;
+       int wrong_service_type = 4;
+
+       sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(wrong_service_type);
+       if (datastore == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_obj_info");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_obj_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_OBJ_INFO;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(TYPE_CALENDAR);
+       if (datastore == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_obj_info");
+       }
+
+       da_err = sync_agent_free_obj_info(TYPE_CALENDAR, datastore);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_obj : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_obj_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_OBJ_INFO;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 4;
+
+       sync_agent_plugin_object_info_s *datastore = sync_agent_get_obj_info(TYPE_CALENDAR);
+       if (datastore == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_obj_info");
+       }
+
+       da_err = sync_agent_free_obj_info(wrong_service_type, datastore);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_obj : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_changelog_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_changelog_s *sync_agent_changelog = NULL;
+
+       da_err = sync_agent_create_changelog(&sync_agent_changelog);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_changelog_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_update_changelog_query_s query;
+
+       int *item_type_id_list = (int *)calloc(1, sizeof(int));
+       if (item_type_id_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "itemTypeIdList is NULL");
+       }
+
+       item_type_id_list[0] = TYPE_CALENDAR;
+
+       query.option = SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS;
+       query.folder_id_list = NULL;
+       query.folder_id_count = 0;
+       query.item_type_id_list = item_type_id_list;
+       query.item_type_id_count = 1;
+
+       da_err = sync_agent_update_changelog(account_id, &query);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_changelog_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_update_changelog_query_s query;
+
+       int wrong_account_id = -1;
+
+       int *item_type_id_list = (int *)calloc(1, sizeof(int));
+       if (item_type_id_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "itemTypeIdList is NULL");
+       }
+
+       item_type_id_list[0] = TYPE_CALENDAR;
+
+       query.option = SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS;
+       query.folder_id_list = NULL;
+       query.folder_id_count = 0;
+       query.item_type_id_list = item_type_id_list;
+       query.item_type_id_count = 1;
+
+       da_err = sync_agent_update_changelog(wrong_account_id, &query);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_changelog_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_delete_changelog_query_s query;
+
+       query.option = SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_TYPE_ID;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_delete_changelog(account_id, &query);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_changelog_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_delete_changelog_query_s query;
+
+       int wrong_account_id = -1;
+
+       query.option = SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_TYPE_ID;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_delete_changelog(wrong_account_id, &query);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_changelog : %d", da_err);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_changelog_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_changelog_s *sync_agent_changelog = NULL;
+
+       da_err = sync_agent_create_changelog(&sync_agent_changelog);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_changelog : %d", da_err);
+       }
+
+       da_err = sync_agent_get_changelog(account_id, NULL, &sync_agent_changelog);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_changelog_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CHANGELOG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *changelog_list = NULL;
+
+       sync_agent_da_get_changelog_list_query_s get_ch_query;
+       get_ch_query.option = SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID;
+       get_ch_query.account_id = account_id;
+       get_ch_query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_changelog_list(&get_ch_query, &changelog_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_changelog_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_changelog_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CHANGELOG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *changelog_list = NULL;
+
+       int wrong_account_id = -1;
+
+       sync_agent_da_get_changelog_list_query_s get_ch_query;
+       get_ch_query.option = SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID;
+       get_ch_query.account_id = wrong_account_id;
+       get_ch_query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_changelog_list(&get_ch_query, &changelog_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_changelog_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_changelog_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_CHANGELOG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_changelog_s *sync_agent_changelog = NULL;
+
+       da_err = sync_agent_create_changelog(&sync_agent_changelog);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_changelog : %d", da_err);
+       }
+
+       da_err = sync_agent_free_changelog(sync_agent_changelog);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_changelog : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_changelog_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_CHANGELOG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *changelog_list = NULL;
+
+       sync_agent_da_get_changelog_list_query_s get_ch_query;
+       get_ch_query.option = SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID;
+       get_ch_query.account_id = account_id;;
+       get_ch_query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_changelog_list(&get_ch_query, &changelog_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_changelog_list : %d", da_err);
+       }
+
+       da_err = sync_agent_free_changelog_list(changelog_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_changelog_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       config->access_name = "access_name";
+       config->config_id = account_id;
+       config->key = "key";
+       config->value = "config";
+       config->type = "string";
+
+       da_err = sync_agent_add_config(config);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_config_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       da_err = sync_agent_add_config(config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_config_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CONFIG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+       GList *config_list = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       config->access_name = "access_name";
+       config->config_id = account_id;
+       config->key = "key1";
+       config->value = "config1";
+       config->type = "string";
+
+       config_list = g_list_append(config_list, config);
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       config->access_name = "access_name";
+       config->config_id = account_id;
+       config->key = "key2";
+       config->value = "config2";
+       config->type = "string";
+
+       config_list = g_list_append(config_list, config);
+
+       da_err = sync_agent_add_config_list(config_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_config_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_config_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CONFIG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+       GList *config_list = NULL;
+
+       da_err = sync_agent_add_config_list(config_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_config_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       config->access_name = "access_name";
+       config->config_id = account_id;
+       config->key = "key";
+       config->value = "update config";
+       config->type = "string";
+
+       da_err = sync_agent_update_config(config);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_config_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+
+       da_err = sync_agent_update_config(config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *key = "key";
+
+       da_err = sync_agent_delete_config(account_id, key);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_config_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *key = NULL;
+
+       da_err = sync_agent_delete_config(account_id, key);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_is_exist_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_IS_EXIST_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *key = "key";
+       int exist;
+
+       da_err = sync_agent_is_exist_config(account_id, key, &exist);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_is_exist_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_is_exist_config_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_IS_EXIST_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *key = NULL;
+       int exist;
+
+       da_err = sync_agent_is_exist_config(account_id, key, &exist);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_is_exist_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+       char *key = "key2";
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       da_err = sync_agent_get_config(account_id, key, &config);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_config_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONFIG;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_config_s *config = NULL;
+       char *key = NULL;
+
+       da_err = sync_agent_create_config(&config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_config : %d", da_err);
+       }
+
+       da_err = sync_agent_get_config(account_id, key, &config);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_config : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_config_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONFIG_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *config_list = NULL;
+
+       da_err = sync_agent_get_config_list(account_id, &config_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_config_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+       char *folder_id = NULL;
+       char *new_folder_id = NULL;
+
+       folder_id = sync_agent_generate_folder_luid();
+       if (folder_id == NULL) {
+               dts_message(api_name, "sync_agent_generate_folder_luid");
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       folder->account_id = account_id;
+       folder->folder_id = strdup(folder_id);
+       folder->data_store_id = TYPE_CALENDAR;
+       folder->folder_type_id = 0;
+       folder->parent_folder_id = NULL;
+       folder->service_id = strdup("0");
+       folder->access_name = strdup("EventHandler");
+
+       da_err = sync_agent_add_folder(folder, &new_folder_id);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+       char *new_folder_id = NULL;
+
+       da_err = sync_agent_add_folder(folder, &new_folder_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+       sync_agent_da_folder_s *get_folder = NULL;
+       char *folder_id = NULL;
+       char *new_folder_id = NULL;
+
+       folder_id = sync_agent_generate_folder_luid();
+       if (folder_id == NULL) {
+               dts_message(api_name, "sync_agent_generate_folder_luid");
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       folder->account_id = account_id;
+       folder->folder_id = strdup(folder_id);
+       folder->data_store_id = TYPE_CALENDAR;
+       folder->folder_type_id = 0;
+       folder->parent_folder_id = NULL;
+       folder->service_id = strdup("0");
+       folder->access_name = strdup("EventHandler");
+
+       da_err = sync_agent_add_folder(folder, &new_folder_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+
+       da_err = sync_agent_create_folder(&get_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_get_folder(folder_id, &get_folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *get_folder = NULL;
+       char *folder_id = NULL;
+
+       da_err = sync_agent_get_folder(folder_id, &get_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_list = NULL;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = TYPE_CALENDAR;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       sync_agent_da_get_folder_list_query_s foler_list_query;
+       foler_list_query.option = SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING;
+       foler_list_query.account_id = account_id;
+       foler_list_query.folder_id = folder_id;
+
+       da_err = sync_agent_get_folder_list(&foler_list_query, &folder_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_list = NULL;
+
+       sync_agent_da_get_folder_list_query_s foler_list_query;
+       foler_list_query.option = SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING;
+       foler_list_query.account_id = account_id;
+       foler_list_query.folder_id = NULL;
+
+       da_err = sync_agent_get_folder_list(&foler_list_query, &folder_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_id_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = 0;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_folder_id_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FOLDER_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s *folder_id_list_query = NULL;
+
+       da_err = sync_agent_get_folder_id_list(folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+       }
+
+       da_err = sync_agent_free_folder(folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *folder = NULL;
+
+       da_err = sync_agent_free_folder(folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_list = NULL;
+       char *folder_id = NULL;
+
+       sync_agent_da_folder_s *folder = NULL;
+       char *new_folder_id = NULL;
+
+       folder_id = sync_agent_generate_folder_luid();
+       if (folder_id == NULL) {
+               dts_message(api_name, "sync_agent_generate_folder_luid");
+               dts_fail(api_name);
+       }
+
+       da_err = sync_agent_create_folder(&folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_message(api_name, "sync_agent_create_folder : %d", da_err);
+               dts_fail(api_name);
+       }
+
+       folder->account_id = account_id;
+       folder->folder_id = strdup(folder_id);
+       folder->data_store_id = TYPE_CALENDAR;
+       folder->folder_type_id = 0;
+       folder->parent_folder_id = NULL;
+       folder->service_id = strdup("0");
+       folder->access_name = strdup("EventHandler");
+
+       da_err = sync_agent_add_folder(folder, &new_folder_id);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_folder : %d", da_err);
+       }
+
+       sync_agent_da_get_folder_list_query_s foler_list_query;
+       foler_list_query.option = SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING;
+       foler_list_query.account_id = account_id;
+       foler_list_query.folder_id = new_folder_id;
+
+       da_err = sync_agent_get_folder_list(&foler_list_query, &folder_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_list : %d", da_err);
+       }
+
+       da_err = sync_agent_free_folder_list(folder_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_list = NULL;
+
+       da_err = sync_agent_free_folder_list(folder_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_id_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = 0;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       da_err = sync_agent_free_folder_id(folder_id);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_id_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *folder_id = NULL;
+
+       da_err = sync_agent_free_folder_id(folder_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_id_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_list = NULL;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = 0;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       da_err = sync_agent_free_folder_id_list(folder_id_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_folder_id_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FOLDER_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+
+       da_err = sync_agent_free_folder_id_list(folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_folder_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_CREATE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_ADD_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       char **item_luid_list = NULL;
+       int item_count = 2;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+
+       sync_agent_item->item_id = item_luid_list[0];
+       sync_agent_item->data_store_id = TYPE_CALENDAR;
+       sync_agent_item->account_id = account_id;
+       sync_agent_item->folder_id = g_strdup("0");
+       sync_agent_item->service_id = item_luid_list[1];
+       sync_agent_item->access_name = g_strdup("DACI_ChangeLog");
+
+       da_err = sync_agent_add_item(sync_agent_item, &item_id, true);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_ADD_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       char *item_id = NULL;
+
+       da_err = sync_agent_add_item(sync_agent_item, &item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_UPDATE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_update_item(item_id, true);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_UPDATE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *item_id = NULL;
+
+       da_err = sync_agent_update_item(item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_DELETE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       char *item_id = NULL;
+       char **item_luid_list = NULL;
+       int item_count = 2;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+
+       sync_agent_item->item_id = item_luid_list[0];
+       sync_agent_item->data_store_id = TYPE_CALENDAR;
+       sync_agent_item->account_id = account_id;
+       sync_agent_item->folder_id = g_strdup("0");
+       sync_agent_item->service_id = item_luid_list[1];
+       sync_agent_item->access_name = g_strdup("DACI_ChangeLog");
+
+       da_err = sync_agent_add_item(sync_agent_item, &item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_item : %d", da_err);
+       }
+
+       da_err = sync_agent_delete_item(item_id, true);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_DELETE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *item_id = NULL;
+
+       da_err = sync_agent_delete_item(item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_delete_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_QUERY_DELETE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       char *item_id = NULL;
+       char **item_luid_list = NULL;
+       int item_count = 2;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+
+       sync_agent_item->item_id = item_luid_list[0];
+       sync_agent_item->data_store_id = TYPE_CALENDAR;
+       sync_agent_item->account_id = account_id;
+       sync_agent_item->folder_id = g_strdup("0");
+       sync_agent_item->service_id = item_luid_list[1];
+       sync_agent_item->access_name = g_strdup("DACI_ChangeLog");
+
+       da_err = sync_agent_add_item(sync_agent_item, &item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_item : %d", da_err);
+       }
+
+       sync_agent_da_delete_item_query_s query_item;
+       query_item.option = SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID;
+       query_item.item_type_id = TYPE_CALENDAR;
+       query_item.account_id = account_id;
+
+       da_err = sync_agent_query_delete_item(&query_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_query_delete_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_delete_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_QUERY_DELETE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_delete_item_query_s *query_item = NULL;
+
+       da_err = sync_agent_query_delete_item(query_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_query_delete_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       sync_agent_da_item_s *get_sync_agent_item = NULL;
+       char *item_id = NULL;
+       char **item_luid_list = NULL;
+       int item_count = 2;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+       service_id = item_luid_list[1];
+
+       sync_agent_item->item_id = item_luid_list[0];
+       sync_agent_item->data_store_id = TYPE_CALENDAR;
+       sync_agent_item->account_id = account_id;
+       sync_agent_item->folder_id = g_strdup("0");
+       sync_agent_item->service_id = item_luid_list[1];
+       sync_agent_item->access_name = g_strdup("DACI_ChangeLog");
+
+       da_err = sync_agent_add_item(sync_agent_item, &item_id, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_item : %d", da_err);
+       }
+
+       da_err = sync_agent_create_item(&get_sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+
+       da_err = sync_agent_get_item(item_id, &get_sync_agent_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+       char *item_id = NULL;
+
+       da_err = sync_agent_get_item(item_id, &sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_list_p(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_list = NULL;
+
+       sync_agent_da_get_item_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_list(account_id, &query, &item_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_list_n(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_list = NULL;
+
+       sync_agent_da_get_item_list_query_s *query = NULL;
+
+       da_err = sync_agent_get_item_list(account_id, query, &item_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_id_p(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *guid = NULL;
+
+       sync_agent_da_get_item_id_query_s query;
+       query.service_id = service_id;
+       query.account_id = 1;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_id(&query, &guid);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_id_n(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *guid = NULL;
+
+       sync_agent_da_get_item_id_query_s *query = NULL;
+
+       da_err = sync_agent_get_item_id(query, &guid);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_id_list_p(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_id_list = NULL;
+
+       sync_agent_da_get_item_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_id_list(&query, &item_id_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_id_list_n(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_id_list = NULL;
+
+       sync_agent_da_get_item_id_list_query_s *query = NULL;
+
+       da_err = sync_agent_get_item_id_list(query, &item_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_p(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+
+       da_err = sync_agent_create_item(&sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_item : %d", da_err);
+       }
+
+       da_err = sync_agent_free_item(sync_agent_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_n(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *sync_agent_item = NULL;
+
+       da_err = sync_agent_free_item(sync_agent_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_list_p(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_list = NULL;
+
+       sync_agent_da_get_item_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_list(account_id, &query, &item_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_list : %d", da_err);
+       }
+
+       da_err = sync_agent_free_item_list(item_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_list_n(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_list = NULL;
+
+       da_err = sync_agent_free_item_list(item_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_id_p(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *item_id = NULL;
+
+       sync_agent_da_get_item_id_query_s query;
+       query.service_id = service_id;
+       query.account_id = 1;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_id(&query, &item_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id : %d", da_err);
+       }
+
+       da_err = sync_agent_free_item_id(item_id);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_id_n(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *item_id = NULL;
+
+       da_err = sync_agent_free_item_id(item_id);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_id : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_id_list_p(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_id_list = NULL;
+
+       sync_agent_da_get_item_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_item_id_list(&query, &item_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_id_list : %d", da_err);
+       }
+
+       da_err = sync_agent_free_item_id_list(item_id_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_item_id_list_n(void)
+{
+       char *api_name = API_SYNC_AGENT_FREE_ITEM_ID_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *item_id_list = NULL;
+
+       da_err = sync_agent_free_item_id_list(item_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_item_id_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_item_count_p(void)
+{
+       char *api_name = API_SYNC_AGENT_GET_ITEM_COUNT;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int item_count;
+
+       da_err = sync_agent_get_item_count(TYPE_CALENDAR, &item_count);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_item_count : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_last_anchor_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *sync_agent_last_anchor = NULL;
+
+       da_err = sync_agent_create_last_anchor(&sync_agent_last_anchor);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_last_anchor_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s lastAnchor_daci;
+
+       lastAnchor_daci.account_id = account_id;
+       lastAnchor_daci.data_store_id = TYPE_CALENDAR;
+       lastAnchor_daci.last_anchor_server = NULL;
+       lastAnchor_daci.last_anchor_client = NULL;
+       lastAnchor_daci.access_name = "Engine";
+
+       da_err = sync_agent_add_last_anchor(&lastAnchor_daci);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_last_anchor_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *lastAnchor_daci = NULL;
+
+       da_err = sync_agent_add_last_anchor(lastAnchor_daci);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_last_anchor_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s lastAnchor_daci;
+
+       lastAnchor_daci.account_id = account_id;
+       lastAnchor_daci.data_store_id = TYPE_CALENDAR;
+       lastAnchor_daci.last_anchor_server = "1234";
+       lastAnchor_daci.last_anchor_client = "4567";
+       lastAnchor_daci.access_name = "Engine";
+
+       da_err = sync_agent_update_last_anchor(&lastAnchor_daci);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_last_anchor_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *lastAnchor_daci = NULL;
+
+       da_err = sync_agent_update_last_anchor(lastAnchor_daci);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_last_anchor_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_LAST_ANCHOR_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *anchor_list = NULL;
+
+       sync_agent_da_get_last_anchor_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_last_anchor_list(&query, &anchor_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_last_anchor_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_last_anchor_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_LAST_ANCHOR_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *anchor_list = NULL;
+       sync_agent_da_get_last_anchor_list_query_s *query = NULL;
+
+       da_err = sync_agent_get_last_anchor_list(&query, &anchor_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_last_anchor_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_last_anchor_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *sync_agent_last_anchor = NULL;
+
+       da_err = sync_agent_create_last_anchor(&sync_agent_last_anchor);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_last_anchor : %d", da_err);
+       }
+
+       da_err = sync_agent_free_last_anchor(sync_agent_last_anchor);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_last_anchor_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_LAST_ANCHOR;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *sync_agent_last_anchor = NULL;
+
+       da_err = sync_agent_free_last_anchor(sync_agent_last_anchor);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_mapping_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       da_err = sync_agent_create_mapping(&sync_agent_mapping);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_mapping_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       da_err = sync_agent_create_mapping(&sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+
+       sync_agent_mapping->account_id = account_id;
+       sync_agent_mapping->data_store_id = TYPE_CALENDAR;
+       sync_agent_mapping->luid = "1234";
+       sync_agent_mapping->guid = "5678";
+       sync_agent_mapping->access_name = strdup("SA");
+
+       da_err = sync_agent_add_mapping(sync_agent_mapping);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_mapping_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       da_err = sync_agent_add_mapping(sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mapping_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_da_delete_mapping_query_s query;
+       query.option = SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID;
+       query.account_id = account_id;
+       query.luid = "1234";
+
+       da_err = sync_agent_delete_mapping(&query);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mapping_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_da_delete_mapping_query_s *query = NULL;
+
+       da_err = sync_agent_delete_mapping(query);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mapping_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+       sync_agent_da_mapping_s *get_sync_agent_mapping = NULL;
+
+       da_err = sync_agent_create_mapping(&sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+
+       sync_agent_mapping->account_id = account_id;
+       sync_agent_mapping->data_store_id = TYPE_CALENDAR;
+       sync_agent_mapping->luid = "1234";
+       sync_agent_mapping->guid = "5678";
+       sync_agent_mapping->access_name = strdup("SA");
+
+       da_err = sync_agent_add_mapping(sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_mapping : %d", da_err);
+       }
+
+       da_err = sync_agent_create_mapping(&get_sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+
+       sync_agent_da_get_mapping_query_s query;
+       query.account_id = account_id;
+       query.luid = "1234";
+
+       da_err = sync_agent_get_mapping(&query, &get_sync_agent_mapping);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mapping_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       sync_agent_da_get_mapping_query_s *query = NULL;
+
+       da_err = sync_agent_get_mapping(&query, &sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mapping_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAPPING_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *mapping_list = NULL;
+
+       sync_agent_da_get_mapping_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
+       query.account_id = account_id;
+
+       da_err = sync_agent_get_mapping_list(&query, &mapping_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_mapping_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mapping_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAPPING_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *mapping_list = NULL;
+
+       sync_agent_da_get_mapping_list_query_s *query = NULL;
+
+       da_err = sync_agent_get_mapping_list(query, &mapping_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_mapping_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mapping_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       da_err = sync_agent_create_mapping(&sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_last_anchor : %d", da_err);
+       }
+
+       da_err = sync_agent_free_mapping(sync_agent_mapping);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mapping_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MAPPING;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_mapping_s *sync_agent_mapping = NULL;
+
+       da_err = sync_agent_free_mapping(sync_agent_mapping);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_mapping : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mapping_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MAPPING_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *mapping_list = NULL;
+
+       sync_agent_da_get_mapping_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
+       query.account_id = account_id;
+
+       da_err = sync_agent_get_mapping_list(&query, &mapping_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_mapping_list : %d", da_err);
+       }
+
+       da_err = sync_agent_free_mapping_list(mapping_list);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_mapping_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mapping_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MAPPING_LIST;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *mapping_list = NULL;
+
+       da_err = sync_agent_free_mapping_list(mapping_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_mapping_list : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_is_exist_mapping_by_account_id_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_IS_EXIST_MAPPING_BY_ACCOUNT_ID;
+       int exist = 0;
+
+       exist = sync_agent_is_exist_mapping_by_account_id(account_id);
+       if (exist >= 0) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_mapping_list");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_open_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_open_service(TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_open_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_open_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_open_service(wrong_service_type);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_open_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_close_service(TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_close_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_close_service(wrong_service_type);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_close_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_begin_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_BEGIN_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_begin_service(TYPE_CALENDAR);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_begin_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_begin_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_BEGIN_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_begin_service(wrong_service_type);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_begin_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_end_service_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_END_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_end_service(TYPE_CALENDAR, true);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_end_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_end_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_END_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_end_service(wrong_service_type, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_end_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_service_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_SERVICE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_folder_s *service_folder = NULL;
+
+       da_err = sync_agent_create_service_folder(&service_folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       da_err = sync_agent_free_service_item(service_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_service_item_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+
+       da_err = sync_agent_free_service_item(service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_service_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_SERVICE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_folder_s *service_folder = NULL;
+
+       da_err = sync_agent_create_service_folder(&service_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_folder : %d", da_err);
+       }
+
+       da_err = sync_agent_free_service_folder(service_folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_service_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_service_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_SERVICE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_folder_s *service_folder = NULL;
+
+       da_err = sync_agent_free_service_folder(service_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_free_service_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+       sync_agent_da_service_item_s *service_item = NULL;
+       char *folder_id = NULL;
+       char *data = "BEGIN:VCALENDAR\r\n\
+VERSION:1.0\r\n\
+TZ:+0900\r\n\
+DAYLIGHT:FALSE\r\n\
+BEGIN:VEVENT\r\n\
+SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=EC=A0=90=EC=8B=AC\r\n\
+LOCATION:123\r\n\
+CLASS:PUBLIC\r\n\
+DTSTART:20121210T020000Z\r\n\
+DTEND:20121210T030000Z\r\n\
+AALARM:20121210T015500Z;;0;\r\n\
+X-FUNAMBOL-ALLDAY:0\r\n\
+END:VEVENT\r\n\
+END:VCALENDAR";
+
+       char **item_luid_list = NULL;
+       int item_count = 1;
+
+       sync_agent_da_get_folder_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+       query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       service_item->item_id = item_luid_list[0];
+       service_item->content_type = TYPE_CALENDAR;
+       service_item->account_id = account_id;
+       service_item->folder_id = g_strdup(folder_id);
+       service_item->access_name = g_strdup("Engine");
+       service_item->data = g_strdup(data);
+
+       sync_agent_begin_service(TYPE_CALENDAR);
+       da_err = sync_agent_add_service_item(service_item, &item_id, false);
+       sync_agent_end_service(TYPE_CALENDAR, true);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_service_item_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+       char *item_id = NULL;
+
+       da_err = sync_agent_add_service_item(service_item, &item_id, false);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+       sync_agent_da_service_item_s *service_item = NULL;
+       char *folder_id = NULL;
+       char *data = "BEGIN:VCALENDAR\r\n\
+VERSION:1.0\r\n\
+TZ:+0900\r\n\
+DAYLIGHT:FALSE\r\n\
+BEGIN:VEVENT\r\n\
+SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=EC=A0=90=EC=8B=AC\r\n\
+LOCATION:123\r\n\
+CLASS:PUBLIC\r\n\
+DTSTART:20121210T020000Z\r\n\
+DTEND:20121210T030000Z\r\n\
+AALARM:20121210T015500Z;;0;\r\n\
+X-FUNAMBOL-ALLDAY:0\r\n\
+END:VEVENT\r\n\
+END:VCALENDAR";
+
+       sync_agent_da_get_folder_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+       query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       service_item->item_id = item_id;
+       service_item->content_type = TYPE_CALENDAR;
+       service_item->account_id = account_id;
+       service_item->folder_id = g_strdup(folder_id);
+       service_item->access_name = g_strdup("Engine");
+       service_item->data = g_strdup(data);
+
+       da_err = sync_agent_update_service_item(service_item, item_id, false);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_service_item_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+       char *item_id = NULL;
+
+       da_err = sync_agent_update_service_item(service_item, item_id, false);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_update_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_delete_service_item(item_id, false);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_service_item_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *item_id = NULL;
+
+       da_err = sync_agent_delete_service_item(item_id, false);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_delete_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_delete_service_items_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_DELETE_SERVICE_ITEMS;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_da_delete_service_item_query_s query;
+       query.content_type = TYPE_CALENDAR;
+       query.account_id = account_id;
+
+       da_err = sync_agent_query_delete_service_items(&query);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_query_delete_service_items : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_query_delete_service_items_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_DELETE_SERVICE_ITEMS;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_delete_service_item_query_s *query = NULL;
+
+       da_err = sync_agent_query_delete_service_items(query);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_query_delete_service_items : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_item_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+       sync_agent_da_service_item_s *get_service_item = NULL;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+       char *data = "BEGIN:VCALENDAR\r\n\
+VERSION:1.0\r\n\
+TZ:+0900\r\n\
+DAYLIGHT:FALSE\r\n\
+BEGIN:VEVENT\r\n\
+SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=EC=A0=90=EC=8B=AC\r\n\
+LOCATION:123\r\n\
+CLASS:PUBLIC\r\n\
+DTSTART:20121210T020000Z\r\n\
+DTEND:20121210T030000Z\r\n\
+AALARM:20121210T015500Z;;0;\r\n\
+X-FUNAMBOL-ALLDAY:0\r\n\
+END:VEVENT\r\n\
+END:VCALENDAR";
+
+       char **item_luid_list = NULL;
+       int item_count = 1;
+       char *item_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+       query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       service_item->item_id = item_luid_list[0];
+       service_item->content_type = TYPE_CALENDAR;
+       service_item->account_id = account_id;
+       service_item->folder_id = g_strdup(folder_id);
+       service_item->access_name = g_strdup("Engine");
+       service_item->data = g_strdup(data);
+
+       sync_agent_begin_service(TYPE_CALENDAR);
+       da_err = sync_agent_add_service_item(service_item, &item_id, false);
+       sync_agent_end_service(TYPE_CALENDAR, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_service_item : %d", da_err);
+       }
+
+       da_err = sync_agent_create_service_item(&get_service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       da_err = sync_agent_get_service_item(item_id, &get_service_item);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_item_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ITEM;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_item_s *service_item = NULL;
+       char *item_id = NULL;
+
+       da_err = sync_agent_get_service_item(item_id, &service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_item : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_service_folder_s *service_folder = NULL;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_ITEM_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+
+       da_err = sync_agent_get_folder_id_list(&query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       da_err = sync_agent_create_service_folder(&service_folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_folder : %d", da_err);
+       }
+
+       da_err = sync_agent_get_service_folder(folder_id, service_folder);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *folder_id = NULL;
+       sync_agent_da_service_folder_s *service_folder = NULL;
+
+       da_err = sync_agent_create_service_folder(&service_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_folder : %d", da_err);
+       }
+
+       da_err = sync_agent_get_service_folder(folder_id, service_folder);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_folder : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_execute_service_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_SERVICE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       void *result = NULL;;
+       void *values = NULL;
+
+       da_err = sync_agent_execute_service(TYPE_SMS, 1, "send_msg", values, &result);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_execute_service : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT;
+       int count = 0;
+
+       count = sync_agent_get_used_service_item_count(TYPE_CALENDAR);
+       if (count >= 0) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_used_service_item_count");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT;
+       int wrong_service_type = 5;
+       int count = 0;
+
+       count = sync_agent_get_used_service_item_count(wrong_service_type);
+       if (count < 0) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_used_service_item_count");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT_FOR_FOLDER;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+       int item_count = 0;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = TYPE_CALENDAR;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       item_count = sync_agent_get_used_service_item_count_for_folder(TYPE_CALENDAR, account_id, folder_id);
+       if (item_count >= 0) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_used_service_item_count_for_folder");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_used_service_item_count_for_folder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USED_SERVICE_ITEM_COUNT_FOR_FOLDER;
+       char *folder_id = NULL;
+       int item_count = 0;
+
+       item_count = sync_agent_get_used_service_item_count_for_folder(TYPE_CALENDAR, account_id, folder_id);
+       if (item_count < 0) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_used_service_item_count_for_folder");
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_backup_service_items_to_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_BACKUP_SERVICE_ITEMS_TO_FILE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_backup_service_items_to_file(TYPE_BOOKMARK, 0, &saved_file_path);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_backup_service_items_to_file : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_backup_service_items_to_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_BACKUP_SERVICE_ITEMS_TO_FILE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *saved_file_path = NULL;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_backup_service_items_to_file(wrong_service_type, 0, &saved_file_path);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_backup_service_items_to_file : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_restore_service_items_from_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RESTORE_SERVICE_ITEMS_FROM_FILE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+       da_err = sync_agent_restore_service_items_from_file(TYPE_BOOKMARK, 0, saved_file_path);
+       if (da_err == SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_restore_service_items_from_file : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_restore_service_items_from_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RESTORE_SERVICE_ITEMS_FROM_FILE;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int wrong_service_type = 5;
+
+       da_err = sync_agent_restore_service_items_from_file(wrong_service_type, 0, saved_file_path);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_restore_service_items_from_file : %d", da_err);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_item_id_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ITEM_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       char *service_item_id = NULL;
+       sync_agent_da_service_item_s *service_item = NULL;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+       char *data = "BEGIN:VCALENDAR\r\n\
+VERSION:1.0\r\n\
+TZ:+0900\r\n\
+DAYLIGHT:FALSE\r\n\
+BEGIN:VEVENT\r\n\
+SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=EC=A0=90=EC=8B=AC\r\n\
+LOCATION:123\r\n\
+CLASS:PUBLIC\r\n\
+DTSTART:20121210T020000Z\r\n\
+DTEND:20121210T030000Z\r\n\
+AALARM:20121210T015500Z;;0;\r\n\
+X-FUNAMBOL-ALLDAY:0\r\n\
+END:VEVENT\r\n\
+END:VCALENDAR";
+
+       char **item_luid_list = NULL;
+       int item_count = 1;
+       char *item_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s query;
+       query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       query.account_id = account_id;
+       query.item_type_id = TYPE_CALENDAR;
+       query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid : %d", da_err);
+       }
+
+       da_err = sync_agent_create_service_item(&service_item);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_create_service_item : %d", da_err);
+       }
+
+       service_item->item_id = item_luid_list[0];
+       service_item->content_type = TYPE_CALENDAR;
+       service_item->account_id = account_id;
+       service_item->folder_id = g_strdup(folder_id);
+       service_item->access_name = g_strdup("Engine");
+       service_item->data = g_strdup(data);
+
+       sync_agent_begin_service(TYPE_CALENDAR);
+       da_err = sync_agent_add_service_item(service_item, &item_id, false);
+       sync_agent_end_service(TYPE_CALENDAR, true);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_add_service_item : %d", da_err);
+       }
+
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       if (service_item_id != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_item_id");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_item_id_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_ITEM_ID;
+       char *service_item_id = NULL;
+       char *item_id = NULL;
+
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       if (service_item_id == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_item_id");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_folder_id_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER_ID;
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       GList *folder_id_list = NULL;
+       char *folder_id = NULL;
+       char *service_folder_id = NULL;
+
+       sync_agent_da_get_folder_id_list_query_s folder_id_list_query;
+       folder_id_list_query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+       folder_id_list_query.account_id = account_id;
+       folder_id_list_query.item_type_id = TYPE_CALENDAR;
+       folder_id_list_query.folder_type_id = 0;
+
+       da_err = sync_agent_get_folder_id_list(&folder_id_list_query, &folder_id_list);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_folder_id_list : %d", da_err);
+       }
+
+       if (g_list_length(folder_id_list) > 0) {
+               GList *iter = g_list_nth(folder_id_list, 0);
+               folder_id = (char *)(iter->data);
+       }
+
+       service_folder_id = sync_agent_get_service_folder_id(folder_id);
+       if (service_folder_id != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_folder_id");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_folder_id_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_FOLDER_ID;
+       char *folder_id = NULL;
+       char *service_folder_id = NULL;
+
+       service_folder_id = sync_agent_get_service_folder_id(folder_id);
+       if (service_folder_id == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_get_service_folder_id");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_generate_item_luid_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GENERATE_ITEM_LUID;
+       char **item_luid_list = NULL;
+       int item_count = 10;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_generate_item_luid_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GENERATE_ITEM_LUID;
+       char **item_luid_list = NULL;
+       int item_count = 0;
+
+       item_luid_list = sync_agent_generate_item_luid(1, item_count);
+       if (item_luid_list == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_item_luid");
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_generate_folder_luid_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GENERATE_FOLDER_LUID;
+       char *folder_id = NULL;
+
+       folder_id = sync_agent_generate_folder_luid();
+       if (folder_id != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_fail(api_name);
+               dts_message(api_name, "sync_agent_generate_folder_luid");
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_device.c b/TC/testcase/utc_sync_agent_framework_device.c
new file mode 100755 (executable)
index 0000000..b59bc9d
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+
+#define API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION               "sync_agent_execute_dev_function"
+#define API_NAME_SYNC_AGENT_GET_DEVINFO                                "sync_agent_get_devinfo"
+
+////////////////////////////////////////executor.h//////////////////////////////////////////////
+
+static void utc_sync_agent_framework_sync_agent_execute_dev_function_p(void);
+static void utc_sync_agent_framework_sync_agent_execute_dev_function_n(void);
+
+////////////////////////////////////////information.h//////////////////////////////////////////////
+
+static void utc_sync_agent_framework_sync_agent_get_devinfo_p(void);
+static void utc_sync_agent_framework_sync_agent_get_devinfo_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_execute_dev_function_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_execute_dev_function_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_devinfo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_devinfo_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       } else {
+               dts_pass(API_NAME_SYNC_START_UP);
+       }
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_execute_dev_function_p(void)
+{
+       sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION;
+       int memory_type = 0;
+       char *function_name = NULL;
+
+       function_name = "fota_flag";
+
+       err = sync_agent_execute_dev_function(2, function_name, 1, memory_type);
+       if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               dts_message(api_name, "sync_agent_execute_dev_function : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_execute_dev_function_n(void)
+{
+       sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION;
+       int memory_type = 0;
+       char *function_name = NULL;
+
+       err = sync_agent_execute_dev_function(2, function_name, 1, memory_type);
+       if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_execute_dev_function : %d", err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_devinfo_p(void)
+{
+       sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_DEVINFO;
+
+       int device_plugin_id = 0;
+       char *info_name = NULL;
+       char *value = NULL;
+
+       device_plugin_id = 2;
+       info_name = "FOTADownDir";
+
+       err = sync_agent_get_devinfo(device_plugin_id, info_name, &value);
+       if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_devinfo : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_devinfo_n(void)
+{
+       sync_agent_dev_return_e err = SYNC_AGENT_ACC_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_DEVINFO;
+
+       int device_plugin_id = 0;
+       char *info_name = NULL;
+       char *value = NULL;
+
+       device_plugin_id = 2;
+
+       err = sync_agent_get_devinfo(device_plugin_id, info_name, &value);
+       if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_devinfo : %d", err);
+               dts_fail(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_device_manager.c b/TC/testcase/utc_sync_agent_framework_device_manager.c
new file mode 100755 (executable)
index 0000000..7efa207
--- /dev/null
@@ -0,0 +1,1966 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+
+///////////////////////////////////mo_accessor.h//////////////////////////////////////////
+#define API_NAME_SYNC_AGENT_CREATE_MO_ITEM     "sync_agent_create_mo_item"
+#define API_NAME_SYNC_AGENT_ADD_MO_ITEM                "sync_agent_add_mo_item"
+#define API_NAME_SYNC_AGENT_UPDATE_MO_ITEM     "sync_agent_update_mo_item"
+#define API_NAME_SYNC_AGENT_DELETE_MO_ITEM     "sync_agent_delete_mo_item"
+#define API_NAME_SYNC_AGENT_DELETE_MO_TREE_ITEM        "sync_agent_delete_mo_tree_item"
+#define API_NAME_SYNC_AGENT_GET_MO_ITEM        "sync_agent_get_mo_item"
+#define API_NAME_SYNC_AGENT_GET_MO_ITEMS       "sync_agent_get_mo_items"
+#define API_NAME_SYNC_AGENT_QUERY_MO_ITEM "sync_agent_query_mo_item"
+#define API_NAME_SYNC_AGENT_FREE_MO_ITEM       "sync_agent_free_mo_item"
+#define API_NAME_SYNC_AGENT_CREATE_MO_ACC_ITEM "sync_agent_create_mo_acc_item"
+#define API_NAME_SYNC_AGENT_UPDATE_MO_ACC_ITEM "sync_agent_update_mo_acc_item"
+#define API_NAME_SYNC_AGENT_GET_MO_ACC_ITEM    "sync_agent_get_mo_acc_item"
+#define API_NAME_SYNC_AGENT_FREE_MO_ACC_ITEM   "sync_agent_free_mo_acc_item"
+#define API_NAME_SYNC_AGENT_INITIALIZE                                 "sync_agent_initialize"
+#define API_NAME_SYNC_AGENT_OPEN                                               "sync_agent_open"
+#define API_NAME_SYNC_AGENT_CLOSE                                              "sync_agent_close"
+#define API_NAME_SYNC_AGENT_BEGIN_TRANSACTION_MO       "sync_agent_begin_transaction_mo"
+#define API_NAME_SYNC_AGENT_END_TRANSACTION_MO                 "sync_agent_end_transaction_mo"
+#define API_NAME_SYNC_AGENT_CONSTRUCT_MO_TABLE                 "sync_agent_construct_mo_table"
+#define API_NAME_SYNC_AGENT_UPTODATE_MO_TABLE          "sync_agent_uptodate_mo_table"
+#define API_NAME_SYNC_AGENT_DELETE_ALL_MO_TABLE                "sync_agent_delete_all_mo_table"
+#define API_NAME_SYNC_AGENT_GET_SERVERINFO                     "sync_agent_get_serverinfo"
+#define API_NAME_SYNC_AGENT_FREE_SERVERINFO                    "sync_agent_free_serverinfo"
+#define API_NAME_SYNC_AGENT_GET_SERVERID                               "sync_agent_get_serverid"
+#define API_NAME_SYNC_AGENT_GET_ROOT_PATH                              "sync_agent_get_root_path"
+#define API_NAME_SYNC_AGENT_GET_SERVER_TYPE                    "sync_agent_get_server_type"
+#define API_NAME_SYNC_AGENT_IS_EXIST_MO                                "sync_agent_is_exist_mo"
+#define API_NAME_SYNC_AGENT_GET_MO_TYPE                                "sync_agent_get_mo_type"
+#define API_NAME_SYNC_AGENT_CHECK_ACL_VALUE                            "sync_agent_check_acl_value"
+#define API_NAME_SYNC_AGENT_DESCENDANT_MO_TREE                 "sync_agent_descendant_mo_tree"
+#define API_NAME_SYNC_AGENT_TRAVERSE_MO_TREE_PREORDER  "sync_agent_traverse_mo_tree_preorder"
+
+#define API_NAME_SYNC_AGENT_EXPORT_TNDS_STREAM                 "sync_agent_export_tnds_stream"
+#define API_NAME_SYNC_AGENT_IMPORT_TNDS_STREAM                 "sync_agent_import_tnds_stream"
+
+///////////////////////////////////mo_executor.h//////////////////////////////////////////
+#define API_NAME_SYNC_AGENT_EXECUTE_MO_EXT                     "sync_agent_execute_mo_ext"
+
+///////////////////////////////////interface.h//////////////////////////////////////////
+#define API_NAME_SYNC_AGENT_START_MDM_SERVICE                  "sync_agent_start_mdm_service"
+#define API_NAME_SYNC_AGENT_STOP_MDM_SERVICE                   "sync_agent_stop_mdm_service"
+#define API_NAME_SYNC_AGENT_GET_MDM_SERVICE                    "sync_agent_get_mdm_service"
+#define API_NAME_SYNC_AGENT_SET_MDM_SERVICE                    "sync_agent_set_mdm_service"
+#define API_NAME_SYNC_AGENT_EXECUTE_MDM_SERVICE                "sync_agent_execute_mdm_service"
+
+#define TNDS_SAMPLE_FILE "../../../testcase/fw-test-file/tnds_sample.txt"
+
+static void utc_sync_agent_framework_sync_agent_create_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_add_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_add_mo_item_n(void);
+static void utc_sync_agent_framework_sync_agent_update_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_update_mo_item_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_mo_item_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_mo_tree_item_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_mo_tree_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_items_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_items_n(void);
+static void utc_sync_agent_framework_sync_agent_query_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_qyery_mo_item_n(void);
+static void utc_sync_agent_framework_sync_agent_free_mo_item_p(void);
+static void utc_sync_agent_framework_sync_agent_free_mo_item_list_p(void);
+static void utc_sync_agent_framework_sync_agent_create_mo_acc_item_p(void);
+static void utc_sync_agent_framework_sync_agent_update_mo_acc_item_p(void);
+static void utc_sync_agent_framework_sync_agent_update_mo_acc_item_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_acc_item_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_acc_item_n(void);
+static void utc_sync_agent_framework_sync_agent_free_mo_acc_item_p(void);
+
+static void utc_sync_agent_framework_sync_agent_initialize_p(void);
+static void utc_sync_agent_framework_sync_agent_initialize_n(void);
+
+static void utc_sync_agent_framework_sync_agent_construct_mo_table_p(void);
+static void utc_sync_agent_framework_sync_agent_construct_mo_table_n(void);
+
+static void utc_sync_agent_framework_sync_agent_uptodate_mo_table_p(void);
+static void utc_sync_agent_framework_sync_agent_uptodate_mo_table_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_all_mo_table_p(void);
+
+static void utc_sync_agent_framework_sync_agent_get_serverinfo_p(void);
+static void utc_sync_agent_framework_sync_agent_free_serverinfo_p(void);
+
+static void utc_sync_agent_framework_sync_agent_get_serverid_p(void);
+static void utc_sync_agent_framework_sync_agent_get_serverid_n(void);
+static void utc_sync_agent_framework_sync_agent_get_root_path_p(void);
+static void utc_sync_agent_framework_sync_agent_get_root_path_n(void);
+
+static void utc_sync_agent_framework_sync_agent_get_server_type_p(void);
+static void utc_sync_agent_framework_sync_agent_get_server_type_n(void);
+
+static void utc_sync_agent_framework_sync_agent_is_exist_mo_p(void);
+static void utc_sync_agent_framework_sync_agent_is_exist_mo_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_type_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mo_type_n(void);
+
+static void utc_sync_agent_framework_sync_agent_check_acl_value_p(void);
+static void utc_sync_agent_framework_sync_agent_check_acl_value_n(void);
+static void utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_p(void);
+static void utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_n(void);
+static void utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_p(void);
+static void utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_n(void);
+
+static void utc_sync_agent_framework_sync_agent_export_tnds_stream_p(void);
+static void utc_sync_agent_framework_sync_agent_export_tnds_stream_n(void);
+static void utc_sync_agent_framework_sync_agent_import_tnds_stream_p(void);
+static void utc_sync_agent_framework_sync_agent_import_tnds_stream_n(void);
+
+static void utc_sync_agent_framework_sync_agent_open_p(void);
+static void utc_sync_agent_framework_sync_agent_begin_transaction_mo_p(void);
+static void utc_sync_agent_framework_sync_agent_end_transaction_mo_p(void);
+static void utc_sync_agent_framework_sync_agent_close_p(void);
+
+///////////////////////////////////mo_executor.h//////////////////////////////////////////
+
+static void utc_sync_agent_framework_sync_agent_execute_mo_ext_n(void);
+
+///////////////////////////////////mdm_control_code.h//////////////////////////////////////////
+
+static void utc_sync_agent_framework_sync_agent_start_mdm_service_p(void);
+static void utc_sync_agent_framework_sync_agent_start_mdm_service_n(void);
+static void utc_sync_agent_framework_sync_agent_stop_mdm_service_p(void);
+static void utc_sync_agent_framework_sync_agent_stop_mdm_service_n(void);
+static void utc_sync_agent_framework_sync_agent_set_mdm_value_p(void);
+static void utc_sync_agent_framework_sync_agent_set_mdm_value_n(void);
+static void utc_sync_agent_framework_sync_agent_get_mdm_value_p(void);
+static void utc_sync_agent_framework_sync_agent_get_mdm_value_n(void);
+static void utc_sync_agent_framework_sync_agent_execute_mdm_p(void);
+static void utc_sync_agent_framework_sync_agent_execute_mdm_n(void);
+
+struct tet_testlist tet_testlist[] = {
+
+       {utc_sync_agent_framework_sync_agent_create_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_mo_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_mo_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mo_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mo_tree_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_mo_tree_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_items_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_items_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_query_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_qyery_mo_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mo_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mo_item_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_mo_acc_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_mo_acc_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_update_mo_acc_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_acc_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_acc_item_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_mo_acc_item_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_initialize_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_initialize_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_mo_table_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_construct_mo_table_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_uptodate_mo_table_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_uptodate_mo_table_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_all_mo_table_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_serverinfo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_serverinfo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_serverid_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_serverid_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_root_path_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_root_path_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_server_type_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_server_type_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_exist_mo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_exist_mo_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_type_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mo_type_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_check_acl_value_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_check_acl_value_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_export_tnds_stream_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_export_tnds_stream_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_import_tnds_stream_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_import_tnds_stream_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_open_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_begin_transaction_mo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_end_transaction_mo_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_execute_mo_ext_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_start_mdm_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_start_mdm_service_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_mdm_value_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_mdm_value_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mdm_value_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_mdm_value_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_execute_mdm_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_execute_mdm_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_stop_mdm_service_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_stop_mdm_service_n, NEGATIVE_TC_IDX},
+
+       {NULL, 0}
+
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+
+               err = sync_agent_open_mo();
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               }
+
+               err = sync_agent_delete_all_mo_table();
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               } else {
+               }
+
+               dts_fail(API_NAME_SYNC_START_UP);
+       } else {
+
+               err = sync_agent_open_mo();
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               }
+
+               err = sync_agent_delete_all_mo_table();
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               } else {
+               }
+
+               dts_pass(API_NAME_SYNC_START_UP);
+       }
+
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_create_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_MO_ITEM;
+
+       err = sync_agent_create_mo_item(&sync_agent_mo_item);
+
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+       sync_agent_free_mo_item(sync_agent_mo_item);
+}
+
+static void utc_sync_agent_framework_sync_agent_add_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       char *api_name = API_NAME_SYNC_AGENT_ADD_MO_ITEM;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test1";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_add_mo_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_ADD_MO_ITEM;
+
+       err = sync_agent_add_mo_item(sync_agent_mo_item);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_update_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_MO_ITEM;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test2";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_mo_item.value = "aaaa";
+
+       err = sync_agent_update_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_update_mo_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_MO_ITEM;
+
+       err = sync_agent_update_mo_item(sync_agent_mo_item);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MO_ITEM;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test3";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_delete_mo_item("./dmacc/test3");
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mo_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MO_ITEM;
+
+       err = sync_agent_delete_mo_item(NULL);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mo_tree_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MO_TREE_ITEM;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test4";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_delete_mo_tree_item("./dmacc/test4");
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_mo_tree_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_MO_ITEM;
+
+       err = sync_agent_delete_mo_tree_item(NULL);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       sync_agent_dm_mo_node_s *sync_agent_mo_items = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ITEM;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test5";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_get_mo_item("./dmacc/test5", &sync_agent_mo_items);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_items = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ITEM;
+
+       err = sync_agent_get_mo_item(NULL, &sync_agent_mo_items);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_items_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       sync_agent_dm_mo_node_s *sync_agent_mo_items = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ITEMS;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test6";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_get_mo_items("./dmacc/test6", &sync_agent_mo_items);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_items_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_items = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ITEMS;
+
+       err = sync_agent_get_mo_items(NULL, &sync_agent_mo_items);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_query_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_MO_ITEM;
+       sync_agent_dm_mo_item_s sync_agent_mo_query;
+       GList *list = NULL;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test7";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_mo_query.mo_path = "./dmacc/test7";
+       sync_agent_mo_query.interface_type = MO_ONLY_DATA_VALUE;
+       sync_agent_mo_query.mo_type = 1;
+       sync_agent_mo_query.option = SYNC_AGENT_DM_MO_GET_OPTION_NODE;
+
+       err = sync_agent_query_mo_item(&sync_agent_mo_query, &list);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_qyery_mo_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_items = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_QUERY_MO_ITEM;
+       sync_agent_dm_mo_item_s *sync_agent_mo_query = NULL;
+       GList *list = NULL;
+
+       err = sync_agent_query_mo_item(sync_agent_mo_query, &list);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mo_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MO_ITEM;
+
+       err = sync_agent_create_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_free_mo_item(sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mo_item_list_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MO_ITEM;
+       GList *list = NULL;
+
+       err = sync_agent_create_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       list = g_list_append(list, sync_agent_mo_item);
+
+       sync_agent_free_mo_item_list(list);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_create_mo_acc_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_MO_ACC_ITEM;
+       sync_agent_dm_acc_info_s *acc_info = NULL;
+
+       err = sync_agent_create_mo_acc_item(&acc_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+       sync_agent_free_mo_acc_item(&acc_info);
+
+}
+
+static void utc_sync_agent_framework_sync_agent_update_mo_acc_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_MO_ACC_ITEM;
+       sync_agent_dm_acc_info_s acc_info;
+       sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_mo_acc_info_item.serverid = "RSate";
+       sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+
+       acc_info.auth_type = "xxx";
+       acc_info.auth_secret = "xxx";
+       acc_info.auth_name = "xxxx";
+       acc_info.auth_level = "xxx";
+       acc_info.auth_data = "xxx";
+       acc_info.addr = "xxxxx";
+
+       err = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_update_mo_acc_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_UPDATE_MO_ACC_ITEM;
+       sync_agent_dm_acc_info_s acc_info;
+       sync_agent_dm_mo_acc_item_info_s *sync_agent_mo_acc_info_item = NULL;
+
+       err = sync_agent_update_mo_acc_item(sync_agent_mo_acc_info_item, &acc_info);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_acc_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ACC_ITEM;
+
+       sync_agent_dm_acc_info_s *acc_info = NULL;
+       sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_mo_acc_info_item.serverid = "RSate";
+       sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+
+       err = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_acc_item_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_ACC_ITEM;
+       sync_agent_dm_acc_info_s *acc_info = NULL;
+       sync_agent_dm_mo_acc_item_info_s *sync_agent_mo_acc_info_item = NULL;
+
+       err = sync_agent_get_mo_acc_item(sync_agent_mo_acc_info_item, &acc_info);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+       err = sync_agent_close_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_mo_acc_item_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_FREE_MO_ACC_ITEM;
+       sync_agent_dm_acc_info_s *acc_info = NULL;
+
+       err = sync_agent_create_mo_acc_item(&acc_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_free_mo_acc_item(&acc_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+       err = sync_agent_close_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_initialize_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_INITIALIZE;
+       int mo_plugin_id = 8;
+
+       err = sync_agent_initialize_mo(mo_plugin_id);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_initialize_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_INITIALIZE;
+       int mo_plugin_id = 100;
+
+       err = sync_agent_initialize_mo(mo_plugin_id);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_begin_transaction_mo_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE;
+
+       err = sync_agent_begin_transaction_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_end_transaction_mo_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE;
+
+       err = sync_agent_begin_transaction_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+       //db control
+
+       err = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_mo_table_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_MO_TABLE;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_construct_mo_table_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CONSTRUCT_MO_TABLE;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = NULL;
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_uptodate_mo_table_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_UPTODATE_MO_TABLE;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_uptodate_mo_table(mo_type, mo_plugin_id, "./DMAcc/gcf");
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_uptodate_mo_table_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_UPTODATE_MO_TABLE;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       int mo_plugin_id = 4;
+
+       err = sync_agent_uptodate_mo_table(mo_type, mo_plugin_id, NULL);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_all_mo_table_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_ALL_MO_TABLE;
+
+       err = sync_agent_delete_all_mo_table();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_serverinfo_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVERINFO;
+       sync_agent_dm_server_info_s *server_info = NULL;
+
+       err = sync_agent_get_serverinfo(&server_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               err = sync_agent_free_serverinfo(server_info);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_free_serverinfo_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_FREE_SERVERINFO;
+       sync_agent_dm_server_info_s *server_info = NULL;
+
+       err = sync_agent_get_serverinfo(&server_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_free_serverinfo(server_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_serverid_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVERID;
+       char *server_id = NULL;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       err = sync_agent_get_serverid(mo_type, &server_id);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_serverid_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVERID;
+       sync_agent_dm_mo_type_e mo_type = 16;
+       char *server_id = NULL;
+
+       err = sync_agent_get_serverid(mo_type, &server_id);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_root_path_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_ROOT_PATH;
+       char *mo_full_path = NULL;
+       char *root_path = NULL;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_full_path = "./DMAcc/gcf/Name";
+
+       err = sync_agent_get_root_path(mo_full_path, &root_path);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_root_path_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_ROOT_PATH;
+       char *mo_full_path = NULL;
+       char *root_path = NULL;
+
+       err = sync_agent_get_root_path(mo_full_path, &root_path);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_server_type_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVER_TYPE;
+       char *server_id = NULL;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       server_id = "RSate";
+
+       err = sync_agent_get_server_type(server_id, &server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_server_type_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVER_TYPE;
+       char *server_id = NULL;
+       int server_type = 0;
+
+       err = sync_agent_get_server_type(server_id, &server_type);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_is_exist_mo_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVER_TYPE;
+       char *mo_path = NULL;
+       int is_exist = 0;
+
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test8";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_path = "./dmacc/test8";
+
+       err = sync_agent_is_exist_mo(mo_path, &is_exist);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_is_exist_mo_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVER_TYPE;
+       char *mo_path = NULL;
+       int is_exist = 0;
+
+       err = sync_agent_is_exist_mo(mo_path, &is_exist);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_type_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_TYPE;
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_type_e mo_type = 0;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test9";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_full_path = "./dmacc/test9";
+
+       err = sync_agent_get_mo_type(mo_full_path, &mo_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mo_type_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MO_TYPE;
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_type_e mo_type = 0;
+
+       err = sync_agent_get_mo_type(mo_full_path, &mo_type);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_check_acl_value_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CHECK_ACL_VALUE;
+
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+       sync_agent_dm_mo_access_type_e access_type = SYNC_AGENT_DM_MO_ACCESSTYPE_GET;
+       char *mo_full_path = NULL;
+       char *server_id = NULL;
+       int check_acl = 0;
+
+       runtime_property = (sync_agent_dm_mo_runtime_property_s *) calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s) + 1);
+       if (runtime_property == NULL) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       runtime_property->acl = "Get=RSate&Replace=RSate";
+
+       sync_agent_mo_item.mo_type = 1;
+       sync_agent_mo_item.full_path = "./dmacc/test10";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+       sync_agent_mo_item.runtime_property = runtime_property;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               free(runtime_property);
+               dts_fail(api_name);
+       }
+
+       mo_full_path = "./dmacc/test10";
+       server_id = "RSate";
+
+       err = sync_agent_check_acl_value(mo_full_path, access_type, server_id, &check_acl);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               free(runtime_property);
+               dts_fail(api_name);
+       } else {
+
+               free(runtime_property);
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_check_acl_value_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CHECK_ACL_VALUE;
+
+       sync_agent_dm_mo_access_type_e access_type = SYNC_AGENT_DM_MO_ACCESSTYPE_GET;
+       char *mo_full_path = NULL;
+       char *server_id = NULL;
+       int check_acl = 0;
+
+       server_id = "RSate";
+
+       err = sync_agent_check_acl_value(mo_full_path, access_type, server_id, &check_acl);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_DESCENDANT_MO_TREE;
+
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int count = 0;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_full_path = "./DMAcc/gcf/Name";
+
+       err = sync_agent_get_descendant_mo_tree(mo_type, mo_full_path, &root_node, &count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_descendant_mo_tree_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_DESCENDANT_MO_TREE;
+
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int count = 0;
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+       err = sync_agent_get_descendant_mo_tree(mo_type, mo_full_path, &root_node, &count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void *print_Node(sync_agent_dm_mo_node_s * mo_node, int depth, void **data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static void utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_TRAVERSE_MO_TREE_PREORDER;
+
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int v_err = 0;
+       int count = 0;
+       int depth = 1;
+       void *arg = NULL;
+
+       sync_agent_mo_item.mo_type = 0;
+       sync_agent_mo_item.full_path = "./dmacc/test11";
+       sync_agent_mo_item.value = "aa";
+       sync_agent_mo_item.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+       err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_full_path = "./dmacc";
+
+       err = sync_agent_get_descendant_mo_tree(0, mo_full_path, &root_node, &count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       v_err = sync_agent_traverse_mo_tree_preorder(root_node, print_Node, depth, 0, &arg);
+       if (v_err != 0) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_traverse_mo_tree_preorder_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_TRAVERSE_MO_TREE_PREORDER;
+       char *mo_full_path = NULL;
+       sync_agent_dm_mo_type_e mo_type = 0;
+       sync_agent_dm_mo_node_s sync_agent_mo_item;
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int v_err = NULL;
+       int count = 0;
+       int depth = 0;
+       void *arg = NULL;
+
+       v_err = sync_agent_traverse_mo_tree_preorder(root_node, NULL, depth, 0, &arg);
+       if (v_err == 0) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_export_tnds_stream_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXPORT_TNDS_STREAM;
+
+       char *mo_path = NULL;
+       char *output_stream = NULL;
+       unsigned int byte_size = 0;
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       const char *vendar_file = "/usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml";
+       int mo_plugin_id = 4;
+       int server_type = 16;
+
+       err = sync_agent_construct_mo_table(mo_type, vendar_file, mo_plugin_id, server_type);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_path = "./DMAcc";
+
+       err = sync_agent_export_tnds_stream(SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML, mo_type, mo_path, &output_stream, &byte_size);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./DMAcc");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_export_tnds_stream_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXPORT_TNDS_STREAM;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       char *mo_path = NULL;
+       char *output_stream = NULL;
+       unsigned int byte_size = 0;
+
+       err = sync_agent_export_tnds_stream(SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML, mo_type, mo_path, &output_stream, &byte_size);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_import_tnds_stream_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXPORT_TNDS_STREAM;
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       char *mo_path = NULL;
+       char *input_stream = NULL;
+       unsigned int byte_size = 0;
+
+       sync_agent_fsapi_return_e f_err = SYNC_AGENT_FSAPI_TRUE;
+
+       f_err = sync_agent_is_existing_fs(TNDS_SAMPLE_FILE);
+       if (f_err != SYNC_AGENT_FSAPI_TRUE) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       f_err = sync_agent_read_whole_file(TNDS_SAMPLE_FILE, &input_stream, &byte_size);
+       if (f_err != SYNC_AGENT_FSAPI_TRUE) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       }
+
+       mo_path = "./test";
+
+       err = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_ADD, SYNC_AGENT_DM_MO_TNDS_TYPE_XML, mo_type, mo_path, input_stream, byte_size);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               err = sync_agent_delete_mo_tree_item("./test");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_fail(api_name);
+       } else {
+
+               err = sync_agent_delete_mo_tree_item("./test");
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       dts_message(api_name, "sync_agent_framework : %d", err);
+                       dts_fail(api_name);
+               }
+
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_import_tnds_stream_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXPORT_TNDS_STREAM;
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+       char *mo_path = NULL;
+       char *input_stream = NULL;
+       unsigned int byte_size = 0;
+
+       mo_path = NULL;
+
+       err = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_ADD, SYNC_AGENT_DM_MO_TNDS_TYPE_XML, mo_type, mo_path, input_stream, byte_size);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_open_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_OPEN;
+
+       err = sync_agent_open_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_close_p(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE;
+
+       err = sync_agent_close_mo();
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void utc_sync_agent_framework_sync_agent_execute_mo_ext_n(void)
+{
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_MO_EXT;
+       const char *mo_path = NULL;
+       int err_num = 0;
+       int check_operation = 1;
+
+       err = sync_agent_execute_mo_ext(mo_path, &err_num, check_operation);
+       if (err == SYNC_AGENT_DM_MO_SUCCESS) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_start_mdm_service_p(void)
+{
+
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_START_MDM_SERVICE;
+
+       err = sync_agent_start_mdm_service(1, "syncagent-service");
+       if (err != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_start_mdm_service_n(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_START_MDM_SERVICE;
+
+       err = sync_agent_start_mdm_service(1, NULL);
+       if (err == SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_stop_mdm_service_p(void)
+{
+
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_STOP_MDM_SERVICE;
+
+       err = sync_agent_stop_mdm_service(1, "syncagent-service");
+       if (err != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_stop_mdm_service_n(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_STOP_MDM_SERVICE;
+
+       err = sync_agent_stop_mdm_service(1, NULL);
+       if (err == SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_mdm_value_p(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MDM_SERVICE;
+
+       err = sync_agent_set_mdm_value(1, SYNC_AGENT_DM_MDM_ALLOW_WIFI, SYNC_AGENT_DM_MDM_ALLOWED);
+       if (err != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_set_mdm_value_n(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_GET_MDM_SERVICE;
+
+       err = sync_agent_set_mdm_value(1, 102, 3);
+       if (err == SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mdm_value_p(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_SET_MDM_SERVICE;
+
+       sync_agent_dm_mdm_password_policy_s old_policy = { 0 };
+
+       err = sync_agent_get_mdm_value(1, SYNC_AGENT_DM_MDM_PWD_POLICY, &old_policy);
+       if (err != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_get_mdm_value_n(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_SET_MDM_SERVICE;
+
+       sync_agent_dm_mdm_password_policy_s old_policy = { 0 };
+
+       err = sync_agent_get_mdm_value(1, 102, &old_policy);
+       if (err == SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_execute_mdm_p(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_MDM_SERVICE;
+
+       err = sync_agent_execute_mdm(1, SYNC_AGENT_DM_MDM_EXE_ENFORCE_PWD_CHANGE);
+       if (err != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
+
+static void utc_sync_agent_framework_sync_agent_execute_mdm_n(void)
+{
+       sync_agent_dm_mdm_return_e err = SYNC_AGENT_DM_MDM_SUCCEEDED;
+       char *api_name = API_NAME_SYNC_AGENT_EXECUTE_MDM_SERVICE;
+
+       err = sync_agent_execute_mdm(1, 102);
+       if (err == SYNC_AGENT_DM_MDM_SUCCEEDED) {
+               dts_message(api_name, "sync_agent_framework : %d", err);
+
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+
+}
diff --git a/TC/testcase/utc_sync_agent_framework_engine_controller.c b/TC/testcase/utc_sync_agent_framework_engine_controller.c
new file mode 100755 (executable)
index 0000000..76665a4
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+
+#define API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT "sync_agent_alloc_param_spec_int"
+#define API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE "sync_agent_alloc_param_spec_structure"
+
+#define API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE "sync_agent_create_queuing_rule_spec_outline"
+#define API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT "sync_agent_add_progress_blocking_element"
+
+#define API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC "sync_agent_alloc_simple_task_spec"
+
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p(void);
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n(void);
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p(void);
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n(void);
+static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p(void);
+static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n(void);
+static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p(void);
+static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n(void);
+static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p(void);
+static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n, NEGATIVE_TC_IDX},
+
+       {NULL, 0}
+};
+
+#define EC_MSG_TYPE_SIMPLE_TASK                1
+#define EC_MSG_TYPE_NAME_SIMPLE_TASK   "simple_task"
+
+sync_agent_ec_task_error_e simple_task(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+
+       return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+}
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       } else {
+               dts_pass(API_NAME_SYNC_START_UP);
+       }
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT;
+       sync_agent_ec_param_spec_s *param_spec = NULL;
+
+       param_spec = sync_agent_alloc_param_spec_int("param_int", true, false, false, 0, 0, false, 0, false, 0, 0);
+       if (param_spec != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_param_spec_int");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT;
+       sync_agent_ec_param_spec_s *param_spec = NULL;
+
+       param_spec = sync_agent_alloc_param_spec_int(NULL, true, false, false, 0, 0, false, 0, false, 0, 0);
+       if (param_spec == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_param_spec_int");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE;
+       sync_agent_ec_param_spec_s *param_spec = NULL;
+
+       param_spec = sync_agent_alloc_param_spec_structure("param_struct", NULL, NULL, true, false, false, NULL, false, NULL, false, NULL);
+       if (param_spec != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_param_spec_structure");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE;
+       sync_agent_ec_param_spec_s *param_spec = NULL;
+
+       param_spec = sync_agent_alloc_param_spec_structure(NULL, NULL, NULL, true, false, false, NULL, false, NULL, false, NULL);
+       if (param_spec == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_param_spec_structure");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE;
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
+
+       queuing_rule = sync_agent_create_queuing_rule_spec_outline("queuing_rule_name");
+       if (queuing_rule != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE;
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
+
+       queuing_rule = sync_agent_create_queuing_rule_spec_outline(NULL);
+       if (queuing_rule == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT;
+       sync_agent_ec_error_e ec_err = SYNC_AGENT_EC_OK;
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       sync_agent_ec_param_spec_s *param_spec = sync_agent_alloc_param_spec_int("param", true, false, false, 0, 0, false, 0, false, 0, 0);
+       if (param_spec == NULL) {
+               dts_message(api_name, "sync_agent_alloc_param_spec_int");
+               dts_fail(api_name);
+       }
+
+       sync_agent_ec_param_spec_s *param_spec_array[1] = { param_spec };
+
+       task_spec = sync_agent_alloc_simple_task_spec("simple_task", simple_task, NULL, NULL, 1, param_spec_array);
+       if (task_spec == NULL) {
+               dts_message(api_name, "sync_agent_alloc_simple_task_spec");
+               dts_fail(api_name);
+       }
+
+       sync_agent_unref_param_spec(param_spec);
+
+       queuing_rule = sync_agent_create_queuing_rule_spec_outline("queuing_rule_name");
+       if (queuing_rule == NULL) {
+               dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
+               dts_fail(api_name);
+       }
+
+       ec_err = sync_agent_add_progress_blocking_element(queuing_rule, EC_MSG_TYPE_SIMPLE_TASK, task_spec, 0);
+       if (ec_err == SYNC_AGENT_EC_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_progress_blocking_element");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT;
+       sync_agent_ec_error_e ec_err = SYNC_AGENT_EC_OK;
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       ec_err = sync_agent_add_progress_blocking_element(queuing_rule, EC_MSG_TYPE_SIMPLE_TASK, task_spec, 0);
+       if (ec_err != SYNC_AGENT_EC_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_progress_blocking_element");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC;
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       sync_agent_ec_param_spec_s *param_spec = sync_agent_alloc_param_spec_int("param", true, false, false, 0, 0, false, 0, false, 0, 0);
+       if (param_spec == NULL) {
+               dts_message(api_name, "sync_agent_alloc_param_spec_int");
+               dts_fail(api_name);
+       }
+
+       sync_agent_ec_param_spec_s *param_spec_array[1] = { param_spec };
+
+       task_spec = sync_agent_alloc_simple_task_spec("simple_task", simple_task, NULL, NULL, 1, param_spec_array);
+       if (task_spec != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_simple_task_spec");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC;
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       task_spec = sync_agent_alloc_simple_task_spec(NULL, NULL, NULL, NULL, 1, NULL);
+       if (task_spec == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_alloc_simple_task_spec");
+               dts_fail(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event.c b/TC/testcase/utc_sync_agent_framework_event.c
new file mode 100755 (executable)
index 0000000..6c65411
--- /dev/null
@@ -0,0 +1,566 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define EVENT_NUM 1
+#define NOTI_NUM 1
+#define NOTI_KEY "fw_test_noti"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+#define API_NAME_EVENT_CB "_event_cb"
+#define API_NAME_CANCEL_CB "_cancel_cb"
+#define API_NAME_NOTI_CB "_noti_cb"
+
+#define API_NAME_SYNC_AGENT_APPEND_EVENT_DATA_PARAM "sync_agent_append_event_data_param"
+#define API_NAME_SYNC_AGENT_GET_EVENT_DATA_PARAM "sync_agent_get_event_data_param"
+#define API_NAME_SYNC_AGENT_RUN_EVENT_HANDLER "sync_agent_run_event_handler"
+#define API_NAME_SYNC_AGENT_SET_EVENT_CALLBACK "sync_agent_set_event_callback"
+#define API_NAME_SYNC_AGENT_CREATE_NOTI "sync_agent_create_noti"
+#define API_NAME_SYNC_AGENT_SEND_NOTI "sync_agent_send_noti"
+#define API_NAME_SYNC_AGENT_CREATE_EVENT "sync_agent_create_event"
+#define API_NAME_SYNC_AGENT_SEND_EVENT "sync_agent_send_event"
+#define API_NAME_SYNC_AGENT_RUN_NOTI_LISTENER "sync_agent_run_noti_listener"
+#define API_NAME_SYNC_AGENT_STOP_NOTI_LISTENER "sync_agent_stop_noti_listener"
+#define API_NAME_SYNC_AGENT_SET_NOTI_CALLBACK "sync_agent_set_noti_callback"
+#define API_NAME_SYNC_AGENT_CLEAN_EVENT_HANDLER "sync_agent_clean_event_handler"
+
+static void utc_sync_agent_framework_sync_agent_append_event_data_param_p(void);
+static void utc_sync_agent_framework_sync_agent_get_event_data_param_p(void);
+static void utc_sync_agent_framework_sync_agent_run_event_handler_p(void);
+static void utc_sync_agent_framework_sync_agent_set_event_callback_p(void);
+static void utc_sync_agent_framework_sync_agent_set_event_callback_n(void);
+static void utc_sync_agent_framework_sync_agent_create_noti_p(void);
+static void utc_sync_agent_framework_sync_agent_send_noti_p(void);
+static void utc_sync_agent_framework_sync_agent_send_noti_n(void);
+static void utc_sync_agent_framework_sync_agent_create_event_p(void);
+static void utc_sync_agent_framework_sync_agent_send_event_p(void);
+static void utc_sync_agent_framework_sync_agent_send_event_n(void);
+static void utc_sync_agent_framework_sync_agent_run_noti_listener_p(void);
+static void utc_sync_agent_framework_sync_agent_run_noti_listener_n(void);
+static void utc_sync_agent_framework_sync_agent_stop_noti_listener_p(void);
+static void utc_sync_agent_framework_sync_agent_set_noti_callback_p(void);
+static void utc_sync_agent_framework_sync_agent_clean_event_handler_p(void);
+
+static int _event_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static sync_agent_event_ipc_cancel_e _cancel_cb(void *user_data);
+static int _noti_cb(sync_agent_event_data_s * noti, void *user_data);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_append_event_data_param_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_event_data_param_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_run_event_handler_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_event_callback_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_event_callback_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_noti_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_send_noti_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_send_noti_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_event_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_send_event_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_send_event_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_run_noti_listener_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_run_noti_listener_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_stop_noti_listener_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_noti_callback_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_clean_event_handler_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       sync_agent_event_error_e event_err = sync_agent_set_event_callback(EVENT_NUM, _event_cb);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_set_event_callback : %d", event_err);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       event_err = sync_agent_set_noti_callback(NOTI_NUM, _noti_cb, NULL);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_set_noti_callback : %d", event_err);
+               dts_fail(API_NAME_SYNC_START_UP);
+       }
+
+       /* todo : register event callback  x */
+
+       /* create noti listener  x */
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       sync_agent_event_error_e event_err = sync_agent_clean_event_handler();
+}
+
+static void utc_sync_agent_framework_sync_agent_append_event_data_param_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_APPEND_EVENT_DATA_PARAM;
+       sync_agent_event_data_s *request_event = NULL;
+       int event_int_data = 1;
+
+       request_event = sync_agent_create_event(EVENT_NUM);
+       if (request_event != NULL) {
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+               sync_agent_free_event_data(request_event);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_event");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_event_data_param_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_EVENT_DATA_PARAM;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+       int event_int_data = 1;
+       char *event_char_data = strdup("event data");
+       int result_int = 0;
+
+       request_event = sync_agent_create_event(EVENT_NUM);
+       if (request_event == NULL) {
+               dts_message(api_name, "sync_agent_create_event");
+               dts_fail(api_name);
+       }
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, event_char_data);
+
+       response_event = sync_agent_send_event(request_event, &event_err);
+
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               sync_agent_free_event_data(response_event);
+               sync_agent_free_event_data(request_event);
+               dts_fail(api_name);
+       }
+
+       if (response_event != NULL) {
+               sync_agent_get_event_data_param(response_event, &result_int);
+               dts_message(api_name, "sync_agent_get_event_data_param (event result) : %d", result_int);
+               sync_agent_free_event_data(request_event);
+               sync_agent_free_event_data(response_event);
+               dts_pass(api_name);
+       } else {
+               sync_agent_free_event_data(request_event);
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_run_event_handler_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RUN_EVENT_HANDLER;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       unsigned long int thread_id = 0;
+
+       event_err = sync_agent_run_event_handler(&thread_id);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               pthread_cancel(thread_id);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_run_event_handler : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_event_callback_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_EVENT_CALLBACK;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_set_event_callback(EVENT_NUM, _event_cb);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_event_callback_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_EVENT_CALLBACK;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       int event_num = 3;      /* not defined event */
+
+       event_err = sync_agent_set_event_callback(event_num, _event_cb);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_noti_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_NOTI;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *noti = NULL;
+
+       noti = sync_agent_create_noti(NOTI_NUM);
+       if (noti != NULL) {
+               sync_agent_free_noti(noti);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_noti : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_send_noti_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_NOTI;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *noti = NULL;
+       sync_agent_event_data_s *response = NULL;
+       int noti_int_data = 0;
+       char *noti_char_data = strdup("noti data");
+       void *user_data = NULL;
+
+       event_err = sync_agent_run_noti_listener(NOTI_KEY);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_run_noti_listener : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_run_main_loop(1);
+
+       noti = sync_agent_create_noti(NOTI_NUM);
+       if (noti == NULL) {
+               dts_message(api_name, "sync_agent_create_noti : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &noti_int_data);
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, noti_char_data);
+
+       sync_agent_send_noti(NOTI_KEY, noti, _cancel_cb, user_data, &event_err);
+
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               sync_agent_free_noti(noti);
+               dts_pass(api_name);
+       } else {
+               sync_agent_free_noti(noti);
+               dts_message(api_name, "sync_agent_send_noti : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_send_noti_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_NOTI;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *noti = NULL;
+       sync_agent_event_data_s *response = NULL;
+       int noti_int_data = 0;
+       char *noti_char_data = strdup("noti data");
+       void *user_data = NULL;
+
+       event_err = sync_agent_run_noti_listener(NULL);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_run_noti_listener : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_run_main_loop(1);
+
+       noti = sync_agent_create_noti(NOTI_NUM);
+       if (noti == NULL) {
+               dts_message(api_name, "sync_agent_create_noti : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &noti_int_data);
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, noti_char_data);
+
+       sync_agent_send_noti(NULL, noti, _cancel_cb, user_data, &event_err);
+
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               sync_agent_free_noti(noti);
+               dts_message(api_name, "sync_agent_send_noti : %d", event_err);
+               dts_fail(api_name);
+       } else {
+               sync_agent_free_noti(noti);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_event_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_EVENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *event = NULL;
+
+       event = sync_agent_create_event(EVENT_NUM);
+       if (event != NULL) {
+               sync_agent_free_noti(event);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_noti : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_send_event_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_EVENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request = NULL;
+       sync_agent_event_data_s *response = NULL;
+       int event_int_data = 0;
+       char *event_char_data = strdup("event data");
+       int event_result = 0;
+
+       request = sync_agent_create_event(EVENT_NUM);
+       if (request == NULL) {
+               dts_message(api_name, "sync_agent_create_event : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_append_event_data_param(request, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+       sync_agent_append_event_data_param(request, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, event_char_data);
+
+       response = sync_agent_send_event(request, &event_err);
+
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               sync_agent_free_event(request);
+               sync_agent_free_event(response);
+               dts_fail(api_name);
+       }
+
+       if (response != NULL) {
+               sync_agent_get_event_data_param(response, &event_result);
+               dts_message(api_name, "sync_agent_get_event_data_param (event result) : %d", event_result);
+               sync_agent_free_event(request);
+               sync_agent_free_event(response);
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               sync_agent_free_event(request);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_send_event_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_EVENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request = NULL;
+       sync_agent_event_data_s *response = NULL;
+       int event_int_data = 0;
+       char *event_char_data = strdup("event data");
+       int event_result = 0;
+
+       request = sync_agent_create_event(EVENT_NUM);
+       if (request == NULL) {
+               dts_message(api_name, "sync_agent_create_event : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_append_event_data_param(request, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+       sync_agent_append_event_data_param(request, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, event_char_data);
+
+       response = sync_agent_send_event(NULL, &event_err);
+
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               sync_agent_free_event(request);
+               sync_agent_free_event(response);
+               dts_fail(api_name);
+       }
+
+       if (response != NULL) {
+               dts_message(api_name, "sync_agent_send_event : %d", event_err);
+               sync_agent_free_event(request);
+               dts_fail(api_name);
+       } else {
+               sync_agent_get_event_data_param(response, &event_result);
+               dts_message(api_name, "sync_agent_get_event_data_param (event result) : %d", event_result);
+               sync_agent_free_event(request);
+               sync_agent_free_event(response);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_run_noti_listener_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RUN_NOTI_LISTENER;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_run_noti_listener(NOTI_KEY);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_run_noti_listener : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_run_noti_listener_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RUN_NOTI_LISTENER;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_run_noti_listener(NULL);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_run_noti_listener : %d", event_err);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_stop_noti_listener_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_STOP_NOTI_LISTENER;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_stop_noti_listener();
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_stop_noti_listener : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_noti_callback_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_NOTI_CALLBACK;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_set_noti_callback(NOTI_NUM, _noti_cb, NULL);
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_set_noti_callback : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_clean_event_handler_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLEAN_EVENT_HANDLER;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+
+       event_err = sync_agent_clean_event_handler();
+       if (event_err == SYNC_AGENT_EVENT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_clean_event_handler : %d", event_err);
+               dts_fail(api_name);
+       }
+}
+
+static int _event_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("start event callback \n");
+
+       char *api_name = API_NAME_EVENT_CB;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       int event_int_data = 0;
+       char *event_char_data = NULL;
+       int event_result = 1;
+
+       sync_agent_get_event_data_param(request, &event_int_data);
+       sync_agent_get_event_data_param(request, &event_char_data);
+
+       g_print("%s : received event data\n", __func__);
+       dts_message(api_name, "sync_agent_get_event_data_param (int) : %d", event_int_data);
+       dts_message(api_name, "sync_agent_get_event_data_param (char) : %s", event_char_data);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s : event response\n", __func__);
+       dts_message(api_name, "sync_agent_append_event_data_param (int) : %d", event_result);
+
+       return 1;
+}
+
+static sync_agent_event_ipc_cancel_e _cancel_cb(void *user_data)
+{
+       g_print("start cancel callback \n");
+
+       char *api_name = API_NAME_CANCEL_CB;
+
+       sync_agent_ec_boolean cancel_flag = sync_agent_check_cancel_flag();
+       sync_agent_event_ipc_cancel_e result_cancel;
+
+       if (cancel_flag == 0)
+               result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_UN_NEED_CANCEL;
+       else
+               result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL;
+
+       dts_message(api_name, "cancel result : %d", result_cancel);
+
+       return result_cancel;
+}
+
+static int _noti_cb(sync_agent_event_data_s * noti, void *user_data)
+{
+       g_print("start noti callback \n");
+
+       char *api_name = API_NAME_NOTI_CB;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       int noti_int_data = 0;
+       char *noti_char_data = NULL;
+
+       sync_agent_get_event_data_param(noti, &noti_int_data);
+       sync_agent_get_event_data_param(noti, &noti_char_data);
+
+       g_print("%s : received event data\n", __func__);
+       dts_message(api_name, "sync_agent_get_event_data_param (int) : %d", noti_int_data);
+       dts_message(api_name, "sync_agent_get_event_data_param (char) : %s", noti_char_data);
+
+       event_err = sync_agent_stop_noti_listener();
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_run_noti_listener : %d", event_err);
+//              dts_fail(api_name);
+       }
+
+       sync_agent_stop_main_loop(1);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_account_reg.c b/TC/testcase/utc_sync_agent_framework_event_omadm_account_reg.c
new file mode 100755 (executable)
index 0000000..bffbe0c
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_REG_INIT "sync_agent_dm_reg_init"
+#define API_NAME_SYNC_AGENT_DM_REG_ACCOUNT_REGISTRATION "sync_agent_dm_reg_account_registration"
+#define API_NAME_SYNC_AGENT_DM_REG_DEINIT "sync_agent_dm_reg_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_reg_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_reg_account_registration_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_reg_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_reg_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_reg_account_registration_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_reg_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_reg_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_REG_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_reg_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_reg_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_reg_account_registration_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_REG_ACCOUNT_REGISTRATION;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_reg_account_registration();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_reg_account_registration : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_reg_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_REG_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_reg_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_reg_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       event_err = sync_agent_set_event_callback(EVENT_ACCOUNT_REGISTRATION, ___account_registration_cb);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+               dts_fail(api_name);
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+//      sync_agent_get_event_data_param(request, &response_type);
+//
+//      sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_admin.c b/TC/testcase/utc_sync_agent_framework_event_omadm_admin.c
new file mode 100755 (executable)
index 0000000..66eb6bb
--- /dev/null
@@ -0,0 +1,713 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_INIT "sync_agent_dm_admin_init"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_GET_FUMO_CONFIG "sync_agent_dm_admin_get_fumo_config"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_SET_FUMO_CONFIG "sync_agent_dm_admin_set_fumo_config"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_GET_PROFILE "sync_agent_dm_admin_get_profile"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_SET_PROFILE "sync_agent_dm_admin_set_profile"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_RESET_PROFILE "sync_agent_dm_admin_reset_profile"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_USER_INITIATE "sync_agent_dm_admin_user_initiate"
+#define API_NAME_SYNC_AGENT_DM_ADMIN_DEINIT "sync_agent_dm_admin_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_get_fumo_config_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_set_fumo_config_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_get_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_set_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_reset_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_user_initiate_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_admin_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_admin_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_get_fumo_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_set_fumo_config_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_get_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_set_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_reset_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_user_initiate_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_admin_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_admin_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_get_fumo_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_GET_FUMO_CONFIG;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int wifi_only = 0;
+
+       dm_err = sync_agent_dm_admin_get_fumo_config(&wifi_only);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_get_fumo_config : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_set_fumo_config_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_SET_FUMO_CONFIG;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int wifi_only = 1;
+
+       dm_err = sync_agent_dm_admin_set_fumo_config(wifi_only);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_set_fumo_config : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_get_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_GET_PROFILE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int profile_type = 1;
+       sync_agent_dm_setting_data_s *setting_data = (sync_agent_dm_setting_data_s *) calloc(1, sizeof(sync_agent_dm_setting_data_s));
+       if (setting_data == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return false;
+       }
+
+       dm_err = sync_agent_dm_admin_get_profile(profile_type, &setting_data);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_get_profile : %d", dm_err);
+               dts_fail(api_name);
+       }
+
+       if (setting_data != NULL) {
+               if (setting_data->profile_name != NULL)
+                       g_free(setting_data->profile_name);
+               if (setting_data->imei != NULL)
+                       g_free(setting_data->imei);
+               if (setting_data->server_url != NULL)
+                       g_free(setting_data->server_url);
+               if (setting_data->server_pwd != NULL)
+                       g_free(setting_data->server_pwd);
+               if (setting_data->client_id != NULL)
+                       g_free(setting_data->client_id);
+               if (setting_data->client_pwd != NULL)
+                       g_free(setting_data->client_pwd);
+               if (setting_data->client_auth_type != NULL)
+                       g_free(setting_data->client_auth_type);
+               if (setting_data->server_auth_type != NULL)
+                       g_free(setting_data->server_auth_type);
+
+               g_free(setting_data);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_set_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_SET_PROFILE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int profile_type = 1;
+       sync_agent_dm_setting_data_s setting_data;
+
+       setting_data.server_url = strdup("server url");
+       setting_data.server_id = strdup("server id");
+       setting_data.server_pwd = strdup("server pwd");
+       setting_data.client_id = strdup("client id");
+       setting_data.client_pwd = strdup("client pwd");
+       setting_data.client_auth_type = strdup("client auth type");
+       setting_data.server_auth_type = strdup("server auth type");
+
+       dm_err = sync_agent_dm_admin_set_profile(profile_type, &setting_data);
+
+       free(setting_data.server_url);
+       free(setting_data.server_id);
+       free(setting_data.server_pwd);
+       free(setting_data.client_id);
+       free(setting_data.client_pwd);
+       free(setting_data.client_auth_type);
+       free(setting_data.server_auth_type);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_set_profile : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_reset_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_RESET_PROFILE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int profile_type = 1;
+
+       dm_err = sync_agent_dm_admin_reset_profile(profile_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_reset_profile : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_user_initiate_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_USER_INITIATE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int server_type = 16;
+
+       dm_err = sync_agent_dm_admin_user_initiate(server_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_reset_profile : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_admin_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADMIN_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_admin_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_admin_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_alert.c b/TC/testcase/utc_sync_agent_framework_event_omadm_alert.c
new file mode 100755 (executable)
index 0000000..75c41c5
--- /dev/null
@@ -0,0 +1,651 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_ALERT_INIT "sync_agent_dm_alert_init"
+#define API_NAME_SYNC_AGENT_DM_ALERT_CONFIRMATION "sync_agent_dm_alert_confirmation"
+#define API_NAME_SYNC_AGENT_DM_ALERT_INPUTTEXT "sync_agent_dm_alert_inputtext"
+#define API_NAME_SYNC_AGENT_DM_ALERT_SINGLE_CHOICE "sync_agent_dm_alert_single_choice"
+#define API_NAME_SYNC_AGENT_DM_ALERT_MULTIPLE_CHOICE "sync_agent_dm_alert_multiple_choice"
+#define API_NAME_SYNC_AGENT_DM_ALERT_DEINIT "sync_agent_dm_alert_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_alert_confirmation_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_alert_inputtext_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_alert_single_choice_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_alert_multiple_choice_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_alert_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_alert_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_alert_confirmation_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_alert_inputtext_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_alert_single_choice_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_alert_multiple_choice_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_alert_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_alert_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_confirmation_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_CONFIRMATION;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+
+       dm_err = sync_agent_dm_alert_confirmation(response_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_confirmation : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_inputtext_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_INPUTTEXT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+       char *text = strdup("test alert input text");
+
+       dm_err = sync_agent_dm_alert_inputtext(response_type, text);
+
+       free(text);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_inputtext : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_single_choice_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_SINGLE_CHOICE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+       int selected_count = 1;
+       char *selected_number = strdup("1");
+
+       dm_err = sync_agent_dm_alert_single_choice(response_type, selected_count, selected_number);
+
+       free(selected_number);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_single_choice : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_multiple_choice_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_SINGLE_CHOICE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+       char *selected_number1 = strdup("1");
+       char *selected_number2 = strdup("2");
+
+       GList *out_data_list = NULL;
+       out_data_list = g_list_append(out_data_list, selected_number1);
+       out_data_list = g_list_append(out_data_list, selected_number2);
+
+       dm_err = sync_agent_dm_alert_multiple_choice(response_type, out_data_list);
+
+       free(selected_number1);
+       free(selected_number2);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_multiple_choice : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_alert_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ALERT_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_alert_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_alert_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_cp.c b/TC/testcase/utc_sync_agent_framework_event_omadm_cp.c
new file mode 100755 (executable)
index 0000000..cf7b1d0
--- /dev/null
@@ -0,0 +1,581 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_CP_INIT "sync_agent_dm_cp_init"
+#define API_NAME_SYNC_AGENT_DM_CP_CHECK_PIN_CODE "sync_agent_dm_cp_check_pin_code"
+#define API_NAME_SYNC_AGENT_DM_CP_DEINIT "sync_agent_dm_cp_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_cp_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_cp_check_pin_code_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_cp_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_cp_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_cp_check_pin_code_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_cp_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_cp_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_CP_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_cp_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_cp_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_cp_check_pin_code_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_CP_CHECK_PIN_CODE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int ext_id = 1;
+       int response_type = 1;
+       char *user_pin = strdup("1234");
+       int pin_check_response = 0;
+
+       dm_err = sync_agent_dm_cp_check_pin_code(ext_id, response_type, user_pin, &pin_check_response);
+
+       free(user_pin);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_cp_check_pin_code : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_cp_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_CP_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_cp_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_cp_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_dmacc.c b/TC/testcase/utc_sync_agent_framework_event_omadm_dmacc.c
new file mode 100755 (executable)
index 0000000..5b971e1
--- /dev/null
@@ -0,0 +1,594 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_DMACC_INIT "sync_agent_dm_dmacc_init"
+#define API_NAME_SYNC_AGENT_DM_ADD_DMACC "sync_agent_dm_add_dmacc"
+#define API_NAME_SYNC_AGENT_DM_REMOVE_DMACC "sync_agent_dm_remove_dmacc"
+#define API_NAME_SYNC_AGENT_DM_DMACC_DEINIT "sync_agent_dm_dmacc_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_dmacc_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_add_dmacc_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_remove_dmacc_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_dmacc_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_dmacc_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_add_dmacc_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_remove_dmacc_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_dmacc_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_dmacc_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_DMACC_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_dmacc_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_dmacc_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_add_dmacc_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_ADD_DMACC;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       dm_err = sync_agent_dm_add_dmacc(dmacc_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_add_dmacc : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_remove_dmacc_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_REMOVE_DMACC;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       dm_err = sync_agent_dm_remove_dmacc(dmacc_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_remove_dmacc : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_dmacc_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_DMACC_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_dmacc_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_dmacc_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_fota.c b/TC/testcase/utc_sync_agent_framework_event_omadm_fota.c
new file mode 100755 (executable)
index 0000000..5565098
--- /dev/null
@@ -0,0 +1,649 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_FOTA_INIT "sync_agent_dm_fota_init"
+#define API_NAME_SYNC_AGENT_DM_FOTA_SOFTWARE_UPDATE "sync_agent_dm_fota_software_update"
+#define API_NAME_SYNC_AGENT_DM_FOTA_CANCEL "sync_agent_dm_fota_cancel"
+#define API_NAME_SYNC_AGENT_DM_FOTA_DOWNLOAD "sync_agent_dm_fota_download"
+#define API_NAME_SYNC_AGENT_DM_FOTA_INSTALL "sync_agent_dm_fota_install"
+#define API_NAME_SYNC_AGENT_DM_FOTA_SET_INTERVAL "sync_agent_dm_fota_set_interval"
+#define API_NAME_SYNC_AGENT_DM_FOTA_DEINIT "sync_agent_dm_fota_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_software_update_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_cancel_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_download_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_install_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_set_interval_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_fota_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_fota_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_software_update_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_cancel_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_download_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_install_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_set_interval_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_fota_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_fota_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_software_update_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_SOFTWARE_UPDATE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_dm_service_server_type_e server_type = UI_SAMSUNG_FUMO_TYPE;
+
+       dm_err = sync_agent_dm_fota_software_update(server_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_software_update : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_cancel_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_CANCEL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_fota_cancel();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_cancel : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_download_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_DOWNLOAD;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+
+       dm_err = sync_agent_dm_fota_download(response_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_download : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_install_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_INSTALL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+
+       dm_err = sync_agent_dm_fota_install(response_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_install : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_set_interval_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_SET_INTERVAL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int interval_type = 1;
+
+       dm_err = sync_agent_dm_fota_set_interval(interval_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_set_interval : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_fota_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_FOTA_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_fota_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_fota_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omadm_noti.c b/TC/testcase/utc_sync_agent_framework_event_omadm_noti.c
new file mode 100755 (executable)
index 0000000..f415fe4
--- /dev/null
@@ -0,0 +1,654 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include "../../src/framework/event/oma_dm_api_common_internal.h"
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADM_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omadm.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DM_PUSH_INIT "sync_agent_dm_push_init"
+#define API_NAME_SYNC_AGENT_DM_PUSH_SOFTWARE_UPDATE "sync_agent_dm_push_software_update"
+#define API_NAME_SYNC_AGENT_DM_PUSH_CANCEL "sync_agent_dm_push_cancel"
+#define API_NAME_SYNC_AGENT_DM_PUSH_DOWNLOAD "sync_agent_dm_push_download"
+#define API_NAME_SYNC_AGENT_DM_PUSH_INSTALL "sync_agent_dm_push_install"
+#define API_NAME_SYNC_AGENT_DM_PUSH_SET_INTERVAL "sync_agent_dm_fota_set_interval"
+#define API_NAME_SYNC_AGENT_DM_PUSH_DEINIT "sync_agent_dm_push_deinit"
+
+#define API_NAME_START_TEST_DM_AGENT "_start_test_dm_agent"
+
+static void utc_sync_agent_framework_sync_agent_dm_push_init_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_software_update_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_cancel_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_download_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_install_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_set_interval_p(void);
+static void utc_sync_agent_framework_sync_agent_dm_push_deinit_p(void);
+
+static void *_start_test_dm_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_dm_push_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_software_update_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_cancel_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_download_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_install_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_set_interval_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_dm_push_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_dm_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_dm_agent_thread_id, 0, _start_test_dm_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_dm_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_INIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_push_init();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_init : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_software_update_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_SOFTWARE_UPDATE;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       char *server_id = strdup("server id");
+       char *session_id = strdup("111");
+
+       dm_err = sync_agent_dm_push_software_update(server_id, session_id);
+
+       free(server_id);
+       free(session_id);
+
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_software_update : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_cancel_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_CANCEL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_push_cancel();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_cancel : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_download_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_DOWNLOAD;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+
+       dm_err = sync_agent_dm_push_download(response_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_download : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_install_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_INSTALL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int response_type = 1;
+
+       dm_err = sync_agent_dm_push_install(response_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_install : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_set_interval_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_SET_INTERVAL;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       int interval_type = 1;
+
+       dm_err = sync_agent_dm_push_set_interval(interval_type);
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_set_interval : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_dm_push_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DM_PUSH_DEINIT;
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       dm_err = sync_agent_dm_push_deinit();
+       if (dm_err == UI_SYNC_AGENT_DM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_dm_push_deinit : %d", dm_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_dm_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DM_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADM_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case EVENT_SOFTWARE_UPDATE:
+               return ___software_update_cb;
+               break;
+       case EVENT_CANCEL:
+               return ___cancel_cb;
+               break;
+       case EVENT_DOWNLOAD:
+               return ___download_cb;
+               break;
+       case EVENT_INSTALL:
+               return ___install_cb;
+               break;
+       case EVENT_SET_INTERVAL:
+               return ___set_interval_cb;
+               break;
+       case EVENT_ACCOUNT_REGISTRATION:
+               return ___account_registration_cb;
+               break;
+       case EVENT_GET_FUMO_CONFIG:
+               return ___get_fumo_config_cb;
+               break;
+       case EVENT_SET_FUMO_CONFIG:
+               return ___set_fumo_config_cb;
+               break;
+       case EVENT_GET_PROFILE:
+               return ___get_profile_cb;
+               break;
+       case EVENT_SET_PROFILE:
+               return ___set_profile_cb;
+               break;
+       case EVENT_RESET_PROFILE:
+               return ___reset_profile_cb;
+               break;
+       case EVENT_UIC_ALERT:
+               return ___uic_alert_cb;
+               break;
+       case EVENT_CHECK_PIN_CODE:
+               return ___check_pin_code_cb;
+               break;
+       case EVENT_ADD_DMACC:
+               return ___add_dmacc_cb;
+               break;
+       case EVENT_REMOVE_DMACC:
+               return ___remove_dmacc_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___software_update_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ui_type = 0;
+       char *session_id = NULL;
+       char *server_id = NULL;
+       int task_id = 0;
+       int server_type = 0;
+
+       sync_agent_get_event_data_param(request, &ui_type);
+
+       switch (ui_type) {
+       case FOTA_COMMON_UI:
+               g_print("fota common ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case FOTA_NOTI_UI:
+               g_print("fota noti ui \n");
+               sync_agent_get_event_data_param(request, &session_id);
+               sync_agent_get_event_data_param(request, &server_id);
+               break;
+       case FOTA_BACKGROUND_UI:
+               g_print("fota background ui \n");
+               break;
+       case ADMIN_UI:
+               g_print("admin ui \n");
+               sync_agent_get_event_data_param(request, &task_id);
+               sync_agent_get_event_data_param(request, &server_type);
+               break;
+       case CP_UI:
+               g_print("cp ui \n");
+               break;
+       default:
+               break;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       free(session_id);
+       free(server_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___cancel_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int task_id = 0;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___download_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___install_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int response_type = 0;
+
+       sync_agent_get_event_data_param(request, &response_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_interval_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int request_param = 0;
+
+       sync_agent_get_event_data_param(request, &request_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___account_registration_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only = 1;
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_fumo_config_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int wifi_only_param = 0;
+
+       sync_agent_get_event_data_param(request, &wifi_only_param);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *profile_name = strdup("profile name");
+       char *client_targetUrl = strdup("client target url");
+       char *server_url = strdup("server url");
+       char *server_pwd = strdup("server pwd");
+       char *client_id = strdup("client id");
+       char *client_pwd = strdup("client pwd");
+       char *client_authType = strdup("client auth type");
+       char *server_authType = strdup("server auth type");
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+       free(profile_name);
+       free(client_targetUrl);
+       free(server_url);
+       free(server_pwd);
+       free(client_id);
+       free(client_pwd);
+       free(client_authType);
+       free(server_authType);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___set_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+       char *server_url = NULL;
+       char *server_id = NULL;
+       char *server_pw = NULL;
+       char *user_id = NULL;
+       char *user_pw = NULL;
+       char *user_auth_type = NULL;
+       char *server_auth_type = NULL;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+       sync_agent_get_event_data_param(request, &server_url);
+       sync_agent_get_event_data_param(request, &server_id);
+       sync_agent_get_event_data_param(request, &server_pw);
+       sync_agent_get_event_data_param(request, &user_id);
+       sync_agent_get_event_data_param(request, &user_pw);
+       sync_agent_get_event_data_param(request, &user_auth_type);
+       sync_agent_get_event_data_param(request, &server_auth_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___reset_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___uic_alert_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       uic_type type = UIC_NONE_TYPE;
+       int response_ret = 0;
+       char *input_text = NULL;
+       int count = 0;
+       int i = 0;
+
+       sync_agent_get_event_data_param(request, &response_ret);
+       sync_agent_get_event_data_param(request, &type);
+
+       if (response_ret == 1) {
+               switch (type) {
+               case UIC_CONFIRMATION_TYPE:
+                       break;
+               case UIC_INPUT_TEXT_TYPE:
+                       sync_agent_get_event_data_param(request, &input_text);
+                       break;
+               case UIC_SINGLE_CHOICE_TYPE:
+               case UIC_MULTIPLE_CHOICE_TYPE:
+                       {
+                               sync_agent_get_event_data_param(request, &count);
+
+                               if (count != 0) {
+                                       for (i = 0; i < count; ++i) {
+                                               char *input = NULL;
+                                               sync_agent_get_event_data_param(request, &input);
+                                       }
+                               }
+                       }
+                       break;
+               case UIC_DISPLAY_TYPE:
+               default:
+                       break;
+               }
+       } else {
+               g_printf("response failed \n");
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___check_pin_code_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int ext_id = 0;
+       char *user_pin = NULL;
+       int response_type = 0;
+       int response_value = 1;
+
+       sync_agent_get_event_data_param(request, &ext_id);
+       sync_agent_get_event_data_param(request, &response_type);
+
+       if (response_type == 1)
+               sync_agent_get_event_data_param(request, &user_pin);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+       if (user_pin != NULL)
+               free(user_pin);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___add_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___remove_dmacc_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int sv_type = 0;
+
+       sync_agent_get_event_data_param(request, &sv_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_event_omads.c b/TC/testcase/utc_sync_agent_framework_event_omads.c
new file mode 100755 (executable)
index 0000000..d75dd9e
--- /dev/null
@@ -0,0 +1,1060 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_OMADS_FILE      "../../../testcase/fw-test-cfg/test_fw_config_omads.xml"
+
+#define OMA_DS_EVENT_NUM 10
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_CLEAN_UP "cleanup"
+
+#define API_NAME_SYNC_AGENT_DS_INIT "sync_agent_ds_init"
+#define API_NAME_SYNC_AGENT_DS_CREATE_PROFILE_INFO "sync_agent_ds_create_profile_info"
+#define API_NAME_SYNC_AGENT_DS_SET_PROFILE_NAME "sync_agent_ds_set_profile_name"
+#define API_NAME_SYNC_AGENT_DS_SET_SERVER_INFO "sync_agent_ds_set_server_info"
+#define API_NAME_SYNC_AGENT_DS_SET_SYNC_INFO "sync_agent_ds_set_sync_info"
+#define API_NAME_SYNC_AGENT_DS_SET_SYNC_SERVICE_INFO "sync_agent_ds_set_sync_service_info"
+#define API_NAME_SYNC_AGENT_DS_GET_PROFILE_NAME "sync_agent_ds_get_profile_name"
+#define API_NAME_SYNC_AGENT_DS_GET_SERVER_INFO "sync_agent_ds_get_server_info"
+#define API_NAME_SYNC_AGENT_DS_GET_SYNC_INFO "sync_agent_ds_get_sync_info"
+#define API_NAME_SYNC_AGENT_DS_GET_SYNC_SERVICE_INFO "sync_agent_ds_get_sync_service_info"
+#define API_NAME_SYNC_AGENT_DS_GET_LAST_SYNC_INFO "sync_agent_ds_get_last_sync_info"
+#define API_NAME_SYNC_AGENT_DS_GET_SYNC_STATISTICS "sync_agent_ds_get_sync_statistics"
+#define API_NAME_SYNC_AGENT_DS_ADD_PROFILE "sync_agent_ds_add_profile"
+#define API_NAME_SYNC_AGENT_DS_GET_PROFILE "sync_agent_ds_get_profile"
+#define API_NAME_SYNC_AGENT_DS_GET_ALL_PROFILE "sync_agent_ds_get_all_profile"
+#define API_NAME_SYNC_AGENT_DS_UPDATE_PROFILE "sync_agent_ds_update_profile"
+#define API_NAME_SYNC_AGENT_DS_DELETE_PROFILE "sync_agent_ds_delete_profile"
+#define API_NAME_SYNC_AGENT_DS_START_SYNC "sync_agent_ds_start_sync"
+#define API_NAME_SYNC_AGENT_DS_STOP_SYNC "sync_agent_ds_stop_sync"
+#define API_NAME_SYNC_AGENT_DS_FREE_PROFILE_INFO "sync_agent_ds_free_profile_info"
+#define API_NAME_SYNC_AGENT_DS_DEINIT "sync_agent_ds_deinit"
+
+#define API_NAME_START_TEST_DS_AGENT "_start_test_ds_agent"
+
+static void utc_sync_agent_framework_sync_agent_sync_agent_ds_init_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_create_profile_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_set_profile_name_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_set_server_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_set_sync_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_set_sync_service_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_profile_name_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_server_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_service_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_last_sync_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_statistics_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_add_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_get_all_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_update_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_delete_profile_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_start_sync_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_stop_sync_p(void);
+//static void utc_sync_agent_framework_sync_agent_ds_free_profile_info_p(void);
+static void utc_sync_agent_framework_sync_agent_ds_deinit_p(void);
+
+static void *_start_test_ds_agent(void *arg);
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___add_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___update_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___delete_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___start_sync_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___stop_sync_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_sync_category_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_sync_statistics_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___get_all_profiles_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_sync_agent_ds_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_create_profile_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_set_profile_name_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_set_server_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_set_sync_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_set_sync_service_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_profile_name_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_server_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_sync_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_sync_service_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_last_sync_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_sync_statistics_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_add_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_get_all_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_update_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_delete_profile_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_start_sync_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_ds_stop_sync_p, POSITIVE_TC_IDX},
+//      { utc_sync_agent_framework_sync_agent_ds_free_profile_info_p, POSITIVE_TC_IDX },
+       {utc_sync_agent_framework_sync_agent_ds_deinit_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static pthread_t test_ds_agent_thread_id;
+
+static void startup(void)
+{
+       /* start of TC */
+       pthread_create(&test_ds_agent_thread_id, 0, _start_test_ds_agent, 0);
+
+       sleep(3);
+}
+
+static void cleanup(void)
+{
+       /* clean of TC */
+       pthread_cancel(test_ds_agent_thread_id);
+
+       sync_agent_stop_main_loop(1);
+}
+
+static void utc_sync_agent_framework_sync_agent_sync_agent_ds_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_INIT;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_err = sync_agent_ds_init();
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_init : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_create_profile_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_CREATE_PROFILE_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_set_profile_name_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_SET_PROFILE_NAME;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       char *profile_name = "profile name";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_set_server_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_SET_SERVER_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *addr = "http://";
+       char *id = "id";
+       char *password = "password";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_set_server_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_set_sync_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_SET_SYNC_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *sync_mode = "Periodic";
+       char *sync_type = "Update both";
+       char *interval = "1 hour";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_set_sync_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_set_sync_service_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_SET_SYNC_SERVICE_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+       int enabled = 1;
+       char *src_uri = "Contacts";
+       char *tgt_uri = "card";
+       char *id = "id";
+       char *password = "password";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_sync_service_info(profile_h, service_type, enabled, src_uri, tgt_uri, id, password);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_set_sync_service_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_profile_name_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_PROFILE_NAME;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       char *get_profile_dir_name = NULL;
+       char *profile_name = NULL;
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_profile_name(profile_h, &get_profile_dir_name, &profile_name);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_server_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_SERVER_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       sync_agent_ds_server_info server_info = { NULL };
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_server_info(profile_h, &server_info);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_server_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_SYNC_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       sync_agent_ds_sync_info sync_info = { NULL };
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_sync_info(profile_h, &sync_info);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_sync_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_service_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_SYNC_SERVICE_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       GList *service_list = NULL;
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_sync_service_info(profile_h, &service_list);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_sync_service_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_last_sync_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_LAST_SYNC_INFO;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       int last_sync_status = 0;
+       int last_sync_time = 0;
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_last_sync_info(profile_h, &last_sync_status, &last_sync_time);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_last_sync_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_sync_statistics_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_SYNC_STATISTICS;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       GList *statistics_list = NULL;
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_get_sync_statistics(profile_h, &statistics_list);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_sync_statistics : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_add_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_ADD_PROFILE;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       char *profile_name = "profile name";
+
+       char *addr = "http://";
+       char *id = "id";
+       char *password = "password";
+
+       char *sync_mode = "Periodic";
+       char *sync_type = "Update both";
+       char *interval = "1 hour";
+
+       sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+       int enabled = 1;
+       char *src_uri = "Contacts";
+       char *tgt_uri = "card";
+
+       int profile_id = 0;
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_server_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_sync_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_add_profile(profile_h, &profile_id);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_add_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_PROFILE;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+
+       ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_get_all_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_GET_ALL_PROFILE;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       GList *profile_list = NULL;
+
+       ds_err = sync_agent_ds_get_all_profile(&profile_list);
+
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_get_all_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_update_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_UPDATE_PROFILE;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profile_dir_name = "Sync1";
+       char *profile_name = "updated profile name";
+
+       char *addr = "http://";
+       char *id = "id";
+       char *password = "password";
+
+       char *sync_mode = "Periodic";
+       char *sync_type = "Update both";
+       char *interval = "1 hour";
+
+       sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+       int enabled = 1;
+       char *src_uri = "Contacts";
+       char *tgt_uri = "card";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_server_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_sync_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_update_profile(profile_h);
+       sync_agent_ds_free_profile_info(profile_h);
+
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_update_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_delete_profile_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_DELETE_PROFILE;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profileDirName = "Sync1";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_delete_profile(profile_h);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_delete_profile : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_start_sync_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_START_SYNC;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profileDirName = "Sync1";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_start_sync(profile_h);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_start_sync : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_ds_stop_sync_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_STOP_SYNC;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_profile_h profile_h = NULL;
+       char *profileDirName = "Sync1";
+
+       ds_err = sync_agent_ds_create_profile_info(&profile_h);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               dts_message(api_name, "sync_agent_ds_set_profile_name : %d", ds_err);
+               dts_fail(api_name);
+       }
+
+       ds_err = sync_agent_ds_stop_sync(profile_h);
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_stop_sync : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+//static void utc_sync_agent_framework_sync_agent_ds_free_profile_info_p(void)
+//{
+//      char *api_name = API_NAME_SYNC_AGENT_DS_FREE_PROFILE_INFO;
+//      sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+//
+//      ds_profile_h profile_h = NULL;
+//
+//      ds_err = sync_agent_ds_create_profile_info(&profile_h);
+//      if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+//              dts_message(api_name, "sync_agent_ds_create_profile_info : %d", ds_err);
+//              dts_fail(api_name);
+//      }
+//
+//      sync_agent_ds_free_profile_info(profile_h);
+//}
+
+static void utc_sync_agent_framework_sync_agent_ds_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DS_DEINIT;
+       sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+
+       ds_err = sync_agent_ds_deinit();
+       if (ds_err == SYNC_AGENT_DS_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_ds_deinit : %d", ds_err);
+               dts_fail(api_name);
+       }
+}
+
+static void *_start_test_ds_agent(void *arg)
+{
+       char *api_name = API_NAME_START_TEST_DS_AGENT;
+       sync_agent_event_error_e event_err = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_OMADS_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+
+       int event_id = 0;
+       for (event_id = 1; event_id < OMA_DS_EVENT_NUM; event_id++) {
+               event_err = sync_agent_set_event_callback(event_id, __get_event_callback(event_id));
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       dts_message(api_name, "sync_agent_set_event_callback : %d", event_err);
+                       dts_fail(api_name);
+               }
+       }
+
+       sync_agent_run_main_loop(1);
+}
+
+static int (*__get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+       g_print("%s Start \n", __func__);
+
+       switch (event_id) {
+       case 1:
+               return ___add_profile_cb;
+               break;
+       case 2:
+               return ___update_profile_cb;
+               break;
+       case 3:
+               return ___delete_profile_cb;
+               break;
+       case 4:
+               return ___start_sync_cb;
+               break;
+       case 5:
+               return ___stop_sync_cb;
+               break;
+       case 6:
+               return ___get_profile_cb;
+               break;
+       case 7:
+               return ___get_sync_category_cb;
+               break;
+       case 8:
+               return ___get_sync_statistics_cb;
+               break;
+       case 9:
+               return ___get_all_profiles_cb;
+               break;
+       default:
+               return ___default_cb;
+               break;
+       }
+
+       g_print("%s End \n", __func__);
+}
+
+static int ___add_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile_dir_name = NULL;
+       char *profile_name = NULL;
+       char *addr = NULL;
+       char *id = NULL;
+       char *password = NULL;
+       char *sync_mode = NULL;
+       char *sync_type = NULL;
+       char *interval = NULL;
+       int category_count = 0;
+       int account_id = 1;
+
+       sync_agent_get_event_data_param(request, &profile_dir_name);
+       sync_agent_get_event_data_param(request, &profile_name);
+       sync_agent_get_event_data_param(request, &addr);
+       sync_agent_get_event_data_param(request, &id);
+       sync_agent_get_event_data_param(request, &password);
+       sync_agent_get_event_data_param(request, &sync_mode);
+       sync_agent_get_event_data_param(request, &sync_type);
+       sync_agent_get_event_data_param(request, &interval);
+       sync_agent_get_event_data_param(request, &category_count);
+
+       int i = 0;
+       for (; i < category_count; i++) {
+               sync_agent_ds_service_info *category = NULL;
+               sync_agent_get_event_data_param(request, &(category->service_type));
+               sync_agent_get_event_data_param(request, &(category->enabled));
+               sync_agent_get_event_data_param(request, &(category->src_uri));
+               sync_agent_get_event_data_param(request, &(category->tgt_uri));
+               sync_agent_get_event_data_param(request, &(category->id));
+               sync_agent_get_event_data_param(request, &(category->password));
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &account_id);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___update_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile_dir_name = NULL;
+       char *profile_name = NULL;
+       char *addr = NULL;
+       char *id = NULL;
+       char *password = NULL;
+       char *sync_mode = NULL;
+       char *sync_type = NULL;
+       char *interval = NULL;
+       int category_count = 0;
+
+       sync_agent_get_event_data_param(request, &profile_dir_name);
+       sync_agent_get_event_data_param(request, &profile_name);
+       sync_agent_get_event_data_param(request, &addr);
+       sync_agent_get_event_data_param(request, &id);
+       sync_agent_get_event_data_param(request, &password);
+       sync_agent_get_event_data_param(request, &sync_mode);
+       sync_agent_get_event_data_param(request, &sync_type);
+       sync_agent_get_event_data_param(request, &interval);
+       sync_agent_get_event_data_param(request, &category_count);
+
+       int i = 0;
+       for (; i < category_count; i++) {
+               sync_agent_ds_service_info *category = NULL;
+               sync_agent_get_event_data_param(request, &(category->service_type));
+               sync_agent_get_event_data_param(request, &(category->enabled));
+               sync_agent_get_event_data_param(request, &(category->src_uri));
+               sync_agent_get_event_data_param(request, &(category->tgt_uri));
+               sync_agent_get_event_data_param(request, &(category->id));
+               sync_agent_get_event_data_param(request, &(category->password));
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___delete_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int count = 0;
+       sync_agent_get_event_data_param(request, &count);
+
+       int i;
+       char *profile = NULL;
+       for (i = 0; i < count; i++) {
+               sync_agent_get_event_data_param(request, &profile);
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___start_sync_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile = NULL;
+
+       sync_agent_get_event_data_param(request, &profile);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       if (profile != NULL)
+               free(profile);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___stop_sync_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile = NULL;
+
+       sync_agent_get_event_data_param(request, &profile);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+
+       if (profile != NULL)
+               free(profile);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_profile_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile = NULL;
+       char *profile_name = strdup("profile name");
+       char *addr = strdup("addr");
+       char *id = strdup("id");
+       char *password = strdup("password");
+       char *sync_mode = strdup("sync_mode");
+       char *sync_type = strdup("sync_type");
+       char *interval = strdup("interval");
+       int last_session_status = 0;
+       int last_session_time = 0;
+
+       sync_agent_get_event_data_param(request, &profile);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)addr);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_mode);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_type);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)interval);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_status);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_time);
+
+       if (profile != NULL)
+               free(profile);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_sync_category_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile = NULL;
+       int content_type = 0;
+       int enabled = 0;
+       char *srcURI = strdup("srcURI");
+       char *tgtURI = strdup("tgtURI");
+       char *id = strdup("id");
+       char *password = strdup("password");
+
+       sync_agent_get_event_data_param(request, &profile);
+       sync_agent_get_event_data_param(request, &content_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &enabled);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)srcURI);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)tgtURI);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
+
+       if (profile != NULL)
+               free(profile);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_sync_statistics_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       char *profile = NULL;
+       int content_type = 0;
+       char *dbSynced = strdup("NO");
+       int last_session_time = 0;
+       int server2Client_Total = 0;
+       int server2Client_NrOfAdd = 0;
+       int server2Client_NrOfDelete = 0;
+       int server2Client_NrOfReplace = 0;
+       int client2Server_Total = 0;
+       int client2Server_NrOfAdd = 0;
+       int client2Server_NrOrDelete = 0;
+       int client2Server_NrOfReplace = 0;
+
+       sync_agent_get_event_data_param(request, &profile);
+       sync_agent_get_event_data_param(request, &content_type);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)dbSynced);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_session_time);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_Total);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfAdd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfDelete);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server2Client_NrOfReplace);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_Total);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOfAdd);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOrDelete);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &client2Server_NrOfReplace);
+
+       if (profile != NULL)
+               free(profile);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___get_all_profiles_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       int event_result = 1;
+       int profile_count = 1;
+       int category_count = 1;
+       sync_agent_ds_service_info *category_info = NULL;
+
+       char *profile_dir_name = strdup("profile_dir_name");
+       char *profile_name = strdup("profile_name");
+       char *addr = strdup("addr");
+       char *id = strdup("id");
+       char *password = strdup("password");
+       char *sync_mode = strdup("sync_mode");
+       char *sync_type = strdup("sync_type");
+       char *interval = strdup("interval");
+       int last_sync_status = 0;
+       int last_sync_time = 1;
+       int service_type = 1;
+       int enabled = 1;
+       char *src_uri = strdup("src_uri");
+       char *tgt_uri = strdup("tgt_uri");
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_count);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_dir_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_name);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)addr);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_mode);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_type);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)interval);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_sync_status);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &last_sync_time);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &service_type);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &enabled);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)src_uri);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)tgt_uri);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)id);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)password);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
+
+static int ___default_cb(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       g_print("%s Start \n", __func__);
+
+       g_print("%s End \n", __func__);
+
+       return 1;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_fsapi.c b/TC/testcase/utc_sync_agent_framework_fsapi.c
new file mode 100755 (executable)
index 0000000..0b52d36
--- /dev/null
@@ -0,0 +1,964 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define FILE_SRC               "../../../testcase/fw-test-file/file_src"
+#define FILE_DST               "../../../testcase/fw-test-file/file_dst"
+#define FILE_DST_DIR   "../../../testcase/fw-test-file/dir_src/file_dst"
+#define DIR_SRC                        "../../../testcase/fw-test-file/dir_src"
+#define DIR_DST                        "../../../testcase/fw-test-file/dir_dst"
+#define NOT_EXISTING   "./not_existing"
+
+#define API_NAME_SYNC_AGENT_IS_EXISTING_FS     "sync_agent_is_existing_fs"
+#define API_NAME_SYNC_AGENT_GET_FS_INFO        "sync_agent_get_fs_info"
+#define API_NAME_SYNC_AGENT_FREE_FS_INFO       "sync_agent_free_fs_info"
+#define API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE    "sync_agent_get_fs_mem_size"
+#define API_NAME_SYNC_AGENT_GET_FILE_SIZE      "sync_agent_get_file_size"
+#define API_NAME_SYNC_AGENT_COPY_FILE  "sync_agent_copy_file"
+#define API_NAME_SYNC_AGENT_DELETE_FILE        "sync_agent_delete_file"
+#define API_NAME_SYNC_AGENT_MOVE_FILE  "sync_agent_move_file"
+#define API_NAME_SYNC_AGENT_RENAME_FILE        "sync_agent_rename_file"
+#define API_NAME_SYNC_AGENT_GET_FILE_LIST      "sync_agent_get_file_list"
+#define API_NAME_SYNC_AGENT_READ_FILE  "sync_agent_read_file"
+#define API_NAME_SYNC_AGENT_READ_WHOLE_FILE    "sync_agent_read_whole_file"
+#define API_NAME_SYNC_AGENT_FREE_FILE  "sync_agent_free_file"
+#define API_NAME_SYNC_AGENT_WRITE_FILE "sync_agent_write_file"
+#define API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE   "sync_agent_write_whole_file"
+#define API_NAME_SYNC_AGENT_APPEND_FILE        "sync_agent_append_file"
+#define API_NAME_SYNC_AGENT_CREATE_DIRECTORY   "sync_agent_create_directory"
+#define API_NAME_SYNC_AGENT_DELETE_DIRECTORY   "sync_agent_delete_directory"
+#define API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS   "sync_agent_empty_directory_contents"
+#define API_NAME_SYNC_AGENT_RENAME_DIRECTORY   "sync_agent_rename_directory"
+#define API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST "sync_agent_get_directory_list"
+#define API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION        "sync_agent_file_md5_validation"
+
+static void utc_sync_agent_framework_sync_agent_is_existing_fs_p(void);
+static void utc_sync_agent_framework_sync_agent_is_existing_fs_n(void);
+static void utc_sync_agent_framework_sync_agent_get_fs_info_p(void);
+static void utc_sync_agent_framework_sync_agent_get_fs_info_n(void);
+static void utc_sync_agent_framework_sync_agent_free_fs_info_p(void);
+static void utc_sync_agent_framework_sync_agent_free_fs_info_n(void);
+static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_p(void);
+static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_n(void);
+static void utc_sync_agent_framework_sync_agent_get_file_size_p(void);
+static void utc_sync_agent_framework_sync_agent_get_file_size_n(void);
+static void utc_sync_agent_framework_sync_agent_copy_file_p(void);
+static void utc_sync_agent_framework_sync_agent_copy_file_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_file_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_file_n(void);
+static void utc_sync_agent_framework_sync_agent_move_file_p(void);
+static void utc_sync_agent_framework_sync_agent_move_file_n(void);
+static void utc_sync_agent_framework_sync_agent_rename_file_p(void);
+static void utc_sync_agent_framework_sync_agent_rename_file_n(void);
+static void utc_sync_agent_framework_sync_agent_get_file_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_file_list_n(void);
+static void utc_sync_agent_framework_sync_agent_read_file_p(void);
+static void utc_sync_agent_framework_sync_agent_read_file_n(void);
+static void utc_sync_agent_framework_sync_agent_read_whole_file_p(void);
+static void utc_sync_agent_framework_sync_agent_read_whole_file_n(void);
+static void utc_sync_agent_framework_sync_agent_free_file_p(void);
+static void utc_sync_agent_framework_sync_agent_free_file_n(void);
+static void utc_sync_agent_framework_sync_agent_write_file_p(void);
+static void utc_sync_agent_framework_sync_agent_write_file_n(void);
+static void utc_sync_agent_framework_sync_agent_write_whole_file_p(void);
+static void utc_sync_agent_framework_sync_agent_write_whole_file_n(void);
+static void utc_sync_agent_framework_sync_agent_append_file_p(void);
+static void utc_sync_agent_framework_sync_agent_append_file_n(void);
+static void utc_sync_agent_framework_sync_agent_create_directory_p(void);
+static void utc_sync_agent_framework_sync_agent_create_directory_n(void);
+static void utc_sync_agent_framework_sync_agent_delete_directory_p(void);
+static void utc_sync_agent_framework_sync_agent_delete_directory_n(void);
+static void utc_sync_agent_framework_sync_agent_empty_directory_contents_p(void);
+static void utc_sync_agent_framework_sync_agent_empty_directory_contents_n(void);
+static void utc_sync_agent_framework_sync_agent_rename_directory_p(void);
+static void utc_sync_agent_framework_sync_agent_rename_directory_n(void);
+static void utc_sync_agent_framework_sync_agent_get_directory_list_p(void);
+static void utc_sync_agent_framework_sync_agent_get_directory_list_n(void);
+static void utc_sync_agent_framework_sync_agent_file_md5_validation_p(void);
+static void utc_sync_agent_framework_sync_agent_file_md5_validation_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_is_existing_fs_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_is_existing_fs_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_fs_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_fs_info_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_fs_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_fs_info_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_fs_mem_size_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_fs_mem_size_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_file_size_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_file_size_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_copy_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_copy_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_move_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_move_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_rename_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_rename_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_file_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_file_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_read_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_read_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_read_whole_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_read_whole_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_free_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_write_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_write_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_write_whole_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_write_whole_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_append_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_append_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_directory_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_directory_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_directory_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_delete_directory_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_empty_directory_contents_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_empty_directory_contents_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_rename_directory_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_rename_directory_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_directory_list_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_directory_list_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_file_md5_validation_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_file_md5_validation_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_is_existing_fs_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_IS_EXISTING_FS;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_is_existing_fs(FILE_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_is_existing_fs returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_is_existing_fs_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_IS_EXISTING_FS;
+       int ret = 0;
+
+       ret = sync_agent_is_existing_fs(NOT_EXISTING);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_is_existing_fs returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_fs_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FS_INFO;
+       int ret = 0;
+       char *fs_info = NULL;
+
+       ret = sync_agent_get_fs_info(&fs_info);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_fs_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FS_INFO;
+       int ret = 0;
+       char *fs_info = NULL;
+
+       ret = sync_agent_get_fs_info(NULL);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_fs_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FS_INFO;
+       int ret = 0;
+       char *fs_info = NULL;
+
+       ret = sync_agent_get_fs_info(&fs_info);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_get_fs_info returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_free_fs_info(fs_info);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_free_fs_info returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_fs_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FS_INFO;
+       int ret = 0;
+
+       ret = sync_agent_free_fs_info(NULL);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_free_fs_info returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE;
+       int ret = 0;
+       long double size_free = 0;
+       long double size_total = 0;
+
+       ret = sync_agent_get_fs_mem_size("/", &size_free, &size_total);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_get_fs_mem_size returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_fs_mem_size_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FS_MEM_SIZE;
+       int ret = 0;
+       long double size_free = 0;
+       long double size_total = 0;
+
+       ret = sync_agent_get_fs_mem_size(NOT_EXISTING, &size_free, &size_total);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_fs_mem_size returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_file_size_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FILE_SIZE;
+       int ret = 0;
+       unsigned long size = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_file_size(FILE_SRC, &size);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_get_file_size returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_file_size_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FILE_SIZE;
+       int ret = 0;
+       unsigned long size = 0;
+
+       ret = sync_agent_get_file_size(NOT_EXISTING, &size);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_file_size returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_copy_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COPY_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_copy_file(FILE_SRC, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               sync_agent_delete_file(FILE_DST);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_copy_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COPY_FILE;
+       int ret = 0;
+
+       ret = sync_agent_copy_file(NOT_EXISTING, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_delete_file(FILE_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_delete_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_delete_file(NOT_EXISTING);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_delete_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_move_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_MOVE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_move_file(FILE_SRC, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_move_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_DST);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_move_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_MOVE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_move_file(NOT_EXISTING, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_move_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_rename_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RENAME_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_rename_file(FILE_SRC, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_rename_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_DST);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_rename_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RENAME_FILE;
+       int ret = 0;
+
+       ret = sync_agent_rename_file(NOT_EXISTING, FILE_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_rename_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_file_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FILE_LIST;
+       int ret = 0;
+       GSList *list = NULL;
+
+       ret = sync_agent_get_file_list("./", &list);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_get_file_list returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_file_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_FILE_LIST;
+       int ret = 0;
+       GSList *list = NULL;
+
+       ret = sync_agent_get_file_list(NOT_EXISTING, &list);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_file_list returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_read_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_READ_FILE;
+       int ret = 0;
+       char *contents = NULL;
+       unsigned long contents_len = 0;
+       bool final = false;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_read_file(FILE_SRC, &contents, 10, &contents_len, &final);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_read_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_read_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_READ_FILE;
+       int ret = 0;
+       char *contents = NULL;
+       unsigned long contents_len = 0;
+       bool final = false;
+
+       ret = sync_agent_read_file(NOT_EXISTING, &contents, 10, &contents_len, &final);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_read_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_read_whole_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_READ_WHOLE_FILE;
+       int ret = 0;
+       char *contents = NULL;
+       unsigned long contents_len = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_read_whole_file(FILE_SRC, &contents, &contents_len);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_read_whole_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_READ_WHOLE_FILE;
+       int ret = 0;
+       char *contents = NULL;
+       unsigned long contents_len = 0;
+
+       ret = sync_agent_read_whole_file(NOT_EXISTING, &contents, &contents_len);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FILE;
+       int ret = 0;
+       char *contents = NULL;
+       unsigned long contents_len = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_read_whole_file(FILE_SRC, &contents, &contents_len);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_read_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       sync_agent_delete_file(FILE_SRC);
+
+       ret = sync_agent_free_file(&contents);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_free_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_free_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FREE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_free_file(NULL);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_free_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_write_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_WRITE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_file(FILE_SRC, "test writing", strlen("test writing"), true, true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_write_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_WRITE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_file(FILE_SRC, NULL, strlen("test writing"), true, true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_write_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_write_whole_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_write_whole_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_WRITE_WHOLE_FILE;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, NULL, strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_append_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_APPEND_FILE;
+       int ret = 0;
+
+       ret = sync_agent_append_file(FILE_SRC, "test writing", strlen("test writing"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_append_file returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_append_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_APPEND_FILE;
+       int ret = 0;
+
+       ret = sync_agent_append_file(FILE_SRC, NULL, strlen("test writing"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_append_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_directory_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_create_directory(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_directory_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_create_directory(NULL);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_directory_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_create_directory(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_delete_directory(DIR_SRC, true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_delete_directory returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_delete_directory_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DELETE_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_delete_directory(NOT_EXISTING, true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_delete_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_empty_directory_contents_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS;
+       int ret = 0;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_create_directory(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_copy_file(FILE_SRC, FILE_DST_DIR);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       sync_agent_delete_file(FILE_SRC);
+
+       ret = sync_agent_empty_directory_contents(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_message(api_name, "sync_agent_empty_directory_contents returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_empty_directory_contents_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_EMPTY_DIRECTORY_CONTENTS;
+       int ret = 0;
+
+       ret = sync_agent_empty_directory_contents(NOT_EXISTING);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_empty_directory_contents returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_rename_directory_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RENAME_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_create_directory(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_rename_directory(DIR_SRC, DIR_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_message(api_name, "sync_agent_rename_directory returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_directory(DIR_DST, true);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_rename_directory_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RENAME_DIRECTORY;
+       int ret = 0;
+
+       ret = sync_agent_rename_directory(NOT_EXISTING, DIR_DST);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_rename_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_directory_list_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST;
+       int ret = 0;
+       GSList *list = NULL;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_create_directory(DIR_SRC);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_create_directory returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_copy_file(FILE_SRC, FILE_DST_DIR);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_message(api_name, "sync_agent_copy_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       sync_agent_delete_file(FILE_SRC);
+
+       ret = sync_agent_get_directory_list(DIR_SRC, &list);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_message(api_name, "sync_agent_get_directory_list returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_directory(DIR_SRC, true);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_directory_list_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_DIRECTORY_LIST;
+       int ret = 0;
+       GSList *list = NULL;
+
+       ret = sync_agent_get_directory_list(NOT_EXISTING, &list);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_directory_list returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_file_md5_validation_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION;
+       int ret = 0;
+       char *md5hash = strdup("DF8F725F131D55A19742C001AB03DC42");
+       bool same = false;
+
+       ret = sync_agent_write_whole_file(FILE_SRC, "tizen sync-agent framework", strlen("tizen sync-agent framework"), true);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_message(api_name, "sync_agent_write_whole_file returned [%d]", ret);
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_file_md5_validation(FILE_SRC, md5hash, &same);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               sync_agent_delete_file(FILE_SRC);
+               dts_message(api_name, "sync_agent_file_md5_validation returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_delete_file(FILE_SRC);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_file_md5_validation_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_FILE_MD5_VALIDATION;
+       int ret = 0;
+       char *md5hash = strdup("c88ad98ef5a3368404ff42926adc4eb0");
+       bool same = false;
+
+       ret = sync_agent_file_md5_validation(NOT_EXISTING, md5hash, &same);
+       if (ret == SYNC_AGENT_FSAPI_FALSE) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_file_md5_validation returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_initialization.c b/TC/testcase/utc_sync_agent_framework_initialization.c
new file mode 100755 (executable)
index 0000000..dfc2bcb
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define TEST_FW_CONFIG_FILE_P  "../../../testcase/fw-test-cfg/test_fw_config.xml"
+#define TEST_FW_CONFIG_FILE_N  "../../../testcase/fw-test-cfg/test_fw_config_not_existing.xml"
+
+#define API_NAME_SYNC_AGENT_INIT       "sync_agent_init"
+#define API_NAME_SYNC_AGENT_DEINIT     "sync_agent_deinit"
+
+static void utc_sync_agent_framework_sync_agent_init_p(void);
+static void utc_sync_agent_framework_sync_agent_init_n(void);
+static void utc_sync_agent_framework_sync_agent_deinit_p(void);
+static void utc_sync_agent_framework_sync_agent_deinit_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_init_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_deinit_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_deinit_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_init_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT;
+
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE_P);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT;
+
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE_N);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_init : %d", init_error);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_deinit_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DEINIT;
+
+       sync_agent_init_error_e init_error = sync_agent_deinit();
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(api_name, "sync_agent_deinit : %d", init_error);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_deinit_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DEINIT;
+
+//      Trying to deinitialize without initializing..
+       sync_agent_init_error_e init_error = sync_agent_deinit();
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_deinit : %d", init_error);
+               dts_fail(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_network_access.c b/TC/testcase/utc_sync_agent_framework_network_access.c
new file mode 100755 (executable)
index 0000000..4fde6e8
--- /dev/null
@@ -0,0 +1,389 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+unsigned int session_id = 0;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_AGENT_OPEN_CONNECTION                            "sync_agent_open_connection"
+#define API_NAME_SYNC_AGENT_GET_STATUS                                 "sync_agent_get_status"
+#define API_NAME_SYNC_AGENT_CHECK_NETWORK_STATUS               "sync_agent_check_network_status"
+#define API_NAME_SYNC_AGENT_GET_CONNECTION_TYPE                        "sync_agent_get_connection_type"
+#define API_NAME_SYNC_AGENT_GET_CONNECTION_STATE               "sync_agent_get_connection_state"
+#define API_NAME_SYNC_AGENT_SEND_MSG                                   "sync_agent_send_msg"
+#define API_NAME_SYNC_AGENT_GET_HEADER_INFO                            "sync_agent_get_header_info"
+#define API_NAME_SYNC_AGENT_CANCEL_MSG                                 "sync_agent_cancel_msg"
+#define API_NAME_SYNC_AGENT_ADD_AUTHENTICATION_INFO            "sync_agent_add_authentication_info"
+#define API_NAME_SYNC_AGENT_CLOSE_CONNECTION                   "sync_agent_close_connection"
+#define API_NAME_SYNC_AGENT_DESTROY_NETOWK_ACCESS              "sync_agent_destroy_netowk_access"
+
+static void utc_sync_agent_framework_sync_agent_open_connection_p(void);
+static void utc_sync_agent_framework_sync_agent_open_connection_n(void);
+static void utc_sync_agent_framework_sync_agent_get_status_p(void);
+static void utc_sync_agent_framework_sync_agent_get_status_n(void);
+static void utc_sync_agent_framework_sync_agent_check_network_status_p(void);
+static void utc_sync_agent_framework_sync_agent_check_network_status_n(void);
+static void utc_sync_agent_framework_sync_agent_get_connection_type_p(void);
+static void utc_sync_agent_framework_sync_agent_get_connection_type_n(void);
+static void utc_sync_agent_framework_sync_agent_get_connection_state_p(void);
+static void utc_sync_agent_framework_sync_agent_get_connection_state_n(void);
+static void utc_sync_agent_framework_sync_agent_send_msg_p(void);
+static void utc_sync_agent_framework_sync_agent_send_msg_n(void);
+static void utc_sync_agent_framework_sync_agent_get_header_info_p(void);
+static void utc_sync_agent_framework_sync_agent_get_header_info_n(void);
+static void utc_sync_agent_framework_sync_agent_cancel_msg_p(void);
+static void utc_sync_agent_framework_sync_agent_cancel_msg_n(void);
+static void utc_sync_agent_framework_sync_agent_add_authentication_info_p(void);
+static void utc_sync_agent_framework_sync_agent_add_authentication_info_n(void);
+static void utc_sync_agent_framework_sync_agent_close_connection_p(void);
+static void utc_sync_agent_framework_sync_agent_close_connection_n(void);
+static void utc_sync_agent_framework_sync_agent_destroy_netowk_access_p(void); // actually is "positive" case but given "negative" because of execution order
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_open_connection_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_open_connection_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_status_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_status_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_check_network_status_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_check_network_status_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_connection_type_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_connection_type_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_connection_state_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_connection_state_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_send_msg_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_send_msg_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_header_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_header_info_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_cancel_msg_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_cancel_msg_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_add_authentication_info_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_authentication_info_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_connection_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_close_connection_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_destroy_netowk_access_p, NEGATIVE_TC_IDX}, // actually is "positive" case but given "negative" because of execution order
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       } else {
+               dts_pass(API_NAME_SYNC_START_UP);
+       }
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_open_connection_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_CONNECTION;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_open_connection(1, 30, &session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_open_connection returned code [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_open_connection_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_OPEN_CONNECTION;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_open_connection(2, 30, &session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_open_connection returned code [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_status_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STATUS;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       double status = 0;
+
+       ret = sync_agent_get_status(1, session_id, SYNC_AGENT_NA_STATUS_ELAPSED_TIME, &status);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_status returned code [%ld]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_status_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STATUS;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       double status = 0;
+
+       ret = sync_agent_get_status(2, session_id, SYNC_AGENT_NA_STATUS_ELAPSED_TIME, &status);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_status returned code [%ld]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_check_network_status_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CHECK_NETWORK_STATUS;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       int interval = 1;
+       int retry_cnt = 3;
+
+       ret = sync_agent_check_network_status(interval, retry_cnt);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_check_network_status returned code [%ld]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_check_network_status_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CHECK_NETWORK_STATUS;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       int interval = -1;
+       int retry_cnt = 3;
+
+       ret = sync_agent_check_network_status(interval, retry_cnt);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_check_network_status returned code [%ld]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_connection_type_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONNECTION_TYPE;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       sync_agent_na_network_connection_type_e con_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN;
+
+       ret = sync_agent_get_connection_type(&con_type);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_connection_type returned code [%ld]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_connection_type_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONNECTION_TYPE;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_get_connection_type(NULL);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_connection_type returned code [%ld]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_connection_state_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONNECTION_STATE;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       sync_agent_na_network_connection_state_e con_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+
+       ret = sync_agent_get_connection_state(&con_state);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_connection_state returned code [%ld]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_connection_state_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_CONNECTION_STATE;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_get_connection_state(NULL);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_connection_state returned code [%ld]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_send_msg_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_MSG;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_send_msg_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SEND_MSG;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_get_header_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_HEADER_INFO;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_get_header_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_HEADER_INFO;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_cancel_msg_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CANCEL_MSG;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_cancel_msg_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CANCEL_MSG;
+
+       dts_pass(api_name);
+}
+
+static void utc_sync_agent_framework_sync_agent_add_authentication_info_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_AUTHENTICATION_INFO;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_add_authentication_info(1, "user", "password", session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_authentication_info returned code [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_authentication_info_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_AUTHENTICATION_INFO;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_add_authentication_info(2, "user", "password", session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_authentication_info returned code [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_connection_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_CONNECTION;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_close_connection(1, session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_close_connection returned code [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_close_connection_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CLOSE_CONNECTION;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_close_connection(2, session_id);
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_close_connection returned code [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_destroy_netowk_access_p(void)  // actually is "positive" case but given "negative" because of execution order
+{
+       char *api_name = API_NAME_SYNC_AGENT_DESTROY_NETOWK_ACCESS;
+
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+       ret = sync_agent_destroy_netowk_access();
+       if (ret != SYNC_AGENT_NA_SUCCESS) {
+               dts_message(api_name, "sync_agent_destroy_netowk_access returned code [%ld]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_platform_monitor.c b/TC/testcase/utc_sync_agent_framework_platform_monitor.c
new file mode 100755 (executable)
index 0000000..a1a881c
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_alarm.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static int alarm_id = 0;
+static int alarm_id_invalid = 0;
+
+#define TEST_FW_CONFIG_FILE    "../../../testcase/fw-test-cfg/test_fw_config.xml"
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_AGNET_REGISTER_USER_CALLBACK             "sync_agnet_register_user_callback"
+#define API_NAME_SYNC_AGENT_ADD_SERVICE_DATA                   "sync_agent_add_service_data"
+#define API_NAME_SYNC_AGENT_GET_SERVICE_DATA                   "sync_agent_get_service_data"
+#define API_NAME_SYNC_AGENT_REMOVE_SERVICE_DATA                        "sync_agent_remove_service_data"
+#define API_NAME_SYNC_AGENT_UNREGISTER_SERVICE_NOTI            "sync_agent_unregister_service_noti"
+
+static void utc_sync_agent_framework_sync_agnet_register_user_callback_p(void);
+static void utc_sync_agent_framework_sync_agnet_register_user_callback_n(void);
+static void utc_sync_agent_framework_sync_agent_add_service_data_p(void);
+static void utc_sync_agent_framework_sync_agent_add_service_data_n(void);
+static void utc_sync_agent_framework_sync_agent_get_service_data_p(void);
+static void utc_sync_agent_framework_sync_agent_get_service_data_n(void);
+static void utc_sync_agent_framework_sync_agent_remove_service_data_p(void);
+static void utc_sync_agent_framework_sync_agent_remove_service_data_n(void);
+static void utc_sync_agent_framework_sync_agent_unregister_service_noti_p(void);
+static void utc_sync_agent_framework_sync_agent_unregister_service_noti_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agnet_register_user_callback_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agnet_register_user_callback_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_service_data_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_service_data_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_data_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_service_data_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_remove_service_data_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_remove_service_data_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_unregister_service_noti_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_unregister_service_noti_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+       sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
+               dts_fail(API_NAME_SYNC_START_UP);
+       } else {
+               dts_pass(API_NAME_SYNC_START_UP);
+       }
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+int alarm_cb(int item_id, void *user_data)
+{
+       return 0;
+}
+
+static void utc_sync_agent_framework_sync_agnet_register_user_callback_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGNET_REGISTER_USER_CALLBACK;
+
+       sync_agent_pm_return_e ret = sync_agnet_register_user_callback(1, NULL, 1, alarm_cb);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_message(api_name, "sync_agnet_register_user_callback returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agnet_register_user_callback_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGNET_REGISTER_USER_CALLBACK;
+
+       sync_agent_pm_return_e ret = sync_agnet_register_user_callback(3, NULL, 1, alarm_cb);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agnet_register_user_callback returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_service_data_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_SERVICE_DATA;
+
+       pmci_alarm_s *alarm_info = (pmci_alarm_s *) calloc(1, sizeof(pmci_alarm_s));
+       alarm_info->start_alarm_time = g_strdup("2014-12-13T15:32:17Z");
+       alarm_info->is_disposable = 0;
+       alarm_info->repeat_type = REPEAT;
+       alarm_info->repeat_value = 5 * 60;
+
+       sync_agent_pm_return_e ret = sync_agent_add_service_data(1, alarm_info, &alarm_id);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_message(api_name, "sync_agent_add_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_service_data_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_SERVICE_DATA;
+
+       pmci_alarm_s *alarm_info = (pmci_alarm_s *) calloc(1, sizeof(pmci_alarm_s));
+       alarm_info->start_alarm_time = g_strdup("2014-12-13T15:32:17Z");
+       alarm_info->is_disposable = 0;
+       alarm_info->repeat_type = REPEAT;
+       alarm_info->repeat_value = 5 * 60;
+
+       sync_agent_pm_return_e ret = sync_agent_add_service_data(3, alarm_info, &alarm_id_invalid);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_data_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_DATA;
+
+       pmci_alarm_s *alarm_info = NULL;
+
+       sync_agent_pm_return_e ret = sync_agent_get_service_data(1, alarm_id, &alarm_info);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_message(api_name, "sync_agent_get_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_service_data_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_SERVICE_DATA;
+
+       pmci_alarm_s *alarm_info = NULL;
+
+       sync_agent_pm_return_e ret = sync_agent_get_service_data(1, alarm_id_invalid, &alarm_info);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_remove_service_data_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_REMOVE_SERVICE_DATA;
+
+       sync_agent_pm_return_e ret = sync_agent_remove_service_data(1, alarm_id);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_message(api_name, "sync_agent_remove_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_remove_service_data_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_REMOVE_SERVICE_DATA;
+
+       sync_agent_pm_return_e ret = sync_agent_remove_service_data(1, alarm_id_invalid);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_remove_service_data returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_unregister_service_noti_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNREGISTER_SERVICE_NOTI;
+
+       sync_agent_pm_return_e ret = sync_agent_unregister_service_noti(1);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_message(api_name, "sync_agent_unregister_service_noti returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_unregister_service_noti_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNREGISTER_SERVICE_NOTI;
+
+       sync_agent_pm_return_e ret = sync_agent_unregister_service_noti(3);
+       if (ret != SYNC_AGENT_PM_SUCCESS) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_unregister_service_noti returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_protocol_binder.c b/TC/testcase/utc_sync_agent_framework_protocol_binder.c
new file mode 100755 (executable)
index 0000000..6928510
--- /dev/null
@@ -0,0 +1,1586 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define API_NAME_SYNC_AGENT_INIT_BINDER_FUNCTION_SET   "sync_agent_init_binder_function_set"
+#define API_NAME_SYNC_AGENT_INIT_PROTOCOL_BINDER       "sync_agent_init_protocol_binder"
+#define API_NAME_SYNC_AGENT_INIT_REVERSE_PROTOCOL_BINDER       "sync_agent_init_reverse_protocol_binder"
+#define API_NAME_SYNC_AGENT_ADD_BINDER_FUNCTION_SET    "sync_agent_add_binder_function_set"
+#define API_NAME_SYNC_AGENT_APPEND_ELEMENT     "sync_agent_append_element"
+#define API_NAME_SYNC_AGENT_NEXT_ELEMENT       "sync_agent_next_element"
+#define API_NAME_SYNC_AGENT_GET_STREAM_FROM_PROTOCOL_BINDER    "sync_agent_get_stream_from_protocol_binder"
+#define API_NAME_SYNC_AGENT_GET_STREAM_SIZE_FROM_PROTOCOL_BINDER       "sync_agent_get_stream_size_from_protocol_binder"
+#define API_NAME_SYNC_AGENT_GET_ENCODING_FROM_PROTOCOL_BINDER  "sync_agent_get_encoding_from_protocol_binder"
+#define API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_PROTOCOL_BINDER "sync_agent_get_xml_from_protocol_binder"
+#define API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_REVERSE_PROTOCOL_BINDER "sync_agent_get_xml_from_reverse_protocol_binder"
+#define API_NAME_SYNC_AGENT_GET_USER_DATA_FROM_REVERSE_PROTOCOL_BINDER "sync_agent_get_user_data_from_reverse_protocol_binder"
+
+#define API_NAME_SYNC_AGENT_SWITCH_PROTOCOL    "sync_agent_switch_protocol"
+#define API_NAME_SYNC_AGENT_UNDO_SWITCH_PROTOCOL       "sync_agent_undo_switch_protocol"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME   "sync_agent_create_node"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE     "sync_agent_create_node_with_namespace"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_TEXT "sync_agent_create_text_node"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT   "sync_agent_create_text_node_with_namespace"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_CDATA        "sync_agent_create_cdata_node"
+#define API_NAME_SYNC_AGENT_CREATE_WBXML_TREE  "sync_agent_create_wbxml_tree"
+#define API_NAME_SYNC_AGENT_ADD_WBXML_TREE_TO_WBXML_NODE       "sync_agent_add_wbxml_tree_to_wbxml_node"
+#define API_NAME_SYNC_AGENT_SET_WBXML_TREE_ROOT        "sync_agent_set_wbxml_tree_root"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME        "sync_agent_add_child_node"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE  "sync_agent_add_child_node_with_namespace"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_TEXT      "sync_agent_add_child_text_node"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT        "sync_agent_add_child_text_node_with_namespace"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_CDATA     "sync_agent_add_child_cdata_node"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_INT       "sync_agent_add_child_int_node"
+#define API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_INT "sync_agent_add_child_int_node_with_namespace"
+#define API_NAME_SYNC_AGENT_GET_XML_NAME_FROM_ELEMENT_WBXML_NODE       "sync_agent_get_name_from_element_node"
+#define API_NAME_SYNC_AGENT_GET_NAMESPACE_FROM_ELEMENT_WBXML_NODE      "sync_agent_get_namespace_from_element_node"
+#define API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_NODE   "sync_agent_get_text_from_node"
+#define API_NAME_SYNC_AGENT_GET_BINARY_POINTER_FROM_WBXML_NODE "sync_agent_get_binary_from_node"
+#define API_NAME_SYNC_AGENT_GET_INT_FROM_WBXML_NODE    "sync_agent_get_int_from_node"
+#define API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_CDATA_NODE     "sync_agent_get_text_from_cdata_node"
+#define API_NAME_SYNC_AGENT_DESTROY_WBXML_NODE "sync_agent_destroy_wbxml_node"
+
+sync_agent_pb_protocol_binder_function_set_s *binder_function_set = NULL;
+sync_agent_pb_protocol_binder_info_s *binder = NULL;
+sync_agent_pb_protocol_binder_reverse_info_s *reverse_binder = NULL;
+
+WBXMLTreeNode *node = NULL;
+WBXMLTreeNode *node_child = NULL;
+WBXMLTree *tree = NULL;
+
+static sync_agent_pb_error_e start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e header_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e body_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e final_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e results_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+
+static sync_agent_pb_error_e header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
+static sync_agent_pb_error_e final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
+static sync_agent_pb_error_e results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
+
+typedef enum {
+       PE_UNDEF = 0, PE_ERROR, PE_ADD, PE_ALERT, PE_ATOMIC_START, PE_ATOMIC_END, PE_COPY, PE_DELETE, PE_EXEC, PE_GET,
+       PE_MAP, PE_PUT_START, PE_PUT_END, PE_RESULTS_START, PE_RESULTS_END, PE_SEARCH, PE_SEQUENCE_START, PE_SEQUENCE_END,
+       PE_STATUS, PE_SYNC_START, PE_SYNC_END, PE_REPLACE, PE_HEADER, PE_PUT_GET, PE_CMD_GROUP, PE_GENERIC, PE_FINAL, PE_DEVINF,
+       PE_SYNCML_START, PE_SYNCML_END, PE_BODY_START, PE_BODY_END
+} protocol_element_e;
+
+const sync_agent_pb_function_info_s binder_function_info[8] = {
+       {PE_SYNCML_START, "SyncML", start_converter_function, NULL, false},
+       {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
+       {PE_HEADER, "SyncHdr", header_converter_function, header_reverse_converter_function, true},
+       {PE_BODY_START, "SyncBody", body_start_converter_function, NULL, false},
+       {PE_BODY_END, "/SyncBody", NULL, NULL, false},
+       {PE_FINAL, "Final", final_converter_function, final_reverse_converter_function, true},
+       {PE_RESULTS_START, "Results", results_command_converter_function, results_command_reverse_converter_function, false},
+       {PE_RESULTS_END, "/Results", NULL, NULL, false}
+};
+
+const sync_agent_pb_function_info_s binder_function_info_additional[8] = {
+       {PE_SYNCML_START, "SyncML", start_converter_function, NULL, false},
+       {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
+       {PE_HEADER, "SyncHdr", header_converter_function, header_reverse_converter_function, true},
+       {PE_BODY_START, "SyncBody", body_start_converter_function, NULL, false},
+       {PE_BODY_END, "/SyncBody", NULL, NULL, false},
+       {PE_FINAL, "Final", final_converter_function, final_reverse_converter_function, true},
+       {PE_RESULTS_START, "Results", results_command_converter_function, results_command_reverse_converter_function, false},
+       {PE_RESULTS_END, "/Results", NULL, NULL, false}
+};
+
+static void utc_sync_agent_framework_sync_agent_init_binder_function_set_p(void);
+static void utc_sync_agent_framework_sync_agent_init_binder_function_set_n(void);
+static void utc_sync_agent_framework_sync_agent_init_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_init_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_add_binder_function_set_p(void);
+static void utc_sync_agent_framework_sync_agent_add_binder_function_set_n(void);
+static void utc_sync_agent_framework_sync_agent_append_element_p(void);
+static void utc_sync_agent_framework_sync_agent_append_element_n(void);
+static void utc_sync_agent_framework_sync_agent_next_element_p(void);
+static void utc_sync_agent_framework_sync_agent_next_element_n(void);
+static void utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_n(void);
+static void utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_p(void);
+static void utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_n(void);
+
+static void utc_sync_agent_framework_sync_agent_switch_protocol_p(void);
+static void utc_sync_agent_framework_sync_agent_switch_protocol_n(void);
+static void utc_sync_agent_framework_sync_agent_undo_switch_protocol_p(void);
+static void utc_sync_agent_framework_sync_agent_undo_switch_protocol_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_n(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_tree_p(void);
+static void utc_sync_agent_framework_sync_agent_create_wbxml_tree_n(void);
+static void utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_p(void);
+static void utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_n(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_p(void);
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_n(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_n(void);
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_p(void);
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_n(void);
+static void utc_sync_agent_framework_sync_agent_destroy_wbxml_node_p(void);
+static void utc_sync_agent_framework_sync_agent_destroy_wbxml_node_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_init_binder_function_set_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_binder_function_set_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_binder_function_set_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_binder_function_set_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_append_element_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_append_element_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_next_element_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_next_element_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_n, NEGATIVE_TC_IDX},
+
+       {utc_sync_agent_framework_sync_agent_switch_protocol_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_switch_protocol_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_undo_switch_protocol_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_undo_switch_protocol_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_tree_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_wbxml_tree_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_destroy_wbxml_node_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_destroy_wbxml_node_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_init_binder_function_set_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_BINDER_FUNCTION_SET;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_init_binder_function_set(sizeof(binder_function_info) / sizeof(sync_agent_pb_function_info_s), (sync_agent_pb_function_info_s *) binder_function_info, &binder_function_set);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_init_binder_function_set returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_binder_function_set_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_BINDER_FUNCTION_SET;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_init_binder_function_set(sizeof(binder_function_info) / sizeof(sync_agent_pb_function_info_s), NULL, &binder_function_set);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_init_binder_function_set returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_PROTOCOL_BINDER;
+
+       binder = sync_agent_init_protocol_binder(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL, SYNC_AGENT_PB_ENCODING_XML, false, false, false, true, false, NULL, NULL, binder_function_set);
+       if (binder == NULL) {
+               dts_message(api_name, "sync_agent_init_protocol_binder returned NULL");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_PROTOCOL_BINDER;
+
+       binder = sync_agent_init_protocol_binder(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL, SYNC_AGENT_PB_ENCODING_XML, false, false, false, true, false, NULL, NULL, NULL);
+       if (binder == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_init_protocol_binder returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_REVERSE_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+       char *xml_stream = NULL;
+       unsigned long xml_stream_length = 0;
+
+       sync_agent_read_whole_file("../../../testcase/fw-test-file/sample_xml", &xml_stream, &xml_stream_length);
+
+       ret = sync_agent_init_reverse_protocol_binder(xml_stream, xml_stream_length, SYNC_AGENT_PB_DECODING_XML, &protocol, binder_function_set, "user data", &reverse_binder);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_init_reverse_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_init_reverse_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_INIT_REVERSE_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+
+       ret = sync_agent_init_reverse_protocol_binder("wrong xml", strlen("wrong xml"), SYNC_AGENT_PB_DECODING_XML, &protocol, binder_function_set, "user data", &reverse_binder);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_init_reverse_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_binder_function_set_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_BINDER_FUNCTION_SET;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_add_binder_function_set(binder_function_set, sizeof(binder_function_info_additional) / sizeof(sync_agent_pb_function_info_s), (sync_agent_pb_function_info_s *) binder_function_info_additional);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_add_binder_function_set returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_binder_function_set_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_BINDER_FUNCTION_SET;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_add_binder_function_set(binder_function_set, sizeof(binder_function_info_additional) / sizeof(sync_agent_pb_function_info_s), NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_binder_function_set returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_append_element_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_APPEND_ELEMENT;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_append_element(binder, PE_SYNCML_START, NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_append_element returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_append_element_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_APPEND_ELEMENT;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_append_element(NULL, PE_SYNCML_START, NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_append_element returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_next_element_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_NEXT_ELEMENT;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       Protocol_Element protocol_element = PE_UNDEF;
+       char *protocol_element_name = NULL;
+       Content_Ptr content = NULL;
+
+       ret = sync_agent_next_element(binder, &protocol_element, &protocol_element_name, &content);
+       if (ret != SYNC_AGENT_PB_RETURN_OK && ret != SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT) {
+               dts_message(api_name, "sync_agent_append_element returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_next_element_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_NEXT_ELEMENT;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       Protocol_Element protocol_element = PE_UNDEF;
+       char *protocol_element_name = NULL;
+       Content_Ptr content = NULL;
+
+       ret = sync_agent_next_element(NULL, &protocol_element, &protocol_element_name, &content);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_append_element returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STREAM_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *stream = NULL;
+       unsigned int stream_len = 0;
+
+       ret = sync_agent_get_stream_from_protocol_binder(binder, &stream, &stream_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_get_stream_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_stream_from_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STREAM_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *stream = NULL;
+       unsigned int stream_len = 0;
+
+       ret = sync_agent_get_stream_from_protocol_binder(binder, NULL, &stream_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_stream_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STREAM_SIZE_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       unsigned int stream_len = 0;
+
+       ret = sync_agent_get_stream_size_from_protocol_binder(binder, &stream_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_get_stream_size_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_stream_size_from_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_STREAM_SIZE_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       unsigned int stream_len = 0;
+
+       ret = sync_agent_get_stream_size_from_protocol_binder(NULL, &stream_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_stream_size_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ENCODING_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_UNKNOWN;
+
+       ret = sync_agent_get_encoding_from_protocol_binder(binder, &encoding);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_get_encoding_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_encoding_from_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ENCODING_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_UNKNOWN;
+
+       ret = sync_agent_get_encoding_from_protocol_binder(NULL, &encoding);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_encoding_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml = NULL;
+       unsigned int xml_len = 0;
+
+       ret = sync_agent_get_xml_from_protocol_binder(binder, &xml, &xml_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK && ret != SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_ENCODING) {
+               dts_message(api_name, "sync_agent_get_xml_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml = NULL;
+       unsigned int xml_len = 0;
+
+       ret = sync_agent_get_xml_from_protocol_binder(NULL, &xml, &xml_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_xml_from_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_REVERSE_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml = NULL;
+       unsigned int xml_len = 0;
+
+       ret = sync_agent_get_xml_from_reverse_protocol_binder(reverse_binder, &xml, &xml_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK && ret != SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_DECODING) {
+               dts_message(api_name, "sync_agent_get_xml_from_reverse_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_for_debugging_from_reverse_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_FOR_DEBUGGING_FROM_REVERSE_PROTOCOL_BINDER;
+
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml = NULL;
+       unsigned int xml_len = 0;
+
+       ret = sync_agent_get_xml_from_reverse_protocol_binder(NULL, &xml, &xml_len);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_xml_from_reverse_protocol_binder returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USER_DATA_FROM_REVERSE_PROTOCOL_BINDER;
+
+       void *user_data = NULL;;
+
+       user_data = sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+       if (user_data != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_user_data_from_reverse_protocol_binder returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_user_data_from_reverse_protocol_binder_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_USER_DATA_FROM_REVERSE_PROTOCOL_BINDER;
+
+       void *user_data = NULL;
+
+       user_data = sync_agent_get_user_data_from_reverse_protocol_binder(NULL);
+       if (user_data != NULL) {
+               dts_message(api_name, "sync_agent_get_user_data_from_reverse_protocol_binder returned non-NULL");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_switch_protocol_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SWITCH_PROTOCOL;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_switch_protocol(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_switch_protocol returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_switch_protocol_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SWITCH_PROTOCOL;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_switch_protocol(binder, SYNC_AGENT_PB_PROTOCOL_UNKNOWN);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_switch_protocol returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_undo_switch_protocol_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNDO_SWITCH_PROTOCOL;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_undo_switch_protocol(binder);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_undo_switch_protocol returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_undo_switch_protocol_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNDO_SWITCH_PROTOCOL;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_undo_switch_protocol(NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_undo_switch_protocol returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME;
+
+       node = sync_agent_create_node(NULL, "Item");
+       if (node == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_create_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE;
+
+       node = sync_agent_create_node_with_namespace(binder, "FolderCreate", "FolderHierarchy:");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE;
+
+       node = sync_agent_create_node_with_namespace(NULL, "FolderCreate", "FolderHierarchy:");
+       if (node == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_create_node_with_namespace returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_TEXT;
+
+       node = sync_agent_create_text_node(binder, "SaveInSentItems", "1", 1);
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_text_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_text_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_TEXT;
+
+       node = sync_agent_create_text_node(NULL, "SaveInSentItems", "1", 1);
+       if (node == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_create_text_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT;
+       char *client_id = "test_account";
+
+       node = sync_agent_create_text_node_with_namespace(binder, "ClientId", "ComposeMail:", client_id, strlen(client_id));
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_text_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_and_namespace_with_text_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT;
+       char *client_id = "test_account";
+
+       node = sync_agent_create_text_node_with_namespace(NULL, "ClientId", "ComposeMail:", client_id, strlen(client_id));
+       if (node == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_create_text_node_with_namespace returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_CDATA;
+       char *mime = "mime";
+
+       node = sync_agent_create_cdata_node(binder, "MIME", mime, strlen(mime));
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_cdata_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_node_using_xml_name_with_cdata_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_NODE_USING_XML_NAME_WITH_CDATA;
+       char *mime = "mime";
+
+       node = sync_agent_create_cdata_node(NULL, "MIME", mime, strlen(mime));
+       if (node == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_create_cdata_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_tree_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_TREE;
+
+       tree = sync_agent_create_wbxml_tree(binder);
+       if (tree == NULL) {
+               dts_message(api_name, "sync_agent_create_wbxml_tree returned NULL");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_wbxml_tree_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_WBXML_TREE;
+
+       tree = sync_agent_create_wbxml_tree(NULL);
+       if (tree == NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_wbxml_tree returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_WBXML_TREE_TO_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_add_wbxml_tree_to_wbxml_node(node, tree);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_add_wbxml_tree_to_wbxml_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_wbxml_tree_to_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_WBXML_TREE_TO_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_add_wbxml_tree_to_wbxml_node(NULL, tree);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_add_wbxml_tree_to_wbxml_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_WBXML_TREE_ROOT;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       node_child = sync_agent_create_node(binder, "Source");
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_set_wbxml_tree_root(tree, node_child);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_set_wbxml_tree_root returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_wbxml_tree_root_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_WBXML_TREE_ROOT;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_set_wbxml_tree_root(tree, NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_set_wbxml_tree_root returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME;
+
+       node_child = sync_agent_add_child_node(binder, node, "Source");
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME;
+
+       node_child = sync_agent_add_child_node(binder, node, "Source");
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE;
+
+       node_child = sync_agent_add_child_node_with_namespace(binder, node, "Options", "ItemOperations:");
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE;
+
+       node_child = sync_agent_add_child_node_with_namespace(NULL, node, "Options", "ItemOperations:");
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_TEXT;
+       char *loc_uri = "loc_uri";
+
+       node_child = sync_agent_add_child_text_node(binder, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_text_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_TEXT;
+       char *loc_uri = "loc_uri";
+
+       node_child = sync_agent_add_child_text_node(NULL, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_text_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT;
+       char *sync_key = "sync_key";
+
+       node_child = sync_agent_add_child_text_node_with_namespace(binder, node, "SyncKey", "FolderHierarchy:", sync_key, strlen(sync_key));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_text_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_TEXT;
+       char *sync_key = "sync_key";
+
+       node_child = sync_agent_add_child_text_node_with_namespace(NULL, node, "SyncKey", "FolderHierarchy:", sync_key, strlen(sync_key));
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_text_node_with_namespace returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_CDATA;
+       char *data = "data";
+
+       node_child = sync_agent_add_child_cdata_node(binder, node, "Data", data, strlen(data));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_cdata_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_cdata_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_CDATA;
+       char *data = "data";
+
+       node_child = sync_agent_add_child_cdata_node(NULL, node, "Data", data, strlen(data));
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_cdata_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_INT;
+       int mime_support = 1;
+
+       node_child = sync_agent_add_child_int_node(binder, node, "MIMESupport", mime_support);
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_int_node returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_with_int_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_WITH_INT;
+       int mime_support = 1;
+
+       node_child = sync_agent_add_child_int_node(NULL, node, "MIMESupport", mime_support);
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_int_node returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_INT;
+       int type = 1;
+
+       node_child = sync_agent_add_child_int_node_with_namespace(binder, node, "Type", "FolderHierarchy:", type);
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_int_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_int_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ADD_CHILD_WBXML_NODE_USING_XML_NAME_AND_NAMESPACE_WITH_INT;
+       int type = 1;
+
+       node_child = sync_agent_add_child_int_node_with_namespace(NULL, node, "Type", "FolderHierarchy:", type);
+       if (node_child == NULL) {
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node_child);
+               dts_message(api_name, "sync_agent_add_child_int_node_with_namespace returned non-NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_NAME_FROM_ELEMENT_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml_name = NULL;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_name_from_element_node(node, &xml_name);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_set_wbxml_tree_root returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_xml_name_from_element_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_XML_NAME_FROM_ELEMENT_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *xml_name = NULL;
+
+       binder = sync_agent_init_protocol_binder(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL, SYNC_AGENT_PB_ENCODING_XML, false, false, false, true, false, NULL, NULL, binder_function_set);
+       if (binder == NULL) {
+               dts_message(api_name, "sync_agent_init_protocol_binder returned NULL");
+               dts_fail(api_name);
+       }
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_name_from_element_node(NULL, &xml_name);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_name_from_element_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_NAMESPACE_FROM_ELEMENT_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *name_space = NULL;
+
+       node = sync_agent_create_node_with_namespace(binder, "FolderCreate", "FolderHierarchy:");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_namespace_from_element_node(binder, node, &name_space);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_namespace_from_element_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_namespace_from_element_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_NAMESPACE_FROM_ELEMENT_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *name_space = NULL;
+
+       node = sync_agent_create_node_with_namespace(binder, "FolderCreate", "FolderHierarchy:");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node_with_namespace returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_namespace_from_element_node(NULL, node, &name_space);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_namespace_from_element_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *loc_uri = "loc_uri";
+       char *text_pointer = NULL;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_text_node(binder, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_text_from_node(node_child, &text_pointer);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_text_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *loc_uri = "loc_uri";
+       char *text_pointer = NULL;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_text_node(binder, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_text_from_node(NULL, &text_pointer);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_text_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_BINARY_POINTER_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *loc_uri = "loc_uri";
+       char *binary_pointer = NULL;
+       unsigned int binary_size = 0;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_text_node(binder, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_binary_from_node(node_child, &binary_pointer, &binary_size);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_binary_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_binary_pointer_from_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_BINARY_POINTER_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *loc_uri = "loc_uri";
+       char *binary_pointer = NULL;
+       unsigned int binary_size = 0;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_text_node(binder, node, "LocURI", loc_uri, strlen(loc_uri));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_binary_from_node(NULL, &binary_pointer, &binary_size);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_binary_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_INT_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       int value = 0;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_int_node(binder, node, "Node", 777);
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_int_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_int_from_node(node_child, &value);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_int_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_int_from_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_INT_FROM_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       int value = 0;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_int_node(binder, node, "Node", 777);
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_int_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_int_from_node(NULL, &value);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_int_from_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_CDATA_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *data = "data";
+       char *text_pointer = NULL;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_cdata_node(binder, node, "Data", data, strlen(data));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_text_from_cdata_node(node_child, &text_pointer);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_text_from_cdata_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_text_pointer_from_wbxml_cdata_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_TEXT_POINTER_FROM_WBXML_CDATA_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+       char *data = "data";
+       char *text_pointer = NULL;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       node_child = sync_agent_add_child_cdata_node(binder, node, "Data", data, strlen(data));
+       if (node_child == NULL) {
+               dts_message(api_name, "sync_agent_add_child_text_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_get_text_from_cdata_node(NULL, &text_pointer);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               sync_agent_destroy_wbxml_node(node);
+               dts_pass(api_name);
+       } else {
+               sync_agent_destroy_wbxml_node(node);
+               dts_message(api_name, "sync_agent_get_text_from_cdata_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_destroy_wbxml_node_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DESTROY_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       node = sync_agent_create_node(binder, "Item");
+       if (node == NULL) {
+               dts_message(api_name, "sync_agent_create_node returned NULL");
+               dts_fail(api_name);
+       }
+
+       ret = sync_agent_destroy_wbxml_node(node);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_message(api_name, "sync_agent_destroy_wbxml_node returned [%d]", ret);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_destroy_wbxml_node_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DESTROY_WBXML_NODE;
+       sync_agent_pb_error_e ret = SYNC_AGENT_PB_RETURN_OK;
+
+       ret = sync_agent_destroy_wbxml_node(NULL);
+       if (ret != SYNC_AGENT_PB_RETURN_OK) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_destroy_wbxml_node returned [%d]", ret);
+               dts_fail(api_name);
+       }
+}
+
+// =================================================
+static sync_agent_pb_error_e start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       WBXMLTreeNode *node = sync_agent_create_node(binder, "SyncML");
+       *ppWbxml_dom_node = node;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e header_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       WBXMLTreeNode *node = sync_agent_create_node(binder, "SyncHdr");
+       *ppWbxml_dom_node = node;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e body_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       WBXMLTreeNode *node = sync_agent_create_node(binder, "SyncBody");
+       *ppWbxml_dom_node = node;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e final_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       WBXMLTreeNode *node = sync_agent_create_node(binder, "Final");
+       *ppWbxml_dom_node = node;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e results_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       WBXMLTreeNode *node = sync_agent_create_node(binder, "Results");
+       *ppWbxml_dom_node = node;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+// =================================================
+static sync_agent_pb_error_e header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+       return SYNC_AGENT_PB_RETURN_OK;
+}
+
+static sync_agent_pb_error_e results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+       return SYNC_AGENT_PB_RETURN_OK;
+}
diff --git a/TC/testcase/utc_sync_agent_framework_security_assistant.c b/TC/testcase/utc_sync_agent_framework_security_assistant.c
new file mode 100755 (executable)
index 0000000..01dd9e8
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+#define API_NAME_SYNC_START_UP "startup"
+#define API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH  "sync_agent_encrypt_cryptograhic_hash"
+#define API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH_WITH_FLAGS       "sync_agent_encrypt_cryptograhic_hash_with_flags"
+#define API_NAME_SYNC_AGENT_GET_ENCRYPTION_VALUE       "sync_agent_get_encryption_value"
+
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_p(void);
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_n(void);
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_p(void);
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_n(void);
+static void utc_sync_agent_framework_sync_agent_get_encryption_value_p(void);
+static void utc_sync_agent_framework_sync_agent_get_encryption_value_n(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_encryption_value_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_encryption_value_n, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, "sync-agent", strlen("sync-agent"));
+       if (digest != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agnet_resync_agent_encrypt_cryptograhic_hash returned wrong value");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, NULL, strlen("sync-agent"));
+       if (digest != NULL) {
+               dts_message(api_name, "sync_agnet_resync_agent_encrypt_cryptograhic_hash returned wrong value");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH_WITH_FLAGS;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_encrypt_cryptograhic_hash_with_flags(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, "sync-agent", strlen("sync-agent"), "tizen", strlen("tizen"), SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC);
+       if (digest != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_encrypt_cryptograhic_hash_with_flags returned wrong value");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_encrypt_cryptograhic_hash_with_flags_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ENCRYPT_CRYPTOGRAHIC_HASH_WITH_FLAGS;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_encrypt_cryptograhic_hash_with_flags(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, NULL, strlen("sync-agent"), "tizen", strlen("tizen"), SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC);
+       if (digest != NULL) {
+               dts_message(api_name, "sync_agnet_resync_agent_encrypt_cryptograhic_hash returned wrong value");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_encryption_value_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ENCRYPTION_VALUE;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_get_encryption_value(SYNC_AGENT_SA_ENCRYPTION_MD5, "sync-agent", strlen("sync-agent"));
+       if (digest != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_encryption_value returned wrong value");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_encryption_value_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ENCRYPTION_VALUE;
+
+       unsigned char *digest = NULL;
+
+       digest = sync_agent_get_encryption_value(SYNC_AGENT_SA_ENCRYPTION_MD5, NULL, strlen("sync-agent"));
+       if (digest != NULL) {
+               dts_message(api_name, "sync_agent_get_encryption_value returned wrong value");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
diff --git a/TC/testcase/utc_sync_agent_framework_utility.c b/TC/testcase/utc_sync_agent_framework_utility.c
new file mode 100755 (executable)
index 0000000..696ace4
--- /dev/null
@@ -0,0 +1,565 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <tet_api.h>
+
+#include <sync_agent.h>
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+sync_agent_util_ref_object_s *ref_object = NULL;
+
+#define API_NAME_SYNC_AGENT_ALLOC_ASYNC_QUEUE  "sync_agent_alloc_async_queue"
+#define API_NAME_SYNC_AGENT_RECEIVE_MSG_ASYNC_QUEUE    "sync_agent_receive_msg_async_queue"
+#define API_NAME_SYNC_AGENT_ASYNC_QUEUE_LENGTH "sync_agent_async_queue_length"
+#define API_NAME_SYNC_AGENT_COMPRESS           "sync_agent_compress"
+#define API_NAME_SYNC_AGENT_UNCOMPRESS "sync_agent_uncompress"
+#define API_NAME_SYNC_AGENT_SET_INT_INTO_FILE  "sync_agent_set_int_into_file"
+#define API_NAME_SYNC_AGENT_GET_INT_INTO_FILE  "sync_agent_get_int_into_file"
+#define API_NAME_SYNC_AGENT_GET_MAIN_LOOP      "sync_agent_get_main_loop"
+#define API_NAME_SYNC_AGENT_CONVERT_SECONDS_TO_UTC     "sync_agent_convert_seconds_to_utc"
+#define API_NAME_SYNC_AGENT_CREATE_REFERENCED_OBJECT   "sync_agent_create_referenced_object"
+#define API_NAME_SYNC_AGENT_GET_REFERENCED_OBJECT              "sync_agent_get_referenced_object"
+#define API_NAME_SYNC_AGENT_GET_ORIGINAL_OBJECT                "sync_agent_get_original_object"
+#define API_NAME_SYNC_AGENT_COMPARE_OBJECT     "sync_agent_compare_object"
+#define API_NAME_SYNC_AGENT_DAEMONIZE  "sync_agent_daemonize"
+
+static void utc_sync_agent_framework_sync_agent_alloc_async_queue_p(void);
+static void utc_sync_agent_framework_sync_agent_receive_msg_async_queue_p(void);
+static void utc_sync_agent_framework_sync_agent_receive_msg_async_queue_n(void);
+static void utc_sync_agent_framework_sync_agent_async_queue_length_p(void);
+static void utc_sync_agent_framework_sync_agent_async_queue_length_n(void);
+static void utc_sync_agent_framework_sync_agent_compress_p(void);
+static void utc_sync_agent_framework_sync_agent_compress_n(void);
+static void utc_sync_agent_framework_sync_agent_uncompress_p(void);
+static void utc_sync_agent_framework_sync_agent_uncompress_n(void);
+static void utc_sync_agent_framework_sync_agent_set_int_into_file_p(void);
+static void utc_sync_agent_framework_sync_agent_set_int_into_file_n(void);
+static void utc_sync_agent_framework_sync_agent_get_int_into_file_p(void);
+static void utc_sync_agent_framework_sync_agent_get_int_into_file_n(void);
+static void utc_sync_agent_framework_sync_agent_get_main_loop_p(void);
+static void utc_sync_agent_framework_sync_agent_get_main_loop_n(void);
+static void utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_p(void);
+static void utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_n(void);
+static void utc_sync_agent_framework_sync_agent_create_referenced_object_p(void);
+static void utc_sync_agent_framework_sync_agent_create_referenced_object_n(void);
+static void utc_sync_agent_framework_sync_agent_get_referenced_object_p(void);
+static void utc_sync_agent_framework_sync_agent_get_referenced_object_n(void);
+static void utc_sync_agent_framework_sync_agent_get_original_object_p(void);
+static void utc_sync_agent_framework_sync_agent_get_original_object_n(void);
+static void utc_sync_agent_framework_sync_agent_compare_object_p(void);
+static void utc_sync_agent_framework_sync_agent_compare_object_n(void);
+static void utc_sync_agent_framework_sync_agent_daemonize_p(void);
+
+struct tet_testlist tet_testlist[] = {
+       {utc_sync_agent_framework_sync_agent_alloc_async_queue_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_receive_msg_async_queue_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_receive_msg_async_queue_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_async_queue_length_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_async_queue_length_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_compress_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_compress_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_uncompress_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_uncompress_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_int_into_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_set_int_into_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_int_into_file_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_int_into_file_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_main_loop_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_main_loop_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_referenced_object_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_create_referenced_object_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_referenced_object_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_referenced_object_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_original_object_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_get_original_object_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_compare_object_p, POSITIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_compare_object_n, NEGATIVE_TC_IDX},
+       {utc_sync_agent_framework_sync_agent_daemonize_p, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       /* start of TC */
+}
+
+static void cleanup(void)
+{
+       /* start of TC */
+}
+
+static void utc_sync_agent_framework_sync_agent_alloc_async_queue_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ALLOC_ASYNC_QUEUE;
+
+       static sync_agent_util_async_queue_s *queue;
+
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               dts_message(api_name, "sync_agent_alloc_async_queue : returned NULL");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_receive_msg_async_queue_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RECEIVE_MSG_ASYNC_QUEUE;
+
+       static sync_agent_util_async_queue_s *queue;
+
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               dts_message(api_name, "sync_agent_alloc_async_queue : returned NULL");
+               dts_fail(api_name);
+       }
+
+       sync_agent_send_msg_async_queue(queue, "test message");
+
+       char *message = sync_agent_receive_msg_async_queue(queue);
+       if (!strcmp(message, "test message")) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_receive_msg_async_queue returned [%s]", message);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_receive_msg_async_queue_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_RECEIVE_MSG_ASYNC_QUEUE;
+
+       static sync_agent_util_async_queue_s *queue;
+
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               dts_message(api_name, "sync_agent_alloc_async_queue : returned NULL");
+               dts_fail(api_name);
+       }
+
+       sync_agent_send_msg_async_queue(queue, "test message");
+
+       char *message = sync_agent_receive_msg_async_queue(NULL);
+       if (message != NULL) {
+               dts_message(api_name, "sync_agent_receive_msg_async_queue returned [%s]", message);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_async_queue_length_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ASYNC_QUEUE_LENGTH;
+
+       static sync_agent_util_async_queue_s *queue;
+
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               dts_message(api_name, "sync_agent_alloc_async_queue : returned NULL");
+               dts_fail(api_name);
+       }
+
+       sync_agent_send_msg_async_queue(queue, "test message 1");
+       sync_agent_send_msg_async_queue(queue, "test message 2");
+       sync_agent_send_msg_async_queue(queue, "test message 3");
+
+       int length = sync_agent_async_queue_length(queue);
+       if (length == 3) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_async_queue_length returned [%d] and it is wrong", length);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_async_queue_length_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_ASYNC_QUEUE_LENGTH;
+
+       static sync_agent_util_async_queue_s *queue;
+
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               dts_message(api_name, "sync_agent_alloc_async_queue : returned NULL");
+               dts_fail(api_name);
+       }
+
+       sync_agent_send_msg_async_queue(queue, "test message 1");
+       sync_agent_send_msg_async_queue(queue, "test message 2");
+       sync_agent_send_msg_async_queue(queue, "test message 3");
+
+       int length = sync_agent_async_queue_length(NULL);
+       if (length == -1) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_async_queue_length returned [%d] and it is wrong", length);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_compress_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COMPRESS;
+
+       sync_agent_util_compress_result_e result = sync_agent_compress(SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR, "../../../testcase/fw-test-file/target_compress", "../../../testcase/fw-test-file/target_compress.tar");
+       if (result == SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+               sync_agent_delete_file("../../../testcase/fw-test-file/target_compress.tar");
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_compress returned [%d]", result);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_compress_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COMPRESS;
+
+       sync_agent_util_compress_result_e result = sync_agent_compress(SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR, "../../../testcase/fw-test-file/target_compress_not_existing", "../../../testcase/fw-test-file/target_compress.tar");
+       if (result == SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+               dts_message(api_name, "sync_agent_compress returned [%d]", result);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_uncompress_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNCOMPRESS;
+
+       sync_agent_util_compress_result_e result = sync_agent_uncompress(SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR, "../../../testcase/fw-test-file/target_uncompress.tar", "/");
+       if (result == SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+               sync_agent_delete_file("../../../testcase/fw-test-file/target_uncompress");
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_uncompress returned [%d]", result);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_uncompress_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_UNCOMPRESS;
+
+       sync_agent_util_compress_result_e result = sync_agent_uncompress(SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR, "../../../testcase/fw-test-file/target_uncompress.tar_not_existing", "/");
+       if (result == SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+               dts_message(api_name, "sync_agent_uncompress returned [%d]", result);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_int_into_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_INT_INTO_FILE;
+
+       int value_in = 2012;
+       int value_out = 0;
+       int result = sync_agent_set_int_into_file("test", value_in);
+       if (!result) {
+               dts_message(api_name, "sync_agent_set_int_into_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+
+       result = sync_agent_get_int_from_file("test", &value_out);
+       if (!result) {
+               dts_message(api_name, "sync_agent_get_int_from_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+
+       if (value_out == value_in) {
+               sync_agent_unset_file("test");
+               dts_pass(api_name);
+       } else {
+               sync_agent_unset_file("test");
+               dts_message(api_name, "sync_agent_compress returned [%d]", value_out);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_set_int_into_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_SET_INT_INTO_FILE;
+
+       int value_in = 2012;
+       int value_out = 0;
+       int result = sync_agent_set_int_into_file(NULL, value_in);
+       if (!result) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_set_int_into_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_int_into_file_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_INT_INTO_FILE;
+
+       int value_in = 2012;
+       int value_out = 0;
+       int result = sync_agent_set_int_into_file("test", value_in);
+       if (!result) {
+               dts_message(api_name, "sync_agent_set_int_into_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+
+       result = sync_agent_get_int_from_file("test", &value_out);
+       if (!result) {
+               dts_message(api_name, "sync_agent_get_int_from_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+
+       if (value_out == value_in) {
+               sync_agent_unset_file("test");
+               dts_pass(api_name);
+       } else {
+               sync_agent_unset_file("test");
+               dts_message(api_name, "sync_agent_compress returned [%d]", value_out);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_int_into_file_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_INT_INTO_FILE;
+
+       int value_in = 2012;
+       int value_out = 0;
+       int result = sync_agent_set_int_into_file("test", value_in);
+       if (!result) {
+               dts_message(api_name, "sync_agent_set_int_into_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+
+       result = sync_agent_get_int_from_file("test_not_existsing", &value_out);
+       if (!result) {
+               sync_agent_unset_file("test");
+               dts_pass(api_name);
+       } else {
+               sync_agent_unset_file("test");
+               dts_message(api_name, "sync_agent_get_int_from_file returned [%d]", result);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_main_loop_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAIN_LOOP;
+
+       sync_agent_run_main_loop(true);
+
+       if (sync_agent_get_main_loop() != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_main_loop returned NULL");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_main_loop_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_MAIN_LOOP;
+
+       sync_agent_stop_main_loop(true);
+
+       if (sync_agent_get_main_loop() != NULL) {
+               dts_message(api_name, "sync_agent_get_main_loop returned non-NULL");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONVERT_SECONDS_TO_UTC;
+
+       int utc = sync_agent_convert_seconds_to_utc(time(NULL));
+       if (utc != 0) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_convert_seconds_to_utc returned invalid value [%d]", utc);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_convert_seconds_to_utc_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CONVERT_SECONDS_TO_UTC;
+
+       int utc = sync_agent_convert_seconds_to_utc(0);
+       if (utc != sync_agent_convert_seconds_to_utc(time(NULL))) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_convert_seconds_to_utc returned invalid value [%d]", utc);
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_referenced_object_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_REFERENCED_OBJECT;
+
+       char *data = (char *)calloc(1, sizeof(char));
+
+       ref_object = sync_agent_create_referenced_object(data, free);
+       if (ref_object != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_create_referenced_object returned NULL !!!");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_create_referenced_object_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_CREATE_REFERENCED_OBJECT;
+
+       char *data = (char *)calloc(1, sizeof(char));
+
+       ref_object = sync_agent_create_referenced_object(NULL, free);
+       if (ref_object != NULL) {
+               dts_message(api_name, "sync_agent_create_referenced_object returned non-NULL !!!");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_referenced_object_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_REFERENCED_OBJECT;
+
+       ref_object = sync_agent_get_referenced_object(ref_object);
+       if (ref_object != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_referenced_object returned NULL !!!");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_referenced_object_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_REFERENCED_OBJECT;
+
+       ref_object = sync_agent_get_referenced_object(NULL);
+       if (ref_object != NULL) {
+               dts_message(api_name, "sync_agent_get_referenced_object returned non-NULL !!!");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_original_object_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ORIGINAL_OBJECT;
+
+       char *data = sync_agent_get_original_object(ref_object);
+       if (data != NULL) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_original_object returned NULL !!!");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_get_original_object_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_GET_ORIGINAL_OBJECT;
+
+       char *data = sync_agent_get_original_object(NULL);
+       if (data != NULL) {
+               dts_message(api_name, "sync_agent_get_original_object returned non-NULL !!!");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_compare_object_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COMPARE_OBJECT;
+
+       char *data = (char *)calloc(1, sizeof(char));
+
+       sync_agent_util_ref_object_s *ref_object1 = NULL;
+       sync_agent_util_ref_object_s *ref_object2 = NULL;
+
+       ref_object1 = sync_agent_create_referenced_object(data, free);
+       ref_object2 = sync_agent_create_referenced_object(data, free);
+
+       bool result = sync_agent_compare_object(ref_object1, ref_object2);
+       if (result == true) {
+               dts_pass(api_name);
+       } else {
+               dts_message(api_name, "sync_agent_get_original_object returned FALSE !!!");
+               dts_fail(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_compare_object_n(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_COMPARE_OBJECT;
+
+       char *data = (char *)calloc(1, sizeof(char));
+
+       sync_agent_util_ref_object_s *ref_object1 = NULL;
+       sync_agent_util_ref_object_s *ref_object2 = NULL;
+
+       ref_object1 = sync_agent_create_referenced_object(data, free);
+       ref_object2 = sync_agent_create_referenced_object(data, free);
+
+       bool result = sync_agent_compare_object(NULL, ref_object2);
+       if (result == true) {
+               dts_message(api_name, "sync_agent_get_original_object returned TRUE !!!");
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
+
+static void utc_sync_agent_framework_sync_agent_daemonize_p(void)
+{
+       char *api_name = API_NAME_SYNC_AGENT_DAEMONIZE;
+
+       int result = sync_agent_daemonize();
+       if (result != 0) {
+               dts_message(api_name, "sync_agent_daemonize returned [%d]", result);
+               dts_fail(api_name);
+       } else {
+               dts_pass(api_name);
+       }
+}
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100644 (file)
index 0000000..03f029a
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/testcase/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..1d79cc2
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=False # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..02d7030
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage 
+TET_PASS_TC_NAME=True # showing name , passed TC
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..ae32528
--- /dev/null
@@ -0,0 +1,5 @@
+TET_OUTPUT_CAPTURE=False # capturing execution or not
+TET_EXEC_TOOL=  # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE=   # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
diff --git a/common-public-plugins.manifest b/common-public-plugins.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..9f09e5b
--- /dev/null
@@ -0,0 +1,63 @@
+libsync-agent-framework (0.1.8) unstable; urgency=low
+
+  * 1. prevent defect patch. - resource free.
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.8
+
+ -- Juhaki Park <juhaki.park@samsung.com>  Thu, 24 Jan 2013 11:12:10 +0900
+
+libsync-agent-framework (0.1.7) unstable; urgency=low
+
+  * 1. license , prevent defect patch.
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.7
+
+ -- Juhaki Park <juhaki.park@samsung.com>  Mon, 21 Jan 2013 21:55:10 +0900
+
+libsync-agent-framework (0.1.6) unstable; urgency=low
+
+  * 1. account api patch.
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.6
+
+ -- Juhaki Park <juhaki.park@samsung.com>  Fri, 11 Jan 2013 14:15:10 +0900
+
+libsync-agent-framework (0.1.5) unstable; urgency=low
+
+  * 1. Prevent defects fixed.
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.5
+
+ -- Juhaki Park <juhaki.park@samsung.com>  Thu, 10 Jan 2013 10:06:10 +0900
+
+libsync-agent-framework (0.1.4) unstable; urgency=low
+
+  * 1. Smack file removed (common-private-plugins.manifest)
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.4
+
+ -- WooJin Yun <suhoangel9@samsung.com>  Wed, 09 Jan 2013 18:46:16 +0900
+
+libsync-agent-framework (0.1.3) unstable; urgency=low
+
+  * 1. Prevent defects fixed.
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.3
+
+ -- Juhaki Park <juhaki.park@samsung.com>  Wed, 09 Jan 2013 18:16:10 +0900
+
+libsync-agent-framework (0.1.2) unstable; urgency=low
+
+  * 1. Internal: build error & dependency patch
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.2
+
+ -- WooJin Yun <suhoangel9@samsung.com>  Fri, 28 Dec 2012 22:40:10 +0900
+
+libsync-agent-framework (0.1.1) unstable; urgency=low
+
+  * Initial update
+  * Git: framework/system/sync-agent
+  * Tag: sync-agent_0.1.1 
+
+ -- WooJin Yun <suhoangel9@samsung.com>  Wed, 01 Feb 2012 10:30:16 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100755 (executable)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..71b7bfd
--- /dev/null
@@ -0,0 +1,30 @@
+Source: libsync-agent-framework
+Section: embedded
+Priority: optional
+Maintainer: WooJin Yun <suhoangel9@samsung.com>, Joohark Park <juhaki.park@samsung.com>, Junhyuk Lee <junhyuk7.lee@samsung.com>, Sunbong Ha<sunbong.ha@samsung.com>
+Uploaders: Joohark Park <juhaki.park@samsung.com>, Junhyuk Lee <junhyuk7.lee@samsung.com>, Sunbong Ha<sunbong.ha@samsung.com>
+Build-Depends: debhelper (>= 5), libslp-msg-service-dev, libslp-calendar-dev, libslp-memo-dev, libcontacts-service-dev, libaccounts-svc-dev, email-service-dev, drm-client-dev, libvconf-dev, uuid-dev, dlog-dev, libglib2.0-dev, libsqlite3-dev, libsoup2.4-dev, check, libxml2-dev, libbookmark-service-dev, libslp-alarm-dev, capi-messaging-push-dev, libgcrypt11, libgcrypt11-dev, libwbxml2-dev, libslp-location-dev, libslp-pm-dev, libslp-tapi-dev, libslp-sysman-dev, libdata-router-interface-dev, liboauth-dev, libmobex-connector-interface-dev, libeas-common-dev, libslp-db-util-dev, libalarm-dev, libsamsung-sso-svc-dev, capi-network-connection-dev, libmdm-dev, libaul-1-dev, syspopup-caller-dev, libslp-smemo-dev
+#Build-Depends: debhelper (>= 5), libslp-msg-service-dev, libslp-calendar-dev, libslp-memo-dev, libcontacts-service-dev, libaccounts-svc-dev, email-service-dev, drm-client-dev, libvconf-dev, uuid-dev, dlog-dev, libglib2.0-dev, libsqlite3-dev, libsoup2.4-dev, check, libxml2-dev, libbookmark-service-dev, libslp-alarm-dev, capi-messaging-push-dev, libgcrypt11, libgcrypt11-dev, libwbxml2-dev, libslp-location-dev, libslp-pm-dev, libtapi-dev, libslp-sysman-dev, libdata-router-interface-dev, liboauth-dev, libmobex-connector-interface-dev, libeas-common-dev, libslp-db-util-dev, libalarm-dev, libsamsung-sso-svc-dev, capi-network-connection-dev, libmdm-dev, libaul-1-dev, syspopup-caller-dev, libssl-dev
+Standards-Version: 0.1.1
+
+Package: libsync-agent-framework
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Integrated Framework Library Package
+
+Package: libsync-agent-framework-dev
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}, libsync-agent-framework (= ${Source-Version})
+Description: Integrated Framework Library Package (dev)
+
+Package: libsync-agent-framework-dbg
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${misc:Depends}, libsync-agent-framework (= ${Source-Version})
+Description: Integrated Framework Library Package (dbg)
+
diff --git a/debian/control.slp b/debian/control.slp
new file mode 100755 (executable)
index 0000000..fba21bb
--- /dev/null
@@ -0,0 +1,7 @@
+#Sat May 15 19:14:26 KST 2010
+Version=1.0.0
+IdealScreen=480x800,46x71
+Vendor=slp
+Privileges=
+AppInstallPath=/usr
+UserUninstall=yes
diff --git a/debian/dirs b/debian/dirs
new file mode 100755 (executable)
index 0000000..4418816
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/debian/libsync-agent-framework-dev.install b/debian/libsync-agent-framework-dev.install
new file mode 100755 (executable)
index 0000000..5bb2016
--- /dev/null
@@ -0,0 +1,2 @@
+/usr/lib/pkgconfig/*
+/usr/include/*
diff --git a/debian/libsync-agent-framework-dev.postinst b/debian/libsync-agent-framework-dev.postinst
new file mode 100755 (executable)
index 0000000..08d231a
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm -rf /usr/include/agent-framework/agent-framework
+
diff --git a/debian/libsync-agent-framework.install b/debian/libsync-agent-framework.install
new file mode 100755 (executable)
index 0000000..c5a962b
--- /dev/null
@@ -0,0 +1 @@
+/usr/lib/*.*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..f16dec6
--- /dev/null
@@ -0,0 +1,104 @@
+#!/usr/bin/make -f
+
+## DO NOT MODIFY THIS AREA : BEGIN
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# $(PKGDIR) is a package build directory to create a final .deb package .
+include debian/control.slp
+
+PKGDIR = debian/PKG
+ifneq (,$(filter ide,$(DEB_BUILD_OPTIONS)))
+DESTDIR = .
+else
+DESTDIR = ..
+endif
+CONTROLFILE = debian/control.slp
+CONTROLFILE_SRC = debian/control
+
+BUILD_TYPE=Debug
+# BUILD_TYPE=Release
+
+# UNIT_TEST_ENABLE=TRUE
+ UNIT_TEST_ENABLE=FALSE
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+build: pre-build configure
+       # Add here commands to compile the package.
+       $(MAKE)
+
+
+configure: 
+       cmake . -DCMAKE_INSTALL_PREFIX=${AppInstallPath} -DCMAKE_PROJECT=${Source} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DUNIT_TEST_ENABLE=${UNIT_TEST_ENABLE}
+       rm -rf CMakeFiles/CompilerIdC*
+#      sed 's/^Package:.*$$/Package: $(Package)/' $(CONTROLFILE_SRC) > $(CONTROLFILE_SRC).tmp ; mv -f $(CONTROLFILE_SRC).tmp $(CONTROLFILE_SRC)
+
+clean: 
+       # Add here commands to clean up before the build process.
+       # debian clean
+       -$(MAKE) clean
+
+       -find . -name "CMakeFiles" -exec rm -rf {} \;
+       -find . -name "CMakeCache.txt" -exec rm -rf {} \;
+       -find . -name "Makefile" -exec rm -rf {} \;
+       -find . -name "cmake_install.cmake" -exec rm -rf {} \;
+       -find . -name "install_manifest.txt" -exec rm -rf {} \;
+       -find . -name "*.pc" -exec rm -rf {} \;
+       -find . -name "*.so" -exec rm -rf {} \;
+
+       -rm -rf $(PKGDIR)
+
+       dh_clean
+
+install: build pre-install
+       rm -rf $(PKGDIR)
+       mkdir $(PKGDIR)
+
+       # Add here commands to install the package into $(PKGDIR).
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+       
+       #execute unit test
+       debian/unit_test.sh ./debian/tmp/usr/bin/fw-test
+
+# Build architecture-dependent files here.
+binary: install pre-binary
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+       dh_link
+       dh_strip --dbg-package=libsync-agent-framework-dbg
+       dh_compress
+       dh_fixperms
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+       
+
+.PHONY: build clean install binary 
+## DO NOT MODIFY THIS AREA : END
+
+## DO NOT MODIFY OR DELETE TARGET.
+pre-build:
+       # Add here commands to execute before the build process.
+
+pre-install:
+       # Add here commands to execute before installing the binaries into $(PKGDIR).
+
+pre-binary:
+       # Add here commands to execute before creating a package.
+
diff --git a/debian/unit_test.sh b/debian/unit_test.sh
new file mode 100755 (executable)
index 0000000..c2bc14f
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+FW_TEST_BIN="$1"
+echo "$FW_TEST_BIN"
+
+echo ""
+echo "*********************************************************************************"
+echo "                  executing framework unit test binary..."
+echo "*********************************************************************************"
+echo ""
+
+if [ ! -e "$FW_TEST_BIN" ]
+then
+        echo "  fw-test binary missing. (check debian package is in unit test mode)"
+else
+        echo ""
+        echo ""
+        echo "*********************************************************************************"
+        echo "                  framework unit test START..."
+        echo "*********************************************************************************"
+        echo ""
+        
+       $FW_TEST_BIN
+        
+       echo ""
+        echo ""
+        echo "*********************************************************************************"
+        echo "                  framework unit test FINISH..."
+        echo "*********************************************************************************"
+        echo ""
+fi
+
diff --git a/doc/Doxyfile b/doc/Doxyfile
new file mode 100644 (file)
index 0000000..46cb49d
--- /dev/null
@@ -0,0 +1,1790 @@
+# Doxyfile 1.7.6.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should 
+# identify the project. Note that if you do not use Doxywizard you need 
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME           = "Sync-agent Framework"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 1.0
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description 
+# for a project that appears at the top of each page and should give viewer 
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = 
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is 
+# included in the documentation. The maximum height of the logo should not 
+# exceed 55 pixels and the maximum width should not exceed 200 pixels. 
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           = ./images/tizen_logo.png
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = .
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful if your file system 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only). 
+# A mapping has the form "name=value". For example adding 
+# "class=itcl::class" will allow you to use the command class in the 
+# itcl::class meaning.
+
+TCL_SUBST              = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it 
+# parses. With this tag you can assign which parser to use for a given extension. 
+# Doxygen has a built-in mapping, but you can override or extend it using this 
+# tag. The format is ext=language, where ext is a file extension, and language 
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also makes the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 
+# unions are shown inside the group in which they are included (e.g. using 
+# @ingroup) instead of on a separate page (for HTML and Man pages) or 
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 
+# unions with only public data fields will be shown inline in the documentation 
+# of the scope in which they are defined (i.e. file, namespace, or group 
+# documentation), provided this scope is documented. If set to NO (the default), 
+# structs, classes, and unions are shown on a separate page (for HTML and Man 
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penalty. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will roughly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE      = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 
+# their name and scope. Since this can be an expensive process and often the 
+# same symbol appear multiple times in the code, doxygen keeps a cache of 
+# pre-resolved symbols. If the cache is too small doxygen will become slower. 
+# If the cache is too large, memory is wasted. The cache size is given by this 
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 
+# will list include files with double quotes in the documentation 
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 
+# will sort the (brief and detailed) documentation of class members so that 
+# constructors and destructors are listed first. If set to NO (the default) 
+# the constructors will appear in the respective orders defined by 
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 
+# do proper type resolution of all parameters of a function it will reject a 
+# match between the prototype and the implementation of a member function even 
+# if there is only one candidate or it is obvious which candidate to choose 
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or macro consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and macros in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 
+# by doxygen. The layout file controls the global structure of the generated 
+# output files in an output format independent way. The create the layout file 
+# that represents doxygen's defaults, run doxygen with the -l option. 
+# You can optionally specify a file name after the option, if omitted 
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            = DoxygenLayout.xml
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files 
+# containing the references data. This must be a list of .bib files. The 
+# .bib extension is automatically appended if omitted. Using this command 
+# requires the bibtex tool to be installed. See also 
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES         = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = ./ \
+                         ../include/ \
+                         ../include/account \
+                         ../include/data-adapter \
+                         ../include/device \
+                         ../include/device-manager \
+                         ../include/engine-controller \
+                         ../include/event \
+                         ../include/fsapi \
+                         ../include/initialization \
+                         ../include/network-access \
+                         ../include/protocol-binder \
+                         ../include/platform-monitor \
+                         ../include/plugin \
+                         ../include/plugin \
+                         ../include/security-assistant \
+                         ../include/utility
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag. 
+# Note that relative paths are relative to the directory from which doxygen is 
+# run.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 
+# directories that are symbolic links (a Unix file system feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = ../test/client/oma-ds \
+                         ../test/client/oma-dm \
+                         .
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = ./images
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty or if 
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) 
+# and it is also possible to disable source filtering for a specific pattern 
+# using *.ext= (so without naming a filter). This option only has effect when 
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS = 
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
+# link to the source code.  Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header. Note that when using a custom header you are responsible  
+# for the proper inclusion of any scripts and style sheets that doxygen 
+# needs, which is dependent on the configuration options used. 
+# It is advised to generate a default header using "doxygen -w html 
+# header.html footer.html stylesheet.css YourConfigFile" and then modify 
+# that header. Note that the header is subject to change so you typically 
+# have to redo this when upgrading to a newer version of doxygen or when 
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 
+# other source files which should be copied to the HTML output directory. Note 
+# that these files will be copied to the base HTML output directory. Use the 
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that 
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       = 
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 
+# Doxygen will adjust the colors in the style sheet and background images 
+# according to this color. Hue is specified as an angle on a colorwheel, 
+# see http://en.wikipedia.org/wiki/Hue for more information. 
+# For instance the value 0 represents red, 60 is yellow, 120 is green, 
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 
+# the colors in the HTML output. For a value of 0 the output will use 
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 
+# the luminance component of the colors in the HTML output. Values below 
+# 100 gradually make the output lighter, whereas values above 100 make 
+# the output darker. The value divided by 100 is the actual gamma applied, 
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 
+# page will contain the date and time when the page was generated. Setting 
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 
+# the documentation publisher. This should be a reverse domain-name style 
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = sync_agent_framework_v1.0.chm
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = "D:/Program Files/HTML Help Workshop/hhc.exe"
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 
+# that can be used as input for Qt's qhelpgenerator to generate a 
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 
+# add. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 
+# custom filter to add. For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> 
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 
+# project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> 
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files  
+# will be generated, which together with the HTML files, form an Eclipse help 
+# plugin. To install this plugin and make it available under the help contents 
+# menu in Eclipse, the contents of the directory containing the HTML and XML 
+# files needs to be copied into the plugins directory of eclipse. The name of 
+# the directory within the plugins directory should be the same as 
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin 
+# the directory name containing the HTML and XML files should also have 
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 
+# at top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it. Since the tabs have the same information as the 
+# navigation tree you can set this option to NO if you already set 
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value is set to YES, a side panel will be generated 
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 
+# Windows users are probably better off using the HTML help feature. 
+# Since the tree basically has the same information as the tab index you 
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW      = YES
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML 
+# documentation. Note that a value of 0 will completely suppress the enum 
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE   = 6
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, 
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = YES
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images 
+# generated for formulas are transparent PNGs. Transparent PNGs are 
+# not supported properly for IE 6.0, but are supported on all modern browsers. 
+# Note that when changing this option you need to delete any form_*.png files 
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 
+# (see http://www.mathjax.org) which uses client side Javascript for the 
+# rendering instead of using prerendered bitmaps. Use this if you do not 
+# have LaTeX installed or if you want to formulas look prettier in the HTML 
+# output. When enabled you also need to install MathJax separately and 
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you need to specify the location relative to the 
+# HTML output directory using the MATHJAX_RELPATH option. The destination 
+# directory should contain the MathJax.js script. For instance, if the mathjax 
+# directory is located at the same level as the HTML output directory, then 
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the 
+# mathjax.org site, so you can quickly see the result without installing 
+# MathJax, but it is strongly recommended to install a local copy of MathJax 
+# before deployment.
+
+MATHJAX_RELPATH        = http://www.mathjax.org/mathjax
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     = 
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box 
+# for the HTML output. The underlying search engine uses javascript 
+# and DHTML and should work on any modern browser. Note that when using 
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 
+# (GENERATE_DOCSET) there is already a search function so this one should 
+# typically be disabled. For large projects the javascript based search engine 
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be 
+# implemented using a PHP enabled web server instead of at the web client 
+# using Javascript. Doxygen will generate the search PHP script and index 
+# file to put on the web server. The advantage of the server 
+# based approach is that it scales better to large projects and allows 
+# full text search. The disadvantages are that it is more difficult to setup 
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name. 
+# Note that when enabling USE_PDFLATEX this option is only used for 
+# generating bitmaps for formulas in the HTML output, but not in the 
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 
+# the generated latex document. The footer should contain everything after 
+# the last chapter. If it is left blank doxygen will generate a 
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include 
+# source code with syntax highlighting in the LaTeX output. 
+# Note that which sources are shown also depends on other settings 
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the 
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition that 
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all references to function-like macros 
+# that are alone on a line, have an all uppercase name, and do not end with a 
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links. 
+# Note that each tag file must have a unique name 
+# (where the name does NOT include the path) 
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option also works with HAVE_DOT disabled, but it is recommended to 
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 
+# allowed to run in parallel. When set to 0 (the default) doxygen will 
+# base this on the number of processors available in the system. You can set it 
+# explicitly to a value larger than 0 to get control over the balance 
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will use the Helvetica font for all dot files that 
+# doxygen generates. When you want a differently looking font you can specify 
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find 
+# the font, which can be done by putting it in a standard location or by setting 
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 
+# directory containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the Helvetica font. 
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 
+# set the path where dot can find it.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include 
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are svg, png, jpg, or gif. 
+# If left blank png will be used. If you choose svg you need to set 
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 
+# enable generation of interactive SVG images that allow zooming and panning. 
+# Note that this requires a modern browser other than Internet Explorer. 
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG        = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that 
+# contain msc files that are included in the documentation (see the 
+# \mscfile command).
+
+MSCFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. Warning: Depending on the platform used, 
+# enabling this option may lead to badly anti-aliased labels on the edges of 
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/doc/DoxygenLayout.xml b/doc/DoxygenLayout.xml
new file mode 100644 (file)
index 0000000..1c8525c
--- /dev/null
@@ -0,0 +1,184 @@
+<doxygenlayout version="1.0">
+  <!-- Navigation index tabs for HTML output -->
+  <navindex>
+    <tab type="mainpage" visible="yes" title=""/>
+    <tab type="pages" visible="yes" title=""/>
+    <tab type="modules" visible="yes" title=""/>
+    <tab type="namespaces" visible="yes" title="">
+      <tab type="namespaces" visible="yes" title=""/>
+      <tab type="namespacemembers" visible="yes" title=""/>
+    </tab>
+    <tab type="classes" visible="yes" title="">
+      <tab type="classes" visible="yes" title=""/>
+      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> 
+      <tab type="hierarchy" visible="yes" title=""/>
+      <tab type="classmembers" visible="yes" title=""/>
+    </tab>
+    <tab type="files" visible="yes" title="">
+      <tab type="files" visible="yes" title=""/>
+      <tab type="globals" visible="yes" title=""/>
+    </tab>
+    <tab type="dirs" visible="yes" title=""/>
+    <tab type="examples" visible="yes" title=""/>  
+  </navindex>
+
+  <!-- Layout definition for a class page -->
+  <class>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <inheritancegraph visible="$CLASS_GRAPH"/>
+    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+    <allmemberslink visible="yes"/>
+    <memberdecl>
+      <nestedclasses visible="yes" title=""/>
+      <publictypes title=""/>
+      <publicslots title=""/>
+      <signals title=""/>
+      <publicmethods title=""/>
+      <publicstaticmethods title=""/>
+      <publicattributes title=""/>
+      <publicstaticattributes title=""/>
+      <protectedtypes title=""/>
+      <protectedslots title=""/>
+      <protectedmethods title=""/>
+      <protectedstaticmethods title=""/>
+      <protectedattributes title=""/>
+      <protectedstaticattributes title=""/>
+      <packagetypes title=""/>
+      <packagemethods title=""/>
+      <packagestaticmethods title=""/>
+      <packageattributes title=""/>
+      <packagestaticattributes title=""/>
+      <properties title=""/>
+      <events title=""/>
+      <privatetypes title=""/>
+      <privateslots title=""/>
+      <privatemethods title=""/>
+      <privatestaticmethods title=""/>
+      <privateattributes title=""/>
+      <privatestaticattributes title=""/>
+      <friends title=""/>
+      <related title="" subtitle=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <constructors title=""/>
+      <functions title=""/>
+      <related title=""/>
+      <variables title=""/>
+      <properties title=""/>
+      <events title=""/>
+    </memberdef>
+    <usedfiles visible="$SHOW_USED_FILES"/>
+    <authorsection visible="yes"/>
+  </class>
+
+  <!-- Layout definition for a namespace page -->
+  <namespace>
+    <briefdescription visible="yes"/>
+    <memberdecl>
+      <nestednamespaces visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </namespace>
+
+  <!-- Layout definition for a file page -->
+  <file>
+    <briefdescription visible="yes"/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <includegraph visible="$INCLUDE_GRAPH"/>
+    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+    <sourcelink visible="yes"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection/>
+  </file>
+
+  <!-- Layout definition for a group page -->
+  <group>
+    <briefdescription visible="yes"/>
+    <groupgraph visible="$GROUP_GRAPHS"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <dirs visible="yes" title=""/>
+      <nestedgroups visible="yes" title=""/>
+      <files visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+      <membergroups visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+    <memberdef>
+      <pagedocs/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </group>
+
+  <!-- Layout definition for a directory page -->
+  <directory>
+    <briefdescription visible="yes"/>
+    <directorygraph visible="yes"/>
+    <memberdecl>
+      <dirs visible="yes"/>
+      <files visible="yes"/>
+    </memberdecl>
+    <detaileddescription title=""/>
+  </directory>
+</doxygenlayout>
diff --git a/doc/appendix_configuration.dox b/doc/appendix_configuration.dox
new file mode 100644 (file)
index 0000000..51a614c
--- /dev/null
@@ -0,0 +1,20 @@
+/**\r
+ @page appendix_configuration Framework configuration XML\r
+\r
+ @section Overview\r
+Here explains about XML file which Sync-agent Framework uses for agent property configuration.<br>\r
+Framework reads the XML file on init request, and configures Framework modules and Plugins as described in the XML file.<br>\r
+Through this guide, you can acknowledge what to descirbe how in the XML file to initiate Framework.<br>\r
+\r
+ @section Examples\r
+Following examples of the Framework configuration XML with full set of Framework modules, Plugin Domains.<br>\r
+Basically need to prepare 2 XMLs, one for client and the other for client UI.<br>\r
+Refer to annotations attached to each element.<br>\r
+\r
+       - <b>Client UI XML</b><br>\r
+       @verbinclude sample_client_ui.xml\r
+\r
+       - <b>Client XML</b><br>\r
+       @verbinclude sample_client.xml\r
+\r
+*/\r
diff --git a/doc/appendix_plugin.dox b/doc/appendix_plugin.dox
new file mode 100644 (file)
index 0000000..9365c94
--- /dev/null
@@ -0,0 +1,36 @@
+/**\r
+ @page appendix_plugin Plugin implementation\r
+\r
+ @section Overview\r
+Here explains about Plugin implementation.<br>\r
+Through this guide, you can acknowledge what to do how in order to make your own sync client using Sync-agent Framework.<br>\r
+\r
+ @section Steps\r
+- <b>First, decide what kind of job you want to make your client to do.</b><br>\r
+       -# Choose Plugin Domains which Sync-agent Framework supports, taking into account what your own client should do.<br>\r
+       Refer to @ref plugin_interface "Plugin Interface overview" page and check what each Domain can do.<br>\r
+       <br>\r
+       -# Go over Plulgin interface set which Plugin Domain you hope to use has, and check if they are enough to realize your desire.<br>\r
+       If something not supported or good enough, we are sorry that you better contact us and request for additional implementation.<br>\r
+       Otherwise, you may improve Sync-agent Framework by yourself and take a chance to contribute to public. :-)<br>\r
+       Just focus on that any contribution should be considered common in the belonged Domain.<br>\r
+       Refer to @ref plugin "Plugin Interface Doxygen" page for interface set in each Plugin Domain.<br>\r
+\r
+- <b>Second, check if the operation that you want to implement through Plugins has support in platform aspect.</b><br>\r
+       -# Basically Plugin mechanism is adopted to make Sync-agent Framework platform-independent.<br>\r
+       Means Plugin is just a gateway doing platform-depedent jobs in the middle.<br>\r
+       But that is not mandatory and actually you can put any implementation in it regardless of platfrom just if suitable for interface set.<br>\r
+       <br>\r
+       -# Note that you can use other Plugins in a Plugin by calling Framework in a Plugin.<br>\r
+       This way you may fulfill lack of support from platform.<br>\r
+\r
+- <b>Third, make your own implementation according to interface set that Framework defined.</b><br>\r
+       -# You may omit implementing any interfaces, just don't forget to prepare for such exception case in the code.<br>\r
+       Sync-agent Framework can handle such 'symbol not found' case in advance, but you better be awared for such cases.\r
+\r
+- <b>For the last, write necessary settings in configuration file.</b><br>\r
+       -# In order for Framework to load your Plugin, details about the Plugin should be described in configuration file.<br>\r
+       Path and name of the .so file, and relation to other Plugin, registration data if necessary.<br>\r
+       Refer to @ref appendix_configuration "Framework configuration XML" page and check how to compose the configuration file.<br>\r
+*/\r
+\r
diff --git a/doc/groups.dox b/doc/groups.dox
new file mode 100644 (file)
index 0000000..7f5066f
--- /dev/null
@@ -0,0 +1,43 @@
+/** \r
+ * @addtogroup account Account\r
+ * Account group\r
+ *\r
+ * @addtogroup data_adapter Data Adapter\r
+ * Data Adapter group\r
+ *\r
+ * @addtogroup device Device\r
+ * Device group\r
+ *\r
+ * @addtogroup device_manager Device Manager\r
+ * Device Manager group\r
+ *\r
+ * @addtogroup engine_controller Engine Controller\r
+ * Engine Controller group\r
+ *\r
+ * @addtogroup event Event\r
+ * Event group\r
+ *\r
+ * @addtogroup fsapi File System\r
+ * File System API group\r
+ *\r
+ * @addtogroup initialization Initialization\r
+ * Initialization group\r
+ *\r
+ * @addtogroup network_access Network Access\r
+ * Network Access group\r
+ *\r
+ * @addtogroup platform_monitor Platform Monitor\r
+ * Platform Monitor group\r
+ *\r
+ * @addtogroup plugin Plugin Interface\r
+ * Plugin Interface group\r
+ *\r
+ * @addtogroup protocol_binder Protocol Binder\r
+ * Protocol Binder group\r
+ *\r
+ * @addtogroup security_assistant Security Assistant\r
+ * Security Assistant group\r
+ *\r
+ * @addtogroup utility Utility\r
+ * Utility group\r
+ */\r
diff --git a/doc/groups_account.dox b/doc/groups_account.dox
new file mode 100644 (file)
index 0000000..177e66b
--- /dev/null
@@ -0,0 +1,18 @@
+/**\r
+ @page account Account module\r
+\r
+ @section Overview\r
+Account module provides capabilities to access Platform accounts.<br>\r
+The access operates through Framework accounts mapped to Platform accounts.<br>\r
+In order to be independent from Platform, internally it keeps mapping information between Framework accounts and Platform accounts.<br>\r
+Any Platform-dependent operations are executed through Plugins under Plugin Domain "Account".<br>\r
+\r
+ @image html overview_account.png "Software architecture of Account module"\r
+\r
+Account module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Mapping Account</b><br>\r
+       Manages relationship between Framework accounts and Platform accounts.<br>\r
+\r
+       - <b>Account Operator</b><br>\r
+       Provides creation, deletion, update, fetch of Framework accounts.<br>\r
+*/\r
diff --git a/doc/groups_data_adapter.dox b/doc/groups_data_adapter.dox
new file mode 100644 (file)
index 0000000..0850fa5
--- /dev/null
@@ -0,0 +1,35 @@
+/**\r
+ @page data_adapter Data Adapter module\r
+\r
+ @section Overview\r
+Data Adapter module provides capabilities to access Platform data stores(DB).<br>\r
+The access operates through Framework DB mapped to Platform data stores(DB).<br>\r
+In order to be independent from Platform, internally it keeps mapping information between Framework DB and Platform data stores(DB).<br>\r
+Any Platform-dependent operations are executed through Plugins under Plugin Domain "DataConnector" and "DataConverter".<br>\r
+\r
+Plugins under Plugin Domain "DataConnector" handles conversion between external and Platform internal,<br>\r
+and Plugin under Plugin Domain "DataConverter" handles Platform DB item I/O.<br>\r
+\r
+ @image html overview_data_adapter.png "Software architecture of Data Adapter module"\r
+\r
+Data Adapter module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Framework DB Accessor</b><br>\r
+       Provides APIs to manipulate Framework DB items.<br>\r
+\r
+       - <b>Platform DB Accessor</b><br>\r
+       Provides APIs to manipulate Platform DB items.<br>\r
+       Such operations are made through Plugins.<br>\r
+\r
+       - <b>Changelog Processer</b><br>\r
+       Provides APIs to manipulate Framework changelog items.<br>\r
+       And even internally maintains changelog by catching change notifications from Platform <br>\r
+       so that User Agent which uses framework may utilize it as sync history.<br>\r
+\r
+       - <b>Converter</b><br>\r
+       Provides APIs to initialize and compose Platform DB items<br>\r
+       which Platform doesn't support conversion(between external and Platform internal) for.<br>\r
+\r
+       - <b>LUID Generator</b><br>\r
+       It guarantees generation of unique ID value used for Framework DB item.<br>\r
+       It has limitation for maximum range of the generation, which is specified in Framework configuration XML.<br>\r
+*/\r
diff --git a/doc/groups_device.dox b/doc/groups_device.dox
new file mode 100644 (file)
index 0000000..c5a1fc3
--- /dev/null
@@ -0,0 +1,21 @@
+/**\r
+ @page device Device module\r
+\r
+ @section Overview\r
+Device module provides capabilities to access Platform device information.<br>\r
+The capabilities are executed directly through Plugins under Plugin Domain "DeviceInfo"<br>\r
+without any involvement of Framework.<br>\r
+\r
+ @image html overview_device.png "Software architecture of Device module"\r
+\r
+Device module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Device Info</b><br>\r
+       Provides API to get device information.<br>\r
+       Such information has key-value form, so the key should be predefined<br>\r
+       between agent developer and plugin developer before using.<br>\r
+\r
+       - <b>Device Executor</b><br>\r
+       Provides APIs to execute device function.<br>\r
+       Such functions are invoked by specifying function name, so the name should be predefined<br>\r
+       between agent developer and plugin developer before using.<br>\r
+*/\r
diff --git a/doc/groups_device_manager.dox b/doc/groups_device_manager.dox
new file mode 100644 (file)
index 0000000..31d3464
--- /dev/null
@@ -0,0 +1,25 @@
+/**\r
+ @page device_manager Device Manager module\r
+\r
+ @section Overview\r
+Device Manager module provides capabilities to manipulate MO(Management Object) items and device policy(MDM).<br>\r
+In order to enable MO handling, provides TNS and DDF parsing as well.<br>\r
+Any Platform-dependent operations are executed through Plugins under Plugin Domain "MO" and "DeviceManager".<br>\r
+\r
+ @image html overview_device_manager.png "Software architecture of Device Manager module"\r
+\r
+Device Manager module has following sub implementations with each corresponding roles.<br>\r
+       - <b>MO Accessor</b><br>\r
+       Provides APIs to manipulate Framework MO items.<br>\r
+\r
+       - <b>MO DDF Parser</b><br>\r
+       Constructs MO databse reading given DDF file.<br>\r
+       These functions are implemented in MO plugin desinged for each DDF file,<br>\r
+       and the parsing should be done before using Framework MO items<br>\r
+\r
+       - <b>TNDS Processor</b><br>\r
+       Performs TNDS import and export.<br>\r
+\r
+       - <b>MO executor</b><br>\r
+       Performs MO specific device operation. (ex. OMA-DM LAWMO - lock and wipe)<br>\r
+*/\r
diff --git a/doc/groups_engine_controller.dox b/doc/groups_engine_controller.dox
new file mode 100644 (file)
index 0000000..f4d6543
--- /dev/null
@@ -0,0 +1,30 @@
+/**\r
+ @page engine_controller Engine Controller module\r
+\r
+ @section Overview\r
+Engine Controller module provides encapsulated multi-thread environment plus its control.<br>\r
+\r
+ @image html overview_engine_controller.png "Software architecture of Engine Controller module"\r
+\r
+It uses an internal object called "Task", and it contains\r
+       - A pointer to a user-registered function\r
+       - Input/output parameters of the function and relationship to other Tasks\r
+\r
+Engine Controller provides two kinds of Tasks - Sync and Async.\r
+       - Sync Tasks return after execution finish.\r
+       - Async Tasks return before execution finish, and afterwards call user-specified callback when the execution finished.\r
+\r
+User need to define and register expected Tasks in advnace before using it.<br>\r
+And by registering queueing rule connected to user Tasks, user may control their processing order.<br>\r
+For example, precedent condition such as "Task B should be executed after Task A has finished." can be specified.\r
+\r
+Engine Controller module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Task generator</b><br>\r
+       Provides APIs to generate and register Task object, and to register between-Tasks relationship called "Queuing rule".<br>\r
+\r
+       - <b>Task Manager</b><br>\r
+       Manages user-registered Tasks and their relationship with other Tasks internally.<br>\r
+\r
+       - <b>Task Executor</b><br>\r
+       Executes/cancels user-registerd Tasks on demand.<br>\r
+*/\r
diff --git a/doc/groups_event.dox b/doc/groups_event.dox
new file mode 100644 (file)
index 0000000..46c26d7
--- /dev/null
@@ -0,0 +1,59 @@
+/**\r
+ @page event Event module\r
+\r
+ @section Overview\r
+Event module provides encapsulated IPC mechanism.<br>\r
+Event which is sent from UI to engine, is based on socket, and Noti which is sent from engine to UI, is based on Inotify.<br>\r
+\r
+ @image html overview_event.png "Software architecture of Event module"\r
+\r
+In order to enable customizing, external Event/Noti spec files are used,<br>\r
+and path of the spec files in Target device should be specified in Framework configuration XML.<br>\r
+Sync-agent Framework parses the spec files and performs requested IPC operation as defined in the spec files.\r
+\r
+Following example of spec file contents.\r
+- eventconfig<br>\r
+1, 1, 0, 30, addprofile<br>\r
+2, 1, 0, 30, editprofile<br>\r
+3, 1, 0, 30, deleteprofile<br>\r
+4, 1, 0, 30, requestsync<br>\r
+5, 1, 0, 30, cancelsync<br>\r
+\r
+- noticonfig<br>\r
+1, 0, 0, 30, sessionprocess<br>\r
+2, 0, 0, 30, processupdate<br>\r
+\r
+First column specifies unique index number,<br>\r
+second column specifies type (sync or async, currently uses only sync type(1)),<br>\r
+third column specifies related event/noti index (currently not in use(0)),<br>\r
+fourth column specifies pending time (currently not in use, use any number),<br>\r
+fifth column specifies description just for human readability.<br>\r
+\r
+For each Event and Noti, user should register callback function which will be invoked on reception.<br>\r
+Those registration should be done before using IPC.\r
+\r
+In brief, user may go through next steps to activate Framework IPC system.<br>\r
+-# Compose Event/Noti spec files. (Environment)\r
+-# Register Event/Noti callback for each event. (Code)\r
+-# Run Event/Noti listener. (Code)\r
+\r
+Sync-agent Framework provides standard IPC API set for OMA DM and OMA DS. (Refer to oma_xx_api.h)\r
+\r
+Event module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Spec Manager</b><br>\r
+       Parses and loads event/noti spec files specified.<br>\r
+\r
+       - <b>Event Accessor</b><br>\r
+       Provides APIs to access Event/Noti instance exchanging between UI and engine.<br>\r
+       Using those APIs, user can get/set data in Event/Noti instance.<br>\r
+\r
+       - <b>Event Handler</b><br>\r
+       Creates Event listener and handles received Event as specified in spec files.<br>\r
+       Provides API for user to register Event callback executed on reception.<br>\r
+       Engine can dispatch Noti to UI through this module.<br>\r
+\r
+       - <b>UI API</b><br>\r
+       Creates Noti listener and handles received Noti as specified in spec files.<br>\r
+       Provides API for user to register Noti callback executed on reception.<br>\r
+       UI can dispatch Event to engine through this module.<br>\r
+*/\r
diff --git a/doc/groups_file_system.dox b/doc/groups_file_system.dox
new file mode 100644 (file)
index 0000000..73bf4c2
--- /dev/null
@@ -0,0 +1,15 @@
+/**\r
+ @page file_system File System module\r
+\r
+ @section Overview\r
+File System module provides encapsulated file system APIs such as read, write, create, delete, move, list and etc.<br>\r
+\r
+ @image html overview_file_system.png "Software architecture of File System module"\r
+\r
+File System module has following sub implementations with each corresponding roles.<br>\r
+       - <b>File Operator</b><br>\r
+       Provides APIs to manipulate file related operations.<br>\r
+\r
+       - <b>Directory Operator</b><br>\r
+       Provides APIs to manipulate directory related operations.<br>\r
+*/\r
diff --git a/doc/groups_initialization.dox b/doc/groups_initialization.dox
new file mode 100644 (file)
index 0000000..905ceb6
--- /dev/null
@@ -0,0 +1,19 @@
+/**\r
+ @page initialization Initialization module\r
+\r
+ @section Overview\r
+Initialization module provides customized environment initialization.<br>\r
+It parses given XML file - called Framework configuration XML,<br>\r
+and loads Plugins and configures Framework environment as written in the XML file<br>\r
+\r
+ @image html overview_initialization.png "Software architecture of Initialization module"\r
+\r
+Initialization module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Initializer</b><br>\r
+       Loads Plugins and configures Framework environment through Config Parser,<br>\r
+       and performs additional setting using loaded Plugins.<br>\r
+\r
+       - <b>Config Parser</b><br>\r
+       Parses Framework configuration XML which agent specified,<br>\r
+       loads requested Plugins and configures each Framework modules which agent says it uses.<br>\r
+*/\r
diff --git a/doc/groups_network_access.dox b/doc/groups_network_access.dox
new file mode 100644 (file)
index 0000000..ed4bb7e
--- /dev/null
@@ -0,0 +1,21 @@
+/**\r
+ @page network_access Network Access module\r
+\r
+ @section Overview\r
+Network Access module provides capabilities to communicate with external server through network protocol such as HTTP.<br>\r
+The capabilities are executed directly through Plugins under Plugin Domain "NetworkAccess".<br>\r
+Otherwise network connection and session are under control of Network Access module itself.<br>\r
+\r
+ @image html overview_network_access.png "Software architecture of Network Access module"\r
+\r
+Network Access module usually needs initialization step and<br>\r
+once the init implemented in Plugin, is automatically done by Framework Init operation internal<br>\r
+by reading Framework configuration XML in which PlatformMonitor Plugin is specified.<br>\r
+\r
+Network Access module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Connection Management</b><br>\r
+       Controls network connection and session open/close.<br>\r
+\r
+       - <b>Communication</b><br>\r
+       Provides communication APIs to send and receive messages.\r
+*/\r
diff --git a/doc/groups_platform_monitor.dox b/doc/groups_platform_monitor.dox
new file mode 100644 (file)
index 0000000..4814f6c
--- /dev/null
@@ -0,0 +1,22 @@
+/**\r
+ @page platform_monitor Platform Monitor module\r
+\r
+ @section Overview\r
+Platform Monitor module provides capabilities to catch event from target platform, such as alarm, mobile network.<br>\r
+The capabilities are executed directly through Plugins under Plugin "PlatformMonitor"<br>\r
+without any involvement of Framework.<br>\r
+\r
+ @image html overview_platform_monitor.png "Software architecture of Platform Monitor module"\r
+\r
+The mechanism for event catch from platform requires device module init and callback registration,<br>\r
+and the device module init which is implemented in Plulgin, is automatically done by Framework Init operation internal<br>\r
+by reading Framework configuration XML in which PlatformMonitor Plugin is specified.<br>\r
+\r
+Some kinds of device module may have module data related to the system event,<br>\r
+and in this case user can access(get/set) the data through APIs provided.<br>\r
+\r
+Platform Monitor module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Platform Inerface</b><br>\r
+       Provides API, realted to device module which occurs system event.<br>\r
+       User can register system event callback, get/set device module data.<br>\r
+*/\r
diff --git a/doc/groups_plugin_interface.dox b/doc/groups_plugin_interface.dox
new file mode 100644 (file)
index 0000000..076b2d7
--- /dev/null
@@ -0,0 +1,55 @@
+/**\r
+ @page plugin_interface Plugin Interface module\r
+\r
+ @section Overview\r
+Plugin Interface module provides sets of Plugin interface per Plugin Domain.<br>\r
+And internally manages Plugin loading and symbol connection between Framework-using client and Plugins.\r
+\r
+ @image html overview_plugin_interface.png "Software architecture of Plugin Interface module"\r
+\r
+Header files for each Plugin Domain are located in "/usr/include/sync-agent/plugin".<br>\r
+Each header file defines Domain-specific API set and Plugins should be implemented according to it.<br>\r
+For detail information about each API, refer to Doxygen "Modules" page describing "Plugin" module.<br>\r
+\r
+Plugin Interface module has following interface set(Plugin Domain) with each corresponding roles.<br>\r
+       - <b>Plugin Manager</b><br>\r
+       Loads Plugins and provides dynamic symbol connection to the Plugin interfaces.<br>\r
+\r
+       - <b>Account Domain</b><br>\r
+       Provides API to implemented platform-dependent account operation.<br>\r
+       Plugins under Account Domain are used in Account module in Framework.<br>\r
+\r
+       - <b>DataConverter Domain</b><br>\r
+       Provides API to implemented platform-dependent converting operation for platform datastore.<br>\r
+       (External data type to internal datastore item, internal dadtastore item to external data type.)<br>\r
+       Plugins under DataConverter Domain are used in Data Adapter module in Framework.<br>\r
+\r
+       - <b>DataConnector Domain</b><br>\r
+       Provides API to implemented platform-dependent datastore operation for platform datastore.<br>\r
+       External data should be converted to internal datastore item through DataConverter Plugin before using inside of platform.<br>\r
+       Vice versa, internal datastore item should be converted to external data through DataConverter Plugin before using out of platform.<br>\r
+       Plugins under DataConnector Domain are used in Data Adapter module in Framework.<br>\r
+\r
+       - <b>DeviceInfo Domain</b><br>\r
+       Provides API to fetch platform device information such as version, revision and etc.<br>\r
+       Plugins under DeviceInfo Domain are used in Device module in Framework.<br>\r
+\r
+       - <b>DeviceManager Domain</b><br>\r
+       Provides API to get/set platform device policy such as MDM.<br>\r
+       Plugins under DeviiceManager Domain are used in Device Manager module in Framework.<br>\r
+\r
+       - <b>MO Domain</b><br>\r
+       Provides API to get/set Management Object(MO).<br>\r
+       1 Plugin required per 1 MO tree and need to parse DDF into MO tree(DB) before using.<br>\r
+       Plugins under MO Domain are used in Device Manager module in Framework.<br>\r
+\r
+       - <b>NetworkAccess Domain</b><br>\r
+       Provides API to communicate with external server.<br>\r
+       1 Plugin required per 1 protocol.<br>\r
+       Plugins under NetworkAccess Domain are used in Network Access module in Framework.<br>\r
+\r
+       - <b>PlatformMonitor Domain</b><br>\r
+       Provides API to monitor specific event platform device module originates.<br>\r
+       1 Plugin required per 1 kind of system event.<br>\r
+       Plugins under PlatformMonitor Domain are used in Platform Monitor module in Framework.<br>\r
+*/\r
diff --git a/doc/groups_protocol_binder.dox b/doc/groups_protocol_binder.dox
new file mode 100644 (file)
index 0000000..8bb22d8
--- /dev/null
@@ -0,0 +1,17 @@
+/**\r
+ @page protocol_binder Protocol Binder module\r
+\r
+ @section Overview\r
+Protocol Binder module provides capabilities to parse and generate XML/WBXML stream.<br>\r
+\r
+ @image html overview_protocol_binder.png "Software architecture of Protocol Binder module"\r
+\r
+Protocol Binder module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Parser</b><br>\r
+       Parses XML/WBXML stream.<br>\r
+       Using APIs provided, user can get data from stream.<br>\r
+\r
+       - <b>Enerator</b><br>\r
+       Generates XML/WBXML stream.<br>\r
+       Using APIs provided, user can make stream with user data.<br>\r
+*/\r
diff --git a/doc/groups_security_assistant.dox b/doc/groups_security_assistant.dox
new file mode 100644 (file)
index 0000000..72347ee
--- /dev/null
@@ -0,0 +1,19 @@
+/**\r
+ @page security_assistant Security Assistant module\r
+\r
+ @section Overview\r
+Security Assistant module provides capabilities to make encryption and decryption.<br>\r
+\r
+ @image html overview_security_assistant.png "Software architecture of Security Assistant module"\r
+\r
+Currently Sync-agent Framework supports following encryption algorithm.\r
+       - MD5\r
+       - SHA1\r
+\r
+Security Assistant module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Encrypt</b><br>\r
+       Provides API to encrypt stream under requested algorithm.<br>\r
+\r
+       - <b>Decrypt</b><br>\r
+       Provides API to decryption stream under requested algorithm.<br>\r
+*/\r
diff --git a/doc/groups_utility.dox b/doc/groups_utility.dox
new file mode 100644 (file)
index 0000000..9641d0a
--- /dev/null
@@ -0,0 +1,27 @@
+/**\r
+ @page utility Utility module\r
+\r
+ @section Overview\r
+Utility module provides small utility functions.<br>\r
+\r
+ @image html overview_utility.png "Software architecture of Utility module"\r
+\r
+Utility module has following sub implementations with each corresponding roles.<br>\r
+       - <b>Logging</b><br>\r
+       Provides logging macros useful for developement.<br>\r
+\r
+       - <b>Data Structure</b><br>\r
+       Provides wrapped data structure such as async queue.<br>\r
+\r
+       - <b>Compress</b><br>\r
+       Provides API to compress/uncompress TAR ball.<br>\r
+\r
+       - <b>File</b><br>\r
+       Provides API to use file as integer property store.<br>\r
+\r
+       - <b>Mainloop</b><br>\r
+       Provides API to create and control g_main_loop.<br>\r
+\r
+       - <b>Time</b><br>\r
+       Provides timestamp conversion between seconds and UTC.<br>\r
+*/\r
diff --git a/doc/images/overview_account.png b/doc/images/overview_account.png
new file mode 100644 (file)
index 0000000..71b4bd8
Binary files /dev/null and b/doc/images/overview_account.png differ
diff --git a/doc/images/overview_data_adapter.png b/doc/images/overview_data_adapter.png
new file mode 100644 (file)
index 0000000..1692e03
Binary files /dev/null and b/doc/images/overview_data_adapter.png differ
diff --git a/doc/images/overview_device.png b/doc/images/overview_device.png
new file mode 100644 (file)
index 0000000..6074dd6
Binary files /dev/null and b/doc/images/overview_device.png differ
diff --git a/doc/images/overview_device_manager.png b/doc/images/overview_device_manager.png
new file mode 100644 (file)
index 0000000..76b9abc
Binary files /dev/null and b/doc/images/overview_device_manager.png differ
diff --git a/doc/images/overview_engine_controller.png b/doc/images/overview_engine_controller.png
new file mode 100644 (file)
index 0000000..4bd9dff
Binary files /dev/null and b/doc/images/overview_engine_controller.png differ
diff --git a/doc/images/overview_event.png b/doc/images/overview_event.png
new file mode 100644 (file)
index 0000000..1e827ca
Binary files /dev/null and b/doc/images/overview_event.png differ
diff --git a/doc/images/overview_file_system.png b/doc/images/overview_file_system.png
new file mode 100644 (file)
index 0000000..ffb441e
Binary files /dev/null and b/doc/images/overview_file_system.png differ
diff --git a/doc/images/overview_initialization.png b/doc/images/overview_initialization.png
new file mode 100644 (file)
index 0000000..3b4eff3
Binary files /dev/null and b/doc/images/overview_initialization.png differ
diff --git a/doc/images/overview_network_access.png b/doc/images/overview_network_access.png
new file mode 100644 (file)
index 0000000..99e6d48
Binary files /dev/null and b/doc/images/overview_network_access.png differ
diff --git a/doc/images/overview_platform_monitor.png b/doc/images/overview_platform_monitor.png
new file mode 100644 (file)
index 0000000..71491b0
Binary files /dev/null and b/doc/images/overview_platform_monitor.png differ
diff --git a/doc/images/overview_plugin_interface.png b/doc/images/overview_plugin_interface.png
new file mode 100644 (file)
index 0000000..2eaed87
Binary files /dev/null and b/doc/images/overview_plugin_interface.png differ
diff --git a/doc/images/overview_protocol_binder.png b/doc/images/overview_protocol_binder.png
new file mode 100644 (file)
index 0000000..de9913c
Binary files /dev/null and b/doc/images/overview_protocol_binder.png differ
diff --git a/doc/images/overview_security_assistant.png b/doc/images/overview_security_assistant.png
new file mode 100644 (file)
index 0000000..e06c90f
Binary files /dev/null and b/doc/images/overview_security_assistant.png differ
diff --git a/doc/images/overview_sync_agent_framework.png b/doc/images/overview_sync_agent_framework.png
new file mode 100644 (file)
index 0000000..9ce2b13
Binary files /dev/null and b/doc/images/overview_sync_agent_framework.png differ
diff --git a/doc/images/overview_utility.png b/doc/images/overview_utility.png
new file mode 100644 (file)
index 0000000..f2101e2
Binary files /dev/null and b/doc/images/overview_utility.png differ
diff --git a/doc/images/tizen_logo.png b/doc/images/tizen_logo.png
new file mode 100644 (file)
index 0000000..7c17c54
Binary files /dev/null and b/doc/images/tizen_logo.png differ
diff --git a/doc/mainpage.dox b/doc/mainpage.dox
new file mode 100644 (file)
index 0000000..d6f5fb3
--- /dev/null
@@ -0,0 +1,53 @@
+/**\r
+ @mainpage Sync-agent Framework\r
+\r
+ @section Introduction\r
+The purposes of this guide are to describe the Tizen Sync-agent Framework<br>\r
+and to explain how to use the Sync-agent Framework APIs to develop Tizen sync client applications<br>\r
+that can be implemented in Samsung mobile devices.<br>\r
+\r
+This guide does not discuss building and deploying Tizen applications.<br>\r
+The content presentation is based on the assumption that you are knowledgeable in the Tizen programming environment.<br>\r
+\r
+ @section Overview\r
+\r
+@image html overview_sync_agent_framework.png "Software architecture of Sync-agent Framework"\r
+\r
+Sync-agent Framework provides common elementaries necessary for sync client.<br>\r
+It adopted Plugin mechanism so platfom-specific implementation can be independent.<br>\r
+\r
+User applications such as OMA DM/DS agent may utilize Sync-agent Framework APIs on purpose of Platform API usage or device manipulation.<br>\r
+\r
+Currently, Sync-agent Framework can be divided into 14 modules.<br>\r
+You can refer to detail explanation about each module through following sub page links.<br>\r
+\r
+       - @subpage account "Account"\r
+       - @subpage data_adapter "Data Adapter"\r
+       - @subpage device "Device"\r
+       - @subpage device_manager "Device Manager"\r
+       - @subpage engine_controller "Engine Controller"\r
+       - @subpage event "Event"\r
+       - @subpage file_system "File System"\r
+       - @subpage initialization "Initialization"\r
+       - @subpage network_access "Network Access"\r
+       - @subpage platform_monitor "Platform Monitor"\r
+       - @subpage plugin_interface "Plugin Interface"\r
+       - @subpage protocol_binder "Protocol Binder"\r
+       - @subpage security_assistant "Security Assistant"\r
+       - @subpage utility "Utility"\r
+\r
+In order for your client to use Sync-agent Framework, you need to write configuration in a file called Framework configuration XML.<br>\r
+Refer to following link for details about composition rule.<br>\r
+       - @ref appendix_configuration "How to compose Framework configuration XML file"<br>\r
+\r
+And if you are willing to develope your own Plugins, there some guide lines.<br>\r
+Refer to following link for details about Plugin implementation.<br>\r
+       - @ref appendix_plugin "How to implement your own Plugins"<br>\r
+\r
+ @section Maintainers\r
+ - WooJin Yun <suhoangel9@samsung.com>\r
+ - Juhak Park <juhaki.park@samsung.com>\r
+ - SangHyuk Ko <sanghyuk.ko@samsung.com>\r
+ - Taewhan Gi  <th1128.gil@samsung.com>\r
+ - Junhyeong Park <jruss.park@samsung.com>\r
+*/\r
diff --git a/doc/sample_client.xml b/doc/sample_client.xml
new file mode 100644 (file)
index 0000000..103a6af
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml  version="1.0" encoding="UTF-8" ?>
+<INIT>
+       <Agent-Key>user_client</Agent-Key>      <!-- User defined agent key string used for identifier -->
+       <MainLoop>1</MainLoop>
+       <Event> <!-- Event detail -->
+       <!-- Following Event-Key and Event-Config should be same with UI client setting  -->
+               <Event-Key>user_client_event</Event-Key>        <!-- User defined Event key string used for Event channel identifier -->
+               <Event-Config>/usr/share/user-cfg/eventconfig_user_client</Event-Config>        <!-- Path of Event spec file -->
+               <RunEventHandler>1</RunEventHandler>    <!-- Set 1 if need Framework Event handler on this agent -->
+       </Event>
+       <Noti>  <!-- Noti detail -->
+       <!-- Following Noti-Key and Noti-Config should be same with UI client setting  -->
+               <Noti-Key>user_client_noti</Noti-Key>   <!-- User defined Noti key string used for Noti channel identifier -->
+               <Noti-Config>/usr/share/user-cfg/noticonfig_user_client</Noti-Config>   <!-- Path of Noti spec file -->
+       </Noti>
+       <EngineController>      <!-- Engine Controller setting -->
+               <Max-Thread>5</Max-Thread>      <!-- Maximum number of thread to allow -->
+       </EngineController>
+       <FrameworkDB use="1">   <!-- Use Framework DB or not, set use="1" if needed -->
+               <Path>/opt/dbspace/.user_client.db</Path>       <!-- Path to store Framework DB -->
+       </FrameworkDB>
+       <ID-Provider>   <!-- ID Provider setting -->
+               <Code>1</Code>  <!-- Unique identifier code which Framework identifies owner of ID provider instance internally -->
+               <MaxID>4000000000</MaxID>       <!-- Maximum range of ID generation -->
+               <PageSize>5</PageSize>  <!-- Page size to use for ID generation  -->
+       </ID-Provider>
+       <PlugIn-Mgr>    <!-- Plugins detail -->
+               <Domain name="Account" count="1">       <!-- Specify Domain name and number of Plugins to describe -->
+                       <Plug-In>
+                               <ID>1</ID>      <!-- Plugin ID to use in the code as Plugin identifier  -->
+                               <Path>/usr/lib/user_client/libplugin-account.so</Path>  <!-- Path and name of .so file -->
+                               <Description>SLP Account Accessor</Description>         <!-- Human readable description -->
+                       </Plug-In>
+               </Domain>
+               <Domain name="DataConnector" count="2">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-da-contact.so</Path>
+                               <Description>SLP Contact Access PlugIn</Description>
+                               <DataConverter-PlugIn>1</DataConverter-PlugIn>          <!-- DataConverter Plugin ID which this DataConnector Plugin works paired with -->
+                               <Handle-ChangeNoti>1</Handle-ChangeNoti>        <!-- Set 1 if this Plugin is capable of handling datastore change noti -->
+                               <Use-MainLoop>1</Use-MainLoop>          <!-- Set 1 if g_main_loop required to operate this Plugin -->
+                       </Plug-In>
+                       <Plug-In>
+                               <ID>2</ID>
+                               <Path>/usr/lib/user_client/libplugin-da-calendar.so</Path>
+                               <Description>SLP Calendar Access PlugIn</Description>
+                               <DataConverter-PlugIn>2</DataConverter-PlugIn>
+                               <Handle-ChangeNoti>1</Handle-ChangeNoti>
+                               <Use-MainLoop>1</Use-MainLoop>
+                       </Plug-In>
+               </Domain>
+               <Domain name="DataConverter" count="2">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-dc-vcard.so</Path>
+                               <Description>SLP Contact Converter</Description>
+                       </Plug-In>
+                       <Plug-In>
+                               <ID>2</ID>
+                               <Path>/usr/lib/user_client/libplugin-dc-vcalendar.so</Path>
+                               <Description>SLP Calendar Converter</Description>
+                       </Plug-In>
+               </Domain>
+               <Domain name="NetworkAccess" count="1">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-na-http.so</Path>
+                               <Description>Http Protocol</Description>
+                               <UseNetwork>1</UseNetwork>      <!-- Set 1 if device network required to operate this Plugin -->
+                       </Plug-In>
+               </Domain>
+               <Domain name="DeviceInfo" count="1">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-di-slp-device.so</Path>
+                               <Description>SLP Device Accessor</Description>
+                       </Plug-In>
+               </Domain>
+               <Domain name="PlatformMonitor" count="2">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-pm-slp-sysnoti-alarm.so</Path>
+                               <Description>Monitoring Alarm Event from SLP Platform</Description>
+                               <Use-MainLoop>1</Use-MainLoop>          <!-- Set 1 if g_main_loop required to operate this Plugin -->
+                               <Register-Data count="1">       <!-- Set 'count' property if package registration required to operate this Plugin -->
+                                       <Data>          
+                                               <Pkg-Name>user_client</Pkg-Name>        <!-- Specify pacakage identifier -->
+                                               <Additional-Data>-</Additional-Data>    <!-- Specify additional data for registration -->
+                                       </Data>
+                               </Register-Data>
+                       </Plug-In>
+                       <Plug-In>
+                               <ID>2</ID>
+                               <Path>/usr/lib/user_client/libplugin-pm-slp-sysnoti-network-connection.so</Path>
+                               <Description>Monitoring Network Connection Event from SLP Platform</Description>
+                                       <Use-MainLoop>1</Use-MainLoop>
+                               <Register-Data count="0">-</Register-Data>
+                       </Plug-In>
+               </Domain>
+               <Domain name="MO">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-mo-devdetail.so</Path>
+                               <Description>About device detail information</Description>
+                               <Type>DEVDETAIL</Type>          <!-- Specify MO type this Plugin supports, currently supports OMA DM standard MO types -->
+                       </Plug-In>
+                       <Plug-In>
+                               <ID>2</ID>
+                               <Path>/usr/lib/user_client/libplugin-mo-devinfo.so</Path>
+                               <Description>About device information</Description>
+                               <Type>DEVINFO</Type>
+                       </Plug-In>
+               </Domain>
+               <Domain name="DeviceManager" count="1">
+                       <Plug-In>
+                               <ID>1</ID>
+                               <Path>/usr/lib/user_client/libplugin-mdm-slp-device.so</Path>
+                               <Description>SLP Mobile Device Manager</Description>
+                       </Plug-In>
+               </Domain>
+       </PlugIn-Mgr>
+</INIT>
diff --git a/doc/sample_client_ui.xml b/doc/sample_client_ui.xml
new file mode 100644 (file)
index 0000000..8d23ea9
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml  version="1.0" encoding="UTF-8" ?>
+<INIT>
+       <Agent-Key>user_client_ui</Agent-Key>   <!-- User defined agent key string used for identifier -->
+       <Event> <!-- Describes Event detail -->
+       <!-- Following Event-Key and Event-Config should be same with client setting  -->
+               <Event-Key>user_client_event</Event-Key>        <!-- User defined Event key string used for Event channel identifier -->
+               <Event-Config>/usr/share/user-cfg/eventconfig_user_client</Event-Config>        <!-- Path of Event spec file -->
+               <RunEventHandler>0</RunEventHandler>    <!-- Set 1 if need Framework Event handler on this agent -->
+       </Event>
+       <Noti>  <!-- Describe Noti detail -->
+       <!-- Following Noti-Key and Noti-Config should be same with client setting  -->
+               <Noti-Key>user_client_noti</Noti-Key>   <!-- User defined Noti key string used for Noti channel identifier -->
+               <Noti-Config>/usr/share/user-cfg/noticonfig_user_client</Noti-Config>   <!-- Path of Noti spec file -->
+       </Noti>
+</INIT>
diff --git a/include/account/account.h b/include/account/account.h
new file mode 100755 (executable)
index 0000000..4ae6338
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "manager.h"
+#include "service.h"
diff --git a/include/account/manager.h b/include/account/manager.h
new file mode 100755 (executable)
index 0000000..77aad72
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACCOUNT_MANAGER_H_
+#define ACCOUNT_MANAGER_H_
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       manager.h
+ * @brief      Support to use framework Account module
+ */
+
+/** @addtogroup account
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of error codes for Account module
+ */
+       typedef enum {
+               SYNC_AGENT_ACC_SUCCESS,
+                               /**< when account operation is succeed */
+               SYNC_AGENT_ACC_FAIL,            /**< when account operation is failed */
+               SYNC_AGENT_ACC_EMPTY,   /**< when account is not exist */
+               SYNC_AGENT_ACC_CHANGED
+                               /**< when account storage changed */
+       } sync_agent_acc_error_e;
+
+/**
+ * @brief      Structure of Framework Account instance
+ */
+       typedef struct {
+               int account_id; /**< account id */
+               char *email;    /**< e-mail address */
+               char *password; /**< password */
+               int enable;     /**< state flag */
+               char *access_name;      /**< access name */
+       } sync_agent_fw_account_s;
+
+/**
+ * @brief      Enumerations of Account query type
+ */
+       typedef enum {
+               ACCOUNT_QUERY_BY_NONE,  /**< type of no query  */
+               ACCOUNT_QUERY_BY_ACCESS_NAME,   /**< type by access name  */
+               ACCOUNT_QUERY_BY_SERVICE_TYPE,  /**< type by service  */
+               ACCOUNT_QUERY_BY_SERVICE_TYPE_SERVICE_ID_INDEX, /**< type by service id  */
+       } sync_agent_fw_account_query_type_e;
+
+/**
+ * @brief      Structure of Framework Account query instance
+ */
+       typedef struct {
+               sync_agent_fw_account_query_type_e query;       /**< type of query */
+               char *access_name;      /**< access name */
+               int service_type;       /**< service type */
+               int service_account_id; /**< service account id */
+               int index;      /**< index */
+               int fw_account_id;      /**< framework account id */
+       } sync_agent_fw_account_query_s;
+
+/**
+ * @brief              Create sync_agent_fw_account_s struct
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ account_err = sync_agent_create_fw_account(&fw_account);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out] account instance of framework account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL              When memory allocation is failed
+ */
+       sync_agent_acc_error_e sync_agent_create_fw_account(sync_agent_fw_account_s ** account);
+
+/**
+ * @brief              Register a new account to SyncAgent
+ * @par Usage:
+ * @code
+ int account_id;
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ account_err = sync_agent_add_fw_account(fw_account, &account_id);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account instance of framework account info
+ * @param[out] account_id      framework account id
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL             When add account is failed
+ */
+       sync_agent_acc_error_e sync_agent_add_fw_account(sync_agent_fw_account_s * account, int *account_id);
+
+/**
+ * @brief              Update account info
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ account_err = sync_agent_update_fw_account(fw_account);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account instance of framework account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL             When update account is failed
+ */
+       sync_agent_acc_error_e sync_agent_update_fw_account(sync_agent_fw_account_s * account);
+
+/**
+ * @brief              Delete account
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ account_err = sync_agent_delete_fw_account(account_id);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id      framework account id
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL             When update account is failed
+ */
+       sync_agent_acc_error_e sync_agent_delete_fw_account(int account_id);
+
+/**
+ * @brief              Get account info
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ account_err = sync_agent_get_fw_account(account_id, &fw_account);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id      framework account id
+ * @param[out] account         instance of framework account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL     when update account is failed
+ */
+       sync_agent_acc_error_e sync_agent_get_fw_account(int account_id, sync_agent_fw_account_s ** account);
+
+/**
+ * @brief              Get account info by query
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_query_s query;
+ GList *account_info_list = NULL;
+ query.query = ACCOUNT_QUERY_BY_SERVICE_TYPE;
+ query.service_type = FW_CONTACT;
+ account_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS)
+       ...
+ }
+ * @endcode
+ * @param[in]          query   instance of framework account query
+ * @param[out] list    list of instance of framework account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS  Successful
+ * @retval     SYNC_AGENT_ACC_FAIL     when update account is failed
+ */
+       sync_agent_acc_error_e sync_agent_query_fw_account(sync_agent_fw_account_query_s * query, GList ** list);
+
+/**
+ * @brief              Free sync_agent_fw_account_s struct
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ account_err = sync_agent_get_fw_account(account_id, &fw_account);
+ ...
+ sync_agent_free_fw_account(fw_account);
+ * @endcode
+ * @param[in]          fw_account      instance of framework account info
+ */
+       void sync_agent_free_fw_account(sync_agent_fw_account_s * fw_account);
+
+/**
+ * @brief              Free list of sync_agent_fw_account_s struct
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_query_s query;
+ GList *account_info_list = NULL;
+ query.query = ACCOUNT_QUERY_BY_SERVICE_TYPE;
+ query.service_type = 1;
+ account_err = sync_agent_query_fw_account(&query, &account_info_list);
+ ...
+ sync_agent_free_fw_account_list(account_info_list);
+ * @endcode
+ * @param[in]          list    list of instance of framework account info
+ */
+       void sync_agent_free_fw_account_list(GList * list);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ACCOUNT_MANAGER_H_ */
diff --git a/include/account/service.h b/include/account/service.h
new file mode 100755 (executable)
index 0000000..9014e3e
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACCOUNT_SERVICE_H_
+#define ACCOUNT_SERVICE_H_
+
+#include "manager.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       service.h
+ * @brief      Support to use framework Account module
+ */
+
+/** @addtogroup account
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of account type
+ */
+       typedef enum {
+               SYNC_AGENT_ACC_TYPE_LOCAL = 0,
+                                       /**< local account type */
+               SYNC_AGENT_ACC_TYPE_EAS,        /**< eas account type */
+               SYNC_AGENT_ACC_TYPE_GOOGLE,     /**< google account type */
+               SYNC_AGENT_ACC_TYPE_NONE        /**< no account type */
+       } sync_agent_service_account_type_e;
+
+/**
+ * @brief      Structure of Service Account instance
+ */
+       typedef struct {
+               char *email;    /**< e-mail address */
+               sync_agent_service_account_type_e type; /**< type of service account */
+       } sync_agent_service_account_info_s;
+
+/**
+ * @brief      Mapping service's all account to F/W account
+ * @par Usage:
+ * @code
+
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ account_err = sync_agent_construct_account_tbl_from_service();
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks    Services which are provided as a DataConnector plug-in.
+ * @return     SYNC_AGENT_ACC_SUCCESS on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS          Successful
+ * @retval     SYNC_AGENT_ACC_FAIL                     Parsing the initialization config file failed
+ * @retval     SYNC_AGENT_ACC_CHANGED  Service account repository changed
+ * @post               Mapped service's all existed account id with F/W account id
+ */
+
+       sync_agent_acc_error_e sync_agent_construct_account_tbl_from_service(void);
+
+/**
+ * @brief      Create sync_agent_service_account_info_s structure
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_service_account_info_s *account_info = NULL;
+ account_err = sync_agent_create_service_account_info(&account_info);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out] account_info instance of service account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise a error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS          Successful
+ * @retval     SYNC_AGENT_ACC_FAIL                     When memory allocation is failed
+ */
+       sync_agent_acc_error_e sync_agent_create_service_account_info(sync_agent_service_account_info_s ** account_info);
+
+/**
+ * @brief      Get Account Information
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_service_account_info_s *account_info = NULL;
+ account_err = sync_agent_get_service_account(fw_account_id, 1, &account_info);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks    Account Information type is defined in account plugIn.
+ * @param[in]  fw_account_id   account id
+ * @param[in]  service_type    service type
+ * @param[out] account_info instance of service account info
+ * @return     SYNC_AGENT_ACC_SUCCESS  on success, otherwise an error value.
+ * @retval     SYNC_AGENT_ACC_SUCCESS          Successful
+ * @retval     SYNC_AGENT_ACC_FAIL                     Parsing the initialization config file failed
+ * @retval     SYNC_AGENT_ACC_CHANGED  Service account repository changed
+ * @pre account plugIn loaded
+ */
+       sync_agent_acc_error_e sync_agent_get_service_account(int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info);
+
+/**
+ * @brief      Free sync_agent_service_account_info_s structure
+ * @par Usage:
+ * @code
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_service_account_info_s *account_info = NULL;
+ account_err = sync_agent_get_service_account(fw_account_id, 1, &account_info);
+ ...
+ sync_agent_free_service_account_info(account_info);
+ * @endcode
+ * @param[in] account_info instance of service account info
+ */
+       void sync_agent_free_service_account_info(sync_agent_service_account_info_s * account_info);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ACCOUNT_SERVICE_H_ */
diff --git a/include/data-adapter/agent_handler_manager.h b/include/data-adapter/agent_handler_manager.h
new file mode 100755 (executable)
index 0000000..986bc66
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AGENT_HANDLER_MANAGER_H_
+#define AGENT_HANDLER_MANAGER_H_
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               agent_handler_manager.h
+ * @brief      Interface list to use framework Common DataBase
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of managing database connection
+ */
+       typedef struct {
+               GHashTable *daci_handlerTable;
+                                       /**< agent db handler hash table */
+               pthread_mutex_t *daci_handlerTable_mutex;       /**< mutex for agent db handler hash table */
+       } sync_agent_da_handler_mgr_s;
+
+/**
+ * @brief              Open Agent database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                           success
+ * @retval                     SYNC_AGENT_DA_ERR_OPEN_FAILED                   fail
+ */
+       sync_agent_da_return_e sync_agent_open_agent(void);
+
+/**
+ * @brief              Close Agent database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_close_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                           success
+ * @retval                     SYNC_AGENT_DA_ERR_CLOSE_FAILED          fail
+ */
+       sync_agent_da_return_e sync_agent_close_agent(void);
+
+/**
+ * @brief              Empty Agent database table
+ * @par Usage:
+ * @code
+
+ sync_agent_da_table_name_e table_name = SYNC_AGENT_DA_TABLE_NAME_CONFIG;
+ sync_agent_da_return_e da_err = sync_agent_empty_agent_default_table(table_name);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                           success
+ * @retval                     SYNC_AGENT_DA_ERR_CLOSE_FAILED          fail
+ */
+       sync_agent_da_return_e sync_agent_empty_agent_default_table(sync_agent_da_table_name_e table_name);
+
+/**
+ * @brief              Empty all Agent database table
+ * @par Usage:
+ * @code
+
+ sync_agent_da_return_e da_err = sync_agent_empty_all_agent_default_table();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                           success
+ * @retval                     SYNC_AGENT_DA_ERR_CLOSE_FAILED          fail
+ */
+       sync_agent_da_return_e sync_agent_empty_all_agent_default_table();
+
+/**
+* @brief               Start Agent database transaction
+* @par Usage:
+* @code
+
+sync_agent_da_return_e da_err = sync_agent_begin_transaction(void);
+if (da_err != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @return                      operation result
+* @retval                      SYNC_AGENT_DA_SUCCESS                                                           success
+* @retval                      SYNC_AGENT_DA_ERR_TRANSACTION_FAILED    fail
+*/
+       sync_agent_da_return_e sync_agent_begin_transaction(void);
+
+/**
+* @brief               Finish Agent database transaction
+* @par Usage:
+* @code
+
+sync_agent_da_transaction_e transaction = SYNC_AGENT_DA_TRANSACTION_COMMIT;
+sync_agent_da_return_e da_err = sync_agent_end_transaction(transaction);
+if (da_err != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]           transaction                                                                             commit or rollback transaction
+* @return                      operation result
+* @retval                      SYNC_AGENT_DA_SUCCESS                                                           success
+* @retval                      SYNC_AGENT_DA_ERR_TRANSACTION_FAILED    fail
+*/
+       sync_agent_da_return_e sync_agent_end_transaction(sync_agent_da_transaction_e transaction);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* AGENT_HANDLER_MANAGER_H_ */
diff --git a/include/data-adapter/agent_manager.h b/include/data-adapter/agent_manager.h
new file mode 100755 (executable)
index 0000000..bfb97b1
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AGENT_MANAGER_H_
+#define AGENT_MANAGER_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               agent_manager.h
+ * @brief      Support to sync F/W item, folder change log table with service storage
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of change operation code
+ */
+       typedef enum {
+               SYNC_AGENT_DA_CHANGE_OPERATION_ADD = 301,
+                                                 /**< means add */
+               SYNC_AGENT_DA_CHANGE_OPERATION_UPDATE = 302,
+                                                    /**< means update */
+               SYNC_AGENT_DA_CHANGE_OPERATION_DELETE = 303,
+                                                    /**< means delete */
+       } sync_agent_da_change_operation_e;
+
+/**
+ * @brief      Construct F/W item, change log table from Service storage
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_construct_item_tbl_from_service(fw_account_id, FW_CONTACT);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks    F/W maintain change point of service storage change, this function use the change point.
+ * @param[in]  fw_account_id   F/W account ID
+ * @param[in]  service_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise a error value.
+ */
+       sync_agent_da_return_e sync_agent_construct_item_tbl_from_service(int fw_account_id, int service_type);
+
+/**
+ * @brief      Construct all account's F/W folder table from Service storage
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_construct_folder_tbl_from_service(FW_CONTACT);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]  service_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise a error value.
+ */
+       sync_agent_da_return_e sync_agent_construct_folder_tbl_from_service(int service_type);
+
+/**
+ * @brief      Refresh F/W only item table from Service storage
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_refresh_item_tbl_from_service(fw_account_id, FW_CONTACT);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks    delete all F/W item, change log table and construct item table from item in current Service storage.
+ * @param[in]  fw_account_id   F/W account ID
+ * @param[in]  service_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise a error value.
+ */
+       sync_agent_da_return_e sync_agent_refresh_item_tbl_from_service(int fw_account_id, int service_type);
+
+/**
+ * @brief      Set service change point as flag
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = sync_agent_set_service_change_point(fw_account_id, FW_CONTACT);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks    this change point used when construct item, change log table
+ * @param[in]  fw_account_id   F/W account ID
+ * @param[in]  service_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise a error value.
+ */
+       sync_agent_da_return_e sync_agent_set_service_change_point(int fw_account_id, int service_type);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* AGENT_MANAGER_H_ */
diff --git a/include/data-adapter/common.h b/include/data-adapter/common.h
new file mode 100755 (executable)
index 0000000..0dc37f7
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_ADAPTER_COMMON_H_
+#define DATA_ADAPTER_COMMON_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <malloc.h>
+#include <glib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <sys/stat.h>
+#include <sqlite3.h>
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               common.h
+ * @brief      Common factor of Framework common database
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      MO handler
+ */
+#define SYNC_AGENT_DA_MO_HANDLER                                                                                               sqlite3
+
+/**
+ * @brief      Data Adapter handler
+ */
+#define SYNC_AGENT_DA_HANDLER                                                                                          sqlite3
+
+/**
+ * @brief      Database retry count
+ */
+#define SYNC_AGENT_DA_RETRY_COUNT                                                                              10
+
+/**
+ * @brief      Max DB query length
+ */
+#define SYNC_AGENT_DA_MAX_QUERY_LENGTH                                                 2048
+
+/**
+ * @brief      Max number account that sync-agent framework supports
+ */
+#define SYNC_AGENT_DA_MAX_ACCOUNT                                                                              10
+
+/**
+ * @brief      Redefined memset()
+ */
+#define SYNC_AGENT_DA_MEMORY_SET(ptr)                                                                  memset(ptr, 0x00, sizeof(ptr));
+
+/**
+ * @brief      Redefined malloc()
+ */
+#define SYNC_AGENT_DA_MEMORY_MALLOC(type, size, count)         (type)malloc(size*count)
+
+/**
+ * @brief      Redefined calloc()
+ */
+#define SYNC_AGENT_DA_MEMORY_CALLOC(type, size, count)         (type)calloc(count, size)
+
+/**
+ * @brief      Redefined free()
+ */
+#define SYNC_AGENT_DA_MEMORY_FREE(src) \
+       if (src != NULL) {\
+               free(src);\
+               src = NULL;\
+       }\
+
+/**
+ * @brief      Redefined strdup()
+ */
+#define SYNC_AGENT_DA_STRDUP(src)                                                                      (src == NULL) ?  NULL : strdup(src);
+
+/**
+ * @brief      Redefined atoi()
+ */
+#define        SYNC_AGENT_DA_ATOI(src)                                                                         (src == NULL) ? 0 : atoi(src);
+
+/**
+ * @brief      Macro for fetching self thread id
+ */
+#define SYNC_AGENT_DA_GET_THREAD_ID                                                    pthread_self()
+
+/**
+ * @brief      Redefined sqlite3 connection
+ */
+       typedef sqlite3_stmt *daci_stmt;
+
+/**
+ * @brief      Enumerations of database peak type
+ */
+       typedef enum {
+               SYNC_AGENT_DA_PEAK_TYPE_ON = 601,
+                                               /**< peak type on */
+               SYNC_AGENT_DA_PEAK_TYPE_ON_N_OFF,
+                                               /**< peak type N off */
+               SYNC_AGENT_DA_PEAK_TYPE_OFF
+                                       /**< peak type off */
+       } sync_agent_da_peak_type_e;
+
+/**
+ * @brief      Enumerations of database transaction
+ */
+       typedef enum {
+               SYNC_AGENT_DA_TRANSACTION_COMMIT,
+                                               /**< means commit */
+               SYNC_AGENT_DA_TRANSACTION_ROLLBACK
+                                               /**< means rollback */
+       } sync_agent_da_transaction_e;
+
+/**
+ * @brief      Enumerations of common db's table list
+ */
+       typedef enum {
+               SYNC_AGENT_DA_TABLE_NAME_ACCOUNT,
+                                               /**< means account_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_FOLDER,/**< means folder_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_ITEM,
+                                       /**< means item_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_CONFIG,/**< means config_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG,/**< means account_item_changelog_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR,
+                                               /**< means last_anchor_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_MAPPING,
+                                               /**< means mapping_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_ID_PROVIDER,
+                                               /**< means id_provider_tbl */
+               SYNC_AGENT_DA_TABLE_NAME_ID_PAGE,
+                                               /**< means id_page_tbl */
+
+               SYNC_AGENT_DA_TABLE_NAME_MAX
+                                       /**< count of common database's tables */
+       } sync_agent_da_table_name_e;
+
+/**
+ * @brief      Structure of Item information
+ */
+       typedef struct {
+               char *itemId;
+                       /**< F/W item id */
+               int itemTypeId;
+                       /**< service data connector pluIn's ID described in F/W config file  */
+               char *serviceId;/**< service item id */
+               int operationId;/**< operation type - add, delete, update */
+               char *syncStatus;
+                               /**< user defined status of item */
+       } sync_agent_da_item_info_s;
+
+/**
+ * @brief      Structure of Item id's container
+ */
+       typedef struct {
+               int count;
+                       /**< count of id */
+               char **id;
+                       /**< real id list */
+       } sync_agent_da_id_list_s;
+
+/**
+ * @brief      Structure of framework id provider instance
+ */
+       typedef struct {
+               unsigned int id_provider_code;
+                                       /**< ID of id provider - this described in F/W configuration file */
+               unsigned int id_capacity;       /**< max ID count possible id provider generate - this described in F/W configuration file */
+               unsigned int bit_per_page;      /**< most number of bit per one page */
+               unsigned int last_id;
+                               /**< current last provided ID */
+               unsigned int free_bit_cnt;      /**< the number of IDs that can be issued */
+       } sync_agent_da_id_provider_s;
+
+/**
+ * @brief      Structure of framework id page instance
+ */
+       typedef struct {
+               unsigned int page_index;
+                               /**< index of page */
+               unsigned int id_provider_code;
+                                       /**< ID of id provider - this described in F/W configuration file */
+               char *page_bit;
+                       /**< real construction of ID issued */
+       } sync_agent_da_id_page_s;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* SYNC_AGENT_DA_COMMON_H_ */
diff --git a/include/data-adapter/converter.h b/include/data-adapter/converter.h
new file mode 100755 (executable)
index 0000000..b5012b9
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CONVERTER_H_
+#define CONVERTER_H_
+
+#include "plugin/data_converter_resource.h"
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               converter.h
+ * @brief      Support to use service converter module
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief                      Allocate internal object for content type
+ * @par Usage:
+ * @code
+ int content_type = FW_CONTACT;
+ char *obj = (char *)sync_agent_alloc_obj(content_type);
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     internal_structure_pointer                                                      success
+ * @retval                     0                                                                                                               fail
+ */
+       void *sync_agent_alloc_obj(int content_type);
+
+/**
+ * @brief                      Free internal object for content type
+ * @par Usage:
+ * @code
+ int content_type = 1;
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ char *obj = (char *)sync_agent_alloc_obj(content_type);
+ ...
+ da_err = sync_agent_free_obj(1, (void *)obj);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @param[in]  in_object                                                                                       internal object pointer
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                                   success
+ * @retval                     SYNC_AGENT_DA_ERRORS                                    fail
+ */
+       sync_agent_da_return_e sync_agent_free_obj(int content_type, void *in_object);
+
+/**
+ * @brief                      Set value for internal object
+ * @par Usage:
+ * @code
+ char *object = (char*)sync_agent_alloc_obj(FW_CONTACT);
+ char *account_name = "test_account";
+ char *result = sync_agent_set_value_to_obj(FW_CONTACT, (void*)object, VCARD_CONTENT_EXTENSION, "X-ACCOUNT-N", (void*)account_name);
+ if (result == NULL) {
+       ...
+ }
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @param[in]  in_object                                                                                       internal object pointer
+ * @param[in]  key                                                                                                     key
+ * @param[in]  extension_key                                                                   extension key
+ * @param[in]  set_value                                                                                       value
+ * @return                     operation result
+ * @retval                     new_object_pointer                                                              success
+ * @retval                     0                                                                                                               fail
+ */
+       void *sync_agent_set_value_to_obj(int content_type, void *in_object, int key, char *extension_key, void *set_value);
+
+/**
+ * @brief                      Allocate internal object for content type
+ * @par Usage:
+ * @code
+ char *account_full_name = sync_agent_get_value_to_obj(FW_CONTACT, object, VCARD_CONTENT_EXTENSION, "X-ACCOUNT");
+ if (account_full_name == NULL) {
+       ...
+ }
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @param[in]  in_object                                                                                       internal object pointer
+ * @param[in]  key                                                                                                     key
+ * @param[in]  extension_key                                                                   extension key
+ * @return                     operation result
+ * @retval                     value_pointer                                                                           success
+ * @retval                     0                                                                                                               fail
+ */
+       void *sync_agent_get_value_to_obj(int content_type, void *in_object, int key, char *extension_key);
+
+/**
+ * @brief                      Get meta infomation of internal object
+ * @par Usage:
+ * @code
+ sync_agent_plugin_object_info_s *datastore_info = sync_agent_get_obj_info(FW_CONTACT);
+ if (datastore_info != NULL) {
+       ...
+ }
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     value_pointer                                                                           success
+ * @retval                     0                                                                                                               fail
+ */
+       sync_agent_plugin_object_info_s *sync_agent_get_obj_info(int content_type);
+
+/**
+ * @brief                      Free infomation of internal object
+ * @par Usage:
+ * @code
+ sync_agent_plugin_object_info_s *datastore_info = sync_agent_get_obj_info(FW_CONTACT);
+
+ sync_agent_da_return_e result = sync_agent_free_obj_info(FW_CONTACT, datastore_info);
+ if( result != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]  content_type    service type - service data connector pluIn's ID described in F/W config file
+ * @param[in]  obj_info                object info
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS           success
+ * @retval                     SYNC_AGENT_DA_ERRORS            fail
+ */
+       sync_agent_da_return_e sync_agent_free_obj_info(int content_type, sync_agent_plugin_object_info_s * obj_info);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* CONVERTER_H_ */
diff --git a/include/data-adapter/data_adapter.h b/include/data-adapter/data_adapter.h
new file mode 100755 (executable)
index 0000000..588f218
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "agent_handler_manager.h"
+#include "agent_manager.h"
+#include "common.h"
+#include "luid.h"
+#include "converter.h"
+#include "error.h"
+#include "interface_service_item.h"
+#include "interface_changelog.h"
+#include "interface_item.h"
+#include "interface_config.h"
+#include "interface_folder.h"
+#include "interface_last_anchor.h"
+#include "interface_mapping.h"
diff --git a/include/data-adapter/error.h b/include/data-adapter/error.h
new file mode 100755 (executable)
index 0000000..07419c7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_ADAPTER_ERROR_H_
+#define DATA_ADAPTER_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               error.h
+ * @brief      Definition of framework error codes for Data Adapter
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of error codes for Data Adapter
+ */
+       typedef enum data_adapter_return {
+               SYNC_AGENT_DA_SUCCESS = 1,                                                                      /**< successful */
+               SYNC_AGENT_DA_ERRORS = -800,                                                            /**< fail */
+               SYNC_AGENT_DA_NOT_FOUND_PLUG_IN = -801,                 /**< not found data connector or converter plugIn */
+               SYNC_AGENT_DA_ERR_OPEN_FAILED = -802,                                   /**< database open fail */
+               SYNC_AGENT_DA_ERR_CLOSE_FAILED = -803,                                  /**< database close fail */
+               SYNC_AGENT_DA_ERR_TRANSACTION_FAILED = -804,                    /**< transaction fail */
+               SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED = -805,                   /**< create table fail */
+               SYNC_AGENT_DA_ERR_DROP_TABLE_FAILED = -806,                     /**< drop table fail */
+               SYNC_AGENT_DA_ERR_QUERY_FAILED = -807,                                  /**< process query fail */
+               SYNC_AGENT_DA_ERR_NOT_OPENED = -808,                                    /**< database not opened so fail */
+               SYNC_AGENT_DA_ERR_ACCOUNT_FULL = -809,                          /**< exist full account */
+               SYNC_AGENT_DA_ERR_DELETE_LAST_ACCOUNT = -810,           /**<  */
+               SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE = -811,        /**< already exist primary key */
+               SYNC_AGENT_DA_ERR_DB_HANDLER_MGR = -812,                                /**< database connection fail - get or create */
+               SYNC_AGENT_DA_ERR_ALREADY_EXIST = -813,                                 /**<  item already exist */
+               SYNC_AGENT_DA_ERR_INVALID_CONTENT = -814,                       /**<  invalid content */
+               SYNC_AGENT_DA_ERR_MEMORY_FULL = -815,                           /**< memory full */
+               SYNC_AGENT_DA_ERR_SUB_DATA_EXIST = -816,                                /**< item not empty */
+               SYNC_AGENT_DA_ERR_LOCKED = -817,                                                                /**< database lock */
+               SYNC_AGENT_DA_ERR_MORE_DATA = -818,                                     /**< query result has more data, used when iterating */
+               SYNC_AGENT_DA_ERR_NO_DATA = -819,                                                       /**< query result not found */
+               SYNC_AGENT_DA_ERR_NOT_SUPPORTED = -820,                         /**< operation not supported */
+               SYNC_AGENT_DA_ERR_NOT_EXECUTE = -821,                                   /**< operation not executed */
+               SYNC_AGENT_DA_ERR_ITEM_READ_ONLY = -822,                                        /**< requested item is read only*/
+               SYNC_AGENT_DA_ERR_INVALID_PARAMETER = -823,             /**< invalid parameter*/
+               SYNC_AGENT_DA_ERR_SERVICE_DB = -824,                    /**< service database error*/
+               SYNC_AGENT_DA_ERR_SERVICE_IPC = -825,                   /**< service ipc error*/
+       } sync_agent_da_return_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DATA_ADAPTER_ERROR_H_ */
diff --git a/include/data-adapter/interface_changelog.h b/include/data-adapter/interface_changelog.h
new file mode 100755 (executable)
index 0000000..34513b4
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_CHANGELOG_H_
+#define INTERFACE_CHANGELOG_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_changelog.h
+ * @brief              Support to process changed service item, effect to F/W item, change log table.
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework changelog instance
+ */
+       typedef struct {
+               char *item_id;
+                       /**< F/W item id */
+               int operation_id;
+                               /**< operation id - add, delete, update */
+               char *status;
+                       /**< user defined status of item */
+               char *access_name;
+                               /**< name of accessor */
+       } sync_agent_da_item_changelog_s;
+
+/**
+ * @brief      Enumerations of changelog update type
+ */
+       typedef enum {
+               SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_SYNC_STATUS,
+                                                               /**< changelog update by sync status */
+               SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS,
+                                                               /**< changelog update by wait status */
+       } sync_agent_da_update_changelog_option_e;
+
+/**
+ * @brief      Structure of changelog update query instance
+ */
+       typedef struct {
+               sync_agent_da_update_changelog_option_e option;
+               sync_agent_da_item_changelog_s *update_item;
+                                                       /**< will be updated changelog - SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_SYNC_STATUS */
+               char **folder_id_list;
+                               /**< array of folder id - SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS */
+               int folder_id_count;
+                               /**< count of folder id list - SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS */
+               int *item_type_id_list;
+                               /**< array of item type id - SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS */
+               int item_type_id_count;
+                               /**< count of item type id list - SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS */
+       } sync_agent_da_update_changelog_query_s;
+
+/**
+ * @brief      Enumerations of changelog deletion type
+ */
+       typedef enum {
+               SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_ID,
+                                                       /**< changelog deletion by item id */
+               SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_TYPE_ID,     /**< changelog deletion by item type id */
+               SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_ID_LIST,     /**< changelog deletion by item id list */
+       } sync_agent_da_delete_changelog_option_e;
+
+/**
+ * @brief      Structure of changelog deletion query instance
+ */
+       typedef struct {
+               sync_agent_da_delete_changelog_option_e option;
+                                                       /**< Type of deletion */
+               char *item_id;
+                       /**< F/W item id - SYNC_AGENT_DA_DELET_CHANGELOG_OPTION_ITEM_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_DELET_CHANGELOG_OPTION_ITEM_TYPE_ID*/
+               char **item_id_list;
+                               /**< F/W item id list - SYNC_AGENT_DA_DELET_CHANGELOG_OPTION_ITEM_ID_LIST */
+               int count;
+                       /**< count of F/W item id list - SYNC_AGENT_DA_DELET_CHANGELOG_OPTION_ITEM_ID_LIST */
+       } sync_agent_da_delete_changelog_query_s;
+
+/**
+ * @brief      Enumerations of changelog fetch type
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID,
+                                                               /**< changelog fetch by item type id */
+       } sync_agent_da_get_changelog_list_option_e;
+
+/**
+ * @brief      Structure of changelog fetch query instance
+ */
+       typedef struct {
+               sync_agent_da_get_changelog_list_option_e option;
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID */
+       } sync_agent_da_get_changelog_list_query_s;
+
+/**
+ * @brief                      Create item changelog info
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_changelog_s *changelog = NULL;
+ da_err = sync_agent_create_changelog(&changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out] sync_agent_changelog     item changelog info initizlied
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_create_changelog(sync_agent_da_item_changelog_s ** sync_agent_changelog);
+
+/**
+ * @brief                      Update item changelog info
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+ sync_agent_da_update_changelog_query_s query;
+ query.option = SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS;
+ query.folder_id_list = NULL;
+ query.folder_id_count = 0;
+ query.item_type_id_list = item_type_id_list;
+ query.item_type_id_count = 1;
+
+ da_err = sync_agent_update_changelog(accoutn_id, &query);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id F/W account id
+ * @param[in]          query F/W sync_agent_da_update_changelog_query_s type of query instance
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_update_changelog(int account_id, sync_agent_da_update_changelog_query_s * query);
+
+/**
+ * @brief                      Delete item changelog info
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+ sync_agent_da_delete_changelog_query_s query;
+ query.option = SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_TYPE_ID;
+ query.item_type_id = FW_CONTACT;
+ da_err = sync_agent_delete_changelog(account_id, &query);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id F/W account id
+ * @param[in]          query sync_agent_da_update_changelog_query_s type of query instance
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_delete_changelog(int account_id, sync_agent_da_delete_changelog_query_s * query);
+
+/**
+ * @brief                      Get item changelog info
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_changelog_s *changelog = NULL;
+
+ da_err = sync_agent_create_changelog(&changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ da_err = sync_agent_get_changelog(account_id, item_id, &changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id F/W account id
+ * @param[in]          item_id F/W item id
+ * @param[out]         sync_agent_changelog     item changelog info (item_id, operation_id, status, access_name)
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_get_changelog(int account_id, char *item_id, sync_agent_da_item_changelog_s ** sync_agent_changelog);
+
+/**
+ * @brief                      Fetch list of changelog instance according to given query option
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_changelog_s *changelog = NULL;
+ GList *changelog_list = NULL;
+ sync_agent_da_get_changelog_list_query_s query;
+ query.option = SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = item_type_id;
+ da_err = sync_agent_get_changelog_list(&query, &changelog_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          query sync_agent_da_update_changelog_query_s type of query instance
+ * @param[out]         list list of sync_agent_da_item_changelog_s type of changelog instance
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_get_changelog_list(sync_agent_da_get_changelog_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Free changelog instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_changelog_s *changelog = NULL;
+
+ da_err = sync_agent_create_changelog(&changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ da_err = sync_agent_get_changelog(account_id, item_id, &changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ da_err = sync_agent_free_changelog(changelog);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_changelog sync_agent_da_item_changelog_s type of changelog instance to free
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_free_changelog(sync_agent_da_item_changelog_s * sync_agent_changelog);
+
+/**
+ * @brief                      Free list of changelog instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_item_changelog_s *changelog = NULL;
+ GList *changelog_list = NULL;
+ sync_agent_da_get_changelog_list_query_s query;
+ query.option = SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = item_type_id;
+ da_err = sync_agent_get_changelog_list(&query, &changelog_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+ da_err = sync_agent_free_changelog_list(changelog_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]  list list of sync_agent_da_item_changelog_s type of changelog instance to free
+ * @return             SYNC_AGENT_DA_SUCCESS on success, otherwise a negative error value.
+ */
+       sync_agent_da_return_e sync_agent_free_changelog_list(GList * list);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_CHANGELOG_H_ */
diff --git a/include/data-adapter/interface_config.h b/include/data-adapter/interface_config.h
new file mode 100755 (executable)
index 0000000..480025b
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_CONFIG_H_
+#define INTERFACE_CONFIG_H_
+
+#include "error.h"
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_config.h
+ * @brief              Support to store configuration data into framework
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of config info instance - mapped column of fw configuration database
+ */
+       typedef struct {
+               int config_id;
+                       /**< configuration id, this means account id */
+               char *key;
+                       /**< configuration key */
+               char *value;
+                       /**< configuration value */
+               char *type;
+                       /**< configuration type */
+               char *access_name;
+                               /**< name of accessor */
+       } sync_agent_da_config_s;
+
+/**
+ * @brief                              Create config info instance initialized
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_config_s *config = NULL;
+ da_err = sync_agent_create_config(&config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out]         config                                                                                  empty config info instance newly initialized
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_create_config(sync_agent_da_config_s ** config);
+
+/**
+ * @brief                              Insert config info instance into fw configuration database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_config_s *config = NULL;
+ da_err = sync_agent_create_config(&config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ config->access_name = access_name;
+ config->config_id = account_id;
+ config->key  = "test";
+ config->value = "ok";
+ config->type = "int";
+ da_err = sync_agent_add_config(config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  config                                                                                  config info instance to add
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_add_config(sync_agent_da_config_s * config);
+
+/**
+ * @brief                              Insert config info instance list into fw configuration database
+ * @par Usage:
+ * @code
+ GList *config_list = NULL;
+ append_config_instances_onto_g_list(&config_list);
+ da_err = sync_agent_add_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  config_list                                                                             list of config info instance to add
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_add_config_list(GList * config_list);
+
+/**
+ * @brief                              Insert or update config info instance into fw configuration database
+ *                                     checking whether the config exist in config_tbl.
+ *                                     If it does not exist, insert config into config_tbl.
+ *                                     If it existed, update config into config_tbl.
+ * @par Usage:
+ * @code
+ sync_agent_da_config_s *config = NULL;
+ da_err = sync_agent_get_config(account_id, "test", &config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ config->value = "updated value";
+ da_err = sync_agent_update_config(&config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]                  config                                                                                  config info instance to update
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_update_config(sync_agent_da_config_s * config);
+
+/**
+ * @brief                              Delete config info instance from fw configuration database by key
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ da_err = sync_agent_delete_config(account_id, "test");
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  account_id                                                                              account_id
+ * @param[in]                  key                                                                                             key of config info to delete
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_delete_config(int account_id, char *key);
+
+/**
+ * @brief                      Check whether config of the given key exist in fw configuration database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ int exist = 0;
+
+ da_err = sync_agent_is_exist_config(accoutn_id, "test", &exist);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ if (exist == 1) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  account_id                                                                              account_id
+ * @param[in]                  key                                                                                             key fo config info to check
+ * @param[out]         exist                                                                                           1 on exist case, otherwise 0
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_is_exist_config(int account_id, char *key, int *exist);
+
+/**
+ * @brief                              Get config info instance from fw configuration database by key
+ * @par Usage:
+ * @code
+ sync_agent_da_config_s *config = NULL;
+ da_err = sync_agent_get_config(account_id, "test", &config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  account_id                                                                              account_id
+ * @param[in]                  key                                                                                             key of config info to fetch
+ * @param[out]         config                                                                                  config info instance
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                   success
+ * @retval                     error_value                                                                             fail
+ */
+       sync_agent_da_return_e sync_agent_get_config(int account_id, char *key, sync_agent_da_config_s ** config);
+
+/**
+ * @brief                              Get list of config info instance from fw configuration database by account_id
+ *                                     get all the config in account
+ * @par Usage:
+ * @code
+ GList *config_list = NULL;
+ da_err = sync_agent_get_config_list(account_id, &config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  account_id                                                      account_id
+ * @param[in]                  list                                                                    list of config info instance
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                                                           success
+ * @retval                     error_value                                                                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_config_list(int account_id, GList ** list);
+
+/**
+ * @brief                              Free config info instance
+ * @par Usage:
+ * @code
+ sync_agent_da_config_s *config = NULL;
+ da_err = sync_agent_get_config(account_id, "test", &config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ da_err = sync_agent_free_config(config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  config                                                          config info instance to free
+ */
+       void sync_agent_free_config(sync_agent_da_config_s * config);
+
+/**
+ * @brief                              Free list of config info instance
+ * @par Usage:
+ * @code
+ GList *config_list = NULL;
+ da_err = sync_agent_get_config_list(account_id, &config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+ da_err = sync_agent_free_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  list                                                                                            list of config info instance to free
+ */
+       void sync_agent_free_config_list(GList * list);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_CONFIG_H_ */
diff --git a/include/data-adapter/interface_folder.h b/include/data-adapter/interface_folder.h
new file mode 100755 (executable)
index 0000000..719f009
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_FOLDER_H_
+#define INTERFACE_FOLDER_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_folder.h
+ * @brief              Support to store folder item into framework
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework folder item instance
+ */
+       typedef struct {
+               char *folder_id;                /**< F/W folder id */
+               int data_store_id;              /**< service data connector pluIn's ID described in F/W config file  */
+               int account_id;         /**< F/W account id */
+               int folder_type_id;             /**< data connector plugIn has this folder type id */
+               char *service_id;               /**< service folder id */
+               char *parent_folder_id;
+                               /**< parent folder id if exist hierarchy */
+               char *access_name;      /**< name of accessor */
+       } sync_agent_da_folder_s;
+
+/**
+ * @brief      Enumerations of option used to fetch framework folder item list
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING,/**< get folder list by service id mapping */
+       } sync_agent_da_get_folder_list_option_e;
+
+/**
+ * @brief      Structure of query used to fetch framework folder item list
+ */
+       typedef struct {
+               sync_agent_da_get_folder_list_option_e option;
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING */
+               char *folder_id;/**< F/W folder id - SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING */
+       } sync_agent_da_get_folder_list_query_s;
+
+/**
+ * @brief      Enumerations of option used to fetch framework folder item id list
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID,      /**< get folder id by folder type */
+               SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_ITEM_TYPE_ID,        /**< get folder id by item type */
+       } sync_agent_da_get_folder_id_list_option_e;
+
+/**
+ * @brief      Structure of query used to fetch framework folder item id list
+ */
+       typedef struct {
+               sync_agent_da_get_folder_id_list_option_e option;
+                                                               /**< sync_agent_da_get_folder_id_list_option_e type of enumeration for fetch option */
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID, SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_ITEM_TYPE_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID, SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_ITEM_TYPE_ID */
+               int folder_type_id;
+                               /**< F/W folder type id - SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID */
+       } sync_agent_da_get_folder_id_list_query_s;
+
+/**
+ * @brief                      Create initialized folder item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_folder_s *folder = NULL;
+ da_err = sync_agent_create_folder(&folder);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks            folder item in FW corresponds to entity in service layer such as addressbook in Contact-service and calendar in Calendar-service
+ * @param[out] sync_agent_folder                               framework folder item instance initialized new
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_create_folder(sync_agent_da_folder_s ** sync_agent_folder);
+
+/**
+ * @brief                      Add framework folder item instance into framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_folder_s *folder = NULL;
+ char *folder_id = NULL;
+ da_err = sync_agent_create_folder(&folder);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+ da_err = sync_agent_add_folder(folder, &folder_id);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          sync_agent_folder                               framework folder item instance to add
+ * @param[out] folder_id                                               id of framework folder item instance added new
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_add_folder(sync_agent_da_folder_s * sync_agent_folder, char **folder_id);
+
+/**
+ * @brief                      Fetch framework folder item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_folder_s *folder = NULL;
+ da_err = sync_agent_get_folder(folder_id, &folder);
+       ...
+ }
+ * @endcode
+ * @param[in]          folder_id                                               id of framework folder item instance desired to get
+ * @param[out] sync_agent_folder                               framework folder item instance fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_folder(char *folder_id, sync_agent_da_folder_s ** sync_agent_folder);
+
+/**
+ * @brief                      Fetch list of framework folder item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_get_folder_list_query_s query;
+ GList *folder_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING;
+ query.account_id = account_id;
+ query.folder_id = folder_id;
+ da_err = sync_agent_get_folder_list(&query, &folder_list);
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_folder_list_query_s type of query for fetch operation
+ * @param[out] list                                                    list of framework folder item instance fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_folder_list(sync_agent_da_get_folder_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Fetch list of framework folder item id
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_get_folder_id_list_query_s query;
+ GList *folder_id_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ query.folder_type_id = 0;
+ da_err = sync_agent_get_folder_list(&query, &folder_id_list);
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_folder_id_list_query_s type of query for fetch operation
+ * @param[out] list                                                    list of framework folder item id fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_folder_id_list(sync_agent_da_get_folder_id_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Free framework folder item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_folder_s *folder = NULL;
+ da_err = sync_agent_get_folder(folder_id, &folder);
+       ...
+ }
+
+...
+
+ da_err = sync_agent_free_folder(folder);
+       ...
+ }
+
+ * @endcode
+ * @param[in]          sync_agent_folder                               framework folder item instance to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_folder(sync_agent_da_folder_s * sync_agent_folder);
+
+/**
+ * @brief                      Free list of framework folder item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_get_folder_list_query_s query;
+ GList *folder_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING;
+ query.account_id = account_id;
+ query.folder_id = folder_id;
+ da_err = sync_agent_get_folder_list(&query, &folder_list);
+       ...
+ }
+
+ ...
+ da_err = sync_agent_free_folder_list(folder_list);
+       ...
+ }
+ * @endcode
+ * @param[in]          list                                                    list of framework folder item instance to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_folder_list(GList * list);
+
+/**
+ * @brief                      Free framework folder item id
+
+* @par Usage:
+* @code
+
+sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+sync_agent_da_folder_s *folder = NULL;
+char *folder_id = NULL;
+
+da_err = sync_agent_create_folder(&folder);
+if (da_err != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+da_err = sync_agent_add_folder(folder, &folder_id);
+if (da_err != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+da_err = sync_agent_free_folder_id(folder_id);
+if (da_err != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]           folder_id                                               framework folder item id to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_folder_id(char *folder_id);
+
+/**
+ * @brief                      Free list of framework folder item id
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_get_folder_id_list_query_s query;
+ GList *folder_id_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ query.folder_type_id = 0;
+ da_err = sync_agent_get_folder_list(&query, &folder_id_list);
+       ...
+ }
+ ...
+ da_err = sync_agent_free_folder_id_list(folder_id_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          list                                                    list of framework folder item id to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_folder_id_list(GList * list);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_FOLDER_H_ */
diff --git a/include/data-adapter/interface_item.h b/include/data-adapter/interface_item.h
new file mode 100755 (executable)
index 0000000..2b5bd0e
--- /dev/null
@@ -0,0 +1,525 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_ITEM_H_
+#define INTERFACE_ITEM_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_item.h
+ * @brief
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework item instance
+ */
+       typedef struct {
+               char *item_id;
+                       /**< F/W item id */
+               int data_store_id;
+                               /**< service data connector pluIn's ID described in F/W config file  */
+               int account_id;
+                       /**< F/W account id */
+               char *folder_id;/**< F/W folder id */
+               char *service_id;
+                               /**< service item id */
+               char *access_name;
+                               /**< name of accessor */
+       } sync_agent_da_item_s;
+
+/**
+ * @brief      Enumerations of option used to delete framework item
+ */
+       typedef enum {
+               SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID,
+                                                       /**< delete item by item type */
+       } sync_agent_da_delete_item_option_e;
+
+/**
+ * @brief      Structure of query used to delete framework item
+ */
+       typedef struct {
+               sync_agent_da_delete_item_option_e option;
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID */
+       } sync_agent_da_delete_item_query_s;
+
+/**
+ * @brief      Enumerations of option used to fetch framework item list
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID,          /**< get item by account id */
+               SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_SERVICE_ID_MAPPING,
+                                                               /**< get item by service id */
+       } sync_agent_da_get_item_list_option_e;
+
+/**
+ * @brief      Structure of query used to fetch framework item list
+ */
+       typedef struct {
+               sync_agent_da_get_item_list_option_e option;
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_ACCOUNT_ID */
+               char *item_id;
+                       /**< F/W item id - SYNC_AGENT_DA_ITEM_GET_LIST_OPTION_SERVICE_ID_MAPPING */
+       } sync_agent_da_get_item_list_query_s;
+
+/**
+ * @brief      Structure of query used to fetch framework item id
+ */
+       typedef struct {
+               int account_id; /**< account id */
+               char *service_id;       /**< service id */
+               int item_type_id;       /**< item type */
+       } sync_agent_da_get_item_id_query_s;
+
+/**
+ * @brief      Enumerations of option used to fetch framework item id list
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME,                                      /**< get item by column name */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID,                                     /**< get item by operation id */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID,         /**< get item by operation id and folder id */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID,      /**< get item by operation id and item type */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID,                                     /**< get item by item type */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID,        /**< get item by item type and account id */
+               SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_FOLDER_ID_N_ACCOUNT_ID            /**< get item by folder id and account id */
+       } sync_agent_da_get_item_id_list_option_e;
+
+/**
+ * @brief      Enumerations of common column related to framework item
+ */
+       typedef enum {
+               SYNC_AGENT_DA_COLUMN_NAME_ACCOUNT_ID,
+                                               /**< means column, account_id */
+               SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID,
+                                               /**< means column, item_id */
+               SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID,
+                                               /**< means column, service_id */
+               SYNC_AGENT_DA_COLUMN_NAME_ACCESS_NAME,
+                                               /**< means column, access_name */
+
+               SYNC_AGENT_DA_COLUMN_NAME_MAX
+                                       /**< count of common columns */
+       } sync_agent_da_column_name_e;
+
+/**
+ * @brief      Structure of query used to fetch framework item id list
+ */
+       typedef struct {
+               sync_agent_da_get_item_id_list_option_e option;
+               sync_agent_da_column_name_e column_name;/**< Column name - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME */
+               int operation_id;       /**< F/W operation id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID*/
+               char *folder_id;/**< F/W folder id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID */
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID, SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID */
+       } sync_agent_da_get_item_id_list_query_s;
+
+/**
+ * @brief                      Create initialized framework item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item;
+ ret = sync_agent_create_item(&item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @remarks            item in FW corresponds to entity in service layer such as conatct in Contact-service and event in Calendar-service
+ * @param[out] sync_agent_item                         framework item instance initialized new
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_create_item(sync_agent_da_item_s ** sync_agent_item);
+
+/**
+ * @brief                      Add framework item instance into frameowrk db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+ char *item_id = NULL;
+
+ ret = sync_agent_create_item(&item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+ ret = sync_agent_add_item(item, &item_id, true);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_item                         framework item instance to add
+ * @param[out] item_id                                         id of framework item instance added new
+ * @param[in]          use_changelog                           option specifying whether use of changelog for sync history
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_add_item(sync_agent_da_item_s * sync_agent_item, char **item_id, int use_changelog);
+
+/**
+ * @brief                      Update framework item
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+
+ ret = sync_agent_get_item(item_id, &item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_update_item(item_id, true);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @remarks            Framework item is just mapped to service item so just has mapping information. Means it doesn't have real service data, and mapping information which framework item has just need to be updated
+ * @param[in]          item_id                                         id of framework item instance desired to update
+ * @param[in]          use_changelog                           option specifying whether use of changelog for sync history
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_update_item(char *item_id, int use_changelog);
+
+/**
+ * @brief                      Delete framework item
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ ret = sync_agent_delete_item(item_id, true);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          item_id                                         id of framework item instance desired to delete
+ * @param[in]          use_changelog                           option specifying whether use of changelog for sync history
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_delete_item(char *item_id, int use_changelog);
+
+/**
+ * @brief                      Delete framework items according to given query in GList form
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_delete_item_query_s query;
+
+ query_item.option = SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID;
+ query_item.item_type_id = FW_CONTACT;
+ query_item.account_id = account_id;
+
+ ret = sync_agent_query_delete_item(&query);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_delete_item_query_s type of query for delete operation
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_query_delete_item(sync_agent_da_delete_item_query_s * query);
+
+/**
+ * @brief                      Fetch framework item instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+
+ ret = sync_agent_get_item(item_id, &item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          item_id                                         id of framework folder item instance desired to get
+ * @param[out] sync_agent_item                         framework item instance fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_item(char *item_id, sync_agent_da_item_s ** sync_agent_item);
+
+/**
+ * @brief                      Fetch framework items according to given query in GList form
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_list_query_s query;
+ GList *item_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
+ query.item_type_id = FW_CONTACT;
+
+ ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          account_id                                      account id of items desired to get
+ * @param[in]          query                                           sync_agent_da_get_item_list_query_s type of query for fetch operation
+ * @param[out] list                                                    list of framework item instance fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Get framework item id according to given query
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_id_query_s query;
+ char *item_id = NULL;
+
+ query.service_id = service_item_id;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+
+ da_err = sync_agent_get_item_id(&query, &item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_item_id_query_s type of query for fetch operation
+ * @param[out] item_id                                         id of framework item instance requested
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_item_id(sync_agent_da_get_item_id_query_s * query, char **item_id);
+
+/**
+ * @brief                      Get framework item ids according to given query in GList form
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_id_list_query_s query;
+ GList *item_id_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
+
+ da_err = sync_agent_get_item_id_list(&query, &item_id_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_item_id_list_query_s type of query for fetch operation
+ * @param[out] list                                                    list of framework item id fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_item_id_list(sync_agent_da_get_item_id_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Free framework item instance provided
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_item_s *item = NULL;
+
+ ret = sync_agent_get_item(item_id, &item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_item(item);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          sync_agent_item                         framework item instance to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_item(sync_agent_da_item_s * sync_agent_item);
+
+/**
+ * @brief                      Free framework items provided in GList form
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_list_query_s query;
+ GList *item_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID;
+ query.item_type_id = FW_CONTACT;
+
+ ret = sync_agent_get_item_list(accoutn_id, &query, &item_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_item_list(item_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          list                                                    framework item instance list to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_item_list(GList * list);
+
+/**
+ * @brief                      Free framework item id provided
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_id_query_s query;
+ char *item_id = NULL;
+
+ query.service_id = service_item_id;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+
+ da_err = sync_agent_get_item_id(&query, &item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_item_id(item_id);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          item_id                                         framework item id to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_item_id(char *item_id);
+
+/**
+ * @brief                      Free framework item id list provided in GList form
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_item_id_list_query_s query;
+ GList *item_id_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ query.operation_id = SYNC_AGENT_DA_CHANGE_OPERATION_DELETE;
+
+ da_err = sync_agent_get_item_id_list(&query, &item_id_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_item_id_list(item_id_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          list                                                    framework item id list to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_item_id_list(GList * list);
+
+/**
+ * @brief              get item count in item table where service type
+ * @param[in]  data_store_id                           item's service type
+ * @param[out] item_count                                      item count for service id
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_ITEM_H_ */
diff --git a/include/data-adapter/interface_last_anchor.h b/include/data-adapter/interface_last_anchor.h
new file mode 100755 (executable)
index 0000000..27c4913
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_LAST_ANCHOR_H_
+#define INTERFACE_LAST_ANCHOR_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_last_anchor.h
+ * @brief
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework last anchor instance
+ */
+       typedef struct {
+               int account_id;
+                       /**< F/W account id */
+               int data_store_id;
+                               /**< service data connector plug-in id described in F/W config file  */
+               char *last_anchor_server;
+                                       /**< last anchor that server has */
+               char *last_anchor_client;
+                                       /**< last anchor that client has */
+               char *access_name;
+                               /**< name of accessor */
+       } sync_agent_da_last_anchor_s;
+
+/**
+ * @brief      Enumerations of option used to fetch framework last anchor instance
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID,
+                                                               /**< get last anchor by item type id */
+       } sync_agent_da_get_last_anchor_list_option_e;
+
+/**
+ * @brief      Structure of query used to fetch list of framework last anchor
+ */
+       typedef struct {
+               sync_agent_da_get_last_anchor_list_option_e option;     /**< sync_agent_da_get_last_anchor_list_option_e type of option */
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID */
+               int item_type_id;
+                               /**< F/W item type id - SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID */
+       } sync_agent_da_get_last_anchor_list_query_s;
+
+/**
+ * @brief                      Create initialized framework last anchor instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_last_anchor_s *anchor;
+ ret = sync_agent_create_last_anchor(&anchor);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out] sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance newly initialied
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_create_last_anchor(sync_agent_da_last_anchor_s ** sync_agent_last_anchor);
+
+/**
+ * @brief                      Add framework last anchor instance into frameowrk db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_last_anchor_s *anchor;
+ ret = sync_agent_create_last_anchor(&anchor);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_add_last_anchor(anchor);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance to add into framework
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_add_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
+
+/**
+ * @brief                      Update framework last anchor on framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_last_anchor_list_query_s query;
+ GList *anchor_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ ret = sync_agent_get_last_anchor_list(&query, &anchor_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+ ret = sync_agent_update_last_anchor((sync_agent_da_last_anchor_s *)(anchor_list->data));
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ * @endcode
+ * @param[in]          sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor instance to update into framework
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_update_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
+
+/**
+ * @brief                      Fetch framework last anchor from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_last_anchor_list_query_s query;
+ GList *anchor_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID;
+ query.account_id = account_id;
+ query.item_type_id = FW_CONTACT;
+ ret = sync_agent_get_last_anchor_list(&query, &anchor_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                                   sync_agent_da_get_last_anchor_list_query_s type of query to apply to fetch operation
+ * @param[out] list                                                            GList type of list which will be filled with last anchor instances fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_last_anchor_list(sync_agent_da_get_last_anchor_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Free framework last anchor fetched from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_last_anchor_s *anchor;
+ ret = sync_agent_create_last_anchor(&anchor);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_last_anchor(anchor);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_last_anchor                          sync_agent_da_last_anchor_s type of last anchor item to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_LAST_ANCHOR_H_ */
diff --git a/include/data-adapter/interface_mapping.h b/include/data-adapter/interface_mapping.h
new file mode 100755 (executable)
index 0000000..b755044
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_MAPPING_H_
+#define INTERFACE_MAPPING_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_mapping.h
+ * @brief
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework mapping instance
+ */
+       typedef struct {
+               int account_id; /**< F/W account id */
+               int data_store_id;      /**< service data connector pluIn's ID described in F/W config file  */
+               char *luid;             /**< Locally unique identifier */
+               char *guid;             /**< Globally unique identifier */
+               char *access_name;
+                               /**< name of accessor */
+       } sync_agent_da_mapping_s;
+
+/**
+ * @brief      Enumerations of option used to delete framework mapping instance
+ */
+       typedef enum {
+               SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID,
+                                                       /**< delete mapping by account id */
+               SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID,               /**< delete mapping by luid */
+       } sync_agent_da_delete_mapping_option_e;
+
+/**
+ * @brief      Structure of query used to delete framework mapping
+ */
+       typedef struct {
+               sync_agent_da_delete_mapping_option_e option;
+                                                       /**< sync_agent_da_delete_mapping_option_e type of option */
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID, SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID */
+               char *luid;     /**< F/W luid - SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID */
+       } sync_agent_da_delete_mapping_query_s;
+
+/**
+ * @brief      Structure of query used to fetch framework mapping
+ */
+       typedef struct {
+               int account_id;
+                       /**< F/W account id */
+               char *luid;     /**< F/W luid */
+       } sync_agent_da_get_mapping_query_s;
+
+/**
+ * @brief      Enumerations of option used to fetch list of framework mapping instance
+ */
+       typedef enum {
+               SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID,
+                                                               /**< get mapping list by account id */
+       } sync_agent_da_get_mapping_list_option_e;
+
+/**
+ * @brief      Structure of query used to fetch list of framework mapping instance
+ */
+       typedef struct {
+               sync_agent_da_get_mapping_list_option_e option;
+                                                       /**< sync_agent_da_get_mapping_list_option_e type of option */
+               int account_id;
+                       /**< F/W account id - SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID */
+       } sync_agent_da_get_mapping_list_query_s;
+
+/**
+ * @brief                      Create initialized framework mapping instance
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_mapping_s *mapping;
+ ret = sync_agent_create_mapping(&mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[out] sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance newly initialied
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_create_mapping(sync_agent_da_mapping_s ** sync_agent_mapping);
+
+/**
+ * @brief                      Add framework mapping instance into frameowrk db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_mapping_s *mapping;
+ ret = sync_agent_create_mapping(&mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_add_mapping(mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance to add into framework
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_add_mapping(sync_agent_da_mapping_s * sync_agent_mapping);
+
+/**
+ * @brief                      Delete framework mapping instance from frameowrk db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_delete_mapping_query_s query;
+ query.option = SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID;
+ query.account_id = account_id;
+
+ ret = sync_agent_delete_mapping(&query);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_delete_mapping_query_s type of query to apply to delete operation
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_delete_mapping(sync_agent_da_delete_mapping_query_s * query);
+
+/**
+ * @brief                      Fetch framework mapping from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_mapping_query_s query;
+ sync_agent_da_mapping_s *mapping = NULL;
+
+ query.account_id = account_id;
+ query.luid = framework_id;
+
+ ret = sync_agent_get_mapping(&query, &mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_mapping_query_s type of query to apply to fetch operation
+ * @param[out] sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_mapping(sync_agent_da_get_mapping_query_s * query, sync_agent_da_mapping_s ** sync_agent_mapping);
+
+/**
+ * @brief                      Fetch list of framework mapping from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_mapping_list_query_s query;
+ GList *mapping_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
+ query.account_id = account_id;
+
+ ret = sync_agent_get_mapping_list(&query, &mapping_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          query                                           sync_agent_da_get_mapping_list_query_s type of query to apply to fetch operation
+ * @param[out] list                                                    GList type of list which will be filled with mapping instances fetched
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_get_mapping_list(sync_agent_da_get_mapping_list_query_s * query, GList ** list);
+
+/**
+ * @brief                      Free framework mapping fetched from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_mapping_query_s query;
+ sync_agent_da_mapping_s *mapping = NULL;
+
+ query.account_id = account_id;
+ query.luid = framework_id;
+
+ ret = sync_agent_get_mapping(&query, &mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_mapping(mapping);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          sync_agent_mapping                      sync_agent_da_mapping_s type of mapping instance to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_mapping(sync_agent_da_mapping_s * sync_agent_mapping);
+
+/**
+ * @brief                      Free framework list of mappint fetched from framework db
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_get_mapping_list_query_s query;
+ GList *mapping_list = NULL;
+
+ query.option = SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID;
+ query.account_id = account_id;
+
+ ret = sync_agent_get_mapping_list(&query, &mapping_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+
+ ...
+
+ ret = sync_agent_free_mapping_list(mapping_list);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]          list                                                    GList type of list which is filled with mapping instances to free
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS           success
+ * @retval             error_value                                     fail
+ */
+       sync_agent_da_return_e sync_agent_free_mapping_list(GList * list);
+
+/**
+ * @brief                      Check whether framework has mapping information related to given account id
+ * @par Usage:
+ * @code
+ int result = sync_agent_is_exist_mapping_by_account_id(account_id);
+ if (result == 1) {
+       ...
+ } else {
+       ...
+ }
+ * @endcode
+ * @param[in]          account_id                                      accound id
+ * @return             checking result
+ * @retval             1                                                       exist
+ * @retval             0(or error value)                               not exist
+ */
+       int sync_agent_is_exist_mapping_by_account_id(int account_id);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INTERFACE_MAPPING_H_ */
diff --git a/include/data-adapter/interface_service_item.h b/include/data-adapter/interface_service_item.h
new file mode 100755 (executable)
index 0000000..9c9a23f
--- /dev/null
@@ -0,0 +1,557 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_SERVICE_ITEM_H_
+#define INTERFACE_SERVICE_ITEM_H_
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               interface_service_item.h
+ * @brief      Support to use service storage
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Structure of framework service item instance
+ */
+       typedef struct {
+               char *item_id;          /** service item id */
+               int content_type;               /** content type of service item */
+               int account_id;         /** service account id */
+               char *folder_id;                /** service folder id to which service item mapped to */
+               char *access_name;      /** name of accessor */
+               const void *data;               /** void pointer type of service data */
+       } sync_agent_da_service_item_s;
+
+/**
+ * @brief      Structure of framework service folder instance
+ */
+       typedef struct {
+               char *folder_id;                /** service folder id */
+               char *folder_name;      /** name of service folder */
+               int folder_type;                /** type of service folder */
+       } sync_agent_da_service_folder_s;
+
+/**
+ * @brief      Structure of query used to delete framework service item
+ */
+       typedef struct {
+               int content_type;       /**< type of content to delete */
+               int account_id; /**< id of the account desired to delete */
+       } sync_agent_da_delete_service_item_query_s;
+
+/**
+ * @brief                              Open service database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_open_service(FW_CONTACT);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_open_service(int content_type);
+
+/**
+ * @brief                              Close service database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_close_service(FW_CONTACT);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_close_service(int content_type);
+
+/**
+ * @brief                              Start transaction for service database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_begin_service(FW_CONTACT);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_begin_service(int content_type);
+
+/**
+ * @brief                              End transaction for service database
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_end_service(FW_CONTACT, false);      //transaction rollback by 'false'
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @param[in]                  is_success                                              1 : commit, 0 : rollback
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_end_service(int content_type, int is_success);
+
+/**
+* @brief                               Create initialized framework service item instance
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+
+ret = sync_agent_create_service_item(&service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[out]          service_item                                            sync_agent_da_service_item_s type of framework service item instance newly initialied
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_create_service_item(sync_agent_da_service_item_s ** service_item);
+
+/**
+* @brief                               Create initialized framework service folder instance
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_folder_s *service_folder = NULL;
+
+ret = sync_agent_create_service_folder(&service_folder);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[out]          service_folder                                          sync_agent_da_service_folder_s type of framework service folder instance newly initialied
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_create_service_folder(sync_agent_da_service_folder_s ** service_folder);
+
+/**
+* @brief                               Free framework service item instance provided
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+
+ret = sync_agent_create_service_item(&service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+ret = sync_agent_free_service_item(service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   service_item                                            sync_agent_da_service_item_s type of framework service item instance to free
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_free_service_item(sync_agent_da_service_item_s * service_item);
+
+/**
+* @brief                               Free framework service folder instance provided
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_folder_s *service_folder = NULL;
+
+ret = sync_agent_create_service_folder(&service_folder);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+ret = sync_agent_free_service_folder(&service_folder);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   service_folder                                          sync_agent_da_service_folder_s type of framework service folder instance to free
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_free_service_folder(sync_agent_da_service_folder_s * service_folder);
+
+/**
+* @brief                               Add framework service item instance into frameowrk db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+char *item_id = NULL;
+
+ret = sync_agent_create_service_item(&service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+ret = sync_agent_add_service_item(service_item, &item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   service_item                                            sync_agent_da_service_item_s type of framework service item instance to add into framework db
+* @param[out]          item_id                                                 id of framework service item instance added new
+* @param[in]                   update_changelog                                        option specifying whether use of changelog for sync history
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_add_service_item(sync_agent_da_service_item_s * service_item, char **item_id, bool update_changelog);
+
+/**
+* @brief                               Update framework service item on framework db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+
+ret = sync_agent_get_service_item(item_id, &service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+...
+
+ret = sync_agent_update_service_item(service_item, item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   service_item                                            sync_agent_da_service_item_s type of framework service item instance to update into framework db
+* @param[in]                   item_id                                                 id of framework service item instance desired to update
+* @param[in]                   update_changelog                                        option specifying whether use of changelog for sync history
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_update_service_item(sync_agent_da_service_item_s * service_item, char *item_id, bool update_changelog);
+
+/**
+* @brief                               Delete framework service item instance from frameowrk db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+ret = sync_agent_delete_service_item(item_id, true);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   item_id                                                 id of framework service item instance desired to delete
+* @param[in]                   update_changelog                                        option specifying whether use of changelog for sync history
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog);
+
+/**
+* @brief                               Delete framework service item instance from frameowrk db using query option
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_delete_service_item_query_s query;
+
+query.content_type = FW_CONTACT;
+query.account_id = account_id;
+
+ret = sync_agent_query_delete_service_items(&query);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   query                                                   sync_agent_da_delete_service_item_query_s type of query for delete operation
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_query_delete_service_items(sync_agent_da_delete_service_item_query_s * query);
+
+/**
+* @brief                               Fetch framework service item from framework db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_item_s *service_item = NULL;
+
+ret = sync_agent_get_service_item(item_id, &service_item);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   item_id                                                 id of framework service item instance desired to get
+* @param[out]          service_item                                            framework service item instance fetched
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_get_service_item(char *item_id, sync_agent_da_service_item_s ** service_item);
+
+/**
+* @brief                               Fetch framework service folder from framework db
+* @par Usage:
+* @code
+
+sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+sync_agent_da_service_folder_s *service_folder = NULL;
+
+ret = sync_agent_get_service_folder(folder_id, &service_folder);
+if (ret != SYNC_AGENT_DA_SUCCESS) {
+   ...
+}
+
+* @endcode
+* @param[in]                   folder_id                                                       id of framework service folder instance desired to get
+* @param[out]          service_folder                                          framework service folder instance fetched
+* @return                      operation result
+* @retval                              SYNC_AGENT_DA_SUCCESS                   success
+* @retval                              error_value                                             fail
+*/
+       sync_agent_da_return_e sync_agent_get_service_folder(char *folder_id, sync_agent_da_service_folder_s ** service_folder);
+
+/**
+ * @brief                              Execute predefined operation through plug-in
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ char *msg = get_msg_body();
+ bool *result = NULL;
+ ret = sync_agent_execute_service(FW_SMS, account_id, "send_msg", msg, &result);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @param[in]                  account_id                                              F/W account id
+ * @param[in]                  execute_key                                             execute key
+ * @param[in]                  execute_values                                  execute values
+ * @param[out]         result                                                  extension result info
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_execute_service(int content_type, int account_id, const char *execute_key, void *execute_values, void **result);
+
+/**
+ * @brief                              Get item used count
+ * @par Usage:
+ * @code
+ int count = 0;
+
+ count = sync_agent_get_used_service_item_count(FW_CONTACT);
+ if (count == 0) {
+       ...
+ } else {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @return                     operation result
+ * @retval                     current item count                                      success
+ * @retval                     error value                                             fail
+ */
+       int sync_agent_get_used_service_item_count(int content_type);
+
+/**
+ * @brief                              Get item used count for folder
+ * @par Usage:
+ * @code
+ int count = 0;
+
+ count = sync_agent_get_used_service_item_count_for_folder(FW_CONTACT, account_id, folder_id);
+ if (count == 0) {
+       ...
+ } else {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @param[in]                  account_id                                              F/W account id
+ * @param[in]                  folder_id       F/W                                             folder id
+ * @return                     operation result
+ * @retval                     current item count                                      success
+ * @retval                     error value                                             fail
+ */
+       int sync_agent_get_used_service_item_count_for_folder(int content_type, int account_id, char *folder_id);
+
+/**
+ * @brief                              Write data store items to file
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_backup_service_items_to_file(FW_CONTACT, account_id, "/tmp/contact_backup");
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @param[in]                  account_id                                              F/W account id
+ * @param[out]         file_path                                                       written file path
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_backup_service_items_to_file(int content_type, int account_id, char **file_path);
+
+/**
+ * @brief                              Add file-written item to data store
+ * @par Usage:
+ * @code
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ ret = sync_agent_restore_service_items_from_file(FW_CONTACT, account_id, "/tmp/contact_backup");
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  content_type                                            service type - service data connector plug-in's ID described in F/W config file
+ * @param[in]                  account_id                                              F/W account id
+ * @param[in]                  file_path                                                       file path
+ * @return                     operation result
+ * @retval                     SYNC_AGENT_DA_SUCCESS                   success
+ * @retval                     error_value                                             fail
+ */
+       sync_agent_da_return_e sync_agent_restore_service_items_from_file(int content_type, int account_id, const char *file_path);
+
+/**
+ * @brief                              Get service item id from framework service item id
+ * @par Usage:
+ * @code
+ char *item_id = NULL;
+
+ item_id = sync_agent_get_service_item_id(framework_item_id);
+ if (item_id != NULL) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  item_id                                                 item id
+ * @return                     operation result
+ * @retval                     service_item_id                                 success
+ * @retval                     0                                                               fail
+ */
+       char *sync_agent_get_service_item_id(char *item_id);
+
+/**
+ * @brief                              Get service folder id from framework service folder id
+ * @par Usage:
+ * @code
+ char *folder_id = NULL;
+
+ folder_id = sync_agent_get_service_folder_id(framework_folder_id);
+ if (folder_id != NULL) {
+       ...
+ }
+ * @endcode
+ * @param[in]                  folder_id                                                       folder id
+ * @return                     operation result
+ * @retval                     service_folder_id                                       success
+ * @retval                     0                                                               fail
+ */
+       char *sync_agent_get_service_folder_id(char *folder_id);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* INTERFACE_SERVICE_ITEM_H_ */
diff --git a/include/data-adapter/luid.h b/include/data-adapter/luid.h
new file mode 100755 (executable)
index 0000000..002b341
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LUID_H_
+#define LUID_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               luid.h
+ * @brief      Support to generate unique ID
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief                      Generate new item LUID to use inside agent, when add new item
+ * @remarks            Generated Sequence ID ( 1, 2, 3, .... ) to max ID value described in F/W initiation config file \<ID-Provider\>\<MaxID\>
+ * @par Usage:
+ * @code
+ char **id_list = NULL;
+ id_list = sync_agent_generate_item_luid(1, count);
+ if (id_list != NULL) {
+       for( int i = 0; i < count; i++) {
+               do_something(id_list[i]);
+       }
+ }
+ * @endcode
+ * @param[in]  id_provider_code        ID's seed value described in F/W initiation config file \<ID-Provider\>\<Code\>
+ * @param[in]  count   number of id to generate
+ * @return                     operation result
+ * @retval                     generated_item_luid_list                success (new item LUID converted to string)
+ * @retval                     0                                               fail
+ */
+       char **sync_agent_generate_item_luid(int id_provider_code, int count);
+
+/**
+ * @brief                      Generate new folder LUID to use inside agent, when add new folder
+ * @par Usage:
+ * @code
+ char *folder_id = NULL;
+
+ folder_id = sync_agent_generate_folder_luid();
+ do_something(folder_id);
+ * @endcode
+ * @return                     operation result
+ * @retval                     folder_luid             success (new folder LUID converted to string)
+ * @retval                     0                                       fail
+ */
+       char *sync_agent_generate_folder_luid(void);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* LUID_H_ */
diff --git a/include/device-manager/device_manager.h b/include/device-manager/device_manager.h
new file mode 100755 (executable)
index 0000000..cc6e435
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mdm_control_code.h"
+#include "mdm_error.h"
+#include "mdm_type.h"
+#include "interface.h"
+#include "mo_accessor.h"
+#include "mo_error.h"
+#include "mo_executor.h"
+#include "mo_struct.h"
diff --git a/include/device-manager/interface.h b/include/device-manager/interface.h
new file mode 100755 (executable)
index 0000000..17c03ce
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_MANAGER_INTERFACE_H_
+#define DEVICE_MANAGER_INTERFACE_H_
+
+#include "mdm_control_code.h"
+#include "mdm_error.h"
+#include "mdm_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface.h           Defines network data communication APIs
+ * @brief Defines MDM manipulation APIs
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * API to start mdm service (register client & open connection to MDM server daemon)
+ *
+ * @par Usage:
+ * @code
+    sync_agent_dm_mdm_return_e error = SYNC_AGENT_DM_MDM_SUCCEEDED;
+               int mdm_plugin_id = 1;
+               char *pkg_name = "xxx";
+               ...
+               error = sync_agent_start_mdm_service(mdm_plugin_id, pkg_name);
+               if (error != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] mdm_plugin_id device-manager plugin id
+ * @param[in] pkg_name package name of agent that wish to use the service
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_start_mdm_service(int, char *)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_start_mdm_service(int mdm_plugin_id, char *pkg_name);
+
+/**
+ * API to stop mdm service (deregister client & close connection)
+ * @remarks The application should be called sync_agent_start_mdm_service() and returned SYNC_AGENT_DM_MDM_SUCCEEDED
+ *
+ * @par Usage:
+ * @code
+               sync_agent_dm_mdm_return_e error = SYNC_AGENT_DM_MDM_SUCCEEDED;
+               int mdm_plugin_id = 1;
+               char *pkg_name = "xxx";
+               ...
+    error = sync_agent_stop_mdm_service(mdm_plugin, PKG_NAME);
+               if (error != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] mdm_plugin_id device-manager plugin id
+ * @param[in] pkg_name package name of agent that wish to use the service
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_stop_mdm_service(int, char *)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_stop_mdm_service(int mdm_plugin_id, char *pkg_name);
+
+/**
+ * API to set user value to the mdm service
+ *
+ * @par Usage:
+ * @code
+               int mdm_plugin_id = 1;
+               sync_agent_dm_mdm_return_e error = SYNC_AGENT_DM_MDM_SUCCEEDED;
+               sync_agent_dm_mdm_ctrl_e ctrl = SYNC_AGENT_DM_MDM_PWD_RECOVERY;
+               ...
+               error = sync_agent_set_mdm_value(mdm_plugin, ctrl, SYNC_AGENT_DM_MDM_TRUE);
+               if (error != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] mdm_plugin_id device-manager plugin id
+ * @param[in] ctrl mdm setting items
+ * @param[in] ... setting value
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_mdm_value(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_set_mdm_value(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...);
+
+/**
+ * API to get mdm service value that user want to know
+ *
+ * @par Usage:
+ * @code
+               int mdm_plugin_id = 1;
+               sync_agent_dm_mdm_return_e error = SYNC_AGENT_DM_MDM_SUCCEEDED;
+               sync_agent_dm_mdm_ctrl_e ctrl = SYNC_AGENT_DM_MDM_PWD_POLICY;
+               sync_agent_dm_mdm_password_policy_s old_policy = {0, };
+               ...
+               error = sync_agent_get_mdm_value(mdm_plugin_id, ctrl, &old_policy);
+               if (error != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] mdm_plugin_id device-manager plugin id
+ * @param[in] ctrl mdm setting items
+ * @param[in] ... service value that user want to know
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_mdm_value(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_get_mdm_value(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...);
+
+/**
+ * API to execute mdm service that user want to execute
+ *
+ * @par Usage:
+ * @code
+               int mdm_plugin_id = 1;
+               sync_agent_dm_mdm_return_e error = SYNC_AGENT_DM_MDM_SUCCEEDED;
+               sync_agent_dm_mdm_ctrl_e ctrl = SYNC_AGENT_DM_MDM_EXE_ENFORCE_PWD_CHANGE;
+               ...
+               error = sync_agent_execute_mdm(mdm_plugin_id, ctrl);
+               if (error != SYNC_AGENT_DM_MDM_SUCCEEDED) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] mdm_plugin_id device-manager plugin id
+ * @param[in] ctrl mdm setting items
+ * @param[in] ... data needed for executing mdm service (some specific case)
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_execute_mdm(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_execute_mdm(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_MANAGER_INTERFACE_H_ */
diff --git a/include/device-manager/mdm_control_code.h b/include/device-manager/mdm_control_code.h
new file mode 100755 (executable)
index 0000000..e8f44b3
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MDM_CONTROL_CODE_H_
+#define MDM_CONTROL_CODE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file mdm_control_code.h
+ * @brief      Provides definition of mdm setting items enum and mdm policy event enum
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * Enumerations for the mdm setting items
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MDM_ALLOW_WIFI = 1,
+                                         /**< setting for the wifi permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_BT,
+                                   /**< setting for the bluetooth permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_CAMERA,
+                                       /**< setting for the camera permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_INTERNET_SHARING,
+                                                 /**< setting for the internet sharing permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_DESKTOP_SYNC,
+                                             /**< setting for the desktop sync permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_STORAGE_CARD,
+                                             /**< setting for the storage card permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_TEXT_MESSAGING,
+                                               /**< setting for the text messaging permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_POP_IMAP,
+                                         /**< setting for the POP or IMAP permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_BROWSER,
+                                        /**< setting for the browser permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_IRDA,
+                                     /**< setting for the IRDA permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_DEVICE_ENCRYPTION,
+                                                  /**< setting for the device encryption permission on the device */
+               SYNC_AGENT_DM_MDM_ALLOW_STORAGE_CARD_ENCRYPTION,
+                                                        /**< setting for the storage card encryption permission on the device */
+               SYNC_AGENT_DM_MDM_PWD_QUALITY,
+                                      /**< setting for the quality of password on the device */
+               SYNC_AGENT_DM_MDM_PWD_MIN_LENGTH,
+                                         /**< setting for the minimum length of password on the device */
+               SYNC_AGENT_DM_MDM_PWD_MAX_FAILED_ATTEMPTS,
+                                                  /**< setting for the maximum number of failed password attempts on the device */
+               SYNC_AGENT_DM_MDM_PWD_EXPIRARION,
+                                         /**< setting for the expiration of password on the device */
+               SYNC_AGENT_DM_MDM_PWD_HISTORY,
+                                      /**< setting for the history of password on the device */
+               SYNC_AGENT_DM_MDM_PWD_NUM_OF_COMPLEX_CHAR,
+                                                  /**< setting for number of complex character of the password on the device */
+               SYNC_AGENT_DM_MDM_PWD_RECOVERY,
+                                       /**< setting for the recovery of password on the device */
+               SYNC_AGENT_DM_MDM_MAX_INACTIVITY_TIME,
+                                              /**< setting for the maximum inactive time on the device */
+
+               SYNC_AGENT_DM_MDM_PWD_POLICY,
+                                     /**< setting for the policy of password on the device */
+
+               SYNC_AGENT_DM_MDM_EXE_ENFORCE_PWD_CHANGE = 100,
+                                                       /**< password change execution on the device */
+               SYNC_AGENT_DM_MDM_EXE_SYSTEM_POPUP
+                                          /**< system popup execution on the device */
+       } sync_agent_dm_mdm_ctrl_e;
+
+/**
+ * Enumerations for the mdm policy event
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_PASSWORD,
+                                                   /**< Password status changed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_WIFI,
+                                               /**< wifi not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_BT,
+                                             /**< bluetooth not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_CAMERA,
+                                                 /**< camera not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_ROAMING_SYNC,
+                                                       /**< roaming sync not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_LOCATION,
+                                                   /**< location service not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_MIC,
+                                              /**< microphone not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_MOBILE_AP,
+                                                    /**< mobile ap not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_KIES,
+                                               /**< kies not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_MESSAGE,
+                                                  /**< message service not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_EMAIL,
+                                                /**< email service not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_ON_BROWSER,
+                                                  /**< browser not allowed */
+               SYNC_AGENT_DM_MDM_EVENT_POLICY_NOTI_MAX
+       } sync_agent_dm_mdm_event_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MDM_CONTROL_CODE_H_ */
diff --git a/include/device-manager/mdm_error.h b/include/device-manager/mdm_error.h
new file mode 100755 (executable)
index 0000000..6a510b8
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MDM_ERROR_H_
+#define MDM_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file mdm_error.h
+ * @brief      Provides definition of mdm result enum
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * Enumerations of return codes for mdm operation
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MDM_PERMISSION_DENIED = -2,
+                                                 /**< Permission denied */
+               SYNC_AGENT_DM_MDM_FAILED = -1,
+                                      /**< Fail */
+               SYNC_AGENT_DM_MDM_SUCCEEDED = 0,
+                                        /**< Success */
+               SYNC_AGENT_DM_MDM_UNSUPPORTED = 1
+                                         /**< Unsupported feature */
+       } sync_agent_dm_mdm_return_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MDM_ERROR_H_ */
diff --git a/include/device-manager/mdm_type.h b/include/device-manager/mdm_type.h
new file mode 100755 (executable)
index 0000000..f982ad1
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MDM_TYPE_H_
+#define MDM_TYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file mdm_type.h
+ * @brief      Provides definition of mdm status enum and various enum related to the password
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * Function which is called when status is changed
+ *
+ * @param[in] status mdm status
+ * @param[in] userdata user data
+ *
+ * @return
+ *
+ * @par Since:
+ *
+ *
+ * @see dm_register_mdm_callback(int, sync_agent_dm_mdm_event_e, sync_agent_device_manager_cb, void*)
+ *
+ */
+       typedef int (*sync_agent_device_manager_cb) (int status, void *userdata);
+
+/**
+ * Enumerations of mdm status
+ */
+       typedef enum {
+               sync_agent_dm_mdm_status_e_ERROR = -1,
+
+               SYNC_AGENT_DM_MDM_ALLOWED = 0,
+               SYNC_AGENT_DM_MDM_RESTRICTED = 1,
+
+               SYNC_AGENT_DM_MDM_ENABLED = 0,
+               SYNC_AGENT_DM_MDM_DISABLED = 1,
+
+               SYNC_AGENT_DM_MDM_FALSE = 0,
+               SYNC_AGENT_DM_MDM_TRUE = 1,
+
+               SYNC_AGENT_DM_MDM_BT_ALLOWED = 0,    /**<  */
+               SYNC_AGENT_DM_MDM_BT_RESTRICTED = 1,
+               SYNC_AGENT_DM_MDM_BT_HANDSFREE_ONLY = 2,
+       } sync_agent_dm_mdm_status_e;
+
+/**
+ * Enumerations of password quality
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_UNSPECIFIED,
+                                                       /**< No requirements for password. */
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_SOMETHING,        /**< Some kind password is required, but doesn't care what it is */
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_NUMERIC,  /**< Containing at least numeric characters */
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_ALPHABETIC,       /**< Containing at least alphabetic (or other symbol) characters */
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_ALPHANUMERIC,
+                                                       /**< Containing at least numeric and alphabetic characters */
+       } sync_agent_dm_mdm_pwd_quality_type_e;
+
+/**
+ * Enumerations of password change status
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MDM_PWD_CHANGED,
+                                      /**< Password successfully set or changed */
+               SYNC_AGENT_DM_MDM_PWD_FAILED,
+                                     /**< Device unlock failed */
+               SYNC_AGENT_DM_MDM_PWD_SUCCEEDED,
+                                        /**< Device unlock succeeded */
+               SYNC_AGENT_DM_MDM_PWD_EXPIRED,
+                                      /**< Password expired */
+
+               SYNC_AGENT_DM_MDM_RECOVERY_PASSWORD_FAILED,
+                                                   /**< Device unlock failed by Password recovery */
+               SYNC_AGENT_DM_MDM_RECOVERY_PASSWORD_SUCCEEDED,
+                                                      /**< Device unlock succeeded by Password recovery */
+
+               SYNC_AGENT_DM_MDM_PWD_QUALITY_CHANGED,
+                                              /**< Password quality successfully changed */
+               SYNC_AGENT_DM_MDM_PWD_MIN_LENGTH_CHANGED,
+                                                 /**< Password min_length successfully changed */
+               SYNC_AGENT_DM_MDM_PWD_COMPLEX_CHAR_CHANGED,
+                                                   /**< Password complex_char successfully changed */
+               SYNC_AGENT_DM_MDM_PWD_PATTERN_CHANGED,
+                                              /**< Password pattern successfully changed */
+
+               SYNC_AGENT_DM_MDM_PWD_STATUS_MAX
+       } sync_agent_dm_mdm_password_status_e;
+
+/**
+ * Enumerations of password policy
+ */
+       typedef struct _sync_agent_dm_mdm_password_policy_s {
+               int quality;
+                    /**< pwd quailty passwd length , refer to mdm_password_quality_t */
+               int min_length;
+                       /**< minimum passwd length */
+               int max_num_wipe;
+                         /**< maximum fail for wipe */
+               int expire;
+                   /**< expire time */
+               int min_complex;
+                        /**< minimum complex */
+               int history_cnt;
+                        /**< history count */
+               int recoverable;
+                        /**< password recovery enabled */
+       } sync_agent_dm_mdm_password_policy_s;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MDM_TYPE_H_ */
diff --git a/include/device-manager/mo_accessor.h b/include/device-manager/mo_accessor.h
new file mode 100755 (executable)
index 0000000..8d66b6b
--- /dev/null
@@ -0,0 +1,1392 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_ACCESSOR_H_
+#define MO_ACCESSOR_H_
+
+#include "mo_error.h"
+#include "mo_struct.h"
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       mo_accessor.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of sync_agent_mo_item
+ */
+       typedef enum _sync_agent_dm_mo_item_e {
+               MO_ITEM_CHILD_MO_VALUE_LIST = 1,
+                                            /**< get value type for mo item chile value list */
+               MO_ONLY_DATA_VALUE,                              /**< get value type for mo item only value list */
+               MO_ALL_VALUE                                            /**< get value type for mo item all value with property list */
+       } sync_agent_dm_mo_item_e;
+
+/**
+ * @brief      Structure of sync_agent_mo_item
+ */
+       typedef struct _sync_agent_dm_mo_item_s {
+               char *mo_path;                                                  /**< mo node path */
+               sync_agent_dm_mo_type_e mo_type;                /**< mo node mo type */
+               sync_agent_dm_mo_get_option_e option;   /**< get option type*/
+               sync_agent_dm_mo_item_e interface_type;
+                                               /**< get interface type */
+       } sync_agent_dm_mo_item_s;
+
+/**
+ * @brief      Structure of sync_agent_mo_acc_item
+ */
+       typedef struct _mo_acc_item_info_s {
+               char *serverid;                                                 /**< server id*/
+               sync_agent_dm_acc_type_e acc_type;              /**< access type*/
+       } sync_agent_dm_mo_acc_item_info_s;
+
+/********************************************************COMMON INTERFACE********************************************************/
+
+/**
+ * API to create mo item
+ * @remarks MO is oma-dm's management object.
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s **sync_agent_mo_item = NULL;
+
+  err = sync_agent_create_mo_item(&sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[out] sync_agent_mo_item created mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need mo creation.
+ * @post new mo node struct is created.
+ *
+ * @par Since:
+ *
+ *
+ * @see add_mo(int server_type, char *mo_full_path, char *value, sync_agent_dm_mo_node_type_e node_type, char *contenttype, char *format)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_create_mo_item(sync_agent_dm_mo_node_s ** sync_agent_mo_item);
+
+/**
+ * API to add mo item
+ * @remarks mo node add to dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s sync_agent_mo_item;
+
+  sync_agent_mo_item.mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+   ...
+
+  err = sync_agent_add_mo_item(&sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] sync_agent_mo_item node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server add command or factory bootstrap
+ * @post new mo node struct is added in dm agent db
+ *
+ * @par Since:
+ *
+ *
+ * @see add_mo(int server_type, char *mo_full_path, char *value, sync_agent_dm_mo_node_type_e node_type, char *contenttype, char *format)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_add_mo_item(sync_agent_dm_mo_node_s * sync_agent_mo_item);
+
+/**
+ * API to update mo item
+ * @remarks mo node update dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s sync_agent_mo_item;
+
+  sync_agent_mo_item.mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+   ...
+
+  err = sync_agent_update_mo_item(&sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] sync_agent_item node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server replace command.
+ * @post mo node in dm agent db struct is updated
+ *
+ * @par Since:
+ *
+ *
+ * @see replace_mo( char *mo_full_path, char *value, char *prop_value, char *contenttype, char * format, GetType prop_type)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_update_mo_item(sync_agent_dm_mo_node_s * sync_agent_item);
+
+/**
+ * API to delete mo item
+ * @remarks mo node delete dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  char * mo_path = NULL;
+
+  mo_path = ./DMAcc/xxx/xxx;
+
+  err = sync_agent_delete_mo_item(mo_path);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_path mo node full path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server delete command.
+ * @post mo node in dm agent db is deleted.
+ *
+ * @par Since:
+ *
+ *
+ * @see delete_mo(char *mo_full_path)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_delete_mo_item(const char *mo_path);
+
+/**
+ * API to delete mo tree
+ * @remarks mo tree delete dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  char * mo_path = NULL;
+
+  mo_path = ./DMAcc/xxx/xxx;
+
+  err = sync_agent_delete_mo_item(mo_path);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_path mo node full path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server delete command.
+ * @post mo tree in dm agent db is deleted.
+ *
+ * @par Since:
+ *
+ *
+ * @see delete_mo(char *mo_full_path)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_delete_mo_tree_item(const char *mo_path);
+
+/**
+ * API to get mo item
+ * @remarks mo node get dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+  char * mo_path = NULL;
+
+  mo_path = ./DMAcc/xxx/xxx;
+
+  err = sync_agent_get_mo_item(mo_path, &sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in]  mo_path mo node full path
+ * @param[out] sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post new mo node struct in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see get_mo_data(char* full_path, char** data )
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_mo_item(const char *mo_path, sync_agent_dm_mo_node_s ** sync_agent_mo_item);
+
+/**
+ * API to get mo items
+ * @remarks mo nodes get dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+  char * mo_path = NULL;
+
+  mo_path = ./DMAcc/xxx/xxx;
+
+  err = sync_agent_get_mo_items(mo_path, &sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in]  mo_path mo node full path
+ * @param[out] sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post new mo node structs in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see get_mo_node_property(const char *mo_path, propoerty_type pr_type, char** property)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_mo_items(const char *mo_path, sync_agent_dm_mo_node_s ** sync_agent_mo_item);
+
+/**
+ * API to get mo item list
+ * @remarks mo node list get dm-agent's in db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+  GList *list = NULL;
+
+  err = sync_agent_query_mo_item(sync_agent_mo_item, &list);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in]  sync_agent_mo_query mo node struct
+ * @param[out] list sync_agent_mo_item in list
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post mo node structs list in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see get_mo_node_property(const char *mo_path, propoerty_type pr_type, char** property)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_query_mo_item(sync_agent_dm_mo_item_s * sync_agent_mo_query, GList ** list);
+
+/**
+ * API to free mo item
+ * @remarks mo node struct is distroyed
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+
+  char * mo_path = NULL;
+
+  mo_path = ./DMAcc/xxx/xxx;
+
+  err = sync_agent_get_mo_item(mo_path, &sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+
+  err = sync_agent_free_mo_item(sync_agent_mo_item);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in]  sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need free mo struct
+ * @post mo node struct list is destroyed.
+ *
+ * @par Since:
+ *
+ *
+ * @see _get_child_mo( char *mo_full_path, GList **mo_node_list)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_free_mo_item(sync_agent_dm_mo_node_s * sync_agent_mo_item);
+
+/**
+ * API to free mo item list
+ * @remarks mo node struct list is distroyed
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+    sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+  GList *list = NULL;
+
+  err = sync_agent_query_mo_item(sync_agent_mo_item, &list);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+
+  err = sync_agent_free_mo_item_list(list);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] list sync_agent_mo_item in list
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need free mo struct list
+ * @post mo node struct list is destroyed.
+ *
+ * @par Since:
+ *
+ *
+ * @see get_mo_data(char* full_path, char** data )
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_free_mo_item_list(GList * list);
+
+/**
+ * API to create dm acc item
+ * @remarks dm acc struct is created
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_acc_info_s *acc_info = NULL;
+
+  err = sync_agent_create_mo_acc_item(&acc_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in]  acc_info dm acc struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need dm acc struct creation.
+ * @post dm acc struct list is created.
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_create_mo_acc_item(sync_agent_dm_acc_info_s ** acc_info);
+
+/**
+ * API to update dm acc item
+ * @remarks dm acc struct is updated
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_acc_info_s acc_info;
+  sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+  sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+  sync_agent_mo_acc_info_item.serverid = "xxx";
+
+  acc_info.auth_name = "xxxx";
+  acc_info.value = "xxx";
+
+  err = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] sync_agent_mo_acc_info_item mo'dmacc info
+ * @param[in] acc_info dm acc struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need update dm acc in dm agent db.
+ * @post dm acc struct is updated.
+ *
+ * @par Since:
+ *
+ *
+ * @see update_dmacc( char* pServer_id, dm_acc *dmaccount)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_update_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);
+
+/**
+ * API to get dm acc item
+ * @remarks dm acc struct is getted
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+  sync_agent_dm_acc_info_s *acc_info = NULL;
+  sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+  sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+  sync_agent_mo_acc_info_item.serverid = "xxx";
+
+  err = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] sync_agent_mo_acc_info_item mo'dmacc info
+ * @param[out] acc_info dm acc struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need get dm acc in dm agent db.
+ * @post dm acc struct is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see update_dmacc( char* pServer_id, dm_acc *dmaccount)
+ *
+ */
+       sync_agent_dm_mo_error_e 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);
+
+/**
+ * API to free dm acc item
+ * @remarks dm acc struct is destroyed
+ *
+ * @par Usage:
+ * @code
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_acc_info_s *acc_info = NULL;
+
+       err = sync_agent_create_mo_acc_item(&acc_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+
+       err = sync_agent_free_mo_acc_item(&acc_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] acc_info dm acc struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need destroy dm acc in dm agent db.
+ * @post dm acc struct is destroyed.
+ *
+ * @par Since:
+ *
+ *
+ * @see update_dmacc( char* pServer_id, dm_acc *dmaccount)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_free_mo_acc_item(sync_agent_dm_acc_info_s ** acc_info);
+
+/********************************************************UTIL INTERFACE********************************************************/
+
+/**
+ * Prototype of event callback function
+ * @remark     event described in event config file will be processed in this callback function
+ *
+ * @param[in] mo_node request received traverse mo tree
+ * @param[in] depth    depth number
+ * @param[in] arg
+ *
+ *
+ * @return 0 on success, -1 on error
+ *
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_traverse_mo_tree_preorder(sync_agent_dm_mo_node_s *root_ptr, sync_agent_mo_worker_cb func_ptr, int depth, int err_stop, void **arg)
+ *
+ */
+       typedef int (*sync_agent_mo_worker_cb) (sync_agent_dm_mo_node_s * mo_node, int depth, void **arg);
+
+/**
+ * API to Initialize mo plug-in function
+ * @remarks Initialize function for call mo plug-in function
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+  err = sync_agent_initialize_mo(x);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_plugin_id plugin number
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need initialize mo plugin.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_initialize_mo(int mo_plugin_id);
+
+/**
+ * API to Open the sync agent mo db
+ * @remarks This function is use to open sync agent mo db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+  err = sync_agent_open_mo();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to open sync agent mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see _start_dm_init_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_open_mo(void);
+
+/**
+ * API to Close the sync agent mo db
+ * @remarks This function is use to close sync agent mo db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+  err = sync_agent_close_mo();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to close sync agent mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see _start_dm_init_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_close_mo(void);
+
+/**
+ * API to Begin transaction mo db
+ * @remarks This function is use to transaction begin mo db
+ *
+ * @par Usage:
+ * @code
+ *
+  sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+  err = sync_agent_begin_transaction_mo();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to transaction begine mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see update_dmacc( char* pServer_id, dm_acc *dmaccount)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_begin_transaction_mo(void);
+
+/**
+ * API to Begin transaction mo db
+ * @remarks This function is use to transaction begin mo db
+ *
+ * @par Usage:
+ * @code
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err = sync_agent_begin_transaction_mo();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               err = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+               if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       //error handling
+               }
+       } else {
+               err = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+               if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       //error handling
+               }
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] transaction commit, rollback enum
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to transaction end mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see update_dmacc( char* pServer_id, dm_acc *dmaccount)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_end_transaction_mo(sync_agent_dm_mo_transaction_e transaction);
+
+/**
+ * API to Create mo db table by xml ddf
+ * @remarks This function is use to create mo db table by xml ddf
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       ddf_spec ddf_content;
+       ddf_content.mo_type = x;
+       ddf_content.schema_file = "file_url";
+       ddf_content->service_ddf = x;
+       ddf_content->server_type = x;
+
+       err_code = sync_agent_construct_mo_table(ddf_content.mo_type,ddf_content.schema_file , ddf_content.service_ddf, ddf_content.server_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_type mo type in oma dm
+ * @param[in] vendar_file ddf xml file
+ * @param[in] mo_plugin_id mo plugin number
+ * @param[in] server_type mo server type
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to make mo db table by xml ddf
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see _start_ddf_mo(GSList * seg_list)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_construct_mo_table(sync_agent_dm_mo_type_e mo_type, const char *vendar_file, int mo_plugin_id, int server_type);
+
+/**
+ * API to Update mo db table by xml ddf
+ * @remarks This function is use to update mo db table by xml ddf
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       sync_agent_dm_mo_type_e mo_type = x;
+       int mo_plugin_id = x;
+       char *mo_root = "xxx";
+
+       err_code = sync_agent_uptodate_mo_table( mo_type, mo_plugin_id, mo_root);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_type mo type in oma dm
+ * @param[in] mo_plugin_id mo plugin number
+ * @param[in] mo_root mo root node full path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo table by xml ddf
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see reset_dmacc_mscserver()
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_uptodate_mo_table(sync_agent_dm_mo_type_e mo_type, int mo_plugin_id, char *mo_root);
+
+/**
+ * API to delete All mo db table
+ * @remarks This function is use to delete all mo db table
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_delete_all_mo_table(void);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo db talbe
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see clean_dm_mo()
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_delete_all_mo_table(void);
+
+/**
+ * API to get servers info
+ * @remarks This function is use to get servers info
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_server_info_s *server_info = NULL;
+
+       err_code = sync_agent_get_serverinfo(&server_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[out] server_info mo server info struct in oma dm service
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get servers info in mo table
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see get_server_type(char *server_id, int *server_type)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_serverinfo(sync_agent_dm_server_info_s ** server_info);
+
+/**
+ * API to Destroy servers info struct
+ * @remarks This function is use to destroy servers info struct
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_server_info_s *server_info = NULL;
+
+       sync_agent_get_serverinfo(&server_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+       err_code = sync_agent_free_serverinfo(&server_info);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] server_info server_info struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to destroy servers info struct
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see get_server_type(char *server_id, int *server_type)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_free_serverinfo(sync_agent_dm_server_info_s * server_info);
+
+/**
+ * API to Get server id
+ * @remarks This function is use to get server id
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_FUMO;
+       char *server_id = NULL;
+
+       err_code = sync_agent_get_serverid(mo_type, &server_id);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_type mo server type enum
+ * @param[out] server_id mo control server id
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get server id
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see get_Serverid(SERVICE_SERVER_TYPE mo_type, char** server_id)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_serverid(sync_agent_dm_mo_type_e mo_type, char **server_id);
+
+/**
+ * API to Get root path
+ * @remarks This function is use to get root path
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *mo_full_path = "./xxx/xxx;
+       char *root_path = NULL;
+
+       err_code = sync_agent_get_root_path(mo_full_path , &root_path);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_full_path mo full path
+ * @param[out] root_path mo root path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get root path
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see get_mo_root_path(const char *mo_full_path, char **root_path)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_root_path(const char *mo_full_path, char **root_path);
+
+/**
+ * API to Get server type
+ * @remarks This function is use to get server type
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *server_id = "xxx";
+       int server_type = 0;
+
+       err_code = sync_agent_get_server_type(server_id, &server_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] server_id server id
+ * @param[out] server_type server type enum
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get server type
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see get_engine_type_by_serverid(const char* server_id)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_server_type(const char *server_id, int *server_type);
+
+/**
+ * API to Check for exist mo node
+ * @remarks This function is use to check for exist mo node
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *mo_path = "xxxx";
+       int is_exist = 0;
+
+       err_code = sync_agent_is_exist_mo(mo_path, &is_exist);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_path mo node path
+ * @param[out] is_exist exist node flag
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for exsit mo node
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see _receive_get_cmd(Session *session, Command *command)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_is_exist_mo(const char *mo_path, int *is_exist);
+
+/**
+ * API to Get mo type
+ * @remarks This function is use to get mo type
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *mo_full_path = "./xxx/xxx;
+       sync_agent_dm_mo_type_e mo_type = 0;
+
+       err_code = sync_agent_get_mo_type(mo_full_path, &mo_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_full_path mo node path
+ * @param[out] mo_type mo type property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for get mo type
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see  get_service_type(const char *mo_full_path)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_mo_type(const char *mo_full_path, sync_agent_dm_mo_type_e * mo_type);
+
+/**
+ * API to Check mo acl
+ * @remarks This function is use to check mo acl
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       char *mo_full_path = "xxx/xxx";
+       sync_agent_dm_mo_access_type_e access_type = SYNC_AGENT_DM_MO_ACCESSTYPE_GET;
+       char *server_id = NULL;
+       int check_acl = 0;
+
+       err_code = sync_agent_check_acl_value(mo_full_path, access_type, server_id, &check_acl);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_full_path mo node path
+ * @param[in] access_type receive command type by server
+ * @param[in] server_id server id
+ * @param[out] check_acl check acl flag true, false
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for check mo acl
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see  _receive_get_cmd(Session *session, Command *command)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_check_acl_value(const char *mo_full_path, sync_agent_dm_mo_access_type_e access_type, const char *server_id, int *check_acl);
+
+/**
+ * API to Get descendant mo tree
+ * @remarks This function is use to get descendant mo tree
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_type_e type = 0;
+       char *mo_path = "./xx/xx"
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int count = 0;
+       sync_agent_dm_mo_get_option_e option = 0;
+
+       err_code = sync_agent_get_descendant_mo_tree(type, mo_path, &root_node, &count, option);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] type     mo type
+ * @param[in] mo_path mo node path
+ * @param[out] root_node receive root node
+ * @param[out] count node count
+ * @param[in] option get mo option
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for get descendant mo tree
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see  _get_descendant_mo(char *mo_full_path,  sync_agent_dm_mo_node_s **root_node , int *count )
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_get_descendant_mo_tree(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s ** root_node, int *count, sync_agent_dm_mo_get_option_e option);
+
+/**
+ * API to Traverse mo tree
+ * @remarks This function is use to traverse mo tree
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_type_e type = 0;
+       char * mo_full_path = "xxxx";
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       sync_agent_mo_worker_cb func_ptr = xx;
+       int count = 0;
+       int depth = 0;
+       int err_stop = 0;
+       void *arg = NULL;
+
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_type_e mo_type;
+       err_code = sync_agent_get_mo_type(mo_full_path, &mo_type);
+       _DEBUG_TRACE("get mo type result : %d", err_code);
+       _DEBUG_TRACE("mo type : %d", mo_type);
+
+       err_code = sync_agent_get_descendant_mo_tree(mo_type, mo_full_path, &root_node, &count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handle
+       }
+
+       ...
+       if (*count == 0 || root_node == NULL) {
+               //error handle
+       }
+       ...
+
+       err_code = sync_agent_traverse_mo_tree_preorder(root_node, func_ptr, depth, err_stop, &arg );
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] root_ptr node struct
+ * @param[in] func_ptr callback function
+ * @param[in] depth depth count
+ * @param[in] err_stop err stop flag
+ * @param[out] arg arg
+ *
+ * @return 0 on success, -1 on error
+ *
+ * @pre  This function should be called if need check for traverse mo tree
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see  _get_descendant_mo(char *mo_full_path,  sync_agent_dm_mo_node_s **root_node , int *count )
+ *
+ */
+       int sync_agent_traverse_mo_tree_preorder(sync_agent_dm_mo_node_s * root_ptr, sync_agent_mo_worker_cb func_ptr, int depth, int err_stop, void **arg);
+
+/**
+ * API to Export tnds stream
+ * @remarks This function is use to export tnds stream
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+
+       sync_agent_dm_tnds_type_e tnds_type = SYNC_AGENT_DM_MO_TNDS_TYPE_XML;
+       sync_agent_dm_mo_type_e mo_type = 0;
+       char *mo_full_path = "xxx/xxx";
+       char *output_stream = NULL;
+       unsigned int byte_size = 0;
+
+       ...
+
+       err_code = sync_agent_export_tnds_stream(tnds_type, mo_type, mo_root, &output_stream, &byte_size);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] tnds_type tnds type
+ * @param[in] mo_type mo type
+ * @param[in] mo_full_path mo node path
+ * @param[out] output_stream result xml stream
+ * @param[out] byte_size stream size
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for export tnds stream
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see   get_tnds(char* contenttype, char *mo_full_path, char **output_stream, unsigned int *stream_size)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_export_tnds_stream(sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char **output_stream, unsigned int *byte_size);
+
+/**
+ * API to Import tnds stream
+ * @remarks This function is use to import tnds stream
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_tnds_action_e tnds_action = SYNC_AGENT_DM_MO_TNDS_ACTION_REPLACE;
+       sync_agent_dm_tnds_type_e tnds_type = SYNC_AGENT_DM_MO_TNDS_TYPE_XML;
+       sync_agent_dm_mo_type_e mo_type = 0;
+       char *mo_full_path = "xxx/xxx";
+       char *input_stream = "xxxxx";
+       int *byte_size = strlen(input_stream);
+
+       ...
+
+       err_code = sync_agent_import_tnds_stream(tnds_action, tnds_type, mo_type, mo_full_path, input_stream, byte_stream);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] tnds_action tnds action command
+ * @param[in] tnds_type tnds type
+ * @param[in] mo_type mo type
+ * @param[in] mo_full_path mo node path
+ * @param[in] input_stream tnds byte stream
+ * @param[in] byte_size stream size
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for import tnds stream
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see   replace_itemtomo(Item *item)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_import_tnds_stream(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char *input_stream, unsigned int byte_size);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_ACCESSOR_H_ */
diff --git a/include/device-manager/mo_error.h b/include/device-manager/mo_error.h
new file mode 100755 (executable)
index 0000000..1ef4a50
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_ERROR_H_
+#define MO_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+/**
+ * @file       mo_error.h
+ * @brief      Definition of framework error codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * Enumerations of error codes for mo device manager module
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_SUCCESS,               /**< when MO Operation is succeed */
+               SYNC_AGENT_DM_MO_FAIL,                          /**< when MO Operation is failed */
+               SYNC_AGENT_DM_MO_EXIST_NODE,    /**< when Node is already existed */
+               SYNC_AGENT_DM_MO_NOT_EXIST_NODE /**< when Node is not existed */
+       } sync_agent_dm_mo_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_ERROR_H_ */
diff --git a/include/device-manager/mo_executor.h b/include/device-manager/mo_executor.h
new file mode 100755 (executable)
index 0000000..4ae6237
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_EXECUTOR_H_
+#define MO_EXECUTOR_H_
+
+#include "mo_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       mo_executor.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * API to Execute vendor specification function
+ * @remarks Execute vendor specification function
+ *
+ * @par Usage:
+ * @code
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       char *mo_path = "xxxx";
+       int err_num = 0;
+       int check_operation = 0;
+
+  err = sync_agent_execute_mo_ext(mo_path, &err_num, check_operation);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] mo_path mo node path
+ * @param[out] err_num error type
+ * @param[in] check_operation check flag sync or async
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need execute vendor specification function
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see _vendor_dependency_lawmo_operation(char* full_path, LAWMO_Result_code *lawmo_return, int check_operation)
+ *
+ */
+       sync_agent_dm_mo_error_e sync_agent_execute_mo_ext(const char *mo_path, int *err_num, int check_operation);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_EXECUTOR_H_ */
diff --git a/include/device-manager/mo_struct.h b/include/device-manager/mo_struct.h
new file mode 100755 (executable)
index 0000000..5d10a24
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_STRUCT_H_
+#define MO_STRUCT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       mo_struct.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+#define DEVICE_MANAGER_MO_BOOL_TRUE    "T"
+#define DEVICE_MANAGER_MO_BOOL_FALSE   "F"
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_type_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_TYPE_DMACC = 0,        /**< dm acc type*/
+               SYNC_AGENT_DM_MO_TYPE_DEVINFO = 1,      /**< device info type*/
+               SYNC_AGENT_DM_MO_TYPE_DEVDETAIL = 2,
+                                               /**< device detail type*/
+               SYNC_AGENT_DM_MO_TYPE_FUMO = 4,         /**< fumo type*/
+               SYNC_AGENT_DM_MO_TYPE_LAWMO = 8,        /**< lawmo type*/
+               SYNC_AGENT_DM_MO_TYPE_SCOMO = 16,       /**< scomo type*/
+               SYNC_AGENT_DM_MO_TYPE_NO_TYPE = 32      /**< mo no type*/
+       } sync_agent_dm_mo_type_e;
+
+#define DEVICE_MANAGER_MO_ACCESSTYPE_CNT  6
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_access_type_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET = 0,
+                                               /**< accesstype no */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_ADD = 1,    /**< accesstype add */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_COPY = 2,   /**< accesstype copy */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE = 4,
+                                               /**< accesstype delete */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC = 8,   /**< accesstype exec */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_GET = 16,   /**< accesstype get */
+               SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE = 32/**< accesstype replace */
+       } sync_agent_dm_mo_access_type_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_format_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_FORMAT_NO_SET = 0,
+                                               /**< format no */
+               SYNC_AGENT_DM_MO_FORMAT_B64,            /**< format b64 */
+               SYNC_AGENT_DM_MO_FORMAT_BIN,            /**< format bin */
+               SYNC_AGENT_DM_MO_FORMAT_BOOL,           /**< format bool */
+               SYNC_AGENT_DM_MO_FORMAT_CHR,            /**< format chr */
+               SYNC_AGENT_DM_MO_FORMAT_INT,            /**< format int */
+               SYNC_AGENT_DM_MO_FORMAT_NODE,           /**< format node */
+               SYNC_AGENT_DM_MO_FORMAT_NULL,           /**< format null */
+               SYNC_AGENT_DM_MO_FORMAT_XML,            /**< format xml */
+               SYNC_AGENT_DM_MO_FORMAT_DATE,           /**< format date */
+               SYNC_AGENT_DM_MO_FORMAT_TIME,           /**< format time */
+               SYNC_AGENT_DM_MO_FORMAT_FLOAT           /**< format float */
+       } sync_agent_dm_mo_format_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_occurrence_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_OCCURRENCE_NO_SET = 0,
+                                               /**< occurence no */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ONE,                /**< occurence one */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORONE,  /**< occurence zero or one */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORMORE,
+                                               /**< occurence zero or more */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ONEORMORE,  /**< occurence one or more */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORN,    /**< occurence zero or n */
+               SYNC_AGENT_DM_MO_OCCURRENCE_ONEORN              /**< occurence one or n */
+       } sync_agent_dm_mo_occurrence_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_scope_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_SCOPE_NO_SET = 0,
+                                               /**< scope no */
+               SYNC_AGENT_DM_MO_SCOPE_PERMANENT,
+                                               /**< scope premanent */
+               SYNC_AGENT_DM_MO_SCOPE_DYNAMIC  /**< scope dynamic */
+       } sync_agent_dm_mo_scope_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_df_type_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_DF_TYPE_NO_SET = 0,
+                                               /**< df type no */
+               SYNC_AGENT_DM_MO_DF_TYPE_MIME,          /**< df type mime */
+               SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME        /**< df type ddfname */
+       } sync_agent_dm_mo_df_type_e;
+
+/**
+ * @brief      structure of sync_agent_dm_mo_framework_property_s
+ */
+       typedef struct {
+               sync_agent_dm_mo_access_type_e accessType;      /**< accesstype enum */
+               char *defaultValue;                                                             /**< default value */
+               char *description;                                                              /**< description */
+               sync_agent_dm_mo_format_e dffFormat;                    /**< ddf format enum */
+               sync_agent_dm_mo_occurrence_e occurrence;               /**< occurrence enum */
+               int occurrence_num;                                                             /**< occurrence number */
+               sync_agent_dm_mo_scope_e scope;                                 /**< scope enum */
+               char *dfTitle;                                                                  /**< df title */
+               sync_agent_dm_mo_df_type_e dfType;                              /**< df type enum */
+               char *dfType_Value;                                                             /**< df type value */
+       } sync_agent_dm_mo_framework_property_s;
+
+/**
+ * @brief      structure of sync_agent_dm_mo_runtime_property_s
+ */
+       typedef struct {
+               char *acl;                                                                              /**< acl value */
+               sync_agent_dm_mo_format_e format;                       /**< format enum */
+               char *name;                                                                     /**< name */
+               char *size;                                                                     /**< size */
+               char *title;                                                                    /**< title */
+               char *tStamp;                                                                   /**< time stamp */
+               sync_agent_dm_mo_df_type_e type;                        /**< df type */
+               char *type_value;                                                               /**< type value */
+               char *verNo;                                                                    /**< version number */
+       } sync_agent_dm_mo_runtime_property_s;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_node_type_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_NODE_ROOT = 1,                         /**< root node type */
+               SYNC_AGENT_DM_MO_NODE_FIRST,                            /**< first node type */
+               SYNC_AGENT_DM_MO_NODE_INTERIOR,                         /**< interior node type */
+               SYNC_AGENT_DM_MO_NODE_LEAF                                      /**< leaf node type */
+       } sync_agent_dm_mo_node_type_e;
+
+/**
+ * @brief      structure of sync_agent_dm_mo_node_s
+ */
+       typedef struct sync_agent_dm_mo_node_s {
+               int id;                                                                                                         /**< id in db */
+               int parent_id;                                                                                          /**< parent id in db*/
+               char *name;                                                                                                     /**< name */
+               char *value;                                                                                                    /**< value */
+               char *full_path;                                                                                                /**< mo node path */
+               sync_agent_dm_mo_node_type_e type;                                                      /**< node type */
+               sync_agent_dm_mo_type_e mo_type;                                                        /**< mo type */
+               int server_type;                                                                                                /**< server type */
+               sync_agent_dm_mo_framework_property_s *framework_property;
+                                                                       /**< framework property */
+               sync_agent_dm_mo_runtime_property_s *runtime_property;  /**< runtime property */
+               struct sync_agent_dm_mo_node_s *child_node_list;                        /**< child node list */
+               struct sync_agent_dm_mo_node_s *next_node;                              /**< next node */
+               struct sync_agent_dm_mo_node_s *parent_node;                            /**< parent node */
+               int child_node_cnt;                                                                                     /**< child node count */
+       } sync_agent_dm_mo_node_s;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_get_option_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_GET_OPTION_ALL = 0,            /**< get type all */
+               SYNC_AGENT_DM_MO_GET_OPTION_NODE                        /**< get type node value */
+       } sync_agent_dm_mo_get_option_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_mo_transaction_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_TRANSACTION_COMMIT = 0,/**< db transaction commit */
+               SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK   /**< db transaction rollback */
+       } sync_agent_dm_mo_transaction_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_tnds_type_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_TNDS_TYPE_XML = 0,             /**< tnds xml type */
+               SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML                        /**< tnds wbxml type */
+       } sync_agent_dm_tnds_type_e;
+
+/**
+ * @brief      Enumerations of sync_agent_dm_tnds_action_e
+ */
+       typedef enum {
+               SYNC_AGENT_DM_MO_TNDS_ACTION_ADD = 0,           /**< tnds add action */
+               SYNC_AGENT_DM_MO_TNDS_ACTION_REPLACE            /**< tnds replace action */
+       } sync_agent_dm_tnds_action_e;
+
+/**
+ * @brief      structure of sync_agent_dm_acc_info_s
+ */
+       typedef struct {
+               char *auth_name;                                                                /**< auth name */
+               char *auth_secret;                                                      /**< auth secret */
+               char *auth_data;                                                                /**< auth data(nonce) */
+               char *auth_type;                                                                /**< auth type */
+               char *auth_level;                                                               /**< auth level */
+               char *addr;                                                                     /**< server url */
+       } sync_agent_dm_acc_info_s;
+
+/**
+ * @brief      structure of sync_agent_dm_acc_type_e
+ */
+       typedef enum {
+               DEVICE_MANAGE_ACC_TYPE_SERVER,                          /**< dm acc server type */
+               DEVICE_MANAGE_ACC_TYPE_CLIENT                           /**< dm acc client type */
+       } sync_agent_dm_acc_type_e;
+
+/**
+ * @brief      structure of sync_agent_dm_server_info_s
+ */
+       typedef struct sync_agent_dm_server_info_s {
+               char *server_id;                                                                /**< server id */
+               int server_type;                                                                /**< server type */
+               struct sync_agent_dm_server_info_s *next;       /**< sync_agent_dm_server_info_s struct */
+       } sync_agent_dm_server_info_s;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_STRUCT_H_ */
diff --git a/include/device/common.h b/include/device/common.h
new file mode 100755 (executable)
index 0000000..b159bdb
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_COMMON_H_
+#define DEVICE_COMMON_H_
+
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file common.h
+ * @brief Defines enumerations for device execution
+ */
+
+/** @addtogroup device
+ *     @{
+ */
+
+/**
+ * @brief Get particular device information on the memory
+ * @param[in] device_plugin_id Device plugIn ID
+ * @param[in] info_name Name of device information
+ * @param[out] value Value of device information
+ * @return Calculated ID in unsigned integer type
+ */
+       typedef sync_agent_dev_return_e(*sync_agent_get_devinfo_cb) (int devinfo_plugin_id, char *info_name, char **value);
+
+/**
+ * @brief Execute particular device feature
+ * @param[in] device_plugin_id Device PlugIn ID
+ * @param[in] function_name Function name defined in plug-in
+ * @param[in] args_cnt Number of following arguments which abbreviated
+ * @return Calculated ID in unsigned integer type
+ */
+       typedef sync_agent_dev_return_e(*sync_agent_execute_dev_cb) (int devinfo_plugin_id, char *function_name, int args_cnt, ...);
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_COMMON_H_ */
diff --git a/include/device/device.h b/include/device/device.h
new file mode 100755 (executable)
index 0000000..54c5ad8
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common.h"
+#include "executor.h"
+#include "information.h"
+#include "error.h"
diff --git a/include/device/error.h b/include/device/error.h
new file mode 100755 (executable)
index 0000000..f41abb4
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_ERROR_H_
+#define DEVICE_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file error.h
+ * @brief Defines DCI errors
+ */
+
+/** @addtogroup device
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for the DCI errors
+ */
+       typedef enum {
+               SYNC_AGENT_DEV_RETURN_SUCCESS = 1,              /**< Success */
+               SYNC_AGENT_DEV_RETURN_FAIL = -1,                /**< Fail */
+
+               SYNC_AGENT_DEV_RETURN_NOT_EXIST_DEVINFO = -2,   /**< Device information is not exist */
+               SYNC_AGENT_DEV_RETURN_DEVINFO_VALUE_IS_NULL = -3,
+                                                               /**< Device information value is NULL */
+       } sync_agent_dev_return_e;
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_ERROR_H_ */
diff --git a/include/device/executor.h b/include/device/executor.h
new file mode 100755 (executable)
index 0000000..c585a1d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXECUTOR_H_
+#define EXECUTOR_H_
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file executor.h
+ * @brief Defines device execution APIs
+ */
+
+/** @addtogroup device
+ *     @{
+ */
+
+/**
+ * @brief Executes device function under specific name defined in plug-in
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+ *
+ * res = sync_agent_execute_dev_function(2, "reboot", 0);
+ * if (res != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] device_plugin_id Device PlugIn ID
+ * @param[in] function_name Function name defined in plug-in
+ * @param[in] args_cnt Number of following arguments which abbreviated
+ * @param[in] ... Arguments which will be handed over plug-in specific for each function
+ * @return Operation result
+ * @retval SYNC_AGENT_DEV_RETURN_SUCCESS Successful
+ * @retval error_value Operation failed
+ *
+ */
+       sync_agent_dev_return_e sync_agent_execute_dev_function(int device_plugin_id, char *function_name, int args_cnt, ...);
+
+/* TODO */
+/*
+sync_agent_dev_return_e DCI_Execute_Dev_App_Install(const char *platform, char *file_name, char *application_id);
+sync_agent_dev_return_e DCI_Execute_Dev_App_UnInstall(const char *platform, char *application_id);
+sync_agent_dev_return_e DCI_Execute_Dev_App_Activate(const char *platform, char *application_id, int activate_status);
+*/
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* EXECUTOR_H_ */
diff --git a/include/device/information.h b/include/device/information.h
new file mode 100755 (executable)
index 0000000..31311c1
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_INFORMATION_H_
+#define DEVICE_INFORMATION_H_
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file information.h
+ * @brief Defines device information APIs
+ */
+
+/** @addtogroup device
+ *     @{
+ */
+
+/**
+ * @brief Get particular device information on the memory
+ * @remarks DevID(device id), Man(manufacture), Mod(model id or model number), SwV(software version),
+ * HwV(hardware version), FwV(firmware version), OEM(original equipment manufacturer),
+ * DevTyp(device type), Lang(language), DTDV(DTD version), PDAV(PDA version),
+ *     CSCV(CSC version), ModemV(modem version), KernelV(kernal version), OPCO(OPCO information)
+ * @par Useage:
+ * @code
+ *
+ * char *value;
+ * sync_agent_dev_return_e res = DICI_Get_DevInfo(1, "DevID", &value);
+ *
+ * @endcode
+ * @param[in] device_plugin_id Device plugIn ID
+ * @param[in] info_name Name of device information (see remarks)
+ * @param[out] value Value of device information
+ * @return Operation result
+ * @retval SYNC_AGENT_DEV_RETURN_SUCCESS Successful
+ * @retval error_value Operation failed
+ * @pre The application should be called dev_init_dev()
+ */
+       sync_agent_dev_return_e sync_agent_get_devinfo(int device_plugin_id, char *info_name, char **value);
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_INFORMATION_H_ */
diff --git a/include/engine-controller/define.h b/include/engine-controller/define.h
new file mode 100755 (executable)
index 0000000..93027be
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEFINE_H_
+#define DEFINE_H_
+
+#include "fundamental_type.h"
+#include "task_error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file define.h
+ * @brief Provides definitaion of result enum and data type enum
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Enumeration for type of value used in Engine Controller
+ */
+       typedef enum {
+               SYNC_AGENT_EC_VALUE_TYPE_UNKNOWN = 0,
+                                               /**< unknown type */
+               SYNC_AGENT_EC_VALUE_TYPE_BOOLEAN,       /**< boolean type */
+               SYNC_AGENT_EC_VALUE_TYPE_CHAR,          /**< char type */
+               SYNC_AGENT_EC_VALUE_TYPE_UCHAR,         /**< unsigned char type */
+               SYNC_AGENT_EC_VALUE_TYPE_INT,           /**< integer type */
+               SYNC_AGENT_EC_VALUE_TYPE_UINT,          /**< unsigned integer type */
+               SYNC_AGENT_EC_VALUE_TYPE_FLOAT,         /**< float type */
+               SYNC_AGENT_EC_VALUE_TYPE_DOUBLE,        /**< double type */
+               SYNC_AGENT_EC_VALUE_TYPE_STRUCT         /**< structure type */
+       } sync_agent_ec_value_type_e;
+
+/**
+ * @brief Callback function which calculates ID
+ * @param[in] data Data to use for calculation
+ * @return Calculated ID in unsigned integer type
+ */
+       typedef sync_agent_ec_uint(*sync_agent_calculate_identifier_cb) (sync_agent_ec_pointer data);
+
+/**
+ * @brief Enumeration for type of error used in Engine Controller
+ */
+       typedef enum {
+               SYNC_AGENT_EC_OK = 0,                                                                   /**< OK, no error */
+               SYNC_AGENT_EC_UNKNOWN_ERROR,                                            /**< Unknown error */
+
+               SYNC_AGENT_EC_INVALID_PARAMETER,                                        /**< When invalid parameters are used */
+
+               SYNC_AGENT_EC_OUT_OF_MEMORY,                                            /**< When system gets out of memory */
+               SYNC_AGENT_EC_TASK_PARAMETERS_NOT_CONNECTABLE,  /**< When function parameters are not match each other so not connectable */
+               SYNC_AGENT_EC_INVALID_TASK,                                                     /**< When invalid task requested  */
+
+               SYNC_AGENT_EC_INVALID_CHILD_TASK_INDEX,                 /**< When child task's index is wrong */
+               SYNC_AGENT_EC_INVALID_PARAM_INDEX = 5,                          /**< When parameter index is wrong*/
+
+               SYNC_AGENT_EC_MUST_USE_CONTAINER_TASK,                  /**< When 'simple' or 'dynamic container' task is used instead of 'dynamic' task */
+               SYNC_AGENT_EC_MUST_USE_DYNAMIC_CONTAINER_TASK,  /**< When 'simple' or 'container' task is used instead of dynamic container task */
+
+               SYNC_AGENT_EC_CANNOT_FIND_FROM_TASK,                            /**< When fail to get parameter from task */
+               SYNC_AGENT_EC_CANNOT_FIND_TO_TASK,                              /**< When fail to set parameter to task */
+               SYNC_AGENT_EC_CANNOT_FIND_FROM_PARAM = 10,              /**< When fail to get value from parameter */
+               SYNC_AGENT_EC_CANNOT_FIND_TO_PARAM,                             /**< When fail to set parameter to parameter */
+
+               SYNC_AGENT_EC_INVALID_CHILD_PATH,                                       /**< When queuing rule related child has wrong path */
+               SYNC_AGENT_EC_DUPLICATE_CHILD_PATH,                             /**< When queuing rule related child has duplicated path */
+
+               SYNC_AGENT_EC_OUT_OF_FREE_ID,                                           /**< When there is no free ID to issue */
+
+               SYNC_AGENT_EC_DUPLICATE_QUEUING_RULE_SPEC = 15, /**< When trying to register same queuing rule spec */
+
+               SYNC_AGENT_EC_DUPLICATE_PROGRESS_BLOCKING_ENTITY,
+                                                               /**< When trying to registe same blocking entitiy in a queuing rule spec */
+
+               SYNC_AGENT_EC_DUPLICATE_DATA_FLOW_EDGE                  /**< When trying to set same data flow edge */
+       } sync_agent_ec_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEFINE_H_ */
diff --git a/include/engine-controller/engine_controller.h b/include/engine-controller/engine_controller.h
new file mode 100755 (executable)
index 0000000..36f8d51
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "define.h"
+#include "fundamental_type.h"
+#include "interface.h"
+#include "param_spec.h"
+#include "param_value.h"
+#include "param.h"
+#include "queuing_rule_spec.h"
+#include "task_error.h"
+#include "task_process.h"
+#include "task_spec.h"
diff --git a/include/engine-controller/fundamental_type.h b/include/engine-controller/fundamental_type.h
new file mode 100755 (executable)
index 0000000..f276b91
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FUNDAMENTAL_TYPE_H_
+#define FUNDAMENTAL_TYPE_H_
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fundamental_type.h
+ * @brief Provides data type definition internally used in Engine Controller
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Definition of internal char type used in Engine Controller
+ */
+       typedef char sync_agent_ec_char;
+
+/**
+ * @brief Definition of internal short type used in Engine Controller
+ */
+       typedef short sync_agent_ec_short;
+
+/**
+ * @brief Definition of internal long type used in Engine Controller
+ */
+       typedef long sync_agent_ec_long;
+
+/**
+ * @brief Definition of internal int type used in Engine Controller
+ */
+       typedef int sync_agent_ec_int;
+
+/**
+ * @brief Definition of internal boolean type used in Engine Controller
+ */
+       typedef sync_agent_ec_int sync_agent_ec_boolean;
+
+/**
+ * @brief Definition of internal unsigned char type used in Engine Controller
+ */
+       typedef unsigned char sync_agent_ec_uchar;
+
+/**
+ * @brief Definition of internal unsigned short type used in Engine Controller
+ */
+       typedef unsigned short sync_agent_ec_ushort;
+
+/**
+ * @brief Definition of internal unsigned long type used in Engine Controller
+ */
+       typedef unsigned long sync_agent_ec_ulong;
+
+/**
+ * @brief Definition of internal unsigned int type used in Engine Controller
+ */
+       typedef unsigned int sync_agent_ec_uint;
+
+/**
+ * @brief Definition of internal float type used in Engine Controller
+ */
+       typedef float sync_agent_ec_float;
+
+/**
+ * @brief Definition of internal double type used in Engine Controller
+ */
+       typedef double sync_agent_ec_double;
+
+/**
+ * @brief Definition of internal void pointer type used in Engine Controller
+ */
+       typedef void *sync_agent_ec_pointer;
+
+/**
+ * @brief Definition of internal const void pointer type used in Engine Controller
+ */
+       typedef const void *sync_agent_ec_constpointer;
+
+/**
+ * @brief Definition of internal int8 type used in Engine Controller
+ */
+       typedef signed char sync_agent_ec_int8;
+
+/**
+ * @brief Definition of internal unsigned int8 type used in Engine Controller
+ */
+       typedef unsigned char sync_agent_ec_uint8;
+
+/**
+ * @brief Definition of internal int16 type used in Engine Controller
+ */
+       typedef signed short sync_agent_ec_int16;
+
+/**
+ * @brief Definition of internal unsigned int16 type used in Engine Controller
+ */
+       typedef unsigned short sync_agent_ec_uint16;
+
+/**
+ * @brief Definition of internal int32 type used in Engine Controller
+ */
+       typedef signed int sync_agent_ec_int32;
+
+/**
+ * @brief Definition of internal unsigned int32 type used in Engine Controller
+ */
+       typedef unsigned int sync_agent_ec_uint32;
+
+/**
+ * @brief Definition of internal int64 type used in Engine Controller
+ */
+       typedef signed long long sync_agent_ec_int64;
+
+/**
+ * @brief Definition of internal unsigned int64 type used in Engine Controller
+ */
+       typedef unsigned long long sync_agent_ec_uint64;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FUNDAMENTAL_TYPE_H_ */
diff --git a/include/engine-controller/interface.h b/include/engine-controller/interface.h
new file mode 100755 (executable)
index 0000000..95438cc
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENGINE_CONTROLLER_INTERFACE_H_
+#define ENGINE_CONTROLLER_INTERFACE_H_
+
+#include "define.h"
+#include "task_spec.h"
+#include "queuing_rule_spec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface.h
+ * @brief Provides APIs to support task registration and request
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Callback function which is called when task is finsihed
+ * @param[in] task_error Result of the watching task
+ * @param[in] out_param_cnt Count of out parameter of the watching task
+ * @param[in] out_param_array Array of parameter values of the watching task
+ * @param[in] usr_data User defined data
+ */
+       typedef void (*sync_agent_task_finish_cb) (sync_agent_ec_task_error_e task_error, sync_agent_ec_uint out_param_cnt, sync_agent_ec_param_param_s ** out_param_array, sync_agent_ec_pointer usr_data);
+
+/**
+ * @brief Callback function which is called when queuing rule spec registration done
+ * @param[in] ec_error Result of the registration
+ * @param[in] registered_id ID of the registered queuing rule spec
+ * @param[in] usr_data User defined data
+ */
+       typedef void (*sync_agent_register_finish_cb) (sync_agent_ec_error_e ec_error, sync_agent_ec_uint registered_id, sync_agent_ec_pointer usr_data);
+
+/* external interfaces */
+
+/**
+ * @brief Registers user created task spec
+ * @par Usage:
+ * @code
+ sync_agent_ec_task_spec_s *make_synchronize_task()
+ {
+        sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+        sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,  true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("sanPackage", NULL, sanPackageParserFree, true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *param_spec_array[3] = {pParam_spec1, pParam_spec2, pParam_spec3};
+        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize", synchronize_task_process, NULL, NULL, 3, param_spec_array);
+        sync_agent_unref_param_spec(pParam_spec1);
+        sync_agent_unref_param_spec(pParam_spec2);
+        sync_agent_unref_param_spec(pParam_spec3);
+        return pTask_spec;
+ }
+
+ sync_operation()
+ {
+        sync_agent_ec_task_spec_s *pSyncTaskSpec = make_synchronize_task();
+        sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST, EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST, pSyncTaskSpec, NULL);
+
+        ...
+ }
+ * @endcode
+ * @param[in] task_spec_id User defined task spec ID
+ * @param[in] task_spec_name User defined task spec ID
+ * @param[in] task_spec User created task spec in task_stpec_t type
+ * @param[in] cal_func ID calculation func
+ */
+       void sync_agent_register_task_spec(sync_agent_ec_uint task_spec_id, sync_agent_ec_char * task_spec_name, sync_agent_ec_task_spec_s * task_spec, sync_agent_calculate_identifier_cb cal_func);
+
+/**
+ * @brief Registers user created asychronousqueuing rule spec
+ * @par Usage:
+ * @code
+ sync_agent_ec_task_spec_s *make_synchronize_task()
+ {
+        sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+        sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,  true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("sanPackage", NULL, sanPackageParserFree, true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *param_spec_array[3] = {pParam_spec1, pParam_spec2, pParam_spec3};
+        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize", synchronize_task_process, NULL, NULL, 3, param_spec_array);
+        sync_agent_unref_param_spec(pParam_spec1);
+        sync_agent_unref_param_spec(pParam_spec2);
+        sync_agent_unref_param_spec(pParam_spec3);
+        return pTask_spec;
+ }
+ sync_operation()
+ {
+        sync_agent_ec_task_spec_s *pSyncTaskSpec = make_synchronize_task();
+        sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST, EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST, pSyncTaskSpec, NULL);
+
+        sync_agent_ec_queuing_rule_spec_s *pQueuing_rule = sync_agent_create_queuing_rule_spec_outline("sync_queueing_rule");
+        
+        sync_agent_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, pSyncTaskSpec, 0);
+        sync_agent_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_REQUEST, pSyncTaskSpec, 0);
+        sync_agent_add_progress_blocking_element(pQueuing_rule, EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, pSyncTaskSpec, 0);
+        
+        sync_agent_register_async_queuing_rule_spec(pQueuing_rule, NULL, NULL);
+
+        ...
+ }
+ * @endcode
+ * @param[in] spec User created queuing rule spec to register
+ * @param[in] finish_callback Callback function to be called on registration done
+ * @param[in] usr_data User data to pass to the callback function
+ */
+       void sync_agent_register_async_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_register_finish_cb finish_callback, sync_agent_ec_pointer usr_data);
+
+/**
+ * @brief Requests task asynchronously, using task spec/param info and etc
+ * @par Usage:
+ * @code
+ static void _request_manual_sync_task_finish_callback(sync_agent_ec_task_error_e task_error, unsigned int out_param_cnt, sync_agent_ec_param_param_s **out_param_spec_array, void *usr_data)
+ {
+       ...
+ }
+
+ sync_agent_ec_task_spec_s *make_synchronize_task()
+ {
+        sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+        sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,  true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("sanPackage", NULL, sanPackageParserFree, true, false, false, NULL, false, NULL, false, NULL);
+        sync_agent_ec_param_spec_s *param_spec_array[3] = {pParam_spec1, pParam_spec2, pParam_spec3};
+        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize", synchronize_task_process, NULL, NULL, 3, param_spec_array);
+        sync_agent_unref_param_spec(pParam_spec1);
+        sync_agent_unref_param_spec(pParam_spec2);
+        sync_agent_unref_param_spec(pParam_spec3);
+        return pTask_spec;
+ }
+ sync_operation()
+ {
+        sync_agent_ec_task_spec_s *pSyncTaskSpec = make_synchronize_task();
+        sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST, EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST, pSyncTaskSpec, NULL);
+
+        ...
+
+        int account_id =  get_account_id(profile, false);
+        char *sync_mode = strdup(DEFINE_SYNC_MODE_MANUAL);
+        
+        void *in_param_value_array[3] = {&account_id, &sync_mode, NULL};
+        int in_param_index_array[3] = {0, 1, 2};
+        sync_agent_ec_value_type_e in_param_value_type_array[3] = {SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT};
+        
+        unsigned int request_msg_id = 0;
+        sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REQUEST, 0, 3, in_param_index_array, in_param_value_type_array, in_param_value_array, _request_manual_sync_task_finish_callback, NULL, (int *)&request_msg_id);
+
+        ...
+ }
+ * @endcode
+ * @param[in] task_spec_id User defined task spec ID
+ * @param[in] identifier User defined task identifier
+ * @param[in] cnt_in_param Count of input parameters
+ * @param[in] in_param_index_array Array containing param index
+ * @param[in] in_param_value_type_array Array containing param value type
+ * @param[in] in_param_value_array Array containing param value
+ * @param[in] task_finish_callback Task finish callback
+ * @param[in] simple_task_finish_callback_usr_data User data passed to finish callback
+ * @param[out] request_id Task request ID which Engine Controller issues
+ */
+       void sync_agent_request_async_task(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                          sync_agent_ec_pointer * in_param_value_array, sync_agent_task_finish_cb task_finish_callback, sync_agent_ec_pointer simple_task_finish_callback_usr_data, sync_agent_ec_int * request_id);
+
+/**
+ * @brief Requests task synchronously, using task spec/param info and etc
+ * @par Usage:
+ * @code
+ sync_agent_ec_task_spec_s *make_reset_all_data_task()
+ {
+        _EXTERN_FUNC_ENTER;
+        sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+        sync_agent_ec_param_spec_s *param_spec_array[1] = {pParam_spec1};
+        sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_all_data",
+                                                                                        reset_all_data_task_process, NULL, NULL,
+                                                                                        1, param_spec_array);
+        sync_agent_unref_param_spec(pParam_spec1);
+        _EXTERN_FUNC_EXIT;
+        return pTask_spec;
+ }
+ reset_operation()
+ {
+        sync_agent_ec_task_spec_s *pResetAllDataTaskSpec = make_reset_all_data_task();
+        sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, EC_MSG_TYPE_NAME_SYNC_TASK_RESET_ALL_DATA, pResetAllDataTaskSpec, NULL);
+
+        ...
+
+        unsigned int request_msg_id = 0;
+        sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+        
+        unsigned int out_param_count;
+        sync_agent_ec_param_param_s **param_array = NULL;
+        
+        sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+        ...
+ }
+ * @endcode
+ * @param[in] task_spec_id User defined task spec ID
+ * @param[in] identifier User defined task identifier
+ * @param[in] cnt_in_param Count of input parameters
+ * @param[in] in_param_index_array Array containing param index
+ * @param[in] in_param_value_type_array Array containing param value type
+ * @param[in] in_param_value_array Array containing param value
+ * @param[out] request_id Task request ID which Engine Controller issues
+ * @param[out] task_error Result of the task
+ * @param[out] out_param_cnt Count of output parameter of the task
+ * @param[out] out_param_array param_t type of array containing output parameter of the task
+ */
+       void sync_agent_request_sync_task(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                         sync_agent_ec_pointer * in_param_value_array, sync_agent_ec_int * request_id, sync_agent_ec_task_error_e * task_error, sync_agent_ec_uint * out_param_cnt, sync_agent_ec_param_param_s *** out_param_array);
+
+/**
+ * @brief Cancel task which has given request ID
+ * @par Usage:
+ * @code
+ ...
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ ...
+ sync_agent_cancel_task(request_msg_id_to_cancel);
+ * @endcode
+ * @param[in] request_id_to_cancel request ID of task to cancel
+ */
+       void sync_agent_cancel_task(sync_agent_ec_int request_id_to_cancel);
+
+/**
+ * @brief Cancels all running task
+ * @par Usage:
+ * @code
+ ...
+ sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REQUEST, 0, 3, in_param_index_array, in_param_value_type_array, in_param_value_array, _request_manual_sync_task_finish_callback, NULL, (int *)&request_msg_id);
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ ...
+ sync_agent_cancel_all_tasks();
+ * @endcode
+ */
+       void sync_agent_cancel_all_tasks(void);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ENGINE_CONTROLLER_INTERFACE_H_ */
diff --git a/include/engine-controller/param.h b/include/engine-controller/param.h
new file mode 100755 (executable)
index 0000000..982830a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_H_
+#define PARAM_H_
+
+#include "param_value.h"
+#include "param_spec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file param.h
+ * @brief Provides param structure
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for parameter which contains parameter information such as spec and value
+ */
+       typedef struct engine_controller_param sync_agent_ec_param_param_s;
+/**
+ * @brief Structure for parameter which contains parameter information such as spec and value
+ */
+       struct engine_controller_param {
+               sync_agent_ec_uint read_ref_count;      /**< Reference count for read */
+               sync_agent_ec_uint write_ref_count;     /**< Reference count for write */
+               sync_agent_ec_param_spec_s *pParam_spec;        /**< Parameter spec */
+               sync_agent_ec_param_value_u param_value;        /**< Parameter value */
+       };
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PARAM_H_ */
diff --git a/include/engine-controller/param_spec.h b/include/engine-controller/param_spec.h
new file mode 100755 (executable)
index 0000000..a390add
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_SPEC_H_
+#define PARAM_SPEC_H_
+
+#include "fundamental_type.h"
+#include "define.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file param_spec.h
+ * @brief Provides parameter spec creation for various data type
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Callback function which copies parameter data in structure type
+ * @param[in] pStruct Parameter data in structure type to copy from
+ * @return Pointer of newly copied structure�
+ */
+       typedef sync_agent_ec_pointer(*sync_agent_copy_struct_cb) (sync_agent_ec_pointer pStruct);
+
+/**
+ * @brief Callback function which frees parameter data in structure type
+ * @param[in] pStruct Parameter data in structure type to free
+ */
+       typedef void (*sync_agent_free_struct_cb) (sync_agent_ec_pointer pStruct);
+
+/**
+ * @brief Callback function which validates parameter data in structure type
+ * @param[in] pStruct Parameter data in structure type to validate
+ * @return 1 on validation success case, otherwise 0
+ */
+       typedef sync_agent_ec_boolean(*sync_agent_validate_struct_cb) (sync_agent_ec_pointer pStruct, sync_agent_ec_pointer usr_data);
+
+/**
+ * @brief Enumerations of flag which indicates sort of parameter
+ */
+       typedef enum {
+               SYNC_AGENT_EC_PARAM_FLAG_DEFAULT = 0,                           /**< Default type */
+               SYNC_AGENT_EC_PARAM_FLAG_INPUT = 1,                                     /**< Input type */
+               SYNC_AGENT_EC_PARAM_FLAG_OUTPUT = 2,                            /**< Output type */
+               SYNC_AGENT_EC_PARAM_FLAG_INPUT_VALIDATE_ON = 4, /**< Input-validate type */
+               SYNC_AGENT_EC_PARAM_FLAG_OUTPUT_VALIDATE_ON = 8,        /**< Output-validate type */
+               SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON = 16
+                                                               /**< Intput-default-value type */
+       } sync_agent_ec_param_flags_e;
+
+/**
+ * @brief Structure of parameter spec which contains function parameter spec
+ */
+       typedef struct sync_agent_ec_param_param_spec sync_agent_ec_param_spec_s;
+
+/**
+ * @brief Decreases reference count of parameter spec
+ * @par Usage:
+ * @code
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free, true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *param_spec_array[2] = {pParam_spec1, pParam_spec2};
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize", synchronize_task_process, NULL, NULL, 2, param_spec_array);
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ * @endcode
+ * @param[in] param_spec Pointer of parameter spec to decrease ref count
+ */
+       void sync_agent_unref_param_spec(sync_agent_ec_param_spec_s * param_spec);
+
+/**
+ * @brief Allocs and returns int type of parameter spec
+ * @par Usage:
+ * @code
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
+ * @endcode
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+       sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_int(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_int input_minimum,
+                                                                   sync_agent_ec_int input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_int input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_int output_minimum,
+                                                                   sync_agent_ec_int output_maximum);
+
+/**
+ * @brief Allocs and returns structure(Pointer) type of parameter spec
+ * @par Usage:
+ * @code
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free, true, false, false, NULL, false, NULL, false, NULL);
+ * @endcode
+ * @param[in] name Name of parameter which user defined
+ * @param[in] copy_func Function which can make copy of this structure type of parameter
+ * @param[in] free_func Function which can free this structure type of parameter
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] in_val_func Function which can validate this structure type of input parameter
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] default_struct Default value of this structure type of parameter
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] out_val_func which can validate this structure type of output parameter
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+       sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_structure(const sync_agent_ec_char * name, sync_agent_copy_struct_cb copy_func, sync_agent_free_struct_cb free_func, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output,
+                                                                         sync_agent_ec_boolean input_validate_on, sync_agent_validate_struct_cb in_val_func, sync_agent_ec_boolean input_default_on, sync_agent_ec_pointer default_struct,
+                                                                         sync_agent_ec_boolean output_validate_on, sync_agent_validate_struct_cb out_val_func);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PARAM_SPEC_H_ */
diff --git a/include/engine-controller/param_value.h b/include/engine-controller/param_value.h
new file mode 100755 (executable)
index 0000000..e38c442
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_VALUE_H_
+#define PARAM_VALUE_H_
+
+#include "fundamental_type.h"
+#include "define.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file param_value.h
+ * @brief Provides set/get operation of parameter value
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Union for parameter value corresponding to various data type
+ */
+       typedef union {
+               sync_agent_ec_boolean boolean_value;
+                                               /**< boolean type */
+               sync_agent_ec_char char_value;          /**< char type */
+               sync_agent_ec_uchar uchar_value;                        /**< unsigned char type */
+               sync_agent_ec_int int_value;            /**< int type */
+               sync_agent_ec_uint uint_value;          /**< unsigned int type */
+               sync_agent_ec_float float_value;                        /**< float type */
+               sync_agent_ec_double double_value;      /**< double type */
+               sync_agent_ec_pointer pointer_value;
+                                               /**< pointer type */
+       } sync_agent_ec_param_value_u;
+
+/**
+ * @brief Provides set operation for parameter value
+ * @par Usage:
+ * @code
+ typedef int (*callback_func)(user_data *data);
+
+ sync_agent_ec_task_error_e SE_db_backup_ready_pass_through (sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s **param_array)
+ {
+        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+        callback_func func = NULL;
+        user_data *data = NULL;
+        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &func);
+        sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &data);
+        int res = func(data);
+        sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &res);
+        return err;
+ }
+ * @endcode
+ * @param[in] param_value param_value_t type of variable to set in
+ * @param[in] value_type Type of value to set in sync_agent_ec_value_type_e type
+ * @param[in] value Value of parameter to set
+ */
+       void sync_agent_set_param_value(sync_agent_ec_param_value_u * param_value, sync_agent_ec_value_type_e value_type, sync_agent_ec_constpointer value);
+
+/**
+ * @brief Provides get operation for parameter value
+ * @par Usage:
+ * @code
+ typedef int (*callback_func)(user_data *context);
+
+ sync_agent_ec_task_error_e SE_db_backup_ready_pass_through (sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s **param_array)
+ {
+        sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+        callback_func func = NULL;
+        user_data *data = NULL;
+        sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &func);
+        sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &data);
+        int res = func(data);
+        sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &res);
+        return err;
+ }
+ * @endcode
+ * @param[in] param_value param_value_t type of variable to get from
+ * @param[in] value_type Type of value to get in sync_agent_ec_value_type_e type
+ * @param[out] value Value of requested parameter
+ */
+       void sync_agent_get_param_value(sync_agent_ec_param_value_u * param_value, sync_agent_ec_value_type_e value_type, sync_agent_ec_pointer value);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PARAM_VALUE_H_ */
diff --git a/include/engine-controller/queuing_rule_spec.h b/include/engine-controller/queuing_rule_spec.h
new file mode 100755 (executable)
index 0000000..04b44cd
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QUEUING_RULE_SPEC_H_
+#define QUEUING_RULE_SPEC_H_
+
+#include <glib.h>
+#include "fundamental_type.h"
+#include "define.h"
+#include "task_spec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file queuing_rule_spec.h
+ * @brief Provides queuing rule related operation such as create, add
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for queuing rule spec which contains queuing-related information
+ */
+       typedef struct engine_controller_queuing_rule_spec sync_agent_ec_queuing_rule_spec_s;
+
+/**
+ * @brief API to initiates and returns sync_agent_ec_queuing_rule_spec_s type of instance
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_queuing_rule_spec_s *queuing_rule_spec = NULL;
+               char *queuing_rule_name = "xxx";
+               ...
+               queuing_rule_spec = sync_agent_create_queuing_rule_spec_outline(queuing_rule_name);
+               if (queuing_rule_spec == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] queuing_rule_name User defined name to use as name of rule
+ *
+ * @return Newly allocated instance in sync_agent_ec_queuing_rule_spec_s type on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_ec_queuing_rule_spec_s *sync_agent_create_queuing_rule_spec_outline(sync_agent_ec_char * queuing_rule_name);
+
+/**
+ * @brief API to add progress blocking element
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_error_e error = SYNC_AGENT_EC_OK;
+               sync_agent_ec_queuing_rule_spec_s *queuing_rule_spec = NULL;
+               char *queuing_rule_name = "xxx";
+               sync_agent_ec_uint root_task_spec_id = 1;
+               sync_agent_ec_task_spec_s *task_spec = NULL;
+               sync_agent_ec_uint child_depth = 0;
+               ...
+               error = sync_agent_add_progress_blocking_element(queuing_rule_spec, root_task_spec_id, task_spec, child_depth);
+               if (error != SYNC_AGENT_EC_OK) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] rule Queuing rule spec
+ * @param[in] root_task_spec_id Root task spec id
+ * @param[in] root_task_spec Root task spec
+ * @param[in] child_depth Depth of child task
+ * @param[in] ... Iteration of detail information about element in the path from root to blocking element (sync_agent_ec_boolean is_dynamic, sync_agent_ec_int dynamic_case, sync_agent_ec_int child_index)
+ *
+ * @return SYNC_AGENT_EC_OK on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_ec_error_e sync_agent_add_progress_blocking_element(sync_agent_ec_queuing_rule_spec_s * rule, sync_agent_ec_uint root_task_spec_id, sync_agent_ec_task_spec_s * root_task_spec, sync_agent_ec_uint child_depth, ...);
+
+/**
+ * @brief API to decreases reference count of queuing rule spec
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_queuing_rule_spec_s *queuing_rule_spec = NULL;
+               char *queuing_rule_name = "xxx";
+               ...
+               queuing_rule_spec = sync_agent_create_queuing_rule_spec_outline(queuing_rule_name);
+               if (queuing_rule_spec == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_unref_queuing_rule_spec(queuing_rule_spec);
+ *
+ * @endcode
+ *
+ * @param[in] rule Queuing rule spec
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       void sync_agent_unref_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * rule);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* QUEUING_RULE_SPEC_H_ */
diff --git a/include/engine-controller/task_error.h b/include/engine-controller/task_error.h
new file mode 100755 (executable)
index 0000000..5f3151c
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_ERROR_H_
+#define TASK_ERROR_H_
+
+#include "fundamental_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file task_error.h
+ * @brief Provides enum definition for task status
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for task result cases
+ */
+       typedef enum {
+               SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN = 0,
+                                                 /**< 'Not run yet' case */
+               SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS,
+                                             /**< 'Success' case */
+               SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED,
+                                            /**< 'Fail' case */
+               SYNC_AGENT_EC_TASK_ERROR_CANCELED,
+                                          /**< 'Canceled' case */
+               SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK
+                                             /**< 'Invalid' case */
+       } sync_agent_ec_task_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* TASK_ERROR_H_ */
diff --git a/include/engine-controller/task_process.h b/include/engine-controller/task_process.h
new file mode 100755 (executable)
index 0000000..d220574
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_PROCESS_H_
+#define TASK_PROCESS_H_
+
+#include "define.h"
+#include "param.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file task_process.h
+ * @brief Provides process related operations such as cancel flag check, callbak de/registration
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief task_process_callback function which is considered as default unit of task for Engine Controller to launch
+ *
+ * @param[in] param_cnt Count of parameters which will be used in the processing logic
+ * @param[in] param_array Array of parameters which contains parameters values itself
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_alloc_simple_task_spec(sync_agent_ec_char *, sync_agent_task_process_cb, sync_agent_ec_pointer, sync_agent_post_task_cb, sync_agent_ec_uint, sync_agent_ec_param_spec_s **)
+ *
+ */
+       typedef sync_agent_ec_task_error_e(*sync_agent_task_process_cb) (sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @brief process_cancel_callback function which is called when cancel flag gets on
+ *
+ * @param[in] user_data User data to process inside the calcel callback function
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_register_cancel_callback(sync_agent_process_cancel_cb, sync_agent_ec_pointer)
+ *
+ */
+       typedef void (*sync_agent_process_cancel_cb) (void *user_data);
+
+/**
+ * @brief API to check cancel flag
+ * @remarks Note that below functions are valid only inside the TASK_PROCESS function which will be registered at task spec
+ * Note that this can be called every where inside processing logic
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_task_error_e sample_add_task_process(sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s** param_array) {
+                       sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+                       sync_agent_ec_boolean cancel_flag = false;
+
+                       sync_agent_ec_int a = 0;
+                       sync_agent_ec_int b = 0;
+                       sync_agent_ec_int c = 0;
+
+                       //get input parameter pass by user or previous task
+                       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &a);
+                       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &b);
+
+                       //processing logic will be located here
+                       //checking cancel flag and register, unregister cancel callback will be done inside here
+                       {
+                               //register cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_register_cancel_callback(simple_add_cancel_callback, NULL);
+
+                               //check cancel flag (note that this can be called every where inside processing logic)
+                               cancel_flag = sync_agent_check_cancel_flag();
+                               if (cancel_flag) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_CANCELLED;
+                                       goto return_part;
+                               }
+
+                               //processing logic
+                               c = a+b;
+
+                               //if fail occured during processing logic, then set task failed state.
+                               if (c != a+b) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+                                       goto return_part;
+                               }
+
+                               //unregister cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_unregister_cancel_callback(simple_add_cancel_callback, NULL);
+                       }
+
+                       //set output parameter
+                       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &c);
+
+                       return_part:
+                       return err;
+               }
+ *
+ * @endcode
+ *
+ * @return 1 when cancel flag is on, otherwise 0
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_ec_boolean sync_agent_check_cancel_flag(void);
+
+/**
+ * @brief API to register cancel callback function which is called when cancel flag gets on
+ * @remarks Note that below functions are valid only inside the TASK_PROCESS function which will be registered at task spec
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_task_error_e sample_add_task_process(sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s** param_array) {
+                       sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+                       sync_agent_ec_boolean cancel_flag = false;
+
+                       sync_agent_ec_int a = 0;
+                       sync_agent_ec_int b = 0;
+                       sync_agent_ec_int c = 0;
+
+                       //get input parameter pass by user or previous task
+                       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &a);
+                       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &b);
+
+                       //processing logic will be located here
+                       //checking cancel flag and register, unregister cancel callback will be done inside here
+                       {
+                               //register cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_register_cancel_callback(simple_add_cancel_callback, NULL);
+
+                               //check cancel flag (note that this can be called every where inside processing logic)
+                               cancel_flag = sync_agent_check_cancel_flag();
+                               if (cancel_flag) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_CANCELLED;
+                                       goto return_part;
+                               }
+
+                               //processing logic
+                               c = a+b;
+
+                               //if fail occured during processing logic, then set task failed state.
+                               if (c != a+b) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+                                       goto return_part;
+                               }
+
+                               //unregister cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_unregister_cancel_callback(simple_add_cancel_callback, NULL);
+                       }
+
+                       //set output parameter
+                       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &c);
+
+                       return_part:
+                       return err;
+               }
+ *
+ * @endcode
+ *
+ * @param[in] callback_func Function to use on cancellation
+ * @param[in] user_data User data to pass to the callback function on cancellation
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       void sync_agent_register_cancel_callback(sync_agent_process_cancel_cb callback_func, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief API to unregister cancel callback function registered in advance
+ * @remarks Note that below functions are valid only inside the TASK_PROCESS function which will be registered at task spec
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_task_error_e sample_add_task_process(sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s** param_array) {
+                       sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+                       sync_agent_ec_boolean cancel_flag = false;
+
+                       sync_agent_ec_int a = 0;
+                       sync_agent_ec_int b = 0;
+                       sync_agent_ec_int c = 0;
+
+                       //get input parameter pass by user or previous task
+                       sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &a);
+                       sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &b);
+
+                       //processing logic will be located here
+                       //checking cancel flag and register, unregister cancel callback will be done inside here
+                       {
+                               //register cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_register_cancel_callback(simple_add_cancel_callback, NULL);
+
+                               //check cancel flag (note that this can be called every where inside processing logic)
+                               cancel_flag = sync_agent_check_cancel_flag();
+                               if (cancel_flag) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_CANCELLED;
+                                       goto return_part;
+                               }
+
+                               //processing logic
+                               c = a+b;
+
+                               //if fail occured during processing logic, then set task failed state.
+                               if (c != a+b) {
+                                       err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+                                       goto return_part;
+                               }
+
+                               //unregister cancel callback (note that this can be called every where inside processing logic)
+                               sync_agent_unregister_cancel_callback(simple_add_cancel_callback, NULL);
+                       }
+
+                       //set output parameter
+                       sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &c);
+
+                       return_part:
+                       return err;
+               }
+ *
+ * @endcode
+ *
+ * @param[in] callback_func Cancel callback function registered in advance
+ * @param[in] user_data User data registered with above callback function in advance
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       void sync_agent_unregister_cancel_callback(sync_agent_process_cancel_cb callback_func, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief API to provide task request ID of itself
+ * @remarks Note that below functions are valid only inside the TASK_PROCESS function which will be registered at task spec
+ *
+ * @par Usage:
+ * @code
+               int task_id = 0;
+               ...
+               task_id = sync_agent_get_self_request_id();
+               if (task_id == -1) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @return task request id of itself on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_ec_int sync_agent_get_self_request_id(void);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* TASK_PROCESS_H_ */
diff --git a/include/engine-controller/task_spec.h b/include/engine-controller/task_spec.h
new file mode 100755 (executable)
index 0000000..53e2680
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_SPEC_H_
+#define TASK_SPEC_H_
+
+#include <glib.h>
+#include <stdbool.h>
+
+#include "define.h"
+#include "param_spec.h"
+#include "param.h"
+#include "task_process.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file task_spec.h
+ * @brief Provides task spec related operations such as create, child task fetch, data/control flow set and etc.
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Callback function called after task running done
+ *
+ * @param[in] usr_post_task_func_data User data to pass to the sync_agent_post_task_cb
+ * @param[in] msg_id Task request msg id
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_alloc_simple_task_spec(sync_agent_ec_char *, sync_agent_task_process_cb, sync_agent_ec_pointer, sync_agent_post_task_cb, sync_agent_ec_uint, sync_agent_ec_param_spec_s **)
+ *
+ */
+       typedef void (*sync_agent_post_task_cb) (sync_agent_ec_pointer usr_post_task_func_data, sync_agent_ec_uint msg_id);
+
+/**
+ * @brief Callback function which calculates result of dynamic task
+ *
+ * @param[in] param_cnt Count of output parameters resulted from dynamic task
+ * @param[in] param_array Array of output parameters resulted from dynamic task
+ *
+ * @return Result of the calculation case callback function as integer
+ *
+ * @par Since:
+ *
+ *
+ * @see ec_alloc_dynamic_container_task_spec_outline(sync_agent_ec_char *, sync_agent_ec_pointer, sync_agent_post_task_cb, sync_agent_ec_uint, sync_agent_ec_param_spec_s **, sync_agent_calculate_case_cb, sync_agent_ec_uint, sync_agent_ec_int *, sync_agent_ec_uint *, sync_agent_ec_task_spec_s ***)
+ *
+ */
+       typedef sync_agent_ec_int(*sync_agent_calculate_case_cb) (sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @brief Structure of task spec which contains task related spec information such as parameter and callabck and etc
+ */
+       typedef struct engine_controller_task_spec sync_agent_ec_task_spec_s;
+
+/**
+ * @brief API to alloc and return sync_agent_ec_task_spec_s type of structure, using given parameters
+ *
+ * @par Usage:
+ * @code
+               sync_agent_ec_task_error_e task_process_cb(sync_agent_ec_uint param_cnt, sync_agent_ec_param_param_s **param_array)
+               {
+               }
+
+               void post_task_cb(sync_agent_ec_pointer usr_post_task_func_data, sync_agent_ec_uint msg_id)
+               {
+               }
+
+               char *task_name = "xxx";
+               void *user_data = NULL;
+               sync_agent_ec_param_spec_s *param_spec1 = NULL;
+               sync_agent_ec_param_spec_s *param_spec2 = NULL;
+               sync_agent_ec_param_spec_s *param_spec3 = NULL;
+               ...
+               sync_agent_ec_param_spec_s *param_spec_array[3] = {param_spec1, param_spec2, param_spec3};
+               sync_agent_ec_task_spec_s *task_spec = NULL;
+               ...
+               task_spec = sync_agent_alloc_simple_task_spec(task_name,
+                                                                                                                                                                                               task_process_cb,
+                                                                                                                                                                                               user_data,
+                                                                                                                                                                                               post_task_cb,
+                                                                                                                                                                                               3,
+                                                                                                                                                                                               param_spec_array);
+               if (task_spec == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] task_name User defined task name
+ * @param[in] task_process sync_agent_task_process_cb function pointer
+ * @param[in] post_task_func_usr_data User data to pass to the sync_agent_post_task_cb
+ * @param[in] post_task_callback Callback function called after task running done
+ * @param[in] param_cnt Count of input parameters
+ * @param[in] param_spec_array Array of input parameters
+ *
+ * @return Newly alloced sync_agent_ec_task_spec_s type of task spec on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_ec_task_spec_s *sync_agent_alloc_simple_task_spec(sync_agent_ec_char * task_name, sync_agent_task_process_cb task_process, sync_agent_ec_pointer post_task_func_usr_data, sync_agent_post_task_cb post_task_callback,
+                                                                    sync_agent_ec_uint param_cnt, sync_agent_ec_param_spec_s ** param_spec_array);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* TASK_SPEC_H_ */
diff --git a/include/event/data_accessor.h b/include/event/data_accessor.h
new file mode 100755 (executable)
index 0000000..5f7d38a
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_ACCESSOR_H_
+#define DATA_ACCESSOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       data_accessor.h
+ * @brief      Support to access (create, append, get, remove) event packet structure
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * Structure of Event Packet
+ */
+       typedef struct {
+               int event_num;
+                      /**< event number described in event config file */
+               char *size;
+                       /**< need to iterate real data */
+               char *data;
+                       /**< real data expected to send */
+       } sync_agent_event_data_s;
+
+/**
+ * Type of parameter in sync_agent_event_data_s
+ */
+       typedef enum {
+               SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER = 'I',
+                                                  /**< Interger type */
+               SYNC_AGENT_EVENT_PARAM_TYPE_STRING = 'S'
+                                                /**< String type */
+       } sync_agent_event_param_type_e;
+
+/**
+ * API to add parameter to Event packet
+ * @remarks Once one parameter is added each time it's invoked. Parameter type can be Number or String
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               int event_int_data = 0;
+               char *event_char_data = NULL;
+               sync_agent_event_data_s *request_event = NULL;
+               ...
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, event_char_data);
+               ...
+ *
+ * @endcode
+ *
+ * @param[in] iter sync_agent_event_data_s pointer parameters to be added
+ * @param[in] type parameter type (SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, SYNC_AGENT_EVENT_PARAM_TYPE_STRING) @ref sync_agent_event_param_type_e
+ * @param[in] data real parameter data
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_noti(int)
+ *
+ */
+       void sync_agent_append_event_data_param(sync_agent_event_data_s * iter, sync_agent_event_param_type_e type, void *data);
+
+/**
+ * API to extract parameter from Event packet
+ * @remarks This function will be used when extracting received event packet.
+ * extracted order is matched the order of @ref sync_agent_append_event_data_param().
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               int event_int_data = 0;
+               int result_int = 0;
+               char *result_char = NULL;
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               sync_agent_event_data_s *request_event = NULL;
+               sync_agent_event_data_s *response_event = NULL;
+               ...
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_int_data);
+               ...
+               response_event = sync_agent_send_event(request_event, &error);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+
+               if (response_event == NULL) {
+                       // error handling
+                       ...
+               }
+
+               sync_agent_get_event_data_param(response_event, &result_int);
+               sync_agent_get_event_data_param(response_event, &result_char);
+               ...
+ *
+ * @endcode
+ *
+ * @param[in] iter sync_agent_event_data_s pointer parameters to be extracted
+ * @param[in] data as returned by sync_agent_get_event_data_param() - real extracted data
+ *
+ * @par Since
+ *
+ *
+ * @see _event_listener(void *)
+ *
+ */
+       void sync_agent_get_event_data_param(sync_agent_event_data_s * iter, void *data);
+
+/**
+ * API to free sync_agent_event_data_s pointer (event object)
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               sync_agent_event_data_s *request_event = NULL;
+               ...
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_free_event_data(request_event);
+               ...
+ *
+ * @endcode
+ *
+ * @param[in] event    event object
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_noti(sync_agent_event_data_s *)
+ *
+ */
+       void sync_agent_free_event_data(sync_agent_event_data_s * event);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* EVENT_DATA_ACCESSOR_H_ */
diff --git a/include/event/error.h b/include/event/error.h
new file mode 100755 (executable)
index 0000000..fc94da6
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EVENT_ERROR_H_
+#define EVENT_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       error.h
+ * @brief      Definition of framework error codes for event module
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * Enumerations of error codes for event module
+ */
+       typedef enum {
+               SYNC_AGENT_EVENT_SUCCESS,
+                                       /**< when Event Operation is succeed */
+               SYNC_AGENT_EVENT_FAIL,
+                              /**< when Event Operation is failed */
+               SYNC_AGENT_EVENT_TIME_OVER,
+                                   /**< when Event Operation is failed because of time over */
+               SYNC_AGENT_EVENT_IPC_ERR,
+                                 /**< when Event Operation is failed because of IPC */
+               SYNC_AGENT_EVENT_CANCLED
+                                /**< when Event Operation is canceled */
+       } sync_agent_event_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* EVENT_ERROR_H_ */
diff --git a/include/event/event.h b/include/event/event.h
new file mode 100755 (executable)
index 0000000..6668713
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "data_accessor.h"
+#include "error.h"
+#include "handler.h"
+#include "ui_api.h"
+#include "oma_ds_api.h"
+#include "oma_dm_admin_api.h"
+#include "oma_dm_alert_api.h"
+#include "oma_dm_cp_api.h"
+#include "oma_dm_fota_api.h"
+#include "oma_dm_noti_api.h"
+#include "oma_dm_registration_api.h"
+#include "oma_dm_dmacc_control_api.h"
diff --git a/include/event/handler.h b/include/event/handler.h
new file mode 100755 (executable)
index 0000000..2870870
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HANDLER_H_
+#define HANDLER_H_
+
+#include "error.h"
+#include "data_accessor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       handler.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * Enumerations of need for cancel IPC
+ */
+       typedef enum {
+               SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL = 1,
+                                                    /**< need to cancel IPC */
+               SYNC_AGENT_EVENT_IPC_CANCEL_UN_NEED_CANCEL
+                                                  /**< not need to cancel IPC */
+       } sync_agent_event_ipc_cancel_e;
+
+/**
+ * Prototype of event callback function
+ * @remark     event described in event config file will be processed in this callback function
+ *
+ * @param[in] request  received event packet from UI
+ * @param[in] response if event need to synchronous response, use this parameter
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_event_callback(int, sync_agent_event_cb), event_get_event_callback(int)
+ *
+ */
+       typedef int (*sync_agent_event_cb) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * Checking logic, need for IPC cancel
+ * @remark this function is used in @ref sync_agent_send_noti()
+ *
+ * @param[in] user_data user data used in callback function
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_noti(const char *, sync_agent_event_data_s *, sync_agent_confirm_ipc_cancel_cb, void *, sync_agent_event_error_e *)
+ *
+ */
+       typedef sync_agent_event_ipc_cancel_e(*sync_agent_confirm_ipc_cancel_cb) (void *user_data);
+
+/**
+ * API to activate the Event Handler
+ * @remarks Event Handler is a thread. Thread's routine is UNIX Domain Socket Server.
+ *
+ * @par Usage:
+ * @code
+               unsigned long int thread_id = 0;
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               ...
+               error = sync_agent_run_event_handler(&thread_id);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] thread_id as returned by sync_agent_run_event_handler() - created thread's id
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @pre  This function should be called one time. or after sync_agent_clean_event_handler() called.
+ * @post new thread is created. Agent can receive event from UI.
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_event(xmlNode *)
+ *
+ */
+       sync_agent_event_error_e sync_agent_run_event_handler(unsigned long int *thread_id);
+
+/**
+ * API to clean the running event handler
+ * @remarks Event handler thread is killed. Event/noti config is removed from memory
+ *
+ * @par Usage:
+ * @code
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               error = sync_agent_clean_event_handler()
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @post Agent can not receive event from UI.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_clean_event_handler()
+ *
+ */
+       sync_agent_event_error_e sync_agent_clean_event_handler(void);
+
+/**
+ * API to set callback function to process event from UI
+ *
+ * @par Usage:
+ * @code
+               int event_cb(sync_agent_event_data_s *request, sync_agent_event_data_s *response)
+               {
+               }
+               ...
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               int event_num = 1;
+               ...
+               error = sync_agent_set_event_callback(event_num, event_cb);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] event_num event number in event config file
+ * @param[in] callback event processing callback function
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @pre event_num must be in event config file
+ * @post callback function will be called when UI send the event
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_event_callback(int, sync_agent_event_cb)
+ *
+ */
+       sync_agent_event_error_e sync_agent_set_event_callback(int event_num, sync_agent_event_cb callback);
+
+/**
+ * API to create empty notification packet
+ * @remarks Notification is from agent to UI. Complete using returned sync_agent_event_data_s pointer. and
+ * send completed sync_agent_event_data_s to UI. sync_agent_event_data_s* should be freed with @ref sync_agent_free_noti() by you.
+ *
+ * @par Usage:
+ * @code
+               sync_agent_event_data_s *noti = NULL;
+               int noti_num = 1;
+               ...
+               noti = sync_agent_create_noti(noti_num);
+               if (noti == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] noti_num notification number in notification config file
+ *
+ * @return sync_agent_event_data_s structure on success, NULL on error
+ *
+ * @pre noti_num must be in notification config file.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_noti(int)
+ *
+ */
+       sync_agent_event_data_s *sync_agent_create_noti(int noti_num);
+
+/**
+ * API to send agent notification to UI
+ *
+ * @par Usage:
+ * @code
+               sync_agent_event_ipc_cancel_e cancel_cb(void *user_data)
+               {
+               }
+               ...
+               int noti_num = 1;
+               int noti_data = 0;
+               char *noti_key = "xxx";
+               void *user_data = NULL;
+               sync_agent_event_data_s *noti = NULL;
+               sync_agent_event_data_s *response = NULL;
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               ...
+               noti = sync_agent_create_noti(noti_num);
+               if (noti == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &noti_data);
+               ..
+               response = sync_agent_send_noti(noti_key, noti, cancel_cb, user_data, &error);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] noti_key destination, described in framework initialization config file \<Not\> tag
+ * @param[in] noti real notification packet
+ * @param[in] confirm_cancel function pointer checking cancel condition. it's needed when response is required.
+ * @param[in] user_data use in confirm_cancel function
+ * @param[out] error as returned by sync_agent_send_noti() - operation result
+ *
+ * @return sync_agent_event_data_s* when response is required, otherwise NULL - meaningless data (will be deprecated)
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_noti(const char *, sync_agent_event_data_s *, sync_agent_confirm_ipc_cancel_cb, void *, sync_agent_event_error_e *)
+ *
+ */
+       sync_agent_event_data_s *sync_agent_send_noti(const char *noti_key, sync_agent_event_data_s * noti, sync_agent_confirm_ipc_cancel_cb confirm_cancel, void *user_data, sync_agent_event_error_e * error);
+
+/**
+ * API to free notification packet
+ * @remarks This function will release sync_agent_event_data_s* returned from @ref sync_agent_create_noti(), sync_agent_send_noti().
+ *
+ * @par Usage:
+ * @code
+               sync_agent_event_data_s *noti = NULL;
+               ...
+               noti = sync_agent_create_noti(noti_num);
+               if (noti == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_free_noti(noti);
+ *
+ * @endcode
+ *
+ * @param[in] noti notification object
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_noti(sync_agent_event_data_s *)
+ *
+ */
+       void sync_agent_free_noti(sync_agent_event_data_s * noti);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* HANDLER_H_ */
diff --git a/include/event/oma_dm_admin_api.h b/include/event/oma_dm_admin_api.h
new file mode 100755 (executable)
index 0000000..bf4362f
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_ADMIN_API_H_
+#define OMA_DM_ADMIN_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_admin_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * @brief      Structure of sync_agent_dm_setting_data_s
+ */
+       typedef struct {
+               char *profile_name;     /**< dm acc profile name*/
+               char *imei;                     /**< imei name*/
+               char *server_url;               /**< server url name*/
+               char *server_id;                /**< server id name*/
+               char *server_pwd;               /**< server password name*/
+               char *client_id;                /**< client id name*/
+               char *client_pwd;               /**< client password name*/
+               char *client_auth_type;
+                               /**< client auth type name*/
+               char *server_auth_type;
+                               /**< server auth type name*/
+       } sync_agent_dm_setting_data_s;
+
+/**
+ * API to Init admin ui config event API
+ * @remarks This function is use to init admin ui config
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_admin_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init admin ui config
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_init();
+
+/**
+ * API to Deinit admin ui config event API
+ * @remarks This function is use to deinit admin ui config
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_admin_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit admin ui config
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_deinit();
+
+/**
+ * API to Get fumo config value event API
+ * @remarks This function is use to get fumo base config value from dm agent
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int wifi_only = 0;
+
+       err_code = sync_agent_dm_admin_get_fumo_config(&wifi_only);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] wifi_only wifi only setted dm agent db value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get fumo base config value from dm agent
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_get_fumo_config(int *wifi_only);
+
+/**
+ * API to Set fumo config value event API
+ * @remarks This function is use to set fumo base config value to dm agent
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int wifi_only = 1;
+
+       err_code = sync_agent_dm_admin_set_fumo_config(wifi_only);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] wifi_only wifi only setting ui value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to set fumo base config value to dm agent
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_set_fumo_config(int wifi_only);
+
+/**
+ * API to Get dmacc profile event API
+ * @remarks This function is use to get dmacc profile from dm agent
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int profile_type = 1;
+       sync_agent_dm_setting_data_s *data = NULL;
+
+       err_code = sync_agent_dm_admin_get_profile(profile_type, &data);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] profile_type server profile type
+ * @param[out] data profile values
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get dmacc profile from dm agent
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_get_profile(int profile_type, sync_agent_dm_setting_data_s ** data);
+
+/**
+ * API to Set dmacc profile event API
+ * @remarks This function is use to set dmacc profile to dm agent
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int profile_type = 1;
+       sync_agent_dm_setting_data_s data;
+
+       data.profile_name = strdup("xxxx");
+       data.imei = strdup("xxx");
+       data.server_url = strdup("xxxx");
+
+       ...
+
+       err_code = sync_agent_dm_admin_set_profile(profile_type, &data);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] profile_type server profile type
+ * @param[in] data edited profile values
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to set dmacc profile to dm agent
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_set_profile(int profile_type, sync_agent_dm_setting_data_s * data);
+
+/**
+ * API to Reset dmacc profile event API
+ * @remarks This function is use to reset dmacc profile to dm agent
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int profile_type = 1;
+
+       err_code = sync_agent_dm_admin_reset_profile(profile_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] profile_type server profile type
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to reset dmacc profile to dm agent
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_reset_profile(int profile_type);
+
+/**
+ * API to User initiate API
+ * @remarks This function is use to user initiate
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_service_server_type_e server_type = UI_GCF_TYPE;
+       int profile_type = 1;
+
+       err_code = sync_agent_dm_admin_user_initiate(server_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+
+       ...
+
+ *
+ * @endcode
+ *
+ * @param[in] server_type server type
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to user initiate
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_admin_user_initiate(sync_agent_dm_service_server_type_e server_type);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_ADMIN_API_H_ */
diff --git a/include/event/oma_dm_alert_api.h b/include/event/oma_dm_alert_api.h
new file mode 100755 (executable)
index 0000000..aa47f3f
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_ALERT_API_H_
+#define OMA_DM_ALERT_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include <glib.h>
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_alert_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * @brief      Structure of sync_agent_dm_alert_option_s
+ */
+       typedef struct _ui_alert_option {
+               char *min_t;            /**< minimum time */
+               char *max_t;            /**< maximum time */
+               char *default_data;
+                               /**< default data value */
+               char *maxlen;           /**< maximum length */
+               char *input_type;       /**< input type */
+               char *echo_type;        /**< echo type */
+       } sync_agent_dm_alert_option_s;
+
+/**
+ * API to Init alert ui config event API.
+ * @remarks This function is use to init alert ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_alert_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init alert ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_init();
+
+/**
+ * API to Deinit alert ui config event API.
+ * @remarks This function is use to deinit alert ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_alert_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit alert ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_deinit();
+
+/*sync_agent_dm_error_e sync_agent_dm_alert_display(int response_type);*/
+
+/**
+ * API to Confirmation alert event API.
+ * @remarks This function is use confirmation user interaction alert ui.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1; //success
+
+       err_code = sync_agent_dm_alert_confirmation(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type response value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to confirmation user interaction alert ui.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_confirmation(int response_type);
+
+/**
+ * API to Inputtext alert event API.
+ * @remarks This function is use inputtext user interaction alert ui.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1; //success
+       char *text = strdup("xxxx"); //input data by ui
+
+       err_code = sync_agent_dm_alert_inputtext(response_type, text);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type response value
+ *  @param[in] text    input text by user
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to confirmation user interaction alert ui.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_inputtext(int response_type, char *text);
+
+/**
+ * API to Single choice alert event API
+ * @remarks This function is use single choice user interaction alert ui
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1; //success
+       int selected_count = 1; // 1
+       char *selected_number = strdup("1");
+
+       err_code = sync_agent_dm_alert_single_choice(response_type, text);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type response value
+ * @param[in] selected_count absolute "1"
+ * @param[in] selected_number clicked number by user
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to single choice user interaction alert ui
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_single_choice(int response_type, int selected_count, char *selected_number);
+
+/**
+ * API to Multiple choice alert event API
+ * @remarks This function is use multiple choice user interaction alert ui
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1; //success
+       char *selected_number1 = strdup("1"); //input data by ui
+       char *selected_number2 = strdup("1");   //input data by ui
+//     int selected_count = 0;
+
+       GList * out_data_list = NULL;
+       out_data_list = g_list_append(out_data_list, selected_number1);
+       out_data_list = g_list_append(out_data_list, selected_number2);
+
+//     selected_count = g_list_length(out_data_list);
+
+//     err_code = sync_agent_dm_alert_multiple_choice(response_type, selected_count, out_data_list);
+  err_code = sync_agent_dm_alert_multiple_choice(response_type, out_data_list);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type response value
+ * @param[in] out_data_list clicked numbers by user
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to multiple choice user interaction alert ui
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_alert_multiple_choice(int response_type, GList * out_data_list);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_ALERT_API_H_ */
diff --git a/include/event/oma_dm_api_common.h b/include/event/oma_dm_api_common.h
new file mode 100755 (executable)
index 0000000..553282d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_API_COMMON_H_
+#define OMA_DM_API_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#define SYNC_AGENT_DM_API_RESULT_FAILURE       0
+#define SYNC_AGENT_DM_API_RESULT_SUCCESS       1
+
+/**
+ * @file       oma_dm_api_common.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/* common */
+       typedef enum {
+               UI_SYNC_AGENT_DM_FAIL = -1,     /**< response fail to app*/
+               UI_SYNC_AGENT_DM_SUCCESS = 0
+                                       /**< response successful to app*/
+       } sync_agent_dm_error_e;
+
+       typedef enum {
+               UI_SAMSUNG_FUMO_TYPE = 4,       /**< samsung fumo server type */
+               UI_SAMSUNG_FMM_TYPE = 8,                /**< samsung fmm server type */
+               UI_GCF_TYPE = 16,               /**< product server type */
+               UI_NO_ENGINE_TYPE = 32          /**< none server type */
+       } sync_agent_dm_service_server_type_e;
+
+       typedef enum {
+               UI_RESPONSE_TYPE_NONE = 0,      /**< none event value */
+               UI_RESPONSE_TYPE_OK,                    /**< response event ok to dm agent */
+               UI_RESPONSE_TYPE_CANCEL,                /**< response event cancel to dm agent */
+               UI_RESPONSE_TYPE_TIMEOVER,      /**< response event timeout to dm agent */
+
+               //Todo: add the response type if U need
+               UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR,
+                                                       /**< response event reminder interval 1 hour to dm agent */
+               UI_RESPONSE_TYPE_REMINDER_INTERVAL_3_HOURS,
+                                                       /**< response event reminder interval 3 hours to dm agent */
+               UI_RESPONSE_TYPE_REMINDER_INTERVAL_6_HOURS,
+                                                       /**< response event reminder interval 6 hours to dm agent */
+               UI_RESPONSE_TYPE_REMINDER_INTERVAL_12_HOURS,
+                                                       /**< response event reminder interval 12 hours to dm agent */
+               UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_DAY,       /**< response event reminder interval 1 day to dm agent */
+
+               UI_RESPONSE_TYPE_NUM                                                    /**< response event type num */
+       } sync_agent_dm_response_type_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_API_COMMON_H_ */
diff --git a/include/event/oma_dm_cp_api.h b/include/event/oma_dm_cp_api.h
new file mode 100755 (executable)
index 0000000..68fc52a
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_CP_API_H_
+#define OMA_DM_CP_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_cp_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * API to Init cp ui config event API.
+ * @remarks This function is use to init cp ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_cp_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init cp ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_cp_init();
+
+/**
+ * API to Deinit cp ui config event API.
+ * @remarks This function is use to deinit cp ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_cp_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit cp ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_cp_deinit();
+
+/**
+ * API to Check pin code event API.
+ * @remarks This function is use to check pin code.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int ext_id = 1;
+       int response_type = 1;
+       char *user_pin = "1234";
+       int pin_check = 0;
+
+       err_code = sync_agent_dm_cp_check_pin_code(ext_id, response_type, user_pin, &pin_check);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] ext_id generated id by dm agent
+ * @param[in] response_type response result
+ * @param[in] user_pin input user pin value
+ * @param[out] pin_check pin validation value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to check pin code.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_cp_check_pin_code(int ext_id, int response_type, char *user_pin, int *pin_check);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_CP_API_H_ */
diff --git a/include/event/oma_dm_dmacc_control_api.h b/include/event/oma_dm_dmacc_control_api.h
new file mode 100755 (executable)
index 0000000..de1a272
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_DMACC_CONTROL_API_H_
+#define OMA_DM_DMACC_CONTROL_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_dmacc_control_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * API to Init dmacc ui config event API.
+ * @remarks This function is use to init dmacc ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_dmacc_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init dmacc ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_dmacc_init();
+
+/**
+ * API to Deinit dmacc ui config event API.
+ * @remarks This function is use to deinit dmacc ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_dmacc_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit dmacc ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_dmacc_deinit();
+
+/**
+ * API to Add dmacc to dm agent event API.
+ * @remarks This function is use to add dmacc to dm agent.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       err_code = sync_agent_dm_add_dmacc(dmacc_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add dmacc to dm agent.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_add_dmacc(sync_agent_dm_service_server_type_e dmacc_type);
+
+/**
+ * API to Remove dmacc to dm agent event API.
+ * @remarks This function is use to remove dmacc to dm agent.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       err_code = sync_agent_dm_remove_dmacc(dmacc_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add remove to dm agent.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_remove_dmacc(sync_agent_dm_service_server_type_e dmacc_type);
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* OMA_DM_DMACC_CONTROL_API_H_ */
diff --git a/include/event/oma_dm_fota_api.h b/include/event/oma_dm_fota_api.h
new file mode 100755 (executable)
index 0000000..f10d150
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_FOTA_API_H_
+#define OMA_DM_FOTA_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_fota_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * API to Init fota ui config event API.
+ * @remarks This function is use to init fota ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_fota_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init fota ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_init();
+
+/**
+ * API to Deinit fota ui config event API.
+ * @remarks This function is use to deinit fota ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_fota_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit fota ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_deinit();
+
+/**
+ * API to Software update button in fota ui event API.
+ * @remarks This function is use to software update.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_service_server_type_e server_type = UI_SAMSUNG_FUMO_TYPE;
+
+       err_code = sync_agent_dm_fota_software_update(server_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] server_type server type
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click software update button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_software_update(sync_agent_dm_service_server_type_e server_type);
+
+/**
+ * API to Cancel button in fota ui event API.
+ * @remarks This function is use to cancel fota flow.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_fota_cancel();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click cancel button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_cancel();
+
+/**
+ * API to Download button in fota ui event API.
+ * @remarks This function is use to download fota delta file.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1;
+
+       err_code = sync_agent_dm_fota_download(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type event response result
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click download button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_download(int response_type);
+
+/**
+ * API to Install button in fota ui event API.
+ * @remarks This function is use to install fota.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1;
+
+       err_code = sync_agent_dm_fota_install(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type event response result
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click install button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_install(int response_type);
+
+/**
+ * API to Remind interval save button in fota ui event API.
+ * @remarks This function is use to set remind interval.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int interval_type = 1;
+
+       err_code = sync_agent_dm_fota_install(interval_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] interval_type remind interval value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click remind interval button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_set_interval(int interval_type);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_FOTA_API_H_ */
diff --git a/include/event/oma_dm_noti_api.h b/include/event/oma_dm_noti_api.h
new file mode 100755 (executable)
index 0000000..58dba01
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_NOTI_API_H_
+#define OMA_DM_NOTI_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_noti_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * API to Init fota noti ui config.
+ * @remarks This function is use to init fota noti ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_push_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init fota noti ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_push_init();
+
+/**
+ * API to Denit fota noti ui config.
+ * @remarks This function is use to denit fota noti ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_push_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit fota noti ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_push_deinit();
+
+/**
+ * API to Software update button in fota noti ui event API.
+ * @remarks This function is use to software update.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_service_server_type_e server_type = UI_SAMSUNG_FUMO_TYPE;
+       char *server_id = "xxxx";
+       char *session_id = "111";
+
+       err_code = sync_agent_dm_push_software_update(server_id, session_id);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ * @param[in] server_id server id
+ * @param[in] session_id session id
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click software update button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_update_noti(char *server_id, char *session_id);
+
+/**
+ * API to Cancel button in fota noti ui event API.
+ * @remarks This function is use to cancel fota flow.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_push_cancel();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click cancel button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_cancel_noti();
+
+/**
+ * API to Download button in fota noti ui event API.
+ * @remarks This function is use to download fota delta file.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1;
+
+       err_code = sync_agent_dm_push_download(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type event response result
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click download button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_download_noti(int response_type);
+
+/**
+ * API to Install button in fota noti ui event API.
+ * @remarks This function is use to install fota.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1;
+
+       err_code = sync_agent_dm_push_install(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] response_type event response result
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click install button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_install_noti(int response_type);
+
+/**
+ * API to Remind interval save button in fota noti ui event API.
+ * @remarks This function is use to set remind interval.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       int response_type = 1;
+
+       err_code = sync_agent_dm_fota_install(response_type);
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ * @param[in] interval_type remind interval value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if click remind interval button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_fota_set_interval_noti(int interval_type);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_NOTI_API_H_ */
diff --git a/include/event/oma_dm_registration_api.h b/include/event/oma_dm_registration_api.h
new file mode 100755 (executable)
index 0000000..c81c68b
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_REGISTRATION_API_H_
+#define OMA_DM_REGISTRATION_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "oma_dm_api_common.h"
+
+/**
+ * @file       oma_dm_registration_api.h
+ * @brief      Support to use framework event module for agent
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * API to Init fota registraion ui config.
+ * @remarks This function is use to init fota registraion ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_reg_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to init fota registraion ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_reg_init();
+
+/**
+ * API to Deinit fota registraion ui config.
+ * @remarks This function is use to deinit fota registraion ui config.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_reg_deinit();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to deinit fota registraion ui config.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_reg_deinit();
+
+/**
+ * API to register fota account event API.
+ * @remarks This function is use to register fota account.
+ *
+ * @par Usage:
+ * @code
+ *
+ *
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = sync_agent_dm_reg_init();
+       if(err != SYNC_AGENT_DM_MO_SUCCESS) {
+               //error handling
+       }
+       ...
+ *
+ * @endcode
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to register fota account button.
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_error_e sync_agent_dm_reg_account_registration();
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_REGISTRATION_API_H_ */
diff --git a/include/event/oma_ds_api.h b/include/event/oma_ds_api.h
new file mode 100755 (executable)
index 0000000..559b04c
--- /dev/null
@@ -0,0 +1,801 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DS_API_H_
+#define OMA_DS_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * Enumerations of error codes for OMA DS API
+ */
+       typedef enum {
+               SYNC_AGENT_DS_FAIL = -1,        /**< Fail */
+               SYNC_AGENT_DS_SUCCESS = 0       /**< Successful */
+       } sync_agent_ds_error_e;
+
+/**
+ * Enumerations of service type
+ */
+       typedef enum {
+               SYNC_AGENT_CONTACT = 0,         /**< Contact */
+               SYNC_AGENT_CALENDAR = 1,        /**< Calendar */
+               SYNC_AGENT_MEMO = 2,            /**< Memo */
+               SYNC_AGENT_CALLLOG = 3          /**< Calllog */
+       } sync_agent_ds_service_type_e;
+
+/**
+ * @brief      Structure of OMA DS Server information instance
+ */
+       typedef struct {
+               char *addr;                                     /**< Server ip */
+               char *id;                                       /**< Id */
+               char *password;                         /**< Password */
+       } sync_agent_ds_server_info;
+
+/**
+ * @brief      Structure of OMA DS Sync information instance
+ */
+       typedef struct {
+               char *sync_mode;                /**< Sync mode */
+               char *sync_type;                /**< Sync type */
+               char *interval;                 /**< Interval */
+       } sync_agent_ds_sync_info;
+
+/**
+ * @brief      Structure of OMA DS Service information instance
+ */
+       typedef struct {
+               sync_agent_ds_service_type_e service_type;      /**< Service type */
+               int enabled;                                                            /**< Enable or not */
+               char *src_uri;                                                          /**< Source uri */
+               char *tgt_uri;                                                          /**< Target uri */
+               char *id;                                                                       /**< Id */
+               char *password;                                                         /**< password */
+       } sync_agent_ds_service_info;
+
+/**
+ * @brief      Structure of OMA DS Profile information instance
+ */
+       typedef struct {
+               char *profile_dir_name;                                         /**< Profile dir name */
+               char *profile_name;                                                     /**< Profile name */
+               sync_agent_ds_server_info server_info;          /**< Server information */
+               sync_agent_ds_sync_info sync_info;                      /**< Sync information */
+               GList *service_list;                                            /**< Service list */
+               int last_sync_status;                                           /**< Last sync status */
+               int last_sync_time;                                                     /**< Last sync time */
+       } sync_agent_ds_profile_info;
+
+/**
+ * @brief      Structure of OMA DS Statistics information instance
+ */
+       typedef struct {
+               char *dbsynced;                                                         /**< Sync result(success, fail, stop) */
+               int last_session_time;                                          /**< Sync time */
+               int server2client_total;                                        /**< Total items(server to client) */
+               int server2client_nrofadd;                                      /**< Add items(server to client) */
+               int server2client_nrofdelete;                           /**< Delete items(server to client) */
+               int server2client_nrofreplace;                          /**< Replace items(server to client) */
+               int client2server_total;                                        /**< Total items(client to server) */
+               int client2server_nrofadd;                                      /**< Add items(client to server) */
+               int client2server_nrofdelete;                           /**< Delete items(client to server) */
+               int client2server_nrofreplace;                          /**< Replace items(client to server) */
+       } sync_agent_ds_statistics_info;
+
+/**
+ * @brief      profile info handler
+ */
+       typedef void *ds_profile_h;
+
+/**
+ * @brief initialize OMA DS
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_init();
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_deinit
+ */
+       sync_agent_ds_error_e sync_agent_ds_init();
+
+/**
+ * @brief create profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ *
+ * ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[out] profile_h        profile info initialized
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_free_profile_info
+ */
+       sync_agent_ds_error_e sync_agent_ds_create_profile_info(ds_profile_h * profile_h);
+
+/**
+ * @brief set profile name into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * char *profile_name = "profile name";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info initialized
+ * @param[in]  profile_dir_name        profile dir name
+ * @param[in]  profile_name            profile name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_dir_name, char *profile_name);
+
+/**
+ * @brief set server information into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *addr = "http://xxx.xxx.xxx";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info initialized
+ * @param[in]  addr                    server ip address
+ * @param[in]  id                              account id
+ * @param[in]  password                account password
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_server_info(ds_profile_h profile_h, char *addr, char *id, char *password);
+
+/**
+ * @brief set sync information into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *sync_mode = "Periodic";
+ * char *sync_type = "Update both";
+ * char *interval = "1 hour";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info initialized
+ * @param[in]  sync_mode               sync mode(Push, Manual, Periodic)
+ * @param[in]  sync_type               sync type(Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone)
+ * @param[in]  interval                interval(only for periodic sync(5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week))
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, char *sync_mode, char *sync_type, char *interval);
+
+/**
+ * @brief set service information into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+ * int enabled = 1;
+ * char *src_uri = "Contacts";
+ * char *tgt_uri = "card";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_set_sync_category(profile_h, service_type, enabled, src_uri, tgt_uri, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info initialized
+ * @param[in]  service_type    service type(SYNC_AGENT_CONTACT, SYNC_AGENT_CALENDAR, SYNC_AGENT_MEMO,  SYNC_AGENT_CALLLOG)
+ * @param[in]  enabled                 enable or not( 1 =  enable, 0 = prevent)
+ * @param[in]  src_uri                 source uri
+ * @param[in]  tgt_uri                 target uri
+ * @param[in]  id                              id
+ * @param[in]  password                password
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password);
+
+/**
+ * @brief get profile dir name, profile name from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * char *get_profile_dir_name = NULL;
+ * char *profile_name = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_profile_name(profile_h, &get_profile_dir_name, &profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info
+ * @param[out] profile_dir_name        profile dir name
+ * @param[out] profile_name            profile name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_dir_name, char **profile_name);
+
+/**
+ * @brief get profile server information from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * sync_agent_ds_server_info server_info = {NULL};
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_server_info(profile_h, &server_info);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info
+ * @param[out] server_info                     server info structure
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_server_info(ds_profile_h profile_h, sync_agent_ds_server_info * server_info);
+
+/**
+ * @brief get profile sync information from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * sync_agent_ds_sync_info sync_info = {NULL};
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_sync_info(profile_h, &sync_info);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info
+ * @param[out] sync_info                       sync info structure
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_sync_info(ds_profile_h profile_h, sync_agent_ds_sync_info * sync_info);
+
+/**
+ * @brief get profile service information list from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * GList service_list = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_sync_category_info(profile_h, &service_list);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                               profile info
+ * @param[out] service_list                    list of service_info structure
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_sync_service_info(ds_profile_h profile_h, GList ** service_list);
+
+/**
+ * @brief get profile last sync status, last sync time from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * int last_sync_status = 0;
+ * int last_sync_time = 0;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_last_sync_info(profile_h, &last_sync_status, &last_sync_time);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                               profile info
+ * @param[out] last_sync_status                last sync status
+ * @param[out] last_sync_time                  last sync time
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_last_sync_info(ds_profile_h profile_h, int *last_sync_status, int *last_sync_time);
+
+/**
+ * @brief get statistics info list from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * GList *statistics_list = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_sync_statistics(profile_h, &statistics_list);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                               profile info
+ * @param[out] statistics_list                 list of statistics info structure
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_sync_statistics(ds_profile_h profile_h, GList ** statistics_list);
+
+/**
+ * @brief add profile
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * char *profile_name = "profile name";
+ *
+ * char *addr = "http://xxx.xxx.xxx";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * char *sync_mode = "Periodic";
+ * char *sync_type = "Update both";
+ * char *interval = "1 hour";
+ *
+ * sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+ * int enabled = 1;
+ * char *src_uri = "Contacts";
+ * char *tgt_uri = "card";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * int profile_id = 0;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_sync_category(profile_h, service_type, enabled, src_uri, tgt_uri, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_add_profile(profile_h, &profile_id);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @param[out] profile_id              profile id
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_set_profile_name, sync_agent_ds_set_server_info, sync_agent_ds_set_sync_info, sync_agent_ds_set_sync_category
+ */
+       sync_agent_ds_error_e sync_agent_ds_add_profile(ds_profile_h profile_h, int *profile_id);
+
+/**
+ * @brief get profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char * profile_dir_name = "Sync1";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in]  profile_dir_name                profile dir name
+ * @param[out] profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_free_profile_info
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_profile(char *profile_dir_name, ds_profile_h * profile_h);
+
+/**
+ * @brief get all profiles info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * GList **profile_list = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_all_profile(&profile_list);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[out] profile_list            list of profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_free_profile_info
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_all_profile(GList ** profile_list);
+
+/**
+ * @brief update profile
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_dir_name = "Sync1";
+ * char *profile_name = "updated profile name";
+ *
+ * char *addr = "http://xxx.xxx.xxx";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * char *sync_mode = "Periodic";
+ * char *sync_type = "Update both";
+ * char *interval = "1 hour";
+ *
+ * sync_agent_ds_service_type_e service_type = SYNC_AGENT_CONTACT;
+ * int enabled = 1;
+ * char *src_uri = "Contacts";
+ * char *tgt_uri = "card";
+ * char *id = "id";
+ * char *password = "password";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_sync_info(profile_h, sync_mode, sync_type, interval);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_set_sync_category(profile_h, service_type, enabled, src_uri, tgt_uri, id, password);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_update_profile(profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_set_profile_name, sync_agent_ds_set_server_info, sync_agent_ds_set_sync_info, sync_agent_ds_set_sync_category
+ */
+       sync_agent_ds_error_e sync_agent_ds_update_profile(ds_profile_h profile_h);
+
+/**
+ * @brief delete profile
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_FAIL;
+ * ds_profile_h profile_h = NULL;
+ * char *profileDirName = "Sync1";
+ *
+ * ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_delete_profile(profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_set_profile_name
+ */
+       sync_agent_ds_error_e sync_agent_ds_delete_profile(ds_profile_h profile_h);
+
+/**
+ * @brief start sync
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_FAIL;
+ * ds_profile_h profile_h = NULL;
+ * char *profileDirName = "Sync1";
+ *
+ * ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_start_sync(profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_set_profile_name
+ */
+       sync_agent_ds_error_e sync_agent_ds_start_sync(ds_profile_h profile_h);
+
+/**
+ * @brief stop sync
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_FAIL;
+ * ds_profile_h profile_h = NULL;
+ * char *profileDirName = "Sync1";
+ *
+ * ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_stop_sync(profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_set_profile_name
+ */
+       sync_agent_ds_error_e sync_agent_ds_stop_sync(ds_profile_h profile_h);
+
+/**
+ * @brief free profile info
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_FAIL;
+ * ds_profile_h profile_h = NULL;
+ *
+ * ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if (result == SYNC_AGENT_DS_FAIL) {
+ *     ...
+ * }
+ *
+ * sync_agent_ds_free_profile_info(profile_h);
+ *
+ * @endcode
+ * @param[in]  profile_h               profile info
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_create_profile_info, sync_agent_ds_get_profile, sync_agent_ds_get_all_profile
+ */
+       void
+        sync_agent_ds_free_profile_info(ds_profile_h profile_h);
+
+/**
+ * @brief deinitialize OMA DS
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_init();
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * ds_err = sync_agent_ds_deinit();
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_init
+ */
+       sync_agent_ds_error_e sync_agent_ds_deinit();
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DS_API_H_ */
diff --git a/include/event/ui_api.h b/include/event/ui_api.h
new file mode 100755 (executable)
index 0000000..c17d8d5
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UI_API_H_
+#define UI_API_H_
+
+#include "error.h"
+#include "data_accessor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file ui_api.h
+ * @brief      Support to use framework event module for UI
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * Prototype of notification callback function
+ * @remark     Notification described in notification config file will be processed in this callback function.
+ *
+ * @param[in]  noti received notification packet from agent
+ * @param[in]  user_data user data
+ *
+ * @par Since:
+ *
+ *
+ * @see event_register_noti_callback(int noti_num, sync_agent_noti_cb, void *), event_get_noti_callback(int)
+ *
+ */
+       typedef int (*sync_agent_noti_cb) (sync_agent_event_data_s * noti, void *user_data);
+
+/**
+ * API to create empty event packet
+ * @remarks Event is from UI to Agent. Complete using returned sync_agent_event_data_s pointer. and
+ * send completed sync_agent_event_data_s to Agent. sync_agent_event_data_s* should be freed with @ref sync_agent_free_event() by you.
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               sync_agent_event_data_s *request_event = NULL;
+               ...
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] event_num event number in event config file
+ *
+ * @return sync_agent_event_data_s structure on success, NULL on error
+
+ * @pre  event_num must be in event config file.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_event(int)
+ *
+ */
+       sync_agent_event_data_s *sync_agent_create_event(int event_num);
+
+/**
+ * API to send ui event to the agent
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               int event_data = 0;
+               int event_result = 0;
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               sync_agent_event_data_s *request_event = NULL;
+               sync_agent_event_data_s *response_event = NULL;
+
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_data);
+               ...
+               response_event = sync_agent_send_event(request_event, &error);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+
+               if (response_event == NULL) {
+                       // error handling
+                       ...
+               }
+
+               sync_agent_get_event_data_param(response_event, &event_result);
+               ...
+
+               // free logic
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+ *
+ * @endcode
+ *
+ * @param[in] event real event packet
+ * @param[in] error as returned by sync_agent_send_event() - operation result
+ *
+ * @return sync_agent_event_data_s* when response is required
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_event(), sync_agent_free_event()
+ *
+ */
+       sync_agent_event_data_s *sync_agent_send_event(sync_agent_event_data_s * event, sync_agent_event_error_e * error);
+
+/**
+ * API to activate the notification listener
+ * @remarks Notification listener is based on g_main_loop.
+ * @remarks Notification Listener is a thread. Thread's routine is UNIX Domain Socket Server. - will be deprecated
+ *
+ * @par Usage:
+ * @code
+               char *noti_key = "xxx";
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               ...
+               error = sync_agent_run_noti_listener(noti_key);
+               if (err != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+                       result = UI_SYNC_AGENT_DM_FAIL;
+               }
+ *
+ * @endcode
+ *
+ * @param[in] noti_key destination, described in framework initialization config file \<Noti\> tag
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @pre This function should be called one time. or after sync_agent_stop_noti_listener() called.
+ * @post new thread is created. UI can receive event from Agent. - will be deprecated
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_run_noti_listener(const char *)
+ *
+ */
+       sync_agent_event_error_e sync_agent_run_noti_listener(const char *noti_key);
+
+/**
+ * @brief Stop the Running Notification Listener
+ * @remarks Event/noti config is removed from memory
+ * @remarks Notification Listener thread is killed. event/noti config is removed from memory - will be deprecated
+ *
+ * @par Usage:
+ * @code
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               error = sync_agent_stop_noti_listener();
+               if (err != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @post UI can not receive event from Agent.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_stop_noti_listener()
+ *
+ */
+       sync_agent_event_error_e sync_agent_stop_noti_listener(void);
+
+/**
+ * API to set callback function to process Notification from Agent
+ *
+ * @par Usage:
+ * @code
+               int noti_cb(sync_agent_event_data_s * request, void *data)
+               {
+               }
+               ...
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+               int noti_num = 1;
+               void *user_data = NULL;
+               ...
+               error = sync_agent_set_noti_callback(noti_num, noti_cb, user_data);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] noti_type notification number in notification config file
+ * @param[in] callback notification processing callback function
+ * @param[in] user_data use in notification callback function
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS on success, SYNC_AGENT_EVENT_FAIL on error
+ *
+ * @pre  notiType must be in notification config file.
+ * @post callback function will be called when Agent send the UI.
+ *
+ * @par Since:
+
+ *
+ * @see sync_agent_set_noti_callback(int, sync_agent_noti_cb, void *);
+ *
+ */
+       sync_agent_event_error_e sync_agent_set_noti_callback(int noti_type, sync_agent_noti_cb callback, void *user_data);
+
+/**
+ * API to free event packet
+ * @remarks This function will release sync_agent_event_data_s* returned from @ref sync_agent_create_event(), sync_agent_send_event()
+ *
+ * @par Usage:
+ * @code
+               int event_num = 1;
+               sync_agent_event_data_s *request_event = NULL;
+               ...
+               request_event = sync_agent_create_event(event_num);
+               if (request_event == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               sync_agent_free_event(request_event);
+ *
+ * @endcode
+ *
+ * @param[in] event object
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_event(sync_agent_event_data_s *)
+ *
+ */
+       void sync_agent_free_event(sync_agent_event_data_s * event);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* UI_API_H_ */
diff --git a/include/fsapi/fsapi.h b/include/fsapi/fsapi.h
new file mode 100755 (executable)
index 0000000..55c2cae
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "operation.h"
diff --git a/include/fsapi/operation.h b/include/fsapi/operation.h
new file mode 100755 (executable)
index 0000000..531cda9
--- /dev/null
@@ -0,0 +1,575 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPERATION_H_
+#define OPERATION_H_
+
+#include <stdbool.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file operation.h
+ * @brief Provides file system related operations such as file/folder create, delete, read, write and etc.
+ */
+
+/** @addtogroup fsapi
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of FSAPI return values
+ */
+       typedef enum {
+               SYNC_AGENT_FSAPI_FALSE = 0,
+                                       /**< false return */
+               SYNC_AGENT_FSAPI_TRUE = 1,
+                                  /**< true return */
+       } sync_agent_fsapi_return_e;
+
+/**
+ * @brief Check whether given file path is existing or not
+ * @remarks file path can be either a file or a folder.
+ * @par Usage:
+ * @code
+ *
+ * int result = sync_agent_is_existing_fs(file_name);
+ * if (result != 1) {
+ *   ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path you want to check
+ * @return SYNC_AGENT_FSAPI_TRUE when the instance you want to check exists, otherwise 0
+ */
+       sync_agent_fsapi_return_e sync_agent_is_existing_fs(const char *file_name);
+
+/**
+ * @brief Provides information of internal SD card in character stream
+ * @remarks The character stream includes following information in given order with separator ','
+ * Total size in bytes, max file name length, file name prevent chars, file name code schema,
+ * if allows duplicated file name, max folder depth, max folder name length,
+ * folder name prevent chars.
+ * The FS info stream should be freed when no more in use
+ * @par Usage:
+ * @code
+ *
+ * char **result = NULL;
+ * int result = sync_agent_get_fs_info(&result);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[out] result Double pointer of the char variable you want to load FS info on
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_free_fs_info
+ */
+       sync_agent_fsapi_return_e sync_agent_get_fs_info(char **result);
+
+/**
+ * @brief Provides information of internal SD card in character stream
+ * @remarks The character stream includes following information in given order with separator ','
+ * Total size in bytes, max file name length, file name prevent chars, file name code schema,
+ * if allows duplicated file name, max folder depth, max folder name length,
+ * folder name prevent chars.
+ * The FS info stream should be freed when no more in use
+ * @par Usage:
+ * @code
+ *
+ * char *result = NULL;
+ * int result = sync_agent_get_fs_info(&result);
+ *
+ * ...
+ *
+ * result = sync_agent_free_fs_info(result);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] result variable you want to free FS
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_get_fs_info
+ */
+       sync_agent_fsapi_return_e sync_agent_free_fs_info(char *result);
+
+/**
+ * @brief Provides free size and total size of file system which your file path exists on
+ * @par Usage:
+ * @code
+ *
+ * const char *root = "/tmp";
+ * long double size_free  = 0;
+ * long double size_total = 0;
+ *
+ * int result = sync_agent_get_fs_mem_size(root, &size_free, &size_total);
+ * if (result != 1) {
+ *   ...
+ * }
+ *
+ * @endcode
+ * @param[in] root File path you want to check
+ * @param[out] size_free Free size of file system in bytes
+ * @param[out] size_total Total size of file system in bytes
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_get_fs_mem_size(const char *root, long double *size_free, long double *size_total);
+
+/**
+ * @brief Provides size of your file
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * unsigned long size = 0;
+ *
+ * int result = sync_agent_get_file_size(file_name, &size);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path you want to check
+ * @param[out] size Size of requested file in bytes
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_get_file_size(const char *file_name, unsigned long *size);
+
+/**
+ * @brief Provides file copy operation
+ * @remarks Operation will fail if destination already exists.
+ * @par Usage:
+ * @code
+ *
+ * const char *source = "/tmp/source";
+ * const char *dest = "/tmp/dest";
+ *
+ * int result = sync_agent_copy_file(source, dest);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] source Source file path
+ * @param[in] dest Destination file path
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_copy_file(const char *source, const char *dest);
+
+/**
+ * @brief Provides file delete operation
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ *
+ * int result = sync_agent_delete_file(file_name);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path to delete
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_delete_file(const char *file_name);
+
+/**
+ * @brief Provides file move operation
+ * @remarks Operation will fail if destination already exists.
+ * @par Usage:
+ * @code
+ *
+ * const char *source = "/tmp/source";
+ * const char *dest = "/tmp/dest";
+ *
+ * int result = sync_agent_move_file(source, dest);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] source Source file path
+ * @param[in] dest Destination file path
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_move_file(const char *source, const char *dest);
+
+/**
+ * @brief Provides file rename operation
+ * @remarks Operation will fail if destination already exists.
+ * @par Usage:
+ * @code
+ *
+ * const char *source = "/tmp/source";
+ * const char *dest = "/tmp/dest";
+ *
+ * int result = sync_agent_rename_file(source, dest);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] source Source file path
+ * @param[in] dest Destination file path
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_rename_file(const char *source, const char *dest);
+
+/**
+ * @brief Provides file list information of your folder in a linked list of char stream
+ * @remarks Format of the return char stream is "name,size_in_bytes,111111000,time_stamp".
+ * The list should be freed using sync_agent_free_fs_list when no more in use.
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp";
+ * GList *list = NULL;
+ *
+ * int result = sync_agent_get_file_list(folder_name, &list);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] folder_name Folder path which you want to list files in
+ * @param[out] list Double pointer of GSList variable you want to load file list info on
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_free_fs_list
+ */
+       sync_agent_fsapi_return_e sync_agent_get_file_list(const char *folder_name, GSList ** list);
+
+/**
+ * @brief Provides file read operation (Keeps file descriptor until reaching end of file)
+ * @remarks Need to call repeatedly with proper 'required_length' until you get TRUE value of the bool option 'isFinal'.
+ * Provided contents 'required_contents' should be freed when no more in use.
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * char *required_contents = NULL;
+ * unsigned long required_length = 0;
+ * unsigned long size_return = 0;
+ * bool is_final = false;
+ *
+ * int result = sync_agent_read_file(file_name, &required_contents, &required_length, &size_return, &is_final);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path which you want to read
+ * @param[in] required_length Size to read
+ * @param[out] required_contents Char variable to load file contents on
+ * @param[out] size_return Size of invoked file contents
+ * @param[out] is_final Boolean value to indicate whether end of file reached or not
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_free_file
+ */
+       sync_agent_fsapi_return_e sync_agent_read_file(const char *file_name, char **required_contents, unsigned long required_length, unsigned long *size_return, bool * is_final);
+
+/**
+ * @brief Provides file read operation (Entire contents at once)
+ * @remarks Provided 'required_contents' should be freed when no more in use.
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * char *required_contents = NULL;
+ * unsigned long size_return = 0;
+ *
+ * int result = sync_agent_read_whole_file(file_name, &required_contents, &size_return);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path which you want to read
+ * @param[out] required_contents Char variable to load file contents on
+ * @param[out] size_return Size of invoked file contents
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_free_file
+ */
+       sync_agent_fsapi_return_e sync_agent_read_whole_file(const char *file_name, char **required_contents, unsigned long *size_return);
+
+/**
+ * @brief Provides free operation for file contents loaded from sync_agent_read_file, sync_agent_read_whole_file
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * char *required_contents = NULL;
+ * unsigned long required_length = 0;
+ * unsigned long size_return = 0;
+ * bool is_final = false;
+ *
+ * int result = sync_agent_read_file(file_name, &required_contents, &required_length, &size_return, &is_final);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * result = sync_agent_free_file(required_contents);
+ * if (result !=1 ) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] requested_contents File contents to free
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_read_file, sync_agent_read_whole_file
+ */
+       sync_agent_fsapi_return_e sync_agent_free_file(char **requested_contents);
+
+/**
+ * @brief Provides file write operation (Keeps file descriptor until finish order)
+ * @remarks Writes given contents to given file until 'isFinal' option enabled.
+ * Destination file won't be appeared until you give 'isFinal' option.
+ * Useful when writing several chunks into new file in one task.
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * const char *contents = "contents";
+ * unsigned long length = 0;
+ * bool is_final = false;
+ * bool overwirte = false;
+ *
+ * int result = sync_agent_write_file(file_name, contents, &length, &is_final, &overwrite);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path which you want to write
+ * @param[in] contents Contents to write
+ * @param[in] length Size of the contents
+ * @param[in] is_final Option to order operation finish
+ * @param[in] overwrite Option to order overwriting
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_write_file(const char *file_name, const char *contents, unsigned long length, bool is_final, bool overwrite);
+
+/**
+ * @brief Provides file write operation (Entire contents at once)
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * const char *contents = "contents";
+ * unsigned long length = 0;
+ * bool overwirte = false;
+ *
+ * int result = sync_agent_write_whole_file(file_name, contents, &length, &overwrite);
+ * if (result != ) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path which you want to write
+ * @param[in] contents Contents to write
+ * @param[in] length Size of the contents
+ * @param[in] overwrite Option to order overwriting
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_write_whole_file(const char *file_name, const char *contents, unsigned long length, bool overwrite);
+
+/**
+ * @brief Provides file append operation
+ * @remarks Appends given contents to given file.
+ * If given file not existing, create first and start appending.
+ * @par Usage:
+ * @code
+ *
+ * const char *file_name = "file_name";
+ * const char *contents = "contents";
+ * unsigned long length = 0;
+ * bool overwirte = false;
+ *
+ * int result = sync_agent_append_file(file_name, contents, &length, &overwrite);
+ * if (result != ) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_name File path which you want to write
+ * @param[in] contents Contents to write
+ * @param[in] length Size of the contents
+ * @param[in] overwrite Option to order overwriting
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_append_file(const char *file_name, const char *contents, unsigned long length, bool overwrite);
+
+/**
+ * @brief Provides folder create operation
+ * @remarks All parents folder will be created along
+ * in case any upper parents folders in the ordered folder path not existing.
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp/create_folder";
+ *
+ * int result = sync_agent_create_directory(folder_name);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] folder_name Folder path to create
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_create_directory(const char *folder_name);
+
+/**
+ * @brief Provides folder delete operation
+ * @remarks Operation will fail in case the requested folder is not empty if 'recusive' option not given.
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp/delete_folder";
+ *
+ * int result = sync_agent_delete_directory(folder_name, true);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] folder_name Folder path to delete
+ * @param[in] recursive Option to delete inside recursively
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_delete_directory(const char *folder_name, bool recursive);
+
+/**
+ * @brief Provides folder delete operation without deleting root of the requested folder itself
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp/empty_folder";
+ *
+ * int result = sync_agent_empty_directory_contents(folder_name);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] folder_name Folder path to delete inside
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_empty_directory_contents(const char *folder_name);
+
+/**
+ * @brief Provides folder rename operation
+ * @remarks Operation will fail if destination already exists.
+ * @par Usage:
+ * @code
+ *
+ * const char *source = "/tmp/source_folder";
+ * const char *dest = "/tmp/dest_folder";
+ *
+ * int result = sync_agent_rename_directory(source, dest);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] source Source file path
+ * @param[in] dest Destination file path
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ */
+       sync_agent_fsapi_return_e sync_agent_rename_directory(const char *source, const char *dest);
+
+/**
+ * @brief Provides folder list information of your folder in a linked list of char stream
+ * @remarks Format of the return char stream is "name,number_of_instances_inside,111111000,time_stamp".
+ * The list should be freed using sync_agent_free_fs_list when no more in use.
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp";
+ * GList *list = NULL;
+ *
+ * int result = sync_agent_rename_directory(folder_name, &list);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] folder_name Folder path which you want to list files in
+ * @param[out] list Double pointer of GSList variable you want to load file list info on
+ * @return SYNC_AGENT_FSAPI_TRUE on success, otherwise SYNC_AGENT_FSAPI_FALSE
+ * @see sync_agent_free_fs_list
+ */
+       sync_agent_fsapi_return_e sync_agent_get_directory_list(const char *folder_name, GSList ** list);
+
+/**
+ * @brief Provides free operation for list variable created from sync_agent_get_file_list and sync_agent_get_directory_list
+ * @par Usage:
+ * @code
+ *
+ * const char *folder_name = "/tmp";
+ * GList *list = NULL;
+ *
+ * int result = sync_agent_get_file_list(folder_name, &list);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * result = sync_agent_free_fs_list(list);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] list List variable to free
+ * @see sync_agent_get_file_list, sync_agent_get_directory_list
+ */
+       void sync_agent_free_fs_list(GSList * list);
+
+/**
+ * @brief Provides MD5 hash validation
+ * @par Usage:
+ * @code
+ *
+ * const char *file_path = "file_path";
+ * const char *file_md5_checksum = "checksum";
+ * bool is_same = false;
+ *
+ * int result = sync_agent_file_md5_validation(file_path, file_md5_checksum, is_same);
+ * if (result != 1) {
+ *    ...
+ * }
+ *
+ * @endcode
+ * @param[in] file_path File path to extract MD5 hash
+ * @param[in] file_md5_checksum MD5 hash to compare with
+ * @param[out] is_same Result of comparison
+ */
+       sync_agent_fsapi_return_e sync_agent_file_md5_validation(const char *file_path, const char *file_md5_checksum, bool * is_same);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OPERATION_H_ */
diff --git a/include/initialization/error.h b/include/initialization/error.h
new file mode 100755 (executable)
index 0000000..ef00892
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INITIALIZATION_ERROR_H_
+#define INITIALIZATION_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       error.h
+ * @brief      Definition of framework error codes for Initialization
+ */
+
+/** @addtogroup initialization
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of error codes for Initialization
+ */
+       typedef enum {
+               SYNC_AGENT_INIT_SUCCESS = 0,
+                       /**< Successful */
+               SYNC_AGENT_INIT_FAIL,
+                               /**< Fail */
+               SYNC_AGENT_INIT_PARSER_FAIL,
+                                       /**< Failed to parse the config file */
+               SYNC_AGENT_INIT_ENGINE_CONTROLLER_FAIL,
+                               /**< Failed to initialize the engine controller module */
+               SYNC_AGENT_INIT_SYNC_AGENT_EVENT_FAIL,
+                                               /**< Failed to initialize the event module */
+               SYNC_AGENT_INIT_COMMON_DB_FAIL,
+                       /**< Failed to initialize the common database module */
+               SYNC_AGENT_INIT_PLUGIN_FAIL,
+                                       /**< Failed to initialize the plugIn module */
+               SYNC_AGENT_INIT_SERVICE_DB_FAIL,/**< Failed to initialize the service module */
+               SYNC_AGENT_INIT_PM_FAIL,/**< Failed to initialize the platform monitor module */
+               SYNC_AGENT_INIT_DM_FAIL,/**< Failed to initialize the device manage module */
+               SYNC_AGENT_INIT_NETWORK_FAIL,
+                                       /**< Failed to initialize the network access module */
+               SYNC_AGENT_INIT_DEVICE_FAIL
+                                       /**< Failed to initialize the device module */
+       } sync_agent_init_error_e;
+
+/**
+ * @brief Enumerations of error codes for Deinitialization
+ */
+       typedef enum {
+               SYNC_AGENT_DEINIT_FAIL = -1,
+               SYNC_AGENT_DEINIT_SUCCESS = 0
+       } sync_agent_deinit_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INITIALIZATION_ERROR_H_ */
diff --git a/include/initialization/initialization.h b/include/initialization/initialization.h
new file mode 100755 (executable)
index 0000000..d071e82
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "interface.h"
+#include "error.h"
diff --git a/include/initialization/interface.h b/include/initialization/interface.h
new file mode 100755 (executable)
index 0000000..6b56311
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INITIALIZATION_INTERFACE_H_
+#define INITIALIZATION_INTERFACE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include "error.h"
+
+/**
+ * @file       interface.h
+ * @brief      Support to initialize framework for agent
+ */
+
+/** @addtogroup initialization
+ *     @{
+ */
+
+/**
+ * @brief      Initialization of Agent Framework
+ * @remarks    Framework will be initialized using by config file written by the agent developer.
+ * Initialization config file format is XML.
+ * @par Usage:
+ * @code
+ *
+ * const char *init_config_path = "/tmp/config_file";
+ * sync_agent_init_error_e init_error = sync_agent_init(init_config_path);
+ * if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+ *   ...
+ * }
+ *
+ * @endcode
+ * @param[in]  init_config_path framework init config file - XML format
+ * @return     SYNC_AGENT_INIT_SUCCESS on success, otherwise a error value.
+ * @retval     SYNC_AGENT_INIT_SUCCESS Successful
+ * @retval     SYNC_AGENT_INIT_PARSER_FAIL Parsing the initialization config file failed
+ * @retval     SYNC_AGENT_INIT_ENGINE_CONTROLLER_FAIL Engine controller Initialization failed
+ * @retval     SYNC_AGENT_INIT_SYNC_AGENT_EVENT_FAIL Event module Initialization failed
+ * @retval     SYNC_AGENT_INIT_COMMON_DB_FAIL CommonDataBase Initialization failed
+ * @retval     SYNC_AGENT_INIT_PLUGIN_FAIL PlugIn Initialization failed
+ * @retval     SYNC_AGENT_INIT_PM_FAIL PlatformMonitor Initialization failed
+ * @retval     SYNC_AGENT_INIT_DM_FAIL DeviceManagent Initialization failed
+ * @retval     SYNC_AGENT_INIT_NETWORK_FAIL NetworkAccess Initialization failed
+ * @retval     SYNC_AGENT_INIT_DEVICE_FAIL Device Initialization failed
+ * @pre                Has not been called before. This function should be called one time.
+ * @post       Framework is initialized as described in the file. Agent can use the Framework's function.
+ */
+       sync_agent_init_error_e sync_agent_init(const char *init_config_path);
+
+/**
+ * @brief      Deinitialization of Agent Framework
+ * @remarks Framework must be initialized using by config file written by the agent developer.
+ * @par Usage:
+ * @code
+ *
+ * const char *init_config_path = "/tmp/config_file";
+ * sync_agent_init_error_e init_error = sync_agent_init(init_config_path);
+ * if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+ *    ...
+ *   }
+ *   ...
+ * sync_agent_deinit_error_e deinit_error = sync_agent_deinit();
+ * if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS) {
+ *    ...
+ *   }
+ *
+ * @endcode
+ * @return     SYNC_AGENT_DEINIT_SUCCESS on success, SYNC_AGENT_DEINIT_FAIL on error
+ */
+       sync_agent_deinit_error_e sync_agent_deinit();
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* INITIALIZATION_INTERFACE_H_ */
diff --git a/include/network-access/common.h b/include/network-access/common.h
new file mode 100755 (executable)
index 0000000..eb8e15f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_COMMON_H_
+#define NETWORK_ACCESS_COMMON_H_
+
+#include "error.h"
+#include "property.h"
+#include "status.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file common.h
+ * @brief Support to send message  to the server
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for the type of sending message
+ */
+       typedef enum {
+               SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE = 0,             /**< general process */
+               SYNC_AGENT_NA_SEND_TYPE_JUST_SEND,                                      /**< specific process (send only) */
+       } sync_agent_na_send_type_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* NETWORK_ACCESS_COMMON_H_ */
diff --git a/include/network-access/error.h b/include/network-access/error.h
new file mode 100755 (executable)
index 0000000..836dd2e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_ERROR_H_
+#define NETWORK_ACCESS_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file error.h
+ * @brief Defines NACI errors
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for the NACI error
+ */
+       typedef enum {
+               SYNC_AGENT_NA_SUCCESS = 1,              /**< Successful */
+
+               SYNC_AGENT_NA_FAIL = -1000,             /**< Fail */
+
+               SYNC_AGENT_NA_NETWORK_UNAVAILABLE = -1001,      /**< Unavailable network */
+               SYNC_AGENT_NA_NETWORK_CHANGING = -1002,         /**< Network changing */
+               SYNC_AGENT_NA_INIT_FAIL = -1003,                        /**< Fail to initialize Network access module */
+               SYNC_AGENT_NA_OPEN_CONNECTION_FAIL = -1004,
+                                                       /**< Fail to Open connection */
+               SYNC_AGENT_NA_HEADER_BINDING_FAIL = -1005,      /**< Fail to bind header information */
+               SYNC_AGENT_NA_SEND_MSG_FAIL = -1006,            /**< Fail to send message */
+               SYNC_AGENT_NA_SEND_MSG_CANCEL = -1007,          /**< Cancel when message is sending */
+               SYNC_AGENT_NA_JUST_SEND_MSG_FAIL = -1008,       /**< Fail to send message for send only case */
+               SYNC_AGENT_NA_HEADER_UNBINDING_FAIL = -1009,
+                                                       /**< Fail to unbind header information */
+               SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL = -1010,
+                                                       /**< Fail to close connection */
+               SYNC_AGENT_NA_CANCEL_MSG_FAIL = -1011,          /**< Fail to cancel message */
+               SYNC_AGENT_NA_GET_HEADER_INFO_FAIL = -1012,     /**< Fail to get header information */
+               SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL = -1013,       /**< Fail to download data */
+
+               /* for http */
+               SYNC_AGENT_NA_TIME_OUT_SEND_MSG = -1100,        /**< Time out to send message */
+               SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN = -1101,       /**< Try to send message again*/
+               SYNC_AGENT_NA_ADD_AUTH_INFO_FAIL = -1102,       /**< Fail to add authentication information *//* EAS */
+               SYNC_AGENT_NA_UNTRUSTED_CERTIFICATE = -1103,
+                                                       /**< Untrusted certificate */
+
+       } sync_agent_na_result_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* NETWORK_ACCESS_ERROR_H_ */
diff --git a/include/network-access/external.h b/include/network-access/external.h
new file mode 100755 (executable)
index 0000000..36e448d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTERNAL_H_
+#define EXTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file external.h
+ * @brief Defines common network header setting
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Structure for the network protocol header information setting
+ * @remarks Key-value pair
+ */
+       typedef struct {
+               char *key;              /**< Key */
+               char *value;    /**< Value */
+       } sync_agent_na_common_header_info_s;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* EXTERNAL_H_ */
diff --git a/include/network-access/interface.h b/include/network-access/interface.h
new file mode 100755 (executable)
index 0000000..4eef044
--- /dev/null
@@ -0,0 +1,618 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_INTERFACE_H_
+#define NETWORK_ACCESS_INTERFACE_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#include "common.h"
+#include "external.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface.h
+ * @brief Defines network data communication APIs
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Open network connection (ex> create http session / create socket ...)
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] timeout Set user preferred time-out seconds used in sending message (ex> 30 : means 30sec)
+ * @param[out] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_OPEN_CONNECTION_FAIL Open connection failed
+ * @see sync_agent_close_connection
+ */
+       sync_agent_na_result_e sync_agent_open_connection(int na_plugin_id, int timeout, unsigned int *session_id);
+
+/**
+ * @brief Close network connection (ex> close http session / close socket ...)
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL Close connection failed
+ * @see sync_agent_open_connection
+ */
+       sync_agent_na_result_e sync_agent_close_connection(int na_plugin_id, unsigned int session_id);
+
+/**
+ * @brief Send message to server
+ * 1. Header binding for network protocol
+ * 2, Send message to server
+ * 3. Receive message from server
+ * 4. Divide header and body information from the received message
+ * @par Usage:
+ * @code
+ *
+ * #include "network-access/interface.h"
+ * #include "network-access/external.h"
+ *
+ * int main()
+ * {
+ *     sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ *     GList *header_list = NULL;
+ *     GList *recv_header = NULL;
+ *     char *send_msg = "xxxxxxx";
+ *     char *recv_msg = NULL;
+ *     unsigned int recv_msg_length = 0;
+ *     char *content_value = NULL;
+ *     unsigned int session_id = 0;
+ *     int na_plugIn_id;                               // defined each agent-config.xml files
+ *
+ *     char *ip = "http://xxx.xxx.xxx.xxx";
+ *     char *id = "abcd";
+ *     char *pw = "1234";
+ *
+ *     // open connection
+ *     res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *             ...
+ *     }
+ *
+ *     // add user authentication information - used if necessary
+ *     res = sync_agent_add_authentication_info(na_plugIn_id, id, pw, session_id);
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *             ...
+ *     }
+ *
+ *     // header binding - these elements are necessary to configure the header information !!
+ *                                                                     key : "method"  value : "options" / "get" / "head" / "post" / "put" / "delete" / "trace" / "connect"
+ *                                                                     key : "uri"                     value : ip address (ex> "http://xxx.xxx.xxx.xxx")
+ *     sync_agent_na_common_header_info_s *method = (sync_agent_na_common_header_info_s*)malloc(sizeof(sync_agent_na_common_header_info_s));
+ *     if (method == 0x00) {
+ *             ...
+ *     }
+ *     memset(method, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ *
+ *     method->key = "method";
+ *     method->value = "post";
+ *     header_list = g_list_append(header_list, method);
+ *
+ *     sync_agent_na_common_header_info_s *uri = (sync_agent_na_common_header_info_s*)malloc(sizeof(sync_agent_na_common_header_info_s));
+ *     if (uri == 0x00) {
+ *             ...
+ *     }
+ *     memset(uri, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ *
+ *     uri->key = "uri";
+ *     uri->value = ip;
+ *     header_list = g_list_append(header_list, uri);
+ *
+ *     // test - check header information
+ *     GList *iter = NULL;
+ *     for (iter = header_list; iter != NULL; iter = g_list_next(iter)) {
+ *             fprintf(stdout, "key : %s, \t value : %s\n", ((sync_agent_na_common_header_info_s*)(iter->data))->key, ((sync_agent_na_common_header_info_s*)(iter->data))->value);
+ *     }
+ *
+ *     // send message
+ *     res = sync_agent_send_msg(header_list,
+ *             na_plugIn_id,
+ *             send_msg,
+ *             strlen(send_msg),
+ *             &recv_header,
+ *             &recv_msg,
+ *             &recv_msg_length,
+ *             SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE,
+ *             session_id);
+ *
+ *     switch (res) {
+ *     case SYNC_AGENT_NA_SUCCESS :
+ *             break;
+ *     case SYNC_AGENT_NA_NETWORK_UNAVAILABLE :
+ *             ...
+ *             break;
+ *     case    SYNC_AGENT_NA_HEADER_BINDING_FAIL :
+ *             ...
+ *             break;
+ *     case SYNC_AGENT_NA_SEND_MSG_FAIL :
+ *             ...
+ *             break;
+ *     case SYNC_AGENT_NA_TIME_OUT_SEND_MSG :
+ *             ...
+ *             break;
+ *     case SYNC_AGENT_NA_SEND_MSG_CANCEL :
+ *             ...
+ *             break;
+ *     case SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN :
+ *             ...
+ *             break;
+ *     case SYNC_AGENT_NA_HEADER_UNBINDING_FAIL :
+ *             ...
+ *             break;
+ *     default :
+ *             break;
+ *     }
+ *
+ *     ...
+ *
+ *     // get header information
+ *     res = sync_agent_get_header_info(na_plugIn_id, recv_header, "Content", &content_value);
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ *     }
+ *
+ *     // free header information received from server
+ *     res = na_free_recv_header_info(recv_header);
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ *     }
+ *
+ *     // close connection
+ *     res = sync_agent_close_connection(na_plugIn_id, session_id);
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ *     }
+ *
+ *     // destroy NACI
+ *     res = sync_agent_destroy_netowk_access();
+ *     if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ *     }
+ *
+ *     return 0;
+ * }
+ * @endcode
+ * @param[in] header_info Header information that depending on the protocol type
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] send_msg Body message
+ * @param[in] send_msg_length Length of body message
+ * @param[out] recv_header Header information (key - value pair) of received message
+ * @param[out] recv_msg Body information of received message
+ * @param[out] recv_msg_length Length of received body message
+ * @param[in] send_type Type of send message
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_NETWORK_UNAVAILABLE Network Unavailable (fail to send message)
+ * @retval SYNC_AGENT_NA_HEADER_BINDING_FAIL Header binding failed
+ * @retval SYNC_AGENT_NA_SEND_MSG_FAIL Send message failed     - send_type : SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE
+ * @retval SYNC_AGENT_NA_TIME_OUT_SEND_MSG Send message failed (failure due to timeout) - send_type : SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE
+ * @retval SYNC_AGENT_NA_SEND_MSG_CANCEL Send message failed (failure due to cancel operation request) - send_type : SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE
+ * @retval SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN Send message failed (failure due to over the number of retries (3) for send message) - send_type : SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE
+ * @retval SYNC_AGENT_NA_JUST_SEND_MSG_FAIL Send message failed - send_type : JUST_SEND
+ * @retval SYNC_AGENT_NA_HEADER_UNBINDING_FAIL Header unbinding failed
+ * @retval SYNC_AGENT_NA_RECV_AT_CMD_FROM_PC_SYNC fail (receive AT command from KIES - mobex only)
+ * @see sync_agent_open_connection, sync_agent_close_connection
+ */
+       sync_agent_na_result_e sync_agent_send_msg(GList * header_info, int na_plugin_id, char *send_msg, unsigned int send_msg_length, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length, sync_agent_na_send_type_e send_type,
+                                                  unsigned int session_id);
+
+/**
+ * @brief Cancel operation about message being sent to the server
+ * @remarks This API is must called by other thread
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * GList *header_list = NULL;
+ * GList *recv_header = NULL;
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * char *send_msg = "xxxxxxx";
+ * char *recv_msg = NULL;
+ * unsigned int recv_msg_length = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_send_msg(header_list,
+ *     na_plugIn_id,
+ *     send_msg,
+ *     strlen(send_msg),
+ *     &recv_header,
+ *     &recv_msg,
+ *     &recv_msg_length,
+ *     SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE,
+ *     session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_cancel_msg(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_CANCEL_MSG_FAIL        Cancel message sending operation is failed
+ */
+       sync_agent_na_result_e sync_agent_cancel_msg(int na_plugin_id, unsigned int session_id);
+
+/**
+ * @brief Destroy Network Accesser instance
+ * @remarks Run only once at the end of the process
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ *     ...
+ *
+ *
+ * res = sync_agent_destroy_netowk_access();
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_FAIL Operation failed
+ * @pre The application should be called na_init_network_access() and returned SYNC_AGENT_NA_SUCCESS
+ */
+       sync_agent_na_result_e sync_agent_destroy_netowk_access(void);
+
+/**
+ * @brief Get network header information about specific keyword
+ * @par Usage:
+ * @code
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * GList *header_list = NULL;
+ * GList *recv_header = NULL;
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * char *send_msg = "xxxxxxx";
+ * char *recv_msg = NULL;
+ * unsigned int recv_msg_length = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_send_msg(header_list,
+ *     na_plugIn_id,
+ *     send_msg,
+ *     strlen(send_msg),
+ *     &recv_header,
+ *     &recv_msg,
+ *     &recv_msg_length,
+ *     SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE,
+ *     session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * res = sync_agent_get_header_info(na_plugIn_id, recv_header, "Content", &content_value);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] header_info List of network header information (key-value pair)
+ * @param[in] key Specific keyword of header information that user want to know
+ * @param[out] value Value for the key
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_GET_HEADER_INFO_FAIL Operation failed
+ * @pre The application should be called sync_agent_send_msg() and returned SYNC_AGENT_NA_SUCCESS
+ */
+       sync_agent_na_result_e sync_agent_get_header_info(int na_plugin_id, GList * header_info, char *key, char **value);
+
+/**
+ * @brief Check network status
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * int interval = 0;
+ * int retry_cnt = 1;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_check_network_status(interval, retry_cnt);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] interval Interval time for checking network status (ex> 3 : 3sec)
+ * @param[in] retry_cnt The number of retries for checking network status
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Network is available
+ * @retval SYNC_AGENT_NA_NETWORK_UNAVAILABLE Network is unavailable
+ */
+       sync_agent_na_result_e sync_agent_check_network_status(int interval, int retry_cnt);
+
+/**
+ * @brief Get connection type
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * int conn_type = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_get_connection_type(&conn_type);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[out] conn_type Current network connection type(sync_agent_na_network_connection_type_e)
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_FAIL Operation failed
+ */
+       sync_agent_na_result_e sync_agent_get_connection_type(int *conn_type);
+
+/**
+ * @brief Get connection state
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * int conn_state = 0;
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_get_connection_state(&conn_state);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[out] conn_state Current network connection state(sync_agent_na_network_connection_state_e)
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval     SYNC_AGENT_NA_FAIL Operation failed
+ */
+       sync_agent_na_result_e sync_agent_get_connection_state(int *conn_state);
+
+/**
+ * @brief Add user authentication information (id,  password) to session and
+ * register authentication callback for 'authenticate' signal
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ *
+ * char *id = "abcd";
+ * char *pw = "1234";
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_add_authentication_info(na_plugIn_id, id, pw, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] id User id
+ * @param[in] password User password
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_ADD_AUTH_INFO_FAIL Operation failed
+ */
+       sync_agent_na_result_e sync_agent_add_authentication_info(int na_plugin_id, char *id, char *password, unsigned int session_id);
+
+/**
+ * @brief              Get Status of Network Plugin
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * int na_plugIn_id;                           // defined each agent-config.xml files
+ * unsigned int session_id = 0;
+ * sync_agent_na_status_e status = SYNC_AGENT_NA_STATUS_RESPONSE_CODE;
+ *
+ *
+ * res = sync_agent_open_connection(na_plugIn_id, 300, &session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * res = sync_agent_get_status(na_plugIn_id, session_id, status);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ *
+ * res = sync_agent_close_connection(na_plugIn_id, session_id);
+ * if (res != SYNC_AGENT_NA_SUCCESS) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] session_id Session id
+ * @param[in] status sync_agent_na_status_e
+ * @return             operation result
+ * @retval             SYNC_AGENT_NA_SUCCESS                                                                   success
+ * @retval             SYNC_AGENT_NA_FAIL                                                                              fail
+ */
+       sync_agent_na_result_e sync_agent_get_status(int na_plugin_id, unsigned int session_id, sync_agent_na_status_e status, ...);
+
+/**
+ * @brief              Free common headr info structure
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ *
+ * GList *header_list = NULL;
+ *
+ *     ...
+ * // header binding - these elements are necessary to configure the header information !!
+ *     key : "method"  value : "options" / "get" / "head" / "post" / "put" / "delete" / "trace" / "connect"
+ *     key : "uri"                     value : ip address (ex> "http://xxx.xxx.xxx.xxx")
+ *
+ * sync_agent_na_common_header_info_s *method = (sync_agent_na_common_header_info_s*)malloc(sizeof(sync_agent_na_common_header_info_s));
+ * if (method == 0x00) {
+ *     ...
+ * }
+ * memset(method, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ *
+ * method->key = "method";
+ * method->value = "post";
+ *
+ *     ...
+ *
+ * sync_agent_free_na_common_header_info(method);
+ *
+ * @endcode
+ * @param[in] header_info http header key, value structure
+ * @return
+ */
+       void sync_agent_free_na_common_header_info(sync_agent_na_common_header_info_s * header_info);
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* NETWORK_ACCESS_INTERFACE_H_ */
diff --git a/include/network-access/network_access.h b/include/network-access/network_access.h
new file mode 100755 (executable)
index 0000000..d46461a
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "network_status.h"
+#include "external.h"
+#include "interface.h"
+#include "common.h"
+#include "error.h"
+#include "property.h"
+#include "status.h"
diff --git a/include/network-access/network_status.h b/include/network-access/network_status.h
new file mode 100755 (executable)
index 0000000..3aa5fab
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_STATUS_H_
+#define NETWORK_STATUS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file network_status.h
+ * sync-agent
+ */
+
+ /** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * sync-agent
+ */
+       typedef enum {
+               SYNC_AGENT_NA_NETWORK_UNKNOWN = 0,                                      /**< Initial network status */
+               SYNC_AGENT_NA_NETWORK_ON,                                                                       /**< Network connection */
+               SYNC_AGENT_NA_NETWORK_OFF,                                                                      /**< Network disconnection */
+               SYNC_AGENT_NA_NETWORK_CHANGE                                                    /**< Change ip/proxy information */
+       } sync_agent_na_network_status_e;
+
+/**
+ * sync-agent
+ */
+/*typedef enum {
+       NETWORK_NONE = 0,                                                       * initial network type
+       NETWORK_3G_ON,                                                          * network UMTS on
+       NETWORK_3G_OFF,                                                         * network UMTS off
+       NETWORK_WIFI_ON,                                                                * network WIFI on
+       NETWORK_WIFI_ON_NOT_CONNECTED,  * network WIFI on but not connected
+       NETWORK_WIFI_OFF,                                                               * network WIFI off
+       NETWORK_WIFI_3G_ON,                                                     * network UMTS and WIFI on
+} FW_NETWORK_TYPE;*/
+
+/**
+ * sync-agent
+ */
+       typedef enum {
+               SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN = -1,                     /**< Initial network connection type */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED = 0, /**< Disconnected */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI = 1,                                         /**< Wi-Fi is used for default connection */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR = 4,                     /**< Cellular is used for default connection */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET = 9,                     /**< Ethernet is used for default connection */
+       } sync_agent_na_network_connection_type_e;
+
+/**
+ * sync-agent
+ */
+       typedef enum {
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE = -1,                                                                       /**< Initial network connection state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED = 1,                                    /**< Deactivated WIFI state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED,                                               /**< Disconnected WIFI state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED,                                                  /**< Connected WIFI state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE = 4,     /**< Out of service */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_FLIGHT_MODE,                            /**< Flight mode */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_ROAMING_OFF,                            /**< Roaming is turned off */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE,    /**< Call is only available */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE,                                      /**< Available - not connected yet */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CONNECTED,                                      /**< Available - connected */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED = 10,               /**< Deactivated Ethernet state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED,                   /**< Disconnected Ethernet state */
+               SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED,                              /**< Connected Ethernet state */
+       } sync_agent_na_network_connection_state_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* NETWORK_STATUS_H_ */
diff --git a/include/network-access/property.h b/include/network-access/property.h
new file mode 100755 (executable)
index 0000000..35a8b09
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROPERTY_H_
+#define PROPERTY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file property.h
+ * @brief Defines NACI properties
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for the NACI property
+ */
+       typedef enum {
+               SYNC_AGENT_NA_PROP_TIMEOUT = 1,                         /**< Time out */
+               SYNC_AGENT_NA_PROP_RETRY_COUNT,                         /**< Retry count */
+       } sync_agent_na_property_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PROPERTY_H_ */
diff --git a/include/network-access/status.h b/include/network-access/status.h
new file mode 100755 (executable)
index 0000000..51557e2
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef STATUS_H_
+#define STATUS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file status.h
+ * @brief Defines NACI Status
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for the NACI Status
+ */
+       typedef enum {
+               SYNC_AGENT_NA_STATUS_RESPONSE_CODE = 1,                 /**< Response code */
+               SYNC_AGENT_NA_STATUS_ELAPSED_TIME,                              /**< Elapsed time */
+               SYNC_AGENT_NA_STATUS_CONNECT_TIME                               /**< Connect time */
+       } sync_agent_na_status_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* STATUS_H_ */
diff --git a/include/platform-monitor/common.h b/include/platform-monitor/common.h
new file mode 100755 (executable)
index 0000000..198e84d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_COMMON_H_
+#define PLATFORM_MONITOR_COMMON_H_
+
+#include <stdarg.h>
+#include "error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file common.h
+ * @brief Includes header files needed for using PMCI APIs
+ */
+
+/**
+ * Structure of required data to register the service
+ */
+       typedef struct {
+               char *pkg_name;
+                       /**< package name of agent that wish to use the service */
+               void *additional_data;
+                              /**< additional data for registration to the service */
+               void *user_data;
+                        /**< expansion data */
+       } sync_agent_pm_register_data_s;
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PLATFORM_MONITOR_COMMON_H_ */
diff --git a/include/platform-monitor/error.h b/include/platform-monitor/error.h
new file mode 100755 (executable)
index 0000000..f05d496
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_ERROR_H_
+#define PLATFORM_MONITOR_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file error.h
+ * @brief Defines PMCI errors
+ */
+
+/** @addtogroup platform_monitor
+ *     @{
+ */
+
+/**
+ * Enumerations for the PMCI error
+ */
+       typedef enum {
+               SYNC_AGENT_PM_SUCCESS,
+                              /**< operation success */
+               SYNC_AGENT_PM_FAIL,
+                           /**< operation error */
+       } sync_agent_pm_return_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PLATFORM_MONITOR_ERRORS_H_ */
diff --git a/include/platform-monitor/interface.h b/include/platform-monitor/interface.h
new file mode 100755 (executable)
index 0000000..150b68b
--- /dev/null
@@ -0,0 +1,247 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_INTERFACE_H_
+#define PLATFORM_MONITOR_INTERFACE_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface.h
+ * @brief Defines service platform notification APIs
+ */
+
+/** @addtogroup platform_monitor
+ *     @{
+ */
+
+/**
+ * Prototype of callback function for service notification
+ * @remarks This callback function must be implemented by user
+ *
+ * @param[in] item_id item id (It is only used in ALARM service)
+ * @param[in] user_data data that is passed to the user from service
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef int (*sync_agent_specific_type_cb) (int data_id, void *user_data);
+
+/**
+ * API to register user notification callback function to the specific service
+ * @remarks Connect to the service and register user notification callback function to the service
+ *
+ * @par Usage:
+ * @code
+               1. alarm service
+               int alarm_callback(int item_id, void *user_data)
+               {
+               }
+               ...
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               int alarm_plugin_id = 0;
+               void *data = NULL;
+               ...
+               ret = sync_agnet_register_user_callback(alarm_plugin_id, data, 1, alarm_callback);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+
+               2. wap push service
+               int san_incoming_callback(int item_id, void *user_data)
+               {
+               }
+
+               int san_operation_callback(int item_id, void *user_data)
+               {
+               }
+               ...
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               int wap_push_plugin_id = 0;
+               void *data = NULL;
+               ...
+               ret = sync_agnet_register_user_callback(wap_push_plugin_id, data, 2, san_incoming_callback, san_operation_callback);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] pm_plugin_id platform monitor plugin id
+ * @param[in] user_data some data for passing to the service
+ * @param[in] callback_cnt the number of callback functions
+ * @param[in] ... variable number of callback functions (type : 'sync_agent_specific_type_cb')
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agnet_register_user_callback(int, const char *, int, ...)
+ *
+ */
+       sync_agent_pm_return_e sync_agnet_register_user_callback(int pm_plugin_id, const char *user_data, int callback_cnt, ...);
+
+/**
+ * API to unregister user notification callback function that was previously registered to the service and disconnect to the service
+ * @remarks The application should be called sync_agnet_register_user_callback() and returned SYNC_AGENT_PM_SUCCESS
+ *
+ * @par Usage:
+ * @code
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               int plugin_id = 0;
+               ...
+               ret = sync_agent_unregister_service_noti(plugin_id);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] pm_plugin_id platform monitor plugin id
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_unregister_service_noti(int)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_unregister_service_noti(int pm_plugin_id);
+
+/**
+ * API to add item to the service that was previously initialized by user using 'sync_agnet_register_user_callback()'
+ * @remarks The application should be called sync_agnet_register_user_callback() and returned SYNC_AGENT_PM_SUCCESS
+ *
+ * @par Usage:
+ * @code
+               int plugin_id = 0;
+               void *add_data = NULL;
+               int added_data_id = 0;
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               ...
+               ret = sync_agent_add_service_data(plugin_id, add_data, &added_data_id);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] pm_plugin_id platform monitor plugin id
+ * @param[in] add_data item to add to the service
+ * @param[in] added_data_id id of the newly item added to the service
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_add_service_data(int, void *, int *)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_add_service_data(int pm_plugin_id, void *add_data, int *added_data_id);
+
+/**
+ * API to remove item from the service
+ * @remarks The application should be called sync_agnet_register_user_callback() and returned SYNC_AGENT_PM_SUCCESS
+ *
+ * @par Usage:
+ * @code
+               int plugin_id = 0;
+               int remove_data_id = 0;
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               ...
+               ret = sync_agent_remove_service_data(plugin_id, remove_data_id);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] pm_plugin_id platform monitor plugin id
+ * @param[in] remove_data_id id of item that user want to remove from service
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_pm_return_e sync_agent_remove_service_data(int pm_plugin_id, int remove_data_id);
+
+/**
+ * API to get item that user want to know from the service
+ * @remarks The application should be called sync_agnet_register_user_callback() and returned SYNC_AGENT_PM_SUCCESS
+ *
+ * @par Usage:
+ * @code
+               int plugin_id = 0;
+               int get_data_id = 0;
+               void *service_data = NULL;
+               sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+               ...
+               ret = sync_agent_get_service_data(plugin_id, get_data_id, &service_data);
+               if (ret != SYNC_AGENT_PM_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] pm_plugin_id platform monitor plugin id
+ * @param[in] get_data_id id of the data that user want to know
+ * @param[in] service_data as returned by sync_agent_get_service_data() - data that user want to know
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_service_data(int, int, void **)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_get_service_data(int pm_plugin_id, int get_data_id, void **service_data);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PLATFORM_MONITOR_INTERFACE_H_ */
diff --git a/include/platform-monitor/platform_monitor.h b/include/platform-monitor/platform_monitor.h
new file mode 100755 (executable)
index 0000000..141864a
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "interface.h"
+#include "common.h"
+#include "error.h"
diff --git a/include/plugin/account_interface.h b/include/plugin/account_interface.h
new file mode 100755 (executable)
index 0000000..7bfd4c0
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACCOUNT_INTERFACE_H_
+#define ACCOUNT_INTERFACE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file account_interface.h
+ * @brief      Interface list in this header will be implemented plugIn developer
+ * @remarks Implementation will operate sync-agent-framework account module
+ */
+
+/** @addtogroup plugin_account Account Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to set account repository name
+ * @remarks Repository means mapping storage, between service account id and sync-agent-framework account id
+ *
+ * @param[in] agent_name repository name - described in fw config xml file <Agent-Key>
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_init(const char *)
+ *
+ */
+       void sync_agent_plugin_set_account_repository_name(const char *agent_name);
+
+/**
+ * API to add account to platform
+ * @remarks    Mapping platform account id with sync-agent-framework account id
+ *
+ * @param[in] fw_account_id    sync-agent-framework account id
+ *
+ * @par Since:
+ *
+ *
+ * @see acc_add_platform_account(int)
+ *
+ */
+       void sync_agent_plugin_add_platform_account(int fw_account_id);
+
+/**
+ * API to set mapping relationship between sync-agent-framework account id and service account id
+ * @remarks You must register non-volatile storage not memory ex) File, DataBase..
+ *
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in]  service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in]  service_account_id service account id
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_construct_account_tbl_from_service()
+ */
+       void sync_agent_plugin_set_platform_account_service(int fw_account_id, int service_type, int service_account_id);
+
+/**
+ * API to remove mapping relationship between sync-agent-framework account id and platform account id
+ * @remarks You must remove from storage
+ *
+ * @param[in] fw_account_id sync-agent-framework account id
+ *
+ * @par Since:
+ *
+ *
+ * @see acc_delete_platform_account(int)
+ *
+ */
+       void sync_agent_plugin_delete_platform_account(int fw_account_id);
+
+/**
+ * API to remove mapping relationship between sync-agent-framework account id and service account id
+ * @remarks You must remove from storage
+ *
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_construct_account_tbl_from_service()
+ *
+ */
+       void sync_agent_plugin_delete_platform_account_service(int fw_account_id, int service_type);
+
+/**
+ * API to confirm whether sync-agent-framework account id has the service account id
+ *
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in]  service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ *
+ * @return 1 if has, otherwise 0
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_construct_account_tbl_from_service()
+ *
+ */
+       int sync_agent_plugin_has_platform_account_service(int fw_account_id, int service_type);
+
+/**
+ * API to get service account id mapped with sync-agent-framework account id
+ *
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in]  fw_account_id   sync-agent-framework account id
+ *
+ * @return service account id if it exist mapping relationship, otherwise -100
+ *
+ * @par Since:
+ *
+ *
+ * @see acc_get_service_account_id(int, int)
+ *
+ */
+       int sync_agent_plugin_get_service_account_id(int service_type, int fw_account_id);
+
+/**
+ * API to get sync-agent-framework account id mapped with service account id
+ *
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] service_account_id service account id
+ * @param[in]  index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
+ *
+ * @return sync-agent-framework account id if it exist mapping relationship, otherwise -1
+ *
+ * @par Since:
+ *
+ *
+ * @see acc_get_fw_account_id(int, int, int)
+ *
+ */
+       int sync_agent_plugin_get_fw_account_id(int service_type, int service_account_id, int index);
+
+/**
+ * API to get service account information
+ * @remarks    Account information type must be defined in account plugin.
+ *
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] account_info as returned by sync_agent_plugin_get_service_account_info()
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see acc_get_fw_account_id(int, int, int)
+ *
+ */
+       int sync_agent_plugin_get_service_account_info(int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ACCOUNT_INTERFACE_H_ */
diff --git a/include/plugin/data_connector_interface.h b/include/plugin/data_connector_interface.h
new file mode 100755 (executable)
index 0000000..b2cc894
--- /dev/null
@@ -0,0 +1,560 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONNECTOR_INTERFACE_H_
+#define DATA_CONNECTOR_INTERFACE_H_
+
+#include "data-adapter/error.h"
+
+#include "data_connector_resource.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file data_connector_interface.h
+ * @brief      Interface list in this header will be implemented plugIn developer.
+ * @remarks Implementation will operate sync-agent-framework data-adapter module.
+ */
+
+/** @addtogroup plugin_dataconnector DataConnector Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to connect(open) to the service
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_open_service()
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_open_service(void);
+
+/**
+ * API to disconnect(close) to the service
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_close_service()
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_close_service(void);
+
+/**
+ * API to start transaction for service storage
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_begin_transaction()
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_begin_transaction(void);
+
+/**
+ * API to end transaction for service storage
+ *
+ * @param[in] is_success flag to decide commit/rollback        (1:commit, 0:rollback)
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_end_transaction(int)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_end_transaction(int is_success);
+
+/**
+ * API to insert item into service storage
+ *
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] data data to add to the service
+ * @param[in] item_id as returned by sync_agent_plugin_add_item() - success : id of the newly item added to the service, error : NULL
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_add_item(int, char *, void *, char **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id);
+
+/**
+ * API to update item from service storage
+ *
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] item_id service item id
+ * @param[in] data data to update to the service
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_update_item(int, char *, char *, void *)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data);
+
+/**
+ * API to delete item from service storage
+ *
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in]  item_id service id of item expected to be deleted
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_delete_item(int, char *, char *)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id);
+
+/**
+ * API to delete all items from service storage
+ *
+ * @param[in] account_id service account id
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_delete_all_items(int)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id);
+
+/**
+ * API to get item from service storage
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  folder_id service folder id
+ * @param[in]  item_id expected to get service item id
+ * @param[in]  data as returned by sync_agent_plugin_get_item() - success : item info, error : NULL
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_item(int, char *, char *, void **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data);
+
+/**
+ * API to insert folder into service storage
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  folder_name folder name
+ * @param[in] folder_type folder type
+ * @param[in] folder_id as returned by sync_agent_plugin_add_folder() - success : id of the newly folder added to the service, fail : NULL
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_add_folder(int, char *, int, char **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id);
+
+/**
+ * API to delete folder from service storage
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  folder_id service folder id
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_delete_folder(int, char *)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id);
+
+/**
+ * API to get folder info from service storage
+ *
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in]  out_folder_name as returned by sync_agent_plugin_get_folder() - success : folder name, fail : NULL
+ * @param[in]  out_folder_type as returned by sync_agent_plugin_get_folder() - success : folder type, fail : -1
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_folder(int, char *, char **, int *)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type);
+
+/**
+ * API to execute data into service
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  execute_key execute key
+ * @param[in]  execute_values execute values
+ * @param[in]  result as returned by sync_agent_plugin_execute() -     extension result info
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_execute(int, const char *, void *, void **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_execute(int account_id, const char *execute_key, void *execute_values, void **result);
+
+/**
+ * API to get item used count
+ *
+ * @return current_item_count on success, negative value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_used_item_count()
+ *
+ */
+       int sync_agent_plugin_get_used_item_count(void);
+
+/**
+ * API to get item used count for folder
+ *
+ * @param[in] account_id service account id
+ * @param[in]  folder_id service folder id
+ *
+ * @return current_item_count on success, negative value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_used_item_count_for_folder(int, char *)
+ *
+ */
+       int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id);
+
+/**
+ * API to get folder id list of a account
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  folder_count as returned by sync_agent_plugin_get_folder_id_list() - success : folder count,    fail or not exist : 0
+ * @param[in] folder_type_list as returned by sync_agent_plugin_get_folder_id_list() - success : list, fail or not exist : NULL
+ *
+ * @return folder_id_list on success, NULL on error or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_folder_id_list(int, int *, int **)
+ *
+ */
+       char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list);
+
+/**
+ * API to get all account id list that service has currently
+ *
+ * @param[in] count as returned by sync_agent_plugin_get_account_id_list() - success : count of account id,    fail or not exist : 0
+ * @return account_id_list on success, NULL on fail or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_account_id_list(int *)
+ *
+ */
+       int *sync_agent_plugin_get_account_id_list(int *count);
+
+/**
+ * API to write data store items to file
+ *
+ * @param[in] account_id service account id
+ * @param[in] file_path as returned by sync_agent_plugin_backup_service_items_to_file() - written file path
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, minus value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_backup_service_items_to_file(int, char **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_backup_service_items_to_file(int account_id, char **file_path);
+
+/**
+ * API to add file wrote item to data store
+ *
+ * @param[in] account_id service account id
+ * @param[in] file_path file path
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, minus value on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_restore_service_items_from_file(int, const char *)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_restore_service_items_from_file(int account_id, const char *file_path);
+
+/**
+ * API to get added item list after specific point
+ *
+ * @param[in] account_id service account id
+ * @param[in]  folder_id service folder id
+ * @param[in]  changepoint     specific point
+ * @param[in] changeCount as returned by sync_agent_plugin_get_changed_item_for_folder_add() - success : added item count, fail or not exist : NULL
+ *
+ * @return added_item_info_list (if exist) on success, NULL on error or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_changed_item_for_folder_add(int, const char *, int, int *)
+ *
+ */
+       sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int changepoint, int *changeCount);
+
+/**
+ * API to get deleted item list after specific point
+ *
+ * @param[in] account_id service account id
+ * @param[in]  folder_id service folder id
+ * @param[in]  changepoint specific point
+ * @param[in]  changeCount     as returned by sync_agent_plugin_get_changed_item_for_folder_delete() - success : deleted item count, fail or not exist : NULL
+ *
+ * @return deleted_item_info_list      (if exist) on success, NULL on error or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_changed_item_for_folder_delete(int, const char *, int, int *)
+ *
+ */
+       sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int changepoint, int *changeCount);
+
+/**
+ * API to get updated item list after specific point
+ *
+ * @param[in]  account_id service account id
+ * @param[in]  folder_id service folder id
+ * @param[in]  changepoint specific point
+ * @param[in]  changeCount as returned by sync_agent_plugin_get_changed_item_for_folder_update() - success : updated item count, fail or not exist : NULL
+ *
+ * @return updated_item_info_list      (if exist) on success, NULL on error or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_changed_item_for_folder_update(int, const char *, int, int *)
+ *
+ */
+       sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int changepoint, int *changeCount);
+
+/**
+ * API to get last storage change point information
+ *
+ * @return last storage changing point information on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_last_change_point()
+ *
+ */
+       int sync_agent_plugin_get_last_change_point(void);
+
+/**
+ * API to check notification for the storage change
+ *
+ * @param[in] data user data
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_start_listening_change_noti(void *)
+ *
+ */
+       void sync_agent_plugin_start_listening_change_noti(void *data);
+
+/**
+ * API to set callback function to handle added item to storage
+ *
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ *
+ * @par Since:
+ *
+ *
+ * @see data_connector_resource.h
+ *
+ */
+       void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback);
+
+/**
+ * API to set callback function to handle deleted item to storage
+ *
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ *
+ * @par Since:
+ *
+ *
+ * @see data_connector_resource.h
+ *
+ */
+       void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback);
+
+/**
+ * API to set callback function to handle updated item to storage
+ *
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ *
+ * @par Since:
+ *
+ *
+ * @see data_connector_resource.h
+ *
+ */
+       void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback);
+
+/**
+ * API to set callback function to get service account id list mapped sync-agent-framework account id
+ *
+ * @param[in]  callback callback function - this function is provided from sync-agent-framework
+ *
+ * @par Since:
+ *
+ *
+ * @see data_connector_resource.h
+ *
+ */
+       void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback);
+
+/**
+ * API to get max item count per folder
+ *
+ * @param[in] folder_type folder type provided plugin
+ *
+ * @return max item count on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_max_item_count(int)
+ */
+       int sync_agent_plugin_get_max_item_count(int folder_type);
+
+/**
+ * API to get service data's available field length
+ *
+ * @param[in] field_name field_name provided data-connector plugin
+ * @param[in]  child_field_name child field name provided data-connector plugin
+ *
+ * @return available_field_length      on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_max_field_length(int, int)
+ *
+ */
+       int sync_agent_plugin_get_max_field_length(int field_name, int child_field_name);
+
+/**
+ * API to get service data's available field count
+ *
+ * @param[in] field_name field_name provided data-connector plugin
+ * @param[in]  child_field_name child field name provided data-connector plugin
+ *
+ * @return available_field_count on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_max_field_count(int, int)
+ *
+ */
+       int sync_agent_plugin_get_max_field_count(int field_name, int child_field_name);
+
+/**
+ * API to get service data's available field value's domain
+ *
+ * @param[in]  field_name field name provided data-connector plugin
+ * @param[in]  child_field_name child field name provided data-connector plugin
+ * @param[in]  str_val as returned by sync_agent_plugin_get_field_value() - when domain value is string
+ * @param[in]  num_val1 as returned by sync_agent_plugin_get_field_value() - when domain value is integer (ex minimum value)
+ * @param[in]  num_val2 as returned by sync_agent_plugin_get_field_value() - when domain value is integer (ex maximum value)
+ *
+ * @return 1 on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_field_value(int, int, char **, int *, int *)
+ *
+ */
+       int sync_agent_plugin_get_field_value(int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2);
+
+/**
+ * API to get service data's available field count
+ *
+ * @param[in]  feature feature provided data-connector plugin
+ *
+ * @return 1 : support, 0 : not support on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_get_is_support_feature(int)
+ *
+ */
+       int sync_agent_plugin_get_is_support_feature(int feature);
+
+/**
+ *     @}
+ */
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DATA_CONNECTOR_INTERFACE_H_ */
diff --git a/include/plugin/data_connector_resource.h b/include/plugin/data_connector_resource.h
new file mode 100755 (executable)
index 0000000..ffb76de
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONNECTOR_RESOURCE_H_
+#define DATA_CONNECTOR_RESOURCE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file data_connector_resource.h
+ * @brief      Item id list container & callback functions for item change notification
+ * @remarks Implementation will operate sync-agent-framework data-adapter module
+ */
+
+/** @addtogroup plugin_dataconnector DataConnector Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * Structure of Item ID Node - Linked List
+ */
+       struct sync_agent_plugin_item_node_s {
+               char *item_id;
+                      /**< item id */
+               struct sync_agent_plugin_item_node_s *next;
+                                                   /**< next pointer */
+       };
+
+       typedef struct sync_agent_plugin_item_node_s sync_agent_plugin_item_node_s;
+
+/**
+ * Function which is called at some plugin (calendar, contact, memo) when new item is added to the service
+ *
+ * @param[in] account_id service account id
+ * @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
+ * @param[in] item_id service item id
+ * @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] folder_id service folder id
+ * @param[in] folder_type folder type defined in data-connector plugin
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin)
+ *
+ */
+       typedef int (*sync_agent_add_item_cb_plugin) (int account_id, int index, char *item_id, int item_type, char *folder_id, int folder_type);
+
+/**
+ * Function which is called at some plugin (calendar, contact, memo) when existing item is deleted to the service
+ *
+ * @param[in] account_id service account id
+ * @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
+ * @param[in] item_id service item id
+ * @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin)
+ *
+ */
+       typedef int (*sync_agent_del_item_cb_plugin) (int account_id, int index, char *item_id, int item_type);
+
+/**
+ * Function which is called at some plugin (calendar, contact, memo) when existing item is updated to the service
+ *
+ * @param[in] account_id service account id
+ * @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
+ * @param[in] item_id service item id
+ * @param[in] item_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin)
+ *
+ */
+       typedef int (*sync_agent_update_item_cb_plugin) (int account_id, int index, char *item_id, int item_type);
+
+/**
+ * Function which is called at some plugin (calendar, contact, memo) when need service account id list concerned of service_type
+ *
+ * @param[in] service_type service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] cnt as returned by sync_agent_get_account_id_list_cb_plugin() - count of account id
+ *
+ * @return account_id_list on success, NULL on error or not exist
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin)
+ *
+ */
+       typedef int *(*sync_agent_get_account_id_list_cb_plugin) (int service_type, int *cnt);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DATA_CONNECTOR_RESOURCE_H_ */
diff --git a/include/plugin/data_converter_interface.h b/include/plugin/data_converter_interface.h
new file mode 100755 (executable)
index 0000000..7877372
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONVERTER_INTERFACE_H_
+#define DATA_CONVERTER_INTERFACE_H_
+
+#include "data-adapter/error.h"
+
+#include "data_converter_resource.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file data_converter_interface.h
+ * @brief      Interface list in this header will be implemented plugIn developer.
+ *  Implementation will operate DataAdapter module.
+ */
+
+/** @addtogroup plugin_dataconverter DataConverter Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to convert agent type data to service structure format data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ *
+ * @param[in]  agent_data agent data
+ * @param[in]  service_data as returned by sync_agent_plugin_converter() - created service data
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, SYNC_AGENT_DA_ERRORS on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_add_service_item(sync_agent_da_service_item_s *, char **, bool)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data);
+
+/**
+ * API to convert result of the merge agent data with old service data to service structure format data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ *
+ * @param[in]  old_service_data old service data
+ * @param[in]  agent_data agent data
+ * @param[in]  new_service_data as returned by sync_agent_plugin_replace_converter() - created service data
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, SYNC_AGENT_DA_ERRORS on error
+ *
+ * @par Since:
+ *
+ * @see sync_agent_update_service_item(sync_agent_da_service_item_s *, char *, bool)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data);
+
+/**
+ * API to convert service structure format data to agent type data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ *
+ * @param[in]  service_data created service data
+ * @param[in]  agent_data as returned by sync_agent_plugin_reverse_converter() - agent data
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, SYNC_AGENT_DA_ERRORS on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_service_item(char *, sync_agent_da_service_item_s **)
+ *
+ */
+       sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data);
+
+/**
+ * API to allocate internal object for content type
+ *
+ * @return internal_struct_pointer on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_alloc_obj(int)
+ *
+ */
+       void *sync_agent_plugin_alloc_object(void);
+
+/**
+ * API to free internal object for content type
+ *
+ * @param[in] in_object internal object pointer
+ *
+ * @return SYNC_AGENT_DA_SUCCESS on success, SYNC_AGENT_DA_ERRORS on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_obj(int content_type, void *)
+ *
+ */
+       int sync_agent_plugin_free_object(void *in_object);
+
+/**
+ * API to set value for internal object
+ *
+ * @param[in]  in_object internal object pointer
+ * @param[in]  key key
+ * @param[in]  extension_key extension key
+ * @param[in]  set_value value
+ *
+ * @return new object pointer on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_value_to_obj(int, void *, int, char *, void *)
+ *
+ */
+       void *sync_agent_plugin_set_value(void *in_object, int key, char *extension_key, void *set_value);
+
+/**
+ * API to get value for specific key
+ *
+ * @param[in] in_object internal object pointer
+ * @param[in]  key key
+ * @param[in]  extension_key extension key
+ *
+ * @return value pointer on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_value_to_obj(int, void *, int, char *)
+ *
+ */
+       void *sync_agent_plugin_get_value(void *in_object, int key, char *extension_key);
+
+/**
+ * API to get meta information of internal object
+ *
+ * @return value pointer on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_obj_info(int)
+ *
+ */
+       sync_agent_plugin_object_info_s *sync_agent_plugin_get_obj_info(void);
+
+/**
+ * API to free information of internal object
+ *
+ * @param[in]  obj_info object info
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_obj_info(int, sync_agent_plugin_object_info_s *)
+ *
+ */
+       int sync_agent_plugin_free_obj_info(sync_agent_plugin_object_info_s * obj_info);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DATA_CONVERTER_INTERFACE_H_ */
diff --git a/include/plugin/data_converter_resource.h b/include/plugin/data_converter_resource.h
new file mode 100755 (executable)
index 0000000..957c496
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONVERTER_RESOURCE_H_
+#define DATA_CONVERTER_RESOURCE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file data_converter_resource.h
+ * @brief      Support to share structure DataConverter plugIn with sync-agent-framework
+ */
+
+/** @addtogroup plugin_dataconverter DataConverter Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * Structure of Converter plugin's object's field - linked list
+ */
+       struct sync_agent_plugin_field_info {
+               char *field_name;       /**< field name */
+               int field_child_cnt;    /**< field's child count */
+               struct sync_agent_plugin_field_info *field_child_list;  /**< next field info node */
+       };
+
+/**
+ * Structure of Converter plugin's Object info
+ */
+       typedef struct {
+               char *type;     /**< object type */
+               char *version;
+                       /**< object version */
+               int field_cnt;  /**< field count */
+               struct sync_agent_plugin_field_info *field_list;        /**< real field list **/
+       } sync_agent_plugin_object_info_s;
+
+       typedef struct sync_agent_plugin_field_info sync_agent_plugin_field_info_s;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DATA_CONVERTER_RESOURCE_H_ */
diff --git a/include/plugin/device_info_interface.h b/include/plugin/device_info_interface.h
new file mode 100755 (executable)
index 0000000..2cec2ef
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_INFO_INTERFACE_H_
+#define DEVICE_INFO_INTERFACE_H_
+
+#include <glib.h>
+#include <stdarg.h>
+
+#include "device/common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file device_info_interface.h
+ * @brief Defines plug-in interfaces about device information
+ */
+
+/** @addtogroup plugin_deviceinfo DeviceInfo Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * Device information structure
+ * @remarks This structure is member of list (devInfo)
+ * Key(info_name) - value(value) pair
+ */
+       typedef struct {
+               char *info_name;
+               char *value;
+       } sync_agent_plugin_device_info_s;
+
+/**
+ * API to get device information in the system and load this information on the memory
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see dev_init_dev(int)
+ */
+       int sync_agent_plugin_load_devinfo(void);
+
+/**
+ * API to get device information on the memory that user want to know
+ *
+ * @param[in] info_name name of device information
+ * @param[in] value as returned by sync_agent_plugin_get_devinfo() - value of device information
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_devinfo(int, char *, char **)
+ *
+ */
+       int sync_agent_plugin_get_devinfo(char *info_name, char **value);
+
+/**
+ * API to clear device information on the memory (free memory)
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see dev_destroy_dev(int)
+ *
+ */
+       int sync_agent_plugin_clear_devinfo(void);
+
+/**
+ * API to execute device function
+ *
+ * @param[in] function_name name of device function
+ * @param[in] args_cnt number of following parameters
+ * @param[in] ap varius type of parameters
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_execute_dev_function(int, char *, int, ...)
+ *
+ */
+       int sync_agent_plugin_execute_dev_function(char *function_name, int args_cnt, va_list ap);
+
+/**
+ * API to set function pointer of common type API which fetches device info
+ *
+ * @param[in] func function pointer to set
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_plugin(xmlNode *)
+ *
+ */
+       void sync_agent_plugin_set_common_devinfo_function(sync_agent_get_devinfo_cb func);
+
+/**
+ * API to set function pointer of common type API which executes device function
+ *
+ * @param[in] func function pointer to set
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_plugin(xmlNode *)
+ *
+ */
+       void sync_agent_plugin_set_common_execute_dev_function(sync_agent_execute_dev_cb func);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_INFO_INTERFACE_H_ */
diff --git a/include/plugin/device_manager_interface.h b/include/plugin/device_manager_interface.h
new file mode 100755 (executable)
index 0000000..9de4992
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_MANAGER_INTERFACE_H_
+#define DEVICE_MANAGER_INTERFACE_H_
+
+#include "device-manager/mdm_control_code.h"
+#include "device-manager/mdm_error.h"
+#include "device-manager/mdm_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file device_manager_interface.h
+ * @brief Defines plug-in interfaces about device manager
+ */
+
+/** @addtogroup plugin_devicemanager DeviceManager Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to register client to the service
+ *
+ * @param[in] pkg_name client package name
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_start_mdm_service(int, char *)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_start_service(char *pkg_name);
+
+/**
+ * API to deregister client to the service
+ * @remarks client should be called sync_agent_plugin_start_service() and returned SYNC_AGENT_DM_MDM_SUCCEEDED
+ *
+ * @param[in] pkg_name client package name
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see  sync_agent_stop_mdm_service(int, char *)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_stop_service(char *pkg_name);
+
+/**
+ * API to set user value to the service
+ *
+ * @param[in] ctrl item that user want to set
+ * @param[in] va user value
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_mdm_value(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_set_device_manager_value(sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * API to get value that user want to know
+ *
+ * @param[in] ctrl item that user want to know
+ * @param[in] va as returned by sync_agent_plugin_get_device_manager_value() - service value
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_mdm_value(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_get_device_manager_value(sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * API to execute service that user want to do
+ *
+ * @param[in] ctrl item that user want to execute
+ * @param[in] va user value
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_execute_mdm(int, sync_agent_dm_mdm_ctrl_e, ...)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_execute_device_manager(sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * API to register user callback function for each service event
+ * @remarks not supported api
+ *
+ * @param[in] event service event
+ * @param[in] callback user callback function
+ * @param[in] userdata additional user data
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see dm_register_mdm_callback(int, sync_agent_dm_mdm_event_e, sync_agent_device_manager_cb, void *)
+ *
+ */
+       int sync_agent_plugin_register_device_manager_cb(sync_agent_dm_mdm_event_e event, sync_agent_device_manager_cb callback, void *userdata);
+
+/**
+ * API to deregister user callback function that was previously registered to the service
+ * @remarks not supported api
+ *
+ * @param[in] handle
+ *
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see dm_register_deregister_mdm_callback(int, int)
+ *
+ */
+       sync_agent_dm_mdm_return_e sync_agent_plugin_deregister_device_manager_cb(int handle);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEVICE_MANAGER_INTERFACE_H_ */
diff --git a/include/plugin/mo_interface.h b/include/plugin/mo_interface.h
new file mode 100755 (executable)
index 0000000..1b3d560
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_INTERFACE_H_
+#define MO_INTERFACE_H_
+
+#include "device/information.h"
+#include "device/error.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file mo_interface.h
+ * @brief Defines plug-in interfaces about mo
+ */
+
+/** @addtogroup plugin_mo MO Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to get server id list
+ *
+ * @param[in] server_id_list_cnt count of server id list
+ *
+ * @return server_id_list on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_construct_mo_table(sync_agent_dm_mo_type_e, const char *, int, int)
+ *
+ */
+       char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt);
+
+/**
+ * API to get mo value that user want to know
+ *
+ * @param[in] mo_full_path mo full path
+ * @param[in] mo_name mo name corresponding to the value that user want to know
+ * @param[in] mo_value as returned by sync_agent_plugin_get_mo_value() - mo value
+ *
+ * @return 0 on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_construct_mo_table(sync_agent_dm_mo_type_e, const char *, int, int), sync_agent_uptodate_mo_table(sync_agent_dm_mo_type_e, int, char *)
+ *
+ */
+       int sync_agent_plugin_get_mo_value(const char *mo_full_path, const char *mo_name, char **mo_value);
+
+/**
+ * API to set function pointer for getting device information
+ *
+ * @param[in] func callback function for getting device information
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_device_manage(xmlNode *)
+ *
+ */
+       void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func);
+
+/**
+ * API to execute device function
+ *
+ * @param[in] mo_path mo path
+ * @param[in] err_num as returned by sync_agent_plugin_execute_ext() - error number
+ * @param[in] check_operation setting value for sync / async operation
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_execute_mo_ext(const char *, int *, int)
+ *
+ */
+       int sync_agent_plugin_execute_ext(const char *mo_path, int *err_num, int check_operation);
+
+/**
+ * API to initialize mo related service
+ *
+ * @return 1 on success, -1 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_initialize_mo(int)
+ *
+ */
+       int sync_agent_plugin_initialize();
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_INTERFACE_H_ */
diff --git a/include/plugin/network_access_interface.h b/include/plugin/network_access_interface.h
new file mode 100755 (executable)
index 0000000..352ea0f
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_INTERFACE_H_
+#define NETWORK_ACCESS_INTERFACE_H_
+
+#include <glib.h>
+#include "network-access/property.h"
+#include "network-access/status.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file network_access_interface.h
+ * @brief Defines plug-in interfaces about network access
+ */
+
+/** @addtogroup plugin_networkaccess NetworkAccess Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to open network connection
+ *
+ * @param[in] session as returned by sync_agent_plugin_open_connection() - network session information
+ * @param[in] proxy proxy information
+ * @param[in] timeout user preferred time-out seconds used in sending message (ex> 30 means 30seconds)
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_open_connection(int, int, unsigned int *), _create_all_session(int)
+ *
+ */
+       int sync_agent_plugin_open_connection(void **session, char *proxy, int timeout);
+
+/**
+ * API to bind header information for each network protocol
+ *
+ * @param[in] header_info header information for each network protocol
+ * @param[in] header_binding as returned by sync_agent_plugin_header_binding() - header information bound each network protocol
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_header_binding(GList * header_info, void **header_binding);
+
+/**
+ * API to send message to server and receive message from the server
+ *
+ * @param[in] session network session information
+ * @param[in] header_binding as returned by sync_agent_plugin_send_message() - header binding information
+ * @param[in] send_msg body message
+ * @param[in] send_msg_length length of body message
+ * @param[in] recv_msg_size as returned by sync_agent_plugin_send_message() - the size of received message from the server
+ *
+ * @return 1 on success, otherwise error
+ * @retval 0 operation failed
+ * @retval -1 cancel message
+ * @retval -8 try again
+ * @retval -408 request timeout
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_send_message(void *session, void **header_binding, char *send_msg, unsigned int send_msg_length, unsigned int *recv_msg_size);
+
+/**
+ * API to divide header/body information using received message from the server
+ *
+ * @param[in] msg received message from the server
+ * @param[in] msg_size the size of received message from the server
+ * @param[in] recv_header as returned by sync_agent_plugin_header_unbinding() - header information of received message from the server
+ * @param[in] recv_msg as returned by sync_agent_plugin_header_unbinding() - information of received message from the server
+ * @param[in] recv_msg_length as returned by sync_agent_plugin_header_unbinding() - the length of body information
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_header_unbinding(void *msg, unsigned int msg_size, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length);
+
+/**
+ * API to close network connection
+ *
+ * @param[in] session network session information
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_close_connection(int, unsigned int)
+ *
+ */
+       int sync_agent_plugin_close_connection(void *session);
+
+/**
+ * API to cancel operation about message being sent to the server
+ *
+ * @param[in] session network session information
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_cancel_msg(int, unsigned int)
+ *
+ */
+       int sync_agent_plugin_cancel_message(void *session);
+
+/**
+ * API to just send message to the server (do not receive message from the server)
+ *
+ * @param[in] session network session information
+ * @param[in] header_binding as returned by sync_agent_plugin_just_send_message() - header binding information
+ * @param[in] send_msg Body message
+ * @param[in] send_msg_length Length of body message
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_just_send_message(void *session, void **header_binding, char *send_msg, unsigned int send_msg_length);
+
+/**
+ * API to get network header information about specific keyword
+ *
+ * @param[in] header_info list of network header information (key-value pair)
+ * @param[in] key Specific keyword of header information that user want to know
+ * @param[in] value as returned by sync_agent_plugin_get_header_info() - value for the key
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_header_info(int, GList *, char *, char **)
+ *
+ */
+       int sync_agent_plugin_get_header_info(GList * header_info, char *key, char **value);
+
+/**
+ * API to set download information(download range) to download header information of specific network protocol
+ *
+ * @param[in] down_info download header information of specific network protocol
+ * @param[in] current_down_range download current range
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see na_download_data(GList *header_info, int, unsigned char *, unsigned int, unsigned int, unsigned char **, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_set_data_download_info(void *down_info, char *current_down_range);
+
+/**
+ * API to get download information(download range, filename) to download header information of specific network protocol
+ *
+ * @param[in] http_req_info http request information
+ * @param[in] down_info download header information of specific network protocol
+ * @param[in] total_down_size as returned by sync_agent_plugin_get_data_download_info() - total download size
+ * @param[in] current_down_range as returned by sync_agent_plugin_get_data_download_info() - current download range
+ * @param[in] down_file_name as returned by sync_agent_plugin_get_data_download_info() - download file name
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see na_download_data(GList *header_info, int, unsigned char *, unsigned int, unsigned int, unsigned char **, sync_agent_na_send_type_e, unsigned int)
+ *
+ */
+       int sync_agent_plugin_get_data_download_info(void *http_req_info, void *down_info, int *total_down_size, char **current_down_range, char **down_file_name);
+
+/**
+ * API to add user authentication information (id, password) to session and
+ * register authentication callback for 'authenticate' signal
+ *
+ * @param[in] session network session information
+ * @param[in] id user id
+ * @param[in] password user password
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_add_authentication_info(int, char *, char *, unsigned int)
+ *
+ */
+       int sync_agent_plugin_add_authentication_info(void *session, char *id, char *password);
+
+/**
+ * API to connect service and register to the sync-agent-framework mainloop for data connection
+ *
+ * @param[in] data user data (meaningless value)
+ *
+ * @par Since:
+ *
+ *
+ * @see na_init_network_access(int)
+ *
+ */
+       void sync_agent_plugin_register_fw_main_loop_network_access(void *data);
+
+/**
+ * API to set network communication property
+ *
+ * @param[in] session network session information
+ * @param[in] property network communication property (time out, retry count, ...)
+ * @param[in] va property value
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see na_set_property(int, unsigned int, sync_agent_na_property_e, ...)
+ *
+ */
+       int sync_agent_plugin_set_property(void *session, sync_agent_na_property_e property, va_list va);
+
+/**
+ * API to get network communication status
+ *
+ * @param[in] session network session information
+ * @param[in] status network communication status (response code, elapsed time, connection time, ...)
+ * @param[in] va status value
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_status(int, unsigned int, sync_agent_na_status_e, ...)
+ *
+ */
+       int sync_agent_plugin_get_status(void *session, sync_agent_na_status_e status, va_list va);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* NETWORK_ACCESS_INTERFACE_H_ */
diff --git a/include/plugin/platform_monitor_interface.h b/include/plugin/platform_monitor_interface.h
new file mode 100755 (executable)
index 0000000..48e2dca
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_INTERFACE_H_
+#define PLATFORM_MONITOR_INTERFACE_H_
+
+#include "platform_monitor_resource.h"
+#include "platform-monitor/common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file platform_monitor_interface.h
+ * @brief Defines plug-in interfaces about service platform notification
+ */
+
+/** @addtogroup plugin_platformmonitor PlatformMonitor Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * API to connect to the service and register client for receiving service notification
+ *
+ * @param[in] data data formatted by sync_agent_pm_register_data_s
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_init(const char *)
+ *
+ */
+       void sync_agent_plugin_init_service_noti(void *data);
+
+/**
+ * API to disconnect service and unregister client to the service
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_unregister_service_noti(int)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_plugin_unregister_service_noti(void);
+
+/**
+ * API to add user data to the service
+ *
+ * @param[in] add_data data to add to the service
+ * @param[in] added_data_id as returned by sync_agent_plugin_add_service_data() - id of the newly data added to the service
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_add_service_data(int, void *, int *)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_plugin_add_service_data(void *add_data, int *added_data_id);
+
+/**
+ * API to remove user data to the service
+ *
+ * @param[in] remove_data_id service id of data expected to be deleted
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_remove_service_data(int, int)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id);
+
+/**
+ * API to get service data
+ *
+ * @param[in] get_data_id service id of data that user want to get
+ * @param[in] service_data as returned by sync_agent_plugin_get_service_data() - service data that user want to get
+ *
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_service_data(int, int, void **)
+ *
+ */
+       sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data);
+
+/**
+ * API to set user callback function pointer to the pre-registered service callback function
+ *
+ * @param[in] callback_counts the number of callback functions
+ * @param[in] list variable number of callback functions (type : 'sync_agent_specific_type_cb')
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agnet_register_user_callback(int, const char *, int, ...)
+ *
+ */
+       void sync_agent_plugin_set_user_callback(int callback_counts, va_list list);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PLATFORM_MONITOR_INTERFACE_H_ */
diff --git a/include/plugin/platform_monitor_resource.h b/include/plugin/platform_monitor_resource.h
new file mode 100755 (executable)
index 0000000..4323d0f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_RESOURCE_H_
+#define PLATFORM_MONITOR_RESOURCE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file platform_monitor_resource.h
+ * @brief Defines prototype of callback function about service platform notification
+ */
+
+/** @addtogroup plugin_platformmonitor PlatformMonitor Domain
+ * @ingroup plugin
+ *     @{
+ */
+
+/**
+ * Prototype of the function provided by the service for the purpose of notification
+ *
+ * @param[in] data_id service dependency data
+ * @param[in] user_data service dependency data
+ *
+ * @return
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_plugin(xmlNode *)
+ *
+ */
+       typedef int (*sync_agent_user_callback_cb_plugin) (int data_id, void *user_data);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PLATFORM_MONITOR_RESOURCE_H_ */
diff --git a/include/plugin/plugin_interface.h b/include/plugin/plugin_interface.h
new file mode 100755 (executable)
index 0000000..d285f18
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "account_interface.h"
+#include "data_connector_interface.h"
+#include "data_converter_interface.h"
+#include "device_info_interface.h"
+#include "device_manager_interface.h"
+#include "mo_interface.h"
+#include "network_access_interface.h"
+#include "platform_monitor_interface.h"
+#include "data_connector_resource.h"
+#include "data_converter_resource.h"
+#include "platform_monitor_resource.h"
diff --git a/include/protocol-binder/common.h b/include/protocol-binder/common.h
new file mode 100755 (executable)
index 0000000..41229af
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BINDER_COMMON_H_
+#define BINDER_COMMON_H_
+
+/* common includes */
+#include <stdbool.h>
+
+/* our includes */
+#include "definition.h"
+#include "error.h"
+#include "util.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* BINDER_COMMON_H_ */
diff --git a/include/protocol-binder/definition.h b/include/protocol-binder/definition.h
new file mode 100755 (executable)
index 0000000..afea1c6
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEFINITION_H_
+#define DEFINITION_H_
+
+#include <glib.h>
+#include <stdbool.h>
+#include "error.h"
+#include <wbxml/wbxml.h>
+#include <wbxml/wbxml_parser.h>
+#include <wbxml/wbxml_tree.h>
+#include <wbxml/wbxml_encoder.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+       typedef void *Content_Ptr;
+       typedef void *Protocol_Option_Ptr;
+       typedef unsigned int Protocol_Element;
+
+/**
+ * @file definition.h
+ * @brief Define structure, enum, callback function etc...
+ */
+
+/* common definition */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/**
+ * Enumerations of encoding type
+ */
+       typedef enum {
+               SYNC_AGENT_PB_ENCODING_UNKNOWN = 0,                     /**< Unknown*/
+               SYNC_AGENT_PB_ENCODING_XML,                                     /**< XML*/
+               SYNC_AGENT_PB_ENCODING_WBXML_10,                        /**< WBXML 1.0*/
+               SYNC_AGENT_PB_ENCODING_WBXML_11,                        /**< WBXML 1.1*/
+               SYNC_AGENT_PB_ENCODING_WBXML_12,                        /**< WBXML 1.2*/
+               SYNC_AGENT_PB_ENCODING_WBXML_13                 /**< WBXML 1.3*/
+       } sync_agent_pb_encoding_e;
+
+/**
+ * Enumerations of decoding type
+ */
+       typedef enum {
+               SYNC_AGENT_PB_DECODING_UNKNOWN = 0,                     /**< Unknown*/
+               SYNC_AGENT_PB_DECODING_XML,                                     /**< XML*/
+               SYNC_AGENT_PB_DECODING_WBXML                            /**< WBXML*/
+       } sync_agent_pb_decoding_e;
+
+/**
+ * Enumerations of Protocol that supports by sync_agent_pb_protocol_e binder
+ */
+       typedef enum {
+               SYNC_AGENT_PB_PROTOCOL_UNKNOWN = 0,                     /**< Unknown*/
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML10,         /**< SYNCML1.0*/
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML11,         /**< SYNCML1.1*/
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12,         /**< SYNCML1.2*/
+
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF10,
+                                               /**< SYNCML Device Information 1.0 */
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF11,
+                                               /**< SYNCML Device Information 1.1 */
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12,
+                                               /**< SYNCML Device Information 1.2 */
+
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF10,
+                                               /**< SYNCML Meta Information 1.0 */
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF11,
+                                               /**< SYNCML Meta Information 1.1 */
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF12,
+                                               /**< SYNCML Meta Information 1.2 */
+
+               SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12,
+                                              /**< SYNCML DM DDF 1.2 */
+
+               SYNC_AGENT_PB_PROTOCOL_ACTIVESYNC,
+                                          /**< EAS */
+
+               SYNC_AGENT_PB_PROTOCOL_PROV10,
+                                      /**< EAS Provisioning */
+
+               SYNC_AGENT_PB_PROTOCOL_MAX_COUNT
+                                        /**< for counting supporting protocol */
+       } sync_agent_pb_protocol_e;
+
+/* protocol binder */
+
+/**
+ * Structure for protocol binder
+ */
+       typedef struct protocol_binder_info sync_agent_pb_protocol_binder_info_s;
+
+/**
+ * Restrict Condition Checker callback
+ *
+ * @param[in] enc sync_agent_pb_encoding_e value
+ * @param[in] option Protocol_Option_Ptr
+ * @param[in] restrict_params list of restrict parameter
+ * @param[in] arguments list of parameter
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef bool(*sync_agent_restrict_condition_checker_cb) (sync_agent_pb_encoding_e enc, Protocol_Option_Ptr option, GList * restrict_params, GList * arguments);
+
+/**
+ * Binder Object converter function
+ *
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s pointer
+ * @param[in] content void pointer
+ * @param[in] wbxml_dom_node WBXMLTreeNode
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef sync_agent_pb_error_e(*sync_agent_binder_object_converter_cb) (sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+
+/* reverse protocol binder */
+
+/*typedef struct _Reverse_binder_function_info Reverse_binder_function_info;*/
+/*typedef struct _Reverse_binder_function_set Reverse_binder_function_set;*/
+
+/**
+ * Structure for reverse protocol binder
+ */
+       typedef struct protocol_binder_reverse_info sync_agent_pb_protocol_binder_reverse_info_s;
+
+/**
+ * Reverse Binder Object converter function
+ *
+ * @param[in] reverse_binder sync_agent_pb_protocol_binder_reverse_info_s pointer
+ * @param[in] wbxml_dom_node WBXMLTreeNode
+ * @param[in] content Content_Ptr pointer
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success, otherwise error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef sync_agent_pb_error_e(*sync_agent_reverse_binder_object_converter_cb) (sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
+
+/* protocol binder & reverse protocol binder callback */
+
+/**
+ * Structure for Binder function set
+ */
+       typedef struct protocol_binder_function_set sync_agent_pb_protocol_binder_function_set_s;
+
+/**
+ * Structure for Binder function info
+ */
+       typedef struct protocol_binder_function_info sync_agent_pb_function_info_s;
+       struct protocol_binder_function_info {
+               Protocol_Element protocol_element;                      /**< Defined element */
+               char *protocol_element_xml_name;                        /**< Xml element name */
+               sync_agent_binder_object_converter_cb binder_object_converter_function;         /**< Callback function for object converter*/
+               sync_agent_reverse_binder_object_converter_cb reverse_binder_object_converter_function;         /**< Callback function for reverse object converter*/
+               bool isTerminal;                                                        /**< Whether current node is terminal or not */
+       };
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* DEFINITION_H_ */
diff --git a/include/protocol-binder/error.h b/include/protocol-binder/error.h
new file mode 100755 (executable)
index 0000000..3ac7bb3
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROTOCOL_BINDER_ERROR_H_
+#define PROTOCOL_BINDER_ERROR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file error.h
+ * @brief Defines protocol-binder errors
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/**
+ * @brief Enumerations of error code for protocol binder
+ */
+       typedef enum {
+               SYNC_AGENT_PB_RETURN_OK = 0,                                                                                                                    /**< Successful */
+               SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT = 1,                                                   /**< No more XML Element */
+
+               SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR,                                                                                     /**< Unknown Error */
+               SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY,                                                                                     /**< Out of memory */
+               SYNC_AGENT_PB_RETURN_NOT_DEFINED,                                                                                               /**< Something that have to be defined is not defined  */
+               SYNC_AGENT_PB_RETURN_INIT_REQUIRED_OR_INVALID_BINDER,                                   /**< Initialization is required or invalid binder */
+               SYNC_AGENT_PB_RETURN_UNKNOWN_ENCODING,                                                                  /**< Unknown Encoding type */
+
+               SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_ENCODING,                              /**< Not Support for XML encoding */
+               SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_DECODING,                              /**< Not Support for XML decoding */
+
+               SYNC_AGENT_PB_RETURN_UNKNOWN_LANGUAGE,                                                                  /**< Unknown Language */
+               SYNC_AGENT_PB_RETURN_WBXML_PARSE_FAIL,                                                                          /**< WBXML Parse Fail */
+               SYNC_AGENT_PB_RETURN_XML_PARSE_FAIL,                                                                                    /**< XML Parse Fail */
+               SYNC_AGENT_PB_RETURN_INVALID_XML,                                                                                                       /**< Invalid XML */
+               SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_NOT_DEFINED,                   /**< Function Set Not Defined */
+               SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_LOOKUP_TBL_NOT_DEFINED,                /**< Lookup table has not defined */
+
+               SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL,                                                                          /**< Invalid Protocol */
+               SYNC_AGENT_PB_RETURN_INVALID_CONTENT,                                                                                   /**< Invalid Content */
+
+               SYNC_AGENT_PB_RETURN_UNEXPECTED_CASE_ACCORDING_TO_PROTOCOL_SPEC,                        /**< Unexpected case according to protocol spec */
+
+               SYNC_AGENT_PB_RETURN_ALREADY_SWITCH_PROTOCOL,                                                   /**< Operation failed */
+               SYNC_AGENT_PB_RETURN_HAS_NO_UNDO_SWITCH_PROTOCOL,                               /**< Operation failed */
+               SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL_ELEMENT,                                          /**< Invalid protocol element */
+               SYNC_AGENT_PB_RETURN_APPEND_INVALID_PROTOCOL_ELEMENT,                   /**< Invalid protocol element */
+
+               SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER,                                                   /**< Invalid input parameter */
+
+               SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE,                             /**< Invalid parameter */
+
+               SYNC_AGENT_PB_RETURN_TREE_ALREADY_HAS_ROOT,                                                             /**< Already has root in WBXMLTree */
+
+               /* protocol binder error */
+               SYNC_AGENT_PB_RETURN_UTIL_NO_TEXT_VALUE,        /**< Invalid parameter *//* TODO remove */
+               SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE,                                                                      /**< Invalid parameter */
+               SYNC_AGENT_PB_RETURN_UTIL_NO_INT_VALUE                                                                          /**< Invalid parameter */
+       } sync_agent_pb_error_e;
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PROTOCOL_BINDER_ERROR_H_ */
diff --git a/include/protocol-binder/interface.h b/include/protocol-binder/interface.h
new file mode 100755 (executable)
index 0000000..a5753a5
--- /dev/null
@@ -0,0 +1,900 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROTOCOL_BINDER_INTERFACE_H_
+#define PROTOCOL_BINDER_INTERFACE_H_
+
+#include "common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface.h
+ * @brief Provides binder/reverse binder operation
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/* binder function set */
+
+/**
+ * @brief Initialize binder function set
+ * @par Usage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder_function_cnt Count of binder function
+ * @param[in] info_array sync_agent_pb_function_info_s
+ * @param[out] binder_function_set sync_agent_pb_protocol_binder_function_set_s
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ * @see sync_agent_free_binder_function_set
+ */
+       sync_agent_pb_error_e sync_agent_init_binder_function_set(unsigned int binder_function_cnt, sync_agent_pb_function_info_s * info_array, sync_agent_pb_protocol_binder_function_set_s ** binder_function_set);
+
+/**
+ * @brief Add more function informations to binder function set
+ * @remarks you should notice that if same value of protocol_element
+ * or protocol_element_xml_name are already existed in binder function set,
+ * then previous information is removed from binder function set
+ * @par Usage
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *
+ * const sync_agent_pb_function_info_s additional_binder_function_info[] = {
+ *             { PE_ADD,       "Add",                  _binder_add_converter_function,                 _binder_add_reverse_converter_function, true},
+ *             { PE_DELETE,    "Delete",               _binder_delete_start_converter_function,        _binder_delete_reverse_converter_function, false},
+ *             { PE_REPLACE,   "Replace",              NULL,                                           NULL,                                   false},
+ * };
+ *
+ *
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_add_binder_function_set(pBinder_function_set, sizeof(additional_binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ * additional_binder_function_info);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ * @endcode
+ * @param[in] binder_function_set Binder function set
+ * @param[in] binder_function_info_cnt Number of new binder function informations to be added
+ * @param[in] info_array_to_be_added Array of new binder function informations to be added
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ * @see sync_agent_init_binder_function_set
+ */
+       sync_agent_pb_error_e sync_agent_add_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set, unsigned int binder_function_info_cnt, sync_agent_pb_function_info_s * info_array_to_be_added);
+
+/**
+ * @brief Free binder function set
+ * @par Usage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * sync_agent_free_binder_function_set(pBinder_function_set);
+ *
+ * @endcode
+ * @param[in] binder_function_set sync_agent_pb_protocol_binder_function_set_s
+ * @see sync_agent_init_binder_function_set, sync_agent_add_binder_function_set
+ */
+       void sync_agent_free_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set);
+
+/* protocol binder */
+
+/**
+ * @brief Initialize protocol binder
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] protocol Protocol enum value
+ * @param[in] option Function pointer of Protocol_Option_Ptr
+ * @param[in] enc sync_agent_pb_encoding_e enum value
+ * @param[in] encode_xml_header Whether need XML header encoding or not
+ * @param[in] use_strtbl Whether use string table or not
+ * @param[in] produce_anonymous whether produce an anonymous document or not
+ * @param[in] use_flow_mode Whether use flow mode or not
+ * @param[in] text_public_id Whether use textual public id or not
+ * @param[in] restrict_params List of restrict parameter
+ * @param[in] restrict_condition_checker Function pointer of restrict condition
+ * @param[in] binder_function_set sync_agent_pb_protocol_binder_function_set_s
+ * @return sync_agent_pb_protocol_binder_info_s on success, NULL on fail
+ * @see sync_agent_destroy_protocol_binder
+ */
+       sync_agent_pb_protocol_binder_info_s *sync_agent_init_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_protocol_e protocol, Protocol_Option_Ptr option, sync_agent_pb_encoding_e enc, bool encode_xml_header,
+                                                                             bool use_strtbl, bool produce_anonymous, bool use_flow_mode, bool text_public_id, GList * restrict_params, sync_agent_restrict_condition_checker_cb restrict_condition_checker,
+                                                                             sync_agent_pb_protocol_binder_function_set_s * binder_function_set);
+
+/**
+ * @brief Append specific XML element to WBXMLTree
+ * @remarks Process callback function that has registered to sync_agent_pb_protocol_binder_function_set_s
+ *  pContent by pass to callback function
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_append_element(pBinder, PE_HEADER, "data");
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] protocol_element Protocol_Element
+ * @param[in] content Structure that need to append to WBXMLTree
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_NOT_DEFINED Binder Function Set is not defined
+ * @retval SYNC_AGENT_PB_RETURN_APPEND_INVALID_PROTOCOL_ELEMENT Invalid protocol element
+ * @retval SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR
+ * @see sync_agent_init_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_append_element(sync_agent_pb_protocol_binder_info_s * binder, Protocol_Element protocol_element, Content_Ptr content);
+
+/**
+ * @brief Terminate protocol binder
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * sync_agent_destroy_protocol_binder(pBinder);
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @see sync_agent_init_protocol_binder
+ */
+       void sync_agent_destroy_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder);
+
+/**
+ * @brief Get stream from protocol binder
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *stream = NULL;
+ * unsigned int stream_size = 0;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_append_element(pBinder, PE_HEADER, data);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_get_stream_from_protocol_binder(pBinder, &stream, &stream_size);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[out] byte_stream Encoded stream
+ * @param[out] byte_stream_size Size of Encoded stream
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter
+ * @retval SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR
+ * @see sync_agent_init_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_get_stream_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, char **byte_stream, unsigned int *byte_stream_size);
+
+/**
+ * @brief Get XML stream from protocol binder
+ * @remarks Only support when protocol binder encoding == ENCODING_WBXML_XX
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *xml = NULL;
+ * unsigned int xml_size = 0;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_append_element(pBinder, PE_HEADER, data);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_get_xml_from_protocol_binder(pBinder, &xml, &xml_size);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[out] xml XML
+ * @param[out] xml_size Size of XML
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_ENCODING sync_agent_pb_encoding_e type is SYNC_AGENT_PB_ENCODING_XML
+ * @retval SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR
+ * @see sync_agent_init_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_get_xml_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, char **xml, unsigned int *xml_size);
+
+/**
+ * @brief Get stream size from protocol binder
+ * @par Useage:
+ * @code
+ *
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * unsigned int stream_size = 0;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_append_element(pBinder, PE_HEADER, data);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_get_stream_size_from_protocol_binder(pBinder, &stream_size);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[out] byte_stream_size Size of byte stream
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter
+ * @see sync_agent_init_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_get_stream_size_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, unsigned int *byte_stream_size);
+
+/**
+ * @brief Get encoding type protocol binder
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ * sync_agent_pb_encoding_e out_encoding  = 0;
+ *
+ * unsigned int stream_size = 0;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_get_encoding_from_protocol_binder(pBinder, &out_encoding);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[out] enc sync_agent_pb_encoding_e enum value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @see sync_agent_init_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_get_encoding_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e * enc);
+
+/* reverse protocol binder */
+
+/**
+ * @brief Initialize reverse protocol binder
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, NULL, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] byte_stream WBXML or XML byte stream
+ * @param[in] byte_stream_len Length of byte stream
+ * @param[in] dec Type of sync_agent_pb_decoding_e(SYNC_AGENT_PB_DECODING_XML, SYNC_AGENT_PB_DECODING_WBXML)
+ * @param[in] protocol Protocol Enum value(which Protocol)
+ * @param[in] binder_function_set sync_agent_pb_protocol_binder_function_set_s
+ * @param[in] user_data
+ * @param[out] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter
+ * @retval SYNC_AGENT_PB_RETURN_UNKNOWN_ENCODING Unknown sync_agent_pb_encoding_e type
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ * @see sync_agent_destroy_reverse_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_init_reverse_protocol_binder(char *byte_stream, unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_e * protocol, sync_agent_pb_protocol_binder_function_set_s * binder_function_set,
+                                                                     void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** binder);
+
+/**
+ * @brief Set user data to reverse protocol binder
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * void *user_data = "xxxxxxxxxxx";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, NULL, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * sync_agent_set_user_data_in_reverse_protocol_binder(pBinder, user_data);
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @param[in] user_data User data
+ * @see sync_agent_init_reverse_protocol_binder
+ */
+       void sync_agent_set_user_data_in_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder, void *user_data);
+
+/**
+ * @brief Get user data from reverse protocol binder
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * void *user_data = "xxxxxxxxxxx";
+ * void *return_user_data = NULL;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, user_data, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * return_user_data = sync_agent_set_user_data_in_reverse_protocol_binder(pBinder);
+ * if (return_user_data == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @return void* on success
+ * @see sync_agent_init_reverse_protocol_binder
+ */
+       void *sync_agent_get_user_data_from_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder);
+
+/**
+ * @brief Process next registered XML element related callback function and get structure as a result
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ *
+ * Protocol_Element protocol_element = PE_UNDEF;
+ * char *protocol_element_name = NULL;
+ * Content_Ptr pContent = NULL;
+ *
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, user_data, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_next_element(pBinder, &protocol_element, &protocol_element_name, &pContent);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @param[in] protocol_element Protocol_Element
+ * @param[out] protocol_element_name XML element name
+ * @param[out] content Structure as a callback process result
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT No more XML element
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ * @see sync_agent_init_reverse_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_next_element(sync_agent_pb_protocol_binder_reverse_info_s * binder, Protocol_Element * protocol_element, char **protocol_element_name, Content_Ptr * content);
+
+/**
+ * @brief Terminate Reverse protocol binder
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, NULL, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * sync_agent_destroy_reverse_protocol_binder(pBinder);
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @see sync_agent_init_reverse_protocol_binder
+ */
+       void sync_agent_destroy_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder);
+
+/**
+ * @brief Get XML stream from reverse protocol binder
+ * @remarks Only support when protocol binder encoding == ENCODING_WBXML_XX
+ * @par Useage:
+ * @code
+ * const sync_agent_pb_function_info_s binder_function_info[] = {
+ *             { PE_HEADER,            "Header",       _binder_header_converter_function,      _binder_header_reverse_converter_function,      true},
+ *             { PE_BODY_START,        "Body",         _binder_body_start_converter_function,  NULL,                                           false},
+ *             { PE_BODY_END,          "/Body",        NULL,                                   NULL,                                           false},
+ *             { PE_FINAL,             "Final",        _binder_final_converter_function,       _binder_final_reverse_converter_function,       true},
+ * };
+ *
+ *     ...
+ *
+ *
+ * sync_agent_pb_protocol_e err = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * char *byte_stream = "xxxxxxxxxx";
+ * char *byt_stream_len = 100;
+ * sync_agent_pb_encoding_e decoding = SYNC_AGENT_PB_DECODING_WBXML;
+ * sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ *
+ * char *xml = NULL;
+ * unsigned int xml_size = 0;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, decoding,
+ *     &protocol, pBinder_function_set, NULL, &pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_get_xml_from_reverse_protocol_binder(pBinder, &xml, &xml_size);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @param[out] xml XML
+ * @param[out] xml_size Size of XML
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_INIT_REQUIRED_OR_INVALID_BINDER Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_DECODING sync_agent_pb_encoding_e type is SYNC_AGENT_PB_ENCODING_XML
+ * @retval SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR
+ * @see sync_agent_init_reverse_protocol_binder
+ */
+       sync_agent_pb_error_e sync_agent_get_xml_from_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder, char **xml, unsigned int *xml_size);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PROTOCOL_BINDER_INTERFACE_H_ */
diff --git a/include/protocol-binder/protocol_binder.h b/include/protocol-binder/protocol_binder.h
new file mode 100755 (executable)
index 0000000..e4e9af0
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common.h"
+#include "definition.h"
+#include "error.h"
+#include "interface.h"
+#include "util.h"
diff --git a/include/protocol-binder/util.h b/include/protocol-binder/util.h
new file mode 100755 (executable)
index 0000000..cded57f
--- /dev/null
@@ -0,0 +1,1101 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROTOCOL_BINDER_UTIL_H_
+#define PROTOCOL_BINDER_UTIL_H_
+
+#include <stdbool.h>
+#include "error.h"
+#include "definition.h"
+#include "interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file util.h
+ * @brief Provides protocol binder utility operation
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/* protocol binder property managing functions */
+/**
+ * @brief Change protocol
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_switch_protocol(pBinder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
+ * @param[in] protocol Enum value that means specific protocol
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL Invalid parameter(protocol)
+ * @retval SYNC_AGENT_PB_RETURN_ALREADY_SWITCH_PROTOCOL Operation failed
+ * @see sync_agent_init_protocol_binder, sync_agent_undo_switch_protocol
+ */
+       sync_agent_pb_error_e sync_agent_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_protocol_e protocol);
+
+/**
+ * @brief Go back to previous protocol
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * err = sync_agent_switch_protocol(pBinder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_undo_switch_protocol(pBinder);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_NOT_DEFINED Invalid parameter(pBinder)
+ * @retval SYNC_AGENT_PB_RETURN_HAS_NO_UNDO_SWITCH_PROTOCOL Operation failed
+ * @see sync_agent_switch_protocol
+ */
+       sync_agent_pb_error_e sync_agent_undo_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder);
+
+/* wbxml dom tree building functions */
+/**
+ * @brief Create WBXMLTree using information in sync_agent_pb_protocol_binder_info_s structure
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTree *tree = sync_agent_create_wbxml_tree(pBinder);
+ * if (tree == NULL) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in] binder Structure(sync_agent_pb_protocol_binder_info_s)
+ * @return WBXMLTree on success, NULL on fail
+ * @see sync_agent_init_protocol_binder
+ */
+       WBXMLTree *sync_agent_create_wbxml_tree(const sync_agent_pb_protocol_binder_info_s * binder);
+
+/**
+ * @brief Add WBXMLTree to WBXMLTreeNode as a subree
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ *     goto error;
+ * }
+ *
+ * WBXMLTree *tree = sync_agent_create_wbxml_tree(pBinder);
+ * if (tree == NULL) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_add_wbxml_tree_to_wbxml_node(header_node, tree);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in] parent_node WBXMLTreeNode
+ * @param[in] tree WBXMLTree
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter(parent_node, tree)
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ * @see sync_agent_init_protocol_binder, sync_agent_create_node, sync_agent_create_wbxml_tree
+ */
+       sync_agent_pb_error_e sync_agent_add_wbxml_tree_to_wbxml_node(WBXMLTreeNode * parent_node, WBXMLTree * tree);
+
+/**
+ * @brief Set root node of WBXMLTree
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ *     goto error;
+ * }
+ *
+ * WBXMLTree *root_tree = sync_agent_create_wbxml_tree(pBinder);
+ * if (tree == NULL) {
+ *     ...
+ * }
+ *
+ *
+ * err = sync_agent_set_wbxml_tree_root(root_tree, header_node);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in] tree WBXMLTree
+ * @param[in] node WBXMLTreeNode
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER Invalid parameter(parent_node, tree)
+ * @retval SYNC_AGENT_PB_RETURN_TREE_ALREADY_HAS_ROOT
+ * @see sync_agent_init_protocol_binder, sync_agent_create_wbxml_tree
+ */
+       sync_agent_pb_error_e sync_agent_set_wbxml_tree_root(WBXMLTree * tree, WBXMLTreeNode * node);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] xml_name XML element name
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_create_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name and XML name space
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *name_space = "name_space";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node_with_namespace(pBinder, element_name, name_space);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_create_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with text content
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *text_data = "data";
+ * unsigned int text_len = strlen(text_data);;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_text_node(pBinder, element_name, text_data, text_len);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] xml_name XML element name
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_create_text_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name and XML name space with text content
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *name_space = "name_space";
+ * char *text_data = "data";
+ * unsigned int text_len = strlen(text_data);
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_text_node_with_namespace(pBinder, element_name, name_space, text_data, text_len);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_create_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with cdata content
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *name_space = "name_space";
+ * char *cdata = "data";
+ * unsigned int cdata_len = strlen(cdata);
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_cdata_node(pBinder, element_name, name_space, cdata, cdata_len);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] xml_name XML element name
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_create_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_node(pBinder, header_node, child_element_name);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name and XML name space, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * char *child_namespace = "child_namespace";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_node_with_namespace(pBinder, header_node, child_element_name, child_namespace);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with text content, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * char *child_data = "child_data";
+ * unsigned int child_data_len = strlen(child_data);
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_text_node(pBinder, header_node, child_element_name, child_data, child_data_len);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_text_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name and XML name space with text content, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * char *child_namespace = "child_namespace";
+ * char *child_data = "child_data";
+ * unsigned int child_data_len = strlen(child_data);
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_text_node_with_namespace(pBinder, header_node, child_element_name, child_namespace, child_data, child_data_len);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with cdata content, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * char *child_cdata = "child_cdata";
+ * unsigned int child_cdata_len = strlen(child_cdata);
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, child_cdata, child_cdata_len);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] text Content
+ * @param[in] text_len Length of Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with int content, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * int data = 10;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, data);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] num Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_int_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const int num);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with int content, and add WBXMLTreeNode to parent node as a child node
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ * char *child_element_name = "child";
+ * char *child_namespace = "child_namespace";
+ * int data = 10;
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *child_node = sync_agent_add_child_cdata_node(pBinder, header_node, child_element_name, child_namespace, data);
+ * if (child_node == NULL) {
+ *     ...
+ * }
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @param[in] num Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ * @see sync_agent_init_protocol_binder, sync_agent_destroy_wbxml_node
+ */
+       WBXMLTreeNode *sync_agent_add_child_int_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const int num);
+
+/* wbxml dom tree getter functions */
+
+/**
+ * @brief Get XML element name from WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * WBXMLTreeNode node  = NULL;
+ * char *element_xml_name = NULL;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_name_from_element_node(node, &element_xml_name);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] element_xml_name XML element name
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE Invalid parameter(element_node)
+ */
+       sync_agent_pb_error_e sync_agent_get_name_from_element_node(const WBXMLTreeNode * element_node, char **element_xml_name);
+
+/**
+ * @brief Get XML name space from WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * WBXMLTreeNode node  = NULL;
+ * char *name_space = NULL;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_namespace_from_element_node(pBinder, node, &name_space);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] name_space XML name space
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE Invalid parameter(element_node)
+ */
+       sync_agent_pb_error_e sync_agent_get_namespace_from_element_node(const sync_agent_pb_protocol_binder_reverse_info_s * binder, const WBXMLTreeNode * element_node, char **name_space);
+
+/**
+ * @brief Get pointer of text content from WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * WBXMLTreeNode node  = NULL;
+ * char *text = NULL;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_text_from_node(node, &text);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] text_pointer Pointer of text content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ */
+       sync_agent_pb_error_e sync_agent_get_text_from_node(WBXMLTreeNode * element_node, char **text_pointer);
+
+/**
+ * @brief Get pointer of binary content from WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * WBXMLTreeNode node  = NULL;
+ * char *binary = NULL;
+ * unsigned int binary_size = 0;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_text_from_node(node, &binary, &binary_size);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] binary_pointer Pointer of binary content
+ * @param[out] binary_size Size of binary content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE Invalid parameter(element_node)
+ */
+       sync_agent_pb_error_e sync_agent_get_binary_from_node(WBXMLTreeNode * element_node, char **binary_pointer, unsigned int *binary_size);
+
+/**
+ * @brief Get int content from WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * WBXMLTreeNode node  = NULL;
+ * int value = 0;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_int_from_node(node, &value);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] value Int content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_UTIL_NO_INT_VALUE Invalid parameter(element_node)
+ */
+       sync_agent_pb_error_e sync_agent_get_int_from_node(WBXMLTreeNode * element_node, int *value);
+
+/**
+ * @brief Get pointer of text content from WBXMLTreeNode(cdata node)
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * WBXMLTreeNode node  = NULL;
+ * char *text = 0;
+ *
+ *     ...
+ *
+ * err = sync_agent_get_text_from_cdata_node(node, &text);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] text_pointer Pointer of text content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ */
+       sync_agent_pb_error_e sync_agent_get_text_from_cdata_node(WBXMLTreeNode * element_node, char **text_pointer);
+
+/**
+ * @brief Destroy WBXMLTreeNode
+ * @par Useage:
+ * @code
+ *
+ * sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ * sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ *
+ * sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+ * sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ * sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+ * sync_agent_pb_encoding_e encoding = SYNC_AGENT_PB_ENCODING_WBXML_13;
+ *
+ * char *element_name = "header";
+ *
+ * err = sync_agent_init_binder_function_set(sizeof(binder_function_info)/sizeof(sync_agent_pb_function_info_s),
+ *     (sync_agent_pb_function_info_s*)binder_function_info,
+ *     &pBinder_function_set);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ * pOutBinder = sync_agent_init_protocol_binder(pBinder, protocol, NULL, encoding,
+ *             false, true, false, true, true, NULL, NULL,
+ *             pBinder_function_set);
+ * if (pOutBinder == NULL) {
+ *     ...
+ * }
+ *
+ * WBXMLTreeNode *header_node = sync_agent_create_node(pBinder, element_name);
+ * if (header_node == NULL) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * err = sync_agent_destroy_wbxml_node(header_node);
+ * if (err != SYNC_AGENT_PB_RETURN_OK) {
+ *     ...
+ * }
+ *
+ *
+ * @endcode
+ * @param[in] node WBXMLTreeNode
+ * @return 0 on success, otherwise a negative error value
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @see sync_agent_create_node, sync_agent_create_node_with_namespace, sync_agent_create_text_node, sync_agent_create_text_node_with_namespace, sync_agent_create_cdata_node, sync_agent_add_child_node, sync_agent_add_child_node_with_namespace, sync_agent_add_child_text_node, sync_agent_add_child_text_node_with_namespace, sync_agent_add_child_cdata_node, sync_agent_add_child_int_node, sync_agent_add_child_int_node_with_namespace
+ */
+       sync_agent_pb_error_e sync_agent_destroy_wbxml_node(WBXMLTreeNode * node);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PROTOCOL_BINDER_UTIL_H_ */
diff --git a/include/security-assistant/encryption_decryption.h b/include/security-assistant/encryption_decryption.h
new file mode 100755 (executable)
index 0000000..8b0ed96
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENCRYPTION_DECRYPTION_H_
+#define ENCRYPTION_DECRYPTION_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file encryption_descryption.h
+ * @brief Provides encryption for plain text
+ */
+
+/** @addtogroup security_assistant
+ *     @{
+ */
+
+/**
+ * Enumeration of encryption type
+ */
+       typedef enum {
+               SYNC_AGENT_SA_ENCRYPTION_NO_TYPE = 0,
+                                             /** default value */
+               SYNC_AGENT_SA_ENCRYPTION_BASIC,
+                                       /**< encryption type : BASIC */
+               SYNC_AGENT_SA_ENCRYPTION_MD5,
+                                     /**< encryption type : MD5 */
+       } sync_agent_sa_encryption_type_e;
+
+/**
+ * Enumeration of cryptographic hash function type
+ */
+       typedef enum {
+               SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_NO_TYPE = 0,
+                                                            /**< default value */
+               SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5 = 1,
+                                                        /**< length : 16 byte */
+               SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1 = 2,
+                                                         /**< length : 20 byte */
+       } sync_agent_sa_cryptographic_hash_function_type_e;
+
+/**
+ * Enumeration of cryptographic hash function flag
+ */
+       typedef enum {
+               SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC = 1,
+                                                     /**< hash function flag : HMAC */
+       } sync_agent_sa_cryptographic_hash_function_flags_e;
+
+/**
+ * API to get hash code
+ *
+ * @par Usage:
+ * @code
+               char *plain_text = NULL;
+               ...
+               unsigned char *digest = NULL;
+               digest =  sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, plain_text, strlen(plain_text));
+               if (digest == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in]  type hash function type
+ * @param[in]  plain text
+ * @param[in]  plain_len text length
+ *
+ * @return encrypt data on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_encrypt_cryptograhic_hash(sync_agent_sa_cryptographic_hash_function_type_e, const char *, int)
+ *
+ *
+ */
+       unsigned char *sync_agent_encrypt_cryptograhic_hash(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len);
+
+/**
+ * API to get hash code with flags
+ *
+ * @par Usage:
+ * @code
+               sync_agent_sa_cryptographic_hash_function_type_e type = SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1;
+               const char *plain = NULL;
+               int plain_len = 0;
+               const char *key = NULL;
+               int key_len = 0;
+               sync_agent_sa_cryptographic_hash_function_flags_e flags = SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC;
+               ...
+               unsigned char *hmac = NULL;
+               hmac = sync_agent_encrypt_cryptograhic_hash_with_flags(type,
+                                                                                                                                                                                                                                       plain,
+                                                                                                                                                                                                                                       plain_len,
+                                                                                                                                                                                                                                       key,
+                                                                                                                                                                                                                                       key_len,
+                                                                                                                                                                                                                                       SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC);
+               if (hmac == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in]  type hash function type
+ * @param[in]  plain text
+ * @param[in]  plain_len text length
+ * @param[in]  key key
+ * @param[in]  key_len key length
+ * @param[in]  flags sync_agent_sa_cryptographic_hash_function_flags_e
+ *
+ * @return encrypt data on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_encrypt_cryptograhic_hash_with_flags(sync_agent_sa_cryptographic_hash_function_type_e, const char *, int, const char *, int, sync_agent_sa_cryptographic_hash_function_flags_e)
+ *
+ */
+       unsigned char *sync_agent_encrypt_cryptograhic_hash_with_flags(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len, const char *key, int key_len, sync_agent_sa_cryptographic_hash_function_flags_e flags);
+
+/**
+ * API to generate encrypted text from plain text into desired encryption type
+ *
+ * @par Usage:
+ * @code
+               sync_agent_sa_encryption_type_e encryption_type = SYNC_AGENT_SA_ENCRYPTION_MD5;
+               char *plain_text = NULL;
+               ...
+               unsigned char *md5_text = sync_agent_get_encryption_value(encryption_type, plain_text, strlen(plain_text));
+               if (md5_text == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] encryption_type encryption type
+ * @param[in] plain plain text
+ * @param[in] plain_length length of plain text
+ *
+ * @return encrypted text on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_encryption_value(sync_agent_sa_encryption_type_e, char *, int)
+ *
+ */
+       unsigned char *sync_agent_get_encryption_value(sync_agent_sa_encryption_type_e encryption_type, char *plain, int plain_length);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ENCRYPTION_DECRYPTION_H_ */
diff --git a/include/security-assistant/security_assistant.h b/include/security-assistant/security_assistant.h
new file mode 100755 (executable)
index 0000000..0028206
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "encryption_decryption.h"
diff --git a/include/sync_agent.h b/include/sync_agent.h
new file mode 100755 (executable)
index 0000000..c1b0ac3
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ /// @example oma_ds_client.c
+ /// @example oma_dm_client.c
+
+#include "account/account.h"
+#include "data-adapter/data_adapter.h"
+#include "device/device.h"
+#include "device-manager/device_manager.h"
+#include "engine-controller/engine_controller.h"
+#include "event/event.h"
+#include "fsapi/fsapi.h"
+#include "initialization/initialization.h"
+#include "network-access/network_access.h"
+#include "protocol-binder/protocol_binder.h"
+#include "platform-monitor/platform_monitor.h"
+#include "plugin/plugin_interface.h"
+#include "security-assistant/security_assistant.h"
+#include "utility/utility.h"
diff --git a/include/utility/fw_assert.h b/include/utility/fw_assert.h
new file mode 100755 (executable)
index 0000000..a52dd30
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_ASSERT_H_
+#define FW_ASSERT_H_
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_assert.h
+ * @brief Provides assertion on exception case
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * This macro checks errno and abort if errno != 0
+ *
+ * @par Usage:
+ * @code
+#include "utility/fw_assert.h"
+#include <stdio.h>
+
+ int main()
+ {
+        //try something
+        FILE* fp = fopen("ABCD.txt", "r");
+
+        //checking errno == 0
+        //if errno != 0, then the program aborted and print "ABCD.txt open failed" in log file
+        SYNC_AGENT_UTIL_ERRNO_ABORT("ABCD.txt open failed");
+ }
+ *
+ * @endcode
+ *
+ * @param[in] text string to print out on errno != 0 case
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+#define SYNC_AGENT_UTIL_ERRNO_ABORT(text) do {\
+               if (errno != 0) {\
+                       _DEBUG_ERROR("(errno_abort) text : %s, string error (errno = %d) : %s", text, errno, strerror(errno));\
+                       abort();\
+               } \
+       } while (0)
+
+/**
+ * This macro checks whether condition failed or not and abort on condition failed case
+ *
+ * @par Usage:
+ * @code
+#include "utility/fw_assert.h"
+
+ int main()
+ {
+        //checking condition 1 !=2 is true or false
+        //if the condition is false, then the program aborted and print "1 is not same as 2" in log file
+        SYNC_AGENT_UTIL_ASSERT_CONDITION(1 != 2, "1 is not same as 2");
+ }
+ * @endcode
+ *
+ * @param[in] condition checking condition
+ * @param[in] text string to print out on condition failed case
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+#define SYNC_AGENT_UTIL_ASSERT_CONDITION(condition, text) do {\
+               if (!(condition)) {\
+                       _DEBUG_ERROR("(assertion failed) text : %s, condition failed at : %s", text, #condition);\
+                       abort();\
+               } \
+       } while (0)
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_ASSERT_H_ */
diff --git a/include/utility/fw_async_queue.h b/include/utility/fw_async_queue.h
new file mode 100755 (executable)
index 0000000..86a58e5
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_ASYNC_QUEUE_H_
+#define FW_ASYNC_QUEUE_H_
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_async_queue.h
+ * @brief      provide DataStructure - asynchronous Queue
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * Function which is determined priority
+ *
+ * @param[in] msg1 item
+ * @param[in] msg2 compare item
+ * @param[in] user_data user_data
+ *
+ * @return -1 on msg1's priority < msg2's priority, 0 on msg1's priority == msg2's priority, 1 on msg1's priority > msg2's priority
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef int (*sync_agent_compare_priority_cb) (const void *msg1, const void *msg2, void *user_data);
+
+/**
+ * Structure of asynchronous Queue
+ */
+       typedef struct utility_async_queue sync_agent_util_async_queue_s;
+       struct utility_async_queue {
+               GAsyncQueue *pQueue;    /**< real queue data structure */
+       };
+
+/**
+ * API to create empty asynchronous Queue
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_async_queue_s *queue = NULL;
+               queue = sync_agent_alloc_async_queue();
+               if (queue == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @return created asynchronous queue on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_alloc_async_queue()
+ *
+ */
+       sync_agent_util_async_queue_s *sync_agent_alloc_async_queue(void);
+
+/**
+ * API to pop item from asynchronous Queue
+ * @remarks Blocking until enter item to Queue
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_async_queue_s *queue = NULL;
+               queue = sync_agent_alloc_async_queue();
+               if (queue == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               void *queue_data = sync_agent_receive_msg_async_queue(queue);
+               if (queue_data == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in]  queue asynchronous Queue
+ *
+ * @return item on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_receive_msg_async_queue(sync_agent_util_async_queue_s *)
+ *
+ */
+       void *sync_agent_receive_msg_async_queue(sync_agent_util_async_queue_s * queue);
+
+/**
+ * API to send item to asynchronous Queue
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_async_queue_s *queue = NULL;
+               queue = sync_agent_alloc_async_queue();
+               if (queue == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               void *item = NULL;
+               ...
+               sync_agent_send_msg_async_queue(queue, (void *)item);
+ *
+ * @endcode
+ *
+ * @param[in] queue asynchronous Queue
+ * @param[in] msg item
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_send_msg_async_queue(sync_agent_util_async_queue_s *, void *)
+ *
+ */
+       void sync_agent_send_msg_async_queue(sync_agent_util_async_queue_s * queue, void *msg);
+
+/**
+ * API to get queue length
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_async_queue_s *queue = NULL;
+               queue = sync_agent_alloc_async_queue();
+               if (queue == NULL) {
+                       // error handling
+                       ...
+               }
+               ...
+               int queue_length = sync_agent_async_queue_length(queue);
+ *
+ * @endcode
+ *
+ * @param[in] queue asynchronous Queue
+ *
+ * @return queue length
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_async_queue_length(sync_agent_util_async_queue_s *)
+ *
+ */
+       int sync_agent_async_queue_length(sync_agent_util_async_queue_s * queue);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_ASYNC_QUEUE_H_ */
diff --git a/include/utility/fw_compress.h b/include/utility/fw_compress.h
new file mode 100755 (executable)
index 0000000..b600cf7
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_COMPRESS_H_
+#define FW_COMPRESS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_compress.h
+ * @brief Provides folder de/compress operations
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * Enumerations of compress result
+ */
+       typedef enum {
+               SYNC_AGENT_UTIL_COMPRESS_SUCCESS = 1,
+                                             /**< operation success */
+               SYNC_AGENT_UTIL_COMPRESS_FAIL
+                                     /**< operation failed */
+       } sync_agent_util_compress_result_e;
+
+/**
+ * Enumerations of compress type
+ */
+       typedef enum {
+               SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR = 1,
+                                              /**< compress type : tar */
+               SYNC_AGENT_UTIL_COMPRESS_TYPE_ZIP
+                                         /**< compress type : zip */
+       } sync_agent_util_compress_type_e;
+
+/**
+ * API to compress folder into desired format
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_compress_result_e result = SYNC_AGENT_UTIL_COMPRESS_SUCCESS;
+               sync_agent_util_compress_type_e type = SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR;
+               char *input_path = NULL;
+               char *output_path = NULL;
+               ...
+               result = sync_agent_compress(type, input_path, output_path);
+               if (result != SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] type type of compress in sync_agent_util_compress_type_e type of value
+ * @param[in] input_directory_path folder path to compress
+ * @param[in] output_file_path path to put compressed file
+ *
+ * @return SYNC_AGENT_UTIL_COMPRESS_SUCCESS on success, SYNC_AGENT_UTIL_COMPRESS_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_compress(sync_agent_util_compress_type_e, const char *, const char *)
+ *
+ */
+       sync_agent_util_compress_result_e sync_agent_compress(sync_agent_util_compress_type_e type, const char *input_directory_path, const char *output_file_path);
+
+/**
+ * API to decompress compressed file in specific format
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_compress_type_e type = SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR;
+               char *input_path = NULL;
+               char *output_path = NULL;
+               ...
+               result = sync_agent_uncompress(type, input_path, output_path);
+               if (result != SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] type type of compress in sync_agent_util_compress_type_e type of value
+ * @param[in] input_file_path compressed file path to decompress
+ * @param[in] output_direcory_path path to put decompressed folder
+ *
+ * @return SYNC_AGENT_UTIL_COMPRESS_SUCCESS on success, SYNC_AGENT_UTIL_COMPRESS_FAIL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_uncompress(sync_agent_util_compress_type_e, const char *, const char *)
+ *
+ */
+       sync_agent_util_compress_result_e sync_agent_uncompress(sync_agent_util_compress_type_e type, const char *input_file_path, const char *output_direcory_path);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_COMPRESS_H_ */
diff --git a/include/utility/fw_file.h b/include/utility/fw_file.h
new file mode 100755 (executable)
index 0000000..f274bfb
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_FILE_H_
+#define FW_FILE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_file.h
+ * @brief Provides file read/write operations below the specific folder (/opt/data/sync-agent/db)
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * API to write data below the specific folder (/opt/data/sync-agent/db)
+ *
+ * @par Usage:
+ * @code
+               char *path = NULL;
+               int data = 0;
+               ...
+               int result = sync_agent_set_int_into_file(path, data);
+               if (result != 1) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] file_path file path which you want to write
+ * @param[in] value value to write
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_set_int_into_file(char *, int)
+ *
+ */
+       int sync_agent_set_int_into_file(char *file_path, int value);
+
+/**
+ * API to read data below the specific folder (/opt/data/sync-agent/db)
+ *
+ * @par Usage:
+ * @code
+               char *path = NULL;
+               int data = 0;
+               ...
+               int result = sync_agent_get_int_from_file(path, &data);
+               if (result != 1) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] file_path file path which you want to read
+ * @param[in] value as returned by sync_agent_get_int_from_file
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_int_from_file(char *, int *)
+ *
+ */
+       int sync_agent_get_int_from_file(char *file_path, int *value);
+
+/**
+ * API to delete file below the specific folder (/opt/data/sync-agent/db)
+ *
+ * @par Usage:
+ * @code
+               char *path = NULL;
+               ...
+               int result = sync_agent_unset_file(path);
+               if (result != 1) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] file_path file path which you want to delete
+ *
+ * @return 1 on success, 0 on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_unset_file(char *)
+ *
+ */
+       int sync_agent_unset_file(char *file_path);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_FILE_H_ */
diff --git a/include/utility/fw_mainloop.h b/include/utility/fw_mainloop.h
new file mode 100755 (executable)
index 0000000..bd144a2
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_MAINLOOP_H_
+#define FW_MAINLOOP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_mainloop.h
+ * @brief Provides main-loop manipulation functionality
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * API to create and run the main loop
+ *
+ * @par Usage:
+ * @code
+               int use_thread = 0;
+               ...
+               sync_agent_run_main_loop(use_thread);
+ *
+ * @endcode
+ *
+ * @param[in] use_thread 1 creating thread to run the main loop, otherwise (run the main loop on same thread) 0
+ *
+ * @par Since:
+ *
+ *
+ * @see        sync_agent_run_main_loop(int)
+ *
+ */
+       void sync_agent_run_main_loop(int use_thread);
+
+/**
+ * API to stop the main loop which is running currently
+ *
+ * @par Usage:
+ * @code
+                int use_thread = 0;
+                ...
+                sync_agent_run_main_loop(use_thread);
+                ...
+                sync_agent_stop_main_loop(use_thread);
+ *
+ * @endcode
+ *
+ * @param[in] use_thread same parameter value used at sync_agent_run_main_loop()
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_stop_main_loop(int)
+ *
+ */
+       void sync_agent_stop_main_loop(int use_thread);
+
+/**
+ * API to get the main loop object
+ *
+ * @par Usage:
+ * @code
+               GMainLoop *loop = NULL;
+               ...
+               loop = (GMainLoop *)sync_agent_get_main_loop();
+ *
+ * @endcode
+ *
+ * @return main loop object which is running currently on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_main_loop()
+ *
+ */
+       void *sync_agent_get_main_loop();
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_MAINLOOP_H_ */
diff --git a/include/utility/fw_ref.h b/include/utility/fw_ref.h
new file mode 100755 (executable)
index 0000000..93c82df
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_REF_H_
+#define FW_REF_H_
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_ref.h
+ * @brief Provides conversion service from regular object to referenced object
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * Function which is called when need to alloc some object
+ *
+ * @return object to alloc on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       typedef void *(*sync_agent_alloc_cb) (void);
+
+/**
+ * Function which is called when need to free some object
+ *
+ * @param[in] void* object to free
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_referenced_object(void *, sync_agent_free_cb)
+ *
+ */
+       typedef void (*sync_agent_free_cb) (void *);
+
+/**
+ * Structure of referenced object
+ */
+       typedef struct utility_ref_object {
+               int refcount;           /**< Reference count */
+               void *data;             /**< Void pointer for original regular object */
+               sync_agent_free_cb free_func;
+                                    /**< Free function */
+       } sync_agent_util_ref_object_s;
+
+/**
+ * API to create referenced object using given data with void pointer and function pointer for free logic
+ *
+ * @par Usage:
+ * @code
+               void data_free_cb(void *data)
+               {
+               }
+               ...
+               void *data = NULL;
+               ...
+               sync_agent_util_ref_object_s *ref_obj = sync_agent_create_referenced_object(data, data_free_cb);
+               if (ref_obj == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] data data to maintain reference information for
+ * @param[in] data_free_func function pointer for free logic
+ *
+ * @return referenced object in sync_agent_util_ref_object_s type of structure on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_referenced_object(void *, sync_agent_free_cb)
+ *
+ */
+       sync_agent_util_ref_object_s *sync_agent_create_referenced_object(void *data, sync_agent_free_cb data_free_func);
+
+/**
+ * API to return referenced object using already referenced object and just increase reference count
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_ref_object_s *object = NULL;
+               ...
+               sync_agent_util_ref_object_s *ref_obj = sync_agent_get_referenced_object(object);
+               if (ref_obj == NULL) {
+                       // error handling
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] object referenced object to increase reference count by 1
+ *
+ * @return referenced object in sync_agent_util_ref_object_s type of structure on success, NULL on error
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_referenced_object(sync_agent_util_ref_object_s *)
+ *
+ */
+       sync_agent_util_ref_object_s *sync_agent_get_referenced_object(sync_agent_util_ref_object_s * object);
+
+/**
+ * API to return original object taking from referenced object
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_ref_object_s *ref_obj = NULL;
+               ...
+               void *origin_obj = sync_agent_get_original_object(ref_obj);
+ *
+ * @endcode
+ *
+ * @param[in] object referenced object
+ *
+ * @return original object
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_original_object(sync_agent_util_ref_object_s *)
+ *
+ */
+       void *sync_agent_get_original_object(sync_agent_util_ref_object_s * object);
+
+/**
+ * API to compares if two referenced object has same original object
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_ref_object_s *obj1 = NULL;
+               sync_agent_util_ref_object_s *obj2 = NULL;
+               ...
+               bool is_same = sync_agent_compare_object(obj1, obj2);
+               if (is_same) {
+                       // same case
+                       ...
+               } else {
+                       // different case
+                       ...
+               }
+ *
+ * @endcode
+ *
+ * @param[in] object1 referenced object to compare with
+ * @param[in] object2 referenced object to compare with
+ *
+ * @return 1 when two are same, otherwise 0
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_compare_object(sync_agent_util_ref_object_s *, sync_agent_util_ref_object_s *)
+ *
+ */
+       bool sync_agent_compare_object(sync_agent_util_ref_object_s * object1, sync_agent_util_ref_object_s * object2);
+
+/**
+ * API to decrease reference count of given referenced object
+ * The object will be freed in case reference count becomes 0
+ *
+ * @par Usage:
+ * @code
+               sync_agent_util_ref_object_s *ref_obj = NULL;
+               ...
+               if (ref_obj != NULL) {
+                       sync_agent_unref_referenced_object(ref_obj);
+               }
+ *
+ * @endcode
+ *
+ * @param[in] ref referenced object to decrease ref count by 1
+ *
+ * @par Since:
+ *
+ *
+ * @see        sync_agent_unref_referenced_object(sync_agent_util_ref_object_s *)
+ *
+ */
+       void sync_agent_unref_referenced_object(sync_agent_util_ref_object_s * ref);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_REF_H_ */
diff --git a/include/utility/fw_time.h b/include/utility/fw_time.h
new file mode 100755 (executable)
index 0000000..6633dba
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_TIME_H_
+#define FW_TIME_H_
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_time.h
+ * @brief Provides time manipulation functionality
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define SYNC_AGENT_UTIL_TIME_T time_t
+
+#define SYNC_AGENT_UTIL_TIME(t)                        time(t)
+
+#define SYNC_AGENT_UTIL_TM                     struct tm
+
+#define SYNC_AGENT_UTIL_LOCALTIME(time) localtime(time)
+
+#define SYNC_AGENT_UTIL_MKTIME(tm_time)        mktime(tm_time)
+
+/**
+ * API to convert time stamp in second to UTC time stamp
+ *
+ * @par Usage:
+ * @code
+               int sessionTime = sync_agent_convert_seconds_to_utc(time(NULL));
+ *
+ * @endcode
+ *
+ * @param[in]  seconds time stamp in second
+ *
+ * @return UTC time stamp
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_convert_seconds_to_utc(int)
+ *
+ */
+       int sync_agent_convert_seconds_to_utc(int seconds);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_TIME_H_ */
diff --git a/include/utility/sync_util.h b/include/utility/sync_util.h
new file mode 100755 (executable)
index 0000000..48f9b54
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNC_UTIL_H_
+#define SYNC_UTIL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+#include <string.h>
+
+#include <dlog.h>
+
+#include <libgen.h>
+
+/**
+ * @file sync_util.h
+ * @brief Provides logging macro
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define COLOR_BLACK            "\033[0;30m"
+#define COLOR_RED                      "\033[0;31m"
+#define COLOR_GREEN            "\033[0;32m"
+#define COLOR_YELLOW           "\033[0;33m"
+#define COLOR_BLUE             "\033[0;34m"
+#define COLOR_MARGENTA "\033[0;35m"
+#define COLOR_CYAN             "\033[0;36m"
+#define COLOR_WHITE            "\033[0;37m"
+#define COLOR_END                      "\033[0;m"
+
+#if COMPONENT_TAG == SYSTEM
+#define _DEBUG_VERBOSE(fmt, args...)           SLOGV(" " fmt, ##args)
+#define _DEBUG_TRACE(fmt, args...)             SLOGD(" " fmt, ##args)
+#define _DEBUG_INFO(fmt, args...)              SLOGI(COLOR_YELLOW fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...)           SLOGW(COLOR_MARGENTA" * Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_ERROR(fmt, args...)             SLOGE(COLOR_RED" * Critical * " fmt COLOR_END, ##args)
+#define _INNER_FUNC_ENTER                                      SLOGD(COLOR_CYAN" ENTER >>>"COLOR_END)
+#define _INNER_FUNC_EXIT                                       SLOGD(COLOR_CYAN" EXIT <<<"COLOR_END)
+#define _EXTERN_FUNC_ENTER                             SLOGI(COLOR_GREEN" ENTER >>>"COLOR_END)
+#define _EXTERN_FUNC_EXIT                                      SLOGI(COLOR_GREEN" EXIT <<<"COLOR_END)
+#elif COMPONENT_TAG == APP
+#define _DEBUG_VERBOSE(fmt, args...)           ALOGV(" " fmt, ##args)
+#define _DEBUG_TRACE(fmt, args...)             ALOGD(" " fmt, ##args)
+#define _DEBUG_INFO(fmt, args...)              ALOGI(COLOR_YELLOW fmt COLOR_END, ##args)
+#define _DEBUG_WARNING(fmt, args...)           ALOGW(COLOR_MARGENTA" * Warning * " fmt COLOR_END, ##args)
+#define _DEBUG_ERROR(fmt, args...)             ALOGE(COLOR_RED" * Critical * " fmt COLOR_END, ##args)
+#define _INNER_FUNC_ENTER                                      ALOGD(COLOR_CYAN" ENTER >>>"COLOR_END)
+#define _INNER_FUNC_EXIT                                       ALOGD(COLOR_CYAN" EXIT <<<"COLOR_END)
+#define _EXTERN_FUNC_ENTER                             ALOGI(COLOR_GREEN" ENTER >>>"COLOR_END)
+#define _EXTERN_FUNC_EXIT                                      ALOGI(COLOR_GREEN" EXIT <<<"COLOR_END)
+#endif
+
+#define warn_if(expr, fmt, arg...)             \
+       do {                                    \
+               if (expr) {                     \
+                       _DEBUG_WARNING(fmt, ##arg);     \
+               }                               \
+       } while (0)
+#define ret_if(expr)                           \
+       do {                                    \
+               if (expr) {                     \
+                       return;                 \
+               }                               \
+       } while (0)
+#define retv_if(expr, val)\
+       do {                                    \
+               if (expr) {                     \
+                       return (val);           \
+               }                               \
+       } while (0)
+#define retm_if(expr, fmt, arg...)             \
+       do {                                    \
+               if (expr) {                     \
+                       _DEBUG_ERROR(fmt, ##arg);       \
+                       return;                 \
+               }                               \
+       } while (0)
+#define retvm_if(expr, val, fmt, arg...)       \
+       do {                                    \
+               if (expr) {                     \
+                       _DEBUG_ERROR(fmt, ##arg);       \
+                       return (val);           \
+               }                               \
+       } while (0)
+
+#define _ASSERT(cond, ret)                                     \
+       do {                                                    \
+               if (!(cond)) {                                  \
+                       _DEBUG_ERROR("_ASSERT fails");  \
+                       return (ret);                           \
+               }                                               \
+       } while (0)
+
+/**
+ * API to daemonize client agent
+ *
+ * @par Usage:
+ * @code
+               if (sync_agent_daemonize() < 0) {
+                       _DEBUG_ERROR("daemonize error");
+                       // error handling
+                       ...
+               }
+ *
+ *     @endcode
+ *
+ *     @return 0 on success, -1 on error
+ *
+ *     @par Since:
+ *
+ *
+ *     @see sync_agent_daemonize()
+ *
+ */
+       int sync_agent_daemonize(void);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* SYNC_UTIL_H_ */
diff --git a/include/utility/utility.h b/include/utility/utility.h
new file mode 100755 (executable)
index 0000000..92cd66a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fw_assert.h"
+#include "fw_async_queue.h"
+#include "fw_compress.h"
+#include "fw_file.h"
+#include "fw_mainloop.h"
+#include "fw_ref.h"
+#include "fw_time.h"
+#include "sync_util.h"
diff --git a/packaging/sync-agent.spec b/packaging/sync-agent.spec
new file mode 100755 (executable)
index 0000000..820c986
--- /dev/null
@@ -0,0 +1,120 @@
+Name:       sync-agent
+Summary:    Sync agent FW Library
+Version:    0.1.8
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    Apache License, Version 2.0
+Source0:    sync-agent-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(libsoup-2.4)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(uuid)
+BuildRequires:  pkgconfig(msg-service)
+BuildRequires:  pkgconfig(libxml-2.0)
+BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(calendar-service2)
+BuildRequires:  pkgconfig(pmapi)
+BuildRequires:  pkgconfig(accounts-svc)
+BuildRequires:  pkgconfig(email-service)
+BuildRequires:  pkgconfig(contacts-service2)
+BuildRequires:  pkgconfig(kies_alarm)
+BuildRequires:  pkgconfig(memo)
+BuildRequires:  pkgconfig(push)
+BuildRequires:  pkgconfig(alarm-service)
+BuildRequires:  pkgconfig(location)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(sysman)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(appsvc)
+BuildRequires:  pkgconfig(libcurl)
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(syspopup-caller)
+BuildRequires:  pkgconfig(capi-network-connection)
+BuildRequires:  pkgconfig(capi-network-serial)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  libgcrypt-devel
+BuildRequires:  cmake
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+
+%description
+sync-agent library (development headers)
+
+
+%package devel
+Summary:    Development files for %{name}
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+%description devel
+Development files for %{name}
+
+
+#%package -n common-private-plugins
+#Summary:    Common Private Plugins
+#Group:      TO_BE_FILLED
+
+#%description -n common-private-plugins
+#common private plugins for sync-agent
+
+
+%package -n common-public-plugins
+Summary:    Common Public Plugins
+Group:      TO_BE_FILLED
+
+%description -n common-public-plugins
+common public plugins for sync-agent
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest sync-agent.manifest
+%defattr(-,root,root,-)
+%{_libdir}/*.so
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/sync_agent.h
+%{_includedir}/sync-agent/*
+%{_libdir}/*.so
+%{_libdir}/*.so.*
+%{_libdir}/pkgconfig/sync-agent.pc
+
+
+#%files -n common-private-plugins
+#%manifest common-private-plugins.manifest
+#%defattr(-,root,root,-)
+#/usr/lib/sync-agent/common-private/*
+
+
+%files -n common-public-plugins
+%manifest common-public-plugins.manifest
+%defattr(-,root,root,-)
+/usr/lib/sync-agent/common-public/*
+
diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c2f9b3e
--- /dev/null
@@ -0,0 +1,98 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set a name for the entire project
+PROJECT(sync-agent)
+
+SET(LIBNAME "lib${PROJECT_NAME}")
+SET(LIBDIR "${PREFIX}/lib")
+
+# set variables
+SET(FW_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../include")
+SET(FW_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../src/framework")
+SET(FW_COMPONETS "account;data-adapter;device;device-manager;engine-controller;event;fsapi;initialization;network-access;platform-monitor;plugin;protocol-binder;security-assistant;utility")
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(LPKGS REQUIRED
+                                       glib-2.0
+                                       sqlite3
+                                       libsoup-2.4
+                                       vconf
+                                       uuid
+                                       msg-service
+                                       libxml-2.0
+                                       libwbxml2
+                                       dlog
+                                       )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
+#SET(EXTRA_CFLAGS "-fvisibility=hidden ${EXTRA_CFLAGS}")
+
+# find all source files in a directory.
+FOREACH(FW_COMPONENT ${FW_COMPONETS})
+       AUX_SOURCE_DIRECTORY(${FW_SRC_DIR}/${FW_COMPONENT} SRCS)
+ENDFOREACH(FW_COMPONENT)
+
+# add include directories to the build.
+INCLUDE_DIRECTORIES(${FW_INCLUDE_DIR})
+FOREACH(FW_COMPONENT ${FW_COMPONETS})
+       INCLUDE_DIRECTORIES(${FW_INCLUDE_DIR}/${FW_COMPONENT})
+ENDFOREACH(FW_COMPONENT)
+INCLUDE_DIRECTORIES(${FW_SRC_DIR})
+FOREACH(FW_COMPONENT ${FW_COMPONETS})
+       INCLUDE_DIRECTORIES(${FW_SRC_DIR}/${FW_COMPONENT})
+ENDFOREACH(FW_COMPONENT)
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# add a library to the project using the specified source files.
+ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
+
+# link a target to given libraries from pkg-config.
+TARGET_LINK_LIBRARIES(${LIBNAME} ${LPKGS_LDFLAGS} "-lgcrypt")
+
+# sets additional compiler flags used to build sources within the target.
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+# override the default target name prefix (such as "lib")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+
+# specify the build version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
+
+# specify the api version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+# install library files
+INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIBDIR})
+
+# install .pc file
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+# install header files
+INSTALL(FILES ${FW_INCLUDE_DIR}/sync_agent.h DESTINATION include/)
+FOREACH(FW_COMPONENT ${FW_COMPONETS})
+       INSTALL(DIRECTORY ${FW_INCLUDE_DIR}/${FW_COMPONENT}/ DESTINATION include/sync-agent/${FW_COMPONENT} FILES_MATCHING PATTERN "*.h")
+ENDFOREACH(FW_COMPONENT)
+
+ADD_DEFINITIONS("-DGLIB_VERSION_MIN_REQUIRED=(2<<16|32<<8) ")
diff --git a/src/framework/account/manager.c b/src/framework/account/manager.c
new file mode 100755 (executable)
index 0000000..22ec86e
--- /dev/null
@@ -0,0 +1,306 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/account_plugin.h"
+#include "utility/fw_alloc.h"
+#include "utility/sync_util.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_ACCOUNT"
+#endif
+
+EXPORT_API sync_agent_acc_error_e sync_agent_create_fw_account(sync_agent_fw_account_s ** fw_account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+
+       sync_agent_fw_account_s *temp_fw_account = (sync_agent_fw_account_s *) calloc(1, sizeof(sync_agent_fw_account_s));
+       if (temp_fw_account == NULL) {
+               _DEBUG_ERROR("service_account_info is null!!");
+               *fw_account = NULL;
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       *fw_account = temp_fw_account;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_add_fw_account(sync_agent_fw_account_s * fw_account, int *account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+
+       retvm_if(fw_account == NULL, SYNC_AGENT_ACC_FAIL, "sync_agent_fw_account_s is NULL !!");
+
+       /* insert account info to Sync Agent DB account database */
+       int account = da_add_fw_account_id(fw_account);
+       if (account == -1) {
+               _DEBUG_ERROR("[sync_agent_add_fw_account] Error");
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       /*
+        * todo Process Platform Specific Account
+        */
+       acc_add_platform_account(account);
+
+       /* Update ServerInfo */
+
+       /*
+        * todo Update Policy
+        */
+
+       *account_id = account;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_update_fw_account(sync_agent_fw_account_s * account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+
+       retvm_if(account == NULL, SYNC_AGENT_ACC_FAIL, "sync_agent_fw_account_s is NULL !!");
+
+       result = da_update_fw_account_id(account);
+       if (result != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_update_fw_account] Error");
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_delete_fw_account(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+       /* Remove from Service DB & Syncagent DB */
+       sync_agent_da_return_e result = da_delete_all_database_account(account_id);
+       if ((result == SYNC_AGENT_DA_SUCCESS) || (result == SYNC_AGENT_DA_ERR_DELETE_LAST_ACCOUNT)) {
+               /* Update the Cache */
+
+               /*
+                * todo Remove from Platform account database
+                */
+               acc_delete_platform_account(account_id);
+
+               return err_code;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_ACC_FAIL;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_get_fw_account(int account_id, sync_agent_fw_account_s ** account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+
+       result = da_get_fw_account_info(account_id, account);
+       if (result != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_update_fw_account] Error");
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_query_fw_account(sync_agent_fw_account_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+       sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+
+       retvm_if(query == NULL, SYNC_AGENT_ACC_FAIL, "sync_agent_fw_account_query_s is NULL !!");
+
+       int account_cnt = 0;
+       int *account_id_list = 0;
+       GList *account_list = NULL;
+       int i = 0;
+       int account_id = 0;
+       sync_agent_fw_account_s *account_info = NULL;
+
+       switch (query->query) {
+       case ACCOUNT_QUERY_BY_NONE:
+               {
+                       result = da_get_all_fw_account_info(list);
+                       if (result != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("[da_get_all_fw_account_info] Error");
+                               err_code = SYNC_AGENT_ACC_FAIL;
+                       }
+               }
+               break;
+       case ACCOUNT_QUERY_BY_ACCESS_NAME:
+               {
+                       result = da_get_fw_account_info_by_access_name(query->access_name, list);
+                       if (result != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("[da_get_fw_account_info_by_access_name] Error");
+                               err_code = SYNC_AGENT_ACC_FAIL;
+                       }
+               }
+               break;
+       case ACCOUNT_QUERY_BY_SERVICE_TYPE:
+               {
+                       account_id_list = acc_get_fw_account_id_list(query->service_type, &account_cnt);
+
+                       if (account_id_list != NULL) {
+                               for (i = 0; i < account_cnt; i++) {
+
+                                       err_code = sync_agent_create_fw_account(&account_info);
+                                       if (err_code != SYNC_AGENT_ACC_SUCCESS) {
+                                               _DEBUG_ERROR("[sync_agent_create_fw_account] Error");
+                                               err_code = SYNC_AGENT_ACC_FAIL;
+
+                                               if (account_list != NULL)
+                                                       sync_agent_free_fw_account_list(account_list);
+
+                                               if (account_id_list != NULL)
+                                                       free(account_id_list);
+
+                                               return err_code;
+                                       }
+
+                                       result = da_get_fw_account_info(account_id_list[i], &account_info);
+                                       if (result != SYNC_AGENT_DA_SUCCESS) {
+                                               _DEBUG_ERROR("[da_get_fw_account_info] Error");
+
+                                               if (account_info != NULL)
+                                                       sync_agent_free_fw_account(account_info);
+
+                                               if (account_list != NULL)
+                                                       sync_agent_free_fw_account_list(account_list);
+
+                                               if (account_id_list != NULL)
+                                                       free(account_id_list);
+
+                                               err_code = SYNC_AGENT_ACC_FAIL;
+                                               return err_code;
+                                       }
+
+                                       account_list = g_list_append(account_list, account_info);
+                               }
+                       }
+
+                       *list = account_list;
+
+                       if (account_id_list != NULL)
+                               free(account_id_list);
+               }
+               break;
+       case ACCOUNT_QUERY_BY_SERVICE_TYPE_SERVICE_ID_INDEX:
+               {
+                       account_id = acc_get_fw_account_id(query->service_type, query->service_account_id, query->index);
+
+                       err_code = sync_agent_create_fw_account(&account_info);
+                       if (err_code != SYNC_AGENT_ACC_SUCCESS) {
+                               _DEBUG_ERROR("[sync_agent_create_fw_account] Error");
+                               err_code = SYNC_AGENT_ACC_FAIL;
+                               return err_code;
+                       }
+                       result = da_get_fw_account_info(account_id, &account_info);
+                       if (result != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("[sync_agent_get_fw_account_id] Error");
+                               err_code = SYNC_AGENT_ACC_FAIL;
+
+                               if (account_info != NULL)
+                                       sync_agent_free_fw_account(account_info);
+
+                               return err_code;
+                       }
+
+                       account_list = g_list_append(account_list, account_info);
+                       *list = account_list;
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API void sync_agent_free_fw_account(sync_agent_fw_account_s * fw_account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (fw_account != NULL) {
+               if (fw_account->email != NULL)
+                       free(fw_account->email);
+
+               if (fw_account->password != NULL)
+                       free(fw_account->password);
+
+               if (fw_account->access_name != NULL)
+                       free(fw_account->access_name);
+
+               free(fw_account);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_fw_account_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GList *iter = NULL;
+       if (list != NULL) {
+               for (iter = list; iter != NULL; iter = g_list_next(iter))
+                       sync_agent_free_fw_account(iter->data);
+
+               g_list_free(list);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/account/service.c b/src/framework/account/service.c
new file mode 100755 (executable)
index 0000000..dcc2cde
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/account_plugin.h"
+#include "utility/fw_alloc.h"
+#include "utility/sync_util.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "account/service.h"
+#include "account/util_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_ACCOUNT"
+#endif
+
+EXPORT_API sync_agent_acc_error_e sync_agent_construct_account_tbl_from_service()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+       int fw_account_id_cnt = 0;
+       int content_count = 0;
+       int *fw_account_id_list = NULL;
+       int *service_plugin_id_list = plugin_get_data_connector_plugin_id_list(&content_count);
+
+       if (service_plugin_id_list == NULL) {
+               _DEBUG_INFO("No Data PlugIn loaded!!");
+               err_code = SYNC_AGENT_ACC_SUCCESS;
+               goto return_part;
+       }
+
+       int index = 0;
+       for (; index < content_count; index++) {
+               int service = service_plugin_id_list[index];
+               _DEBUG_INFO("Service ID : %d", service);
+
+               // Get account id List from agent account table
+               fw_account_id_list = da_get_account_id_list(&fw_account_id_cnt);
+
+               _DEBUG_INFO("fw_account_id_cnt : %d", fw_account_id_cnt);
+
+               //Get current All Service Account ID
+               plugin_get_account_id_list_cb func_get_service_account_id_list = plugin_get_function_get_account_id_list(service);
+               if (func_get_service_account_id_list == NULL) {
+                       _DEBUG_INFO("func_get_service_account_id_list is null : %d", service);
+
+                       if (fw_account_id_list != NULL) {
+                               free(fw_account_id_list);
+                               fw_account_id_list = NULL;
+                       }
+                       continue;
+               }
+
+               int service_account_id_cnt;
+               int *service_account_id_list = func_get_service_account_id_list(&service_account_id_cnt);
+               if (service_account_id_list == NULL) {
+                       _DEBUG_ERROR("service_account_id_list is NULL!!");
+                       err_code = SYNC_AGENT_ACC_FAIL;
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("[%d] service_account_id_cnt : %d", service, service_account_id_cnt);
+
+               int *service_account_id_new = 0;
+               if (service_account_id_cnt != 0) {
+                       service_account_id_new = (int *)UTIL_MALLOC(sizeof(int) * service_account_id_cnt);
+                       if (service_account_id_new == NULL) {
+                               _DEBUG_ERROR("fw_malloc Failed!!");
+                               err_code = SYNC_AGENT_ACC_FAIL;
+                               goto return_part;
+                       }
+
+                       int i = 0;
+                       for (; i < service_account_id_cnt; i++) {
+                               service_account_id_new[i] = 1;
+                               _DEBUG_INFO("service_account_id_list[%d] : %d", i, service_account_id_list[i]);
+                       }
+               }
+
+               int i = 0;
+               for (; fw_account_id_list != 0 && i < fw_account_id_cnt; i++) {
+
+                       plugin_has_platform_account_service_cb func_has_platform_account_service = plugin_get_function_has_platform_account_service(plugin_get_account_plugin_id());
+                       int has_service_account_id = func_has_platform_account_service(fw_account_id_list[i], service);
+                       if (has_service_account_id) {
+
+                               // Get Service Account ID, Fw has
+                               int fw_service_account_id = acc_get_service_account_id(service, fw_account_id_list[i]);
+                               _DEBUG_INFO("fw_account_id_list[%d] : %d", i, fw_account_id_list[i]);
+                               _DEBUG_INFO("fw_service_account_id : %d", fw_service_account_id);
+
+                               int k = 0;
+                               for (; k < service_account_id_cnt; k++) {
+                                       if (fw_service_account_id == service_account_id_list[k]) {
+                                               _DEBUG_INFO("service_account_id_list[%d] : %d", k, service_account_id_list[k]);
+                                               service_account_id_new[k] = 0;
+                                               break;
+                                       }
+                               }
+
+                               _DEBUG_INFO("\n\nk : %d\n", k);
+                               // Delete fw_service_account_id from vconf
+                               if (k >= service_account_id_cnt) {
+                                       plugin_delete_platform_account_service_cb func_del_platform_account_service = plugin_get_function_delete_platform_account_service(plugin_get_account_plugin_id());
+                                       func_del_platform_account_service(fw_account_id_list[i], service);
+                                       err_code = SYNC_AGENT_ACC_CHANGED;
+                               }
+                       }
+               }
+
+               i = 0;
+               for (; i < service_account_id_cnt; i++) {
+                       if (service_account_id_new[i] == 1) {
+                               int k = 0;
+                               for (; fw_account_id_list != 0 && k < fw_account_id_cnt; k++) {
+                                       // find empty slot in fw_account_id_list[k]
+                                       plugin_has_platform_account_service_cb func_has_platform_account_service = plugin_get_function_has_platform_account_service(plugin_get_account_plugin_id());
+                                       int has_service_account_id = func_has_platform_account_service(fw_account_id_list[k], service);
+                                       if (!has_service_account_id) {
+                                               plugin_set_platform_account_service_cb pFunc_Set_PlatformAccount_Service = plugin_get_function_set_platform_account_service(plugin_get_account_plugin_id());
+                                               pFunc_Set_PlatformAccount_Service(fw_account_id_list[k], service, service_account_id_list[i]);
+                                               service_account_id_new[i] = 0;
+                                               break;
+                                       }
+                               }
+
+                               if (service_account_id_new[i] == 1) {
+                                       // Create new FW account and append service account id
+                                       _DEBUG_INFO("Create new FW account!!");
+                                       sync_agent_fw_account_s account;
+                                       account.email = "0";
+                                       account.password = "0";
+                                       account.access_name = "Account";
+
+                                       int fw_account_id = da_add_fw_account_id(&account);;
+                                       plugin_set_platform_account_service_cb func_set_platform_account_service = plugin_get_function_set_platform_account_service(plugin_get_account_plugin_id());
+                                       func_set_platform_account_service(fw_account_id, service, service_account_id_list[i]);
+                               }
+                               err_code = SYNC_AGENT_ACC_CHANGED;
+                       }
+               }
+
+               if (fw_account_id_list != NULL) {
+                       free(fw_account_id_list);
+                       fw_account_id_list = NULL;
+               }
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+
+       if (service_plugin_id_list != NULL) {
+               free(service_plugin_id_list);
+               service_plugin_id_list = NULL;
+       }
+       if (fw_account_id_list != NULL) {
+               free(fw_account_id_list);
+               fw_account_id_list = NULL;
+       }
+
+       _DEBUG_INFO("err_code = %d", err_code);
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_create_service_account_info(sync_agent_service_account_info_s ** account_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+
+       sync_agent_service_account_info_s *service_account_info = (sync_agent_service_account_info_s *) calloc(1, sizeof(sync_agent_service_account_info_s));
+       if (service_account_info == NULL) {
+               _DEBUG_ERROR("service_account_info is null!!");
+               *account_info = NULL;
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       *account_info = service_account_info;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_acc_error_e sync_agent_get_service_account(int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_acc_error_e err_code = SYNC_AGENT_ACC_SUCCESS;
+
+       plugin_get_service_account_info_cb func_get_service_account_info = plugin_get_function_get_service_account_info(plugin_get_account_plugin_id());
+
+       if (func_get_service_account_info == NULL) {
+               _DEBUG_ERROR("pFunc_Get_Service_AccountInfo is null!!");
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       int result = func_get_service_account_info(fw_account_id, service_type, account_info);
+       if (result == 0) {
+               _DEBUG_ERROR("failed in get_service_account_info");
+               err_code = SYNC_AGENT_ACC_FAIL;
+               return err_code;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API void sync_agent_free_service_account_info(sync_agent_service_account_info_s * account_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (account_info != NULL) {
+               if (account_info->email != NULL)
+                       free(account_info->email);
+
+               free(account_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/account/util.c b/src/framework/account/util.c
new file mode 100755 (executable)
index 0000000..0c657e4
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "utility/fw_ref.h"
+#include "plugin/account_plugin.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_ACCOUNT"
+#endif
+
+int acc_is_exist_account(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       return da_is_exist_account_id(account_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+int *acc_get_service_account_id_list(int service_type, int *cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int *account_id_list = acc_get_account_list(cnt);
+
+       if ((*cnt != 0) && (account_id_list != NULL)) {
+               int *service_account_id_list = (int *)calloc(*cnt, sizeof(int));
+               if (service_account_id_list == NULL) {
+
+                       if (account_id_list != NULL) {
+                               free(account_id_list);
+                       }
+
+                       *cnt = 0;
+                       return 0;
+               }
+
+               int i = 0;
+               for (; i < *cnt; i++) {
+                       service_account_id_list[i] = acc_get_service_account_id(service_type, account_id_list[i]);
+               }
+               if (account_id_list != NULL) {
+                       free(account_id_list);
+               }
+               return service_account_id_list;
+       }
+
+       if (account_id_list != NULL) {
+               free(account_id_list);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+int acc_get_service_account_id(int service_type, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_service_account_id_cb func = plugin_get_function_get_service_account_id(plugin_get_account_plugin_id());
+
+       if (func != NULL) {
+               int service_account_id = func(service_type, account_id);
+
+               return service_account_id;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return -1;
+}
+
+int acc_get_fw_account_id(int service_type, int service_account_id, int index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_fw_account_id_cb func = plugin_get_function_get_fw_account_id(plugin_get_account_plugin_id());
+
+       if (func != NULL) {
+               int account_id = func(service_type, service_account_id, index);
+
+               return account_id;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return -1;
+}
+
+int *acc_get_account_list(int *cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e da_err = sync_agent_open_agent();
+       _DEBUG_INFO("Done Open Agent DB : %d", da_err);
+
+       int *account_list = da_get_account_id_list(cnt);
+
+       da_err = sync_agent_close_agent();
+       _DEBUG_INFO("Done Close Agent DB : %d", da_err);
+
+       _EXTERN_FUNC_EXIT;
+
+       return account_list;
+}
+
+void acc_add_platform_account(int fw_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("sync_agent_add_platform_account called");
+       plugin_add_platform_account_cb func = plugin_get_function_add_platform_account(plugin_get_account_plugin_id());
+
+       if (func != NULL) {
+               _DEBUG_INFO("pFunc is not null");
+               func(fw_account_id);
+       } else {
+               _DEBUG_INFO("pFunc is null");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void acc_delete_platform_account(int fw_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("sync_agent_delete_platform_account called");
+       plugin_delete_platform_account_cb func = plugin_get_function_delete_platform_account(plugin_get_account_plugin_id());
+
+       if (func != NULL) {
+               _DEBUG_INFO("pFunc is not null");
+               func(fw_account_id);
+       } else {
+               _DEBUG_INFO("pFunc is null");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+int *acc_get_fw_account_id_list(int content_type, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = 0;
+       int fw_account_count = 0;
+       int *fw_account_id_list = da_get_account_id_list(&fw_account_count);
+
+       if (fw_account_count == 0 || fw_account_id_list == NULL) {
+
+               if (fw_account_id_list != NULL)
+                       free(fw_account_id_list);
+
+               return 0;
+       }
+
+       int *account_id_list = (int *)calloc(fw_account_count, sizeof(int));
+       if (account_id_list == NULL) {
+
+               if (fw_account_id_list != NULL)
+                       free(fw_account_id_list);
+
+               return 0;
+       }
+
+       int i = 0;
+       for (; i < fw_account_count; i++) {
+               plugin_has_platform_account_service_cb func_has_platform_account_service = plugin_get_function_has_platform_account_service(plugin_get_account_plugin_id());
+               int has_service_account_id = func_has_platform_account_service(fw_account_id_list[i], content_type);
+
+               if (has_service_account_id) {
+                       account_id_list[*count] = fw_account_id_list[i];
+                       *count = *count + 1;
+               }
+       }
+
+       if (fw_account_id_list != NULL) {
+               free(fw_account_id_list);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return account_id_list;
+}
diff --git a/src/framework/account/util_internal.h b/src/framework/account/util_internal.h
new file mode 100755 (executable)
index 0000000..9da2f73
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACCOUNT_UTIL_INTERNAL_H_
+#define ACCOUNT_UTIL_INTERNAL_H_
+
+#include "account/manager.h"
+
+/**
+ * @file       util_internal.h
+ * @brief      Util internal API for framework Account module
+ */
+
+/** @addtogroup account
+ *     @{
+ */
+
+/**
+ * @brief      Checking whether the account is exist
+ * @param[in]  account_id id of sync-agent-framework account database
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 not exist
+ */
+int acc_is_exist_account(int account_id);
+
+/**
+ * @brief Add platform account
+ * @param[in]  fw_account_id id of sync-agent-framework account
+ */
+void acc_add_platform_account(int fw_account_id);
+
+/**
+ * @brief Cancellation platform account with sync-agent-framework account
+ * @param[in]  fw_account_id id of sync-agent-framework account
+ */
+void acc_delete_platform_account(int fw_account_id);
+
+/**
+ * @brief Get service account id list concern of service_type
+ * @param[in]  service_type service data connector plugin's id described in sync-agent-framework config file
+ * @param[in] cnt      as returned by acc_get_service_account_id_list() - count of id
+ * @return account id lists    on success, NULL on error or not exist
+ */
+int *acc_get_service_account_id_list(int service_type, int *cnt);
+
+/**
+ * @brief Get service account id from sync-agent-framework account id
+ * @param[in]  service_type service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  account_id sync-agent-framework account id
+ * @return service account id (positive number) on success or exist mapping id, -100 on error or not exist mapping id
+ */
+int acc_get_service_account_id(int service_type, int account_id);
+
+/**
+ * @brief Get a list of account id
+ * @param[in]  count as returned by acc_get_account_list() - the current number of registered accounts
+ * @return a list of account id on success (registered accounts exist), NULL on error (not registered account)
+ */
+int *acc_get_account_list(int *count);
+
+/**
+ * @brief Get sync-agent-framework account id from service account id
+ * @param[in]  service_type service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  service_account_id sync-agent-framework account id
+ * @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
+ * @return             sync-agent-framework account id (positive number) on success, -1 on error or not exist mapping id
+ */
+int acc_get_fw_account_id(int service_type, int service_account_id, int index);
+
+/**
+ * @brief      Get sync-agent-framework account id list per service type
+ * @param[in]  content_type content type (Contact, Calendar, Memo ... )
+ * @param[in]  count as returned by acc_get_fw_account_id_list() - count of sync-agent-framework account id which have content type service account id
+ * @return list of sync-agent-framework account id on success, NULL on error
+ */
+int *acc_get_fw_account_id_list(int content_type, int *count);
+
+/**
+ * @}
+ */
+
+#endif                         /* ACCOUNT_UTIL_INTERNAL_H_ */
diff --git a/src/framework/data-adapter/agent.c b/src/framework/data-adapter/agent.c
new file mode 100755 (executable)
index 0000000..eb60abe
--- /dev/null
@@ -0,0 +1,5273 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/common_internal.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/agent.h"
+#include "data-adapter/luid.h"
+
+#include "data-adapter/interface_item.h"
+#include "data-adapter/interface_last_anchor.h"
+#include "data-adapter/interface_mapping.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+/* static function define */
+static int _busy_handler(void *pData, int count);
+static sync_agent_da_return_e __query_exec(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, char *err_msg);
+static daci_stmt __query_prepare(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, int size);
+static sync_agent_da_return_e __stmt_bind_text(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const char *value);
+static sync_agent_da_return_e _stmt_bind_int(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const int value);
+static sync_agent_da_return_e _stmt_bind_blob(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const void *value, int nbyte);
+static sync_agent_da_return_e __stmt_bind_null(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index);
+static sync_agent_da_return_e _stmt_read_step(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt);
+static sync_agent_da_return_e __stmt_write_step(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt);
+static sync_agent_da_return_e _stmt_reset(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt);
+static sync_agent_da_return_e __stmt_finalize(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt);
+static char *_stmt_column_text(daci_stmt stmt, int index);
+static int __stmt_column_int(daci_stmt stmt, int index);
+static sync_agent_da_return_e _get_table(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, char ***result, int *row_count, int *col_count);
+static void __free_table(char **result);
+
+static sync_agent_da_return_e _create_changelog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+static sync_agent_da_return_e _drop_changelog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+static sync_agent_da_return_e _delete_changlog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+static int __exist_table(SYNC_AGENT_DA_HANDLER * daci_handler, const char *table_name);
+static int _get_data_count(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, int size);
+static char *__replace_table_name(char *old, int account_id, int count);
+static char *__get_table_name(sync_agent_da_table_name_e table_name);
+static char *_get_column_name(sync_agent_da_column_name_e column_name);
+static int _get_next_account_id(void);
+static sync_agent_da_return_e _delete_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_table_name_e table_name, int account_id);
+
+static char *daci_file_path = 0;
+static pthread_t use_transaction_thread_id = 0;
+static pthread_mutex_t transaction_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t exec_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static char *g_daci_create_table[] = {
+       /* 1. create account_tbl */
+       "create table account_tbl" "(" "account_id integer not null," "email_address varchar(51) not null," "password varchar(51) not null," "enable boolean not null default 1," "last_update date not null default current_timestamp,"
+           "access_name varchar(64) not null," "constraint account_tbl_pk primary key(account_id)" ");",
+
+       /* 2. create folder_tbl */
+       "create table folder_tbl" "(" "folder_id varchar(64) not null," "data_store_id integer not null," "account_id integer not null," "folder_type_id integer not null," "service_id varchar(20) default null," "parent_folder_id varchar(64) default null,"
+           "last_update date not null default current_timestamp," "access_name varchar(64) not null," "constraint folder_tbl_pk primary key(folder_id)," "constraint folder_tbl_account_id_fk foreign key(account_id) references account_tbl(account_id)" ");",
+
+       /* 3. create item_tbl */
+       "create table item_tbl"
+           "("
+           "item_id varchar(64) not null,"
+           "data_store_id integer not null," "account_id integer not null," "folder_id varchar(64) not null," "service_id varchar(20) not null," "last_update date not null default current_timestamp," "access_name varchar(64) not null,"
+           "constraint item_tbl_pk primary key(item_id)," "constraint item_tbl_account_id_fk foreign key(account_id) references account_tbl(account_id)," "constraint itme_tbl_folder_id_fk foreign key(folder_id) references folder_tbl(folder_id),"
+           "constraint item_tbl_uk unique(data_store_id, account_id, service_id)" ");",
+
+       /* 4. create config_tbl */
+       "create table config_tbl" "(" "config_id integer not null," "key varchar(50) not null," "value varchar(30) default null," "type varchar(10) default null," "last_update date not null default current_timestamp," "access_name varchar(64) not null,"
+           "constraint config_tbl_pk primary key(config_id, Key)" ");",
+
+       /* 5. create account_item_changelog_tbl */
+       "create table account_%d_item_changelog_tbl" "(" "item_id varchar(64) not null," "operation_id integer not null," "status varchar(15) not null default \'SYNC_REQUIRED\'," "last_update date not null default current_timestamp,"
+           "access_name varchar(64) not null," "constraint account_%d_item_changelog_tbl_pk primary key(item_id)," "constraint account_%d_item_changelog_tbl_item_id_fk foreign key(item_id) references item_tbl(item_id)" ");",
+
+       /* 6. create last_anchor_tbl */
+       "create table last_anchor_tbl" "(" "account_id integer not null," "data_store_id integer not null," "last_anchor_server varchar(20) default null," "last_anchor_client varchar(20) default null," "last_update date not null default current_timestamp,"
+           "access_name varchar(64) not null," "constraint last_anchor_tbl_pk primary key(account_id, data_store_id)," "constraint last_anchor_tbl_account_id_fk foreign key(account_id) references account_tbl(account_id)" ");",
+
+       /* 7. create mapping_tbl */
+       "create table mapping_tbl" "(" "account_id integer not null," "data_store_id integer not null," "luid varchar(64) default null," "guid varchar(64) default null," "last_update date not null default current_timestamp,"
+           "access_name varchar(64) not null," "constraint mapping_tbl_pk primary key(account_id, luid)," "constraint mapping_tbl_account_id_fk foreign key(account_id) references account_tbl(account_id)" ");",
+
+       /* 8. create id_provider_tbl */
+       "create table id_provider_tbl" "(" "id_provider_code integer not null," "id_capacity integer not null," "bit_per_page integer not null," "last_id integer not null," "free_bit_cnt integer not null,"
+           "constraint id_provider_tbl_pk primary key(id_provider_code)" ");",
+
+       /* 9. create id_page_tbl */
+       "create table id_page_tbl" "(" "page_index integer not null," "id_provider_code integer not null," "page_bit BLOB," "constraint id_page_tbl_pk primary key(page_index, id_provider_code),"
+           "constraint id_page_tbl_fk foreign key(id_provider_code) references id_provider_tbl(id_provider_code)" ");"
+};
+
+static char *g_daci_drop_table[] = {
+       /* 1. drop account_tbl */
+       "drop table account_tbl",
+
+       /* 2. drop folder_tbl */
+       "drop table folder_tbl",
+
+       /* 3. drop item_tbl */
+       "drop table item_tbl",
+
+       /* 4. drop config_tbl */
+       "drop table config_tbl",
+
+       /* 5. drop account_item_changelog_tbl */
+       "drop table account_%d_item_changelog_tbl",
+
+       /* 6. drop last_anchor_tbl */
+       "drop table last_anchor_tbl",
+
+       /* 7. drop mapping_tbl */
+       "drop table mapping_tbl",
+
+       /* 8. drop id_provider_tbl */
+       "drop table id_provider_tbl",
+
+       /* 9. drop id_page_tbl */
+       "drop table id_page_tbl"
+};
+
+static char *g_daci_delete_table[] = {
+       /* 1. delete account_tbl */
+       "delete from account_tbl",
+
+       /* 2. delete folder_tbl */
+       "delete from folder_tbl",
+
+       /* 3. delete item_tbl */
+       "delete from item_tbl",
+
+       /* 4. delete config_tbl */
+       "delete from config_tbl",
+
+       /* 5. delete account_item_changelog_tbl */
+       "delete from account_%d_item_changelog_tbl",
+
+       /* 6. delete last_anchor_tbl */
+       "delete from last_anchor_tbl",
+
+       /* 7. delete mapping_tbl */
+       "delete from mapping_tbl",
+
+       /* 8. delete id_provider_tbl */
+       "delete from id_provider_tbl",
+
+       /* 9. delete id_page_tbl */
+       "delete from id_page_tbl"
+};
+
+sync_agent_da_return_e da_open_agent(SYNC_AGENT_DA_HANDLER ** daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 0;
+
+       if (*daci_handler == NULL) {
+
+               /* db open */
+               /*  ret = db_util_open(DACI_FILE_PATH, &(*daci_handler), 0); */
+
+               ret = sqlite3_open(daci_file_path, daci_handler);
+               if (ret != SQLITE_OK)
+                       goto DACI_FINISH;
+
+               /* register busy handler */
+               ret = sqlite3_busy_handler(*daci_handler, _busy_handler, 0);
+               if (ret != SQLITE_OK) {
+                       _DEBUG_INFO("Fail to register busy handler");
+                       goto DACI_FINISH;
+               }
+
+               _DEBUG_INFO("agent_db_open_success");
+
+       } else {
+               _DEBUG_INFO("agent_db_already_opened");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+
+ DACI_FINISH:
+
+       _DEBUG_ERROR("agent_open failed(%d) : %s", ret, sqlite3_errmsg(*daci_handler));
+
+       sqlite3_close(*daci_handler);
+       *daci_handler = 0;
+
+       return SYNC_AGENT_DA_ERR_OPEN_FAILED;
+}
+
+sync_agent_da_return_e da_close_Agent(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERR_CLOSE_FAILED, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+       ret = sqlite3_close(daci_handler);
+       daci_handler = 0;
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("agent_db_agent_close failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERR_CLOSE_FAILED;
+       }
+
+       _DEBUG_INFO("agent_db_agent_close_success");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e da_begin_transaction(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERR_TRANSACTION_FAILED, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       int err_mutex = pthread_mutex_lock(&transaction_lock);
+       if (err_mutex) {
+               _DEBUG_INFO("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+
+       use_transaction_thread_id = SYNC_AGENT_DA_GET_THREAD_ID;
+
+       ret = __query_exec(daci_handler, "begin immediate", "agent_db_begin_transaction failed");
+
+       if (ret == SYNC_AGENT_DA_ERR_QUERY_FAILED)
+               ret = SYNC_AGENT_DA_ERR_TRANSACTION_FAILED;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_end_transaction(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_transaction_e transaction)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERR_TRANSACTION_FAILED, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *query = 0;
+       char *err_msg = 0;
+
+       if (transaction == SYNC_AGENT_DA_TRANSACTION_COMMIT) {
+               query = "commit transaction";
+               err_msg = "agent_db_commit_transaction failed";
+       } else if (transaction == SYNC_AGENT_DA_TRANSACTION_ROLLBACK) {
+               query = "rollback transaction";
+               err_msg = "agent_db_rollback_transaction failed";
+       }
+
+       ret = __query_exec(daci_handler, query, err_msg);
+
+       use_transaction_thread_id = 0;
+       int err_mutex = pthread_mutex_unlock(&transaction_lock);
+       if (err_mutex) {
+               _DEBUG_INFO("Failed pthread_mutex_unlock : %d", err_mutex);
+       }
+
+       if (ret == SYNC_AGENT_DA_ERR_QUERY_FAILED) {
+               if (transaction == SYNC_AGENT_DA_TRANSACTION_COMMIT) {
+                       query = "rollback transaction";
+                       err_msg = "agent_db_rollback_transaction failed";
+                       ret = __query_exec(daci_handler, query, err_msg);
+                       if (ret == SYNC_AGENT_DA_SUCCESS)
+                               _DEBUG_INFO("agent_db_rollback_transaction success");
+               }
+               ret = SYNC_AGENT_DA_ERR_TRANSACTION_FAILED;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+void da_set_agent_db_file_path(char *file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(file_path == NULL, "file_path is NULL !!");
+
+       daci_file_path = file_path;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_da_return_e da_create_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if ((da_begin_transaction(daci_handler) != SYNC_AGENT_DA_SUCCESS)) {
+               _DEBUG_ERROR("agent_db_default_tbl_create failed");
+               return SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED;
+       }
+
+       /* 1. create account_tbl */
+       if (__exist_table(daci_handler, "account_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_ACCOUNT], "account_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 2. create folder_tbl */
+       if (__exist_table(daci_handler, "folder_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_FOLDER], "folder_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 3. create item_tbl */
+       if (__exist_table(daci_handler, "item_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_ITEM], "item_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 4. create config_tbl */
+       if (__exist_table(daci_handler, "config_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_CONFIG], "config_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 5. create last_anchor_tbl */
+       if (__exist_table(daci_handler, "last_anchor_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR], "last_anchor_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 6. create mapping_tbl */
+       if (__exist_table(daci_handler, "mapping_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_MAPPING], "mapping_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 7. create id_provider_tbl */
+       if (__exist_table(daci_handler, "id_provider_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_ID_PROVIDER], "id_provider_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 8. create id_page_tbl */
+       if (__exist_table(daci_handler, "id_page_tbl") == 0) {
+               ret = __query_exec(daci_handler, g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_ID_PAGE], "id_page_tbl_create failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+               ret = SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED;
+       } else {
+               ret = da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_empty_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_table_name_e table_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /* delete default table  */
+       ret = __query_exec(daci_handler, g_daci_delete_table[table_name], "deleting table failed");
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               _DEBUG_ERROR("deleting table [query:%s] failed !!!\n", g_daci_delete_table[table_name]);
+               da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+       }
+       _DEBUG_INFO("table deleted [query:%s] !!!\n", g_daci_delete_table[table_name]);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_empty_all_agent_table(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int *account_id_list = 0;
+       int count = 0;
+       int i = 0;
+
+       ret = da_begin_transaction(daci_handler);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("tbl_delete failed");
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       /* delete all changelog table */
+       account_id_list = da_get_account_account_id_list(daci_handler, &count);
+       if (account_id_list == NULL) {
+               _DEBUG_INFO("accountIdList empty !!!!!");
+       } else {
+               _DEBUG_INFO("accountListCount : %d", count);
+               for (i = 0; i < count; i++) {
+                       ret = _delete_changlog_table(daci_handler, account_id_list[i]);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               /* memory free */
+                               if (account_id_list != NULL)
+                                       free(account_id_list);
+
+                               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+                       }
+               }
+       }
+
+       /* delete all default table */
+       for (i = 0; i < SYNC_AGENT_DA_TABLE_NAME_MAX; i++) {
+               if (i == SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG || i == SYNC_AGENT_DA_TABLE_NAME_ID_PROVIDER || i == SYNC_AGENT_DA_TABLE_NAME_ID_PAGE)
+                       continue;
+
+               ret = __query_exec(daci_handler, g_daci_delete_table[i], "deleting table failed");
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+                       _DEBUG_ERROR("deleting table [query:%s] failed !!!\n", g_daci_delete_table[i]);
+                       goto DACI_FINISH;
+               }
+               _DEBUG_INFO("table deleted [query:%s] !!!\n", g_daci_delete_table[i]);
+       }
+
+ DACI_FINISH:
+
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               ret = da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+       else
+               ret = da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_COMMIT);
+
+       /* memory free */
+       if (account_id_list != NULL)
+               free(account_id_list);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_add_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, -1, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(account == NULL, -1, "sync_agent_fw_account_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "insert into account_tbl (account_id, email_address, password, enable, access_name) values (?, ?, ?, ?, ?)";
+
+       account->account_id = _get_next_account_id();
+
+       if (account->account_id > SYNC_AGENT_DA_MAX_ACCOUNT) {
+               _DEBUG_ERROR("account registration is full");
+               account->account_id = -1;
+               goto DACI_FINISH;
+       }
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               account->account_id = -1;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_int(daci_handler, stmt, 1, account->account_id);
+       __stmt_bind_text(daci_handler, stmt, 2, account->email);
+       __stmt_bind_text(daci_handler, stmt, 3, account->password);
+       _stmt_bind_int(daci_handler, stmt, 4, account->enable);
+       __stmt_bind_text(daci_handler, stmt, 5, account->access_name);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               account->account_id = -1;
+
+       __stmt_finalize(daci_handler, stmt);
+
+       if (account->account_id != -1) {
+               _create_changelog_table(daci_handler, account->account_id);
+       }
+
+ DACI_FINISH:
+
+       _EXTERN_FUNC_EXIT;
+
+       return account->account_id;
+}
+
+sync_agent_da_return_e da_update_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(account == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_fw_account_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "update account_tbl set email_address = ?, password = ?, enable = ?, last_update = current_timestamp, access_name = ?  where account_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       __stmt_bind_text(daci_handler, stmt, 1, account->email);
+       __stmt_bind_text(daci_handler, stmt, 2, account->password);
+       _stmt_bind_int(daci_handler, stmt, 3, account->enable);
+       __stmt_bind_text(daci_handler, stmt, 4, account->access_name);
+       _stmt_bind_int(daci_handler, stmt, 5, account->account_id);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int i = 0;
+
+       /* delete default table by accountId */
+       for (i = 0; i < SYNC_AGENT_DA_TABLE_NAME_MAX; i++) {
+               if (i == SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG) {
+                       continue;
+               }
+
+               ret = _delete_account(daci_handler, i, account_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+                       goto DACI_FINISH;
+               }
+       }
+
+       /* drop changelog table */
+       ret = _drop_changelog_table(daci_handler, account_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_get_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_fw_account_s ** account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       daci_stmt stmt = 0;
+       char *query = "select account_id, email_address, password, enable, access_name from account_tbl where account_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, account_id);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*account)->account_id = __stmt_column_int(stmt, 0);
+                       (*account)->email = _stmt_column_text(stmt, 1);
+                       (*account)->password = _stmt_column_text(stmt, 2);
+                       (*account)->enable = __stmt_column_int(stmt, 3);
+                       (*account)->access_name = _stmt_column_text(stmt, 4);
+               }
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_get_all_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       daci_stmt stmt = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+       sync_agent_fw_account_s *fw_account = NULL;
+       GList *account_list = NULL;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from account_tbl");
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select account_id, email_address, password, enable, access_name from account_tbl");
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               fw_account = (sync_agent_fw_account_s *) calloc(1, sizeof(sync_agent_fw_account_s));
+                               fw_account->account_id = __stmt_column_int(stmt, 0);
+                               fw_account->email = _stmt_column_text(stmt, 1);
+                               fw_account->password = _stmt_column_text(stmt, 2);
+                               fw_account->enable = __stmt_column_int(stmt, 3);
+                               fw_account->access_name = _stmt_column_text(stmt, 4);
+
+                               account_list = g_list_append(account_list, fw_account);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       *list = account_list;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_get_fw_account_by_access_name(SYNC_AGENT_DA_HANDLER * daci_handler, char *access_name, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(access_name == NULL, SYNC_AGENT_DA_ERRORS, "access name is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       daci_stmt stmt = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+       sync_agent_fw_account_s *fw_account = NULL;
+       GList *account_list = NULL;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from account_tbl where access_name = \'%s\'", access_name);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select account_id, email_address, password, enable, access_name from account_tbl where access_name = \'%s\'", access_name);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               fw_account = (sync_agent_fw_account_s *) calloc(1, sizeof(sync_agent_fw_account_s));
+                               fw_account->account_id = __stmt_column_int(stmt, 0);
+                               fw_account->email = _stmt_column_text(stmt, 1);
+                               fw_account->password = _stmt_column_text(stmt, 2);
+                               fw_account->enable = __stmt_column_int(stmt, 3);
+                               fw_account->access_name = _stmt_column_text(stmt, 4);
+
+                               account_list = g_list_append(account_list, fw_account);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+       *list = account_list;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int *da_get_account_account_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       int *account_id_list = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from account_tbl");
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+       *count = data_count;
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               account_id_list = SYNC_AGENT_DA_MEMORY_MALLOC(int *, sizeof(int), data_count);
+               if (account_id_list == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       return account_id_list;
+               }
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select account_id from account_tbl");
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               account_id_list[i] = __stmt_column_int(stmt, 0);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return account_id_list;
+}
+
+int da_is_exist_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from account_tbl where account_id = %d", account_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_get_account_count(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from account_tbl");
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       _EXTERN_FUNC_EXIT;
+
+       return data_count;
+}
+
+sync_agent_da_return_e da_add_folder(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_folder_s * folder, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_folder_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int i = 0;
+       char *query = 0;
+
+       for (i = 0; i < count; i++) {
+               if (da_is_exist_folder(daci_handler, folder[i].account_id, folder[i].folder_id) == 1)
+                       return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+       }
+
+       query = "insert into folder_tbl (folder_id, data_store_id, account_id, folder_type_id, service_id, parent_folder_id, access_name) values (?, ?, ?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       for (i = 0; i < count; i++) {
+               __stmt_bind_text(daci_handler, stmt, 1, folder[i].folder_id);
+               _stmt_bind_int(daci_handler, stmt, 2, folder[i].data_store_id);
+               _stmt_bind_int(daci_handler, stmt, 3, folder[i].account_id);
+               _stmt_bind_int(daci_handler, stmt, 4, folder[i].folder_type_id);
+               __stmt_bind_text(daci_handler, stmt, 5, folder[i].service_id);
+               __stmt_bind_text(daci_handler, stmt, 6, folder[i].parent_folder_id);
+               __stmt_bind_text(daci_handler, stmt, 7, folder[i].access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_folder_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *f_id = NULL;
+       int i;
+       char *query = NULL;
+
+       for (i = 0; i < count; i++) {
+               if (folder[i].folder_id != NULL) {
+                       if (da_is_exist_folder(daci_handler, folder[i].account_id, folder[i].folder_id) == 1)
+                               return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+               }
+       }
+
+       query = "insert into folder_tbl (folder_id, data_store_id, account_id, folder_type_id, service_id, parent_folder_id, access_name) values (?, ?, ?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       for (i = 0; i < count; i++) {
+               if (folder[i].folder_id != NULL) {
+                       __stmt_bind_text(daci_handler, stmt, 1, folder[i].folder_id);
+                       *folder_id = strdup(folder[i].folder_id);
+               } else {
+                       f_id = sync_agent_generate_folder_luid();
+                       if (f_id != NULL) {
+                               __stmt_bind_text(daci_handler, stmt, 1, f_id);
+
+                               *folder_id = strdup(f_id);
+
+                               if (f_id != NULL) {
+                                       free(f_id);
+                                       f_id = NULL;
+                               }
+                       } else {
+                               _DEBUG_ERROR("sync_agent_generate_folder_luid() failed !!");
+                               return SYNC_AGENT_DA_ERRORS;
+                       }
+               }
+               _stmt_bind_int(daci_handler, stmt, 2, folder[i].data_store_id);
+               _stmt_bind_int(daci_handler, stmt, 3, folder[i].account_id);
+               _stmt_bind_int(daci_handler, stmt, 4, folder[i].folder_type_id);
+               __stmt_bind_text(daci_handler, stmt, 5, folder[i].service_id);
+               __stmt_bind_text(daci_handler, stmt, 6, folder[i].parent_folder_id);
+               __stmt_bind_text(daci_handler, stmt, 7, folder[i].access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_folder_by_folder_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folderId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folderId == NULL, SYNC_AGENT_DA_ERRORS, "folder Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from folder_tbl where folder_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       __stmt_bind_text(daci_handler, stmt, 1, folderId);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+char *da_get_folder_folder_id_by_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId, char *serviceId, int folderTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(serviceId == NULL, NULL, "service Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *folder_id = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select folder_id from folder_tbl where account_id = %d and data_store_id = %d and service_id = %s and folder_type_id = %d", account_id, itemTypeId, serviceId, folderTypeId);
+
+       _DEBUG_INFO("Query : %s", g_daci_query);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt != NULL) {
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       folder_id = _stmt_column_text(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id;
+}
+
+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 itemTypeId, int folderTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_id_list_s *folder_id_list = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from folder_tbl where account_id = %d and folder_type_id = %d and data_store_id = %d", account_id, folderTypeId, itemTypeId);
+
+       int data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               snprintf(g_daci_query, sizeof(g_daci_query), "select folder_id from folder_tbl where account_id = %d and folder_type_id = %d and data_store_id = %d", account_id, folderTypeId, itemTypeId);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       folder_id_list = (sync_agent_da_id_list_s *) calloc(1, sizeof(sync_agent_da_id_list_s));
+                       if (folder_id_list == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       folder_id_list->id = (char **)calloc(data_count, sizeof(char *));
+                       if (folder_id_list->id == NULL) {
+
+                               if (folder_id_list != NULL)
+                                       free(folder_id_list);
+
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       folder_id_list->count = data_count;
+                       int i = 0;
+                       for (; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               folder_id_list->id[i] = _stmt_column_text(stmt, 0);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *item_id;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from folder_tbl where account_id = %d and folder_type_id = %d and data_store_id = %d", account_id, folder_type_id, item_type_id);
+
+       int data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               snprintf(g_daci_query, sizeof(g_daci_query), "select folder_id from folder_tbl where account_id = %d and folder_type_id = %d and data_store_id = %d", account_id, folder_type_id, item_type_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       int i = 0;
+                       for (; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id = NULL;
+                               item_id = _stmt_column_text(stmt, 0);
+
+                               *list = g_list_append(*list, item_id);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+char *da_get_folder_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folderId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folderId == NULL, NULL, "folder Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *query = "select service_id from folder_tbl where folder_id = ?";
+       char *service_id = 0;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               __stmt_bind_text(daci_handler, stmt, 1, folderId);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       service_id = _stmt_column_text(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return service_id;
+}
+
+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 itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_id_list_s *folder_id_list = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from folder_tbl where account_id = %d and data_store_id = %d", account_id, itemTypeId);
+
+       int data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select folder_id from folder_tbl where account_id = %d and data_store_id = %d", account_id, itemTypeId);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       folder_id_list = (sync_agent_da_id_list_s *) calloc(1, sizeof(sync_agent_da_id_list_s));
+                       if (folder_id_list == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       folder_id_list->id = (char **)calloc(data_count, sizeof(char *));
+                       if (folder_id_list->id == NULL) {
+
+                               if (folder_id_list != NULL)
+                                       free(folder_id_list);
+
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       folder_id_list->count = data_count;
+                       int i = 0;
+                       for (; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               folder_id_list->id[i] = _stmt_column_text(stmt, 0);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *item_id;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from folder_tbl where account_id = %d and data_store_id = %d", account_id, item_type_id);
+
+       int data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select folder_id from folder_tbl where account_id = %d and data_store_id = %d", account_id, item_type_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       int i = 0;
+                       for (; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id = NULL;
+                               item_id = _stmt_column_text(stmt, 0);
+
+                               *list = g_list_append(*list, item_id);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_folder_s *da_get_folder_mapping_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folderId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folderId == NULL, NULL, "folder Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_folder_s *folder = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select count(*) from folder_tbl where folder_type_id in (select folder_type_id from folder_tbl where account_id = %d and folder_id = \'%s\') "
+                "and (account_id != %d) and (account_id != %d) and data_store_id in (select data_store_id from folder_tbl where folder_id = \'%s\')", account_id, folderId, account_id, account_id, folderId);
+
+       _DEBUG_INFO("[RJW] %s", g_daci_query);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+       *count = data_count;
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               folder = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_folder_s *, sizeof(sync_agent_da_folder_s), data_count);
+               if (folder == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       return folder;
+               }
+
+               snprintf(g_daci_query, sizeof(g_daci_query),
+                        "select * from folder_tbl where folder_type_id in (select folder_type_id from folder_tbl where account_id = %d and folder_id = \'%s\') "
+                        "and (account_id != %d) and (account_id != %d) and data_store_id in (select data_store_id from folder_tbl where folder_id = \'%s\')", account_id, folderId, account_id, account_id, folderId);
+
+               _DEBUG_INFO("[RJW] %s", g_daci_query);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               folder[i].folder_id = _stmt_column_text(stmt, 0);
+                               folder[i].data_store_id = __stmt_column_int(stmt, 1);
+                               folder[i].account_id = __stmt_column_int(stmt, 2);
+                               folder[i].folder_type_id = __stmt_column_int(stmt, 3);
+                               folder[i].service_id = _stmt_column_text(stmt, 4);
+                               folder[i].parent_folder_id = _stmt_column_text(stmt, 5);
+                               folder[i].access_name = _stmt_column_text(stmt, 7);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_folder_s *folder;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select count(*) from folder_tbl where folder_type_id in (select folder_type_id from folder_tbl where account_id = %d and folder_id = \'%s\') "
+                "and (account_id != %d) and (account_id != %d) and data_store_id in (select data_store_id from folder_tbl where folder_id = \'%s\')", account_id, folder_id, account_id, account_id, folder_id);
+
+       _DEBUG_INFO("[RJW] %s", g_daci_query);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query),
+                        "select * from folder_tbl where folder_type_id in (select folder_type_id from folder_tbl where account_id = %d and folder_id = \'%s\') "
+                        "and (account_id != %d) and (account_id != %d) and data_store_id in (select data_store_id from folder_tbl where folder_id = \'%s\')", account_id, folder_id, account_id, account_id, folder_id);
+
+               _DEBUG_INFO("[RJW] %s", g_daci_query);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               folder = NULL;
+                               ret = sync_agent_create_folder(&folder);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+                                       return ret;
+                               }
+
+                               folder->folder_id = _stmt_column_text(stmt, 0);
+                               folder->data_store_id = __stmt_column_int(stmt, 1);
+                               folder->account_id = __stmt_column_int(stmt, 2);
+                               folder->folder_type_id = __stmt_column_int(stmt, 3);
+                               folder->service_id = _stmt_column_text(stmt, 4);
+                               folder->parent_folder_id = _stmt_column_text(stmt, 5);
+                               folder->access_name = _stmt_column_text(stmt, 7);
+
+                               *list = g_list_append(*list, folder);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       } else {
+               _DEBUG_INFO("no data !!");
+               ret = SYNC_AGENT_DA_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *query = "select  * from folder_tbl where folder_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               __stmt_bind_text(daci_handler, stmt, 1, folder_id);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*sync_agent_folder)->folder_id = _stmt_column_text(stmt, 0);
+                       (*sync_agent_folder)->data_store_id = __stmt_column_int(stmt, 1);
+                       (*sync_agent_folder)->account_id = __stmt_column_int(stmt, 2);
+                       (*sync_agent_folder)->folder_type_id = __stmt_column_int(stmt, 3);
+                       (*sync_agent_folder)->service_id = _stmt_column_text(stmt, 4);
+                       (*sync_agent_folder)->parent_folder_id = _stmt_column_text(stmt, 5);
+                       (*sync_agent_folder)->access_name = _stmt_column_text(stmt, 7);
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_is_exist_folder(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folderId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folderId == NULL, 0, "folder Id is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from folder_tbl where account_id = %d and folder_id = \'%s\'", account_id, folderId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       _DEBUG_INFO("[%s] End !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_item(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_item_s * item, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       int i;
+       for (i = 0; i < count; i++) {
+               if (da_is_exist_item(daci_handler, item[i].item_id) == 1)
+                       return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+       }
+
+       char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, access_name) values (?, ?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       for (i = 0; i < count; i++) {
+               __stmt_bind_text(daci_handler, stmt, 1, item[i].item_id);
+               _stmt_bind_int(daci_handler, stmt, 2, item[i].data_store_id);
+               _stmt_bind_int(daci_handler, stmt, 3, item[i].account_id);
+               __stmt_bind_text(daci_handler, stmt, 4, item[i].folder_id);
+               __stmt_bind_text(daci_handler, stmt, 5, item[i].service_id);
+               __stmt_bind_text(daci_handler, stmt, 6, item[i].access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char **id_list = NULL;
+
+       int i;
+       for (i = 0; i < count; i++) {
+               if (item[i].item_id != NULL) {
+                       if (da_is_exist_item(daci_handler, item[i].item_id) == 1)
+                               return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+               }
+       }
+
+       char *query = "insert into item_tbl (item_id, data_store_id, account_id, folder_id, service_id, access_name) values (?, ?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       for (i = 0; i < count; i++) {
+               if (item[i].item_id != NULL) {
+                       __stmt_bind_text(daci_handler, stmt, 1, item[i].item_id);
+                       *item_id = strdup(item[i].item_id);
+               } else {
+                       id_list = sync_agent_generate_item_luid(1, 1);
+                       if (id_list != NULL) {
+                               __stmt_bind_text(daci_handler, stmt, 1, id_list[0]);
+
+                               *item_id = strdup(id_list[0]);
+
+                               if (id_list[0] != NULL)
+                                       free(id_list[0]);
+
+                               if (id_list != NULL)
+                                       free(id_list);
+
+                               id_list = NULL;
+                       } else {
+                               _DEBUG_ERROR("sync_agent_generate_item_luid() failed !!");
+                               return SYNC_AGENT_DA_ERRORS;
+                       }
+               }
+               _stmt_bind_int(daci_handler, stmt, 2, item[i].data_store_id);
+               _stmt_bind_int(daci_handler, stmt, 3, item[i].account_id);
+               __stmt_bind_text(daci_handler, stmt, 4, item[i].folder_id);
+               __stmt_bind_text(daci_handler, stmt, 5, item[i].service_id);
+               __stmt_bind_text(daci_handler, stmt, 6, item[i].access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_item_by_Item_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, SYNC_AGENT_DA_ERRORS, "item Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from item_tbl where item_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       __stmt_bind_text(daci_handler, stmt, 1, itemId);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_item_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       int i = 0;
+       int count = 0;
+       sync_agent_da_item_info_s *item_info = 0;
+       char *query = "delete from item_tbl where account_id = ? and data_store_id = ?";
+
+       /* delete changelog */
+       item_info = da_get_item_info_by_item_type_id(daci_handler, account_id, itemTypeId, &count);
+       if (count != 0) {
+               for (i = 0; i < count; i++) {
+                       ret = da_delete_item_changelog_by_item_id(daci_handler, account_id, item_info[i].itemId);
+                       if (ret != SYNC_AGENT_DA_SUCCESS)
+                               goto DACI_FINISH;
+               }
+       }
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               goto DACI_FINISH;
+
+       _stmt_bind_int(daci_handler, stmt, 1, account_id);
+       _stmt_bind_int(daci_handler, stmt, 2, itemTypeId);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               goto DACI_FINISH;
+       }
+
+       sync_agent_free_memory_item_info(item_info, count);
+
+       _EXTERN_FUNC_EXIT;
+
+       return __stmt_finalize(daci_handler, stmt);
+
+ DACI_FINISH:
+
+       sync_agent_free_memory_item_info(item_info, count);
+
+       if (stmt != NULL)
+               __stmt_finalize(daci_handler, stmt);
+
+       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+
+       char *query = "delete from item_tbl where account_id = ? and data_store_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               goto DACI_FINISH;
+
+       _stmt_bind_int(daci_handler, stmt, 1, account_id);
+       _stmt_bind_int(daci_handler, stmt, 2, item_type_id);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               goto DACI_FINISH;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return __stmt_finalize(daci_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               __stmt_finalize(daci_handler, stmt);
+
+       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+}
+
+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 itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int i = 0;
+       int count = 0;
+       sync_agent_da_item_info_s *item_info = 0;
+
+       /* delete changelog */
+       item_info = da_get_item_info_by_item_type_id_and_operation_id(daci_handler, account_id, itemTypeId, 303, &count);
+       if (count != 0) {
+               for (i = 0; i < count; i++) {
+                       ret = da_delete_item_by_Item_id(daci_handler, item_info[i].itemId);
+                       if (ret != SYNC_AGENT_DA_SUCCESS)
+                               goto DACI_FINISH;
+
+                       ret = da_delete_item_changelog_by_item_id(daci_handler, account_id, item_info[i].itemId);
+                       if (ret != SYNC_AGENT_DA_SUCCESS)
+                               goto DACI_FINISH;
+               }
+       }
+
+       sync_agent_free_memory_item_info(item_info, count);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+
+ DACI_FINISH:
+
+       sync_agent_free_memory_item_info(item_info, count);
+
+       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+}
+
+char *da_get_item_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *serviceId, int itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(serviceId == NULL, NULL, "service Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *query = "select item_id from item_tbl where account_id = ? and service_id = ? and data_store_id = ?";
+       char *item_id = 0;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, account_id);
+               __stmt_bind_text(daci_handler, stmt, 2, serviceId);
+               _stmt_bind_int(daci_handler, stmt, 3, itemTypeId);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       item_id = _stmt_column_text(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return item_id;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(service_id == NULL, SYNC_AGENT_DA_ERRORS, "service Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       daci_stmt stmt = 0;
+       char *query = "select item_id from item_tbl where account_id = ? and service_id = ? and data_store_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, account_id);
+               __stmt_bind_text(daci_handler, stmt, 2, service_id);
+               _stmt_bind_int(daci_handler, stmt, 3, item_type_id);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       *item_id = _stmt_column_text(stmt, 0);
+                       ret = SYNC_AGENT_DA_SUCCESS;
+               }
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+char *da_get_item_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, NULL, "item Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *query = "select service_id from item_tbl where item_id = ?";
+       char *service_id = 0;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               __stmt_bind_text(daci_handler, stmt, 1, itemId);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       service_id = _stmt_column_text(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return service_id;
+}
+
+sync_agent_da_item_s *da_get_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, NULL, "item Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *query = "select  * from item_tbl where item_id = ?";
+       sync_agent_da_item_s *item = 0;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               __stmt_bind_text(daci_handler, stmt, 1, itemId);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       item = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_s *, sizeof(sync_agent_da_item_s), 1);
+                       if (item == NULL) {
+                               __stmt_finalize(daci_handler, stmt);
+
+                               _DEBUG_ERROR("memory_allocation failed");
+                               return item;
+                       }
+
+                       item->item_id = _stmt_column_text(stmt, 0);
+                       item->data_store_id = __stmt_column_int(stmt, 1);
+                       item->account_id = __stmt_column_int(stmt, 2);
+                       item->folder_id = _stmt_column_text(stmt, 3);
+                       item->service_id = _stmt_column_text(stmt, 4);
+                       item->access_name = _stmt_column_text(stmt, 6);
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return item;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "select  * from item_tbl where item_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               __stmt_bind_text(daci_handler, stmt, 1, item_id);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*sync_agent_item)->item_id = _stmt_column_text(stmt, 0);
+                       (*sync_agent_item)->data_store_id = __stmt_column_int(stmt, 1);
+                       (*sync_agent_item)->account_id = __stmt_column_int(stmt, 2);
+                       (*sync_agent_item)->folder_id = _stmt_column_text(stmt, 3);
+                       (*sync_agent_item)->service_id = _stmt_column_text(stmt, 4);
+                       (*sync_agent_item)->access_name = _stmt_column_text(stmt, 6);
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_id_list_s *da_get_all_item_id(SYNC_AGENT_DA_HANDLER * daci_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_id_list_s *id_list = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select item_id from item_tbl");
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               id_list = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_id_list_s *, sizeof(sync_agent_da_id_list_s), 1);
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               id_list->count = row_count;
+               id_list->id = SYNC_AGENT_DA_MEMORY_CALLOC(char **, sizeof(char *), row_count);
+
+               for (i = 0; i < row_count; i++) {
+                       id_list->id[i] = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, char *folderId, sync_agent_da_column_name_e column_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folderId == NULL, NULL, "folder Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_id_list_s *id_list = 0;
+       char *column_str = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       column_str = _get_column_name(column_name);
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select %s from item_tbl where folder_id = \'%s\'", column_str, folderId);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               id_list = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_id_list_s *, sizeof(sync_agent_da_id_list_s), 1);
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               id_list->count = row_count;
+               id_list->id = SYNC_AGENT_DA_MEMORY_CALLOC(char **, sizeof(char *), row_count);
+
+               for (i = 0; i < row_count; i++) {
+                       id_list->id[i] = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       char *item_id;
+       char *column_str = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       column_str = _get_column_name(column_name);
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select %s from item_tbl where folder_id = \'%s\'", column_str, folder_id);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_id = NULL;
+                       item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+
+                       *list = g_list_append(*list, item_id);
+               }
+       }
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_item_s *da_get_item_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *item = 0;
+       char **result = 0;
+       char *new_table = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 6;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return item;
+
+//      snprintf(g_daci_query, sizeof(g_daci_query), "select item_id, data_store_id, account_id, folder_id, service_id,  access_name from item_tbl where account_id = %d and data_store_id = %d", accountId, itemTypeId);
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
+                "where item.account_id = %d and item.data_store_id = %d and (changelog.operation_id is null or changelog.operation_id != 303)", new_table, account_id, itemTypeId);
+       _DEBUG_INFO("g_daci_query = %s", g_daci_query);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       *count = row_count;
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               item = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_s *, sizeof(sync_agent_da_item_s), row_count);
+               if (item == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               for (i = 0; i < row_count; i++) {
+                       item[i].item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item[i].data_store_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       item[i].account_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       item[i].folder_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item[i].service_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item[i].access_name = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return item;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_item_s *item;
+       char **result = 0;
+       char *new_table = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 6;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+//      snprintf(g_daci_query, sizeof(g_daci_query), "select item_id, data_store_id, account_id, folder_id, service_id,  access_name from item_tbl where account_id = %d and data_store_id = %d", accountId, itemTypeId);
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select item.item_id, item.data_store_id, item.account_id, item.folder_id, item.service_id, item.access_name " "from item_tbl as item " "left join %s as changelog " "using (item_id) "
+                "where item.account_id = %d and item.data_store_id = %d and (changelog.operation_id is null or changelog.operation_id != 303)", new_table, account_id, item_type_id);
+       _DEBUG_INFO("g_daci_query = %s", g_daci_query);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item = NULL;
+                       ret = sync_agent_create_item(&item);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_create_item() failed !!");
+                               goto DACI_FINISH;
+                       }
+
+                       item->item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item->data_store_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       item->account_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       item->folder_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item->service_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item->access_name = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+
+                       *list = g_list_append(*list, item);
+               }
+       }
+
+ DACI_FINISH:
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_item_info_s *da_get_item_info_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_info_s *itemInfo = 0;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 5;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return itemInfo;
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select item.item_id, item.data_store_id, item.service_id, changelog.operation_id, changelog.status " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d", new_table,
+                account_id, itemTypeId);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       *count = row_count;
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               itemInfo = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_info_s *, sizeof(sync_agent_da_item_info_s), row_count);
+               if (itemInfo == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+               for (i = 0; i < row_count; i++) {
+                       itemInfo[i].itemId = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       itemInfo[i].itemTypeId = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       itemInfo[i].serviceId = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       itemInfo[i].operationId = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       itemInfo[i].syncStatus = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return itemInfo;
+}
+
+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 itemTypeId, int operationId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_info_s *itemInfo = 0;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 5;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return itemInfo;
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select item.item_id, item.data_store_id, item.service_id, changelog.operation_id, changelog.status " "from item_tbl as item " "join %s as changelog " "using (item_id) "
+                "where item.account_id = %d and item.data_store_id = %d and changelog.operation_id = %d", new_table, account_id, itemTypeId, operationId);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       *count = row_count;
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               itemInfo = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_info_s *, sizeof(sync_agent_da_item_info_s), row_count);
+               if (itemInfo == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+               for (i = 0; i < row_count; i++) {
+                       itemInfo[i].itemId = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       itemInfo[i].itemTypeId = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       itemInfo[i].serviceId = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       itemInfo[i].operationId = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       itemInfo[i].syncStatus = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return itemInfo;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 5;
+       char *item_id = NULL;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL) {
+               _DEBUG_ERROR("__replace_table_name() failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+       snprintf(g_daci_query, sizeof(g_daci_query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and changelog.operation_id = %d", new_table, account_id,
+                item_type_id, operation_id);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_id = NULL;
+                       item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index += 5;
+
+                       *list = g_list_append(*list, item_id);
+               }
+       } else {
+               _DEBUG_INFO("no data !!");
+       }
+
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_item_s *da_get_item_mapping_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *itemId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, NULL, "item Id is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_item_s *item = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select count(*) from item_tbl where data_store_id in (select data_store_id from item_tbl where account_id = %d and item_id = \'%s\') " "and service_id in (select service_id from item_tbl where account_id = %d and item_id = \'%s\') "
+                "and (account_id != %d and item_id != \'%s\')", account_id, itemId, account_id, itemId, account_id, itemId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+       *count = data_count;
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               item = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_s *, sizeof(sync_agent_da_item_s), data_count);
+               if (item == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       return item;
+               }
+
+               snprintf(g_daci_query, sizeof(g_daci_query),
+                        "select * from item_tbl where data_store_id in (select data_store_id from item_tbl where account_id = %d and item_id = \'%s\') " "and service_id in (select service_id from item_tbl where account_id = %d and item_id = \'%s\') "
+                        "and (account_id != %d and item_id != \'%s\')", account_id, itemId, account_id, itemId, account_id, itemId);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               item[i].item_id = _stmt_column_text(stmt, 0);
+                               item[i].data_store_id = __stmt_column_int(stmt, 1);
+                               item[i].account_id = __stmt_column_int(stmt, 2);
+                               item[i].folder_id = _stmt_column_text(stmt, 3);
+                               item[i].service_id = _stmt_column_text(stmt, 4);
+                               item[i].access_name = _stmt_column_text(stmt, 6);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return item;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       daci_stmt stmt = 0;
+       sync_agent_da_item_s *item;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select count(*) from item_tbl where data_store_id in (select data_store_id from item_tbl where account_id = %d and item_id = \'%s\') " "and service_id in (select service_id from item_tbl where account_id = %d and item_id = \'%s\') "
+                "and (account_id != %d and item_id != \'%s\')", account_id, item_id, account_id, item_id, account_id, item_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query),
+                        "select * from item_tbl where data_store_id in (select data_store_id from item_tbl where account_id = %d and item_id = \'%s\') " "and service_id in (select service_id from item_tbl where account_id = %d and item_id = \'%s\') "
+                        "and (account_id != %d and item_id != \'%s\')", account_id, item_id, account_id, item_id, account_id, item_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               item = NULL;
+                               ret = sync_agent_create_item(&item);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("sync_agent_create_item() failed !!");
+                                       return ret;
+                               }
+
+                               item->item_id = _stmt_column_text(stmt, 0);
+                               item->data_store_id = __stmt_column_int(stmt, 1);
+                               item->account_id = __stmt_column_int(stmt, 2);
+                               item->folder_id = _stmt_column_text(stmt, 3);
+                               item->service_id = _stmt_column_text(stmt, 4);
+                               item->access_name = _stmt_column_text(stmt, 6);
+
+                               *list = g_list_append(*list, item);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       } else {
+               _DEBUG_ERROR("no data !!");
+               ret = SYNC_AGENT_DA_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_by_datastore_id(SYNC_AGENT_DA_HANDLER * daci_handler, int data_store_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_id_list_s *item_id_list = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from item_tbl where data_store_id = %d", data_store_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               item_id_list = (sync_agent_da_id_list_s *) calloc(1, sizeof(sync_agent_da_id_list_s));
+               if (item_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               item_id_list->id = (char **)calloc(data_count, sizeof(char *));
+               if (item_id_list->id == NULL) {
+
+                       if (item_id_list != NULL)
+                               free(item_id_list);
+
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               item_id_list->count = data_count;
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select item_id from item_tbl where data_store_id = %d", data_store_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id_list->id[i] = _stmt_column_text(stmt, 0);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return item_id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *item_id;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from item_tbl where data_store_id = %d", data_store_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select item_id from item_tbl where data_store_id = %d", data_store_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id = NULL;
+                               item_id = _stmt_column_text(stmt, 0);
+
+                               *list = g_list_append(*list, item_id);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_id_list_s *item_id_list = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from item_tbl where account_id = %d and data_store_id = %d", account_id, data_store_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               item_id_list = (sync_agent_da_id_list_s *) calloc(1, sizeof(sync_agent_da_id_list_s));
+               if (item_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               item_id_list->id = (char **)calloc(data_count, sizeof(char *));
+               if (item_id_list->id == NULL) {
+
+                       if (item_id_list != NULL)
+                               free(item_id_list);
+
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               item_id_list->count = data_count;
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select item_id from item_tbl where account_id = %d and data_store_id = %d", account_id, data_store_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id_list->id[i] = _stmt_column_text(stmt, 0);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return item_id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *item_id;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from item_tbl where account_id = %d and data_store_id = %d", account_id, data_store_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select item_id from item_tbl where account_id = %d and data_store_id = %d", account_id, data_store_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA) {
+                                       break;
+                               }
+
+                               item_id = NULL;
+                               item_id = _stmt_column_text(stmt, 0);
+
+                               *list = g_list_append(*list, item_id);
+                       }
+
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_id_list_s *id_list = 0;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return id_list;
+
+       snprintf(query, sizeof(query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and changelog.operation_id = %d", new_table, account_id,
+                data_store_id, operation_id);
+
+       ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               id_list = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_id_list_s *, sizeof(sync_agent_da_id_list_s), 1);
+
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               id_list->count = row_count;
+               id_list->id = SYNC_AGENT_DA_MEMORY_CALLOC(char **, sizeof(char *), row_count);
+
+               for (i = 0; i < row_count; i++) {
+                       id_list->id[i] = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+       if (result != NULL) {
+               __free_table(result);
+       }
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       char *item_id;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+       snprintf(query, sizeof(query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and changelog.operation_id = %d", new_table, account_id,
+                data_store_id, operation_id);
+
+       ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_id = NULL;
+                       item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+
+                       *list = g_list_append(*list, item_id);
+               }
+       }
+
+       if (result != NULL) {
+               __free_table(result);
+       }
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, NULL, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_id_list_s *id_list = 0;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return id_list;
+
+       snprintf(query, sizeof(query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and item.folder_id = \'%s\' and changelog.operation_id = %d",
+                new_table, account_id, data_store_id, folder_id, operation_id);
+       _DEBUG_INFO("request quary is [%s]\n", query);
+
+       ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               id_list = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_id_list_s *, sizeof(sync_agent_da_id_list_s), 1);
+
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               id_list->count = row_count;
+               id_list->id = SYNC_AGENT_DA_MEMORY_CALLOC(char **, sizeof(char *), row_count);
+
+               for (i = 0; i < row_count; i++) {
+                       id_list->id[i] = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+               }
+       }
+
+ DACI_FINISH:
+       if (result != NULL) {
+               __free_table(result);
+       }
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       char *item_id;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+       snprintf(query, sizeof(query), "select item.item_id " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d and item.folder_id = \'%s\' and changelog.operation_id = %d",
+                new_table, account_id, data_store_id, folder_id, operation_id);
+       _DEBUG_INFO("request quary is [%s]\n", query);
+
+       ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_id = NULL;
+                       item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+
+                       *list = g_list_append(*list, item_id);
+               }
+       }
+
+       if (result != NULL) {
+               __free_table(result);
+       }
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       char *item_id;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 1;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+       snprintf(query, sizeof(query), "select distinct item_tbl.item_id from item_tbl where item_tbl.account_id = %d and item_tbl.folder_id = \'%s\' and item_tbl.item_id not in (select distinct item.item_id from item_tbl as item join %s as changelog where changelog.item_id = item.item_id and changelog.operation_id = 303)", account_id, folder_id, new_table);
+       _DEBUG_INFO("request quary is [%s]\n", query);
+
+       ret = _get_table(daci_handler, query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_id = NULL;
+                       item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       *list = g_list_append(*list, item_id);
+               }
+       }
+
+       if (result != NULL) {
+               __free_table(result);
+       }
+
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+       _EXTERN_FUNC_EXIT;
+       return ret;
+}
+
+int da_is_exist_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, 0, "item Id is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from item_tbl where item_id = \'%s\'", itemId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0) {
+               ret = 0;
+       } else {
+               _DEBUG_ERROR("itemId [%s] already exist number of [%d]", itemId, data_count);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(config == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_config_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *query = "insert into config_tbl (config_id, key, value, type, access_name) values (?, ?, ?, ?, ?)";
+
+       int exist = 0;
+       ret = da_is_exist_config(daci_handler, config->config_id, config->key, &exist);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_is_exist_config is failed");
+               return ret;
+       }
+
+       if (exist == 1)
+               return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, config->config_id);
+       __stmt_bind_text(daci_handler, stmt, 2, config->key);
+       __stmt_bind_text(daci_handler, stmt, 3, config->value);
+       __stmt_bind_text(daci_handler, stmt, 4, config->type);
+       __stmt_bind_text(daci_handler, stmt, 5, config->access_name);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_config_list(SYNC_AGENT_DA_HANDLER * daci_handler, GList * config_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(config_list == NULL, SYNC_AGENT_DA_ERRORS, "config_list is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       GList *iter = NULL;
+       sync_agent_da_config_s *config = NULL;
+
+       char *query = "insert into config_tbl (config_id, key, value, type, access_name) values (?, ?, ?, ?, ?)";
+
+       int exist = 0;
+       for (iter = config_list; iter != NULL; iter = g_list_next(iter)) {
+               config = (sync_agent_da_config_s *) iter->data;
+               ret = da_is_exist_config(daci_handler, config->config_id, config->key, &exist);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_is_exist_config is failed");
+                       return ret;
+               }
+
+               if (exist == 1)
+                       return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+       }
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       for (iter = config_list; iter != NULL; iter = g_list_next(iter)) {
+               config = (sync_agent_da_config_s *) iter->data;
+
+               _stmt_bind_int(daci_handler, stmt, 1, config->config_id);
+               __stmt_bind_text(daci_handler, stmt, 2, config->key);
+               __stmt_bind_text(daci_handler, stmt, 3, config->value);
+               __stmt_bind_text(daci_handler, stmt, 4, config->type);
+               __stmt_bind_text(daci_handler, stmt, 5, config->access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_config_by_key(SYNC_AGENT_DA_HANDLER * daci_handler, int configId, char *key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from config_tbl where config_id = ? and key = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, configId);
+       __stmt_bind_text(daci_handler, stmt, 2, key);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_get_config_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       sync_agent_da_config_s *config = 0;
+       int data_Count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+       GList *config_list = NULL;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from config_tbl where config_id = %d", account_id);
+
+       data_Count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_Count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select * from config_tbl where config_id = %d", account_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_Count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               config = (sync_agent_da_config_s *) calloc(1, sizeof(sync_agent_da_config_s));
+                               if (config == NULL) {
+                                       _DEBUG_ERROR("memory_allocation failed");
+                                       ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+                                       return ret;
+                               }
+
+                               config->config_id = __stmt_column_int(stmt, 0);
+                               config->key = _stmt_column_text(stmt, 1);
+                               config->value = _stmt_column_text(stmt, 2);
+                               config->type = _stmt_column_text(stmt, 3);
+                               config->access_name = _stmt_column_text(stmt, 5);
+
+                               config_list = g_list_append(config_list, config);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       *list = config_list;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       int ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "select key, value, type, access_name from config_tbl where config_id = ? and key =?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _stmt_bind_int(daci_handler, stmt, 1, config_id);
+       __stmt_bind_text(daci_handler, stmt, 2, key);
+
+       if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+               (*config)->config_id = config_id;
+               (*config)->key = _stmt_column_text(stmt, 0);
+               (*config)->value = _stmt_column_text(stmt, 1);
+               (*config)->type = _stmt_column_text(stmt, 2);
+               (*config)->access_name = _stmt_column_text(stmt, 3);
+       } else {
+               ret = SYNC_AGENT_DA_ERR_NO_DATA;
+       }
+
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_is_exist_config(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key, int *exist)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int result = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from config_tbl where config_id = %d and key = \'%s\'", config_id, key);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               result = 0;
+
+       *exist = result;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_update_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(config == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_config_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int exist = 0;
+
+       ret = da_is_exist_config(daci_handler, config->config_id, config->key, &exist);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_is_exist_config is failed");
+               return ret;
+       }
+
+       if (exist == 1)
+               ret = da_set_config_value(daci_handler, config);
+       else
+               ret = da_add_config(daci_handler, config);
+
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_set_config_value(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(config == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_config_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       daci_stmt stmt = 0;
+       char *query = "update config_tbl set value = ?, type = ?, last_update = current_timestamp, access_name = ? " "where config_id = ? and key = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       __stmt_bind_text(daci_handler, stmt, 1, config->value);
+       __stmt_bind_text(daci_handler, stmt, 2, config->type);
+       __stmt_bind_text(daci_handler, stmt, 3, config->access_name);
+       _stmt_bind_int(daci_handler, stmt, 4, config->config_id);
+       __stmt_bind_text(daci_handler, stmt, 5, config->key);
+
+       ret = _stmt_read_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_item_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_da_item_changelog_s * itemChangelog, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemChangelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       int i = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       for (i = 0; i < count; i++) {
+               if (da_is_exist_item_changelog(daci_handler, account_id, itemChangelog[i].item_id) == 1)
+                       return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+       }
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "insert into %s (item_id, operation_id, status, access_name) values (?, ?, ?, ?)", new_table);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       for (i = 0; i < count; i++) {
+               __stmt_bind_text(daci_handler, stmt, 1, itemChangelog[i].item_id);
+               _stmt_bind_int(daci_handler, stmt, 2, itemChangelog[i].operation_id);
+               __stmt_bind_text(daci_handler, stmt, 3, ((itemChangelog[i].status == 0) ? "SYNC_REQUIRED" : itemChangelog[i].status));
+               __stmt_bind_text(daci_handler, stmt, 4, itemChangelog[i].access_name);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+               if ((ret != SYNC_AGENT_DA_ERR_MORE_DATA) && (ret != SYNC_AGENT_DA_SUCCESS)) {
+                       __stmt_finalize(daci_handler, stmt);
+                       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+
+       ret = __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, SYNC_AGENT_DA_ERRORS, "item Id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "delete from %s where item_id = ?", new_table);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       __stmt_bind_text(daci_handler, stmt, 1, itemId);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char **itemIdList, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemIdList == NULL, SYNC_AGENT_DA_ERRORS, "item Id List is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *new_table = 0;
+       int i;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "delete from %s where item_id = ?", new_table);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       for (i = 0; i < count; i++) {
+               __stmt_bind_text(daci_handler, stmt, 1, itemIdList[i]);
+
+               ret = __stmt_write_step(daci_handler, stmt);
+
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       __stmt_finalize(daci_handler, stmt);
+                       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+                       return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               }
+               _stmt_reset(daci_handler, stmt);
+       }
+       __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL) {
+               ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               goto DACI_FINISH;
+       }
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "delete from %s " "where item_id in " "(select item_id " "from %s as changelog " "join item_tbl as item " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d)", new_table,
+                new_table, account_id, itemTypeId);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               goto DACI_FINISH;
+       }
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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 * itemChangelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemChangelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "update %s set operation_id = ?, status = ?, last_update = current_timestamp, access_name = ? where item_id = ?", new_table);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _stmt_bind_int(daci_handler, stmt, 1, itemChangelog->operation_id);
+       __stmt_bind_text(daci_handler, stmt, 2, itemChangelog->status);
+       __stmt_bind_text(daci_handler, stmt, 3, itemChangelog->access_name);
+       __stmt_bind_text(daci_handler, stmt, 4, itemChangelog->item_id);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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 * itemChangelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemChangelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "update %s set status = ?, last_update = current_timestamp, access_name = ? where item_id = ?", new_table);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       __stmt_bind_text(daci_handler, stmt, 1, itemChangelog->status);
+       __stmt_bind_text(daci_handler, stmt, 2, itemChangelog->access_name);
+       __stmt_bind_text(daci_handler, stmt, 3, itemChangelog->item_id);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_set_item_changelog_wait_status(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char **folderIdList, int folderIdCount, int *itemTypeIdList, int itemTypeIdCount)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemTypeIdList == NULL, SYNC_AGENT_DA_ERRORS, "item Type Id List is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char temp_str[10];
+       int i = 0;
+       int len = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "update %s " "set status = \'SYNC_WAIT\' " "where item_id in (select item_id " "from item_tbl as item " "join %s as changelog " "using(item_id) " "where item.account_id = %d and (", new_table, new_table,
+                account_id);
+
+       for (i = 0; i < folderIdCount; i++) {
+               len = g_strlcat(g_daci_query, "item.folder_id = \'", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               len = g_strlcat(g_daci_query, folderIdList[i], SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+
+               if (i < folderIdCount - 1) {
+                       len = g_strlcat(g_daci_query, "\' or ", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               } else {
+                       len = g_strlcat(g_daci_query, "\') and (", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               }
+
+               if (len >= SYNC_AGENT_DA_MAX_QUERY_LENGTH) {
+                       _DEBUG_ERROR("g_daci_query buffer overflow !!");
+                       /* todo : exception handling */
+               }
+       }
+
+       for (i = 0; i < itemTypeIdCount; i++) {
+               memset(temp_str, 0x00, sizeof(temp_str));
+               snprintf(temp_str, sizeof(temp_str), "%d", itemTypeIdList[i]);
+
+               len = g_strlcat(g_daci_query, "item.data_store_id = ", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               len = g_strlcat(g_daci_query, temp_str, SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+
+               if (i < itemTypeIdCount - 1) {
+                       len = g_strlcat(g_daci_query, " or ", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               } else {
+                       len = g_strlcat(g_daci_query, ") )", SYNC_AGENT_DA_MAX_QUERY_LENGTH);
+               }
+
+               if (len >= SYNC_AGENT_DA_MAX_QUERY_LENGTH) {
+                       _DEBUG_ERROR("g_daci_query buffer overflow !!");
+                       /* todo : exception handling */
+               }
+       }
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL) {
+               SYNC_AGENT_DA_MEMORY_FREE(new_table);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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 * itemChangelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select * from %s where item_id = \'%s\'", new_table, itemChangelog->item_id);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt != NULL) {
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       itemChangelog->operation_id = __stmt_column_int(stmt, 1);
+                       itemChangelog->status = _stmt_column_text(stmt, 2);
+                       itemChangelog->access_name = _stmt_column_text(stmt, 4);
+                       ret = SYNC_AGENT_DA_SUCCESS;
+               } else if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_SUCCESS) {
+                       ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _DEBUG_INFO("[%s] End !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       daci_stmt stmt = 0;
+       char *new_table = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select * from %s where item_id = \'%s\'", new_table, item_id);
+
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt != NULL) {
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*sync_agent_changelog)->item_id = SYNC_AGENT_DA_STRDUP(item_id);
+                       (*sync_agent_changelog)->operation_id = __stmt_column_int(stmt, 1);
+                       (*sync_agent_changelog)->status = _stmt_column_text(stmt, 2);
+                       (*sync_agent_changelog)->access_name = _stmt_column_text(stmt, 4);
+                       ret = SYNC_AGENT_DA_SUCCESS;
+               } else if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_SUCCESS) {
+                       ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_item_changelog_s *item_changelog;
+       char *new_table = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 4;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return ret;
+//      snprintf(g_daci_query, sizeof(g_daci_query), "select item.item_id, item.data_store_id, item.service_id, changelog.operation_id, changelog.status " "from item_tbl as item " "join %s as changelog " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d", new_table, account_id, itemTypeId);
+       snprintf(g_daci_query, sizeof(g_daci_query),
+                "select changelog.item_id, changelog.operation_id, changelog.status, changelog.access_name from %s as changelog " "join item_tbl as item " "using (item_id) " "where item.account_id = %d and item.data_store_id = %d", new_table, account_id,
+                item_type_id);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       item_changelog = NULL;
+                       ret = sync_agent_create_changelog(&item_changelog);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_create_changelog() failed !!");
+                               goto DACI_FINISH;
+                       }
+
+                       item_changelog->item_id = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item_changelog->operation_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       item_changelog->status = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       item_changelog->access_name = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+
+                       *list = g_list_append(*list, item_changelog);
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_item_changelog_s *get_itemChangelogByOperationId(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int operationId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_item_changelog_s *item_changelog = 0;
+       char *new_table = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return item_changelog;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from %s where operation_id = %d", new_table, operationId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+       *count = data_count;
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               item_changelog = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_item_changelog_s *, sizeof(sync_agent_da_item_changelog_s), data_count);
+               if (item_changelog == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+
+                       /* memory free */
+                       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+                       return item_changelog;
+               }
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select * from %s where operation_id = %d", new_table, operationId);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               item_changelog[i].item_id = _stmt_column_text(stmt, 0);
+                               item_changelog[i].operation_id = __stmt_column_int(stmt, 1);
+                               item_changelog[i].status = _stmt_column_text(stmt, 2);
+                               item_changelog[i].access_name = _stmt_column_text(stmt, 4);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return item_changelog;
+}
+
+int da_is_exist_item_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *itemId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(itemId == NULL, 0, "item Id is NULL !!");
+
+       int ret = 1;
+       char *new_table = 0;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL)
+               return 0;
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from %s where item_id = \'%s\'", new_table, itemId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = 0;
+
+       if (da_is_exist_last_anchor(daci_handler, last_anchor->account_id, last_anchor->data_store_id) == 1)
+               return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+
+       query = "insert into last_anchor_tbl (account_id, data_store_id, last_anchor_server, last_anchor_client, access_name) values (?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, last_anchor->account_id);
+       _stmt_bind_int(daci_handler, stmt, 2, last_anchor->data_store_id);
+       __stmt_bind_text(daci_handler, stmt, 3, last_anchor->last_anchor_server);
+       __stmt_bind_text(daci_handler, stmt, 4, last_anchor->last_anchor_client);
+       __stmt_bind_text(daci_handler, stmt, 5, last_anchor->access_name);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = _delete_account(daci_handler, SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR, account_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_last_anchor_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from last_anchor_tbl where account_id = ? and data_store_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, account_id);
+       _stmt_bind_int(daci_handler, stmt, 2, itemTypeId);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_set_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "update last_anchor_tbl set last_anchor_server = ?, last_anchor_client = ?, last_update = current_timestamp, access_name = ?" "where account_id = ? and data_store_id = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       __stmt_bind_text(daci_handler, stmt, 1, last_anchor->last_anchor_server);
+       __stmt_bind_text(daci_handler, stmt, 2, last_anchor->last_anchor_client);
+       __stmt_bind_text(daci_handler, stmt, 3, last_anchor->access_name);
+       _stmt_bind_int(daci_handler, stmt, 4, last_anchor->account_id);
+       _stmt_bind_int(daci_handler, stmt, 5, last_anchor->data_store_id);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_last_anchor_s *da_get_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *last_anchor = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 4;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select account_id, data_store_id, last_anchor_server, last_anchor_client from last_anchor_tbl where account_id = %d", account_id);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       *count = row_count;
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               last_anchor = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_last_anchor_s *, sizeof(sync_agent_da_last_anchor_s), row_count);
+               if (last_anchor == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               for (i = 0; i < row_count; i++) {
+                       last_anchor[i].account_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor[i].data_store_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor[i].last_anchor_server = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor[i].last_anchor_client = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor[i].access_name = 0;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return last_anchor;
+}
+
+sync_agent_da_last_anchor_s *da_get_last_anchor_by_item_type_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_last_anchor_s *last_anchor = 0;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 4;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select account_id, data_store_id, last_anchor_server, last_anchor_client from last_anchor_tbl where account_id = %d and data_store_id = %d", account_id, itemTypeId);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+       *count = row_count;
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               last_anchor = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_last_anchor_s *, sizeof(sync_agent_da_last_anchor_s), row_count);
+               if (last_anchor == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       goto DACI_FINISH;
+               }
+
+               for (i = 0; i < row_count; i++) {
+                       last_anchor[i].account_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor[i].data_store_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor[i].last_anchor_server = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor[i].last_anchor_client = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor[i].access_name = 0;
+               }
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return last_anchor;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_last_anchor_s *last_anchor = NULL;
+       char **result = 0;
+       int row_count = 0;
+       int col_count = 0;
+       int i = 0;
+       int index = 4;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select account_id, data_store_id, last_anchor_server, last_anchor_client from last_anchor_tbl where account_id = %d and data_store_id = %d", account_id, item_type_id);
+
+       ret = _get_table(daci_handler, g_daci_query, &result, &row_count, &col_count);
+//      *count = row_count;
+
+       if ((ret == SYNC_AGENT_DA_SUCCESS) && (row_count != 0) && (result != 0)) {
+               for (i = 0; i < row_count; i++) {
+                       last_anchor = NULL;
+                       ret = sync_agent_create_last_anchor(&last_anchor);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_create_last_anchor() failed !!");
+                               goto DACI_FINISH;
+                       }
+
+                       last_anchor->account_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor->data_store_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       last_anchor->last_anchor_server = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor->last_anchor_client = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       last_anchor->access_name = NULL;
+
+                       *list = g_list_append(*list, last_anchor);
+               }
+       } else if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("__get_table() failed !!");
+               return ret;
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL)
+               __free_table(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_is_exist_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int itemTypeId)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from last_anchor_tbl where account_id = %d and data_store_id = %d", account_id, itemTypeId);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_mapping(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_mapping_s * mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(mapping == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_mapping_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = 0;
+
+       if (da_is_exist_mapping_by_luid(daci_handler, mapping->account_id, mapping->luid) == 1) {
+               _DEBUG_INFO("exist mapping item");
+               return SYNC_AGENT_DA_ERR_PRIMARY_KEY_NOT_UNIQUE;
+       }
+
+       query = "insert into mapping_tbl (account_id, data_store_id, luid, guid, access_name) values (?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               _DEBUG_ERROR("stmt is NULL !!");
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _DEBUG_INFO("account_id = %d", mapping->account_id);
+       _DEBUG_INFO("data_store_id = %d", mapping->data_store_id);
+       _DEBUG_INFO("luid = %s", mapping->luid);
+       _DEBUG_INFO("guid = %s", mapping->guid);
+       _DEBUG_INFO("access_name = %s", mapping->access_name);
+
+       _stmt_bind_int(daci_handler, stmt, 1, mapping->account_id);
+       _stmt_bind_int(daci_handler, stmt, 2, mapping->data_store_id);
+       __stmt_bind_text(daci_handler, stmt, 3, mapping->luid);
+       __stmt_bind_text(daci_handler, stmt, 4, mapping->guid);
+       __stmt_bind_text(daci_handler, stmt, 5, mapping->access_name);
+
+       _DEBUG_INFO("query = %s", query);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = _delete_account(daci_handler, SYNC_AGENT_DA_TABLE_NAME_MAPPING, account_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(luid == NULL, SYNC_AGENT_DA_ERRORS, "luid is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from mapping_tbl where account_id = ? and luid = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, account_id);
+       __stmt_bind_text(daci_handler, stmt, 2, luid);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_mapping_s *da_get_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_mapping_s *mapping = 0;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from mapping_tbl where account_id = %d", account_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+       *count = data_count;
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               mapping = SYNC_AGENT_DA_MEMORY_MALLOC(sync_agent_da_mapping_s *, sizeof(sync_agent_da_mapping_s), data_count);
+               if (mapping == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       return mapping;
+               }
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select * from mapping_tbl where account_id = %d", account_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               mapping[i].account_id = __stmt_column_int(stmt, 0);
+                               mapping[i].data_store_id = __stmt_column_int(stmt, 1);
+                               mapping[i].luid = _stmt_column_text(stmt, 2);
+                               mapping[i].guid = _stmt_column_text(stmt, 3);
+                               mapping[i].access_name = _stmt_column_text(stmt, 5);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return mapping;
+}
+
+sync_agent_da_return_e da_get_mapping_by_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       daci_stmt stmt = 0;
+       sync_agent_da_mapping_s *mapping;
+       int data_count = 0;
+       int i = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from mapping_tbl where account_id = %d", account_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count != 0) {
+               /* query initialize */
+               SYNC_AGENT_DA_MEMORY_SET(g_daci_query);
+
+               snprintf(g_daci_query, sizeof(g_daci_query), "select * from mapping_tbl where account_id = %d", account_id);
+
+               stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+               if (stmt != NULL) {
+                       for (i = 0; i < data_count; i++) {
+                               if (_stmt_read_step(daci_handler, stmt) != SYNC_AGENT_DA_ERR_MORE_DATA)
+                                       break;
+
+                               mapping = NULL;
+                               ret = sync_agent_create_mapping(&mapping);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("sync_agent_create_mapping() failed !!");
+                                       return ret;
+                               }
+
+                               mapping->account_id = __stmt_column_int(stmt, 0);
+                               mapping->data_store_id = __stmt_column_int(stmt, 1);
+                               mapping->luid = _stmt_column_text(stmt, 2);
+                               mapping->guid = _stmt_column_text(stmt, 3);
+                               mapping->access_name = _stmt_column_text(stmt, 5);
+
+                               *list = g_list_append(*list, mapping);
+                       }
+                       __stmt_finalize(daci_handler, stmt);
+               } else {
+                       _DEBUG_ERROR("stmt is NULL !!");
+               }
+       } else {
+               _DEBUG_INFO("no data !!");
+               ret = SYNC_AGENT_DA_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+char *da_get_mapping_guid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(luid == NULL, NULL, "luid is NULL !!");
+
+       daci_stmt stmt = 0;
+       char *query = "select guid from mapping_tbl where account_id = ? and luid = ?";
+       char *guid = 0;
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, account_id);
+               __stmt_bind_text(daci_handler, stmt, 2, luid);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       guid = _stmt_column_text(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return guid;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(luid == NULL, SYNC_AGENT_DA_ERRORS, "luid is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       daci_stmt stmt = 0;
+       char *query = "select * from mapping_tbl where account_id = ? and luid = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, account_id);
+               __stmt_bind_text(daci_handler, stmt, 2, luid);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*sync_agent_mapping)->account_id = __stmt_column_int(stmt, 0);
+                       (*sync_agent_mapping)->data_store_id = __stmt_column_int(stmt, 1);
+                       (*sync_agent_mapping)->luid = _stmt_column_text(stmt, 2);
+                       (*sync_agent_mapping)->guid = _stmt_column_text(stmt, 3);
+                       (*sync_agent_mapping)->access_name = _stmt_column_text(stmt, 5);
+                       ret = SYNC_AGENT_DA_SUCCESS;
+               }
+
+               __stmt_finalize(daci_handler, stmt);
+       } else {
+               _DEBUG_ERROR("stmt is NULL !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_is_exist_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from mapping_tbl where account_id = %d", account_id);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_is_exist_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(luid == NULL, 0, "luid is NULL !!");
+
+       int ret = 1;
+       int data_count = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       snprintf(g_daci_query, sizeof(g_daci_query), "select count(*) from mapping_tbl where account_id = %d and luid = \'%s\'", account_id, luid);
+
+       data_count = _get_data_count(daci_handler, g_daci_query, strlen(g_daci_query));
+
+       if (data_count == 0)
+               ret = 0;
+
+       _DEBUG_INFO("ret : %d", ret);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_add_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(id_provider == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_provider_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *query = 0;
+
+       query = "insert into id_provider_tbl (id_provider_code, id_capacity, bit_per_page, last_id, free_bit_cnt) values (?, ?, ?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _stmt_bind_int(daci_handler, stmt, 1, id_provider->id_provider_code);
+       _stmt_bind_int(daci_handler, stmt, 2, id_provider->id_capacity);
+       _stmt_bind_int(daci_handler, stmt, 3, id_provider->bit_per_page);
+       _stmt_bind_int(daci_handler, stmt, 4, id_provider->last_id);
+       _stmt_bind_int(daci_handler, stmt, 5, id_provider->free_bit_cnt);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               __stmt_finalize(daci_handler, stmt);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "select id_capacity, bit_per_page, last_id, free_bit_cnt from id_provider_tbl where id_provider_code = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, id_provider_code);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       *id_provider = (sync_agent_da_id_provider_s *) calloc(1, sizeof(sync_agent_da_id_provider_s));
+                       if (*id_provider == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return SYNC_AGENT_DA_ERRORS;
+                       }
+                       (*id_provider)->id_capacity = __stmt_column_int(stmt, 0);
+                       (*id_provider)->bit_per_page = __stmt_column_int(stmt, 1);
+                       (*id_provider)->last_id = __stmt_column_int(stmt, 2);
+                       (*id_provider)->free_bit_cnt = __stmt_column_int(stmt, 3);
+               } else {
+                       ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_update_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(id_provider == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_provider_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "update id_provider_tbl set last_id = ?, free_bit_cnt = ? where id_provider_code = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, id_provider->last_id);
+       _stmt_bind_int(daci_handler, stmt, 2, id_provider->free_bit_cnt);
+       _stmt_bind_int(daci_handler, stmt, 3, id_provider->id_provider_code);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(id_page == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_page_s is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *query = 0;
+
+       query = "insert into id_page_tbl (page_index, id_provider_code, page_bit) values (?, ?, ?)";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL) {
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _stmt_bind_int(daci_handler, stmt, 1, id_page->page_index);
+       _stmt_bind_int(daci_handler, stmt, 2, id_page->id_provider_code);
+       _stmt_bind_blob(daci_handler, stmt, 3, id_page->page_bit, page_byte_size);
+       int i = 0;
+       for (; i < page_byte_size; i++) {
+               _DEBUG_INFO("[%d] %d\n", i, (id_page->page_bit)[i]);
+       }
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               __stmt_finalize(daci_handler, stmt);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, unsigned int page_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "delete from id_page_tbl where id_provider_code = ? and page_index = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_int(daci_handler, stmt, 1, id_provider_code);
+       _stmt_bind_int(daci_handler, stmt, 2, page_index);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "select page_bit from id_page_tbl where id_provider_code = ? and page_index = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, id_provider_code);
+               _stmt_bind_int(daci_handler, stmt, 2, page_index);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       int byte_len = sqlite3_column_bytes(stmt, 0);
+                       byte_len += 1;  /* The count which sqlite3_column_bytes returns doesn't include trailing \0 in case of string. */
+                       *page_bit = (char *)calloc(byte_len, sizeof(char));
+                       if (*page_bit == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return SYNC_AGENT_DA_ERRORS;
+                       }
+
+                       const unsigned char *geted_page_bit = sqlite3_column_text(stmt, 0);
+
+                       memcpy(*page_bit, geted_page_bit, byte_len);
+               } else {
+                       _DEBUG_INFO("NO DATA");
+                       *page_bit = 0;
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_get_id_page_index(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "select count(*) from id_page_tbl where id_provider_code = ?;";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(daci_handler, stmt, 1, id_provider_code);
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       *count = __stmt_column_int(stmt, 0);
+               } else {
+                       _DEBUG_INFO("NO DATA");
+                       *count = 0;
+               }
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(id_page == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_page_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       daci_stmt stmt = 0;
+       char *query = "update id_page_tbl set page_bit = ? where id_provider_code = ? and page_index = ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       _stmt_bind_blob(daci_handler, stmt, 1, id_page->page_bit, page_byte_size);
+       _stmt_bind_int(daci_handler, stmt, 2, id_page->id_provider_code);
+       _stmt_bind_int(daci_handler, stmt, 3, id_page->page_index);
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+       char *new_table = 0;
+       int data_count = 0;
+
+       _DEBUG_INFO("data_store_id = %d", data_store_id);
+
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", fw_account_id, 1);
+       if (new_table == NULL) {
+               _DEBUG_ERROR("__replace_table_name is failed");
+               *item_count = 0;
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       snprintf(query, sizeof(query), "select count(distinct item_tbl.item_id) from item_tbl where item_tbl.account_id = %d and item_tbl.data_store_id = %d and"
+               " item_tbl.item_id not in (select distinct item.item_id from item_tbl as item join %s as changelog where changelog.item_id = item.item_id and item.data_store_id = %d and changelog.operation_id = 303)", fw_account_id, data_store_id, new_table, data_store_id);
+       _DEBUG_INFO("query = %s", query);
+       data_count = _get_data_count(daci_handler, query, strlen(query));
+
+       *item_count = data_count;
+
+       if (new_table != NULL)
+               free(new_table);
+       new_table = NULL;
+
+       _EXTERN_FUNC_EXIT;
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+
+int _busy_handler(void *pData, int count)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("__busy_handler %d called", count);
+
+       /*  sleep time when SQLITE_LOCK */
+       usleep(100000);
+
+       _INNER_FUNC_EXIT;
+
+       /* retry will be stopped if  busy handler return 0 */
+       return SYNC_AGENT_DA_RETRY_COUNT - count;
+}
+
+sync_agent_da_return_e __query_exec(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, char *err_msg)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERR_NOT_OPENED, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "query is NULL !!");
+
+       char *query_msg = 0;
+       int ret = 0;
+
+       int err_mutex = pthread_mutex_lock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+       ret = sqlite3_exec(daci_handler, query, 0, 0, &query_msg);
+       err_mutex = pthread_mutex_unlock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+       }
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("%s(%d) : %s", err_msg, ret, query_msg);
+
+               if (NULL != query_msg)
+                       sqlite3_free(query_msg);
+
+               if (ret == SQLITE_BUSY)
+                       return SYNC_AGENT_DA_ERR_LOCKED;
+
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+daci_stmt __query_prepare(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, int size)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(query == NULL, NULL, "query is NULL !!");
+
+       int ret = 0;
+       daci_stmt stmt = 0;
+
+       int err_mutex = pthread_mutex_lock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+       ret = sqlite3_prepare_v2(daci_handler, query, size, &stmt, 0);
+       err_mutex = pthread_mutex_unlock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+       }
+
+       if (ret != SQLITE_OK)
+               _DEBUG_ERROR("sqlite3_query_prepare failed(%d) : %s ", ret, sqlite3_errmsg(daci_handler));
+
+       _INNER_FUNC_EXIT;
+
+       return stmt;
+}
+
+sync_agent_da_return_e __stmt_bind_text(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const char *value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       if (value != NULL) {
+               ret = sqlite3_bind_text(stmt, index, value, strlen(value), SQLITE_STATIC);
+       } else {
+               ret = __stmt_bind_null(daci_handler, stmt, index);
+
+               if (ret == SYNC_AGENT_DA_SUCCESS)
+                       ret = SQLITE_OK;
+       }
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_text failed(%d) : %s ", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e _stmt_bind_int(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const int value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_bind_int(stmt, index, value);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_int failed(%d) : %s \n", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e _stmt_bind_blob(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index, const void *value, int nbyte)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_bind_blob(stmt, index, value, nbyte, 0);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_bind_blob failed(%d) : %s \n", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e __stmt_bind_null(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_bind_null(stmt, index);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_null failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e _stmt_read_step(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+//      int err_mutex = 0;
+
+//      err_mutex = pthread_mutex_lock(&exec_lock);
+//      if (err_mutex) {
+//              _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+//      }
+
+       ret = sqlite3_step(stmt);
+
+//      err_mutex = pthread_mutex_unlock(&exec_lock);
+//      if (err_mutex) {
+//              _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+//      }
+
+       if (ret == SQLITE_ROW)
+               return SYNC_AGENT_DA_ERR_MORE_DATA;
+
+       if (ret != SQLITE_DONE) {
+               _DEBUG_ERROR("sqlite3_stmt_step failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+
+               if (ret == SQLITE_BUSY)
+                       return SYNC_AGENT_DA_ERR_LOCKED;
+
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e __stmt_write_step(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int transaction_flag = 0;
+       int err_mutex = 0;
+
+       if (use_transaction_thread_id != 0) {
+               if (use_transaction_thread_id != SYNC_AGENT_DA_GET_THREAD_ID) {
+                       err_mutex = pthread_mutex_lock(&transaction_lock);
+                       if (err_mutex) {
+                               _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+                       }
+                       use_transaction_thread_id = SYNC_AGENT_DA_GET_THREAD_ID;
+                       transaction_flag = 1;
+               }
+       }
+
+       err_mutex = pthread_mutex_lock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+
+       int ret = sqlite3_step(stmt);
+
+       err_mutex = pthread_mutex_unlock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+       }
+
+       if (transaction_flag) {
+               use_transaction_thread_id = 0;
+               err_mutex = pthread_mutex_unlock(&transaction_lock);
+               if (err_mutex) {
+                       _DEBUG_ERROR("Failed pthread_mutex_unlock : %d", err_mutex);
+               }
+       }
+
+       if (ret == SQLITE_ROW) {
+               return SYNC_AGENT_DA_ERR_MORE_DATA;
+       }
+
+       if (ret != SQLITE_DONE) {
+               _DEBUG_ERROR("sqlite3_stmt_step failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+               if (ret == SQLITE_BUSY) {
+                       _DEBUG_ERROR("Never reached this line!!");
+                       return SYNC_AGENT_DA_ERR_LOCKED;
+               }
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e _stmt_reset(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       if (sqlite3_reset(stmt) != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_reset failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e __stmt_finalize(SYNC_AGENT_DA_HANDLER * daci_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_finalize failed(%d) : %s", ret, sqlite3_errmsg(daci_handler));
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+char *_stmt_column_text(daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       char *temp = 0;
+
+       temp = (char *)sqlite3_column_text(stmt, index);
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_STRDUP(temp);
+}
+
+int __stmt_column_int(daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return (int)sqlite3_column_int(stmt, index);
+}
+
+sync_agent_da_return_e _get_table(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, char ***result, int *row_count, int *col_count)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERR_NOT_OPENED, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "query is NULL !!");
+
+       int ret = 0;
+       char *err_msg;
+
+       int err_mutex = pthread_mutex_lock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_TRACE("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+       ret = sqlite3_get_table(daci_handler, query, result, row_count, col_count, &err_msg);
+       err_mutex = pthread_mutex_unlock(&exec_lock);
+       if (err_mutex) {
+               _DEBUG_TRACE("Failed pthread_mutex_lock : %d", err_mutex);
+       }
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_get_table failed(%d) : %s", ret, err_msg);
+
+               __free_table(*result);
+               if (NULL != err_msg)
+                       sqlite3_free(err_msg);
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+void __free_table(char **result)
+{
+       _INNER_FUNC_ENTER;
+
+       if (result != NULL)
+               sqlite3_free_table(result);
+
+       _INNER_FUNC_EXIT;
+}
+
+sync_agent_da_return_e _create_changelog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *new_table = 0;
+       char *new_table_create = 0;
+
+       ret = da_begin_transaction(daci_handler);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("agent_db_changelog_tbl_create failed");
+               return SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED;
+       }
+
+       /* 9. create account_item_changelog_tbl */
+       new_table = __replace_table_name("account_%d_item_changelog_tbl", account_id, 1);
+       if (new_table == NULL) {
+               da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+               return SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED;
+       }
+
+       if (__exist_table(daci_handler, new_table) == 0) {
+               new_table_create = __replace_table_name(g_daci_create_table[SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG], account_id, 4);
+
+               ret = __query_exec(daci_handler, new_table_create, "Item_changelog_tbl_create failed");
+
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+                       return SYNC_AGENT_DA_ERR_CREATE_TABLE_FAILED;
+               }
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table);
+       SYNC_AGENT_DA_MEMORY_FREE(new_table_create);
+
+       _INNER_FUNC_EXIT;
+
+       return da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_COMMIT);
+}
+
+sync_agent_da_return_e _drop_changelog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *new_table_drop = 0;
+
+       /* 9. drop account_item_changelog_tbl */
+       new_table_drop = __replace_table_name(g_daci_drop_table[SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG], account_id, 1);
+
+       ret = __query_exec(daci_handler, new_table_drop, "Item_changelog_tbl_drop failed");
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+/*             da_end_transaction(daci_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);*/
+               return SYNC_AGENT_DA_ERR_DROP_TABLE_FAILED;
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table_drop);
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e _delete_changlog_table(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *new_table_delete = 0;
+
+       /* 9. delete account_item_changelog_tbl */
+       new_table_delete = __replace_table_name(g_daci_delete_table[SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG], account_id, 1);
+
+       ret = __query_exec(daci_handler, new_table_delete, "Item_changelog_tbl_delete failed");
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       /* memory free */
+       SYNC_AGENT_DA_MEMORY_FREE(new_table_delete);
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+int __exist_table(SYNC_AGENT_DA_HANDLER * daci_handler, const char *table_name)
+{
+       _INNER_FUNC_ENTER;
+
+       daci_stmt stmt = 0;
+       int table_count = 0;
+       char *query = "select count(*) from sqlite_master where tbl_name= ?";
+
+       stmt = __query_prepare(daci_handler, query, strlen(query));
+       if ((stmt != NULL) && (__stmt_bind_text(daci_handler, stmt, 1, table_name) == SYNC_AGENT_DA_SUCCESS)) {
+
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       table_count = __stmt_column_int(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+
+               if (table_count > 0) {
+                       _INNER_FUNC_EXIT;
+
+                       return 1;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+int _get_data_count(SYNC_AGENT_DA_HANDLER * daci_handler, char *query, int size)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, 0, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retvm_if(query == NULL, 0, "query is NULL !!");
+
+       daci_stmt stmt = 0;
+       int data_count = 0;
+
+       stmt = __query_prepare(daci_handler, query, size);
+       if (stmt != NULL) {
+               if (_stmt_read_step(daci_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       data_count = __stmt_column_int(stmt, 0);
+
+               __stmt_finalize(daci_handler, stmt);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return data_count;
+}
+
+char *__replace_table_name(char *oldTable, int account_id, int count)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(oldTable == NULL, NULL, "old Table is NULL !!");
+
+       char *new_table = 0;
+       int length = 0;
+
+       /* SVACE : Measure the size for allocation memory. */
+       if (count == 1)         /* table name convert */
+               length = snprintf(0, 0, oldTable, account_id);
+       else if (count == 4)    /* table create query convert */
+               length = snprintf(0, 0, oldTable, account_id, account_id, account_id, account_id);
+
+       new_table = SYNC_AGENT_DA_MEMORY_MALLOC(char *, sizeof(char), (length + 1));
+       if (new_table == NULL) {
+               _DEBUG_ERROR("memory_allocation failed");
+               return new_table;
+       }
+
+       if (count == 1) {
+               snprintf(new_table, length + 1, oldTable, account_id);
+       } else if (count == 4) {
+               snprintf(new_table, length + 1, oldTable, account_id, account_id, account_id, account_id);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return new_table;
+}
+
+char *__get_table_name(sync_agent_da_table_name_e table_name)
+{
+       _INNER_FUNC_ENTER;
+
+       char *table_str = 0;
+
+       switch (table_name) {
+       case SYNC_AGENT_DA_TABLE_NAME_ACCOUNT:
+               {
+                       table_str = "account_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_FOLDER:
+               {
+                       table_str = "folder_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_ITEM:
+               {
+                       table_str = "item_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_CONFIG:
+               {
+                       table_str = "config_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_ACCOUNT_ITEM_CHANGELOG:
+               {
+                       table_str = "account_item_changelog_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_LAST_ANCHOR:
+               {
+                       table_str = "last_anchor_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_MAPPING:
+               {
+                       table_str = "mapping_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_ID_PROVIDER:
+               {
+                       table_str = "id_provider_tbl";
+               }
+               break;
+       case SYNC_AGENT_DA_TABLE_NAME_ID_PAGE:
+               {
+                       table_str = "id_page_tbl";
+               }
+               break;
+       default:
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return table_str;
+}
+
+char *_get_column_name(sync_agent_da_column_name_e column_name)
+{
+       _INNER_FUNC_ENTER;
+
+       char *column_str = 0;
+
+       switch (column_name) {
+       case SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID:
+               {
+                       column_str = "item_id";
+               }
+               break;
+       case SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID:
+               {
+                       column_str = "service_id";
+               }
+               break;
+       default:
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return column_str;
+}
+
+int _get_next_account_id(void)
+{
+       _INNER_FUNC_ENTER;
+
+       int next_account_id = 1;
+       int *account_id_list = 0;
+       int count = 0;
+       int i = 0;
+
+       account_id_list = da_get_account_id_list(&count);
+       if (account_id_list != NULL) {
+               for (i = 0; i < count; i++) {
+                       if ((i + 1) != account_id_list[i])
+                               break;
+
+                       next_account_id++;
+               }
+
+               free(account_id_list);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return next_account_id;
+}
+
+sync_agent_da_return_e _delete_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_table_name_e table_name, int account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(daci_handler == NULL, SYNC_AGENT_DA_ERRORS, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       daci_stmt stmt = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       char *table_str = 0;
+       char g_daci_query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       table_str = __get_table_name(table_name);
+
+       if (!strcmp(table_str, "config_tbl")) {
+               snprintf(g_daci_query, sizeof(g_daci_query), "delete from %s where config_id = %d", table_str, account_id);
+       } else if (!strcmp(table_str, "id_provider_tbl") || !strcmp(table_str, "id_page_tbl")) {
+               return ret;
+       } else {
+               snprintf(g_daci_query, sizeof(g_daci_query), "delete from %s where account_id = %d", table_str, account_id);
+       }
+
+       _DEBUG_TRACE("i = %d, tableName = %s, query = %s", table_name, table_str, g_daci_query);
+       stmt = __query_prepare(daci_handler, g_daci_query, strlen(g_daci_query));
+       if (stmt == NULL)
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+
+       ret = __stmt_write_step(daci_handler, stmt);
+       __stmt_finalize(daci_handler, stmt);
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+/*
+ *=============================================================================================================================
+ * Testing
+ *=============================================================================================================================
+*/
+void da_drop_table(SYNC_AGENT_DA_HANDLER * daci_handler, int *accountIdList, int account_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(daci_handler == NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+       retm_if(accountIdList == NULL, "account Id List is NULL !!");
+
+       int i;
+
+       for (i = 0; i < account_count; i++)
+               _drop_changelog_table(daci_handler, accountIdList[i]);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+char *da_get_daci_file_path(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return daci_file_path;
+}
diff --git a/src/framework/data-adapter/agent.h b/src/framework/data-adapter/agent.h
new file mode 100755 (executable)
index 0000000..923fded
--- /dev/null
@@ -0,0 +1,1319 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AGENT_H_
+#define AGENT_H_
+
+#include "data-adapter/common.h"
+#include "data-adapter/common_internal.h"
+
+#include "account/manager.h"
+
+/**
+ * @file               agent.h
+ * @brief      Internal API to manage sync-agent-framework database
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/*
+ * =============================================================================================================================
+ * Database Open & Close & Delete Account Data
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief Start Agent database transaction
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_TRANSACTION_FAILED error
+ */
+sync_agent_da_return_e da_begin_transaction(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/**
+ * @brief Finish Agent database transaction
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  transaction commit or rollback transaction
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_TRANSACTION_FAILED error
+ */
+sync_agent_da_return_e da_end_transaction(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_transaction_e transaction);
+
+/**
+ * @brief Set agent db file path
+ * @param[in]  file_path agent db file path
+ */
+void da_set_agent_db_file_path(char *file_path);
+
+/**
+ * @brief Open Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_OPEN_FAILED error
+ */
+sync_agent_da_return_e da_open_agent(SYNC_AGENT_DA_HANDLER ** daci_handler);
+
+/**
+ * @brief Close Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
+ */
+sync_agent_da_return_e da_close_Agent(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/**
+ * @brief Create Agent database
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
+ */
+sync_agent_da_return_e da_create_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/**
+ * @brief Empty Agent database table
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
+ */
+sync_agent_da_return_e da_empty_agent_default_table(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_table_name_e table_name);
+
+/**
+ * @brief Empty all Agent database tables
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
+ */
+sync_agent_da_return_e da_empty_all_agent_table(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/*
+ * =============================================================================================================================
+ * account_tb
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert account into account_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  sync_agent_fw_account_s account info
+ * @return Operation result
+ * @retval account id (positive number) success
+ * @retval -1 error
+ */
+int da_add_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account);
+
+/**
+ * @brief Update account into account_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  sync_agent_fw_account_s account info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_fw_account_s * account);
+
+/**
+ * @brief Delete account data from Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+/**
+ * @brief Get account data from Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  account as returned by da_get_fw_account() - account info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, sync_agent_fw_account_s ** account);
+
+/**
+ * @brief Get all account data from Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in] list list of sync_agent_fw_account_s
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_all_fw_account(SYNC_AGENT_DA_HANDLER * daci_handler, GList ** list);
+
+/**
+ * @brief Get account data by access name from Agent database
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  access_name db access name
+ * @param[in]  list as returned by da_get_fw_account_by_access_name() - list of sync_agent_fw_account_s
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_fw_account_by_access_name(SYNC_AGENT_DA_HANDLER * daci_handler, char *access_name, GList ** list);
+
+/**
+ * @brief Get all account id from account_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  count as returned by da_get_account_account_id_list() - count of account id
+ * @return Operation result
+ * @retval array of account id success
+ * @retval NULL error
+ */
+int *da_get_account_account_id_list(SYNC_AGENT_DA_HANDLER * daci_handler, int *count);
+
+/**
+ * @brief Checking whether the account id exist in account_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_account(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+/**
+ * @brief Get account id list from account_tbl by access name
+ * @remarks    Caller should free return value
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  access_name db access name
+ * @param[in]  accountId_count as returned by da_get_account_id_list_by_access_name() - count of account id
+ * @return Operation result
+ * @retval account id list success
+ * @retval NULL error
+ */
+int *da_get_account_id_list_by_access_name(SYNC_AGENT_DA_HANDLER * daci_handler, char *access_name, int *accountId_count);
+
+/**
+ * @brief Get account count
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_get_account_count(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/*
+ * =============================================================================================================================
+ * folder_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief Insert folder into folder_tbl - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder array of folder info
+ * @param[in]  count count of folder info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_folder(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_folder_s * folder, int count);
+
+/**
+ * @brief Insert folder into folder_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder array of folder info
+ * @param[in]  count count of folder info
+ * @param[in] folder_id as returned by da_add_folder_new() - id of newly added folder
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete folder from folder_tbl by folderId
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder_id folder id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_folder_by_folder_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id);
+
+/**
+ * @brief Get folderId from folder_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  service_id service id
+ * @param[in]  folder_type_id folder type id
+ * @return Operation result
+ * @retval folder id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get folderId from folder_tbl by folder  type id - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] item_type_id item type id
+ * @param[in]  folder_type_id folder type id
+ * @return Operation result
+ * @retval folder id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get folderId from folder_tbl by folder  type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] item_type_id item type id
+ * @param[in]  folder_type_id folder type id
+ * @param[in] list as returned by da_get_folder_folder_id_by_folder_type_id_new() - list of folder id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get serviceId from folder_tbl
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder_id folder id
+ * @return Operation result
+ * @retval service id success
+ * @retval NULL error
+ */
+char *da_get_folder_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *folder_id);
+
+/**
+ * @brief Get all folder_id_list from folder_tbl by data_store_id - currently unused function
+ *                             Get all the folders in account and data store
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval array of folder id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get all folder_id_list from folder_tbl by data_store_id
+ *                             Get all the folders in account and data store
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in] list as returned by da_get_folder_folder_id_list_by_item_type_id_new() - list of folder id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item from folder_tbl - currently unused function
+ *                             Belonging to different account of folder get folder with the same service_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @param[in]  count   as returned by da_get_folder_mapping_service_id() -     count of item info
+ * @return Operation result
+ * @retval array of folder info success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item from folder_tbl
+ *                             Belonging to different account of folder get folder with the same service_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @param[in]  list    as returned by da_get_folder_mapping_service_id() -     list of item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get folder info from folder_tbl by folder id
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] folder_id folder id
+ * @param[in] sync_agent_folder as returned by da_get_folder_by_folder_id() - folder info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether the folderId exist in folder_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_folder(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *folder_id);
+
+/*
+ * =============================================================================================================================
+ * item_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert item into item_tbl - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item array of item info
+ * @param[in]  count count of item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_item(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_item_s * item, int count);
+
+/**
+ * @brief      Insert item into item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item array of item info
+ * @param[in]  count count of item info
+ * @param[in] item_id - id of newly added item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete item from item_tbl by item id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_by_Item_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
+
+/**
+ * @brief Delete item from item_tbl by account id and item type id - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete item from item_tbl by account id and item type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete item from item_tbl by account id and item type id and row that checked delete from changelog tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item id from item_tbl - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  service_id service id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval item id success
+ * @retval NULL error
+ */
+char *da_get_item_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *service_id, int item_type_id);
+
+/**
+ * @brief Get item id from item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  service_id service id
+ * @param[in]  item_type_id item type id
+ * @param[in] item_id as returned by da_get_item_item_id_new() - id of newly added item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get service id from item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval service id success
+ * @retval NULL error
+ */
+char *da_get_item_service_id(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
+
+/**
+ * @brief Get item from item_tbl - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval item info success
+ * @retval NULL error
+ */
+sync_agent_da_item_s *da_get_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
+
+/**
+ * @brief Get item from item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item_id item id
+ * @param[in] sync_agent_item as returned by da_get_item_new() - item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get all item id from item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_all_item_id(SYNC_AGENT_DA_HANDLER * daci_handler);
+
+/**
+ * @brief Get all id in folder from item_tbl - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder_id folder id
+ * @param[in]  column_name column name (SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID or SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID)
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get all id in folder from item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  folder_id folder id
+ * @param[in]  column_name column name (SYNC_AGENT_DA_COLUMN_NAME_ITEM_ID or SYNC_AGENT_DA_COLUMN_NAME_SERVICE_ID)
+ * @param[in] list as returned by da_get_item_id_list_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item from item_tbl by accountId - currently unused function
+ *                             Get all the items in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  count as returned by da_get_item_by_account_id() - count of item info
+ * @return Operation result
+ * @retval array of item info success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item from item_tbl by accountId
+ *                             Get all the items in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  list as returned by da_get_item_by_account_id() - list of item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item data from item_tbl and account_item_changelog_tbl
+ *                             Among the items that belong to the item type id, Search for item info belong to the changelog
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  count   as returned by da_get_item_info_by_item_type_id() - count of item data
+ * @return Operation result
+ * @retval array of item data success
+ * @retval NULL error
+ */
+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);
+
+/*
+ * @brief Get item data from item_tbl and account_item_changelog_tbl - currently unused function
+ *                             Among the items that belong to the item type id, Search for item info belong to the changelog
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in] operation_id operation id
+ * @param[in]  count   as returned by da_get_item_info_by_item_type_id_and_operation_id() - count of item data
+ * @return Operation result
+ * @retval array of item data success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item data from item_tbl and account_item_changelog_tbl
+ *                             Among the items that belong to the item type id, Search for item info belong to the changelog
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in] operation_id operation id
+ * @param[in]  list    as returned by da_get_item_info_by_item_type_id_and_operation_id() - list of item data
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item from item_tbl - currently unused function
+ *                             Belonging to different account of item get item with the same service id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @param[in]  count as returned by da_get_item_mapping_service_id() - count of item info
+ * @return Operation result
+ * @retval array of item info success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item from item_tbl
+ *                             Belonging to different account of item get item with the same service id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @param[in]  list as returned by da_get_item_mapping_service_id() - list of item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get all item id from item_tbl by data store id - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  data_store_id data store id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_by_datastore_id(SYNC_AGENT_DA_HANDLER * daci_handler, int data_store_id);
+
+/**
+ * @brief Get all item id from item_tbl by data store id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  data_store_id data store id
+ * @param[in] list as returned by da_get_item_id_list_by_datastore_id_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl by data store id and account id - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id sync-agent-framework account id
+ * @param[in]  data_store_id data store id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error or not exist
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl by data store id and account id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id sync-agent-framework account id
+ * @param[in]  data_store_id data store id
+ * @param[in] list as returned by da_get_item_id_list_by_datastore_id_with_account_id_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id  - currently unused function
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @param[in] list as returned by da_get_item_id_list_by_operation_id_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id and folder id - currently unused function
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] folder_id folder id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl by operation id and folder id
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] folder_id folder id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @param[in] list as returned by da_get_item_id_list_by_operation_id_and_folder_id_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl by account id and folder id
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @param[out] list as returned by da_get_item_id_list_by_operation_id_and_folder_id_new() - list of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether the itemId exist in item_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  item_id item id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_item(SYNC_AGENT_DA_HANDLER * daci_handler, char *item_id);
+
+/*
+ * =============================================================================================================================
+ * config_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert config into config_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config config info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
+
+/**
+ * @brief      Insert config list into config_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config_list list list of config info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_config_list(SYNC_AGENT_DA_HANDLER * daci_handler, GList * config_list);
+
+/**
+ * @brief Delete config from config_tbl by key
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config_id config id
+ * @param[in]  key key value
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_config_by_key(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key);
+
+/**
+ * @brief Get list of config info from config_tbl by account id
+ *                             Get all the config in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  list as returned by da_get_config_by_account_id() - list of config info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_config_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list);
+
+/**
+ * @brief Get config info from config_tbl by key
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config_id config id
+ * @param[in] key key value
+ * @param[in]  config as returned by da_get_config_by_key() - config info (account id, key, value, type)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether account of the config exist in config_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config_id config id
+ * @param[in]  key key value
+ * @param[in]  exist   as returned by da_is_exist_config() -   whether exist or not
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_is_exist_config(SYNC_AGENT_DA_HANDLER * daci_handler, int config_id, char *key, int *exist);
+
+/**
+ * @brief      Insert or update config into config_tbl
+ *                             checking whether the config exist in config_tbl
+ *                             If it does not exist, insert config into config_tbl
+ *                             If it existed, update config into config_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config config info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_config(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
+
+/**
+ * @brief      Update config into config_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  config config info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_config_value(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_config_s * config);
+
+/*
+ * =============================================================================================================================
+ * account_item_changelog_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert itemChangelog into account_item_changelog_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in] account_id account id
+ * @param[in]  itemChangelog array of itemChangelog info
+ * @param[in]  count count of itemChangelog info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_changelog_by_item_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item id list
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_id_list array of item id
+ * @param[in]  count count of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Set operation id and sync status to account_item_changelog_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog itemChangelog info (operationId, syncStatus, accessName, itemId)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Set sync status to account_item_changelog_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog itemChangelog info (syncStatus, accessName, itemId)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Set SYNC_WAIT to account_item_changelog_tbl
+ *                             Among the items that match to the itemTypeId and belong to the folder
+ *                             If it existed in account_item_changelog_tbl, set SYNC_WAIT to account_item_changelog_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  folder_id_list list of folder id
+ * @param[in]  folder_id_count count of folder id
+ * @param[in]  item_type_id_list list of item type id
+ * @param[in]  item_type_id_count count of item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get itemChangelog info from account_item_changelog_tbl by item id - currently unused function
+ * @remarks Item id that is included in sync_agent_da_item_changelog_s must be set by user when call this function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog as returned by da_get_item_changelog_by_item_id() - itemChangelog info (itemId, operationId, syncStatus, accessName)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get itemChangelog info from account_item_changelog_tbl by item id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] item_id item id
+ * @param[in]  sync_agent_item as returned by da_get_item_changelog_by_item_id() - itemChangelog info (itemId, operationId, syncStatus, accessName)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Get itemChangelog info from account_item_changelog_tbl by item type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in] item_type_id item type id
+ * @param[in] list as returned by da_get_item_changelog_by_item_type_id() - list of itemChangelog info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether the item id exist in account_item_changelog_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_item_changelog(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *item_id);
+
+/*
+ * =============================================================================================================================
+ * last_anchor_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert anchor into last_anchor_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  last_anchor last anchor info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor);
+
+/**
+ * @brief Delete anchor from last_anchor_tbl by account id
+ *                             Delete all the anchor in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+/**
+ * @brief Delete anchor from last_anchor_tbl by item type id
+ *                             Delete all the anchor in account and item type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Set last_anchor_server and last_anchor_client to last_anchor_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  last_anchor last anchor info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_last_anchor_s * last_anchor);
+
+/**
+ * @brief Get all last anchor in account from last_anchor_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  count as returned by da_get_last_anchor_by_account_id() -       count of last anchor info
+ * @return Operation result
+ * @retval array of last anchor info success
+ * @retval NULL error
+ */
+sync_agent_da_last_anchor_s *da_get_last_anchor_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count);
+
+/**
+ * @brief Get last_anchor_server and last_anchor_client from last_anchor_tbl by item type id - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id                                                                              accountId
+ * @param[in]  item_type_id                                                                            itemTypeId
+ * @param[in]  count   as returned by da_get_last_anchor_by_item_type_id() - count of last anchor info
+ * @return Operation result
+ * @retval last anchor info success
+ * @retval NULL error
+ */
+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);
+
+/**
+ * @brief Get last_anchor_server and last_anchor_client from last_anchor_tbl by item type id
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id                                                                              accountId
+ * @param[in]  item_type_id                                                                            itemTypeId
+ * @param[in]  list    as returned by da_get_last_anchor_by_item_type_id() - list of last anchor info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether item type id of the anchor exist in last_anchor_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_last_anchor(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int item_type_id);
+
+/*
+ * =============================================================================================================================
+ * mapping_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert mapping into mapping_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  mapping mapping info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_mapping(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_mapping_s * mapping);
+
+/**
+ * @brief Delete mapping from mapping_tbl by account id
+ *                             Delete all the mapping in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+/**
+ * @brief Delete mapping from mapping_tbl by luid
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  luid luid
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
+
+/**
+ * @brief Get all mapping info from mapping_tbl by account id - currently unused function
+ *                             Get all the mapping info in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  count as returned by da_get_mapping_by_account_id() - count of mapping info
+ * @return Operation result
+ * @retval array of mapping info success
+ * @retval NULL error
+ */
+sync_agent_da_mapping_s *da_get_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, int *count);
+
+/**
+ * @brief Get all mapping info from mapping_tbl by account id
+ *                             Get all the mapping info in account
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  list as returned by da_get_mapping_by_account_id() - list of mapping info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_mapping_by_account_id_new(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, GList ** list);
+
+/**
+ * @brief Get luid from mapping_tbl by guid - currently unused function
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  luid luid
+ * @return Operation result
+ * @retval guid success
+ * @retval NULL error
+ */
+char *da_get_mapping_guid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
+
+/**
+ * @brief Get luid from mapping_tbl by guid
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  luid luid
+ * @param[in] sync_agent_mapping as returned by da_get_mapping_guid_new() - mapping info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Checking whether account exist in mapping_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_mapping_by_account_id(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id);
+
+/**
+ * @brief Checking whether the account and item tpe id of the item type id exist in mapping_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  account_id account id
+ * @param[in]  luid luid
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 error or not exist
+ */
+int da_is_exist_mapping_by_luid(SYNC_AGENT_DA_HANDLER * daci_handler, int account_id, char *luid);
+
+/*
+ * =============================================================================================================================
+ * id_provider_tbl, id_page_tbl
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief      Insert id_provider into id_provider_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider);
+
+/**
+ * @brief Get id_provider from id_provider_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  id_provider     as returned by da_get_id_provider() - id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Update id provider in id_provider_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_id_provider(SYNC_AGENT_DA_HANDLER * daci_handler, sync_agent_da_id_provider_s * id_provider);
+
+/**
+ * @brief      Insert id page into id_page_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_page id page info
+ * @param[in] page_byte_size page byte size
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief Delete id page from id_page_tbl by page index
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  page_index page index
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_id_page(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, unsigned int page_index);
+
+/**
+ * @brief      Insert id page into id_page_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  page_index page index
+ * @param[in]  page_bit as returned by da_get_id_page() - page bit
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/**
+ * @brief      Get id of page index
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  count   as returned by da_get_id_page_index() - count of page index
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_id_page_index(SYNC_AGENT_DA_HANDLER * daci_handler, unsigned int id_provider_code, int *count);
+
+/**
+ * @brief Insert id page into id_page_tbl
+ * @param[in]  daci_handler sqlite3 handler pointer about thread
+ * @param[in]  id_page id page info
+ * @param[in]  page_byte_size page byte size
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+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);
+
+/*
+ * @brief      get item count with data store id
+ * @param[in]          daci_handler                                                                    sqlite3 handler pointer about thread
+ * @param[in]          data_store_id                                                                   data store id
+ * @param[in]          fw_account_id                                                                   account id
+ * @param[out] item_count                                                                      item count
+ * @return             operation result
+ * @retval             SYNC_AGENT_DA_SUCCESS                                           success
+ * @retval             error value                                                                     fail
+ */
+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);
+/*
+ * =============================================================================================================================
+ * Testing
+ * =============================================================================================================================
+ */
+
+/**
+ * @brief Drop database table for list of account id
+ * @param[in] daci_handler sqlite3 handler pointer about thread
+ * @param[in] account_id_list list of account id
+ * @param[in] account_count count of account id
+ */
+void da_drop_table(SYNC_AGENT_DA_HANDLER * daci_handler, int *account_id_list, int account_count);
+
+/*
+ * For ID_Provider todo i should remove this rutine!!!!
+ */
+/**
+ * @breif Get daci file path
+ * @return Operation result
+ * @retval daci file path success
+ * @retval NULL error
+ */
+char *da_get_daci_file_path(void);
+
+#endif                         /* AGENT_H_ */
diff --git a/src/framework/data-adapter/agent_handler_manager.c b/src/framework/data-adapter/agent_handler_manager.c
new file mode 100755 (executable)
index 0000000..3c3ddf7
--- /dev/null
@@ -0,0 +1,1575 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+
+#include "data-adapter/agent.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "data-adapter/interface_service_item.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+static sync_agent_da_handler_mgr_s *agent_db_handler_mgr = 0;
+
+/* static function define */
+static sync_agent_da_return_e _free_agent_dc_handler_table(void);
+static sync_agent_da_return_e _free_agent_dc_handler_table_mutex(void);
+static sync_agent_da_return_e _create_agent_db_handler_mgr_info(void);
+static sync_agent_da_return_e __alloc_agent_dc_handler_table(void);
+static sync_agent_da_return_e __alloc_agent_dc_handler_table_mutex(void);
+static void ___destroy_agent_db_hashtable_value(void *handler);
+static void ___destory_agent_db_hashtable_key(void *key);
+
+/* general function implementation */
+/*
+ * ==================================
+ * external API (1. about agent db handler mgr)
+ * ==================================
+ */
+sync_agent_da_return_e da_alloc_agentdb_handler_mgr()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /* alloc the agentDBHandlerMgr */
+       agent_db_handler_mgr = (sync_agent_da_handler_mgr_s *) calloc(1, sizeof(sync_agent_da_handler_mgr_s));
+       if (agent_db_handler_mgr == NULL)
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       _DEBUG_INFO("[%s] pAgentDBHandlerMgr alloc success !\n", __func__);
+
+       /* alloc the agentDBHandlerMgr information */
+       ret = _create_agent_db_handler_mgr_info();
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               _DEBUG_INFO("[%s] _da_create_agent_db_handler_mgr_info alloc fail !\n", __func__);
+       else
+               _DEBUG_INFO("[%s] _da_create_agent_db_handler_mgr_info alloc success !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_free_agentdb_handler_mgr()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (agent_db_handler_mgr != NULL) {
+
+               ret = _free_agent_dc_handler_table_mutex();
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+
+               ret = _free_agent_dc_handler_table();
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+/*
+ * ==================================
+ * external API (2. about agent db )
+ * ==================================
+ */
+sync_agent_da_return_e da_clear_all_database_account()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int *account_Id_list = 0;
+       int count = 0;
+       int i = 0;
+
+       account_Id_list = da_get_account_id_list(&count);
+       if (account_Id_list == NULL) {
+               _DEBUG_ERROR("accountIdList empty");
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       } else {
+               _DEBUG_INFO("accountListCount : %d", count);
+       }
+
+       for (i = 0; i < count; i++) {
+               ret = da_delete_all_database_account(account_Id_list[i]);
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       break;
+       }
+
+       /* memory free */
+       if (account_Id_list != NULL)
+               free(account_Id_list);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_all_database_account(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = 0;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       int data_count = 0;
+/*     if (da_is_exist_account_id(accountId) && DACI_Delete_EmailAccount(accountId) &&
+                       DACI_Delete_ContactAccount(accountId) && DACI_Delete_CalendarAccount(accountId) &&
+                       (da_delete_account_id(accountId) == SYNC_AGENT_DA_SUCCESS)) {*/
+
+       if (da_is_exist_account_id(account_id) && (da_delete_fw_account_id(account_id) == SYNC_AGENT_DA_SUCCESS)) {
+               /* all of the deleted account */
+               data_count = da_get_account_count(daci_handler);
+               if (data_count == 0)
+                       ret = SYNC_AGENT_DA_ERR_DELETE_LAST_ACCOUNT;
+               else
+                       ret = SYNC_AGENT_DA_SUCCESS;
+
+       } else {
+               ret = SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_open_agent()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 0;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+
+               _DEBUG_INFO("daci_handler is 0");
+               _DEBUG_INFO("should register agent_handler to agent_handler_hash_table");
+               ret = da_open_agent(&daci_handler);
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       return ret;
+
+               if (daci_handler != NULL) {
+                       /* add agentDB handler to agentDBHandleMgr */
+                       ret = da_add_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID, daci_handler);
+                       if (ret != SYNC_AGENT_DA_SUCCESS)
+                               return ret;
+               }
+
+       } else {
+               _DEBUG_INFO("daci_handler is not null");
+               _DEBUG_INFO("should not register mo_handler to mo_handler_hash_table");
+       }
+
+       _DEBUG_INFO("agent_db_agent_open_success");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_close_agent()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 0;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler != NULL) {
+
+               /* remove agentDB handler to agentDBHandleMgr */
+               ret = da_remove_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       return ret;
+
+               _DEBUG_INFO("agent_db_agent_close_success");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e da_create_agent_default_table_wrapper()
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_create_agent_default_table(daci_handler);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_empty_agent_default_table(sync_agent_da_table_name_e table_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_empty_agent_default_table(daci_handler, table_name);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_empty_all_agent_default_table()
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_empty_all_agent_table(daci_handler);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_begin_transaction()
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_begin_transaction(daci_handler);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_end_transaction(sync_agent_da_transaction_e transaction)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_end_transaction(daci_handler, transaction);
+}
+
+int da_add_fw_account_id(sync_agent_fw_account_s * account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(account == NULL, -1, "sync_agent_fw_account_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_fw_account(daci_handler, account);
+}
+
+sync_agent_da_return_e da_update_fw_account_id(sync_agent_fw_account_s * account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(account == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_fw_account_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_update_fw_account(daci_handler, account);
+}
+
+sync_agent_da_return_e da_delete_fw_account_id(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_fw_account(daci_handler, account_id);
+}
+
+sync_agent_da_return_e da_get_fw_account_info(int account_id, sync_agent_fw_account_s ** account)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_fw_account(daci_handler, account_id, account);
+}
+
+sync_agent_da_return_e da_get_all_fw_account_info(GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_all_fw_account(daci_handler, list);
+}
+
+sync_agent_da_return_e da_get_fw_account_info_by_access_name(char *access_name, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_fw_account_by_access_name(daci_handler, access_name, list);
+}
+
+int *da_get_account_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_account_account_id_list(daci_handler, count);
+}
+
+int da_is_exist_account_id(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_account(daci_handler, account_id);
+}
+
+sync_agent_da_return_e da_add_folder_internal(sync_agent_da_folder_s * folder, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_folder_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_folder(daci_handler, folder, count);
+}
+
+sync_agent_da_return_e da_delete_folder_by_folder_id_wrapper(char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_folder_by_folder_id(daci_handler, folder_id);
+}
+
+char *da_get_folder_id_by_service_id_wrapper(int account_id, int item_type_id, char *service_id, int folder_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_id == NULL, NULL, "service id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_folder_folder_id_by_service_id(daci_handler, account_id, item_type_id, service_id, folder_type_id);
+}
+
+sync_agent_da_id_list_s *da_get_folder_id_by_folder_type_id_internal(int account_id, int item_type_id, int folder_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_folder_folder_id_by_folder_type_id(daci_handler, account_id, item_type_id, folder_type_id);
+}
+
+sync_agent_da_id_list_s *da_get_folder_id_list_by_item_type_id_internal(int account_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_folder_folder_id_list_by_item_type_id(daci_handler, account_id, item_type_id);
+}
+
+sync_agent_da_folder_s *da_get_item_mapping_service_id_by_folder_id_internal(int account_id, char *folder_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, NULL, "folder id id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_folder_mapping_service_id(daci_handler, account_id, folder_id, count);
+}
+
+sync_agent_da_return_e da_add_item_internal(sync_agent_da_item_s * item, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_item(daci_handler, item, count);
+}
+
+sync_agent_da_return_e sync_agent_add_item_new(sync_agent_da_item_s * item, int count, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_item_new(daci_handler, item, count, item_id);
+}
+
+sync_agent_da_return_e da_delete_item_by_item_id_internal(char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_by_Item_id(daci_handler, item_id);
+}
+
+sync_agent_da_return_e da_delete_item_by_item_type_id_internal(int account_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_by_item_type_id(daci_handler, account_id, item_type_id);
+}
+
+sync_agent_da_return_e da_delete_item_and_changelog_by_item_type_id_internal(int account_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_by_item_type_id_and_delete_changelog(daci_handler, account_id, item_type_id);
+}
+
+char *da_get_item_id_internal(int account_id, char *service_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_id == NULL, NULL, "service id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_item_id(daci_handler, account_id, service_id, item_type_id);
+}
+
+sync_agent_da_item_s *da_get_item_internal(char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, NULL, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item(daci_handler, item_id);
+}
+
+sync_agent_da_id_list_s *da_get_all_item_id_wrapper()
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_all_item_id(daci_handler);
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_internal(char *folder_id, sync_agent_da_column_name_e column_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, NULL, "folder id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_id_list(daci_handler, folder_id, column_name);
+}
+
+sync_agent_da_item_s *da_get_item_by_account_id_internal(int account_id, int item_type_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_by_account_id(daci_handler, account_id, item_type_id, count);
+}
+
+sync_agent_da_item_info_s *da_get_item_info_by_item_type_id_internal(int account_id, int item_type_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_info_by_item_type_id(daci_handler, account_id, item_type_id, count);
+}
+
+sync_agent_da_item_s *da_get_item_mapping_service_id_by_item_id_internal(int account_id, char *item_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, NULL, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_mapping_service_id(daci_handler, account_id, item_id, count);
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_by_data_store_id_internal(int data_store_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_id_list_by_datastore_id(daci_handler, data_store_id);
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_by_data_store_id_with_account_id_internal(int account_id, int data_store_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_id_list_by_datastore_id_with_account_id(daci_handler, account_id, data_store_id);
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id_internal(int account_id, int data_store_id, int operation_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_id_list_by_operation_id(daci_handler, account_id, data_store_id, operation_id);
+}
+
+sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id_and_folder_id_internal(int account_id, char *folder_id, int data_store_id, int operation_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, NULL, "folder id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_id_list_by_operation_id_and_folder_id(daci_handler, account_id, folder_id, data_store_id, operation_id);
+}
+
+int da_is_exist_item_wrapper(char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, 0, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_item(daci_handler, item_id);
+}
+
+//sync_agent_da_return_e sync_agent_add_config(sync_agent_da_config_s *config)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+//      }
+//
+//      return add_config(daci_handler, config);
+//}
+
+//sync_agent_da_return_e sync_agent_delete_config_by_key(int config_id, char *key)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+//      }
+//
+//      return da_delete_config_by_key(daci_handler, config_id, key);
+//}
+
+//sync_agent_da_config_s *sync_agent_get_config_by_config_id(int config_id, int *count)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return NULL;
+//      }
+//
+//      return da_get_config_by_config_id(daci_handler, config_id, count);
+//}
+
+//sync_agent_da_return_e sync_agent_get_config_by_key(sync_agent_da_config_s *config)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+//      }
+//
+//      return da_get_config_by_key(daci_handler, config);
+//}
+
+//int sync_agent_is_exist_config(int config_id, char *key)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+//      }
+//
+//      return da_is_exist_config(daci_handler, config_id, key);
+//}
+
+//sync_agent_da_return_e sync_agent_update_config(sync_agent_da_config_s *config, int count)
+//{
+//      SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+//      if (daci_handler == NULL) {
+//              _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+//              return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+//      }
+//
+//      return da_update_config(daci_handler, config, count);
+//}
+
+sync_agent_da_return_e da_add_item_changelog_wrapper(int account_id, sync_agent_da_item_changelog_s * item_changelog, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_changelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_item_changelog(daci_handler, account_id, item_changelog, count);
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_id_internal(int account_id, char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_changelog_by_item_id(daci_handler, account_id, item_id);
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_id_list_internal(int account_id, char **item_id_list, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id_list == NULL, SYNC_AGENT_DA_ERRORS, "item id list is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_changelog_by_item_id_list(daci_handler, account_id, item_id_list, count);
+}
+
+sync_agent_da_return_e da_delete_item_changelog_by_item_type_id_internal(int account_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_item_changelog_by_item_type_id(daci_handler, account_id, item_type_id);
+}
+
+sync_agent_da_return_e da_set_item_changelog_operation_id_wrapper(int account_id, sync_agent_da_item_changelog_s * item_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_changelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_set_item_changelog_operation_id(daci_handler, account_id, item_changelog);
+}
+
+sync_agent_da_return_e da_set_item_changelog_sync_status_internal(int account_id, sync_agent_da_item_changelog_s * item_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_changelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_set_item_changelog_sync_status(daci_handler, account_id, item_changelog);
+}
+
+sync_agent_da_return_e da_set_item_changelog_wait_status_internal(int account_id, char **folder_id_list, int folder_id_count, int *item_type_id_list, int item_type_id_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_type_id_list == NULL, SYNC_AGENT_DA_ERRORS, "item type id list is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_set_item_changelog_wait_status(daci_handler, account_id, folder_id_list, folder_id_count, item_type_id_list, item_type_id_count);
+
+}
+
+sync_agent_da_return_e sync_agent_get_item_changelog_by_item_id(int account_id, sync_agent_da_item_changelog_s * item_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_changelog == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_changelog_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_changelog_by_item_id(daci_handler, account_id, item_changelog);
+}
+
+int da_is_exist_item_changelog_wrapper(int account_id, char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, 0, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_item_changelog(daci_handler, account_id, item_id);
+}
+
+sync_agent_da_return_e da_add_last_anchor_internal(sync_agent_da_last_anchor_s * last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_last_anchor(daci_handler, last_anchor);
+}
+
+sync_agent_da_return_e DACI_Delete_Last_Anchor_By_Account_Id(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_last_anchor_by_account_id(daci_handler, account_id);
+}
+
+sync_agent_da_return_e DACI_Delete_Last_Anchor_By_Item_Type_Id(int account_id, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_last_anchor_by_item_type_id(daci_handler, account_id, item_type_id);
+}
+
+sync_agent_da_return_e da_set_last_anchor_internal(sync_agent_da_last_anchor_s * last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_set_last_anchor(daci_handler, last_anchor);
+}
+
+sync_agent_da_last_anchor_s *DACI_Get_Last_Anchor_By_Account_Id(int account_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_last_anchor_by_account_id(daci_handler, account_id, count);
+}
+
+sync_agent_da_last_anchor_s *da_get_last_anchor_by_item_type_id_internal(int account_id, int item_type_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_last_anchor_by_item_type_id(daci_handler, account_id, item_type_id, count);
+}
+
+int DACI_IsExist_Last_Anchor(int accountId, int item_type_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_last_anchor(daci_handler, accountId, item_type_id);
+}
+
+sync_agent_da_return_e da_add_mapping_internal(sync_agent_da_mapping_s * mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mapping == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_mapping_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_mapping(daci_handler, mapping);
+}
+
+sync_agent_da_return_e da_delete_mapping_by_account_id_internal(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_mapping_by_account_id(daci_handler, account_id);
+}
+
+sync_agent_da_return_e da_delete_mapping_by_luid_internal(int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(luid == NULL, SYNC_AGENT_DA_ERRORS, "luid is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_mapping_by_luid(daci_handler, account_id, luid);
+}
+
+sync_agent_da_mapping_s *da_get_mapping_by_account_id_internal(int account_id, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_mapping_by_account_id(daci_handler, account_id, count);
+}
+
+char *da_get_mapping_guid_internal(int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(luid == NULL, NULL, "luid is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_mapping_guid(daci_handler, account_id, luid);
+}
+
+int DACI_IsExist_Mapping_By_Luid(int account_id, char *luid)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(luid == NULL, 0, "luid is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_mapping_by_luid(daci_handler, account_id, luid);
+}
+
+sync_agent_da_return_e da_add_id_provider_wrapper(sync_agent_da_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id_provider == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_provider_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_id_provider(daci_handler, id_provider);
+}
+
+sync_agent_da_return_e da_get_id_provider_wrapper(unsigned int id_provider_code, sync_agent_da_id_provider_s ** id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_id_provider(daci_handler, id_provider_code, id_provider);
+}
+
+sync_agent_da_return_e da_update_id_provider_wrapper(sync_agent_da_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id_provider == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_provider_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_update_id_provider(daci_handler, id_provider);
+}
+
+sync_agent_da_return_e da_add_id_page_wrapper(sync_agent_da_id_page_s * id_page, unsigned int page_byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id_page == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_page_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_id_page(daci_handler, id_page, page_byte_size);
+}
+
+sync_agent_da_return_e da_delete_id_page_wrapper(unsigned int id_provider_code, unsigned int page_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_id_page(daci_handler, id_provider_code, page_index);
+}
+
+sync_agent_da_return_e da_get_id_page_wrapper(unsigned int id_provider_code, unsigned int page_index, char **page_bit)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_id_page(daci_handler, id_provider_code, page_index, page_bit);
+}
+
+sync_agent_da_return_e da_get_id_page_index_wrapper(unsigned int id_provider_code, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_id_page_index(daci_handler, id_provider_code, count);
+}
+
+sync_agent_da_return_e da_update_id_page_wrapper(sync_agent_da_id_page_s * id_page, unsigned int page_byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id_page == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_page_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_update_id_page(daci_handler, id_page, page_byte_size);
+}
+
+/*
+ * ==================================
+ * Data connector module internal API
+ * ==================================
+ */
+sync_agent_da_return_e da_add_agent_handler(unsigned int key, SYNC_AGENT_DA_HANDLER * handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(handler == NULL, SYNC_AGENT_DA_ERR_DB_HANDLER_MGR, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       if (agent_db_handler_mgr == NULL || agent_db_handler_mgr->daci_handlerTable_mutex == NULL) {
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       unsigned int *key_copy = (unsigned int *)malloc(sizeof(unsigned int));
+       if (key_copy == NULL)
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+
+       *key_copy = key;
+
+       pthread_mutex_lock(agent_db_handler_mgr->daci_handlerTable_mutex);
+       if (agent_db_handler_mgr->daci_handlerTable == NULL) {
+               ret = __alloc_agent_dc_handler_table();
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto addagentHandler;
+       }
+
+       /* insert to handler */
+       _DEBUG_INFO("[%s] Key  =  %d, Handler  =  %p  !\n", __func__, key, handler);
+       g_hash_table_insert(agent_db_handler_mgr->daci_handlerTable, key_copy, handler);
+
+#ifdef DC_PRINT
+       /* For test log */
+       __print_agentDBHashTableLog();
+#endif
+
+ addagentHandler:
+       pthread_mutex_unlock(agent_db_handler_mgr->daci_handlerTable_mutex);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_remove_agent_handler(unsigned int key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (agent_db_handler_mgr == NULL || agent_db_handler_mgr->daci_handlerTable_mutex == NULL || agent_db_handler_mgr->daci_handlerTable == NULL) {
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       /* remove the handler to hash table */
+       pthread_mutex_lock(agent_db_handler_mgr->daci_handlerTable_mutex);
+       int is_success = g_hash_table_remove(agent_db_handler_mgr->daci_handlerTable, &key);
+       pthread_mutex_unlock(agent_db_handler_mgr->daci_handlerTable_mutex);
+
+#ifdef DC_PRINT
+       /* for test log */
+       __print_agentDBHashTableLog();
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       if (is_success == true)
+               return SYNC_AGENT_DA_SUCCESS;
+
+       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+}
+
+SYNC_AGENT_DA_HANDLER *da_get_agent_handler(unsigned int key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (agent_db_handler_mgr == NULL || agent_db_handler_mgr->daci_handlerTable_mutex == NULL || agent_db_handler_mgr->daci_handlerTable == NULL) {
+               _DEBUG_INFO("[%s] SYNC_AGENT_DA_ERR_DB_HANDLER_MGR !\n", __func__);
+               return NULL;
+       }
+
+       /* get the handler to hash table */
+       pthread_mutex_lock(agent_db_handler_mgr->daci_handlerTable_mutex);
+       SYNC_AGENT_DA_HANDLER *pHandler = g_hash_table_lookup(agent_db_handler_mgr->daci_handlerTable, &key);
+       pthread_mutex_unlock(agent_db_handler_mgr->daci_handlerTable_mutex);
+
+#ifdef DC_PRINT
+       if (pHandler != NULL) {
+               _DEBUG_INFO("[%s] ######### > Value Search Success(key = %d, handler = %p)\n", __func__, key, pHandler);
+       } else {
+               _DEBUG_INFO("[%s] ######### > Value Search Fail(key = %d, handler = %p)\n", __func__, key, pHandler);
+       }
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return pHandler;
+}
+
+/* static function implementation */
+static sync_agent_da_return_e __alloc_agent_dc_handler_table(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (agent_db_handler_mgr != NULL) {
+               agent_db_handler_mgr->daci_handlerTable = g_hash_table_new_full(g_int_hash, g_int_equal, ___destory_agent_db_hashtable_key, ___destroy_agent_db_hashtable_value);
+               if (agent_db_handler_mgr->daci_handlerTable == NULL) {
+                       _DEBUG_VERBOSE("[%s] Not Create agent dc handler hash table \n", __func__);
+                       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+               } else {
+                       _DEBUG_VERBOSE("[%SYNC_AGENT_DA_ERR_DB_HANDLER_MGRent dc handler hash table \n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e __alloc_agent_dc_handler_table_mutex()
+{
+       _INNER_FUNC_ENTER;
+
+       if (agent_db_handler_mgr != NULL) {
+
+               agent_db_handler_mgr->daci_handlerTable_mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+               if (agent_db_handler_mgr->daci_handlerTable_mutex == NULL) {
+                       _DEBUG_VERBOSE("[%s] Not Create agent dc handler hash table mutex \n", __func__);
+                       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+               } else {
+
+                       if (0 != pthread_mutex_init(agent_db_handler_mgr->daci_handlerTable_mutex, 0)) {
+                               _DEBUG_VERBOSE("[%s] Not init agent dc handler hash table mutex\n", __func__);
+                               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+                       }
+                       _DEBUG_VERBOSE("[%s] Init agent dc handler hash table mutex\n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e _free_agent_dc_handler_table(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (agent_db_handler_mgr != NULL && agent_db_handler_mgr->daci_handlerTable != NULL) {
+               g_hash_table_destroy(agent_db_handler_mgr->daci_handlerTable);
+               _DEBUG_TRACE("[%s] daci_handlerTable free success !\n", __func__);
+               agent_db_handler_mgr->daci_handlerTable = 0;;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e _free_agent_dc_handler_table_mutex(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (agent_db_handler_mgr != NULL && agent_db_handler_mgr->daci_handlerTable_mutex != NULL) {
+
+               int ret = pthread_mutex_destroy(agent_db_handler_mgr->daci_handlerTable_mutex);
+               if (ret != 0) {
+                       _DEBUG_TRACE("[%s] daci_handlerTable_mutex free error !\n", __func__);
+                       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+               } else {
+                       free(agent_db_handler_mgr->daci_handlerTable_mutex);
+                       agent_db_handler_mgr->daci_handlerTable_mutex = 0;
+                       _DEBUG_TRACE("[%s] daci_handlerTable_mutex free success !\n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+static sync_agent_da_return_e _create_agent_db_handler_mgr_info(void)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (agent_db_handler_mgr != NULL) {
+
+               /* alloc agent db hander hash table */
+               ret = __alloc_agent_dc_handler_table();
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto allocAgentDBHandlerMgrInfoErr;
+
+               /* alloc agent db hander hash table mutex */
+               ret = __alloc_agent_dc_handler_table_mutex();
+               if (ret != SYNC_AGENT_DA_SUCCESS)
+                       goto allocAgentDBHandlerMgrInfoErr;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+
+ allocAgentDBHandlerMgrInfoErr:
+       da_free_agentdb_handler_mgr();
+       return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+}
+
+static void ___destroy_agent_db_hashtable_value(void *handler)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(handler == NULL, "SYNC_AGENT_DA_HANDLER is NULL !!");
+
+       _DEBUG_VERBOSE("[%s] start \n", __func__);
+       if (handler != NULL) {
+               da_close_Agent((SYNC_AGENT_DA_HANDLER *) handler);
+       }
+       _DEBUG_VERBOSE("[%s] end \n", __func__);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void ___destory_agent_db_hashtable_key(void *key)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(key == NULL, "key is NULL !!");
+
+       _DEBUG_VERBOSE("[%s] start \n", __func__);
+       if (key != NULL)
+               free(key);
+       _DEBUG_VERBOSE("[%s] end \n", __func__);
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/data-adapter/agent_handler_manager_internal.h b/src/framework/data-adapter/agent_handler_manager_internal.h
new file mode 100755 (executable)
index 0000000..f9e2d3c
--- /dev/null
@@ -0,0 +1,679 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AGENT_HANDLER_MANAGER_INTERNAL_H_
+#define AGENT_HANDLER_MANAGER_INTERNAL_H_
+
+#include "data-adapter/common_internal.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "account/manager.h"
+
+/**
+ * @file               agent_handler_manager_internal.h
+ * @brief      Interface list to use framework Common DataBase
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief Alloc the agent db handler manager
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DB_HANDLER_MGR error
+ */
+sync_agent_da_return_e da_alloc_agentdb_handler_mgr(void);
+
+/**
+ * @brief Free the agent db handler manager
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DB_HANDLER_MGR error
+ */
+sync_agent_da_return_e da_free_agentdb_handler_mgr(void);
+
+/**
+ * @brief Delete all accounts data from Email-Service, Contacts-Service database, Calendar-Service database, Agent database
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERRORS error
+ */
+sync_agent_da_return_e da_clear_all_database_account(void);
+
+/**
+ * @brief Delete one account data from Email-Service, Contacts-Service database, Calendar-Service database, Agent database
+ * @param[in] account_id account id of sync-agent-framework
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DELETE_LAST_ACCOUNT success ( delete last account )
+ * @retval SYNC_AGENT_DA_ERRORS error
+ */
+sync_agent_da_return_e da_delete_all_database_account(int account_id);
+
+/**
+ * @brief Create agent database
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_CLOSE_FAILED error
+ */
+sync_agent_da_return_e da_create_agent_default_table_wrapper(void);
+
+/**
+ * @brief Insert account into account_tbl
+ * @param[in]  account account information
+ * @return Operation result
+ * @retval account id (positive number) success
+ * @retval -1 error
+ */
+int da_add_fw_account_id(sync_agent_fw_account_s * account);
+
+/**
+ * @brief Update account data
+ * @param[in]  account account information
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_fw_account_id(sync_agent_fw_account_s * account);
+
+/**
+ * @brief Delete account data from agent database
+ * @param[in]  account_id account id that user want to delete
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_fw_account_id(int account_id);
+
+/**
+ * @brief Get account data from agent database
+ * @param[in] account_id account id of account data that user want to get
+ * @param[in] account as returned by da_get_fw_account_info() - account data
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_fw_account_info(int account_id, sync_agent_fw_account_s ** account);
+
+/**
+ * @brief Get all account data from agent database
+ * @param[in] list as returned by da_get_all_fw_account_info() - list of sync_agent_fw_account_s
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_all_fw_account_info(GList ** list);
+
+/**
+ * @brief Get account data by access name from agent database
+ * @param[in] access_name database access name
+ * @param[in] list as returned by da_get_fw_account_info_by_access_name() - list of sync_agent_fw_account_s
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_fw_account_info_by_access_name(char *access_name, GList ** list);
+
+/**
+ * @brief Checking whether the account id exist in account_tbl
+ * @param[in] account_id account id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 (or error value) not exist
+ */
+int da_is_exist_account_id(int account_id);
+
+/**
+ * @brief Delete folder from folder_tbl by folder id
+ * @param[in]  folder_id folder id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_folder_by_folder_id_wrapper(char *folder_id);
+
+/**
+ * @brief Get folder id from folder_tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  service_id service id
+ * @param[in]  folder_type_id folder type id
+ * @return Operation result
+ * @retval folder id success
+ * @retval NULL error
+ */
+char *da_get_folder_id_by_service_id_wrapper(int account_id, int item_type_id, char *service_id, int folder_type_id);
+
+/**
+ * @brief Get all item id from item_tbl
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_all_item_id_wrapper(void);
+
+/**
+ * @brief Checking whether the item_id exist in item_tbl
+ * @param[in]  item_id item id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0 (or error value) not exist
+ */
+int da_is_exist_item_wrapper(char *item_id);
+
+/**
+ * @brief Insert itemChangelog into account_item_changelog_tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog array of itemChangelog info
+ * @param[in]  count count of itemChangelog info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_item_changelog_wrapper(int account_id, sync_agent_da_item_changelog_s * item_changelog, int count);
+
+/**
+ * @brief Set operation id and syncStatus to account_item_changelog_tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog itemChangelog info (operationId, syncStatus, accessName, itemId)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_item_changelog_operation_id_wrapper(int account_id, sync_agent_da_item_changelog_s * item_changelog);
+
+/**
+ * @brief Checking whether the item id exist in account_item_changelog_tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @return Checking result
+ * @retval 1 exist
+ * @retval 0(or error value) not exist
+ */
+int da_is_exist_item_changelog_wrapper(int account_id, char *item_id);
+
+/**
+ * @brief Insert id_provider into id_provider_tbl
+ * @param[in]  id_provider id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_id_provider_wrapper(sync_agent_da_id_provider_s * id_provider);
+
+/**
+ * @brief Get id_provider from id_provider_tbl
+ * @param[in]  id_provider_code id provider code
+ * @param[in] id_provider as returned by da_get_id_provider_wrapper() - id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_id_provider_wrapper(unsigned int id_provider_code, sync_agent_da_id_provider_s ** id_provider);
+
+/**
+ * @brief Update id provider in id_provider_tbl
+ * @param[in]  id_provider id provider info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_id_provider_wrapper(sync_agent_da_id_provider_s * id_provider);
+
+/**
+ * @brief      Insert id_page into id_page_tbl
+ * @param[in]  id_page id page info
+ * @param[in] page_byte_size page byte size
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_id_page_wrapper(sync_agent_da_id_page_s * id_page, unsigned int page_byte_size);
+
+/**
+ * @brief Delete id_page from id_page_tbl by page index
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  page_index page index
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_id_page_wrapper(unsigned int id_provider_code, unsigned int page_index);
+
+/**
+ * @brief      Get id_page into id_page_tbl
+ * @param[in] id_provider_code id provider code
+ * @param[in]  page_index page index
+ * @param[in]  page_bit as returned by da_get_id_page_wrapper() - page bit
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_get_id_page_wrapper(unsigned int id_provider_code, unsigned int page_index, char **page_bit);
+
+/**
+ * @brief      Get count of page index
+ * @param[in]  id_provider_code id provider code
+ * @param[in]  count as returned by da_get_id_page_index_wrapper() - count of page index
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value      error
+ */
+sync_agent_da_return_e da_get_id_page_index_wrapper(unsigned int id_provider_code, int *count);
+
+/**
+ * @brief      Insert id_page into id_page_tbl
+ * @param[in]  id_page id_page info
+ * @param[in]  page_byte_size page_bit's byte size
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_update_id_page_wrapper(sync_agent_da_id_page_s * id_page, unsigned int page_byte_size);
+
+/**
+ * @brief Add the handler pointer to handler hash table
+ * @param[in]  key     unique key to distinguish handler pointer
+ * @param[in]  handler db handler pointer
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DB_HANDLER_MGR error
+ */
+sync_agent_da_return_e da_add_agent_handler(unsigned int key, SYNC_AGENT_DA_HANDLER * handler);
+
+/**
+ * @brief Add the handler pointer to handler hash table
+ * @param[in]  key unique key to distinguish handler pointer
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DB_HANDLER_MGR error
+ */
+sync_agent_da_return_e da_remove_agent_handler(unsigned int key);
+
+/**
+ * @brief Add the handler pointer to handler hash table
+ * @param[in]  key     unique key to distinguish handler pointer
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval SYNC_AGENT_DA_ERR_DB_HANDLER_MGR error
+ */
+SYNC_AGENT_DA_HANDLER *da_get_agent_handler(unsigned int key);
+
+/**
+ * @brief Get all account_id from account_tbl
+ * @param[in] count as returned by da_get_account_id_list() - count of account id
+ * @return Operation result
+ * @retval array of account id success
+ * @retval NULL error
+ */
+int *da_get_account_id_list(int *count);
+
+/**
+ * @brief      Insert folder into folder_tbl
+ * @param[in]  folder array of folder info
+ * @param[in] count as returned by da_add_folder_internal() - count of folder info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_folder_internal(sync_agent_da_folder_s * folder, int count);
+
+/**
+ * @brief Get folder id from folder_tbl by folder type id
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  folder_type_id folder type id
+ * @return Operation result
+ * @retval folder id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_folder_id_by_folder_type_id_internal(int account_id, int item_type_id, int folder_type_id);
+
+/**
+ * @brief Get all folder_id_list from folder_tbl by data_store_id
+ *                             Get all the folders in account and data store
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval array of folder id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_folder_id_list_by_item_type_id_internal(int account_id, int item_type_id);
+
+/**
+ * @brief Get item from folder_tbl
+ *                             Belonging to different account of folder get folder with the same service_id
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @param[in]  count as returned by da_get_item_mapping_service_id_by_folder_id_internal() - count of item info
+ * @return Operation result
+ * @retval array of folder info success
+ * @retval NULL error
+ */
+sync_agent_da_folder_s *da_get_item_mapping_service_id_by_folder_id_internal(int account_id, char *folder_id, int *count);
+
+/**
+ * @brief      Insert item into item_tbl - currently unused function
+ * @param[in]  item array of item info
+ * @param[in]  count count of item info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_item_internal(sync_agent_da_item_s * item, int count);
+
+/**
+ * @brief      Insert item into item_tbl
+ * @param[in]  item array of item info
+ * @param[in]  count count of item info
+ * @param[in] item_id as returned by sync_agent_add_item_new() - id of newly added item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e sync_agent_add_item_new(sync_agent_da_item_s * item, int count, char **item_id);
+
+/**
+ * @brief Delete item from item_tbl by item id
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_by_item_id_internal(char *item_id);
+
+/**
+ * @brief Delete item from item_tbl by account id and item type id
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_by_item_type_id_internal(int account_id, int item_type_id);
+
+/**
+ * @brief Delete item from item_tbl by account id and item type id and row that checked delete from changelog tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_and_changelog_by_item_type_id_internal(int account_id, int item_type_id);
+
+/**
+ * @brief Get item id from item_tbl
+ * @param[in]  account_id account id
+ * @param[in]  service_id service id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval item id success
+ * @retval NULL error
+ */
+char *da_get_item_id_internal(int account_id, char *service_id, int item_type_id);
+
+/**
+ * @brief Get item information from item_tbl
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval item info success
+ * @retval NULL error
+ */
+sync_agent_da_item_s *da_get_item_internal(char *item_id);
+
+/**
+ * @brief Get all id in folder from item_tbl
+ * @param[in]  folder_id folder id
+ * @param[in]  column_name column name (COLUMN_NAME_ITEM_ID or COLUMN_NAME_SERVICE_ID)
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_internal(char *folder_id, sync_agent_da_column_name_e column_name);
+
+/**
+ * @brief Get item from item_tbl by account id
+ *                             Get all the items in account
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  count as returned by da_get_item_by_account_id_internal() - count of item info
+ * @return Operation result
+ * @retval array of item info success
+ * @retval NULL error
+ */
+sync_agent_da_item_s *da_get_item_by_account_id_internal(int account_id, int item_type_id, int *count);
+
+/**
+ * @brief Get item data from item_tbl and account_item_changelog_tbl
+ *                             Among the items that belong to the itemTypeId, Search for item info belong to the changelog
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  count as returned by da_get_item_info_by_item_type_id_internal() - count of item data
+ * @return Operation result
+ * @retval array of item data success
+ * @retval NULL error
+ */
+sync_agent_da_item_info_s *da_get_item_info_by_item_type_id_internal(int account_id, int item_type_id, int *count);
+
+/**
+ * @brief Get item from item_tbl
+ *                             Belonging to different account of item get item with the same service_id
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @param[in]  count as returned by da_get_item_mapping_service_id_by_item_id_internal() - count of item info
+ * @return Operation result
+ * @retval array of item info success
+ * @retval NULL error
+ */
+sync_agent_da_item_s *da_get_item_mapping_service_id_by_item_id_internal(int account_id, char *item_id, int *count);
+
+/**
+ * @brief Get all id from item_tbl
+ * @param[in]  data_store_id data store id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_by_data_store_id_internal(int data_store_id);
+
+/**
+ * @brief Get item id list
+ * @param[in]  account_id sync-agent-framework account id
+ * @param[in]  data_store_id data store id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error or not exist
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_by_data_store_id_with_account_id_internal(int account_id, int data_store_id);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id
+ * @param[in]  account_id account id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id_internal(int account_id, int data_store_id, int operation_id);
+
+/**
+ * @brief Get item id list from item_tbl and account_item_changelog_tbl
+ *                             Among the items that belong to the data_store_id, Search for item info belong to the changelog by operation_id and folder_id
+ * @param[in]  account_id account id
+ * @param[in]  folder_id folder id
+ * @param[in]  data_store_id data store id
+ * @param[in]  operation_id operation id
+ * @return Operation result
+ * @retval array of item id success
+ * @retval NULL error
+ */
+sync_agent_da_id_list_s *da_get_item_id_list_by_operation_id_and_folder_id_internal(int account_id, char *folder_id, int data_store_id, int operation_id);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item id
+ * @param[in]  account_id account id
+ * @param[in]  item_id item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_changelog_by_item_id_internal(int account_id, char *item_id);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item id list
+ * @param[in]  account_id account id
+ * @param[in]  item_id_list array of item id
+ * @param[in]  count count of item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_changelog_by_item_id_list_internal(int account_id, char **item_id_list, int count);
+
+/**
+ * @brief Delete itemChangelog from account_item_changelog_tbl by item type id
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_item_changelog_by_item_type_id_internal(int account_id, int item_type_id);
+
+/**
+ * @brief Set syncStatus to account_item_changelog_tbl
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog itemChangelog info (syncStatus, accessName, itemId)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_item_changelog_sync_status_internal(int account_id, sync_agent_da_item_changelog_s * item_changelog);
+
+/**
+ * @brief Set SYNC_WAIT to account_item_changelog_tbl
+ *                             Among the items that match to the itemTypeId and belong to the folder
+ *                             If it existed in account_item_changelog_tbl, set SYNC_WAIT to account_item_changelog_tbl
+ * @param[in]  account_id account id
+ * @param[in]  folder_id_list array of folder id
+ * @param[in]  folder_id_count count of folder id
+ * @param[in]  item_type_id_list array of item type id
+ * @param[in]  item_type_id_count count of item type id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_item_changelog_wait_status_internal(int account_id, char **folder_id_list, int folder_id_count, int *item_type_id_list, int item_type_id_count);
+
+/**
+ * @brief Get itemChangelog info from account_item_changelog_tbl by item id
+ * @remarks Item id that is included in sync_agent_da_item_changelog_s must be set by user when call this function
+ * @param[in]  account_id account id
+ * @param[in]  item_changelog as returned by sync_agent_get_item_changelog_by_item_id() - itemChangelog info (itemId, operationId, syncStatus, accessName)
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e sync_agent_get_item_changelog_by_item_id(int account_id, sync_agent_da_item_changelog_s * item_changelog);
+
+/**
+ * @brief      Insert anchor into last_anchor_tbl
+ * @param[in]  last_anchor last anchor info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_last_anchor_internal(sync_agent_da_last_anchor_s * last_anchor);
+
+/**
+ * @brief Set last_anchor_server and last_anchor_client to last_anchor_tbl
+ * @param[in]  last_anchor last anchor info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_set_last_anchor_internal(sync_agent_da_last_anchor_s * last_anchor);
+
+/**
+ * @brief Get last_anchor_server and last_anchor_client from last_anchor_tbl by item type id
+ * @param[in]  account_id account id
+ * @param[in]  item_type_id item type id
+ * @param[in]  count as returned by da_get_last_anchor_by_item_type_id_internal() - count of lastAnchor info
+ * @return Operation result
+ * @retval lastAnchor info success
+ * @retval NULL error
+ */
+sync_agent_da_last_anchor_s *da_get_last_anchor_by_item_type_id_internal(int account_id, int item_type_id, int *count);
+
+/**
+ * @brief      Insert mapping into mapping_tbl
+ * @param[in]  mapping mapping info
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_mapping_internal(sync_agent_da_mapping_s * mapping);
+
+/**
+ * @brief      Delete mapping from mapping_tbl by account id
+ * @param[in]  account_id account id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_mapping_by_account_id_internal(int account_id);
+
+/**
+ * @brief Delete mapping from mapping_tbl by luid
+ * @param[in]  account_id account id
+ * @param[in]  luid luid
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_mapping_by_luid_internal(int account_id, char *luid);
+
+/**
+ * @brief Get all mapping info from mapping_tbl by account id
+ *                             Get all the mapping info in account
+ * @param[in]  account_id account id
+ * @param[in]  count as returned by da_get_mapping_by_account_id_internal() - count of mapping info
+ * @return Operation result
+ * @retval array of mapping info success
+ * @retval NULL error
+ */
+sync_agent_da_mapping_s *da_get_mapping_by_account_id_internal(int account_id, int *count);
+
+/**
+ * @brief Get luid from mapping_tbl by guid
+ * @param[in]  account_id account id
+ * @param[in] luid luid
+ * @return Operation result
+ * @retval guid guid
+ * @retval NULL error
+ */
+char *da_get_mapping_guid_internal(int account_id, char *luid);
+
+/**
+ *     @}
+ */
+
+#endif                         /* AGENT_HANDLER_MANAGER_INTERNAL_H_ */
diff --git a/src/framework/data-adapter/agent_manager.c b/src/framework/data-adapter/agent_manager.c
new file mode 100755 (executable)
index 0000000..6c4ac22
--- /dev/null
@@ -0,0 +1,653 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vconf.h>
+
+#include "initialization/parser.h"
+
+#include "utility/fw_alloc.h"
+#include "utility/sync_util.h"
+#include "utility/fw_file.h"
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/account_plugin.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#include "data-adapter/changelog.h"
+#include "data-adapter/luid.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "data-adapter/agent_manager.h"
+#include "data-adapter/agent_manager_internal.h"
+
+#include "data-adapter/interface_service_item.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+/*
+ * Key         : db/Apps/AgentFramework/[Agent Name]/ServiceChangePoint/[FW AccountID]/[Service_Type]
+ * Value               : Change Point (TimeStamp)
+ */
+#define VCONF_KEY_SERIVCE_CHANGEPOINT  ".%s_service_change_point_%d_%d"
+
+static void _set_serivce_change_point(int fw_account_id, int service_type, int change_point);
+
+static int _get_serivce_change_point(int fw_account_id, int service_type);
+
+static sync_agent_da_return_e _construct_change_log_tbl_from_service(int fw_account_id, int service_type);
+
+EXPORT_API sync_agent_da_return_e sync_agent_construct_item_tbl_from_service(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+       sync_agent_da_return_e err_code = SYNC_AGENT_DA_SUCCESS;
+       err_code = _construct_change_log_tbl_from_service(fw_account_id, service_type);
+       _EXTERN_FUNC_EXIT;
+       return err_code;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_construct_folder_tbl_from_service(int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int fw_account_cnt = 0;
+       int *fw_account_id_list = da_get_account_id_list(&fw_account_cnt);
+
+       if (fw_account_id_list == NULL || fw_account_cnt == 0) {
+               if (fw_account_id_list != NULL) {
+                       free(fw_account_id_list);
+                       fw_account_id_list = NULL;
+               }
+               return SYNC_AGENT_DA_SUCCESS;
+       }
+
+       int *service_account_id_list = 0;
+       if (fw_account_cnt != 0) {
+               service_account_id_list = (int *)calloc(fw_account_cnt, sizeof(int));
+               if (service_account_id_list == NULL) {
+                       if (fw_account_id_list != NULL) {
+                               free(fw_account_id_list);
+                               fw_account_id_list = NULL;
+                       }
+                       return SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               }
+
+               int i = 0;
+               for (; i < fw_account_cnt; i++) {
+                       service_account_id_list[i] = acc_get_service_account_id(service_type, fw_account_id_list[i]);
+                       _DEBUG_INFO("service_account_id_list[%d] : %d", i, service_account_id_list[i]);
+               }
+       }
+
+       int service_account_id_cnt = fw_account_cnt;
+       _DEBUG_INFO("service_account_id_cnt : %d", service_account_id_cnt);
+
+       int i = 0;
+       for (; i < service_account_id_cnt; i++) {
+               int fw_account_id = acc_get_fw_account_id(service_type, service_account_id_list[i], 0);
+               _DEBUG_INFO("fw_account_id[%d] : %d", i, fw_account_id);
+
+               plugin_get_folder_id_list_cb func_get_folder_id_list = plugin_get_function_get_folder_id_list(service_type);
+               if (func_get_folder_id_list == NULL) {
+                       _DEBUG_ERROR("func_get_folder_id_list is NULL !!");
+                       if (fw_account_id_list != NULL) {
+                               free(fw_account_id_list);
+                       }
+//                      if (service_account_id_list != NULL) {
+                       free(service_account_id_list);
+//                      }
+                       return SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               }
+
+               int service_folder_cnt = 0;
+               int *service_folder_type_list = 0;
+               char **service_folder_list = func_get_folder_id_list(service_account_id_list[i], &service_folder_cnt, &service_folder_type_list);
+               if (service_folder_list == NULL) {
+                       _DEBUG_ERROR("service folder list is NULL !!");
+                       if (fw_account_id_list != NULL) {
+                               free(fw_account_id_list);
+                               fw_account_id_list = NULL;
+                       }
+//                      if (service_account_id_list != NULL) {
+                       free(service_account_id_list);
+//                      }
+                       return SYNC_AGENT_DA_ERRORS;
+               }
+
+               _DEBUG_INFO("service_folder_cnt  : %d", service_folder_cnt);
+
+/*
+                //Hard Coding - If account has one folder, consider folder' state complete.
+
+               t_sync_agent_da_id_list_s_t *foder_id_list_info = T_DACI_Get_Folder_Folder_Id_List_By_Account_Id(fw_account_id);
+
+               if (foder_id_list_info != NULL) {
+                       if (foder_id_list_info->count > 0) {
+                               _DEBUG_INFO("foder_id_list_info->count  : %d", foder_id_list_info->count);
+                               return SYNC_AGENT_DA_SUCCESS;
+                       }
+               }*/
+
+               int i = 0;
+               for (; i < service_folder_cnt; i++) {
+
+                       /* checking whether the service_id exist in Folder table */
+                       char *temp_folder_id = da_get_folder_id_by_service_id_wrapper(fw_account_id, service_type, service_folder_list[i], service_folder_type_list[i]);
+
+                       _DEBUG_INFO("fw_account_id  : %d", fw_account_id);
+                       _DEBUG_INFO("service_folder_list[i]  : %s", service_folder_list[i]);
+                       _DEBUG_INFO("service_folder_type_list[i]  : %d", service_folder_type_list[i]);
+                       _DEBUG_INFO("temp_folder_id  : %s", temp_folder_id);
+                       if (temp_folder_id != NULL) {
+                               free(temp_folder_id);
+                       } else {
+                               /* Add Agent Folder table */
+                               sync_agent_da_folder_s folder;
+                               folder.account_id = fw_account_id;
+                               folder.folder_id = sync_agent_generate_folder_luid();
+                               folder.parent_folder_id = "0";
+                               folder.data_store_id = service_type;
+                               folder.folder_type_id = service_folder_type_list[i];
+                               folder.service_id = service_folder_list[i];
+                               folder.access_name = "DACI";
+
+                               da_add_folder_internal(&folder, 1);
+                       }
+               }
+       }
+
+       if (fw_account_id_list != NULL) {
+               free(fw_account_id_list);
+               fw_account_id_list = NULL;
+       }
+       if (service_account_id_list != NULL) {
+               free(service_account_id_list);
+               service_account_id_list = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_refresh_item_tbl_from_service(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /*
+        * todo Delete folder table
+        */
+
+       /*
+        * Delete Changelog table
+        */
+       da_delete_item_changelog_by_item_type_id_internal(fw_account_id, service_type);
+
+       /*
+        * Delete item table
+        */
+       da_delete_item_by_item_type_id_internal(fw_account_id, service_type);
+
+       /*
+        *      todo Insert folder table
+        */
+
+       /*
+        * insert item table
+        */
+       plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
+       plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_chaned_item_for_folder_update(service_type);
+
+       int service_account_id = acc_get_service_account_id(service_type, fw_account_id);
+       _DEBUG_INFO("service_account_id : %d", service_account_id);
+
+       sync_agent_da_id_list_s *fw_folder_id_list_info = da_get_folder_id_list_by_item_type_id_internal(fw_account_id, service_type);
+
+       retvm_if(fw_folder_id_list_info == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_list_s is NULL !!");
+
+       char **fw_folder_id_list = 0;
+       int fw_folder_id_cnt = 0;
+       if (fw_folder_id_list_info != NULL) {
+               fw_folder_id_list = fw_folder_id_list_info->id;
+               fw_folder_id_cnt = fw_folder_id_list_info->count;
+
+               _DEBUG_INFO("fw_folder_id_cnt : %d", fw_folder_id_cnt);
+               _DEBUG_INFO("fw_folder_id_list[0] : %s", fw_folder_id_list_info->id[0]);
+               _DEBUG_INFO("fw_folder_id_list[0] : %s", fw_folder_id_list[0]);
+       }
+
+       int i = 0;
+       for (; i < fw_folder_id_cnt; i++) {
+               _DEBUG_INFO("fw_folder_id_list[%d] : %s", i, fw_folder_id_list[i]);
+
+               char *service_folder_id = sync_agent_get_service_folder_id(fw_folder_id_list[i]);
+
+               _DEBUG_INFO("service_folder_id : %s", service_folder_id);
+
+               int added_item_cnt = 0;
+               sync_agent_plugin_item_node_s *added_service_item_id_list = func_get_changed_item_for_folder_add(service_account_id, service_folder_id, 0, &added_item_cnt);
+               sync_agent_plugin_item_node_s *cursor_ptr = added_service_item_id_list;
+
+               _DEBUG_INFO("added_item_cnt : %d", added_item_cnt);
+
+               /*
+                * Process Add Item
+                */
+               sync_agent_begin_transaction();
+               char **fw_item_id_list = sync_agent_generate_item_luid(1, added_item_cnt);
+               if (fw_item_id_list != NULL) {
+                       int y = 0;
+                       for (; y < added_item_cnt; y++) {
+                               sync_agent_da_item_s item;
+                               item.account_id = fw_account_id;
+                               item.item_id = fw_item_id_list[y];
+                               item.folder_id = fw_folder_id_list[i];
+                               item.data_store_id = service_type;
+                               item.service_id = cursor_ptr->item_id;
+                               item.access_name = "DACI";
+
+                               sync_agent_da_return_e ret = da_add_item_internal(&item, 1);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("add item failed return : %d", ret);
+                               }
+
+                               sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                               cursor_ptr = cursor_ptr->next;
+                               free(temp->item_id);
+                               free(temp);
+
+                               if (fw_item_id_list[y] != NULL) {
+                                       free(fw_item_id_list[y]);
+                               }
+                       }
+                       free(fw_item_id_list);
+               }
+               sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+
+               /*
+                * Process Update Item
+                */
+               int updated_item_cnt = 0;
+               sync_agent_plugin_item_node_s *updated_service_item_id_list = func_get_changed_item_for_folder_update(service_account_id, service_folder_id, 0, &updated_item_cnt);
+               cursor_ptr = updated_service_item_id_list;
+
+               _DEBUG_INFO("updated_item_cnt : %d", updated_item_cnt);
+
+               sync_agent_begin_transaction();
+               fw_item_id_list = sync_agent_generate_item_luid(1, updated_item_cnt);
+               if (fw_item_id_list != NULL) {
+                       int y = 0;
+                       for (; y < updated_item_cnt; y++) {
+                               sync_agent_da_item_s item;
+                               item.account_id = fw_account_id;
+                               item.item_id = fw_item_id_list[y];
+                               item.folder_id = fw_folder_id_list[i];
+                               item.data_store_id = service_type;
+                               item.service_id = cursor_ptr->item_id;
+                               item.access_name = "DACI";
+
+                               sync_agent_da_return_e ret = da_add_item_internal(&item, 1);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("add item failed return : %d", ret);
+                               }
+
+                               sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                               cursor_ptr = cursor_ptr->next;
+                               free(temp->item_id);
+                               free(temp);
+
+                               if (fw_item_id_list[y] != NULL) {
+                                       free(fw_item_id_list[y]);
+                               }
+                       }
+                       free(fw_item_id_list);
+               }
+               sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+
+               if (fw_folder_id_list[i] != NULL) {
+                       free(fw_folder_id_list[i]);
+               }
+
+               if (service_folder_id != NULL) {
+                       free(service_folder_id);
+               }
+       }
+
+       if (fw_folder_id_list_info != NULL) {
+               if (fw_folder_id_list_info->id != NULL) {
+                       free(fw_folder_id_list_info->id);
+               }
+               free(fw_folder_id_list_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_da_return_e da_refresh_changelog_tbl_from_service(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /*
+        * Delete Changelog table
+        */
+       ret = da_delete_item_changelog_by_item_type_id_internal(fw_account_id, service_type);
+
+       /*
+        * Delete item table
+        */
+       ret = da_delete_item_by_item_type_id_internal(fw_account_id, service_type);
+
+       /*
+        * Construct Item & changelog table
+        */
+       plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
+
+       int service_account_id = acc_get_service_account_id(service_type, fw_account_id);
+       _DEBUG_INFO("service_account_id : %d", service_account_id);
+
+       sync_agent_da_id_list_s *fw_folder_id_list_info = da_get_folder_id_list_by_item_type_id_internal(fw_account_id, service_type);
+
+       retvm_if(fw_folder_id_list_info == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_list_s is NULL !!");
+
+       char **fw_folder_id_list = 0;
+       int fw_folder_id_cnt = 0;
+       if (fw_folder_id_list_info != NULL) {
+               fw_folder_id_list = fw_folder_id_list_info->id;
+               fw_folder_id_cnt = fw_folder_id_list_info->count;
+
+               _DEBUG_INFO("[RJW] fw_folder_id_cnt : %d", fw_folder_id_cnt);
+               _DEBUG_INFO("[RJW] fw_folder_id_list[0] : %s", fw_folder_id_list_info->id[0]);
+               _DEBUG_INFO("[RJW] fw_folder_id_list[0] : %s", fw_folder_id_list[0]);
+       }
+
+       int i = 0;
+       for (; i < fw_folder_id_cnt; i++) {
+               _DEBUG_INFO("fw_folder_id_list[%d] : %s", i, fw_folder_id_list[i]);
+
+               char *service_folder_id = sync_agent_get_service_folder_id(fw_folder_id_list[i]);
+
+               _DEBUG_INFO("service_folder_id : %s", service_folder_id);
+
+               int item_cnt = 0;
+               sync_agent_plugin_item_node_s *service_item_id_list = func_get_changed_item_for_folder_add(service_account_id, service_folder_id, 0, &item_cnt);
+               sync_agent_plugin_item_node_s *cursor_ptr = service_item_id_list;
+
+               _DEBUG_INFO("item_cnt : %d", item_cnt);
+
+               sync_agent_begin_transaction();
+               char **fw_item_id_list = sync_agent_generate_item_luid(1, item_cnt);
+               if (fw_item_id_list != NULL) {
+                       int k = 0;
+                       for (; k < item_cnt; k++) {
+                               char *service_item_id = cursor_ptr->item_id;
+                               _DEBUG_INFO("service_item_id[%d] : %s", k, service_item_id);
+                               _DEBUG_INFO("fw_item_id : %s", fw_item_id_list[k]);
+
+                               da_changelog_add_item_internal(fw_account_id, fw_item_id_list[k], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+
+                               sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                               cursor_ptr = cursor_ptr->next;
+                               free(temp->item_id);
+                               free(temp);
+                               if (fw_item_id_list[k] != NULL) {
+                                       free(fw_item_id_list[k]);
+                               }
+                       }
+                       free(fw_item_id_list);
+               }
+               sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       }
+
+       if (fw_folder_id_list_info != NULL) {
+               if (fw_folder_id_list_info->id != NULL) {
+                       free(fw_folder_id_list_info->id);
+               }
+               free(fw_folder_id_list_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_set_service_change_point(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_last_change_point_cb func_get_last_changepoint = plugin_get_function_get_last_change_point(service_type);
+
+       int new_last_change_point = func_get_last_changepoint();
+
+       _DEBUG_INFO("new_last_change_point : %d", new_last_change_point);
+
+       _set_serivce_change_point(fw_account_id, service_type, new_last_change_point);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+/********************************************* static function ****************************/
+
+static void _set_serivce_change_point(int fw_account_id, int service_type, int change_point)
+{
+       _INNER_FUNC_ENTER;
+
+       const char *agent_key = init_get_agent_key();
+
+       char vconf_key[100];
+       snprintf(vconf_key, sizeof(vconf_key), VCONF_KEY_SERIVCE_CHANGEPOINT, agent_key, fw_account_id, service_type);
+
+       _DEBUG_TRACE("vConfKey : %s", vconf_key);
+
+       if (!sync_agent_set_int_into_file(vconf_key, change_point)) {
+               _DEBUG_ERROR("vconf_set_id FAIL");
+       } else {
+               _DEBUG_TRACE("Sucess Vconf Set Id");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _get_serivce_change_point(int fw_account_id, int service_type)
+{
+       _INNER_FUNC_ENTER;
+
+       const char *agent_key = init_get_agent_key();
+
+       char vconf_key[100];
+       snprintf(vconf_key, sizeof(vconf_key), VCONF_KEY_SERIVCE_CHANGEPOINT, agent_key, fw_account_id, service_type);
+
+       int change_point = 0;
+       if (!sync_agent_get_int_from_file(vconf_key, &change_point)) {
+               _DEBUG_TRACE("vconf_set_id FAIL - First attempt??");
+               return 0;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return change_point;
+}
+
+sync_agent_da_return_e _construct_change_log_tbl_from_service(int fw_account_id, int service_type)
+{
+       _INNER_FUNC_ENTER;
+
+       int service_account_id = acc_get_service_account_id(service_type, fw_account_id);
+       _DEBUG_TRACE("service_account_id : %d", service_account_id);
+
+       int changed_flag = 0;
+       int fw_change_point = _get_serivce_change_point(fw_account_id, service_type);
+       _DEBUG_TRACE("fw_last_change_point : %d", fw_change_point);
+
+       plugin_get_changed_item_for_folder_add_cb func_get_changed_item_for_folder_add = plugin_get_function_get_chaned_item_for_folder_add(service_type);
+       plugin_get_changed_item_for_folder_delete_cb func_get_changed_item_for_folder_del = plugin_get_function_get_chaned_item_for_folder_delete(service_type);
+       plugin_get_changed_item_for_folder_update_cb func_get_changed_item_for_folder_update = plugin_get_function_get_chaned_item_for_folder_update(service_type);
+
+       /*
+        * todo Get fw_folder_id list in the service
+        */
+       sync_agent_da_id_list_s *fw_folder_id_list_info = da_get_folder_id_list_by_item_type_id_internal(fw_account_id, service_type);
+
+       retvm_if(fw_folder_id_list_info == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_id_list_s is NULL !!");
+
+       char **fw_folder_id_list = 0;
+       int fw_folder_id_cnt = 0;
+       if (fw_folder_id_list_info != NULL) {
+               fw_folder_id_list = fw_folder_id_list_info->id;
+               fw_folder_id_cnt = fw_folder_id_list_info->count;
+
+               _DEBUG_TRACE("fw_folder_id_cnt : %d", fw_folder_id_cnt);
+               _DEBUG_TRACE("fw_folder_id_list[0] : %s", fw_folder_id_list_info->id[0]);
+               _DEBUG_TRACE("fw_folder_id_list[0] : %s", fw_folder_id_list[0]);
+       }
+
+       int i = 0;
+       for (; i < fw_folder_id_cnt; i++) {
+               _DEBUG_TRACE("fw_folder_id_list[%d] : %s", i, fw_folder_id_list[i]);
+
+               char *service_folder_id = sync_agent_get_service_folder_id(fw_folder_id_list[i]);
+               _DEBUG_TRACE("service_folder_id : %s", service_folder_id);
+
+               /*
+                * 1. Process Add Item
+                */
+               int added_item_cnt = 0;
+               sync_agent_plugin_item_node_s *added_service_item_id_list = func_get_changed_item_for_folder_add(service_account_id, service_folder_id, fw_change_point, &added_item_cnt);
+               sync_agent_plugin_item_node_s *cursor_ptr = added_service_item_id_list;
+
+               _DEBUG_TRACE("added_item_cnt : %d", added_item_cnt);
+               if (added_item_cnt > 0) {
+                       changed_flag = 1;
+               }
+
+               char **fw_item_id_list = sync_agent_generate_item_luid(1, added_item_cnt);
+               int y = 0;
+               if (fw_item_id_list != NULL) {
+                       for (; y < added_item_cnt; y++) {
+                               da_changelog_add_item_internal(fw_account_id, fw_item_id_list[y], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+                               sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                               cursor_ptr = cursor_ptr->next;
+                               free(temp->item_id);
+                               free(temp);
+                               if (fw_item_id_list[y] != NULL) {
+                                       free(fw_item_id_list[y]);
+                               }
+                       }
+
+                       free(fw_item_id_list);
+               }
+
+               /*
+                * 2. Process Delete Item
+                */
+               int deleted_item_cnt = 0;
+               sync_agent_plugin_item_node_s *deleted_service_item_id_list = func_get_changed_item_for_folder_del(service_account_id, service_folder_id, fw_change_point, &deleted_item_cnt);
+               cursor_ptr = deleted_service_item_id_list;
+
+               _DEBUG_TRACE("deleted_item_cnt : %d", deleted_item_cnt);
+               if (deleted_item_cnt > 0) {
+                       changed_flag = 1;
+               }
+
+               y = 0;
+               for (; y < deleted_item_cnt; y++) {
+                       char *fw_item_id = da_get_item_id_internal(fw_account_id, cursor_ptr->item_id, service_type);
+                       sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                       cursor_ptr = cursor_ptr->next;
+                       free(temp->item_id);
+                       free(temp);
+
+                       da_changelog_delete_item_internal(fw_account_id, fw_item_id, service_type);
+
+                       free(fw_item_id);
+               }
+
+               /*
+                * 3. Process Update Item
+                */
+               int updated_item_cnt = 0;
+               sync_agent_plugin_item_node_s *updated_service_item_id_list = func_get_changed_item_for_folder_update(service_account_id, service_folder_id, fw_change_point, &updated_item_cnt);
+               cursor_ptr = updated_service_item_id_list;
+
+               _DEBUG_TRACE("updated_item_cnt : %d", updated_item_cnt);
+               if (updated_item_cnt > 0) {
+                       changed_flag = 1;
+               }
+
+               fw_item_id_list = sync_agent_generate_item_luid(1, updated_item_cnt);
+               if (fw_item_id_list != NULL) {
+                       y = 0;
+                       for (; y < updated_item_cnt; y++) {
+                               char *fw_item_id = da_get_item_id_internal(fw_account_id, cursor_ptr->item_id, service_type);
+
+                               if (fw_item_id == NULL) {
+                                       da_changelog_add_item_internal(fw_account_id, fw_item_id_list[y], cursor_ptr->item_id, service_type, fw_folder_id_list[i]);
+                               } else {
+                                       da_changelog_update_item_internal(fw_account_id, fw_item_id, service_type);
+                               }
+
+                               sync_agent_plugin_item_node_s *temp = cursor_ptr;
+                               cursor_ptr = cursor_ptr->next;
+
+                               free(temp->item_id);
+                               free(temp);
+
+                               if (fw_item_id_list[y] != NULL) {
+                                       free(fw_item_id_list[y]);
+                               }
+
+                               if (fw_item_id != NULL) {
+                                       free(fw_item_id);
+                               }
+                       }
+
+                       free(fw_item_id_list);
+               }
+
+               if (fw_folder_id_list[i] != NULL)
+                       free(fw_folder_id_list[i]);
+
+               if (service_folder_id != NULL)
+                       free(service_folder_id);
+       }
+
+       if (fw_folder_id_list_info != NULL) {
+               if (fw_folder_id_list_info->id != NULL) {
+                       free(fw_folder_id_list_info->id);
+               }
+               free(fw_folder_id_list_info);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
diff --git a/src/framework/data-adapter/agent_manager_internal.h b/src/framework/data-adapter/agent_manager_internal.h
new file mode 100755 (executable)
index 0000000..114b61c
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AGENT_MANAGER_INTERNAL_H_
+#define AGENT_MANAGER_INTERNAL_H_
+
+#include "data-adapter/agent_manager.h"
+
+/**
+ * @file               agent_manager_internal.h
+ * @brief      Support to sync sync-agent-framework item, folder change log table with service storage
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Refresh sync-agent-framework item, changeLog table from Service storage
+ * @remarks    Delete all sync-agent-framework item, change log table and construct item, change log table from item in current Service storage.
+ * @param[in]  fw_account_id   sync-agent-framework account id
+ * @param[in]  service_type    service type - service data connector plugin's id described in sync-agent-framework config file
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_refresh_changelog_tbl_from_service(int fw_account_id, int service_type);
+
+/**
+ *     @}
+ */
+
+#endif                         /* AGENT_MANAGER_INTERNAL_H_ */
diff --git a/src/framework/data-adapter/changelog.c b/src/framework/data-adapter/changelog.c
new file mode 100755 (executable)
index 0000000..52494e0
--- /dev/null
@@ -0,0 +1,954 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <pthread.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_alloc.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/common.h"
+#include "data-adapter/luid.h"
+
+#include "data-adapter/changelog.h"
+#include "data-adapter/changelog_internal.h"
+
+#include "data-adapter/interface_changelog.h"
+#include "data-adapter/agent.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+static pthread_mutex_t change_lock;
+
+int da_handle_add_item(int service_account_id, int index, char *service_item_id, int item_type, char *service_folder_id, int folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_item_id == NULL, 0, "service item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType, folderType
+        * 3. get fw id : accountID, folderID
+        * 4. check whether the item is included
+        * 5. generate item luid
+        * 6. add item & change log
+        */
+       if (pthread_mutex_lock(&change_lock)) {
+               _DEBUG_INFO("pthread_mutex_lock error\n");
+               return 0;
+       }
+
+       _DEBUG_INFO("Index : %d", index);
+       _DEBUG_INFO("service_accountID : %d", service_account_id);
+       _DEBUG_INFO("service_itemID : %s", service_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+       _DEBUG_INFO("service_folderID : %s", service_folder_id);
+       _DEBUG_INFO("folderType : %d", folder_type);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_return_e open_ret = SYNC_AGENT_DA_SUCCESS;
+       char *fw_folder_id = NULL;
+       char *fw_item_id = NULL;
+       char **fw_item_id_list = NULL;
+       sync_agent_da_item_s item;
+       sync_agent_da_item_changelog_s item_changelog;
+
+       open_ret = sync_agent_open_agent();
+       _DEBUG_INFO("Done Open Agent DB : %d", open_ret);
+
+       /*open test */
+       sync_agent_da_return_e daci_res = sync_agent_begin_transaction();
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_begin_transaction fail");
+       }
+
+       /*
+        * if folderID value is NULL ==> folderID set NULL
+        */
+       if ((service_folder_id != NULL) && !strcmp(service_folder_id, ""))
+               service_folder_id = NULL;
+
+       /*
+        * get fw account id
+        */
+       int fw_account_id = acc_get_fw_account_id(item_type, service_account_id, index);
+       _DEBUG_INFO("fw_account_id : %d", fw_account_id);
+
+       if (fw_account_id == -1) {
+               _DEBUG_ERROR("fw account id does not exist");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * get fw folder id
+        */
+       fw_folder_id = da_get_folder_id_by_service_id_wrapper(fw_account_id, item_type, service_folder_id, folder_type);
+       if (fw_folder_id == NULL) {
+               _DEBUG_ERROR("fw folder id does not exist");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the item is included
+        */
+       fw_item_id = da_get_item_id_internal(fw_account_id, service_item_id, item_type);
+       if (fw_item_id != NULL) {
+               _DEBUG_ERROR("service_item_id already exists : %s", service_item_id);
+               goto DACI_FINISH;
+       }
+
+       /*
+        * generate item luid
+        */
+       fw_item_id_list = sync_agent_generate_item_luid(1, 1);
+       if (fw_item_id_list == NULL) {
+               _DEBUG_ERROR("Failed to Generate Item LUID");
+               goto DACI_FINISH;
+       }
+
+       fw_item_id = fw_item_id_list[0];
+       if (fw_item_id == NULL) {
+               _DEBUG_ERROR("Failed to Generate Item LUID");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * add item
+        */
+       item.account_id = fw_account_id;
+       item.item_id = fw_item_id;
+       item.folder_id = fw_folder_id;
+       item.data_store_id = item_type;
+       item.service_id = service_item_id;
+       item.access_name = "DACI_ChangeLog";
+
+       ret = da_add_item_internal(&item, 1);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("Failed to Add Item : %d", ret);
+               goto DACI_FINISH;
+       }
+
+       /*
+        * add change log
+        */
+       item_changelog.item_id = fw_item_id;
+       item_changelog.operation_id = 301;
+       item_changelog.status = "SYNC_REQUIRED";
+       item_changelog.access_name = "DACI_ChangeLog";
+
+       ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("Failed to Add Item changelog : %d", ret);
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+       /*open test */
+       daci_res = sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_end_transaction fail");
+       }
+
+       open_ret = sync_agent_close_agent();
+       _DEBUG_INFO("Done Close Agent DB : %d", open_ret);
+
+       if (fw_folder_id != NULL) {
+               free(fw_folder_id);
+               fw_folder_id = NULL;
+       }
+       if (fw_item_id != NULL) {
+               free(fw_item_id);
+               fw_item_id = NULL;
+       }
+       if (fw_item_id_list != NULL) {
+               free(fw_item_id_list);
+               fw_item_id_list = NULL;
+       }
+       if (pthread_mutex_unlock(&change_lock)) {
+               _DEBUG_ERROR("pthread_mutex_unlock error\n");
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_handle_del_item(int service_account_id, int index, char *service_item_id, int item_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_item_id == NULL, 0, "service item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. get fw id : accountID
+        * 4. check whether the item is included
+        * 5. check whether the change log is included
+        * 6. add/update/delete item change log
+        */
+       _DEBUG_INFO("service_accountID : %d", service_account_id);
+       _DEBUG_INFO("index : %d", index);
+       _DEBUG_INFO("service_itemID : %s", service_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_return_e open_ret = SYNC_AGENT_DA_SUCCESS;
+
+       char *fw_item_id = NULL;
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       open_ret = sync_agent_open_agent();
+       _DEBUG_INFO("Done Open Agent DB : %d", open_ret);
+
+       /*open test */
+       sync_agent_da_return_e daci_res = sync_agent_begin_transaction();
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_begin_transaction fail");
+       }
+
+       /*
+        * get fw account id
+        */
+       int fw_account_id = acc_get_fw_account_id(item_type, service_account_id, index);
+       if (fw_account_id == -1) {
+               _DEBUG_ERROR("fw account id does not exist");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the item is included
+        */
+       fw_item_id = da_get_item_id_internal(fw_account_id, service_item_id, item_type);
+       if (fw_item_id != NULL) {
+               _DEBUG_INFO("Item Already Exists : %s", fw_item_id);
+       } else {
+               _DEBUG_ERROR("Item is not existed!!");
+               goto DACI_FINISH;
+       }
+
+       /* check whether the change log is included */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               switch (item_changelog.operation_id) {
+               case 301:       /* ADD */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : ADD Operation");
+                               ret = da_delete_item_by_item_id_internal(fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+
+                               ret = da_delete_item_changelog_by_item_id_internal(fw_account_id, fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item Change Log : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 302:       /* UPDATE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : UPDATE Operation");
+                               item_changelog.operation_id = 303;
+                               ret = da_set_item_changelog_operation_id_wrapper(fw_account_id, &item_changelog);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 303:       /* DELETE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : DELETE Operation");
+                       }
+                       break;
+               }
+
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 303;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("Failed to Add Item Change Log : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       /*open test */
+       daci_res = sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_end_transaction fail");
+       }
+       open_ret = sync_agent_close_agent();
+       _DEBUG_INFO("Done Close Agent DB : %d", open_ret);
+
+       if (fw_item_id != NULL) {
+               free(fw_item_id);
+               fw_item_id = NULL;
+       }
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_handle_update_item(int service_account_id, int index, char *service_item_id, int item_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_item_id == NULL, 0, "service item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. get fw id : accountID
+        * 4. check whether the item is included
+        * 5. check whether the change log is included
+        * 6. add item change log
+        */
+
+       _DEBUG_INFO("service_accountID : %d", service_account_id);
+       _DEBUG_INFO("service_itemID : %s", service_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_return_e open_ret = SYNC_AGENT_DA_SUCCESS;
+
+       char *fw_item_id = NULL;
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       open_ret = sync_agent_open_agent();
+       _DEBUG_INFO("Done Open Agent DB : %d", open_ret);
+
+       /*open test */
+       sync_agent_da_return_e daci_res = sync_agent_begin_transaction();
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_begin_transaction fail");
+       }
+
+       /*
+        * get fw account id
+        */
+       int fw_account_id = acc_get_fw_account_id(item_type, service_account_id, index);
+       if (fw_account_id == -1) {
+               _DEBUG_ERROR("fw account id does not exist");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the item is included
+        */
+       fw_item_id = da_get_item_id_internal(fw_account_id, service_item_id, item_type);
+       if (fw_item_id != NULL) {
+               _DEBUG_INFO("Item Already Exists : %s", fw_item_id);
+       } else {
+               _DEBUG_ERROR("Item is Not Existed!!");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the change log is included
+        */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               if (item_changelog.operation_id == 303) {       /* DELETE */
+                       _DEBUG_ERROR("Already Deleted Item : %s", fw_item_id);
+                       goto DACI_FINISH;
+               }
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 302;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("Failed to Add Item Change Log : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       /*open test */
+       daci_res = sync_agent_end_transaction(SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       if (daci_res != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_end_transaction fail");
+       }
+       open_ret = sync_agent_close_agent();
+       _DEBUG_INFO("Done Close Agent DB : %d", open_ret);
+
+       if (fw_item_id != NULL) {
+               free(fw_item_id);
+               fw_item_id = NULL;
+       }
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_changelog_add_item_internal(int fw_account_id, char *fw_item_id, char *service_item_id, int item_type, char *fw_folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(fw_item_id == NULL, 0, "fw item id is NULL !!");
+       retvm_if(service_item_id == NULL, 0, "service item id is NULL !!");
+       retvm_if(fw_folder_id == NULL, 0, "fw folder id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. check whether the item is included
+        * 4. generate item luid
+        * 5. add item & change log
+        */
+       _DEBUG_INFO("fw_account_id : %d", fw_account_id);
+       _DEBUG_INFO("fw_item_id : %s", fw_item_id);
+       _DEBUG_INFO("service_item_id : %s", service_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+       _DEBUG_INFO("fw_folder_id : %s", fw_folder_id);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       sync_agent_da_item_s item;
+       sync_agent_da_item_changelog_s item_changelog;
+
+       /*
+        * check whether the item is included
+        */
+
+       /*
+          char *item_id = sync_agent_get_item_id(fw_account_id, service_item_id, itemType);
+          if (item_id != NULL) {
+          _DEBUG_ERROR("Item already exists : %s", item_id);
+          goto DACI_FINISH;
+          }
+        */
+
+       /*
+        * add item
+        */
+       item.account_id = fw_account_id;
+       item.item_id = fw_item_id;
+       item.folder_id = fw_folder_id;
+       item.data_store_id = item_type;
+       item.service_id = service_item_id;
+       item.access_name = "DACI_ChangeLog";
+
+       ret = da_add_item_internal(&item, 1);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("add item failed return : %d", ret);
+               goto DACI_FINISH;
+       }
+
+       /*
+        * add change log
+        */
+       item_changelog.item_id = fw_item_id;
+       item_changelog.operation_id = 301;
+       item_changelog.status = "SYNC_REQUIRED";
+       item_changelog.access_name = "DACI_ChangeLog";
+
+       ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("add item changelog failed return : %d", ret);
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+       /*
+          if (item_id != NULL) {
+          free(item_id);
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_changelog_add_item_new(sync_agent_da_item_s * sync_agent_item, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. check whether the item is included
+        * 4. generate item luid
+        * 5. add item & change log
+        */
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_item_changelog_s item_changelog;
+
+       /*
+        * check whether the item is included
+        */
+
+       /*
+          char *item_id = sync_agent_get_item_id(fw_account_id, service_item_id, itemType);
+          if (item_id != NULL) {
+          _DEBUG_ERROR("Item already exists : %s", item_id);
+          goto DACI_FINISH;
+          }
+        */
+
+       /*
+        * add item
+        */
+       ret = sync_agent_add_item_new(sync_agent_item, 1, item_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("add item failed return : %d", ret);
+               goto DACI_FINISH;
+       }
+
+       /*
+        * add change log
+        */
+       item_changelog.item_id = *item_id;
+       item_changelog.operation_id = 301;
+       item_changelog.status = "SYNC_REQUIRED";
+       item_changelog.access_name = "DACI_ChangeLog";
+
+       ret = da_add_item_changelog_wrapper(sync_agent_item->account_id, &item_changelog, 1);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("add item changelog failed return : %d", ret);
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+       /*
+          if (item_id != NULL) {
+          free(item_id);
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_changelog_delete_item_internal(int fw_account_id, char *fw_item_id, int item_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(fw_item_id == NULL, 0, "fw item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. check whether the item is included
+        * 3. check whether the change log is included
+        * 4. add/update/delete item change log
+        */
+       _DEBUG_INFO("fw_account_id : %d", fw_account_id);
+       _DEBUG_INFO("fw_item_id : %s", fw_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       /*
+        * check whether the item is included
+        */
+       ret = da_is_exist_item_wrapper(fw_item_id);
+       if (ret == 1) {
+               _DEBUG_INFO("Item already exists : %s", fw_item_id);
+       } else {
+               _DEBUG_ERROR("Item is not existed!!");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the change log is included
+        */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               switch (item_changelog.operation_id) {
+               case 301:       /* ADD */
+                       {
+                               _DEBUG_INFO("Item changelog already exists : ADD Operation");
+                               ret = da_delete_item_by_item_id_internal(fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+
+                               ret = da_delete_item_changelog_by_item_id_internal(fw_account_id, fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item Change Log : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 302:       /* UPDATE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : UPDATE Operation");
+                               item_changelog.operation_id = 303;
+                               ret = da_set_item_changelog_operation_id_wrapper(fw_account_id, &item_changelog);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Set Item ChangeLog Operation : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 303:       /* DELETE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : DELETE Operation");
+                       }
+                       break;
+               }
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 303;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("[da_changelog_delete_item_internal] add item change log failed return : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_changelog_delete_item_new(int fw_account_id, char *fw_item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(fw_item_id == NULL, SYNC_AGENT_DA_ERRORS, "fw item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. check whether the item is included
+        * 3. check whether the change log is included
+        * 4. add/update/delete item change log
+        */
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       /*
+        * check whether the item is included
+        */
+       ret = da_is_exist_item_wrapper(fw_item_id);
+       if (ret == 1) {
+               _DEBUG_INFO("Item already exists : %s", fw_item_id);
+//              ret = sync_agent_delete_item_by_item_id(fw_item_id);
+//              if (ret != SYNC_AGENT_DA_SUCCESS) {
+//                      _DEBUG_ERROR("sync_agent_delete_item() failed !! : %d", ret);
+//                      goto DACI_FINISH;
+//              } else {
+//                      _DEBUG_INFO("sync_agent_delete_item() success !!");
+//              }
+       } else {
+               _DEBUG_ERROR("Item is not existed!!");
+               goto DACI_FINISH;
+       }
+
+       /*
+        * check whether the change log is included
+        */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               switch (item_changelog.operation_id) {
+               case 301:       /* ADD */
+                       {
+                               _DEBUG_INFO("Item changelog already exists : ADD Operation");
+                               ret = da_delete_item_by_item_id_internal(fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+
+                               ret = da_delete_item_changelog_by_item_id_internal(fw_account_id, fw_item_id);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Delete Item Change Log : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 302:       /* UPDATE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : UPDATE Operation");
+                               item_changelog.operation_id = 303;
+                               ret = da_set_item_changelog_operation_id_wrapper(fw_account_id, &item_changelog);
+                               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to Set Item ChangeLog Operation : %d", ret);
+                                       goto DACI_FINISH;
+                               }
+                       }
+                       break;
+               case 303:       /* DELETE */
+                       {
+                               _DEBUG_INFO("Item Changelog Already Exists : DELETE Operation");
+                       }
+                       break;
+               }
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 303;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("[da_changelog_delete_item_internal] add item change log failed return : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_changelog_update_item_internal(int fw_account_id, char *fw_item_id, int item_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(fw_item_id == NULL, 0, "fw item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. check whether the item is included
+        * 4. check whether the change log is included
+        * 5. add item change log
+        */
+
+       _DEBUG_INFO("fw_account_id : %d", fw_account_id);
+       _DEBUG_INFO("fw_item_id : %s", fw_item_id);
+       _DEBUG_INFO("itemType : %d", item_type);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       /*
+        * check whether the item is included
+        */
+       ret = da_is_exist_item_wrapper(fw_item_id);
+       if (ret == 1) {
+               _DEBUG_INFO("Item already exists : %s", fw_item_id);
+       } else {
+               _DEBUG_ERROR("Item is not existed!!");
+               goto DACI_FINISH;
+       }
+
+       /* check whether the change log is included */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               if (item_changelog.operation_id == 303) {       /* DELETE */
+                       _DEBUG_ERROR("already deleted item");
+                       goto DACI_FINISH;
+               }
+
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 302;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("Failed to Add Item Change Log : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_changelog_update_item_new(int fw_account_id, char *fw_item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(fw_item_id == NULL, SYNC_AGENT_DA_ERRORS, "fw item id is NULL !!");
+
+       /*
+        * TODO : 1. Need to Null check parameter
+        * 2. converting type : itemType
+        * 3. check whether the item is included
+        * 4. check whether the change log is included
+        * 5. add item change log
+        */
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       sync_agent_da_item_changelog_s item_changelog;
+       item_changelog.status = NULL;
+       item_changelog.access_name = NULL;
+
+       /*
+        * check whether the item is included
+        */
+       ret = da_is_exist_item_wrapper(fw_item_id);
+       if (ret == 1) {
+               _DEBUG_INFO("Item already exists : %s", fw_item_id);
+       } else {
+               _DEBUG_ERROR("Item is not existed!!");
+               goto DACI_FINISH;
+       }
+
+       /* check whether the change log is included */
+       if (da_is_exist_item_changelog_wrapper(fw_account_id, fw_item_id)) {
+               item_changelog.item_id = fw_item_id;
+               sync_agent_get_item_changelog_by_item_id(fw_account_id, &item_changelog);
+
+               if (item_changelog.operation_id == 303) {       /* DELETE */
+                       _DEBUG_ERROR("already deleted item");
+                       goto DACI_FINISH;
+               }
+
+       } else {
+               /*
+                * add change log
+                */
+               item_changelog.item_id = fw_item_id;
+               item_changelog.operation_id = 302;
+               item_changelog.status = strdup("SYNC_REQUIRED");
+               item_changelog.access_name = strdup("DACI_ChangeLog");
+
+               ret = da_add_item_changelog_wrapper(fw_account_id, &item_changelog, 1);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("Failed to Add Item Change Log : %d", ret);
+                       goto DACI_FINISH;
+               }
+       }
+
+ DACI_FINISH:
+       if (item_changelog.status != NULL) {
+               free(item_changelog.status);
+               item_changelog.status = NULL;
+       }
+       if (item_changelog.access_name != NULL) {
+               free(item_changelog.access_name);
+               item_changelog.access_name = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
diff --git a/src/framework/data-adapter/changelog.h b/src/framework/data-adapter/changelog.h
new file mode 100755 (executable)
index 0000000..154b2b6
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CHANGELOG_H_
+#define CHANGELOG_H_
+
+#include "error.h"
+#include "common.h"
+#include "common_internal.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               changelog.h
+ * @brief      Support to process changed service item, effect to F/W item, change log table.
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Handling added item to service storage, update sync-agent-framework item & change log table - currently unused function
+ * @remarks This function is called force by Agent to set item & change log table manually
+ * @param[in]  fw_account_id sync-agent-framework account id
+ * @param[in]  fw_item_id sync-agent-framework item id
+ * @param[in]  service_item_id service item id
+ * @param[in]  item_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  fw_folder_id sync-agent-framework folder id
+ * @return 1 on success, otherwise a negative error value
+ */
+       int da_changelog_add_item_internal(int fw_account_id, char *fw_item_id, char *service_item_id, int item_type, char *fw_folder_id);
+
+/**
+ * @brief      Handling added item to service storage, update sync-agent-framework item & change log table
+ * @remarks This function is called force by Agent to set item & change log table manually
+ * @param[in] sync_agent_item item info
+ * @param[in] item_id as returned by sync_agent_changelog_add_item_new() - id of newly added item
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+       sync_agent_da_return_e sync_agent_changelog_add_item_new(sync_agent_da_item_s * sync_agent_item, char **item_id);
+
+/**
+ * @brief      Handling deleted item from service storage, update sync-agent-framework item & change log table - currently unused function
+ * @param[in]  fw_account_id sync-agent-framework account id
+ * @param[in]  fw_item_id sync-agent-framework item id
+ * @param[in]  item_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @return 1 on success, otherwise a negative error value.
+ */
+       int da_changelog_delete_item_internal(int fw_account_id, char *fw_item_id, int item_type);
+
+/**
+ * @brief      Handling deleted item from service storage, update sync-agent-framework item & change log table
+ * @param[in]  fw_account_id sync-agent-framework account id
+ * @param[in]  fw_item_id sync-agent-framework item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+       sync_agent_da_return_e sync_agent_changelog_delete_item_new(int fw_account_id, char *fw_item_id);
+
+/**
+ * @brief      Handling updated item from service storage, update sync-agent-framework item & change log table - currently unused function
+ * @param[in]  fw_account_id sync-agent-framework account id
+ * @param[in]  fw_item_id sync-agent-framework item id
+ * @param[in]  item_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @return     1 on success, otherwise a negative error value.
+ */
+       int da_changelog_update_item_internal(int fw_account_id, char *fw_item_id, int item_type);
+
+/**
+ * @brief      Handling updated item from service storage, update sync-agent-framework item & change log table
+ * @param[in]  fw_account_id sync-agent-framework account id
+ * @param[in]  fw_item_id sync-agent-framework item id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+       sync_agent_da_return_e sync_agent_changelog_update_item_new(int fw_account_id, char *fw_item_id);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* CHANGELOG_H_ */
diff --git a/src/framework/data-adapter/changelog_internal.h b/src/framework/data-adapter/changelog_internal.h
new file mode 100755 (executable)
index 0000000..c5dfd58
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CHANGELOG_INTERNAL_H_
+#define CHANGELOG_INTERNAL_H_
+
+/**
+ * @file               changelog_internal.h
+ * @brief      Support to process changed service item, effect to F/W item, change log table.
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief      Handling added item to service storage, update sync-agent-framework item & change log table
+ * @remarks    This function is called when the new item is added to the service storage. data connector plugin developer use this function.
+ * @param[in]  service_account_id service account id
+ * @param[in]  index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account.
+ * @param[in]  service_item_id added service item id
+ * @param[in]  item_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  service_folder_id service folder id
+ * @param[in]  folder_type folder type defined in data connector plugin
+ * @return 1 on success, otherwise a negative error value.
+ * @see sync_agent_changelog_add_item()
+ */
+int da_handle_add_item(int service_account_id, int index, char *service_item_id, int item_type, char *service_folder_id, int folder_type);
+
+/**
+ * @brief      Handling deleted item from service storage, update sync-agent-framework item & change log table
+ * @remarks    This function is called when the item is deleted from the service storage. data connector plugin developer use this function.
+ * @param[in]  service_account_id service account id
+ * @param[in]  index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
+ * @param[in]  service_item_id added service item id
+ * @param[in]  item_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @return 1 on success, otherwise a negative error value.
+ * @see sync_agent_changelog_delete_item()
+ */
+int da_handle_del_item(int service_account_id, int index, char *service_item_id, int item_type);
+
+/**
+ * @brief      Handling updated item from service storage, update sync-agent-framework item & change log table
+ * @remarks    This function is called when the item is updated from the service storage. data connector plugin developer use this function.
+ * @param[in]  service_account_id service account id
+ * @param[in]  index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
+ * @param[in]  service_item_id added service item id
+ * @param[in]  item_type service type - service data connector pluIn's ID described in F/W config file
+ * @return 1 on success, otherwise a negative error value.
+ * @see sync_agent_changelog_update_item()
+ */
+int da_handle_update_item(int service_account_id, int index, char *service_item_id, int item_type);
+
+/**
+ *     @}
+ */
+
+#endif                         /* CHANGELOG_INTERNAL_H_ */
diff --git a/src/framework/data-adapter/common.c b/src/framework/data-adapter/common.c
new file mode 100755 (executable)
index 0000000..f7e303b
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "data-adapter/common.h"
+#include "data-adapter/common_internal.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+/*
+ * ==========================================================
+ * Structure Memory Free
+ * ==========================================================
+ */
+void sync_agent_free_memory_folder(sync_agent_da_folder_s * folder, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(folder == NULL, "sync_agent_da_folder_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(folder[i].folder_id);
+               SYNC_AGENT_DA_MEMORY_FREE(folder[i].parent_folder_id);
+               SYNC_AGENT_DA_MEMORY_FREE(folder[i].service_id);
+               SYNC_AGENT_DA_MEMORY_FREE(folder[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(folder);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void sync_agent_free_memory_item(sync_agent_da_item_s * item, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(item == NULL, "sync_agent_da_item_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(item[i].item_id);
+               SYNC_AGENT_DA_MEMORY_FREE(item[i].folder_id);
+               SYNC_AGENT_DA_MEMORY_FREE(item[i].service_id);
+               SYNC_AGENT_DA_MEMORY_FREE(item[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(item);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void da_free_memory_config(sync_agent_da_config_s * config, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(config == NULL, "sync_agent_da_config_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(config[i].key);
+               SYNC_AGENT_DA_MEMORY_FREE(config[i].value);
+               SYNC_AGENT_DA_MEMORY_FREE(config[i].type);
+               SYNC_AGENT_DA_MEMORY_FREE(config[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(config);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void da_free_memory_item_changelog(sync_agent_da_item_changelog_s * item_changelog, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(item_changelog == NULL, "sync_agent_da_item_changelog_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].item_id);
+               SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].status);
+               SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(item_changelog);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_memory_last_anchor(sync_agent_da_last_anchor_s * last_anchor, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(last_anchor == NULL, "sync_agent_da_last_anchor_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].last_anchor_server);
+               SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].last_anchor_client);
+               SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(last_anchor);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_memory_mapping(sync_agent_da_mapping_s * mapping, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(mapping == NULL, "sync_agent_da_mapping_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(mapping[i].luid);
+               SYNC_AGENT_DA_MEMORY_FREE(mapping[i].guid);
+               SYNC_AGENT_DA_MEMORY_FREE(mapping[i].access_name);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(mapping);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_memory_item_info(sync_agent_da_item_info_s * item_info, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(item_info == NULL, "sync_agent_da_item_info_s is NULL !!");
+
+       int i;
+       for (i = 0; i < count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(item_info[i].itemId);
+               SYNC_AGENT_DA_MEMORY_FREE(item_info[i].serviceId);
+               SYNC_AGENT_DA_MEMORY_FREE(item_info[i].syncStatus);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(item_info);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_memory_id_list(sync_agent_da_id_list_s * id_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(id_list == NULL, "sync_agent_da_id_list_s is NULL !!");
+
+       int i;
+       for (i = 0; i < id_list->count; i++) {
+               SYNC_AGENT_DA_MEMORY_FREE(id_list->id[i]);
+       }
+       SYNC_AGENT_DA_MEMORY_FREE(id_list->id);
+       SYNC_AGENT_DA_MEMORY_FREE(id_list);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/data-adapter/common_internal.h b/src/framework/data-adapter/common_internal.h
new file mode 100755 (executable)
index 0000000..673541b
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_ADAPTER_COMMON_INTERNAL_H_
+#define DATA_ADAPTER_COMMON_INTERNAL_H_
+
+#include "data-adapter/common.h"
+
+#include "interface_service_item.h"
+#include "interface_changelog.h"
+#include "interface_item.h"
+#include "interface_config.h"
+#include "interface_folder.h"
+#include "interface_last_anchor.h"
+#include "interface_mapping.h"
+
+/**
+ * @file               common_internal.h
+ * @brief      Common factor of Framework common database
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief Free memory sync_agent_da_folder_s structure
+ * @param[in]  folder sync_agent_da_folder_s structure
+ * @param[in]  count count of sync_agent_da_folder_s
+ */
+void sync_agent_free_memory_folder(sync_agent_da_folder_s * folder, int count);
+
+/**
+ * @brief Free memory sync_agent_da_item_s structure
+ * @param[in]  item sync_agent_da_item_s structure
+ * @param[in]  count count of sync_agent_da_item_s
+ */
+void sync_agent_free_memory_item(sync_agent_da_item_s * item, int count);
+
+/**
+ * @brief Free memory sync_agent_da_last_anchor_s structure
+ * @param[in]  last_anchor sync_agent_da_last_anchor_s structure
+ * @param[in]  count count of sync_agent_da_last_anchor_s
+ */
+void sync_agent_free_memory_last_anchor(sync_agent_da_last_anchor_s * last_anchor, int count);
+
+/**
+ * @brief Free memory sync_agent_da_mapping_s structure
+ * @param[in]  mapping sync_agent_da_mapping_s structure
+ * @param[in]  count count of countsync_agent_da_mapping_s
+ */
+void sync_agent_free_memory_mapping(sync_agent_da_mapping_s * mapping, int count);
+
+/**
+ * @brief Free memory sync_agent_da_item_info_s structure
+ * @param[in]  item_info sync_agent_da_item_info_s structure
+ * @param[in]  count count of sync_agent_da_item_info_s
+ */
+void sync_agent_free_memory_item_info(sync_agent_da_item_info_s * item_info, int count);
+
+/**
+ * @brief Free memory sync_agent_da_id_list_s structure
+ * @param[in]  id_list sync_agent_da_id_list_s structure
+ */
+void sync_agent_free_memory_id_list(sync_agent_da_id_list_s * id_list);
+
+/**
+ * @brief Free memory sync_agent_da_config_s structure
+ * @param[in]  config sync_agent_da_config_s structure
+ * @param[in]  count count of sync_agent_da_config_s
+ */
+void da_free_memory_config(sync_agent_da_config_s * config, int count);
+
+/**
+ * @brief Free memory sync_agent_da_item_changelog_s structure
+ * @param[in]  item_changelog sync_agent_da_item_changelog_s structure
+ * @param[in]  count count of sync_agent_da_item_changelog_s
+ */
+void da_free_memory_item_changelog(sync_agent_da_item_changelog_s * item_changelog, int count);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DATA_ADAPTER_COMMON_INTERNAL_H_ */
diff --git a/src/framework/data-adapter/converter.c b/src/framework/data-adapter/converter.c
new file mode 100755 (executable)
index 0000000..c2b1cd1
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include "plugin/data_connector_plugin.h"
+#include "plugin/data_converter_plugin.h"
+
+#include "utility/sync_util.h"
+
+#include "data-adapter/converter.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+EXPORT_API void *sync_agent_alloc_obj(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_alloc_object_cb func_alloc_object;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       func_alloc_object = plugin_get_function_alloc_object(converter_plugIn_id);
+       if (func_alloc_object == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return NULL;
+       }
+
+       void *result = func_alloc_object();
+       if (result == NULL) {
+               _DEBUG_ERROR("Fail!");
+               ret = SYNC_AGENT_DA_ERR_OPEN_FAILED;
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_obj(int content_type, void *in_object)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(in_object == NULL, SYNC_AGENT_DA_ERRORS, "in_object is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_free_object_cb Func_Free_Object;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       Func_Free_Object = plugin_get_function_free_object(converter_plugIn_id);
+       if (Func_Free_Object == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _DEBUG_INFO("mid");
+       int err = Func_Free_Object(in_object);
+       if (err != 1) {
+               _DEBUG_ERROR("Fail!");
+               ret = SYNC_AGENT_DA_ERRORS;
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API void *sync_agent_set_value_to_obj(int content_type, void *in_object, int key, char *extension_key, void *set_value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(in_object == NULL, NULL, "in_object is NULL !!");
+       retvm_if(set_value == NULL, NULL, "set_value is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_set_value_cb func_set_value_to_object;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       func_set_value_to_object = plugin_get_function_set_value_to_object(converter_plugIn_id);
+       if (func_set_value_to_object == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return NULL;
+       }
+
+       void *result = func_set_value_to_object(in_object, key, extension_key, set_value);
+       if (result == NULL) {
+               _DEBUG_ERROR("Fail!");
+               ret = SYNC_AGENT_DA_ERRORS;
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API void *sync_agent_get_value_to_obj(int content_type, void *in_object, int key, char *extension_key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(in_object == NULL, NULL, "in_object is NULL !!");
+
+       plugin_get_value_cb func_get_value_to_object;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       func_get_value_to_object = plugin_get_function_get_value_to_object(converter_plugIn_id);
+       if (func_get_value_to_object == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return NULL;
+       }
+
+       void *result = func_get_value_to_object(in_object, key, extension_key);
+       if (result == NULL) {
+               _DEBUG_INFO("there are no value!");
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_plugin_object_info_s *sync_agent_get_obj_info(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_get_obj_info_cb func_get_obj_info;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       func_get_obj_info = plugin_get_function_get_obj_info(converter_plugIn_id);
+       if (func_get_obj_info == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return NULL;
+       }
+
+       sync_agent_plugin_object_info_s *result = func_get_obj_info();
+       if (result == NULL) {
+               _DEBUG_ERROR("Fail!");
+               ret = SYNC_AGENT_DA_ERRORS;
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_obj_info(int content_type, sync_agent_plugin_object_info_s * obj_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(obj_info == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_plugin_object_info_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_free_obj_info_cb func_free_obj_info;
+
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(content_type);
+       func_free_obj_info = plugin_get_function_free_obj_info(converter_plugIn_id);
+       if (func_free_obj_info == NULL) {
+               _DEBUG_ERROR("Plug-in function pointer is NULL !!!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       int err = func_free_obj_info(obj_info);
+       if (err != 1) {
+               _DEBUG_ERROR("Fail!");
+               ret = SYNC_AGENT_DA_ERRORS;
+       } else {
+               _DEBUG_INFO("Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
diff --git a/src/framework/data-adapter/interface_changelog.c b/src/framework/data-adapter/interface_changelog.c
new file mode 100755 (executable)
index 0000000..0f4ac91
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <pthread.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/changelog.h"
+#include "data-adapter/interface_changelog.h"
+#include "data-adapter/agent.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_changelog(sync_agent_da_item_changelog_s ** sync_agent_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_changelog = (sync_agent_da_item_changelog_s *) calloc(1, sizeof(sync_agent_da_item_changelog_s));
+       if (*sync_agent_changelog == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_update_changelog(int account_id, sync_agent_da_update_changelog_query_s * query)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_update_changelog_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_SYNC_STATUS:
+               retvm_if(query->update_item == NULL, SYNC_AGENT_DA_ERRORS, "update item is NULL !!");
+
+               ret = da_set_item_changelog_sync_status_internal(account_id, query->update_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_set_item_changelog_sync_status_internal() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_UPDATE_CHANGELOG_OPTION_WAIT_STATUS:
+//              if (query->folder_id_list == NULL || query->item_type_id_list == NULL) {
+//                      _DEBUG_ERROR("folder id list or item type id list is NULL !!");
+//                      return ret;
+//              }
+               ret = da_set_item_changelog_wait_status_internal(account_id, query->folder_id_list, query->folder_id_count, query->item_type_id_list, query->item_type_id_count);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_set_item_changelog_wait_status_internal() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_changelog(int account_id, sync_agent_da_delete_changelog_query_s * query)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_delete_changelog_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+//      if (query == NULL)
+//              return ret;
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_ID:
+               retvm_if(query->item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+               ret = da_delete_item_changelog_by_item_id_internal(account_id, query->item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_item_changelog_by_item_id_internal() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_TYPE_ID:
+               ret = da_delete_item_changelog_by_item_type_id_internal(account_id, query->item_type_id);
+
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_item_changelog_by_item_type_id_internal() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_DELETE_CHANGELOG_OPTION_ITEM_ID_LIST:
+               retvm_if(query->item_id_list == NULL, SYNC_AGENT_DA_ERRORS, "item id list is NULL !!");
+
+               ret = da_delete_item_changelog_by_item_id_list_internal(account_id, query->item_id_list, query->count);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_item_changelog_by_item_id_list_internal() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_changelog(int account_id, char *item_id, sync_agent_da_item_changelog_s ** sync_agent_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id list is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       ret = da_get_item_changelog_by_item_id_new(daci_handler, account_id, item_id, sync_agent_changelog);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_get_item_changelog_by_item_id_new() failed !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_changelog_list(sync_agent_da_get_changelog_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_changelog_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_CHANGELOG_LIST_OPTION_ITEM_TYPE_ID:
+               ret = da_get_item_changelog_by_item_type_id(daci_handler, query->account_id, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_changelog_by_item_type_id() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_changelog(sync_agent_da_item_changelog_s * sync_agent_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_changelog != NULL) {
+               if (sync_agent_changelog->item_id != NULL)
+                       free(sync_agent_changelog->item_id);
+
+               if (sync_agent_changelog->status != NULL)
+                       free(sync_agent_changelog->status);
+
+               if (sync_agent_changelog->access_name != NULL)
+                       free(sync_agent_changelog->access_name);
+
+               free(sync_agent_changelog);
+       } else {
+               _DEBUG_ERROR("sync_agent_changelog is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_changelog_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               sync_agent_da_item_changelog_s *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (sync_agent_da_item_changelog_s *) (iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_changelog(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_changelog() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_ERROR("list is NULL !!");
+               return ret;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
diff --git a/src/framework/data-adapter/interface_config.c b/src/framework/data-adapter/interface_config.c
new file mode 100755 (executable)
index 0000000..201a0da
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/interface_config.h"
+#include "data-adapter/common.h"
+#include "data-adapter/agent.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_config(sync_agent_da_config_s ** config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e err = SYNC_AGENT_DA_SUCCESS;
+
+       sync_agent_da_config_s *temp_config = (sync_agent_da_config_s *) calloc(1, sizeof(sync_agent_da_config_s));
+       if (temp_config == NULL) {
+               _DEBUG_ERROR("sync_agent_da_config_s is null!!");
+               *config = NULL;
+               err = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               return err;
+       }
+
+       *config = temp_config;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_config(sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(config == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_config_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_config(daci_handler, config);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_config_list(GList * config_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(config_list == NULL, SYNC_AGENT_DA_ERRORS, "config_list is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_config_list(daci_handler, config_list);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_update_config(sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(config == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_config_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_update_config(daci_handler, config);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_config(int account_id, char *key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_delete_config_by_key(daci_handler, account_id, key);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_is_exist_config(int account_id, char *key, int *exist)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       return da_is_exist_config(daci_handler, account_id, key, exist);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_config(int account_id, char *key, sync_agent_da_config_s ** config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(key == NULL, SYNC_AGENT_DA_ERRORS, "key is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_config_by_key(daci_handler, account_id, key, config);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_config_list(int account_id, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_config_by_account_id(daci_handler, account_id, list);
+}
+
+EXPORT_API void sync_agent_free_config(sync_agent_da_config_s * config)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (config != NULL) {
+               if (config->key != NULL)
+                       free(config->key);
+
+               if (config->value != NULL)
+                       free(config->value);
+
+               if (config->type != NULL)
+                       free(config->type);
+
+               if (config->access_name != NULL)
+                       free(config->access_name);
+
+               free(config);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_config_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GList *iter = NULL;
+       if (list != NULL) {
+               for (iter = list; iter != NULL; iter = g_list_next(iter))
+                       sync_agent_free_config(iter->data);
+
+               g_list_free(list);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/data-adapter/interface_folder.c b/src/framework/data-adapter/interface_folder.c
new file mode 100755 (executable)
index 0000000..8c5dd24
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/agent.h"
+
+#include "data-adapter/interface_folder.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_folder(sync_agent_da_folder_s ** sync_agent_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_folder = (sync_agent_da_folder_s *) calloc(1, sizeof(sync_agent_da_folder_s));
+       if (*sync_agent_folder == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_folder(sync_agent_da_folder_s * sync_agent_folder, char **folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_folder == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_folder_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       ret = da_add_folder_new(daci_handler, sync_agent_folder, 1, folder_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_add_folder_new() failed !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_folder(char *folder_id, sync_agent_da_folder_s ** sync_agent_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       ret = da_get_folder_by_folder_id(daci_handler, folder_id, sync_agent_folder);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("da_get_folder_by_folder_id() failed !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_folder_list(sync_agent_da_get_folder_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_folder_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_FOLDER_LIST_OPTION_SERVICE_ID_MAPPING:
+               retvm_if(query->folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+               ret = da_get_folder_mapping_service_id_new(daci_handler, query->account_id, query->folder_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_folder_mapping_service_id_new() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_folder_id_list(sync_agent_da_get_folder_id_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_folder_id_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_FOLDER_TYPE_ID:
+               ret = da_get_folder_folder_id_by_folder_type_id_new(daci_handler, query->account_id, query->item_type_id, query->folder_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_folder_folder_id_by_folder_type_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_FOLDER_ID_OPTION_ITEM_TYPE_ID:
+               ret = da_get_folder_folder_id_list_by_item_type_id_new(daci_handler, query->account_id, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_folder_folder_id_list_by_item_type_id_new() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_folder(sync_agent_da_folder_s * sync_agent_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_folder != NULL) {
+               if (sync_agent_folder->folder_id != NULL)
+                       free(sync_agent_folder->folder_id);
+
+               if (sync_agent_folder->service_id != NULL)
+                       free(sync_agent_folder->service_id);
+
+               if (sync_agent_folder->parent_folder_id != NULL)
+                       free(sync_agent_folder->parent_folder_id);
+
+               if (sync_agent_folder->access_name != NULL)
+                       free(sync_agent_folder->access_name);
+
+               free(sync_agent_folder);
+       } else {
+               _DEBUG_ERROR("sync_agent_folder is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_folder_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               sync_agent_da_folder_s *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (sync_agent_da_folder_s *) (iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_folder(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_folder() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_ERROR("list is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_folder_id(char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (folder_id != NULL) {
+               free(folder_id);
+       } else {
+               _DEBUG_ERROR("folder id is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_folder_id_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               char *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (char *)(iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_folder_id(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_folder_id() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_ERROR("list is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
diff --git a/src/framework/data-adapter/interface_item.c b/src/framework/data-adapter/interface_item.c
new file mode 100755 (executable)
index 0000000..1f2007a
--- /dev/null
@@ -0,0 +1,545 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/agent.h"
+
+#include "data-adapter/interface_item.h"
+#include "data-adapter/changelog.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_item(sync_agent_da_item_s ** sync_agent_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_item = (sync_agent_da_item_s *) calloc(1, sizeof(sync_agent_da_item_s));
+       if (*sync_agent_item == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_item(sync_agent_da_item_s * sync_agent_item, char **item_id, int use_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_item_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+//      item_id = (char **) calloc(count, sizeof(char *));
+//      if (item_id == NULL) {
+//              _DEBUG_ERROR("calloc failed !!");
+//      }
+//
+//      for (i; i < count; i++) {
+//              if (use_changelog == 1) {
+//                      ret = sync_agent_changelog_add_item_new(sync_agent_item, item_id);
+//              } else {
+//                      ret = sync_agent_add_item_new(sync_agent_item, count, item_id);
+//              }
+//
+//              if (ret != SYNC_AGENT_DA_SUCCESS) {
+//                      _DEBUG_ERROR("add item failed !!");
+//                      return ret;
+//              }
+//      }
+
+       if (use_changelog == 1) {
+               ret = sync_agent_changelog_add_item_new(sync_agent_item, item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_changelog_add_item_internal() failed !!");
+               }
+       } else {
+               ret = sync_agent_add_item_new(sync_agent_item, 1, item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_add_item_internal() failed !!");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_update_item(char *item_id, int use_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_item_s *get_item = NULL;
+
+       if (use_changelog == 1) {
+               ret = sync_agent_create_item(&get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_create_item() failed !!");
+                       return ret;
+               }
+
+               ret = sync_agent_get_item(item_id, &get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_get_item() failed !!");
+                       int ret_temp = sync_agent_free_item(get_item);
+                       if (ret_temp != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_item() failed !!");
+                       }
+                       return ret;
+               }
+
+               ret = sync_agent_changelog_update_item_new(get_item->account_id, item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_changelog_update_item_new() failed !!");
+               }
+
+               ret = sync_agent_free_item(get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_free_item() failed !!");
+               }
+       } else {
+               ret = SYNC_AGENT_DA_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_item(char *item_id, int use_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       sync_agent_da_item_s *get_item = NULL;
+
+       if (use_changelog == 1) {
+               ret = sync_agent_create_item(&get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_create_item() failed !!");
+                       return ret;
+               }
+
+               ret = sync_agent_get_item(item_id, &get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_get_item() failed !!");
+                       int ret_temp = sync_agent_free_item(get_item);
+                       if (ret_temp != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_item() failed !!");
+                       }
+                       return ret;
+               }
+
+               ret = sync_agent_changelog_delete_item_new(get_item->account_id, item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_changelog_delete_item_internal() failed !!");
+               }
+
+               ret = sync_agent_free_item(get_item);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_free_item() failed !!");
+               }
+       } else {
+               ret = da_delete_item_by_item_id_internal(item_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_item_by_item_id_internal() failed !!");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_query_delete_item(sync_agent_da_delete_item_query_s * query)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_delete_item_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_DELETE_ITEM_OPTION_ITEM_TYPE_ID:
+               ret = da_delete_item_by_item_type_id_new(daci_handler, query->account_id, query->item_type_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_item_by_item_type_id() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_item(char *item_id, sync_agent_da_item_s ** sync_agent_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+//      if (item_id == NULL) {
+//              _DEBUG_ERROR("item id is NULL !!");
+//              return ret;
+//      }
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       ret = da_get_item_new(daci_handler, item_id, sync_agent_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_get_item() faied !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_list(int account_id, sync_agent_da_get_item_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_item_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_ACCOUNT_ID:
+               ret = da_get_item_by_account_id_new(daci_handler, account_id, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_by_account_id() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_LIST_OPTION_SERVICE_ID_MAPPING:
+               retvm_if(query->item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+               ret = da_get_item_mapping_service_id_new(daci_handler, account_id, query->item_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_mapping_service_id() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_id(sync_agent_da_get_item_id_query_s * query, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_item_id_query_s is NULL !!");
+       retvm_if(query->service_id == NULL, SYNC_AGENT_DA_ERRORS, "service id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       ret = da_get_item_item_id_new(daci_handler, query->account_id, query->service_id, query->item_type_id, item_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_get_item_item_id_new() failed !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_id_list(sync_agent_da_get_item_id_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_item_id_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_COLUMN_NAME:
+               retvm_if(query->folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+               ret = da_get_item_id_list_new(daci_handler, query->folder_id, query->column_name, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID:
+               ret = da_get_item_id_list_by_operation_id_new(daci_handler, query->account_id, query->item_type_id, query->operation_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_by_operation_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_FOLDER_ID:
+               retvm_if(query->folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+               ret = da_get_item_id_list_by_operation_id_and_folder_id_new(daci_handler, query->account_id, query->folder_id, query->item_type_id, query->operation_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_by_operation_id_and_folder_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_OPERATION_ID_N_ITEM_TYPE_ID:
+               ret = da_get_item_info_by_item_type_id_and_operation_id_new(daci_handler, query->account_id, query->item_type_id, query->operation_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_info_by_item_type_id_and_operation_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID:
+               ret = da_get_item_id_list_by_datastore_id_new(daci_handler, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_by_datastore_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_ITEM_TYPE_ID_N_ACCOUNT_ID:
+               ret = da_get_item_id_list_by_datastore_id_with_account_id_new(daci_handler, query->account_id, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_by_datastore_id_with_account_id_new() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_GET_ITEM_ID_LIST_OPTION_FOLDER_ID_N_ACCOUNT_ID:
+               retvm_if(query->folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+               ret = da_get_item_id_list_by_folder_id_and_account_id(daci_handler, query->account_id, query->folder_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_id_list_by_folder_id_and_account_id() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_item(sync_agent_da_item_s * sync_agent_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_item != NULL) {
+               if (sync_agent_item->item_id != NULL)
+                       free(sync_agent_item->item_id);
+
+               if (sync_agent_item->folder_id != NULL)
+                       free(sync_agent_item->folder_id);
+
+               if (sync_agent_item->service_id != NULL)
+                       free(sync_agent_item->service_id);
+
+               if (sync_agent_item->access_name != NULL)
+                       free(sync_agent_item->access_name);
+
+               free(sync_agent_item);
+       } else {
+               _DEBUG_ERROR("sync_agent_item is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_item_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               sync_agent_da_item_s *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (sync_agent_da_item_s *) (iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_item(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_item() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_ERROR("list is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_item_id(char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (item_id != NULL) {
+               free(item_id);
+       } else {
+               _DEBUG_ERROR("item id is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_item_id_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               char *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (char *)(iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_item_id(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_item_id() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_INFO("list is NULL !!");
+               return ret;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+EXPORT_API sync_agent_da_return_e sync_agent_get_item_count(int data_store_id, int *item_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_count == NULL, SYNC_AGENT_DA_ERRORS, "*item_count is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+       int total_count = 0;
+       GList *account_info_list = NULL;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto return_part;
+       }
+
+       sync_agent_fw_account_query_s account_query;
+       account_query.query = ACCOUNT_QUERY_BY_SERVICE_TYPE;
+       account_query.service_type = data_store_id;
+       sync_agent_acc_error_e acc_err = sync_agent_query_fw_account(&account_query, &account_info_list);
+       if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto return_part;
+       }
+
+       GList *account_iter = NULL;
+       for (account_iter = account_info_list; account_iter != NULL; account_iter = g_list_next(account_iter)) {
+               sync_agent_fw_account_s *fw_account = (sync_agent_fw_account_s *)account_iter->data;
+               int fw_account_id = fw_account->account_id;
+               int temp_count = 0;
+
+               ret = da_get_item_count_by_datastore_id(daci_handler, data_store_id, fw_account_id, &temp_count);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_item_count_by_datastore_id() failed !!");
+               }
+               total_count += temp_count;
+       }
+
+return_part:
+       *item_count = total_count;
+       _DEBUG_INFO("item_count = %d", *item_count);
+
+       if(account_info_list != NULL) {
+               sync_agent_free_fw_account_list(account_info_list);
+               account_info_list = NULL;
+       }
+       _EXTERN_FUNC_EXIT;
+       return ret;
+}
diff --git a/src/framework/data-adapter/interface_last_anchor.c b/src/framework/data-adapter/interface_last_anchor.c
new file mode 100755 (executable)
index 0000000..ab290ba
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <pthread.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/interface_last_anchor.h"
+#include "data-adapter/agent.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_last_anchor(sync_agent_da_last_anchor_s ** sync_agent_last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_last_anchor = (sync_agent_da_last_anchor_s *) calloc(1, sizeof(sync_agent_da_last_anchor_s));
+       if (*sync_agent_last_anchor == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_last_anchor_internal(sync_agent_last_anchor);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_update_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_last_anchor == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_last_anchor_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_set_last_anchor_internal(sync_agent_last_anchor);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_last_anchor_list(sync_agent_da_get_last_anchor_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_last_anchor_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_LAST_ANCHOR_LIST_OPTION_ITEM_TYPE_ID:
+               ret = da_get_last_anchor_by_item_type_id_new(daci_handler, query->account_id, query->item_type_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_last_anchor_by_item_type_id_new() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_last_anchor(sync_agent_da_last_anchor_s * sync_agent_last_anchor)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_last_anchor != NULL) {
+               if (sync_agent_last_anchor->last_anchor_server != NULL)
+                       free(sync_agent_last_anchor->last_anchor_server);
+
+               if (sync_agent_last_anchor->last_anchor_client != NULL)
+                       free(sync_agent_last_anchor->last_anchor_client);
+
+               if (sync_agent_last_anchor->access_name != NULL)
+                       free(sync_agent_last_anchor->access_name);
+
+               free(sync_agent_last_anchor);
+       } else {
+               _DEBUG_ERROR("sync_agent_last_anchor is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
diff --git a/src/framework/data-adapter/interface_mapping.c b/src/framework/data-adapter/interface_mapping.c
new file mode 100755 (executable)
index 0000000..c691830
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent.h"
+
+#include "data-adapter/agent_handler_manager_internal.h"
+#include "data-adapter/interface_mapping.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_mapping(sync_agent_da_mapping_s ** sync_agent_mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_mapping = (sync_agent_da_mapping_s *) calloc(1, sizeof(sync_agent_da_mapping_s));
+       if (*sync_agent_mapping == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_mapping(sync_agent_da_mapping_s * sync_agent_mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_mapping == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_mapping_s is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_add_mapping(daci_handler, sync_agent_mapping);
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_mapping(sync_agent_da_delete_mapping_query_s * query)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_delete_mapping_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_DELETE_MAPPING_OPTION_ACCOUNT_ID:
+               ret = da_delete_mapping_by_account_id(daci_handler, query->account_id);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_mapping_by_account_id() failed !!");
+               }
+               break;
+       case SYNC_AGENT_DA_DELETE_MAPPING_OPTION_LUID:
+               retvm_if(query->luid == NULL, SYNC_AGENT_DA_ERRORS, "luid is NULL !!");
+
+               ret = da_delete_mapping_by_luid(daci_handler, query->account_id, query->luid);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_delete_mapping_by_luid() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_mapping(sync_agent_da_get_mapping_query_s * query, sync_agent_da_mapping_s ** sync_agent_mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_mapping_query_s is NULL !!");
+       retvm_if(query->luid == NULL, SYNC_AGENT_DA_ERRORS, "luid is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       ret = da_get_mapping_guid_new(daci_handler, query->account_id, query->luid, sync_agent_mapping);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("da_get_mapping_guid_new() failed !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_mapping_list(sync_agent_da_get_mapping_list_query_s * query, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_get_mapping_list_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return ret;
+       }
+
+       switch (query->option) {
+       case SYNC_AGENT_DA_GET_MAPPING_LIST_OPTION_ACCOUNT_ID:
+               ret = da_get_mapping_by_account_id_new(daci_handler, query->account_id, list);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("da_get_mapping_by_account_id_new() failed !!");
+               }
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_mapping(sync_agent_da_mapping_s * sync_agent_mapping)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_mapping != NULL) {
+               if (sync_agent_mapping->luid != NULL)
+                       free(sync_agent_mapping->luid);
+
+               if (sync_agent_mapping->guid != NULL)
+                       free(sync_agent_mapping->guid);
+
+               if (sync_agent_mapping->access_name != NULL)
+                       free(sync_agent_mapping->access_name);
+
+               free(sync_agent_mapping);
+       } else {
+               _DEBUG_ERROR("sync_agent_mapping is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_mapping_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       if (list != NULL) {
+               GList *iter = NULL;
+               sync_agent_da_mapping_s *iter_data;
+
+               for (iter = list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = (sync_agent_da_mapping_s *) (iter->data);
+
+                       iter = g_list_next(iter);
+                       list = g_list_remove(list, iter_data);
+
+                       ret = sync_agent_free_mapping(iter_data);
+                       if (ret != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_free_mapping() failed !!");
+                               return ret;
+                       }
+               }
+
+               g_list_free(list);
+       } else {
+               _DEBUG_ERROR("list is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_is_exist_mapping_by_account_id(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DA_ERR_DB_HANDLER_MGR;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_is_exist_mapping_by_account_id(daci_handler, account_id);
+}
diff --git a/src/framework/data-adapter/interface_service_item.c b/src/framework/data-adapter/interface_service_item.c
new file mode 100755 (executable)
index 0000000..41e3ebd
--- /dev/null
@@ -0,0 +1,891 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/data_converter_plugin.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#include "data-adapter/agent.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "data-adapter/interface_item.h"
+#include "data-adapter/interface_service_item.h"
+#include "data-adapter/service_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_open_service(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_open_service_cb func_service_open = plugin_get_function_open_service(content_type);
+
+       retvm_if(func_service_open == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_open_service_cb !!");
+
+       ret = func_service_open();
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_open_service] Fail!");
+       } else {
+               _DEBUG_INFO("[sync_agent_open_service] Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_close_service(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_close_service_cb func_service_close = plugin_get_function_close_service(content_type);
+
+       retvm_if(func_service_close == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_close_service_cb !!");
+
+       ret = func_service_close();
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_close_service] Fail!");
+       } else {
+               _DEBUG_INFO("[sync_agent_close_service] Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_begin_service(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_begin_transaction_cb func_begin_transaction = plugin_get_function_begin_transaction(content_type);
+
+       retvm_if(func_begin_transaction == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_begin_transaction_cb !!");
+
+       ret = func_begin_transaction();
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_begin_service] Fail!");
+       } else {
+               _DEBUG_INFO("[sync_agent_begin_service] Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_end_service(int content_type, int is_success)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[sync_agent_end_service] start");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       plugin_end_transaction_cb func_end_transaction = plugin_get_function_end_transaction(content_type);
+
+       retvm_if(func_end_transaction == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_end_transaction_cb !!");
+
+       ret = func_end_transaction(is_success);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("[sync_agent_end_service] Fail!");
+       } else {
+               _DEBUG_INFO("[sync_agent_end_service] Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_service_item(sync_agent_da_service_item_s ** service_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *service_item = (sync_agent_da_service_item_s *) calloc(1, sizeof(sync_agent_da_service_item_s));
+       if (*service_item == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_create_service_folder(sync_agent_da_service_folder_s ** service_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *service_folder = (sync_agent_da_service_folder_s *) calloc(1, sizeof(sync_agent_da_service_folder_s));
+       if (*service_folder == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_service_item(sync_agent_da_service_item_s * service_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (service_item != NULL) {
+               if (service_item->item_id != NULL)
+                       free(service_item->item_id);
+
+               if (service_item->folder_id != NULL)
+                       free(service_item->folder_id);
+
+               if (service_item->access_name != NULL)
+                       free(service_item->access_name);
+
+               if (service_item->data != NULL)
+                       free((void *)(service_item->data));
+
+               free(service_item);
+       } else {
+               _DEBUG_ERROR("service_item is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_free_service_folder(sync_agent_da_service_folder_s * service_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (service_folder != NULL) {
+               if (service_folder->folder_id != NULL)
+                       free(service_folder->folder_id);
+
+               if (service_folder->folder_name != NULL)
+                       free(service_folder->folder_name);
+
+               free(service_folder);
+       } else {
+               _DEBUG_ERROR("service_folder is NULL !!");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_add_service_item(sync_agent_da_service_item_s * service_item, char **item_id, bool update_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *fw_item = NULL;
+       int service_account_id = 0;
+       char *service_item_id = NULL;
+       char *service_folder_id = NULL;
+       void *service_data = NULL;
+       plugin_converter_cb func_converter;
+       plugin_add_item_cb func_addItem;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
+       _DEBUG_INFO("[sync_agent_add_service_item] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
+       _DEBUG_INFO("[sync_agent_add_service_item] service_folder_id : %s", service_folder_id);
+
+       /* 3. call plugIn dataconverter */
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
+       func_converter = plugin_get_function_converter(converter_plugIn_id);
+       if (func_converter == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_converter(service_item->data, &service_data);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("%d", __LINE__);
+               goto DACI_FINISH;
+       }
+
+       /* 4. call plugIn dataconnector */
+       func_addItem = plugin_get_function_add_item(service_item->content_type);
+       if (func_addItem == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_addItem(service_account_id, service_folder_id, service_data, &service_item_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_add_service_item] failed pFunc_AddItem()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_add_service_item] success pFunc_AddItem()\n");
+               _DEBUG_INFO("[sync_agent_add_service_item] added service item id : %s", service_item_id);
+       }
+
+       ret = sync_agent_create_item(&fw_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_add_service_item] failed sync_agent_create_item()\n");
+               goto DACI_FINISH;
+       }
+
+       fw_item->data_store_id = service_item->content_type;
+       fw_item->account_id = service_item->account_id;
+       fw_item->item_id = g_strdup(service_item->item_id);
+       fw_item->folder_id = g_strdup(service_item->folder_id);
+       fw_item->service_id = g_strdup(service_item_id);
+       fw_item->access_name = g_strdup(service_item->access_name);
+
+       ret = sync_agent_add_item(fw_item, item_id, update_changelog);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_add_service_item] failed sync_agent_add_item()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_add_service_item] success sync_agent_add_item()\n");
+               _DEBUG_INFO("[sync_agent_add_service_item] added fw item id : %s", *item_id);
+       }
+
+ DACI_FINISH:
+
+       if (ret != SYNC_AGENT_DA_SUCCESS)
+               *item_id = NULL;
+
+       /* memory free */
+       if (fw_item != NULL)
+               sync_agent_free_item(fw_item);
+       if (service_item_id != NULL)
+               free(service_item_id);
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_update_service_item(sync_agent_da_service_item_s * service_item, char *item_id, bool update_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_item == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_service_item_s is NULL !!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       _DEBUG_INFO("[sync_agent_update_service_item] account_id : %d", service_item->account_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] folder_id : %s", service_item->folder_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] item_id : %s", item_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] data : %s", (char *)service_item->data);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       char *service_item_id = NULL;
+       void *service_data = NULL;
+       void *new_service_data = NULL;
+       plugin_get_item_cb func_get_item;
+       plugin_update_item_cb func_update_item;
+       plugin_replace_converter_cb func_replace_converter;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(service_item->content_type, service_item->account_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(service_item->folder_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] service_folder_id : %s", service_folder_id);
+
+       /* 3. get service item id */
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       _DEBUG_INFO("[sync_agent_update_service_item] service_item_id : %s", service_item_id);
+
+       /* 4. call plugIn dataconnector */
+       func_get_item = plugin_get_function_get_item(service_item->content_type);
+       if (func_get_item == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("%d", __LINE__);
+               goto DACI_FINISH;
+       }
+
+       /* 5. call plugIn dataconverter */
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(service_item->content_type);
+       func_replace_converter = plugin_get_function_replace_converter(converter_plugIn_id);
+       if (func_replace_converter == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_replace_converter(service_data, service_item->data, &new_service_data);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("%d", __LINE__);
+               goto DACI_FINISH;
+       }
+
+       /* 6. call plugIn dataconverter */
+       func_update_item = plugin_get_function_update_item(service_item->content_type);
+       if (func_update_item == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_update_item(service_account_id, service_folder_id, service_item_id, new_service_data);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_update_service_item] failed func_update_item()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_update_service_item] success func_update_item()\n");
+       }
+
+       ret = sync_agent_update_item(item_id, update_changelog);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_update_service_item] failed sync_agent_update_item()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_update_service_item] success sync_agent_update_item()\n");
+               _DEBUG_INFO("[sync_agent_update_service_item] updated fw item id : %s", item_id);
+       }
+
+ DACI_FINISH:
+
+       /* memory free */
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       if (service_item_id != NULL)
+               free(service_item_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_delete_service_item(char *item_id, bool update_changelog)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *fw_item = NULL;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       char *service_item_id = NULL;
+       plugin_delete_item_cb func_del_item;
+
+       ret = sync_agent_create_item(&fw_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_create_item() failed !!");
+               goto DACI_FINISH;
+       }
+
+       ret = sync_agent_get_item(item_id, &fw_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_get_item() failed !!");
+               goto DACI_FINISH;
+       }
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(fw_item->data_store_id, fw_item->account_id);
+       _DEBUG_INFO("[sync_agent_delete_service_item] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(fw_item->folder_id);
+       _DEBUG_INFO("[sync_agent_delete_service_item] service_folder_id : %s", service_folder_id);
+
+       /* 3. get service item id */
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       _DEBUG_INFO("[sync_agent_delete_service_item] service_item_id : %s", service_item_id);
+
+       /* 4. call plugIn dataconnector */
+       func_del_item = plugin_get_function_del_item(fw_item->data_store_id);
+       if (func_del_item == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_del_item(service_account_id, service_folder_id, service_item_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_delete_service_item] failed func_del_item()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_delete_service_item] success func_del_item()\n");
+       }
+
+       ret = sync_agent_delete_item(item_id, update_changelog);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_delete_service_item] failed sync_agent_delete_item()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_delete_service_item] success sync_agent_delete_item()\n");
+               _DEBUG_INFO("[sync_agent_delete_service_item] deleted fw item id : %s", item_id);
+       }
+
+ DACI_FINISH:
+
+       /* memory free */
+       if (fw_item != NULL)
+               sync_agent_free_item(fw_item);
+
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       if (service_item_id != NULL)
+               free(service_item_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_query_delete_service_items(sync_agent_da_delete_service_item_query_s * query)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(query == NULL, SYNC_AGENT_DA_ERRORS, "sync_agent_da_delete_service_item_query_s is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+/*     char **folder_id_list = NULL;
+       int folder_id_list_cnt = 0;
+       char *service_item_id = NULL;*/
+       plugin_delete_all_items_cb func_del_all_items;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(query->content_type, query->account_id);
+       _DEBUG_INFO("[sync_agent_query_delete_service_items] service_acount_id : %d", service_account_id);
+
+/*      //2. get folder id list for account id
+       folder_id_list = DACI_Get_Folder_Folder_Id_List_By_Account_Id(account_id, &folder_id_list_cnt);
+       _DEBUG_INFO("[sync_agent_query_delete_service_items] folder_id_list_cnt : %d", folder_id_list_cnt);
+
+        //3. get service item id
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       _DEBUG_INFO("[sync_agent_query_delete_service_items] service_item_id : %s", service_item_id);*/
+
+       /* 2. call plugIn dataconnector */
+       func_del_all_items = plugin_get_function_del_all_items(query->content_type);
+
+       retvm_if(func_del_all_items == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_delete_all_items_cb !!");
+
+       ret = func_del_all_items(service_account_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_query_delete_service_items] failed func_del_all_items()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_query_delete_service_items] success func_del_all_items()\n");
+       }
+
+       /* memory free */
+/*     if (service_folder_id !=NULL)
+               free(service_folder_id);
+
+       if (service_item_id != NULL)
+               free(service_item_id);*/
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_service_item(char *item_id, sync_agent_da_service_item_s ** service_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERRORS, "item id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_item_s *fw_item = NULL;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       char *service_item_id = NULL;
+       void *service_data = NULL;
+       plugin_get_item_cb func_get_item;
+       plugin_reverse_converter_cb func_reverse_converter;
+
+       ret = sync_agent_create_item(&fw_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_create_item() failed !!");
+               goto DACI_FINISH;
+       }
+
+       ret = sync_agent_get_item(item_id, &fw_item);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_get_item() failed !!");
+               goto DACI_FINISH;
+       }
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(fw_item->data_store_id, fw_item->account_id);
+       _DEBUG_INFO("[sync_agent_get_service_item] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(fw_item->folder_id);
+       _DEBUG_INFO("[sync_agent_get_service_item] service_folder_id : %s", service_folder_id);
+
+       /* 3. get service item id */
+       service_item_id = sync_agent_get_service_item_id(item_id);
+       _DEBUG_INFO("[sync_agent_get_service_item] service_item_id : %s", service_item_id);
+
+       /* 4. call plugIn dataconnector */
+       func_get_item = plugin_get_function_get_item(fw_item->data_store_id);
+       if (func_get_item == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_get_item(service_account_id, service_folder_id, service_item_id, &service_data);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("%d", __LINE__);
+               goto DACI_FINISH;
+       }
+
+       /* 5. call plugIn dataconverter */
+       int converter_plugIn_id = plugin_get_data_converter_plugin_id(fw_item->data_store_id);
+       func_reverse_converter = plugin_get_function_reverse_converter(converter_plugIn_id);
+       if (func_reverse_converter == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_reverse_converter(service_data, (void **)(&((*service_item)->data)));
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_get_service_item] failed func_reverse_converter()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_get_service_item] success func_reverse_converter()\n");
+       }
+
+       (*service_item)->content_type = fw_item->data_store_id;
+       (*service_item)->account_id = fw_item->account_id;
+       (*service_item)->item_id = g_strdup(fw_item->item_id);
+       (*service_item)->folder_id = g_strdup(fw_item->folder_id);
+       (*service_item)->access_name = g_strdup(fw_item->access_name);
+
+ DACI_FINISH:
+
+       /* memory free */
+       if (fw_item != NULL)
+               sync_agent_free_item(fw_item);
+
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       if (service_item_id != NULL)
+               free(service_item_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_get_service_folder(char *folder_id, sync_agent_da_service_folder_s ** service_folder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_da_folder_s *fw_folder = NULL;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       plugin_get_folder_cb func_get_folder;
+
+       ret = sync_agent_create_folder(&fw_folder);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+               goto DACI_FINISH;
+       }
+
+       ret = sync_agent_get_folder(folder_id, &fw_folder);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_get_folder() failed !!");
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("folder[%s] info => data_store_id[%d], account_id[%d]", fw_folder->folder_id, fw_folder->data_store_id, fw_folder->account_id);
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(fw_folder->data_store_id, fw_folder->account_id);
+       _DEBUG_INFO("[sync_agent_get_service_folder] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(folder_id);
+       _DEBUG_INFO("[sync_agent_get_service_folder] service_folder_id : %s", service_folder_id);
+
+       /* 3. call plugIn dataconnector */
+       func_get_folder = plugin_get_function_get_folder(fw_folder->data_store_id);
+       if (func_get_folder == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_get_folder(service_account_id, service_folder_id, &((*service_folder)->folder_name), &((*service_folder)->folder_type));
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_get_service_folder] failed func_get_folder()\n");
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[sync_agent_get_service_folder] success func_get_folder()\n");
+       }
+
+       (*service_folder)->folder_id = g_strdup(folder_id);
+
+ DACI_FINISH:
+
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+       if (fw_folder != NULL)
+               sync_agent_free_folder(fw_folder);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_execute_service(int content_type, int account_id, const char *execute_key, void *execute_values, void **result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(execute_key == NULL, SYNC_AGENT_DA_ERRORS, "execute key is NULL !!");
+       retvm_if(execute_values == NULL, SYNC_AGENT_DA_ERRORS, "execute value is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       plugin_execute_cb func_execute;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("[sync_agent_execute_service] service_acount_id : %d", service_account_id);
+
+       /* 2. call plugIn dataconnector */
+       func_execute = plugin_get_function_execute(content_type);
+
+       retvm_if(func_execute == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_execute_cb !!");
+
+       ret = func_execute(service_account_id, execute_key, execute_values, result);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_execute_service] failed pFunc_Execute()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_execute_service] success pFunc_Execute()\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_get_used_service_item_count(int content_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_used_item_count_cb func_get_used_count = plugin_get_function_get_used_item_count(content_type);
+
+       retvm_if(func_get_used_count == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_get_used_item_count_cb !!");
+
+       /* 1. call plugIn dataconnector */
+       int used_count = func_get_used_count();
+       if (used_count <= -1) {
+               _DEBUG_INFO("[sync_agent_get_used_service_item_count] failed pFunc_Get_Used_Count()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_get_used_service_item_count] success pFunc_Get_Used_Count() : %d\n", used_count);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return used_count;
+}
+
+EXPORT_API int sync_agent_get_used_service_item_count_for_folder(int content_type, int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       int used_count = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       plugin_get_used_count_for_folder_cb func_get_used_item_count_for_folder;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(folder_id);
+       _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] service_folder_id : %s", service_folder_id);
+
+       /* 3. call plugIn dataconnector */
+       func_get_used_item_count_for_folder = plugin_get_function_get_used_count_for_folder(content_type);
+       if (func_get_used_item_count_for_folder == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               used_count = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       used_count = func_get_used_item_count_for_folder(service_account_id, service_folder_id);
+       if (used_count <= -1) {
+               _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] failed pFunc_Get_Used_item_Count_For_Folder()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_get_used_service_item_count_for_folder] success pFunc_Get_Used_item_Count_For_Folder() : %d\n", used_count);
+       }
+
+ DACI_FINISH:
+
+       /* memory free */
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return used_count;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_backup_service_items_to_file(int content_type, int account_id, char **file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       plugin_backup_service_items_to_file_cb func_write_items_to_files;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("service_acount_id : %d", service_account_id);
+
+       /* 3. call plugIn dataconnector */
+       func_write_items_to_files = plugin_get_function_backup_service_items_to_file(content_type);
+       if (func_write_items_to_files == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_write_items_to_files(service_account_id, file_path);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("failed pFunc_Write_Items_To_Files()\n");
+       } else {
+               _DEBUG_INFO("success pFunc_Write_Items_To_Files() : %d\n", ret);
+       }
+
+ DACI_FINISH:
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_restore_service_items_from_file(int content_type, int account_id, const char *file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "file path is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       plugin_restore_service_items_from_file_cb func_add_file_wrote_items_to_datastore;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("service_acount_id : %d", service_account_id);
+
+       /* 3. call plugIn dataconnector */
+       func_add_file_wrote_items_to_datastore = plugin_get_function_restore_service_items_from_file(content_type);
+       if (func_add_file_wrote_items_to_datastore == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_add_file_wrote_items_to_datastore(service_account_id, file_path);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("failed pFunc_Add_File_Wrote_Items_To_Datastore()\n");
+       } else {
+               _DEBUG_INFO("success pFunc_Add_File_Wrote_Items_To_Datastore() : %d\n", ret);
+       }
+
+ DACI_FINISH:
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API char *sync_agent_get_service_item_id(char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, NULL, "item id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_item_service_id(daci_handler, item_id);
+}
+
+EXPORT_API char *sync_agent_get_service_folder_id(char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, NULL, "folder id is NULL !!");
+
+       SYNC_AGENT_DA_HANDLER *daci_handler = da_get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (daci_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return da_get_folder_service_id(daci_handler, folder_id);
+}
diff --git a/src/framework/data-adapter/luid.c b/src/framework/data-adapter/luid.c
new file mode 100755 (executable)
index 0000000..f063e23
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "utility/sync_util.h"
+#include "fw_sequential_id_provider_internal.h"
+
+#include "data-adapter/luid.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <uuid.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DACI"
+#endif
+
+/*
+ * temporary - item id gen -> sequence
+ */
+#include <vconf.h>
+
+//#define VCONF_KEY_ITEM_SEQUENCE                       "db/Apps/AgentFramework/ItemSequence/"
+//#define VCONF_KEY_FOLDEs_SEQUENCE             "db/Apps/AgentFramework/FolderSequence/"
+
+static pthread_mutex_t lockx;
+
+static int _exist_in_array(unsigned int id, unsigned int *array, int count);
+static int _get_digit(unsigned int new_id);
+
+EXPORT_API char **sync_agent_generate_item_luid(int id_provider_code, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("=========== Start ============");
+
+       if (count == 0) {
+               return NULL;
+       }
+
+       /*
+        * Start Critical Section
+        */
+       if (pthread_mutex_lock(&lockx)) {
+               _DEBUG_ERROR("pthread_mutex_lock error");
+       }
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+
+       util_id_provider_s *id_provider_local = 0;
+       id_provider_local = util_load_id_persistent_provider(id_provider_code, true);
+       util_tracking_mode_on(id_provider_local);
+
+       /*
+        * Update ID Page
+        */
+       unsigned int free_id_count = util_get_total_free_count(id_provider_local);
+       if (free_id_count < count) {
+               _DEBUG_INFO("Enter to Update ID Page [%d] [%d]", free_id_count, count);
+               /*
+                * Get Page Index count
+                */
+               unsigned int page_index;
+               da_get_id_page_index_wrapper(id_provider_code, (int *)(&page_index));
+
+               _DEBUG_INFO("page_index : %d", page_index);
+
+               /*
+                * Get All id list in item_tbl;
+                */
+               sync_agent_da_id_list_s *dc_item_id_list = da_get_all_item_id_wrapper();
+               if (dc_item_id_list == NULL || dc_item_id_list->count <= 0) {
+                       _DEBUG_ERROR("Failed DACI_Get_All_Item()");
+                       util_tracking_mode_off(id_provider_local);
+                       util_destroy_id_provider(id_provider_local);
+                       if (pthread_mutex_unlock(&lockx)) {
+                               _DEBUG_ERROR("pthread_mutex_unlock error");
+                       }
+                       if (dc_item_id_list != NULL) {
+                               free(dc_item_id_list);
+                       }
+                       return NULL;
+               }
+
+               int item_count = dc_item_id_list->count;
+
+               unsigned int *item_id_list = (unsigned int *)calloc(item_count, sizeof(unsigned int));
+               if (item_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       util_tracking_mode_off(id_provider_local);
+                       util_destroy_id_provider(id_provider_local);
+                       if (pthread_mutex_unlock(&lockx)) {
+                               _DEBUG_ERROR("pthread_mutex_unlock error");
+                       }
+                       if (dc_item_id_list != NULL) {
+                               free(dc_item_id_list);
+                       }
+                       return NULL;
+               }
+               int i = 0;
+               for (; i < item_count; i++) {
+                       item_id_list[i] = atoi(dc_item_id_list->id[i]);
+               }
+
+               i = 0;
+               for (; i < page_index; i++) {
+                       unsigned int bits_per_page = id_provider_local->bits_per_page;
+                       unsigned int k = 0;
+                       for (; k < bits_per_page; k++) {
+                               unsigned int id = (i + k) + (i * (bits_per_page - 1));
+
+                               if (_exist_in_array(id, item_id_list, item_count) == 0) {
+                                       util_delete_id(id_provider_local, id);
+                               }
+                       }
+               }
+
+               if (dc_item_id_list != NULL) {
+                       free(dc_item_id_list);
+               }
+               if (item_id_list != NULL) {
+                       free(item_id_list);
+               }
+
+               free_id_count = util_get_total_free_count(id_provider_local);
+               if (free_id_count < count) {
+                       id_error = util_update_id_persistent_provider(id_provider_local);
+                       _DEBUG_INFO("Full Item ID generated [%d] [%d]", free_id_count, count);
+                       util_tracking_mode_off(id_provider_local);
+                       util_destroy_id_provider(id_provider_local);
+                       if (pthread_mutex_unlock(&lockx)) {
+                               _DEBUG_ERROR("pthread_mutex_unlock error");
+                       }
+                       return NULL;
+               }
+       }
+
+       char **item_luid_list = (char **)calloc(count, sizeof(char *));
+       if (item_luid_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               util_tracking_mode_off(id_provider_local);
+               util_destroy_id_provider(id_provider_local);
+               if (pthread_mutex_unlock(&lockx)) {
+                       _DEBUG_ERROR("pthread_mutex_unlock error");
+               }
+               return NULL;
+       }
+
+       int i = 0;
+       unsigned int new_id = 0;
+       for (; i < count; i++) {
+               id_error = util_provide_id(id_provider_local, &new_id);
+               assert(id_error == UTIL_ID_PROVIDER_OK);
+               if (id_error != UTIL_ID_PROVIDER_OK) {
+                       printf("provider error : %d\n", id_error);
+               }
+
+               int digit = _get_digit(new_id);
+               _DEBUG_INFO("new id = %d, digit = %d", new_id, digit);
+
+               //digit +1(NULL)
+               char *item_luid = (char *)calloc(digit + 1, sizeof(char));
+               if (item_luid != NULL) {
+                       snprintf(item_luid, digit + 1, "%d", new_id);
+               }
+               item_luid_list[i] = item_luid;
+       }
+
+       id_error = util_update_id_persistent_provider(id_provider_local);
+       util_tracking_mode_off(id_provider_local);
+       util_destroy_id_provider(id_provider_local);
+
+       /*
+        * End Critical Section
+        */
+       if (pthread_mutex_unlock(&lockx)) {
+               _DEBUG_ERROR("pthread_mutex_unlock error");
+       }
+
+       _DEBUG_INFO("=========== End ============");
+
+       _EXTERN_FUNC_EXIT;
+
+       return item_luid_list;
+}
+
+EXPORT_API char *sync_agent_generate_folder_luid()
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *folder_luid = NULL;
+       uuid_t out;
+
+       folder_luid = (char *)calloc(sizeof(char) * 36 + 1, 1);
+       if (folder_luid == NULL) {
+               _DEBUG_ERROR("[sync_agent_generate_folder_luid] memory allocation failed");
+               return folder_luid;
+       }
+
+       /* generate random uuid */
+       uuid_generate_random(out);
+
+       /* convert a UUID to string */
+       uuid_unparse(out, folder_luid);
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_luid;
+}
+
+static int _exist_in_array(unsigned int id, unsigned int *array, int count)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(array == NULL, 0, "array is NULL !!");
+
+       int is_exist = 0;
+
+       int i = 0;
+       for (; i < count; i++) {
+               if (id == array[i]) {
+                       is_exist = 1;
+                       break;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_exist;
+}
+
+static int _get_digit(unsigned int new_id)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int temp_id = 0;
+       int count = 1;
+
+       temp_id = new_id;
+
+       while (1) {
+               if (temp_id >= 10) {
+                       temp_id /= 10;
+                       count++;
+               } else
+                       break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return count;
+}
diff --git a/src/framework/data-adapter/service.c b/src/framework/data-adapter/service.c
new file mode 100755 (executable)
index 0000000..bb882fe
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/data_converter_plugin.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#include "data-adapter/agent_handler_manager.h"
+
+#include "data-adapter/interface_service_item.h"
+#include "data-adapter/service_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_DACI"
+#endif
+
+sync_agent_da_return_e da_add_service_folder(int content_type, int account_id, char *folder_name, int folder_type, char **folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, SYNC_AGENT_DA_ERRORS, "folder name is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       plugin_add_folder_cb func_add_folder;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("[sync_agent_add_service_folder] service_acount_id: %d", service_account_id);
+
+       /* 2. call plugIn dataconnector */
+       func_add_folder = plugin_get_function_add_folder(content_type);
+
+       retvm_if(func_add_folder == NULL, SYNC_AGENT_DA_NOT_FOUND_PLUG_IN, "cannot get plugin_add_folder_cb !!");
+
+       ret = func_add_folder(service_account_id, folder_name, folder_type, folder_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_add_service_folder] failed pFunc_AddFolder()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_add_service_folder] success pFunc_AddFolder()\n");
+               _DEBUG_INFO("[sync_agent_add_service_folder] added service id : %s", *folder_id);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_da_return_e da_delete_service_folder(int content_type, int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERRORS, "folder id is NULL !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_account_id = 0;
+       char *service_folder_id = NULL;
+       plugin_delete_folder_cb func_del_folder;
+
+       /* 1. get service account id */
+       service_account_id = acc_get_service_account_id(content_type, account_id);
+       _DEBUG_INFO("[sync_agent_delete_service_folder] service_acount_id : %d", service_account_id);
+
+       /* 2. get service folder id */
+       service_folder_id = sync_agent_get_service_folder_id(folder_id);
+       _DEBUG_INFO("[sync_agent_delete_service_folder] service_folder_id : %s", service_folder_id);
+
+       /* 3. call plugIn dataconnector */
+       func_del_folder = plugin_get_function_delete_folder(content_type);
+       if (func_del_folder == NULL) {
+               _DEBUG_ERROR("%d", __LINE__);
+               ret = SYNC_AGENT_DA_NOT_FOUND_PLUG_IN;
+               goto DACI_FINISH;
+       }
+
+       ret = func_del_folder(service_account_id, service_folder_id);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("[sync_agent_delete_service_folder] failed pFunc_DelFolder()\n");
+       } else {
+               _DEBUG_INFO("[sync_agent_delete_service_folder] success pFunc_DelFolder()\n");
+       }
+
+ DACI_FINISH:
+
+       if (service_folder_id != NULL)
+               free(service_folder_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int da_get_max_service_item_count(int content_type, int folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int max_item_count = 0;
+       plugin_get_max_item_count_cb func_get_max_item_count;
+
+       func_get_max_item_count = plugin_get_function_get_max_item_count(content_type);
+       if (func_get_max_item_count == NULL) {
+               _DEBUG_ERROR("[sync_agent_get_max_service_item_count] Fail!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       max_item_count = func_get_max_item_count(folder_type);
+
+       _EXTERN_FUNC_EXIT;
+
+       return max_item_count;
+}
+
+int da_get_max_service_field_length(int content_type, int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int max_field_len = 0;
+       plugin_get_max_field_length_cb func_get_max_field_len;
+
+       func_get_max_field_len = plugin_get_function_get_max_field_length(content_type);
+       if (func_get_max_field_len == NULL) {
+               _DEBUG_ERROR("[sync_agent_get_max_service_field_length] Fail!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       max_field_len = func_get_max_field_len(field_name, child_field_name);
+
+       _EXTERN_FUNC_EXIT;
+
+       return max_field_len;
+}
+
+int da_get_max_service_field_count(int content_type, int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int max_field_count = 0;
+       plugin_get_max_field_count_cb func_get_max_field_count;
+
+       func_get_max_field_count = plugin_get_function_get_max_field_count(content_type);
+       if (func_get_max_field_count == NULL) {
+               _DEBUG_ERROR("[sync_agent_get_max_service_field_count] Fail!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       max_field_count = func_get_max_field_count(field_name, child_field_name);
+
+       _EXTERN_FUNC_EXIT;
+
+       return max_field_count;
+}
+
+int da_get_service_field_value(int content_type, int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_field_value_cb func_get_field_value;
+
+       func_get_field_value = plugin_get_function_get_field_value(content_type);
+       if (func_get_field_value == NULL) {
+               _DEBUG_ERROR("[sync_agent_get_service_field_value] Fail!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       if (func_get_field_value(field_name, child_field_name, &(*str_val), num_val1, num_val2) == 0) {
+               _DEBUG_ERROR("[sync_agent_get_service_field_value] Error!");
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int da_get_is_support_service_feature(int content_type, int feature)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_get_is_support_feature_cb func_get_is_support_feature;
+
+       func_get_is_support_feature = plugin_get_function_get_is_support_feature(content_type);
+       if (func_get_is_support_feature == NULL) {
+               _DEBUG_ERROR("[sync_agent_get_is_support_service_feature] Fail!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_get_is_support_feature(feature);
+}
diff --git a/src/framework/data-adapter/service_internal.h b/src/framework/data-adapter/service_internal.h
new file mode 100755 (executable)
index 0000000..535035d
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SERVICE_INTERNAL_H_
+#define SERVICE_INTERNAL_H_
+
+#include "data-adapter/interface_service_item.h"
+
+/**
+ * @file               service_internal.h
+ * @brief      Support to use service storage
+ */
+
+/** @addtogroup data_adapter
+ *     @{
+ */
+
+/**
+ * @brief Insert folder into service database
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  account_id sync-agent-framework account id
+ * @param[in]  folder_name folder name
+ * @param[in]  folder_type folder type
+ * @param[in]  folder_id as returned by da_add_service_folder() - folder id on success, NULL on error
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_add_service_folder(int content_type, int account_id, char *folder_name, int folder_type, char **folder_id);
+
+/**
+ * @brief Delete folder from service database
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  account_id sync-agent-framework account id
+ * @param[in]  folder_id       sync-agent-framework folder id
+ * @return Operation result
+ * @retval SYNC_AGENT_DA_SUCCESS success
+ * @retval negative value error
+ */
+sync_agent_da_return_e da_delete_service_folder(int content_type, int account_id, char *folder_id);
+
+/***************************************** Get Storage MetaInfo ****************************************/
+/**
+ * @brief Get max item count per folder
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  folder_type folder type provided plugin
+ * @return Operation result
+ * @retval max item count success
+ * @retval -1 error
+ */
+int da_get_max_service_item_count(int content_type, int folder_type);
+
+/**
+ * @brief      Get service data's available field length
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  field_name field name provided data connector plugin
+ * @param[in]  child_field_name child field name provided data connector plugin
+ * @return Operation result
+ * @retval available field length      success
+ * @retval -1 error
+ */
+int da_get_max_service_field_length(int content_type, int field_name, int child_field_name);
+
+/**
+ * @brief      Get service data's available field count
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  field_name field name provided data connector plugin
+ * @param[in]  child_field_name child field name provided data connector plugin
+ * @return Operation result
+ * @retval available field count success
+ * @retval -1 error
+ */
+int da_get_max_service_field_count(int content_type, int field_name, int child_field_name);
+
+/**
+ * @brief      Get service data's available field value's domain
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  field_name field_name provided data connector plugin
+ * @param[in]  child_field_name child field name provided data connector plugin
+ * @param[in] str_val  as returned by da_get_service_field_value() - when domain value is string
+ * @param[in]  num_val1 as returned by da_get_service_field_value() - when domain value is integer (ex minimum value)
+ * @param[in]  num_val2        as returned by da_get_service_field_value() - when domain value is integer (ex maximum value)
+ * @return Operation result
+ * @retval 1 success
+ * @retval -1 error
+ */
+int da_get_service_field_value(int content_type, int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2);
+
+/**
+ * @brief Checking whether feature is supported in service corresponding to the content type
+ * @param[in]  content_type service type - service data connector plugin's id described in sync-agent-framework config file
+ * @param[in]  feature feature provided data connector plugin
+ * @return Operation result
+ * @retval 1 support
+ * @retval 0 not support
+ * @retval -1 error
+ */
+int da_get_is_support_service_feature(int content_type, int feature);
+
+/**
+ *     @}
+ */
+
+#endif                         /* SERVICE_INTERNAL_H_ */
diff --git a/src/framework/device-manager/interface.c b/src/framework/device-manager/interface.c
new file mode 100755 (executable)
index 0000000..1ae311e
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_alloc.h"
+#include "device-manager/interface.h"
+#include "device-manager/interface_internal.h"
+#include "device-manager/mdm_error.h"
+#include "device-manager/mdm_control_code.h"
+#include "device-manager/mdm_type.h"
+#include "plugin/device_manager_plugin.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MDM"
+#endif
+
+EXPORT_API sync_agent_dm_mdm_return_e sync_agent_start_mdm_service(int mdm_plugin_id, char *pkgName)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pkgName == NULL, SYNC_AGENT_DM_MDM_FAILED, "pkgName is NULL !!");
+
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_start_service_cb func_point_start_service = plugin_get_function_start_service(mdm_plugin_id);
+
+       retvm_if(func_point_start_service == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_start_service_cb !!");
+
+       res = func_point_start_service(pkgName);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_dm_mdm_return_e sync_agent_stop_mdm_service(int mdm_plugin_id, char *pkgName)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pkgName == NULL, SYNC_AGENT_DM_MDM_FAILED, "pkgName is NULL !!");
+
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_stop_service_cb func_point_stop_service = plugin_get_function_stop_service(mdm_plugin_id);
+
+       retvm_if(func_point_stop_service == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_stop_service_cb !!");
+
+       res = func_point_stop_service(pkgName);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_dm_mdm_return_e sync_agent_set_mdm_value(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       va_list va;
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_set_device_manager_value_cb func_point_set_device_manager_value = plugin_get_function_set_device_manager_value(mdm_plugin_id);
+
+       retvm_if(func_point_set_device_manager_value == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_set_device_manager_value_cb !!");
+
+       va_start(va, ctrl);
+       res = func_point_set_device_manager_value(ctrl, va);
+       va_end(va);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_dm_mdm_return_e sync_agent_get_mdm_value(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       va_list va;
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_get_device_manager_value_cb func_point_get_device_manager_value = plugin_get_function_get_device_manager_value(mdm_plugin_id);
+
+       retvm_if(func_point_get_device_manager_value == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_get_device_manager_value_cb !!");
+
+       va_start(va, ctrl);
+       res = func_point_get_device_manager_value(ctrl, va);
+       va_end(va);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_dm_mdm_return_e sync_agent_execute_mdm(int mdm_plugin_id, sync_agent_dm_mdm_ctrl_e ctrl, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       va_list va;
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_execute_device_manager_cb func_point_execute_device_manager = plugin_get_function_execute_device_manager(mdm_plugin_id);
+
+       retvm_if(func_point_execute_device_manager == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_execute_device_manager_cb !!");
+
+       va_start(va, ctrl);
+       res = func_point_execute_device_manager(ctrl, va);
+       va_end(va);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int dm_register_mdm_callback(int mdm_plugin_id, sync_agent_dm_mdm_event_e event, sync_agent_device_manager_cb callback, void *userdata)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_register_device_manager_callback_cb func_point_register_device_manager_callback = plugin_get_function_register_device_manager_callback(mdm_plugin_id);
+
+       retvm_if(func_point_register_device_manager_callback == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_device_manager_register_callback_cb !!");
+
+       res = func_point_register_device_manager_callback(event, callback, userdata);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_dm_mdm_return_e dm_register_deregister_mdm_callback(int mdm_plugin_id, int handle)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mdm_return_e res = SYNC_AGENT_DM_MDM_SUCCEEDED;
+
+       plugin_deregister_device_manager_callback_cb func_point_deregister_device_manager_callback = plugin_get_function_deregister_device_manager_callback(mdm_plugin_id);
+
+       retvm_if(func_point_deregister_device_manager_callback == NULL, SYNC_AGENT_DM_MDM_FAILED, "cannot get plugin_device_manager_deregister_callback_cb !!");
+
+       res = func_point_deregister_device_manager_callback(handle);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
diff --git a/src/framework/device-manager/interface_internal.h b/src/framework/device-manager/interface_internal.h
new file mode 100755 (executable)
index 0000000..24c32d6
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_MANAGER_INTERFACE_INTERNAL_H_
+#define DEVICE_MANAGER_INTERFACE_INTERNAL_H_
+
+//#include "mdm_control_code.h"
+//#include "mdm_error.h"
+//#include "mdm_type.h"
+#include "device-manager/interface.h"
+
+/**
+ * @file               interface_internal.h
+ * @brief      Defines device manager APIS
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * @brief Register mdm callback function
+ * @remarks not supported api
+ * @param[in] mdm_plugin_id mdm plugin id
+ * @param[in] event service event
+ * @param[in] callback user callback function
+ * @param[in] userdata additional user data
+ * @return Operation result
+ * @retval 1 success
+ * @retval 0 error
+ */
+int dm_register_mdm_callback(int mdm_plugin_id, sync_agent_dm_mdm_event_e event, sync_agent_device_manager_cb callback, void *userdata);
+
+/**
+ * @brief Register mdm callback function
+ * @remarks not supported api
+ * @param[in] mdm_plugin_id mdm plugin id
+ * @param[in] handle
+ * @return Operation result
+ * @retval SYNC_AGENT_DM_MDM_SUCCEEDED success
+ * @retval SYNC_AGENT_DM_MDM_PERMISSION_DENIED permission denied, error
+ * @retval SYNC_AGENT_DM_MDM_FAILED error
+ * @retval SYNC_AGENT_DM_MDM_UNSUPPORTED unsupported feature, error
+ */
+sync_agent_dm_mdm_return_e dm_register_deregister_mdm_callback(int mdm_plugin_id, int handle);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DEVICE_MANAGER_INTERFACE_INTERNAL_H_ */
diff --git a/src/framework/device-manager/mo_accessor.c b/src/framework/device-manager/mo_accessor.c
new file mode 100755 (executable)
index 0000000..1f17a89
--- /dev/null
@@ -0,0 +1,2237 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+
+#include "plugin/mo_plugin.h"
+
+#include "data-adapter/common.h"
+
+#include "device-manager/mo_tnds_processor.h"
+#include "device-manager/mo_database_handler.h"
+#include "device-manager/mo_ddf_parser.h"
+#include "device-manager/mo_accessor.h"
+#include "device-manager/mo_accessor_internal.h"
+
+#include "utility/fw_time.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+#define DELIMIT '/'
+
+static int _get_parent_path(const char *mo_pull_path, char **mo_parent_path, char **mo_name);
+
+static sync_agent_dm_mo_node_s *_create_default_mo_node(char *mo_full_path);
+
+static sync_agent_dm_mo_error_e _recursive_get_Descendant_MO_List(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s * parent_node, int *count, sync_agent_dm_mo_get_option_e option);
+
+static char *_get_access_type_string(sync_agent_dm_mo_access_type_e access_type);
+
+static sync_agent_dm_mo_error_e __set_MO_RunTimeProperty(char **server_id_list, int server_id_list_cnt, sync_agent_dm_mo_node_s * mo_node);
+
+static sync_agent_dm_mo_error_e _add_MO_Tree(sync_agent_dm_mo_type_e mo_type, sync_agent_dm_mo_node_s * mo_node, plugin_get_mo_value_cb func_point_get_value, char **server_id_list, int server_id_list_cnt, int server_type);
+
+/* static void __print_Tree(sync_agent_dm_mo_node_s * root_ptr, int depth); // to Debugging */
+
+static int _update_MO_info(sync_agent_dm_mo_node_s * mo_node, int depth, void **arg);
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_open_mo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_open("/opt/dbspace/.momanager.db");
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_close_mo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_close();
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_construct_mo_table(sync_agent_dm_mo_type_e mo_type, const char *vendar_file, int mo_plugin_id, int server_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(vendar_file == NULL, SYNC_AGENT_DM_MO_FAIL, "vendar_file is NULL !!");
+
+       _DEBUG_INFO("vender_file = %s", vendar_file);
+       char *root_node_path = strdup(".");
+
+       sync_agent_dm_mo_node_s *root_node = _create_default_mo_node(root_node_path);
+       if (root_node == NULL) {
+               _DEBUG_INFO("root node null");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+       sync_agent_dm_mo_error_e err_code = dm_mo_construct_mo_tree_ddf(mo_type, vendar_file, root_node);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               return err_code;
+       }
+
+       plugin_get_mo_value_cb func_point_get_value = NULL;
+       func_point_get_value = plugin_get_function_get_mo_value(mo_plugin_id);
+
+       plugin_get_server_id_list_cb func_point_get_server_id_list = NULL;
+       func_point_get_server_id_list = plugin_get_function_get_server_id_list(mo_plugin_id);
+
+       retvm_if(func_point_get_server_id_list == NULL, SYNC_AGENT_DM_MO_FAIL, "cannot get plugin_get_server_id_list_cb !!");
+
+       char **server_id_list = NULL;
+       int server_id_list_cnt = 0;
+       server_id_list = func_point_get_server_id_list(&server_id_list_cnt);
+       _DEBUG_INFO("server_id_list_cnt = %d", server_id_list_cnt);
+
+       err_code = sync_agent_begin_transaction_mo();
+
+       err_code = _add_MO_Tree(mo_type, root_node, func_point_get_value, server_id_list, server_id_list_cnt, server_type);
+
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+       } else {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_begin_transaction_mo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_begin_transaction_wraper();
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_end_transaction_mo(sync_agent_dm_mo_transaction_e transaction)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_transaction_e transation_option;
+
+       if (transaction == SYNC_AGENT_DM_MO_TRANSACTION_COMMIT) {
+               transation_option = SYNC_AGENT_DA_TRANSACTION_COMMIT;
+       } else {
+               transation_option = SYNC_AGENT_DA_TRANSACTION_ROLLBACK;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_end_transaction_wraper(transation_option);
+}
+
+sync_agent_dm_mo_error_e dm_create_mo(sync_agent_dm_mo_node_s ** sync_agent_dm_mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *sync_agent_dm_mo_node = (sync_agent_dm_mo_node_s *) calloc(1, sizeof(sync_agent_dm_mo_node_s));
+       if (*sync_agent_dm_mo_node == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+       (*sync_agent_dm_mo_node)->framework_property = (sync_agent_dm_mo_framework_property_s *) calloc(1, sizeof(sync_agent_dm_mo_framework_property_s));
+       if ((*sync_agent_dm_mo_node)->framework_property == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+       (*sync_agent_dm_mo_node)->runtime_property = (sync_agent_dm_mo_runtime_property_s *) calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s));
+       if ((*sync_agent_dm_mo_node)->runtime_property == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_create_mo_item(sync_agent_dm_mo_node_s ** sync_agent_mo_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_create_mo(sync_agent_mo_item);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_add_mo_item(sync_agent_dm_mo_node_s * sync_agent_mo_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_mo_item == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_add_mo(sync_agent_mo_item->mo_type, sync_agent_mo_item->full_path, sync_agent_mo_item);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_update_mo_item(sync_agent_dm_mo_node_s * sync_agent_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_item == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_update_mo(sync_agent_item->mo_type, sync_agent_item);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_delete_mo_item(const char *mo_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       sync_agent_dm_mo_type_e mo_type = dm_mo_get_mo_type_wraper(mo_path);
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_delete_mo(mo_type, mo_path);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_delete_mo_tree_item(const char *mo_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_delete_mo_tree(mo_path);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_mo_item(const char *mo_path, sync_agent_dm_mo_node_s ** sync_agent_mo_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_get_mo(mo_path, sync_agent_mo_item, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_mo_items(const char *mo_path, sync_agent_dm_mo_node_s ** sync_agent_mo_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_get_mos(mo_path, sync_agent_mo_item, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_query_mo_item(sync_agent_dm_mo_item_s * sync_agent_mo_item, GList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(sync_agent_mo_item == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_item_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       int count = 0;
+       sync_agent_dm_mo_node_s *mo_node_list = NULL;
+
+       if (sync_agent_mo_item->interface_type == MO_ITEM_CHILD_MO_VALUE_LIST) {
+
+               retvm_if(sync_agent_mo_item->mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+               _DEBUG_INFO("mo full path  : %s", sync_agent_mo_item->mo_path);
+               ret = dm_get_child_mo_list(sync_agent_mo_item->mo_type, sync_agent_mo_item->mo_path, &mo_node_list, &count, sync_agent_mo_item->option);
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+               _DEBUG_INFO("get child mo list count : %d", count);
+
+               int i;
+               for (i = 0; i < count; ++i) {
+                       *list = g_list_append(*list, &(mo_node_list[i]));
+               }
+
+               return SYNC_AGENT_DM_MO_SUCCESS;
+
+       } else if (sync_agent_mo_item->interface_type == MO_ONLY_DATA_VALUE) {
+               ret = dm_get_mo(sync_agent_mo_item->mo_path, &mo_node_list, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+
+               *list = g_list_append(*list, mo_node_list);
+
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       } else if (sync_agent_mo_item->interface_type == MO_ALL_VALUE) {
+               ret = dm_get_mo(sync_agent_mo_item->mo_path, &mo_node_list, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+
+               *list = g_list_append(*list, mo_node_list);
+
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_free_mo_item(sync_agent_dm_mo_node_s * sync_agent_mo_item)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (sync_agent_mo_item != NULL) {
+               dm_free_mo(sync_agent_mo_item, 1);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_free_mo_item_list(GList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(list == NULL, SYNC_AGENT_DM_MO_FAIL, "list is NULL !!");
+
+       int count = 0;
+       count = g_list_length(list);
+       _DEBUG_INFO(" mo list length : %d", count);
+       dm_free_mo(list->data, count);
+
+       g_list_free(list);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+sync_agent_dm_mo_error_e dm_add_mo(sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, sync_agent_dm_mo_node_s * mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+       retvm_if(mo_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       _DEBUG_INFO("===============================================");
+       _DEBUG_INFO("sync_agent_dm_mo_type_e  : %d", mo_type);
+       _DEBUG_INFO("mo_full_path  : %s", mo_full_path);
+       _DEBUG_INFO("mo_value  : %s", mo_node->value);
+       _DEBUG_INFO("node type  : %d", mo_node->type);
+       _DEBUG_INFO("===============================================");
+
+       /*
+        * Get Parent Node from MO DB using by mo_parent_path
+        */
+       char *mo_parent_path = NULL;
+       char *mo_name = NULL;
+       int isRootNode = _get_parent_path(mo_full_path, &mo_parent_path, &mo_name);
+       if (isRootNode == -1) {
+               if (mo_parent_path != NULL)
+                       free(mo_parent_path);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (isRootNode) {
+               _DEBUG_INFO("is root node");
+               /*
+                * Add MO Node to MO DB
+                */
+               err = dm_mo_add_node_wraper(SYNC_AGENT_DM_MO_TYPE_NO_TYPE, mo_node);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed dm_mo_add_node_wraper() : [%d]", err);
+                       if (mo_name != NULL)
+                               free(mo_name);
+                       return err;
+               }
+
+               /*
+                * Add MO Properties to MO DB
+                */
+               if (mo_node->framework_property != NULL) {
+                       _DEBUG_INFO("add frameowork_property");
+                       err = dm_mo_add_framework_property_wraper(mo_node->id, mo_node->framework_property);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed dm_mo_add_framework_property_wraper() : [%d]", err);
+                       }
+               }
+
+               if (mo_node->runtime_property != NULL) {
+                       _DEBUG_INFO("add runtime_property");
+                       err = dm_mo_add_runtime_property_wraper(mo_node->id, mo_node->runtime_property);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed dm_mo_add_runtime_property_wraper() : [%d]", err);
+                       }
+               }
+
+               if (mo_name != NULL)
+                       free(mo_name);
+
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       }
+
+       _DEBUG_INFO("mo_parent_path : %s", mo_parent_path);
+       _DEBUG_INFO("mo_name : %s", mo_name);
+
+       sync_agent_dm_mo_node_s *mo_parent_node = NULL;
+       sync_agent_dm_mo_node_s *real_mo_parent_node = NULL;
+       err = dm_get_mos(mo_parent_path, &mo_parent_node, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       _DEBUG_INFO("get mo : %d", err);
+
+       real_mo_parent_node = mo_parent_node;
+       if (real_mo_parent_node == NULL) {
+               /*
+                * Create Parent MO Node (Default MO Node)
+                */
+               _DEBUG_INFO("parent node empty");
+               real_mo_parent_node = _create_default_mo_node(mo_parent_path);
+
+               err = dm_add_mo(SYNC_AGENT_DM_MO_TYPE_NO_TYPE, mo_parent_path, real_mo_parent_node);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       if (mo_name != NULL)
+                               free(mo_name);
+                       return err;
+               }
+       } else {
+               while (real_mo_parent_node != NULL) {
+                       _DEBUG_INFO("parent_node id : %d", real_mo_parent_node->id);
+                       _DEBUG_INFO("parent_node mo type : %d", real_mo_parent_node->mo_type);
+                       _DEBUG_INFO("parent_node server type : %d", real_mo_parent_node->server_type);
+                       _DEBUG_INFO("mo server type : %d", mo_node->server_type);
+
+                       if (real_mo_parent_node->server_type == mo_node->server_type) {
+                               _DEBUG_INFO("mo server type : %d", mo_node->server_type);
+                               break;
+                       }
+                       _DEBUG_INFO("this node is not parent node");
+                       real_mo_parent_node = real_mo_parent_node->next_node;
+               }
+
+               if (real_mo_parent_node == NULL) {
+                       real_mo_parent_node = mo_parent_node;
+               }
+       }
+
+       mo_node->name = mo_name;
+       mo_node->parent_id = real_mo_parent_node->id;
+       mo_node->mo_type = real_mo_parent_node->mo_type;
+
+       _DEBUG_INFO("mo_name : %s", mo_node->name);
+       _DEBUG_INFO("mo_parent_id : %d", mo_node->parent_id);
+       _DEBUG_INFO("node type : %d", mo_node->type);
+       _DEBUG_INFO("mo type : %d", mo_node->mo_type);
+
+       /*
+        * Add MO Node to MO DB
+        */
+       err = dm_mo_add_node_wraper(mo_node->mo_type, mo_node);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_add_node_wraper() : [%d]", err);
+               dm_free_mo(mo_parent_node, 1);
+               return err;
+       }
+
+       /*
+        * Add MO Properties to MO DB
+        */
+       if (mo_node->framework_property != NULL) {
+               _DEBUG_INFO("add frameowork_property  %d", mo_node->id);
+               err = dm_mo_add_framework_property_wraper(mo_node->id, mo_node->framework_property);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed dm_mo_add_framework_property_wraper() : [%d]", err);
+               }
+       }
+
+       if (mo_node->runtime_property != NULL) {
+               _DEBUG_INFO("add runtime_property %d", mo_node->id);
+               err = dm_mo_add_runtime_property_wraper(mo_node->id, mo_node->runtime_property);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed dm_mo_add_runtime_property_wraper() : [%d]", err);
+               }
+       }
+
+       _DEBUG_INFO("mo_parent_node->id : %d", real_mo_parent_node->id);
+       _DEBUG_INFO("mo_node->id : %d", mo_node->id);
+       _DEBUG_INFO("================================================");
+
+       dm_free_mo(mo_parent_node, 1);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_delete_mo(sync_agent_dm_mo_type_e type, const char *mo_full_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       _DEBUG_INFO("mo_full_path  : %s", mo_full_path);
+
+       sync_agent_dm_mo_node_s *target_node = NULL;
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+       err_code = dm_get_mo(mo_full_path, &target_node, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       _DEBUG_INFO("get mo : %d", err_code);
+       if (target_node == NULL) {
+               _DEBUG_INFO("MO is not existed [%s]", mo_full_path);
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       }
+
+       /*
+        * Delete All Child Nodes(Recursive)
+        */
+       if (target_node->type == SYNC_AGENT_DM_MO_NODE_INTERIOR || target_node->type == SYNC_AGENT_DM_MO_NODE_ROOT || target_node->type == SYNC_AGENT_DM_MO_NODE_FIRST) {
+               /*
+                * Get all right Child Node list
+                */
+               sync_agent_dm_mo_node_s *child_node_list = NULL;
+               int child_node_count = 0;
+               err_code = dm_get_child_mo_list(type, mo_full_path, &child_node_list, &child_node_count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+               _DEBUG_INFO("get child mo list result  : %d", err_code);
+               _DEBUG_INFO("child_node_count  : %d", child_node_count);
+
+               if (child_node_list != NULL) {
+                       int i = 0;
+                       for (; i < child_node_count; i++) {
+                               char *child_node_path = child_node_list[i].full_path;
+                               err_code = dm_delete_mo(type, child_node_path);
+                               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("delete mo tree: [%d]", err_code);
+                                       dm_free_mo(target_node, 1);
+                                       return SYNC_AGENT_DM_MO_FAIL;
+                               }
+                       }
+               }
+
+               dm_free_mo(child_node_list, child_node_count);
+       } else {
+               _DEBUG_INFO("leaf node");
+       }
+
+       /*
+        * Delete sync_agent_dm_mo_node_s, MO Properties In MO DB using by mo_node_id
+        */
+       _DEBUG_INFO("target_node->id : %d", target_node->id);
+
+       err_code = dm_mo_delete_node_wraper(target_node->id);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to call dm_mo_delete_node_wraper [%d]", err_code);
+       }
+
+       err_code = dm_mo_delete_runtime_property_wraper(target_node->id);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to call dm_mo_delete_runtime_property_wraper [%d]", err_code);
+       }
+
+       err_code = dm_mo_delete_framework_property_wraper(target_node->id);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to call dm_mo_delete_framework_property_wraper [%d]", err_code);
+       }
+
+       dm_free_mo(target_node, 1);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_delete_mo_tree(const char *mo_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_FAIL;
+       sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+       sync_agent_dm_mo_node_s *mo_parent_node = NULL;
+       int is_exist = 0;
+
+       err = sync_agent_is_exist_mo(mo_path, &is_exist);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("remove dm_acc fail, is existed mo fail");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (is_exist != 1) {
+               _DEBUG_ERROR("remove dm_acc fail because dm acc %s not existed", mo_path);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_NOT_EXIST_NODE;
+       }
+
+       err = sync_agent_get_mo_items(mo_path, &sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("remove dm_acc fail, get mo ite fail");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (sync_agent_mo_item->type == SYNC_AGENT_DM_MO_NODE_FIRST) {
+
+               /*first node */
+               sync_agent_dm_mo_node_s *iter = NULL;
+               int i = 0;
+
+               err = dm_delete_mo(sync_agent_mo_item->mo_type, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("free mo tree: [%d]", err);
+               }
+
+               for (iter = sync_agent_mo_item; iter != NULL; iter = iter->next_node, i++) {
+                       _DEBUG_INFO("mo_node id : %d", iter->id);
+
+                       _DEBUG_INFO("prent id : %d ", iter->parent_id);
+                       err = dm_mo_delete_node_wraper(iter->parent_id);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("delete mo  tree: [%d]", err);
+                               goto error;
+                       }
+
+                       err = dm_mo_delete_runtime_property_wraper(iter->parent_id);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to call dm_mo_delete_runtime_property_wraper [%d]", err);
+                               goto error;
+                       }
+
+                       err = dm_mo_delete_framework_property_wraper(iter->parent_id);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to call dm_mo_delete_framework_property_wraper [%d]", err);
+                               goto error;
+                       }
+               }
+
+       } else if (sync_agent_mo_item->type == SYNC_AGENT_DM_MO_NODE_ROOT) {
+
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_DMACC, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_DEVINFO, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_DEVDETAIL, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_FUMO, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_LAWMO, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+               err = dm_delete_mo(SYNC_AGENT_DM_MO_TYPE_SCOMO, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+
+       } else {
+               /*not root node, first node */
+
+               err = dm_delete_mo(sync_agent_mo_item->mo_type, sync_agent_mo_item->full_path);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("delete mo tree: [%d]", err);
+                       goto error;
+               }
+
+               _DEBUG_INFO("prent id : %d ", sync_agent_mo_item->parent_id);
+               err = dm_mo_get_node_from_id_wraper(sync_agent_mo_item->parent_id, &mo_parent_node);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_parent mo: [%d]", err);
+                       goto error;
+               }
+
+               while (1) {
+
+                       int parent_id = 0;
+                       parent_id = mo_parent_node->parent_id;
+
+                       if (mo_parent_node->type == SYNC_AGENT_DM_MO_NODE_ROOT || mo_parent_node->type == SYNC_AGENT_DM_MO_NODE_FIRST) {
+
+                               err = dm_mo_delete_node_wraper(mo_parent_node->id);
+                               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("delete mo  tree: [%d]", err);
+                                       goto error;
+                               }
+
+                               err = dm_mo_delete_runtime_property_wraper(mo_parent_node->id);
+                               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to call dm_mo_delete_runtime_property_wraper [%d]", err);
+                                       goto error;
+                               }
+
+                               err = dm_mo_delete_framework_property_wraper(mo_parent_node->id);
+                               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to call dm_mo_delete_framework_property_wraper [%d]", err);
+                                       goto error;
+                               }
+
+                               if (mo_parent_node->type == SYNC_AGENT_DM_MO_NODE_ROOT) {
+                                       err = sync_agent_free_mo_item(mo_parent_node);
+                                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                                               _DEBUG_ERROR("free mo  tree: [%d]", err);
+                                               goto error;
+                                       } else {
+                                               _DEBUG_INFO("free mo success");
+                                       }
+
+                                       break;
+                               }
+
+                       } else {
+                               _DEBUG_INFO("first node path : %s", mo_parent_node->full_path);
+                               err = dm_delete_mo(mo_parent_node->mo_type, mo_parent_node->full_path);
+                               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("free mo tree: [%d]", err);
+                                       goto error;
+                               }
+                       }
+
+                       err = sync_agent_free_mo_item(mo_parent_node);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("free mo  tree: [%d]", err);
+                               goto error;
+                       } else {
+                               _DEBUG_INFO("free mo success");
+                       }
+
+                       mo_parent_node = NULL;
+
+                       _DEBUG_INFO("prent id : %d ", parent_id);
+                       err = dm_mo_get_node_from_id_wraper(parent_id, &mo_parent_node);
+                       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to dm_mo_get_parent mo: [%d]", err);
+                               goto error;
+                       }
+               }
+       }
+
+       err = sync_agent_free_mo_item(sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("free mo  tree: [%d]", err);
+               goto error;
+       } else {
+               _DEBUG_INFO("free mo success");
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return err;
+
+ error:
+
+       err = sync_agent_free_mo_item(sync_agent_mo_item);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("free mo  tree: [%d]", err);
+       } else {
+               _DEBUG_INFO("free mo success");
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+sync_agent_dm_mo_error_e dm_update_mo(sync_agent_dm_mo_type_e type, const sync_agent_dm_mo_node_s * mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+       _DEBUG_INFO("sync_agent_dm_mo_type_e  : %d", type);
+       _DEBUG_INFO("node_id  : %d", mo_node->id);
+       _DEBUG_INFO("will be updated full_path  : %s", mo_node->full_path);
+
+       /*
+        * Update MO Node tbl
+        */
+       err_code = dm_mo_update_node_wraper(type, mo_node->full_path, mo_node);
+
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_update_node_wraper() : %d", err_code);
+               return err_code;
+       }
+
+       /*
+        * Update Framework property tbl
+        */
+       if (mo_node->framework_property != NULL) {
+               err_code = dm_mo_update_framework_property_wraper(mo_node->id, mo_node->framework_property);
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed dm_mo_update_framework_property_wraper() : %d", err_code);
+               }
+       }
+
+       /*
+        * Update Runtime property tbl
+        */
+       if (mo_node->runtime_property != NULL) {
+               err_code = dm_mo_update_runtime_property_wraper(mo_node->id, mo_node->runtime_property);
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed dm_mo_update_runtime_property_wraper() : %d", err_code);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+sync_agent_dm_mo_error_e dm_get_child_mo_list(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s ** mo_node_list, int *count, sync_agent_dm_mo_get_option_e option)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _DEBUG_INFO("mo_path : %s", mo_path);
+
+       sync_agent_dm_mo_error_e err_code = dm_mo_get_child_node_wraper(type, mo_path, mo_node_list, count);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_child_node_wraper : [%d]", err_code);
+               _EXTERN_FUNC_EXIT;
+               return err_code;
+       }
+
+       if (option == SYNC_AGENT_DM_MO_GET_OPTION_NODE) {
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       }
+
+       /*
+        * todo Set Property to node list
+        */
+       int i = 0;
+       for (; i < *count; i++) {
+               err_code = dm_mo_get_framework_property_wraper((*mo_node_list)[i].id, &((*mo_node_list)[i].framework_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_framework_property_wraper : [%d]", err_code);
+               }
+               err_code = dm_mo_get_runtime_property_wraper((*mo_node_list)[i].id, &((*mo_node_list)[i].runtime_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_runtime_property_wraper : [%d]", err_code);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_descendant_mo_tree(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s ** root_node, int *count, sync_agent_dm_mo_get_option_e option)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       sync_agent_dm_mo_error_e err_code = dm_get_mo(mo_path, root_node, option);
+       _DEBUG_INFO("mo_path : %s", mo_path);
+       /*
+        * Recursive Call
+        */
+       err_code = _recursive_get_Descendant_MO_List(type, mo_path, *root_node, count, option);
+       _DEBUG_INFO("get_decendant mo list : %d", err_code);
+       /* __print_Tree(*root_node); */
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+sync_agent_dm_mo_error_e dm_get_mo(const char *mo_path, sync_agent_dm_mo_node_s ** mo_node, sync_agent_dm_mo_get_option_e option)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _DEBUG_INFO("mo_path : %s", mo_path);
+
+       sync_agent_dm_mo_error_e err_code = dm_mo_get_node_wraper(mo_path, mo_node);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_node_wraper : [%d]", err_code);
+               return err_code;
+       }
+
+       if (*mo_node == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (option == SYNC_AGENT_DM_MO_GET_OPTION_ALL) {
+               err_code = dm_mo_get_framework_property_wraper((*mo_node)->id, &((*mo_node)->framework_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_framework_property_wraper : [%d]", err_code);
+                       goto error;
+               } else {
+                       _DEBUG_INFO("dm_mo_get_framework_property_wraper success");
+               }
+               err_code = dm_mo_get_runtime_property_wraper((*mo_node)->id, &((*mo_node)->runtime_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_runtime_property_wraper : [%d]", err_code);
+                       goto error;
+               } else {
+                       _DEBUG_INFO("dm_mo_get_runtime_property_wraper success");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+ error:
+       return err_code;
+}
+
+sync_agent_dm_mo_error_e dm_get_mos(const char *mo_path, sync_agent_dm_mo_node_s ** mo_node, sync_agent_dm_mo_get_option_e option)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _DEBUG_INFO("mo_path : %s", mo_path);
+
+       sync_agent_dm_mo_error_e err_code = dm_mo_get_nodes_wraper(mo_path, mo_node);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_node_wraper : [%d]", err_code);
+               return err_code;
+       }
+
+       if (*mo_node == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (option == SYNC_AGENT_DM_MO_GET_OPTION_ALL) {
+
+               sync_agent_dm_mo_node_s *iter = NULL;
+               int i = 0;
+               iter = *mo_node;
+
+               for (iter = *mo_node; iter != NULL; iter = iter->next_node, i++) {
+                       _DEBUG_INFO("mo_node id : %d", iter->id);
+                       err_code = dm_mo_get_framework_property_wraper(iter->id, &(iter->framework_property));
+                       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to dm_mo_get_framework_property_wraper : [%d]", err_code);
+                               goto error;
+                       } else {
+                               _DEBUG_INFO("dm_mo_get_framework_property_wraper success");
+                       }
+                       err_code = dm_mo_get_runtime_property_wraper(iter->id, &(iter->runtime_property));
+                       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to dm_mo_get_runtime_property_wraper : [%d]", err_code);
+                               goto error;
+                       } else {
+                               _DEBUG_INFO("dm_mo_get_runtime_property_wraper success");
+                       }
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+ error:
+       return err_code;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_is_exist_mo(const char *mo_path, int *is_exist)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       _DEBUG_INFO("mo_path : %s", mo_path);
+
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       err_code = dm_mo_is_exist_node_wraper(mo_path);
+       _DEBUG_INFO("is exist node : %d", err_code);
+       if (err_code == SYNC_AGENT_DM_MO_EXIST_NODE) {
+               *is_exist = 1;
+       } else if (err_code == SYNC_AGENT_DM_MO_NOT_EXIST_NODE) {
+               *is_exist = 0;
+       } else {
+               _DEBUG_ERROR("dm_mo_is_exist_node_wraper() FAIL !!!");
+               *is_exist = 0;
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+void dm_free_mo(sync_agent_dm_mo_node_s * mo_node, int count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("free mo node start");
+       if ((mo_node) != NULL && count > 0) {
+               int i = 0;
+               for (i = 0; i < count; ++i) {
+
+                       if ((mo_node[i]).name != NULL) {
+                               free((mo_node[i]).name);
+                       }
+                       if ((mo_node[i]).value != NULL) {
+                               free((mo_node[i]).value);
+                       }
+                       if ((mo_node[i]).full_path != NULL) {
+                               free((mo_node[i]).full_path);
+                       }
+                       if ((mo_node[i]).runtime_property != NULL) {
+                               if ((mo_node[i]).runtime_property->acl != NULL) {
+                                       free((mo_node[i]).runtime_property->acl);
+                               }
+                               if ((mo_node[i]).runtime_property->name != NULL) {
+                                       free((mo_node[i]).runtime_property->name);
+                               }
+                               if ((mo_node[i]).runtime_property->size != NULL) {
+                                       free((mo_node[i]).runtime_property->size);
+                               }
+                               if ((mo_node[i]).runtime_property->title != NULL) {
+                                       free((mo_node[i]).runtime_property->title);
+                               }
+                               if ((mo_node[i]).runtime_property->tStamp != NULL) {
+                                       free((mo_node[i]).runtime_property->tStamp);
+                               }
+                               if ((mo_node[i]).runtime_property->type_value != NULL) {
+                                       free((mo_node[i]).runtime_property->type_value);
+                               }
+                               if ((mo_node[i]).runtime_property->verNo != NULL) {
+                                       free((mo_node[i]).runtime_property->verNo);
+                               }
+                       }
+                       if ((mo_node[i]).framework_property != NULL) {
+                               if ((mo_node[i]).framework_property->defaultValue != NULL) {
+                                       free((mo_node[i]).framework_property->defaultValue);
+                               }
+                               if ((mo_node[i]).framework_property->description != NULL) {
+                                       free((mo_node[i]).framework_property->description);
+                               }
+                               if ((mo_node[i]).framework_property->dfTitle != NULL) {
+                                       free((mo_node[i]).framework_property->dfTitle);
+                               }
+                               if ((mo_node[i]).framework_property->dfType_Value != NULL) {
+                                       free((mo_node[i]).framework_property->dfType_Value);
+                               }
+                       }
+                       if ((mo_node[i]).child_node_list != NULL) {
+                               dm_free_mo((mo_node[i]).child_node_list, (mo_node[i]).child_node_cnt);
+                       }
+                       if ((mo_node[i]).next_node != NULL) {
+                               dm_free_mo((mo_node[i]).next_node, 1);
+                       }
+               }
+
+               free(mo_node);
+       }
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_traverse_mo_tree_preorder(sync_agent_dm_mo_node_s * root_ptr, sync_agent_mo_worker_cb func_ptr, int depth, int err_stop, void **arg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(root_ptr == NULL, -1, "root_ptr is NULL !!");
+
+       _DEBUG_INFO("[%d] mo_node name : %s", depth, root_ptr->name);
+
+       int ret = 0;
+
+       if (depth != 0) {
+               ret = func_ptr(root_ptr, depth, arg);
+               if (ret != -1 && err_stop != 0) {
+                       return ret;
+               }
+       }
+
+       int i = 0;
+       for (; i < root_ptr->child_node_cnt; i++) {
+               ret = sync_agent_traverse_mo_tree_preorder(&(root_ptr->child_node_list[i]), func_ptr, depth + 1, err_stop, arg);
+               if (ret != -1 && err_stop != 0) {
+                       return ret;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+/******************************************* TNDS ******************************************/
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_export_tnds_stream(sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char **output_stream, unsigned int *byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int node_count = 0;
+       sync_agent_dm_mo_error_e err;
+
+       err = sync_agent_get_descendant_mo_tree(mo_type, mo_full_path, &root_node, &node_count, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+       _DEBUG_INFO("get decendant mo list : %d", err);
+
+       sync_agent_dm_mo_error_e mo_error = dm_get_tnds_from_db(tnds_type, root_node, output_stream, byte_size);
+       _DEBUG_INFO("get tnds mo list : %d", mo_error);
+       dm_free_mo(root_node, 1);
+
+       _EXTERN_FUNC_EXIT;
+
+       return mo_error;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_import_tnds_stream(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char *input_stream, unsigned int byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_insert_tnds_to_db(tnds_action, tnds_type, mo_type, mo_full_path, input_stream, byte_size);
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_delete_all_mo_table()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e err_code = sync_agent_begin_transaction_mo();
+
+       err_code = dm_mo_delete_all_node_wraper();
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+               return err_code;
+       }
+
+       err_code = dm_mo_delete_all_framework_property_wraper();
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+               return err_code;
+       }
+
+       err_code = dm_mo_delete_all_runtime_property_wraper();
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+       } else {
+               sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err_code;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_mo_type(const char *mo_full_path, sync_agent_dm_mo_type_e * mo_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       *mo_type = dm_mo_get_mo_type_wraper(mo_full_path);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_get_acl_value(const char *mo_full_path, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       sync_agent_dm_mo_node_s *iter = NULL;
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+       if (!strcmp(mo_full_path, ".")) {
+               err_code = dm_mo_get_node_wraper(mo_full_path, mo_node);
+       } else {
+               /* get nodes */
+               err_code = dm_mo_get_nodes_wraper(mo_full_path, mo_node);
+
+       }
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_node_wraper : [%d]", err_code);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+       retvm_if(*mo_node == NULL, SYNC_AGENT_DM_MO_NOT_EXIST_NODE, "mo_node is NULL !!");
+
+       int i = 0;
+       for (iter = (*mo_node); iter != NULL; iter = iter->next_node) {
+               _DEBUG_INFO("iter mo count : %d", i++);
+
+               err_code = dm_mo_get_runtime_property_wraper(iter->id, &(iter->runtime_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_runtime_property_wraper : [%d]", err_code);
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+
+               err_code = dm_mo_get_framework_property_wraper(iter->id, &(iter->framework_property));
+               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                       _DEBUG_ERROR("Failed to dm_mo_get_framework_property_wraper : [%d]", err_code);
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+
+               if (iter->runtime_property != NULL && iter->runtime_property->acl != NULL) {
+                       _DEBUG_INFO("mo node id : %d", iter->id);
+                       _DEBUG_INFO("mo node acl : %s", iter->runtime_property->acl);
+                       _DEBUG_INFO("current node_acl");
+                       continue;
+               } else {
+                       sync_agent_dm_mo_node_s *mo_parent_node = NULL;
+
+                       err_code = dm_mo_get_node_from_id_wraper(iter->parent_id, &mo_parent_node);
+                       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to dm_mo_get_parent mo: [%d]", err_code);
+                               return SYNC_AGENT_DM_MO_FAIL;
+                       }
+                       int parent_id = -1;
+
+                       while (mo_parent_node != NULL) {
+
+                               err_code = dm_mo_get_runtime_property_wraper(mo_parent_node->id, &(mo_parent_node->runtime_property));
+                               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to dm_mo_get_runtime_property_wraper : [%d]", err_code);
+                               }
+
+                               if (mo_parent_node->runtime_property != NULL && mo_parent_node->runtime_property->acl != NULL) {
+                                       _DEBUG_INFO("current node_acl");
+
+                                       iter->runtime_property = (sync_agent_dm_mo_runtime_property_s *) calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s));
+                                       if (iter->runtime_property == NULL) {
+                                               _DEBUG_ERROR("alloc fail");
+
+                                               dm_free_mo(mo_parent_node, 1);
+                                               mo_parent_node = NULL;
+
+                                               return SYNC_AGENT_DM_MO_FAIL;
+                                       }
+
+                                       iter->runtime_property->acl = strdup(mo_parent_node->runtime_property->acl);
+                                       dm_free_mo(mo_parent_node, 1);
+                                       mo_parent_node = NULL;
+                                       break;
+                               } else {
+                                       _DEBUG_INFO("parent node_acl null");
+                               }
+
+                               parent_id = mo_parent_node->parent_id;
+
+                               dm_free_mo(mo_parent_node, 1);
+                               mo_parent_node = NULL;
+                               if (parent_id == -1) {
+                                       _DEBUG_INFO("root node get acl");
+                                       break;
+                               }
+
+                               err_code = dm_mo_get_node_from_id_wraper(parent_id, &mo_parent_node);
+                               if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to dm_mo_get_parent mo: [%d]", err_code);
+
+                                       dm_free_mo(mo_parent_node, 1);
+                                       mo_parent_node = NULL;
+
+                                       return SYNC_AGENT_DM_MO_FAIL;
+                               }
+                       }
+               }
+       }
+       _EXTERN_FUNC_EXIT;
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+/*
+ * check_acl = 0 : not permission acl
+ * check_acl = 1 : not have accesstype
+ * check_acl = 2 : permission acl
+ */
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_check_acl_value(const char *mo_full_path, sync_agent_dm_mo_access_type_e access_type, const char *server_id, int *check_acl)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (mo_full_path == NULL || server_id == NULL || access_type == SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET) {
+               _DEBUG_INFO("mo_full_path == NULL || acl_value == NULL || access_type == SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET\n");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *mo_node = NULL;
+       sync_agent_dm_mo_node_s *iter = NULL;
+       char *mo_acl_value = NULL;
+       int isSearch_value = 0;
+       int isExist_all = 0;
+       char *mo_server_id = NULL;
+       int server_id_length = 0;
+       char *ptr_sev_id = NULL;
+
+       /* get acl value */
+       err_code = dm_get_acl_value(mo_full_path, &mo_node);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               *check_acl = 0;
+               goto return_part;
+       }
+
+       if (mo_node == NULL) {
+               _DEBUG_INFO("command_str is NULL");
+               *check_acl = 0;
+               err_code = SYNC_AGENT_DM_MO_FAIL;
+               goto return_part;
+       }
+
+       /*check accecctype error */
+       _DEBUG_INFO("check accesstype : %d", access_type);
+
+       if (mo_node->framework_property != NULL) {
+               _DEBUG_INFO("framework accesstype : %d", mo_node->framework_property->accessType);
+
+               if ((mo_node->framework_property->accessType != SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET) && (mo_node->framework_property->accessType & access_type) != access_type) {
+
+                       *check_acl = 1;
+                       goto return_part;
+               }
+       }
+
+       for (iter = mo_node; iter != NULL; iter = iter->next_node) {
+               _DEBUG_INFO("check mo node acl iter\n");
+               if (iter->runtime_property == NULL || iter->runtime_property->acl == NULL) {
+                       _DEBUG_INFO("mo_acl_value is NULL\n");
+                       *check_acl = 2;
+                       err_code = SYNC_AGENT_DM_MO_SUCCESS;
+                       goto return_part;
+               }
+
+               mo_acl_value = iter->runtime_property->acl;
+
+               _DEBUG_INFO("ALC : %s\n", mo_acl_value);
+
+               if (isSearch_value == 2) {
+                       isSearch_value = 1;
+                       _DEBUG_INFO("acl ok \n");
+               } else {
+                       _DEBUG_INFO("mo_acl_value = %s\n", mo_acl_value);
+                       _DEBUG_INFO("access_type = %d\n", access_type);
+
+                       char *command_str = NULL;
+                       command_str = _get_access_type_string(access_type);
+                       if (command_str == NULL) {
+                               _DEBUG_INFO("command_str is NULL");
+                               *check_acl = 0;
+                               err_code = SYNC_AGENT_DM_MO_FAIL;
+                               goto return_part;
+                       }
+
+                       /* search acl command and server_id */
+                       char *ptr_cmd = strstr(mo_acl_value, command_str);
+                       while (ptr_cmd != NULL) {
+
+                               _DEBUG_INFO("########## Operation Start ###########");
+                               _DEBUG_INFO("ptr_cmd = %s\n", ptr_cmd);
+                               ptr_cmd += strlen(command_str);
+
+                               _DEBUG_INFO("ptr_cmd = %s\n", ptr_cmd);
+                               ptr_sev_id = strstr(ptr_cmd, "&");
+
+                               if (ptr_sev_id != NULL) {
+                                       server_id_length = strlen(ptr_cmd) - strlen(ptr_sev_id - 1) + 1;
+                                       _DEBUG_INFO("ptr_sev_id = %s\n", ptr_sev_id);
+                               } else {
+                                       _DEBUG_INFO("ptr_sev_id = %s\n", ptr_cmd);
+                                       server_id_length = strlen(ptr_cmd);
+                               }
+
+                               _DEBUG_INFO("server_id_length = %d\n", server_id_length);
+                               mo_server_id = (char *)calloc(server_id_length + 1, sizeof(char));
+                               if (mo_server_id == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       *check_acl = 0;
+                                       err_code = SYNC_AGENT_DM_MO_FAIL;
+                                       goto return_part;
+                               }
+                               strncpy(mo_server_id, ptr_cmd, server_id_length);
+                               _DEBUG_INFO("[ mo_server_id = %s ]\n", mo_server_id);
+
+                               if (strcmp(mo_server_id, server_id) == 0) {
+                                       _DEBUG_INFO("====> Search ACL Server_id");
+                                       isSearch_value = 2;
+                                       break;
+                               } else if (strcmp(mo_server_id, "*") == 0) {
+                                       _DEBUG_INFO("Exist All Format");
+                                       isExist_all = 1;
+                               }
+
+                               /* prepare next value check */
+                               if (ptr_sev_id != NULL)
+                                       ptr_cmd = strstr(ptr_sev_id, command_str);
+                               else
+                                       ptr_cmd = NULL;
+
+                               if (mo_server_id != NULL) {
+                                       free(mo_server_id);
+                                       mo_server_id = NULL;
+                               }
+                       }
+               }
+       }
+
+       if (mo_server_id != NULL) {
+               free(mo_server_id);
+               mo_server_id = NULL;
+       }
+
+       if (mo_node != NULL)
+               dm_free_mo(mo_node, 1);
+
+       if (isSearch_value == 0) {
+
+               if (isExist_all == 1) {
+                       _DEBUG_INFO("##############################>>>>>> Search Value => exist * format !!");
+                       *check_acl = 2;
+
+                       _EXTERN_FUNC_EXIT;
+
+                       return err_code;
+               } else {
+                       _DEBUG_INFO("##############################>>>>>> Not Search Value ");
+                       *check_acl = 0;
+
+                       _EXTERN_FUNC_EXIT;
+
+                       return err_code;
+               }
+
+       } else {
+               _DEBUG_INFO("##############################>>>>>> Search Value !!");
+               *check_acl = 2;
+
+               _EXTERN_FUNC_EXIT;
+
+               return err_code;
+       }
+
+ return_part:
+
+       if (mo_node != NULL)
+               dm_free_mo(mo_node, 1);
+       _EXTERN_FUNC_EXIT;
+       return err_code;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_create_mo_acc_item(sync_agent_dm_acc_info_s ** acc_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *acc_info = (sync_agent_dm_acc_info_s *) calloc(1, sizeof(sync_agent_dm_acc_info_s));
+       if (*acc_info == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e 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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e mo_error = SYNC_AGENT_DM_MO_SUCCESS;
+
+       const char *server_id_string = "ServerID";
+       const char *acc_type_string = 0;
+
+       if (sync_agent_mo_acc_info_item == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _DEBUG_INFO("get acc info : %d ", sync_agent_mo_acc_info_item->acc_type);
+       _DEBUG_INFO("get acc info : %s ", sync_agent_mo_acc_info_item->serverid);
+
+       switch (sync_agent_mo_acc_info_item->acc_type) {
+       case DEVICE_MANAGE_ACC_TYPE_SERVER:
+               acc_type_string = "/ServerAppAuth/";
+               break;
+       case DEVICE_MANAGE_ACC_TYPE_CLIENT:
+               acc_type_string = "/ClientAppAuth/";
+               break;
+       }
+
+       /*sync_agent_dm_acc_info_s *acc_info = NULL; */
+       mo_error = dm_mo_get_acc_info_wraper(sync_agent_mo_acc_info_item->serverid, server_id_string, acc_type_string, acc_info);
+
+       if (mo_error != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_acc_info_wraper()");
+               return mo_error;
+       }
+
+       if (*acc_info != NULL) {
+               _DEBUG_INFO("auth_name : %s", (*acc_info)->auth_name);
+               _DEBUG_INFO("auth_secret : %s", (*acc_info)->auth_secret);
+               _DEBUG_INFO("auth_data : %s", (*acc_info)->auth_data);
+               _DEBUG_INFO("auth_type : %s", (*acc_info)->auth_type);
+               _DEBUG_INFO("auth_level : %s", (*acc_info)->auth_level);
+               _DEBUG_INFO("addr : %s\n", (*acc_info)->addr);
+       } else {
+               _DEBUG_INFO("\nacc_info is NULL!!\n");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return mo_error;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_update_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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e mo_error = SYNC_AGENT_DM_MO_SUCCESS;
+       const char *server_id_string = "ServerID";
+       const char *acc_type_string = NULL;
+
+       if (sync_agent_mo_acc_info_item == NULL) {
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       switch (sync_agent_mo_acc_info_item->acc_type) {
+       case DEVICE_MANAGE_ACC_TYPE_SERVER:
+               acc_type_string = "/ServerAppAuth/";
+               break;
+       case DEVICE_MANAGE_ACC_TYPE_CLIENT:
+               acc_type_string = "/ClientAppAuth/";
+               break;
+       }
+
+       mo_error = dm_mo_set_acc_info_wraper(sync_agent_mo_acc_info_item->serverid, server_id_string, acc_type_string, acc_info);
+
+       if (mo_error != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_get_acc_info_wraper()");
+               return mo_error;
+       }
+
+       if (acc_info != NULL) {
+               _DEBUG_INFO("\nauth_name : %s", acc_info->auth_name);
+               _DEBUG_INFO("auth_secret : %s", acc_info->auth_secret);
+               _DEBUG_INFO("auth_data : %s", acc_info->auth_data);
+               _DEBUG_INFO("auth_type : %s", acc_info->auth_type);
+               _DEBUG_INFO("auth_level : %s", acc_info->auth_level);
+               _DEBUG_INFO("addr : %s", acc_info->addr);
+       } else {
+               _DEBUG_INFO("\nacc_info is NULL!!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return mo_error;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_free_mo_acc_item(sync_agent_dm_acc_info_s ** acc_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if ((*acc_info) != NULL) {
+               if ((*acc_info)->addr != NULL) {
+                       free((*acc_info)->addr);
+                       (*acc_info)->addr = NULL;
+               }
+               if ((*acc_info)->auth_data != NULL) {
+                       free((*acc_info)->auth_data);
+                       (*acc_info)->auth_data = NULL;
+               }
+               if ((*acc_info)->auth_level != NULL) {
+                       free((*acc_info)->auth_level);
+                       (*acc_info)->auth_level = NULL;
+               }
+               if ((*acc_info)->auth_name != NULL) {
+                       free((*acc_info)->auth_name);
+                       (*acc_info)->auth_name = NULL;
+               }
+               if ((*acc_info)->auth_secret != NULL) {
+                       free((*acc_info)->auth_secret);
+                       (*acc_info)->auth_secret = NULL;
+               }
+               if ((*acc_info)->auth_type != NULL) {
+                       free((*acc_info)->auth_type);
+                       (*acc_info)->auth_type = NULL;
+               }
+               (*acc_info) = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_uptodate_mo_table(sync_agent_dm_mo_type_e mo_type, int mo_plugin_id, char *mo_root)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_root == NULL, SYNC_AGENT_DM_MO_FAIL, "uptodate mo root NULL !!");
+
+       _DEBUG_INFO("mo_type : %d", mo_type);
+
+       sync_agent_dm_mo_node_s *root_node = NULL;
+       int count = 0;
+       sync_agent_dm_mo_error_e err;
+       err = sync_agent_get_descendant_mo_tree(mo_type, mo_root, &root_node, &count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+       _DEBUG_INFO("get decendant mo list : %d", err);
+
+       plugin_get_mo_value_cb func_point_get_value = NULL;
+       _DEBUG_INFO("PLUGIN ID : %d", mo_plugin_id);
+       func_point_get_value = plugin_get_function_get_mo_value(mo_plugin_id);
+
+       sync_agent_traverse_mo_tree_preorder(root_node, _update_MO_info, 0, 0, (void **)(&func_point_get_value));
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_serverinfo(sync_agent_dm_server_info_s ** server_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+       const char *server_id_string = "ServerID";
+
+       err = dm_mo_get_server_id_list_wraper(server_id_string, server_info);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_INFO("get server id list : %d", err);
+               return err;
+       }
+
+       _DEBUG_INFO("get server id list result : %d", err);
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_free_serverinfo(sync_agent_dm_server_info_s * server_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (server_info != NULL) {
+               if (server_info->server_id != NULL) {
+                       free(server_info->server_id);
+                       server_info->server_id = NULL;
+               }
+               if (server_info->next != NULL) {
+                       sync_agent_free_serverinfo(server_info->next);
+                       server_info->next = NULL;
+               }
+
+               free(server_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_serverid(sync_agent_dm_mo_type_e mo_type, char **server_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("mo_type : %d", mo_type);
+
+       const char *server_id_string = "ServerID";
+
+       sync_agent_dm_server_info_s *head_ptr = NULL;
+       dm_mo_get_server_id_list_wraper(server_id_string, &head_ptr);
+
+       sync_agent_dm_server_info_s *cursor_ptr = head_ptr;
+
+       while (cursor_ptr != NULL) {
+               _DEBUG_INFO("server_id : %s", cursor_ptr->server_id);
+               _DEBUG_INFO("server_type : %d", cursor_ptr->server_type);
+
+               int result = mo_type & (cursor_ptr->server_type);
+
+               if (result == mo_type) {
+                       _DEBUG_INFO("corrected");
+                       *server_id = g_strdup(cursor_ptr->server_id);
+                       sync_agent_free_serverinfo(head_ptr);
+                       return SYNC_AGENT_DM_MO_SUCCESS;
+               }
+
+               cursor_ptr = cursor_ptr->next;
+       }
+
+       sync_agent_free_serverinfo(head_ptr);
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_root_path(const char *mo_full_path, char **root_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       err_code = dm_mo_get_root_path_wraper(mo_full_path, root_path);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_get_root_path_wraper() : [%d]", err_code);
+               return SYNC_AGENT_DM_MO_FAIL;
+       } else {
+               _DEBUG_INFO("Successed dm_mo_get_root_path_wraper() : [%s]", *root_path);
+
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_get_server_type(const char *server_id, int *server_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if((server_id) == NULL, SYNC_AGENT_DM_MO_FAIL, "server_id is NULL!!");
+
+       _DEBUG_INFO("server_id : %s", server_id);
+       const char *server_id_string = "ServerID";
+
+       sync_agent_dm_server_info_s *head_ptr = NULL;
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       err_code = dm_mo_get_server_id_list_wraper(server_id_string, &head_ptr);
+
+       if (err_code != SYNC_AGENT_DM_MO_FAIL) {
+               sync_agent_dm_server_info_s *cursor_ptr = head_ptr;
+               while (cursor_ptr != NULL) {
+                       if (cursor_ptr->server_id == NULL) {
+                               *server_type = 0;
+                               sync_agent_free_serverinfo(head_ptr);
+                               return SYNC_AGENT_DM_MO_SUCCESS;
+                       }
+                       _DEBUG_INFO("server_id : %s", cursor_ptr->server_id);
+                       _DEBUG_INFO("server_type : %d", cursor_ptr->server_type);
+
+                       if (!strcmp(cursor_ptr->server_id, server_id)) {
+                               _DEBUG_INFO("corrected server_id : %s", server_id);
+                               *server_type = cursor_ptr->server_type;
+                               sync_agent_free_serverinfo(head_ptr);
+                               return SYNC_AGENT_DM_MO_SUCCESS;
+                       }
+                       cursor_ptr = cursor_ptr->next;
+               }
+       } else {
+
+               *server_type = 0;
+               sync_agent_free_serverinfo(head_ptr);
+               _EXTERN_FUNC_EXIT;
+
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       *server_type = 0;
+
+       sync_agent_free_serverinfo(head_ptr);
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_initialize_mo(int mo_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_initialize func_point_initialize = NULL;
+       func_point_initialize = plugin_get_function_initialize(mo_plugin_id);
+
+       if (func_point_initialize != NULL) {
+               int result = func_point_initialize();
+               if (result != 1) {
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+       } else {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+/******************************** static function implement **********************************/
+
+int _update_MO_info(sync_agent_dm_mo_node_s * mo_node, int depth, void **arg)
+{
+       _INNER_FUNC_ENTER;
+
+       if (mo_node == NULL) {
+               _DEBUG_TRACE("mo_node is NULL!!");
+               return -1;
+       }
+
+       _DEBUG_TRACE("mo_node->full_path : %s", mo_node->full_path);
+       _DEBUG_TRACE("mo_node->name : %s", mo_node->name);
+       _DEBUG_TRACE("mo_node->value : %s", mo_node->value);
+
+       plugin_get_mo_value_cb func_point_get_value = (plugin_get_mo_value_cb) (*arg);
+
+       if (func_point_get_value != NULL) {
+               func_point_get_value(mo_node->full_path, mo_node->name, &(mo_node->value));
+               _DEBUG_TRACE("Be Called func_point_get_value();");
+
+               dm_update_mo(mo_node->mo_type, mo_node);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+/******************************************************** Impl static function *************************************************************/
+
+static int _get_parent_path(const char *mo_pull_path, char **mo_parent_path, char **mo_name)
+{
+       _INNER_FUNC_ENTER;
+
+       int mo_pull_path_len = strlen(mo_pull_path);
+
+       char *last_delimit = strrchr(mo_pull_path, DELIMIT);
+
+       /*
+        * Is Root Node
+        */
+       if (last_delimit == NULL) {
+               *mo_name = (char *)calloc(mo_pull_path_len + 1, sizeof(char));
+               if (*mo_name == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return -1;
+               }
+               strncpy(*mo_name, mo_pull_path, mo_pull_path_len);
+               return 1;
+       }
+
+       int name_len = strlen(last_delimit);
+       int parent_path_len = mo_pull_path_len - name_len;
+
+       *mo_parent_path = (char *)calloc(parent_path_len + 1, sizeof(char));
+       if (*mo_parent_path == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return -1;
+       }
+       *mo_name = (char *)calloc(name_len, sizeof(char));
+       if (*mo_name == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return -1;
+       }
+
+       strncpy(*mo_parent_path, mo_pull_path, parent_path_len);
+       strncpy(*mo_name, last_delimit + 1, name_len);
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static sync_agent_dm_mo_node_s *_create_default_mo_node(char *mo_full_path)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_mo_node_s *mo_node = (sync_agent_dm_mo_node_s *) calloc(1, sizeof(sync_agent_dm_mo_node_s));
+       if (mo_node == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+
+       char *mo_parent_path = NULL;
+       char *mo_name = NULL;
+       int ret = _get_parent_path(mo_full_path, &mo_parent_path, &mo_name);
+       if (ret == -1) {
+               dm_free_mo(mo_node, 1);
+
+               if (mo_parent_path != NULL)
+                       free(mo_parent_path);
+
+               return NULL;
+       }
+
+       _DEBUG_TRACE("mo_full_path : %s", mo_full_path);
+       _DEBUG_TRACE("mo_parent_path : %s", mo_parent_path);
+       _DEBUG_TRACE("mo_name : %s", mo_name);
+
+/*     if (mo_parent_path != NULL) {
+               free(mo_parent_path);
+       }*/
+       mo_node->id = -1;
+       mo_node->parent_id = -1;
+       mo_node->name = mo_name;
+       mo_node->full_path = mo_full_path;
+       mo_node->value = NULL;
+
+       if (mo_parent_path == NULL) {
+               mo_node->type = SYNC_AGENT_DM_MO_NODE_ROOT;
+               _DEBUG_TRACE("------------------root node-----------------");
+       } else {
+               mo_node->type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+       }
+       mo_node->framework_property = (sync_agent_dm_mo_framework_property_s *) calloc(1, sizeof(sync_agent_dm_mo_framework_property_s));
+       if (mo_node->framework_property == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               dm_free_mo(mo_node, 1);
+               if (mo_parent_path != NULL)
+                       free(mo_parent_path);
+
+               return NULL;
+       }
+       mo_node->runtime_property = (sync_agent_dm_mo_runtime_property_s *) calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s));
+       if (mo_node->runtime_property == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               dm_free_mo(mo_node, 1);
+               if (mo_parent_path != NULL)
+                       free(mo_parent_path);
+
+               return NULL;
+       }
+
+       if (mo_node->type == SYNC_AGENT_DM_MO_NODE_ROOT) {
+               mo_node->framework_property->dffFormat = SYNC_AGENT_DM_MO_FORMAT_NODE;
+               mo_node->framework_property->accessType = SYNC_AGENT_DM_MO_ACCESSTYPE_ADD | SYNC_AGENT_DM_MO_ACCESSTYPE_GET;
+               mo_node->runtime_property->acl = strdup("Get=*&Add=*");
+               mo_node->runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_NODE;
+               mo_node->runtime_property->name = strdup(".");
+               _DEBUG_TRACE("root node acl :%s , root node format : %d root node name : %s", mo_node->runtime_property->acl, mo_node->runtime_property->format, mo_node->runtime_property->name);
+       }
+
+       if (mo_parent_path != NULL)
+               free(mo_parent_path);
+
+       _INNER_FUNC_EXIT;
+
+       return mo_node;
+}
+
+static sync_agent_dm_mo_error_e _recursive_get_Descendant_MO_List(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s * parent_node, int *acc_count, sync_agent_dm_mo_get_option_e option)
+{
+       _INNER_FUNC_ENTER;
+
+       int count = 0;
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       err_code = dm_get_child_mo_list(type, mo_path, &(parent_node->child_node_list), &count, option);
+       _DEBUG_TRACE("get child mo list err_code_ : %d", err_code);
+       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+               return err_code;
+       }
+       parent_node->child_node_cnt = count;
+       *acc_count = *acc_count + count;
+       _DEBUG_TRACE("count : %d", count);
+       _DEBUG_TRACE("acc count : %d", *acc_count);
+       _DEBUG_TRACE("MO PAHT : %s", mo_path);
+
+       if (mo_path) {
+               int i = 0;
+               for (; i < count; i++) {
+                       _DEBUG_TRACE("RJW : %s", parent_node->child_node_list[i].full_path);
+                       err_code = _recursive_get_Descendant_MO_List(type, parent_node->child_node_list[i].full_path, &(parent_node->child_node_list[i]), acc_count, option);
+                       _DEBUG_TRACE("err_code : %d", err_code);
+                       if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+                               break;
+                       }
+               }
+       } else {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return err_code;
+}
+
+static char *_get_access_type_string(sync_agent_dm_mo_access_type_e access_type)
+{
+       _INNER_FUNC_ENTER;
+
+       char *command_str = NULL;
+
+       _DEBUG_TRACE("accessType = %d\n", access_type);
+       switch (access_type) {
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_ADD:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_ADD");
+               command_str = "Add=";
+               break;
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_COPY:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_COPY");
+               command_str = "Copy=";
+               break;
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE");
+               command_str = "Delete=";
+               break;
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC");
+               command_str = "Exec=";
+               break;
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_GET:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_GET");
+               command_str = "Get=";
+               break;
+       case SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE:
+               _DEBUG_TRACE("SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE");
+               command_str = "Replace=";
+               break;
+       default:
+               _DEBUG_TRACE("can not execute logic");
+               break;
+       }
+       _DEBUG_TRACE("command string = %s\n", command_str);
+
+       _INNER_FUNC_EXIT;
+
+       return command_str;
+}
+
+static sync_agent_dm_mo_error_e __set_MO_RunTimeProperty(char **server_id_list, int server_id_list_cnt, sync_agent_dm_mo_node_s * mo_node)
+{
+       _INNER_FUNC_ENTER;
+
+       if (mo_node == NULL || server_id_list == NULL) {
+               _DEBUG_ERROR("mo_node == 0 || server_id_list == 0\n");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       sync_agent_dm_mo_framework_property_s *framework_property = mo_node->framework_property;
+       sync_agent_dm_mo_runtime_property_s *runtime_property = mo_node->runtime_property;
+
+       /* set format, type, type value, title property for framework property */
+       runtime_property->format = framework_property->dffFormat;
+       runtime_property->type = framework_property->dfType;
+
+       _DEBUG_VERBOSE("FP[dffFormat = %d], RT[format = %d]", framework_property->dffFormat, runtime_property->format);
+       _DEBUG_VERBOSE("FP[dfType = %d], RT[type = %d]", framework_property->dfType, runtime_property->type);
+
+       if (framework_property->dfType_Value != NULL) {
+               runtime_property->type_value = strdup(framework_property->dfType_Value);
+               _DEBUG_VERBOSE("FP[dfType_Value = %s], RT[type_value = %s]", framework_property->dfType_Value, runtime_property->type_value);
+       }
+
+       if (framework_property->dfTitle != NULL) {
+               runtime_property->title = strdup(framework_property->dfTitle);
+               _DEBUG_VERBOSE("FP[dfTitle = %s], RT[title = %s]", framework_property->dfTitle, runtime_property->title);
+       }
+
+       /* set name for mo_node */
+       if (mo_node->name != NULL) {
+               runtime_property->name = strdup(mo_node->name);
+               _DEBUG_VERBOSE("mo_name[name = %s], RT[name = %s]", mo_node->name, runtime_property->name);
+       }
+
+       /* set version No, size */
+       runtime_property->verNo = strdup("0");
+       runtime_property->size = 0;
+
+       /* set stamp */
+       SYNC_AGENT_UTIL_TIME_T current_time;
+       SYNC_AGENT_UTIL_TIME(&current_time);
+
+       SYNC_AGENT_UTIL_TM *time;
+       time = SYNC_AGENT_UTIL_LOCALTIME(&current_time);
+
+       _DEBUG_VERBOSE("year = %d, mon = %d, day = %d, hour = %d, min = %d, sec = %d", time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
+
+       runtime_property->tStamp = g_strdup_printf("%04d%02d%02dT%02d%02d%02dZ", time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_hour, time->tm_min, time->tm_sec);
+       _DEBUG_VERBOSE("RT[tStamp = %s]", runtime_property->tStamp);
+
+       /* set ACL */
+       if (runtime_property->acl != NULL) {
+               /*aready this is setted runtime property acl */
+               _INNER_FUNC_EXIT;
+               return SYNC_AGENT_DM_MO_SUCCESS;
+       }
+
+       int total_acl_size = 0;
+       if (server_id_list_cnt > 0) {
+
+               int i, j;
+               for (i = 0; i < server_id_list_cnt; i++) {
+                       if (server_id_list[i] == NULL) {
+                               _DEBUG_ERROR("server_id_list[%d] == NULL", i);
+                               return SYNC_AGENT_DM_MO_FAIL;
+                       }
+                       _DEBUG_VERBOSE("server_id_list[%d] = %s, length = %d", i, server_id_list[i], strlen(server_id_list[i]));
+                       total_acl_size += ((10 * DEVICE_MANAGER_MO_ACCESSTYPE_CNT) + strlen(server_id_list[i]));
+               }
+
+               char *total_acl_value = (char *)calloc(total_acl_size, sizeof(char));
+               if (total_acl_value == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return SYNC_AGENT_DM_MO_FAIL;
+               }
+               int total_acl_value_idx = 0;
+
+               sync_agent_dm_mo_access_type_e access_type = SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET;
+               char *command_str = NULL;
+
+               int temp_acl_value_size = 0;
+               char *temp_acl_value = NULL;
+
+               int mul = 1;
+               for (i = 1; i <= DEVICE_MANAGER_MO_ACCESSTYPE_CNT; i++) {
+
+                       _DEBUG_VERBOSE("framework_property->accessType = %d\n", framework_property->accessType);
+                       if (framework_property->accessType != SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET) {
+
+                               access_type = framework_property->accessType & (mul);
+                               _DEBUG_VERBOSE("accessType = %d\n", access_type);
+                               command_str = _get_access_type_string(access_type);
+
+                               if (command_str != NULL) {
+                                       for (j = 0; j < server_id_list_cnt; j++) {
+
+                                               _DEBUG_VERBOSE("server_id_list[%d] = %s", j, server_id_list[j]);
+                                               if (i == DEVICE_MANAGER_MO_ACCESSTYPE_CNT && j == server_id_list_cnt - 1) {
+                                                       temp_acl_value = g_strdup_printf("%s%s", command_str, server_id_list[j]);
+                                               } else {
+                                                       temp_acl_value = g_strdup_printf("%s%s&", command_str, server_id_list[j]);
+                                               }
+
+                                               temp_acl_value_size = strlen(temp_acl_value);
+
+                                               _DEBUG_VERBOSE("temp_acl_value = %s\n", temp_acl_value);
+                                               memcpy(total_acl_value + total_acl_value_idx, temp_acl_value, temp_acl_value_size);
+                                               total_acl_value_idx += temp_acl_value_size;
+                                       }
+                               }
+                       } else {
+                               break;
+                       }
+
+                       mul *= 2;
+               }
+
+               _DEBUG_VERBOSE("total_acl_value = %s\n", total_acl_value);
+               runtime_property->acl = total_acl_value;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static sync_agent_dm_mo_error_e _add_MO_Tree(sync_agent_dm_mo_type_e mo_type, sync_agent_dm_mo_node_s * mo_node, plugin_get_mo_value_cb func_point_get_value, char **server_id_list, int server_id_list_cnt, int server_type)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+
+       if (mo_node == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _DEBUG_TRACE("[%s] [%s] [%d] [%d]", mo_node->name, mo_node->full_path, mo_node->type, mo_node->child_node_cnt);
+       _DEBUG_TRACE("[%d] [%s] [%d] [%d] [%d] [%s] [%d]", mo_node->framework_property->accessType, mo_node->framework_property->description, mo_node->framework_property->dffFormat, mo_node->framework_property->occurrence,
+                    mo_node->framework_property->scope, mo_node->framework_property->dfTitle, mo_node->framework_property->dfType);
+       _DEBUG_TRACE("================================================================================");
+
+       /*
+        * Setting acl of RuntimeProperty in PlugIn
+        */
+
+       /*
+        * Set MO Value from PlugIn
+        */
+       if (func_point_get_value != NULL) {
+               func_point_get_value(mo_node->full_path, mo_node->name, &(mo_node->value));
+               _DEBUG_TRACE("mo value [%s] ", mo_node->value);
+       }
+
+       mo_node->server_type = server_type;
+       err = dm_mo_add_node_wraper(mo_type, mo_node);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_add_node_wraper() : [%d]", err);
+               return err;
+       }
+       err = dm_mo_add_framework_property_wraper(mo_node->id, mo_node->framework_property);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_add_framework_property_wraper() : [%d]", err);
+               return err;
+       }
+
+       _DEBUG_TRACE("set_mo_run Start");
+       err = __set_MO_RunTimeProperty(server_id_list, server_id_list_cnt, mo_node);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed __set_MO_RunTimeProperty() : [%d]", err);
+               return err;
+       }
+
+       _DEBUG_TRACE("set_mo_run ENd");
+       err = dm_mo_add_runtime_property_wraper(mo_node->id, mo_node->runtime_property);
+       if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed dm_mo_add_runtime_property_wraper() : [%d]", err);
+               return err;
+       }
+
+       sync_agent_dm_mo_node_s *pCursor = mo_node->child_node_list;
+       while (pCursor != NULL) {
+               pCursor->parent_id = mo_node->id;
+
+               err = _add_MO_Tree(mo_type, pCursor, func_point_get_value, server_id_list, server_id_list_cnt, server_type);
+               if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+                       return err;
+               }
+
+               pCursor = pCursor->next_node;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+}
+
+/*
+static void __print_Tree(sync_agent_dm_mo_node_s * root_ptr, int depth)
+{
+       if (root_ptr == NULL) {
+               return;
+       }
+//      int i = 0;
+//      for ( ; i < depth; i++) {
+//              _DEBUG_INFO("\t");
+//      }
+       _DEBUG_INFO("[%s] [%s] [%d] [%d]", root_ptr->name, root_ptr->full_path, root_ptr->type, root_ptr->child_node_cnt);
+       _DEBUG_INFO("[%d] [%s] [%d] [%d] [%d] [%s] [%d]", root_ptr->framework_property->accessType, root_ptr->framework_property->description, root_ptr->framework_property->dffFormat, root_ptr->framework_property->occurrence, root_ptr->framework_property->scope, root_ptr->framework_property->dfTitle, root_ptr->framework_property->dfType);
+       _DEBUG_INFO("================================================================================");
+
+       sync_agent_dm_mo_node_s *pCursor = root_ptr->child_node_list;
+       while (pCursor != NULL) {
+               __print_Tree(pCursor, depth + 1);
+               pCursor = pCursor->next_node;
+       }
+}
+*/
diff --git a/src/framework/device-manager/mo_accessor_internal.h b/src/framework/device-manager/mo_accessor_internal.h
new file mode 100755 (executable)
index 0000000..9133de3
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_ACCESSOR_INTERNAL_H_
+#define MO_ACCESSOR_INTERNAL_H_
+
+#include "device-manager/mo_accessor.h"
+
+/**
+ * @file       mo_accessor_internal.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * API to create mo
+ * @remarks MO is oma-dm's management object.
+ *
+ * @par Usage:
+ *
+ * @param[out] sync_agent_mo_item created mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need mo creation.
+ * @post new mo node struct is created.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_create_mo_item(sync_agent_dm_mo_node_s **sync_agent_mo_item);
+ *
+ */
+sync_agent_dm_mo_error_e dm_create_mo(sync_agent_dm_mo_node_s ** sync_agent_dm_mo_node);
+
+/**
+ * API to add mo
+ * @remarks mo node add to dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in] sync_agent_mo_item node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server add command or factory bootstrap
+ * @post new mo node struct is added in dm agent db
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_add_mo_item (sync_agent_dm_mo_node_s *sync_agent_mo_item);
+ *
+ */
+sync_agent_dm_mo_error_e dm_add_mo(sync_agent_dm_mo_type_e type, const char *mo_full_path, sync_agent_dm_mo_node_s * mo_node);
+
+/**
+ * API to update mo
+ * @remarks mo node update dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in] sync_agent_mo_item node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server replace command.
+ * @post mo node in dm agent db struct is updated
+ *
+ * @par Since:
+ *
+ *
+ * @see replace_mo( char *mo_full_path, char *value, char *prop_value, char *contenttype, char * format, GetType prop_type)
+ *
+ */
+sync_agent_dm_mo_error_e dm_update_mo(sync_agent_dm_mo_type_e type, const sync_agent_dm_mo_node_s * mo_node);
+
+/**
+ * API to delete mo
+ * @remarks mo node delete dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_path mo node full path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server delete command.
+ * @post mo node in dm agent db is deleted.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_delete_mo_item (const char * mo_path);
+ *
+ */
+sync_agent_dm_mo_error_e dm_delete_mo(sync_agent_dm_mo_type_e type, const char *mo_full_path);
+
+/**
+ * API to delete mo tree
+ * @remarks mo tree delete dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_path mo node full path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server delete command.
+ * @post mo tree in dm agent db is deleted.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_delete_mo_item (const char * mo_path);
+ *
+ */
+sync_agent_dm_mo_error_e dm_delete_mo_tree(const char *mo_path);
+
+/**
+ * API to get mo
+ * @remarks mo node get dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in]  mo_path mo node full path
+ * @param[out] sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post new mo node struct in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_mo_item (const char * mo_path, sync_agent_dm_mo_node_s **sync_agent_mo_item);
+ *
+ */
+sync_agent_dm_mo_error_e dm_get_mo(const char *mo_path, sync_agent_dm_mo_node_s ** mo_node, sync_agent_dm_mo_get_option_e option);
+
+/**
+ * API to get mos
+ * @remarks mo nodes get dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in]  mo_path mo node full path
+ * @param[out] sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post new mo node structs in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_mo_items (const char * mo_path, sync_agent_dm_mo_node_s **sync_agent_mo_item);
+ *
+ */
+sync_agent_dm_mo_error_e dm_get_mos(const char *mo_path, sync_agent_dm_mo_node_s ** mo_node, sync_agent_dm_mo_get_option_e option);
+
+/**
+ * API to get mo item list
+ * @remarks mo node list get dm-agent's in db
+ *
+ * @par Usage:
+ *
+ * @param[in]  sync_agent_mo_item mo node struct
+ * @param[out] list sync_agent_mo_item in list
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if server get command.
+ * @post mo node structs list in dm agent db is getted.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_query_mo_item (sync_agent_dm_mo_item_s *sync_agent_mo_query, GList** list);
+ *
+ */
+sync_agent_dm_mo_error_e dm_get_child_mo_list(sync_agent_dm_mo_type_e type, const char *mo_path, sync_agent_dm_mo_node_s ** mo_node_list, int *count, sync_agent_dm_mo_get_option_e option);
+
+/**
+ * API to free mo
+ * @remarks mo node struct is distroyed
+ *
+ * @par Usage:
+ *
+ * @param[in]  sync_agent_mo_item mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need free mo struct
+ * @post mo node struct list is destroyed.
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_free_mo_item (sync_agent_dm_mo_node_s *sync_agent_mo_item);
+ *
+ */
+void dm_free_mo(sync_agent_dm_mo_node_s * mo_node, int count);
+
+/**
+ * API to Check mo acl
+ * @remarks This function is use to check mo acl
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_full_path mo node path
+ * @param[in] access_type receive command type by server
+ * @param[in] server_id server id
+ * @param[out] check_acl check acl flag true, false
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need check for check mo acl
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see  _receive_get_cmd(Session *session, Command *command)
+ *
+ */
+sync_agent_dm_mo_error_e dm_get_acl_value(const char *mo_full_path, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ *     @}
+ */
+
+#endif                         /* MO_ACCESSOR_INTERNAL_H_ */
diff --git a/src/framework/device-manager/mo_database.c b/src/framework/device-manager/mo_database.c
new file mode 100755 (executable)
index 0000000..e5d6850
--- /dev/null
@@ -0,0 +1,1756 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_alloc.h"
+#include "device-manager/mo_database_handler.h"
+#include "device-manager/mo_database.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+/* static function define */
+static int _busy_handler(void *pData, int count);
+static sync_agent_dm_mo_error_e _query_exec(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, char *err_msg);
+static daci_stmt _query_prepare(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, int size);
+static sync_agent_da_return_e _stmt_bind_text(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index, const char *value);
+static sync_agent_dm_mo_error_e _stmt_bind_int(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index, const int value);
+static sync_agent_dm_mo_error_e __stmt_bind_null(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index);
+static sync_agent_da_return_e _stmt_step(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt);
+static sync_agent_dm_mo_error_e _stmt_finalize(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt);
+static char *_stmt_column_text(daci_stmt stmt, int index);
+static int _stmt_column_int(daci_stmt stmt, int index);
+static sync_agent_dm_mo_error_e _get_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, char ***result, int *row_count, int *col_count);
+static void _free_table(char **result);
+
+static int _exist_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *table_name);
+static int _last_insert_id(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+static char *_extract_dmacc_name(const char *mo_full_path);
+
+static char *__create_table[] = {
+       /* 1. create node_tbl */
+       "create table node_tbl "
+           "( " "node_id integer primary key autoincrement, " "name varchar(100) not null, " "value varchar(100) default null, " "parent_node_id integer default null, " "full_path varchar(200) not null, " "node_type integer not null, "
+           "mo_type integer not null, " "server_type integer default null, " "constraint node_tbl_parent_node_id_fk foreign key(parent_node_id) references node_tbl(node_id), " "constraint node_tbl_unique_key unique(full_path, mo_type, server_type) " ");",
+
+       /* 2. create framework_property_tbl */
+       "create table framework_property_tbl "
+           "( "
+           "framework_property_id integer primary key autoincrement, "
+           "access_type integer default null, "
+           "default_value varchar(100) default null, " "description varchar(100) default null, " "df_format integer default null, " "occurrence integer default null, " "occurrence_num integer default null, " "scope integer default null, "
+           "df_title varchar(100) default null, " "df_type integer default null, " "df_type_value varchar(20) default null, " "node_id integer not null unique, "
+           "constraint framework_property_tbl_node_id_fk foreign key(node_id) references node_tbl(node_id) " ");",
+
+       /* 3. create runtime_property_tbl */
+       "create table runtime_property_tbl "
+           "( "
+           "runtime_property_id integer primary key autoincrement, "
+           "acl varchar(100) default null, " "format integer default null, " "name varchar(100) default null, " "size varchar(100) default null, " "title varchar(100) default null, " "t_stamp varchar(100) default null, " "type integer default null, "
+           "type_value varchar(30) default null, " "ver_no varchar(100) default null, " "node_id integer not null unique, " "constraint runtime_property_tbl_node_id_fk foreign key(node_id) references node_tbl(node_id) " ");",
+
+};
+
+sync_agent_dm_mo_error_e dm_mo_begin_transaction(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       ret = _query_exec(mo_handler, "begin immediate", "begin_transaction failed");
+
+/*     if (ret == SYNC_AGENT_DA_ERR_QUERY_FAILED)
+               ret = SYNC_AGENT_DA_ERR_TRANSACTION_FAILED;*/
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_end_transaction(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_da_transaction_e transaction)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       char *query = NULL;
+       char *err_msg = NULL;
+
+       if (transaction == SYNC_AGENT_DA_TRANSACTION_COMMIT) {
+               query = "commit transaction";
+               err_msg = "commit_transaction failed";
+       } else if (transaction == SYNC_AGENT_DA_TRANSACTION_ROLLBACK) {
+               query = "rollback transaction";
+               err_msg = "rollback_transaction failed";
+       }
+
+       ret = _query_exec(mo_handler, query, err_msg);
+       if (ret == SYNC_AGENT_DM_MO_FAIL) {
+               if (transaction == SYNC_AGENT_DA_TRANSACTION_COMMIT) {
+                       query = "rollback transaction";
+                       err_msg = "rollback_transaction failed";
+                       ret = _query_exec(mo_handler, query, err_msg);
+                       if (ret == SYNC_AGENT_DM_MO_SUCCESS)
+                               _DEBUG_INFO("rollback_transaction success");
+               }
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e mo_open_agent(SYNC_AGENT_DA_MO_HANDLER ** mo_handler, char *database_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+       char *err_msg = NULL;
+
+       if (*mo_handler == NULL) {
+
+               /* db open */
+               /*  ret = db_util_open(DACI_FILE_PATH, &(*t_daci_handler), 0); */
+
+               ret = sqlite3_open(database_path, mo_handler);
+               if (ret != SQLITE_OK)
+                       goto DACI_FINISH;
+
+               /* register busy handler */
+               ret = sqlite3_busy_handler(*mo_handler, _busy_handler, 0);
+               if (ret != SQLITE_OK) {
+                       _DEBUG_INFO("fail to register busy handler", err_msg);
+                       goto DACI_FINISH;
+               }
+
+               /* enable persist journal mode */
+               ret = sqlite3_exec(*mo_handler, "PRAGMA journal_mode = PERSIST", 0, 0, &err_msg);
+               if (ret != SQLITE_OK) {
+                       _DEBUG_INFO("fail to change journal mode: %s", err_msg);
+                       goto DACI_FINISH;
+               }
+
+               _DEBUG_INFO("mo_db_open success");
+
+       } else {
+               _DEBUG_INFO("mo_db_already opened");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+
+ DACI_FINISH:
+
+       _DEBUG_ERROR("agent_db_open failed(%d) : %s", ret, sqlite3_errmsg(*mo_handler));
+
+       if (err_msg != NULL)
+               sqlite3_free(err_msg);
+
+       sqlite3_close(*mo_handler);
+       *mo_handler = NULL;
+
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+sync_agent_dm_mo_error_e mo_close_agent(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+       ret = sqlite3_close(mo_handler);
+       mo_handler = NULL;
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("mo_db_close failed(%d) : %s", ret, sqlite3_errmsg(mo_handler));
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _DEBUG_INFO("mo_db_close success");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_mo_create_mo_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       if (mo_handler == NULL) {
+               _DEBUG_INFO("[%s] sync_agent_dm_mo_error_e !\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if ((dm_mo_begin_transaction(mo_handler) != SYNC_AGENT_DM_MO_SUCCESS)) {
+               _DEBUG_ERROR("mo_db_default_tbl_create failed");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /* 1. create node_tbl */
+       if (_exist_table(mo_handler, "node_tbl") == 0) {
+               ret = _query_exec(mo_handler, __create_table[0], "node_tbl_create failed");
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 2. create framework_property_tbl */
+       if (_exist_table(mo_handler, "framework_property_tbl") == 0) {
+               ret = _query_exec(mo_handler, __create_table[1], "framework_property_tbl_create failed");
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+       /* 3. create runtime_property_tbl */
+       if (_exist_table(mo_handler, "runtime_property_tbl") == 0) {
+               ret = _query_exec(mo_handler, __create_table[2], "runtime_property_tbl_create failed");
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+               dm_mo_end_transaction(mo_handler, SYNC_AGENT_DA_TRANSACTION_ROLLBACK);
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       } else {
+               ret = dm_mo_end_transaction(mo_handler, SYNC_AGENT_DA_TRANSACTION_COMMIT);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_add_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_dm_mo_type_e mo_type, sync_agent_dm_mo_node_s * mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(mo_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "insert into node_tbl (name, value, parent_node_id, full_path, node_type, mo_type, server_type) values (?, ?, ?, ?, ?, ?, ?)";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+/*     _stmt_bind_int(mo_handler, stmt, 1, mo_node->id);*/
+       _stmt_bind_text(mo_handler, stmt, 1, mo_node->name);
+       _stmt_bind_text(mo_handler, stmt, 2, mo_node->value);
+       _stmt_bind_int(mo_handler, stmt, 3, mo_node->parent_id);
+       _stmt_bind_text(mo_handler, stmt, 4, mo_node->full_path);
+       _stmt_bind_int(mo_handler, stmt, 5, mo_node->type);
+       _stmt_bind_int(mo_handler, stmt, 6, mo_type);
+       _stmt_bind_int(mo_handler, stmt, 7, mo_node->server_type);
+
+       ret = _stmt_step(mo_handler, stmt);
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+               ret = SYNC_AGENT_DM_MO_FAIL;
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+               mo_node->id = -1;
+       } else {
+               mo_node->id = _last_insert_id(mo_handler);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from node_tbl where node_id = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_update_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_dm_mo_type_e mo_type, const char *path, const sync_agent_dm_mo_node_s * mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(mo_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "update node_tbl set value = ? where full_path = ? and mo_type = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_text(mo_handler, stmt, 1, mo_node->value);
+       _stmt_bind_text(mo_handler, stmt, 2, path);
+       _stmt_bind_int(mo_handler, stmt, 3, mo_type);
+
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select * from node_tbl where full_path = ?";
+       sync_agent_dm_mo_node_s *temp_mo_node = NULL;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+
+               _stmt_bind_text(mo_handler, stmt, 1, path);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       temp_mo_node = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_node_s *, sizeof(sync_agent_dm_mo_node_s), 1);
+                       temp_mo_node->id = _stmt_column_int(stmt, 0);
+                       temp_mo_node->name = _stmt_column_text(stmt, 1);
+                       temp_mo_node->value = _stmt_column_text(stmt, 2);
+                       temp_mo_node->parent_id = _stmt_column_int(stmt, 3);
+                       temp_mo_node->full_path = _stmt_column_text(stmt, 4);
+                       temp_mo_node->type = _stmt_column_int(stmt, 5);
+                       temp_mo_node->mo_type = _stmt_column_int(stmt, 6);
+                       temp_mo_node->server_type = _stmt_column_int(stmt, 7);
+                       temp_mo_node->runtime_property = 0;
+                       temp_mo_node->framework_property = 0;
+               } else {
+                       ret = SYNC_AGENT_DM_MO_FAIL;
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       (*mo_node) = temp_mo_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_nodes(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select * from node_tbl where full_path = ?";
+       sync_agent_dm_mo_node_s *current_ptr = NULL;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_text(mo_handler, stmt, 1, path);
+
+               while (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       _DEBUG_INFO("nodes called!!!");
+                       sync_agent_dm_mo_node_s *temp_mo_node = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_node_s *, sizeof(sync_agent_dm_mo_node_s), 1);
+                       if (temp_mo_node == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return SYNC_AGENT_DM_MO_FAIL;
+                       }
+                       temp_mo_node->id = _stmt_column_int(stmt, 0);
+                       temp_mo_node->name = _stmt_column_text(stmt, 1);
+                       temp_mo_node->value = _stmt_column_text(stmt, 2);
+                       temp_mo_node->parent_id = _stmt_column_int(stmt, 3);
+                       temp_mo_node->full_path = _stmt_column_text(stmt, 4);
+                       temp_mo_node->type = _stmt_column_int(stmt, 5);
+                       temp_mo_node->mo_type = _stmt_column_int(stmt, 6);
+                       temp_mo_node->server_type = _stmt_column_int(stmt, 7);
+                       temp_mo_node->runtime_property = 0;
+                       temp_mo_node->framework_property = 0;
+                       if (current_ptr == NULL) {
+                               _DEBUG_INFO("nodes first node!!!");
+                               (*mo_node) = temp_mo_node;
+                               current_ptr = (*mo_node);
+                       } else {
+                               _DEBUG_INFO("nodes next node!!!");
+                               current_ptr->next_node = temp_mo_node;
+                               current_ptr = temp_mo_node;
+                       }
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_is_exist_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(path == NULL, SYNC_AGENT_DM_MO_FAIL, "path is NULL !!");
+
+       _DEBUG_INFO("[%s] Start path : %s\n", __func__, path);
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       int data_count = 0;
+       char query[1024] = { 0, };
+
+       snprintf(query, sizeof(query), "select count(*) from node_tbl where full_path = \'%s\' ", path);
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       data_count = _stmt_column_int(stmt, 0);
+
+               _stmt_finalize(mo_handler, stmt);
+       }
+
+       if (data_count == 0) {
+               ret = SYNC_AGENT_DM_MO_NOT_EXIST_NODE;
+       } else {
+               ret = SYNC_AGENT_DM_MO_EXIST_NODE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_child_node(sync_agent_dm_mo_type_e mo_type, SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node, int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(path == NULL, SYNC_AGENT_DM_MO_FAIL, "path is NULL !!");
+
+       _DEBUG_INFO("[%s] Start ! mopath : %s , mo type : %d\n", __func__, path, mo_type);
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_FAIL; // SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_node_s *temp_mo_node = NULL;
+       char **result = NULL;
+       int row_count = 0;
+       int col_count = 0;
+       int index = 8;
+       int i = 0;
+       char query[SYNC_AGENT_DA_MAX_QUERY_LENGTH] = { 0, };
+
+       if (!strcmp(path, ".")) {
+               snprintf(query, sizeof(query), "select * from node_tbl where parent_node_id in " "(select node_id from node_tbl where full_path = \'%s\')", path);
+               ret = _get_table(mo_handler, query, &result, &row_count, &col_count);
+               if (result == NULL) {
+                       _DEBUG_ERROR("result is NULL!!");
+                       ret = SYNC_AGENT_DM_MO_FAIL;
+                       goto DACI_FINISH;
+               }
+       } else {
+               snprintf(query, sizeof(query), "select * from node_tbl where parent_node_id in " "(select node_id from node_tbl where mo_type = %d and full_path = \'%s\')", mo_type, path);
+               ret = _get_table(mo_handler, query, &result, &row_count, &col_count);
+               if (result == NULL) {
+                       _DEBUG_ERROR("result is NULL!!");
+                       ret = SYNC_AGENT_DM_MO_FAIL;
+                       goto DACI_FINISH;
+               }
+       }
+
+       if ((ret == SYNC_AGENT_DM_MO_SUCCESS) && (row_count != 0)) {
+               *count = row_count;
+               temp_mo_node = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_node_s *, sizeof(sync_agent_dm_mo_node_s), row_count);
+               if (temp_mo_node == NULL) {
+                       _DEBUG_ERROR("memory_allocation failed");
+                       ret = SYNC_AGENT_DM_MO_FAIL;
+                       goto DACI_FINISH;
+               }
+
+               for (i = 0; i < row_count; i++) {
+                       temp_mo_node[i].id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       temp_mo_node[i].name = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       temp_mo_node[i].value = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       temp_mo_node[i].parent_id = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       temp_mo_node[i].full_path = SYNC_AGENT_DA_STRDUP(result[index]);
+                       index++;
+                       temp_mo_node[i].type = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       temp_mo_node[i].mo_type = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+                       temp_mo_node[i].server_type = SYNC_AGENT_DA_ATOI(result[index]);
+                       index++;
+               }
+
+               ret = SYNC_AGENT_DM_MO_SUCCESS;
+               if (result != NULL){
+                       _free_table(result);
+               }
+               (*mo_node) = temp_mo_node;
+               _EXTERN_FUNC_EXIT;
+               return ret;
+       }else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+ DACI_FINISH:
+
+       if (result != NULL){
+               _free_table(result);
+       }
+       //(*mo_node) = temp_mo_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from node_tbl";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_type_e dm_mo_get_mo_type(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *mo_full_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_TYPE_NO_TYPE, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_TYPE_NO_TYPE, "mo_full_path is NULL !!");
+
+       sync_agent_dm_mo_type_e mo_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select mo_type from node_tbl where full_path = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+
+               _stmt_bind_text(mo_handler, stmt, 1, mo_full_path);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       mo_type = _stmt_column_int(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return mo_type;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_node_from_id(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select * from node_tbl where node_id = ?";
+       sync_agent_dm_mo_node_s *temp_mo_node = NULL;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+
+               _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       temp_mo_node = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_node_s *, sizeof(sync_agent_dm_mo_node_s), 1);
+                       temp_mo_node->id = _stmt_column_int(stmt, 0);
+                       temp_mo_node->name = _stmt_column_text(stmt, 1);
+                       temp_mo_node->value = _stmt_column_text(stmt, 2);
+                       temp_mo_node->parent_id = _stmt_column_int(stmt, 3);
+                       temp_mo_node->full_path = _stmt_column_text(stmt, 4);
+                       temp_mo_node->type = _stmt_column_int(stmt, 5);
+                       temp_mo_node->mo_type = _stmt_column_int(stmt, 6);
+                       temp_mo_node->server_type = _stmt_column_int(stmt, 7);
+                       temp_mo_node->runtime_property = 0;
+                       temp_mo_node->framework_property = 0;
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       (*mo_node) = temp_mo_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_acc_info(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s ** acc_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(server_id == NULL, SYNC_AGENT_DM_MO_FAIL, "server id is NULL !!");
+       retvm_if(server_id_string == NULL, SYNC_AGENT_DM_MO_FAIL, "server id string is NULL !!");
+       retvm_if(acc_type_string == NULL, SYNC_AGENT_DM_MO_FAIL, "acc type string is NULL !!");
+
+       _DEBUG_INFO("get acc type string : %s ", acc_type_string);
+       _DEBUG_INFO("get acc server id string : %s ", server_id_string);
+       _DEBUG_INFO("get acc server id : %s ", server_id);
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select full_path from node_tbl where name = ? and value = ? and mo_type = ?";
+       char *full_path = NULL;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+
+               _stmt_bind_text(mo_handler, stmt, 1, server_id_string);
+               _stmt_bind_text(mo_handler, stmt, 2, server_id);
+               _stmt_bind_int(mo_handler, stmt, 3, SYNC_AGENT_DM_MO_TYPE_DMACC);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       full_path = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _DEBUG_INFO("full_path : %s", full_path);
+       if (full_path == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+       /*
+        * Parsing full_path and extract dmacc name
+        */
+       char *dmacc_name = _extract_dmacc_name(full_path);
+       _DEBUG_INFO("dmacc_name : %s", dmacc_name);
+
+       if (dmacc_name == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       *acc_info = (sync_agent_dm_acc_info_s *) calloc(1, sizeof(sync_agent_dm_acc_info_s));
+       if (*acc_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 1. AAuthName
+        */
+       char query01[2048] = { 0, };
+       snprintf(query01, sizeof(query01), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", "AAuthName", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name, acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query01, strlen(query01));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->auth_name = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 2. AAuthSecret
+        */
+       char query02[2048] = { 0, };
+       snprintf(query02, sizeof(query02), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", "AAuthSecret", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name, acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query02, strlen(query02));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->auth_secret = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 3. AAuthLevel
+        */
+       char query03[2048] = { 0, };
+       snprintf(query03, sizeof(query03), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", "AAuthLevel", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name, acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query03, strlen(query03));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->auth_level = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 4. AAuthData
+        */
+       char query04[2048] = { 0, };
+       snprintf(query04, sizeof(query04), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", "AAuthData", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name, acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query04, strlen(query04));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->auth_data = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 5. AAuthType
+        */
+       char query05[2048] = { 0, };
+       snprintf(query05, sizeof(query05), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", "AAuthType", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name, acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query05, strlen(query05));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->auth_type = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 6. Addr
+        */
+       char query06[2048] = { 0, };
+       snprintf(query06, sizeof(query06), "select value from node_tbl where name = '%s' and mo_type = %d and full_path like '\%%%s\%%'", "Addr", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name);
+
+       stmt = _query_prepare(mo_handler, query06, strlen(query06));
+       if (stmt != NULL) {
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       (*acc_info)->addr = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (dmacc_name != NULL) {
+               free(dmacc_name);
+       }
+
+       _DEBUG_INFO("[%s] End !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_set_acc_info(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s * acc_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(server_id == NULL, SYNC_AGENT_DM_MO_FAIL, "server id is NULL !!");
+       retvm_if(server_id_string == NULL, SYNC_AGENT_DM_MO_FAIL, "server id string is NULL !!");
+       retvm_if(acc_type_string == NULL, SYNC_AGENT_DM_MO_FAIL, "acc type string is NULL !!");
+       retvm_if(acc_info == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_acc_info_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       daci_stmt stmt = NULL;
+       char *query = "select full_path from node_tbl where name = ? and value = ? and mo_type = ?";
+       char *full_path = NULL;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+
+               _stmt_bind_text(mo_handler, stmt, 1, server_id_string);
+               _stmt_bind_text(mo_handler, stmt, 2, server_id);
+               _stmt_bind_int(mo_handler, stmt, 3, SYNC_AGENT_DM_MO_TYPE_DMACC);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       full_path = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _DEBUG_INFO("full_path : %s", full_path);
+
+       /*
+        * Parsing full_path and extract dmacc name
+        */
+       char *dmacc_name = _extract_dmacc_name(full_path);
+       _DEBUG_INFO("dmacc_name : %s", dmacc_name);
+
+       if (dmacc_name == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 1. AAuthName
+        */
+       char query01[2048] = { 0, };
+       snprintf(query01, sizeof(query01), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", acc_info->auth_name, "AAuthName", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name,
+                acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query01, strlen(query01));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 2. AAuthSecret
+        */
+       char query02[2048] = { 0, };
+       snprintf(query02, sizeof(query02), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", acc_info->auth_secret, "AAuthSecret", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name,
+                acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query02, strlen(query02));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 3. AAuthLevel
+        */
+       char query03[2048] = { 0, };
+       snprintf(query03, sizeof(query03), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", acc_info->auth_level, "AAuthLevel", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name,
+                acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query03, strlen(query03));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 4. AAuthData
+        */
+       char query04[2048] = { 0, };
+       snprintf(query04, sizeof(query04), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", acc_info->auth_data, "AAuthData", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name,
+                acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query04, strlen(query04));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 5. AAuthType
+        */
+       char query05[2048] = { 0, };
+       snprintf(query05, sizeof(query05), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%' and full_path like '\%%%s\%%'", acc_info->auth_type, "AAuthType", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name,
+                acc_type_string);
+
+       stmt = _query_prepare(mo_handler, query05, strlen(query05));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * 6. Addr
+        */
+       char query06[2048] = { 0, };
+       snprintf(query06, sizeof(query06), "update node_tbl set value = '%s' where name = '%s' and mo_type = %d and full_path like '\%%%s\%%'", acc_info->addr, "Addr", SYNC_AGENT_DM_MO_TYPE_DMACC, dmacc_name);
+
+       stmt = _query_prepare(mo_handler, query06, strlen(query06));
+       if (stmt != NULL) {
+               ret = _stmt_step(mo_handler, stmt);
+
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (dmacc_name != NULL) {
+               free(dmacc_name);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_server_id_list(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id_string, sync_agent_dm_server_info_s ** head_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(server_id_string == NULL, SYNC_AGENT_DM_MO_FAIL, "server id string is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_server_info_s *current_ptr = 0;
+       daci_stmt stmt = 0;
+       char *query = "select value, server_type from node_tbl where name = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_text(mo_handler, stmt, 1, server_id_string);
+               while (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       sync_agent_dm_server_info_s *server_info = (sync_agent_dm_server_info_s *) calloc(1, sizeof(sync_agent_dm_server_info_s));
+                       if (server_info == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return SYNC_AGENT_DM_MO_FAIL;
+                       }
+                       server_info->server_id = _stmt_column_text(stmt, 0);
+                       server_info->server_type = _stmt_column_int(stmt, 1);
+
+                       if (current_ptr == NULL) {
+                               *head_ptr = server_info;
+                               current_ptr = *head_ptr;
+                       } else {
+                               current_ptr->next = server_info;
+                               current_ptr = server_info;
+                       }
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_root_path(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *mo_full_path, char **root_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+
+       char *query = "select full_path from node_tbl where node_type = ? and mo_type = (select mo_type from node_tbl where full_path = ?)";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(mo_handler, stmt, 1, SYNC_AGENT_DM_MO_NODE_FIRST);
+               _stmt_bind_text(mo_handler, stmt, 2, mo_full_path);
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       *root_path = _stmt_column_text(stmt, 0);
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_add_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(framework_property == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "insert into framework_property_tbl " "(access_type, default_value, description, df_format, occurrence, occurrence_num, scope, df_title, df_type, df_type_value, node_id) " "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+/*     _stmt_bind_int(mo_handler, stmt, 1, framework_property->id);*/
+       _stmt_bind_int(mo_handler, stmt, 1, framework_property->accessType);
+       _stmt_bind_text(mo_handler, stmt, 2, framework_property->defaultValue);
+       _stmt_bind_text(mo_handler, stmt, 3, framework_property->description);
+       _stmt_bind_int(mo_handler, stmt, 4, framework_property->dffFormat);
+       _stmt_bind_int(mo_handler, stmt, 5, framework_property->occurrence);
+       _stmt_bind_int(mo_handler, stmt, 6, framework_property->occurrence_num);
+       _stmt_bind_int(mo_handler, stmt, 7, framework_property->scope);
+       _stmt_bind_text(mo_handler, stmt, 8, framework_property->dfTitle);
+       _stmt_bind_int(mo_handler, stmt, 9, framework_property->dfType);
+       _stmt_bind_text(mo_handler, stmt, 10, framework_property->dfType_Value);
+       _stmt_bind_int(mo_handler, stmt, 11, mo_node_id);
+
+       ret = _stmt_step(mo_handler, stmt);
+
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+               ret = SYNC_AGENT_DM_MO_FAIL;
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from framework_property_tbl where node_id = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_update_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(framework_property == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_framework_property_s *framework_property is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "update framework_property_tbl set access_type = ?,  default_value = ?, description = ?, df_format = ?, occurrence = ?," "occurrence_num = ?, scope = ?, df_title = ?, df_type = ?, df_type_value = ? where node_id = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+       _stmt_bind_int(mo_handler, stmt, 1, framework_property->accessType);
+       _stmt_bind_text(mo_handler, stmt, 2, framework_property->defaultValue);
+       _stmt_bind_text(mo_handler, stmt, 3, framework_property->description);
+       _stmt_bind_int(mo_handler, stmt, 4, framework_property->dffFormat);
+       _stmt_bind_int(mo_handler, stmt, 5, framework_property->occurrence);
+       _stmt_bind_int(mo_handler, stmt, 6, framework_property->occurrence_num);
+       _stmt_bind_int(mo_handler, stmt, 7, framework_property->scope);
+       _stmt_bind_text(mo_handler, stmt, 8, framework_property->dfTitle);
+       _stmt_bind_int(mo_handler, stmt, 9, framework_property->dfType);
+       _stmt_bind_text(mo_handler, stmt, 10, framework_property->dfType_Value);
+       _stmt_bind_int(mo_handler, stmt, 11, mo_node_id);
+
+       ret = _stmt_step(mo_handler, stmt);
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+               ret = SYNC_AGENT_DM_MO_FAIL;
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s ** framework_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select * from framework_property_tbl where node_id = ?";
+       sync_agent_dm_mo_framework_property_s *temp_framework_property = 0;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       temp_framework_property = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_framework_property_s *, sizeof(sync_agent_dm_mo_framework_property_s), 1);
+/*                     temp_framework_property->framework_property_id = _stmt_column_int(stmt, 0);*/
+                       temp_framework_property->accessType = _stmt_column_int(stmt, 1);
+                       temp_framework_property->defaultValue = _stmt_column_text(stmt, 2);
+                       temp_framework_property->description = _stmt_column_text(stmt, 3);
+                       temp_framework_property->dffFormat = _stmt_column_int(stmt, 4);
+                       temp_framework_property->occurrence = _stmt_column_int(stmt, 5);
+                       temp_framework_property->occurrence_num = _stmt_column_int(stmt, 6);
+                       temp_framework_property->scope = _stmt_column_int(stmt, 7);
+                       temp_framework_property->dfTitle = _stmt_column_text(stmt, 8);
+                       temp_framework_property->dfType = _stmt_column_int(stmt, 9);
+                       temp_framework_property->dfType_Value = _stmt_column_text(stmt, 10);
+/*                     temp_framework_property->node_id = _stmt_column_text(stmt, 9);*/
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       (*framework_property) = temp_framework_property;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from framework_property_tbl";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_add_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(runtime_property == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_runtime_property_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "insert into runtime_property_tbl " "(acl, format, name, size, title, t_stamp, type, type_value, ver_no, node_id) " "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_text(mo_handler, stmt, 1, runtime_property->acl);
+       _stmt_bind_int(mo_handler, stmt, 2, runtime_property->format);
+       _stmt_bind_text(mo_handler, stmt, 3, runtime_property->name);
+       _stmt_bind_text(mo_handler, stmt, 4, runtime_property->size);
+       _stmt_bind_text(mo_handler, stmt, 5, runtime_property->title);
+       _stmt_bind_text(mo_handler, stmt, 6, runtime_property->tStamp);
+       _stmt_bind_int(mo_handler, stmt, 7, runtime_property->type);
+       _stmt_bind_text(mo_handler, stmt, 8, runtime_property->type_value);
+       _stmt_bind_text(mo_handler, stmt, 9, runtime_property->verNo);
+       _stmt_bind_int(mo_handler, stmt, 10, mo_node_id);
+
+       ret = _stmt_step(mo_handler, stmt);
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+               ret = SYNC_AGENT_DM_MO_FAIL;
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from runtime_property_tbl where node_id = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_update_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(runtime_property == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_runtime_property_s is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "update runtime_property_tbl set acl = ?,  format = ?, name = ?, size = ?, title = ?," "t_stamp = ?, type = ?, type_value = ?, ver_no = ? where node_id = ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+       _stmt_bind_text(mo_handler, stmt, 1, runtime_property->acl);
+       _stmt_bind_int(mo_handler, stmt, 2, runtime_property->format);
+       _stmt_bind_text(mo_handler, stmt, 3, runtime_property->name);
+       _stmt_bind_text(mo_handler, stmt, 4, runtime_property->size);
+       _stmt_bind_text(mo_handler, stmt, 5, runtime_property->title);
+       _stmt_bind_text(mo_handler, stmt, 6, runtime_property->tStamp);
+       _stmt_bind_int(mo_handler, stmt, 7, runtime_property->type);
+       _stmt_bind_text(mo_handler, stmt, 8, runtime_property->type_value);
+       _stmt_bind_text(mo_handler, stmt, 9, runtime_property->verNo);
+       _stmt_bind_int(mo_handler, stmt, 10, mo_node_id);
+
+       ret = _stmt_step(mo_handler, stmt);
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+               ret = SYNC_AGENT_DM_MO_FAIL;
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s ** runtime_property)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = "select * from runtime_property_tbl where node_id = ?";
+       sync_agent_dm_mo_runtime_property_s *temp_runtime_property = 0;
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt != NULL) {
+               _stmt_bind_int(mo_handler, stmt, 1, mo_node_id);
+
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA) {
+                       temp_runtime_property = SYNC_AGENT_DA_MEMORY_CALLOC(sync_agent_dm_mo_runtime_property_s *, sizeof(sync_agent_dm_mo_runtime_property_s), 1);
+/*                     temp_runtime_property->runtime_property_id = _stmt_column_int(stmt, 0);*/
+                       temp_runtime_property->acl = _stmt_column_text(stmt, 1);
+                       temp_runtime_property->format = _stmt_column_int(stmt, 2);
+                       temp_runtime_property->name = _stmt_column_text(stmt, 3);
+                       temp_runtime_property->size = _stmt_column_text(stmt, 4);
+                       temp_runtime_property->title = _stmt_column_text(stmt, 5);
+                       temp_runtime_property->tStamp = _stmt_column_text(stmt, 6);
+                       temp_runtime_property->type = _stmt_column_int(stmt, 7);
+                       temp_runtime_property->type_value = _stmt_column_text(stmt, 8);
+                       temp_runtime_property->verNo = _stmt_column_text(stmt, 9);
+/*                     temp_runtime_property->node_id = _stmt_column_text(stmt, 10);*/
+               }
+               ret = _stmt_finalize(mo_handler, stmt);
+       } else {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       (*runtime_property) = temp_runtime_property;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+       daci_stmt stmt = NULL;
+       char *query = NULL;
+
+       query = "delete from runtime_property_tbl";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if (stmt == NULL) {
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto DACI_FINISH;
+       }
+
+       ret = _stmt_step(mo_handler, stmt);
+
+ DACI_FINISH:
+
+       if (stmt != NULL)
+               _stmt_finalize(mo_handler, stmt);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+int _busy_handler(void *pData, int count)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_ERROR("_busy_handler %d called", count);
+
+       //retvm_if(pData == NULL, 0, "pData is NULL !!");
+       warn_if(pData == NULL, "pData is NULL !!");
+
+       /*  sleep time when SQLITE_LOCK */
+       //usleep(1500000);
+       usleep(500000);
+
+       _INNER_FUNC_EXIT;
+
+       /* retry will be stopped if  busy handler return 0 */
+       return SYNC_AGENT_DA_RETRY_COUNT - count;
+}
+
+sync_agent_dm_mo_error_e _query_exec(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, char *err_msg)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(query == NULL, SYNC_AGENT_DM_MO_FAIL, "query is NULL !!");
+
+       char *queryMsg = NULL;
+       int ret = 0;
+
+       ret = sqlite3_exec(mo_handler, query, 0, 0, &queryMsg);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("%s(%d) : %s", err_msg, ret, queryMsg);
+
+               if (queryMsg != NULL)
+                       sqlite3_free(queryMsg);
+
+/*
+               if (ret == SQLITE_BUSY)
+                       return SYNC_AGENT_DM_MO_FAIL;
+*/
+
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+daci_stmt _query_prepare(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, int size)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, NULL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+       retvm_if(query == NULL, NULL, "query is NULL !!");
+
+       int ret = 0;
+       daci_stmt stmt = NULL;
+
+       ret = sqlite3_prepare_v2(mo_handler, query, size, &stmt, 0);
+       if (ret != SQLITE_OK)
+               _DEBUG_ERROR("sqlite3_query_prepare failed(%d) : %s ", ret, sqlite3_errmsg(mo_handler));
+
+       _INNER_FUNC_EXIT;
+
+       return stmt;
+}
+
+sync_agent_da_return_e _stmt_bind_text(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index, const char *value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       if (value != NULL) {
+               ret = sqlite3_bind_text(stmt, index, value, strlen(value), SQLITE_STATIC);
+       } else {
+               ret = __stmt_bind_null(mo_handler, stmt, index);
+               if (ret == SYNC_AGENT_DA_SUCCESS)
+                       ret = SQLITE_OK;
+       }
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_text failed(%d) : %s ", ret, sqlite3_errmsg(mo_handler));
+               return SYNC_AGENT_DA_ERR_QUERY_FAILED;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e _stmt_bind_int(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index, const int value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_bind_int(stmt, index, value);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_int failed(%d) : %s \n", ret, sqlite3_errmsg(mo_handler));
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e __stmt_bind_null(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_bind_null(stmt, index);
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_bind_null failed(%d) : %s", ret, sqlite3_errmsg(mo_handler));
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_da_return_e _stmt_step(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       ret = sqlite3_step(stmt);
+
+       if (ret == SQLITE_ROW)
+               return SYNC_AGENT_DA_ERR_MORE_DATA;
+
+       if (ret != SQLITE_DONE) {
+               _DEBUG_ERROR("sqlite3_stmt_step failed(%d) : %s", ret, sqlite3_errmsg(mo_handler));
+
+/*             if (ret == SQLITE_BUSY)
+                       return SYNC_AGENT_DM_MO_FAIL;*/
+
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e _stmt_finalize(SYNC_AGENT_DA_MO_HANDLER * mo_handler, daci_stmt stmt)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_stmt_finalize failed(%d) : %s", ret, sqlite3_errmsg(mo_handler));
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+char *_stmt_column_text(daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(stmt == NULL, NULL, "daci_stmt is NULL !!");
+
+       char *temp = NULL;
+       temp = (char *)sqlite3_column_text(stmt, index);
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_STRDUP(temp);
+}
+
+int _stmt_column_int(daci_stmt stmt, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return (int)sqlite3_column_int(stmt, index);
+}
+
+sync_agent_dm_mo_error_e _get_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler, char *query, char ***result, int *row_count, int *col_count)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_handler == NULL, SYNC_AGENT_DM_MO_FAIL, "SYNC_AGENT_DA_MO_HANDLER is NULL !!");
+
+       int ret = 0;
+       char *err_msg = NULL;
+
+       ret = sqlite3_get_table(mo_handler, query, result, row_count, col_count, &err_msg);
+
+       if (ret != SQLITE_OK) {
+               _DEBUG_ERROR("sqlite3_get_table failed(%d) : %s", ret, err_msg);
+
+               _free_table(*result);
+
+               if (err_msg != NULL)
+                       sqlite3_free(err_msg);
+
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+void _free_table(char **result)
+{
+       _INNER_FUNC_ENTER;
+
+       if (result != NULL) {
+               sqlite3_free_table(result);
+               result = NULL;
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _last_insert_id(SYNC_AGENT_DA_MO_HANDLER * mo_handler)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return sqlite3_last_insert_rowid(mo_handler);
+}
+
+int _exist_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *table_name)
+{
+       _INNER_FUNC_ENTER;
+
+       daci_stmt stmt = NULL;
+       int table_count = 0;
+       char *query = "select count(*) from sqlite_master where tbl_name= ?";
+
+       stmt = _query_prepare(mo_handler, query, strlen(query));
+       if ((stmt != NULL) && (_stmt_bind_text(mo_handler, stmt, 1, table_name) == SYNC_AGENT_DA_ERR_MORE_DATA)) {
+
+               if (_stmt_step(mo_handler, stmt) == SYNC_AGENT_DA_ERR_MORE_DATA)
+                       table_count = _stmt_column_int(stmt, 0);
+
+               _stmt_finalize(mo_handler, stmt);
+
+               if (table_count > 0) {
+                       _INNER_FUNC_EXIT;
+                       return 1;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static char *_extract_dmacc_name(const char *mo_full_path)
+{
+       _INNER_FUNC_ENTER;
+
+       char *dmacc_name = NULL;
+
+       int cnt = 0;
+       const char *cursor = mo_full_path;
+       const char *start_point = NULL;
+       while (cursor != NULL) {
+               cursor = strchr(cursor, '/');
+               if (cursor == NULL) {
+                       continue;
+               }
+
+               cnt++;
+
+               if (cnt == 2) {
+                       start_point = cursor;
+               } else if (cnt == 3) {
+                       int len = cursor - start_point + 2;
+
+                       dmacc_name = (char *)calloc(len, sizeof(char));
+                       if (dmacc_name == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       strncpy(dmacc_name, start_point, len - 1);
+
+                       break;
+               }
+
+               cursor += 1;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return dmacc_name;
+}
diff --git a/src/framework/device-manager/mo_database.h b/src/framework/device-manager/mo_database.h
new file mode 100755 (executable)
index 0000000..04245eb
--- /dev/null
@@ -0,0 +1,700 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_DATABASE_H_
+#define MO_DATABASE_H_
+
+#include "data-adapter/common.h"
+#include "device-manager/mo_error.h"
+#include "device-manager/mo_struct.h"
+
+/**
+ * @file       mo_database.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * API to Begin mo db transaction
+ * @remarks This function is use to begin mo db transaction
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to begin mo db transaction
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_begin_transaction(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ * API to End mo db transaction
+ * @remarks This function is use to end mo db transaction
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] transaction transaction commit, rollback enum value
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to end mo db transaction
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_end_transaction(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_da_transaction_e transaction);
+
+/**
+ * API to Open mo db
+ * @remarks This function is use to open mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] database_path db file path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to open mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e mo_open_agent(SYNC_AGENT_DA_MO_HANDLER ** mo_handler, char *database_path);
+
+/**
+ * API to Close mo db
+ * @remarks This function is use to close mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to close mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e mo_close_agent(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ * API to Create mo db table
+ * @remarks This function is use to create mo db table
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to create mo db table
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_create_mo_table(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ * API to Add mo node to mo db
+ * @remarks This function is use to add mo node to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_type mo node type
+ * @param[in] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo node to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_add_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_dm_mo_type_e mo_type, sync_agent_dm_mo_node_s * mo_node);
+
+/**
+ * API to Delete mo node to mo db
+ * @remarks This function is use to delete mo node to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo node id in db
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id);
+
+/**
+ * API to Update mo node to mo db
+ * @remarks This function is use to update mo node to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_type mo node type
+ * @param[in] path mo node path
+ * @param[in] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo node to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_update_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, sync_agent_dm_mo_type_e mo_type, const char *path, const sync_agent_dm_mo_node_s * mo_node);
+
+/**
+ * API to Get mo node in mo db
+ * @remarks This function is use to get mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] path mo node path
+ * @param[out] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_get_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Get mo nodes in mo db
+ * @remarks This function is use to get mo nodes in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] path mo node path
+ * @param[out] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo nodes in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_get_nodes(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Check exist mo node in mo db
+ * @remarks This function is use to check exist mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] path mo node path
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to check exist mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_is_exist_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path);
+
+/**
+ * API to Get mo node's child mo node in mo db
+ * @remarks This function is use to get mo node's child mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_type mo type
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] path mo node path
+ * @param[out] mo_node mo node struct
+ * @param[out] count child node count
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's child mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_get_child_node(sync_agent_dm_mo_type_e mo_type, SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *path, sync_agent_dm_mo_node_s ** mo_node, int *count);
+
+/**
+ * API to Delete all mo node in mo db
+ * @remarks This function is use to delete all mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_all_node(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ * API to Get mo node's mo type in mo db
+ * @remarks This function is use to get mo node's mo type in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_full_path mo node path
+ *
+ *
+ * @return     SYNC_AGENT_DM_MO_TYPE_DMACC, SYNC_AGENT_DM_MO_TYPE_DEVINFO, SYNC_AGENT_DM_MO_TYPE_DEVDETAIL,
+                               SYNC_AGENT_DM_MO_TYPE_FUMO, SYNC_AGENT_DM_MO_TYPE_LAWMO, SYNC_AGENT_DM_MO_TYPE_SCOMO,
+                               SYNC_AGENT_DM_MO_TYPE_NO_TYPE
+ *
+ * @pre  This function should be called if need to get mo node's mo type in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_type_e dm_mo_get_mo_type(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *mo_full_path);
+
+/**
+ * API to Get node from db id
+ * @remarks This function is use to get node from db id
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] node_id db node id
+ * @param[out] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get node from db id
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_get_node_from_id(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Get dmacc struct
+ * @remarks This function is use to get dmacc struct
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] server_id server id
+ * @param[in] server_id_string "ServerID"
+ * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
+ * @param[out] acc_info acc info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get dmacc struct
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_get_acc_info(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s ** acc_info);
+
+/**
+ * API to Set dmacc struct
+ * @remarks This function is use to set dmacc struct
+ *
+ * @par Usage:
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] server_id server id
+ * @param[in] server_id_string "ServerID"
+ * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
+ * @param[in] acc_info acc info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to set dmacc struct
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_set_acc_info(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id, const char *server_id_string, const char *acc_type_string, sync_agent_dm_acc_info_s * acc_info);
+
+/**
+ * API to Get server id list
+ * @remarks This function is use to get server id list
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] server_id server id
+ * @param[out] server_info server info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get server id list
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_get_server_id_list(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *server_id_string, sync_agent_dm_server_info_s ** server_info);
+
+/**
+ * API to Get root path
+ * @remarks This function is use to get root path
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_full_path mo node path
+ * @param[out] root_path node's root path
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get root path
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_get_root_path(SYNC_AGENT_DA_MO_HANDLER * mo_handler, const char *mo_full_path, char **root_path);
+
+/**
+ * API to Add mo node's framework property to mo db
+ * @remarks This function is use to add mo node's framework property to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[in] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo node's framework property to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_add_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property);
+
+/**
+ * API to Delete mo node's framework property in mo db
+ * @remarks This function is use to delete mo node's framework property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id);
+
+/**
+ * API to Update mo node's framework property in mo db
+ * @remarks This function is use to update mo node's framework property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[in] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_update_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s * framework_property);
+
+/**
+ * API to Get mo node's framework property in mo db
+ * @remarks This function is use to get mo node's framework property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[out] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_get_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_framework_property_s ** framework_property);
+
+/**
+ * API to Delete all mo node's framework property in mo db
+ * @remarks This function is use to delete all mo node's framework property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ * API to Add mo node's runtime property to mo db
+ * @remarks This function is use to add mo node's runtime property to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[in] runtime_property mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo node's runtime property to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_add_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property);
+
+/**
+ * API to Delete mo node's runtime property in mo db
+ * @remarks This function is use to delete mo node's runtime property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id);
+
+/**
+ * API to Update mo node's runtime property in mo db
+ * @remarks This function is use to update mo node's runtime property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[in] runtime_property mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_update_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s * runtime_property);
+
+/**
+ * API to Get mo node's runtime property in mo db
+ * @remarks This function is use to get mo node's runtime property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ * @param[in] mo_node_id mo db id
+ * @param[out] runtime mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_get_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler, int mo_node_id, sync_agent_dm_mo_runtime_property_s ** runtime_property);
+
+/**
+ * API to Delete all mo node's runtime property in mo db
+ * @remarks This function is use to delete all mo node's runtime property in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_handler mo db handler manager
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property(SYNC_AGENT_DA_MO_HANDLER * mo_handler);
+
+/**
+ *     @}
+ */
+#endif                         /* MO_DATABASE_H_ */
diff --git a/src/framework/device-manager/mo_database_handler.c b/src/framework/device-manager/mo_database_handler.c
new file mode 100755 (executable)
index 0000000..0d32cb9
--- /dev/null
@@ -0,0 +1,816 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "data-adapter/common.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "device-manager/mo_database.h"
+
+#include "device-manager/mo_database_handler.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+static dm_mo_handler_mgr_s *pMoDBHandlerMgr = NULL;
+
+/* static function define */
+static sync_agent_dm_mo_error_e _add_agent_handler(unsigned int key, SYNC_AGENT_DA_MO_HANDLER * pHandler);
+static sync_agent_dm_mo_error_e _remove_agent_handler(unsigned int key);
+static SYNC_AGENT_DA_MO_HANDLER *_get_agent_handler(unsigned int key);
+static sync_agent_dm_mo_error_e __alloc_agent_dc_handlerTable(void);
+static sync_agent_dm_mo_error_e _alloc_agent_dc_handlerTable_mutex(void);
+static sync_agent_dm_mo_error_e _free_agent_dc_handlerTable(void);
+static sync_agent_dm_mo_error_e _free_agent_dc_handlerTable_mutex(void);
+static sync_agent_dm_mo_error_e _create_agentDBHandlerMgrInfo(void);
+static void __destroy_agentDBHashTableValue(void *pHandler);
+static void __destory_agentDBHashTableKey(void *key);
+
+/* general function implementation */
+/*
+ * ==================================
+ * external API (1. about agent db handler mgr)
+ * ==================================
+ */
+sync_agent_dm_mo_error_e dm_mo_alloc_modb_handler_mgr(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[%s] start !\n", __func__);
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       /* alloc the agentDBHandlerMgr */
+       pMoDBHandlerMgr = (dm_mo_handler_mgr_s *) calloc(1, sizeof(dm_mo_handler_mgr_s));
+       if (pMoDBHandlerMgr == NULL)
+               return SYNC_AGENT_DM_MO_FAIL;
+       _DEBUG_INFO("[%s] pMoDBHandlerMgr alloc success !\n", __func__);
+
+       /* alloc the agentDBHandlerMgr information */
+       ret = _create_agentDBHandlerMgrInfo();
+       if (ret != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_INFO("[%s] _create_agentDBHandlerMgrInfo alloc fail !\n", __func__);
+       } else {
+               _DEBUG_INFO("[%s] _create_agentDBHandlerMgrInfo alloc success !\n", __func__);
+       }
+
+       _DEBUG_INFO("[%s] end !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+sync_agent_dm_mo_error_e dm_mo_free_modb_handler_mgr(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[%s] start !\n", __func__);
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       if (pMoDBHandlerMgr != NULL) {
+
+               ret = _free_agent_dc_handlerTable_mutex();
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       return SYNC_AGENT_DM_MO_FAIL;
+
+               ret = _free_agent_dc_handlerTable();
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       return SYNC_AGENT_DM_MO_FAIL;
+
+       }
+
+       _DEBUG_INFO("[%s] end !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+/*
+ * ==================================
+ * external API (2. about agent db )
+ * ==================================
+ */
+sync_agent_dm_mo_error_e dm_mo_open(char *database_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[%s] Start !\n", __func__);
+       int ret = 0;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+
+               _DEBUG_INFO("mo_handler is 0");
+               _DEBUG_INFO("should register mo_handler to mo_handler_hash_table");
+               ret = mo_open_agent(&mo_handler, database_path);
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       return ret;
+
+               if (mo_handler != NULL) {
+
+                       /* add agentDB handler to agentDBHandleMgr */
+                       ret = _add_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID, mo_handler);
+                       if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                               return ret;
+
+               }
+       } else {
+               _DEBUG_INFO("mo_handler is not null");
+               _DEBUG_INFO("should not register mo_handler to mo_handler_hash_table");
+       }
+
+       _DEBUG_INFO("agent_db_agent_open_success");
+       _DEBUG_INFO("[%s] End !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_mo_close(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[%s] Start !\n", __func__);
+       int ret = 0;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler != NULL) {
+
+               /* remove agentDB handler to agentDBHandleMgr */
+               ret = _remove_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       return ret;
+
+               _DEBUG_INFO("agent_db_agent_close_success");
+       }
+
+       _DEBUG_INFO("[%s] End !\n", __func__);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+sync_agent_dm_mo_error_e dm_mo_create_mo_table_wraper(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_create_mo_table(mo_handler);
+}
+
+sync_agent_dm_mo_error_e dm_mo_begin_transaction_wraper(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_begin_transaction(mo_handler);
+}
+
+sync_agent_dm_mo_error_e dm_mo_end_transaction_wraper(sync_agent_da_transaction_e transaction)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_end_transaction(mo_handler, transaction);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_add_node(mo_handler, mo_type, mo_node);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_node_wraper(int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_node(mo_handler, mo_node_id);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_update_node(mo_handler, mo_type, path, mo_node);
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_node_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_node(mo_handler, path, mo_node);
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_nodes_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_nodes(mo_handler, path, mo_node);
+}
+
+sync_agent_dm_mo_error_e dm_mo_is_exist_node_wraper(const char *path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_is_exist_node(mo_handler, path);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_child_node(mo_type, mo_handler, path, mo_node, count);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_node_wraper(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_all_node(mo_handler);
+}
+
+sync_agent_dm_mo_type_e dm_mo_get_mo_type_wraper(const char *mo_full_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_mo_type(mo_handler, mo_full_path);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_add_framework_property(mo_handler, mo_node_id, framework_property);
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_node_from_id_wraper(int node_id, sync_agent_dm_mo_node_s ** mo_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_node_from_id(mo_handler, node_id, mo_node);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_acc_info(mo_handler, server_id, server_id_string, acc_type_string, acc_info);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_set_acc_info(mo_handler, server_id, server_id_string, acc_type_string, acc_info);
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_server_id_list_wraper(const char *server_id_string, sync_agent_dm_server_info_s ** head_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_server_id_list(mo_handler, server_id_string, head_ptr);
+}
+
+sync_agent_dm_mo_error_e dm_mo_get_root_path_wraper(const char *mo_full_path, char **root_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_root_path(mo_handler, mo_full_path, root_path);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_framework_property_wraper(int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_framework_property(mo_handler, mo_node_id);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_update_framework_property(mo_handler, mo_node_id, framework_property);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_framework_property(mo_handler, mo_node_id, framework_property);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property_wraper(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_all_framework_property(mo_handler);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_add_runtime_property(mo_handler, mo_node_id, runtime_property);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_runtime_property_wraper(int mo_node_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_runtime_property(mo_handler, mo_node_id);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_update_runtime_property(mo_handler, mo_node_id, runtime_property);
+}
+
+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)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_get_runtime_property(mo_handler, mo_node_id, runtime_property);
+}
+
+sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property_wraper(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_DA_MO_HANDLER *mo_handler = _get_agent_handler(SYNC_AGENT_DA_GET_THREAD_ID);
+       if (mo_handler == NULL) {
+               _DEBUG_ERROR("[%s] no handler for key\n", __func__);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dm_mo_delete_all_runtime_property(mo_handler);
+}
+
+/*
+ * ==================================
+ *  Mo module internal API
+ * ==================================
+ */
+sync_agent_dm_mo_error_e _add_agent_handler(unsigned int key, SYNC_AGENT_DA_MO_HANDLER * pHandler)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr == NULL || pMoDBHandlerMgr->mo_handlerTable_mutex == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       unsigned int *pKey_copy = (unsigned int *)malloc(sizeof(unsigned int));
+       if (pKey_copy == NULL)
+               return SYNC_AGENT_DM_MO_FAIL;
+
+       *pKey_copy = key;
+
+       pthread_mutex_lock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+       if (pMoDBHandlerMgr->mo_handlerTable == NULL) {
+               ret = __alloc_agent_dc_handlerTable();
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto addagentHandler;
+       }
+
+       /* insert to handler */
+       _DEBUG_TRACE("[%s] Key  =  %d, Handler  =  %p  !\n", __func__, key, pHandler);
+       g_hash_table_insert(pMoDBHandlerMgr->mo_handlerTable, pKey_copy, pHandler);
+
+#ifdef DC_PRINT
+       /* For test log */
+       __print_agentDBHashTableLog();
+#endif
+       pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+       if(pKey_copy != NULL) {
+               free(pKey_copy);
+       }
+       _INNER_FUNC_EXIT;
+       return ret;
+
+ addagentHandler:
+       pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+       if(pKey_copy != NULL) {
+               free(pKey_copy);
+       }
+       _INNER_FUNC_EXIT;
+       return ret;
+}
+
+sync_agent_dm_mo_error_e _remove_agent_handler(unsigned int key)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr == NULL || pMoDBHandlerMgr->mo_handlerTable_mutex == NULL || pMoDBHandlerMgr->mo_handlerTable == NULL) {
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /* remove the handler to hash table */
+       pthread_mutex_lock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+       int isSuccess = g_hash_table_remove(pMoDBHandlerMgr->mo_handlerTable, &key);
+       pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+
+#ifdef DC_PRINT
+       /* for test log */
+       __print_agentDBHashTableLog();
+#endif
+
+       _INNER_FUNC_EXIT;
+
+       if (isSuccess == 1)
+               return SYNC_AGENT_DM_MO_SUCCESS;
+
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+SYNC_AGENT_DA_MO_HANDLER *_get_agent_handler(unsigned int key)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr == NULL || pMoDBHandlerMgr->mo_handlerTable_mutex == NULL || pMoDBHandlerMgr->mo_handlerTable == NULL) {
+               _DEBUG_TRACE("[%s] SYNC_AGENT_DM_MO_FAIL !\n", __func__);
+               return NULL;
+       }
+
+       /* get the handler to hash table */
+       pthread_mutex_lock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+       SYNC_AGENT_DA_MO_HANDLER *pHandler = g_hash_table_lookup(pMoDBHandlerMgr->mo_handlerTable, &key);
+       pthread_mutex_unlock(pMoDBHandlerMgr->mo_handlerTable_mutex);
+
+#ifdef DC_PRINT
+       if (pHandler != 0) {
+               _DEBUG_TRACE("[%s] ######### > Value Search Success(key = %d, handler = %p)\n", __func__, key, pHandler);
+       } else {
+               _DEBUG_TRACE("[%s] ######### > Value Search Fail(key = %d, handler = %p)\n", __func__, key, pHandler);
+       }
+#endif
+
+       _INNER_FUNC_EXIT;
+
+       return pHandler;
+}
+
+/* static function implementation */
+static sync_agent_dm_mo_error_e __alloc_agent_dc_handlerTable(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr != NULL) {
+               pMoDBHandlerMgr->mo_handlerTable = g_hash_table_new_full(g_int_hash, g_int_equal, __destory_agentDBHashTableKey, __destroy_agentDBHashTableValue);
+               if (pMoDBHandlerMgr->mo_handlerTable == NULL) {
+                       _DEBUG_ERROR("[%s] Not Create agent dc handler hash table \n", __func__);
+                       return SYNC_AGENT_DM_MO_FAIL;
+               } else {
+                       _DEBUG_VERBOSE("[%MO_FAILent dc handler hash table \n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static sync_agent_dm_mo_error_e _alloc_agent_dc_handlerTable_mutex(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr != NULL) {
+
+               pMoDBHandlerMgr->mo_handlerTable_mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+               if (pMoDBHandlerMgr->mo_handlerTable_mutex == NULL) {
+                       _DEBUG_TRACE("[%s] Not Create agent dc handler hash table mutex \n", __func__);
+                       return SYNC_AGENT_DM_MO_FAIL;
+               } else {
+
+                       if (0 != pthread_mutex_init(pMoDBHandlerMgr->mo_handlerTable_mutex, 0)) {
+                               _DEBUG_TRACE("[%s] Not init agent dc handler hash table mutex\n", __func__);
+                               return SYNC_AGENT_DM_MO_FAIL;
+                       }
+                       _DEBUG_TRACE("[%s] Init agent dc handler hash table mutex\n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static sync_agent_dm_mo_error_e _free_agent_dc_handlerTable(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr != NULL && pMoDBHandlerMgr->mo_handlerTable != NULL) {
+               g_hash_table_destroy(pMoDBHandlerMgr->mo_handlerTable);
+               _DEBUG_TRACE("[%s] mo_handlerTable free success !\n", __func__);
+               pMoDBHandlerMgr->mo_handlerTable = NULL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static sync_agent_dm_mo_error_e _free_agent_dc_handlerTable_mutex(void)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pMoDBHandlerMgr != NULL && pMoDBHandlerMgr->mo_handlerTable_mutex != NULL) {
+
+               int ret = pthread_mutex_destroy(pMoDBHandlerMgr->mo_handlerTable_mutex);
+               if (ret != 0) {
+                       _DEBUG_TRACE("[%s] mo_handlerTable_mutex free error !\n", __func__);
+                       return SYNC_AGENT_DM_MO_FAIL;
+               } else {
+                       free(pMoDBHandlerMgr->mo_handlerTable_mutex);
+                       pMoDBHandlerMgr->mo_handlerTable_mutex = NULL;
+                       _DEBUG_TRACE("[%s] mo_handlerTable_mutex free success !\n", __func__);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static sync_agent_dm_mo_error_e _create_agentDBHandlerMgrInfo(void)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       if (pMoDBHandlerMgr != NULL) {
+
+               /* alloc agent db hander hash table */
+               ret = __alloc_agent_dc_handlerTable();
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto allocAgentDBHandlerMgrInfoErr;
+
+               /* alloc agent db hander hash table mutex */
+               ret = _alloc_agent_dc_handlerTable_mutex();
+               if (ret != SYNC_AGENT_DM_MO_SUCCESS)
+                       goto allocAgentDBHandlerMgrInfoErr;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+
+ allocAgentDBHandlerMgrInfoErr:
+       da_free_agentdb_handler_mgr();
+       return SYNC_AGENT_DM_MO_FAIL;
+}
+
+static void __destroy_agentDBHashTableValue(void *pHandler)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_VERBOSE("[%s] start \n", __func__);
+       if (pHandler != NULL) {
+               mo_close_agent((SYNC_AGENT_DA_MO_HANDLER *) pHandler);
+       }
+       _DEBUG_VERBOSE("[%s] end \n", __func__);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __destory_agentDBHashTableKey(void *key)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_VERBOSE("[%s] start \n", __func__);
+       if (key != NULL)
+               free(key);
+       _DEBUG_VERBOSE("[%s] end \n", __func__);
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/device-manager/mo_database_handler.h b/src/framework/device-manager/mo_database_handler.h
new file mode 100755 (executable)
index 0000000..c62142e
--- /dev/null
@@ -0,0 +1,717 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_DATABASE_HANDLER_H_
+#define MO_DATABASE_HANDLER_H_
+
+#include "device-manager/mo_error.h"
+#include "device-manager/mo_struct.h"
+
+#include "data-adapter/common.h"
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file       mo_database_handler.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+       typedef struct {
+               GHashTable *mo_handlerTable;
+                                    /**< agent db handler hash table */
+               pthread_mutex_t *mo_handlerTable_mutex;
+                                              /**< mutex for agent db handler hash table */
+       } dm_mo_handler_mgr_s;
+
+/**
+ * API to Alloc th mo db handler manager
+ * @remarks This function is use to alloc th mo db handler
+ *
+ * @par Usage:
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to alloc th mo db handler
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see __process_device_manage(xmlNode *device_manage_node)
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_alloc_modb_handler_mgr(void);
+
+/**
+ * API to Free th mo db handler manager
+ * @remarks This function is use to free th mo db handler
+ *
+ * @par Usage:
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to free th mo db handler
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_free_modb_handler_mgr(void);
+
+/**
+ * API to Open th mo db
+ * @remarks This function is use to open the mo db handler
+ *
+ * @par Usage:
+ *
+ *     @param[in] database_path database path
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to open the mo db handler
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_open(char *database_path);
+
+/**
+ * API to Close th mo db
+ * @remarks This function is use to close the mo db handler
+ *
+ * @par Usage:
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to close the mo db handler
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_close(void);
+
+/**
+ * API to Create mo table
+ * @remarks This function is use to create the mo table
+ *
+ * @par Usage:
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to close the mo db handler
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_create_mo_table_wraper(void);
+
+/**
+ * API to Begin transaction mo table
+ * @remarks This function is use to begin transaction mo table
+ *
+ * @par Usage:
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to begin transaction mo table
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_begin_transaction_wraper(void);
+
+/**
+ * API to End transaction mo table
+ * @remarks This function is use to end transaction mo table
+ *
+ * @par Usage:
+ *
+ *     @param[in] transaction transaction type (SYNC_AGENT_DA_TRANSACTION_COMMIT, SYNC_AGENT_DA_TRANSACTION_ROLLBACK)
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to end transaction mo table
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_end_transaction_wraper(sync_agent_da_transaction_e transaction);
+
+/**
+ * API to Add mo node to mo db
+ * @remarks This function is use to add mo node to mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_type mo type (dmacc, devinfo...)
+ * @param[in] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo n ode to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       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);
+
+/**
+ * API to Delete mo node in mo db
+ * @remarks This function is use to delete mo node in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id db id
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_node_wraper(int mo_node_id);
+
+/**
+ * API to Update mo node in mo db
+ * @remarks This function is use to update mo node in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_type mo type (dmacc, devinfo...)
+ * @param[in] path mo node path
+ * @param[in] mo_node mo node struct
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+       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);
+
+/**
+ * API to Get mo node in mo db
+ * @remarks This function is use to get mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] path mo node path
+ * @param[out] mo_node mo node struct
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_get_node_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Get mo nodes in mo db
+ * @remarks This function is use to get mo nodes in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] path mo node path
+ * @param[out] mo_node mo node struct
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo nodes in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_get_nodes_wraper(const char *path, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Check exist mo node in mo db
+ * @remarks This function is use to check exist  mo node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] path mo node path
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to check exist  mo node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_is_exist_node_wraper(const char *path);
+
+/**
+ * API to Get mo node's child node in mo db
+ * @remarks This function is use to get mo node's child node in mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_type mo type
+ * @param[in] path mo node path
+ * @param[out] mo_node child mo nodes
+ * @param[out] count child node count
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's child node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Delete all node in mo db
+ * @remarks This function is use to delete all node in mo db
+ *
+ * @par Usage:
+ *
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all node in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_all_node_wraper(void);
+
+/**
+ * API to Get mo node's mo type
+ * @remarks This function is use to get mo node's mo type
+ *
+ * @par Usage:
+ *
+ *     @param[in] mo_full_path mo node path
+ *
+ *
+ * @return     SYNC_AGENT_DM_MO_TYPE_DMACC, SYNC_AGENT_DM_MO_TYPE_DEVINFO, SYNC_AGENT_DM_MO_TYPE_DEVDETAIL,
+                               SYNC_AGENT_DM_MO_TYPE_FUMO, SYNC_AGENT_DM_MO_TYPE_LAWMO, SYNC_AGENT_DM_MO_TYPE_SCOMO,
+                               SYNC_AGENT_DM_MO_TYPE_NO_TYPE
+ *
+ * @pre  This function should be called if need to get mo node's mo type
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_type_e dm_mo_get_mo_type_wraper(const char *mo_full_path);
+
+/**
+ * API to Get node from db id
+ * @remarks This function is use to get node from db id
+ *
+ * @par Usage:
+ * @param[in] node_id db node id
+ * @param[out] mo_node mo node struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get node from db id
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_get_node_from_id_wraper(int node_id, sync_agent_dm_mo_node_s ** mo_node);
+
+/**
+ * API to Get dmacc struct
+ * @remarks This function is use to get dmacc struct
+ *
+ * @par Usage:
+ * @param[in] server_id server id
+ * @param[in] server_id_string "ServerID"
+ * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
+ * @param[out] acc_info acc info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get dmacc struct
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @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)
+ */
+       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);
+
+/**
+ * API to Set dmacc struct
+ * @remarks This function is use to set dmacc struct
+ *
+ * @par Usage:
+ * @param[in] server_id server id
+ * @param[in] server_id_string "ServerID"
+ * @param[in] acc_type_string "/ServerAppAuth/" , "/ClientAppAuth/"
+ * @param[in] acc_info acc info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to set dmacc struct
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @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)
+ */
+       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);
+
+/**
+ * API to Get server id list
+ * @remarks This function is use to get server id list
+ *
+ * @par Usage:
+ * @param[in] server_id server id
+ * @param[out] server_info server info struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get server id list
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see sync_agent_get_serverinfo(sync_agent_dm_server_info_s **server_info)
+ */
+       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);
+
+/**
+ * API to Get root path
+ * @remarks This function is use to get root path
+ *
+ * @par Usage:
+ * @param[in] mo_full_path mo node path
+ * @param[out] root_path node's root path
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get root path
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_get_root_path_wraper(const char *mo_full_path, char **root_path);
+
+/**
+ * API to Add mo node's framework property to mo db
+ * @remarks This function is use to add mo node's framework property to mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[in] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo node's framework property to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Delete mo node's framework property in mo db
+ * @remarks This function is use to delete mo node's framework property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_framework_property_wraper(int mo_node_id);
+
+/**
+ * API to Update mo node's framework property in mo db
+ * @remarks This function is use to update mo node's framework property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[in] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Get mo node's framework property in mo db
+ * @remarks This function is use to get mo node's framework property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[out] framework_property mo node framework property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Delete all mo node's framework property in mo db
+ * @remarks This function is use to delete all mo node's framework property in mo db
+ *
+ * @par Usage:
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo node's framework property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_all_framework_property_wraper(void);
+
+/**
+ * API to Add mo node's runtime property to mo db
+ * @remarks This function is use to add mo node's runtime property to mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[in] runtime_property mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to add mo node's runtime property to mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Delete mo node's runtime property in mo db
+ * @remarks This function is use to delete mo node's runtime property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_runtime_property_wraper(int mo_node_id);
+
+/**
+ * API to Update mo node's runtime property in mo db
+ * @remarks This function is use to update mo node's runtime property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[in] runtime_property mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to update mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Get mo node's runtime property in mo db
+ * @remarks This function is use to get mo node's runtime property in mo db
+ *
+ * @par Usage:
+ * @param[in] mo_node_id mo db id
+ * @param[out] runtime mo node runtime property struct
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       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);
+
+/**
+ * API to Delete all mo node's runtime property in mo db
+ * @remarks This function is use to delete all mo node's runtime property in mo db
+ *
+ * @par Usage:
+ *
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to delete all mo node's runtime property in mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ */
+       sync_agent_dm_mo_error_e dm_mo_delete_all_runtime_property_wraper(void);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* MO_DATABASE_HANDLER_H_ */
diff --git a/src/framework/device-manager/mo_ddf_parser.c b/src/framework/device-manager/mo_ddf_parser.c
new file mode 100755 (executable)
index 0000000..8788a17
--- /dev/null
@@ -0,0 +1,377 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+#include "utility/sync_util.h"
+
+#include <libxml/xmlreader.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "device-manager/mo_parser_properties.h"
+#include "device-manager/mo_ddf_parser.h"
+#include "device-manager/mo_accessor_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+#define DELIMETER "/"
+
+static dm_mo_parse_properties_cb parsing_properties[DM_FRAMEWORK_PROPERTY_COUNT] = {
+       dm_parse_property_access_type,
+       dm_parse_property_default_value,
+       dm_parse_property_description,
+       dm_parse_property_dffFormat,
+       dm_parse_property_occurrence,
+       dm_parse_property_scope,
+       dm_parse_property_df_title,
+       dm_parse_property_df_type
+};
+
+static void _processNode(sync_agent_dm_mo_type_e mo_type, xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node);
+
+static void __set_Node(sync_agent_dm_mo_type_e mo_type, xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node);
+
+static void __set_Path(xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node);
+
+static void __set_Properties(xmlTextReaderPtr reader, sync_agent_dm_mo_framework_property_s * property);
+
+sync_agent_dm_mo_error_e dm_mo_construct_mo_tree_ddf(sync_agent_dm_mo_type_e mo_type, const char *vendar_file, sync_agent_dm_mo_node_s * root_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(vendar_file == NULL, SYNC_AGENT_DM_MO_FAIL, "vendar_file is NULL !!");
+       retvm_if(root_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       xmlTextReaderPtr reader = xmlReaderForFile(vendar_file, NULL, 0);
+       if (reader != NULL) {
+               _processNode(mo_type, reader, root_node);
+               xmlFreeTextReader(reader);
+       } else {
+               _DEBUG_ERROR("Unable to open %s", vendar_file);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+static void _processNode(sync_agent_dm_mo_type_e mo_type, xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(mo_node == NULL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+
+       do {
+               int ret = xmlTextReaderRead(reader);
+               if (ret != 1) {
+                       _DEBUG_TRACE("End Parsing XML");
+                       break;
+               }
+               node_type = xmlTextReaderNodeType(reader);
+               name = (const char *)xmlTextReaderConstName(reader);
+               if (node_type == XML_ELEMENT_NODE) {
+                       if (!strcmp(name, "NodeName")) {
+                               __set_Node(mo_type, reader, mo_node);
+                       } else if (!strcmp(name, "DFProperties")) {
+                               __set_Properties(reader, mo_node->framework_property);
+                       } else if (!strcmp(name, "Path")) {
+                               mo_node->type = SYNC_AGENT_DM_MO_NODE_FIRST;
+                               __set_Path(reader, mo_node);
+                       } else if (!strcmp(name, "Node")) {
+                               sync_agent_dm_mo_node_s *child_node = (sync_agent_dm_mo_node_s *) calloc(1, sizeof(sync_agent_dm_mo_node_s));
+                               if (child_node == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return;
+                               }
+                               child_node->full_path = strdup(mo_node->full_path);
+                               child_node->type = SYNC_AGENT_DM_MO_NODE_LEAF;
+                               child_node->child_node_cnt = 0;
+                               child_node->framework_property = calloc(1, sizeof(sync_agent_dm_mo_framework_property_s));
+                               if (child_node->framework_property == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       dm_free_mo(child_node, 1);
+                                       return;
+                               }
+                               child_node->runtime_property = calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s));
+                               if (child_node->runtime_property == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       dm_free_mo(child_node, 1);
+                                       return;
+                               }
+                               child_node->child_node_list = NULL;
+                               child_node->next_node = NULL;
+                               child_node->parent_node = mo_node;
+                               /*
+                                * Add to Child list
+                                */
+                               mo_node->child_node_cnt++;
+                               sync_agent_dm_mo_node_s *pCursor = mo_node->child_node_list;
+                               if (pCursor == NULL) {
+                                       mo_node->child_node_list = child_node;
+                               } else {
+                                       while (pCursor->next_node != NULL) {
+                                               pCursor = pCursor->next_node;
+                                       }
+
+                                       pCursor->next_node = child_node;
+                               }
+
+                               if ((mo_node->type != SYNC_AGENT_DM_MO_NODE_ROOT) && (mo_node->type != SYNC_AGENT_DM_MO_NODE_FIRST)) {
+                                       mo_node->type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+                               }
+
+                               _processNode(mo_type, reader, child_node);
+                       }
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "Node")));
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __set_Node(sync_agent_dm_mo_type_e mo_type, xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(mo_node == NULL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+
+       do {
+               xmlTextReaderRead(reader);
+
+               node_type = xmlTextReaderNodeType(reader);
+               name = (const char *)xmlTextReaderConstValue(reader);
+
+               if (node_type == XML_TEXT_NODE) {
+                       if (name == NULL) {
+                               name = "";
+                       }
+
+                       if (mo_node->full_path != NULL) {
+                               char *temp = mo_node->full_path;
+                               int full_path_len = strlen(mo_node->full_path) + strlen(name) + strlen(DELIMETER) + 1;
+                               int len = 0;
+                               mo_node->full_path = (char *)calloc(full_path_len, sizeof(char));
+
+                               if (mo_node->full_path != NULL) {
+                                       len = g_strlcat(mo_node->full_path, temp, full_path_len);
+                                       len = g_strlcat(mo_node->full_path, DELIMETER, full_path_len);
+                                       len = g_strlcat(mo_node->full_path, name, full_path_len);
+                                       _DEBUG_VERBOSE(" mo_node->full_path : %s!!", mo_node->full_path);
+
+                                       if (len >= full_path_len) {
+                                               _DEBUG_ERROR("mo_node->full_path buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+
+                                       _DEBUG_VERBOSE(" mo_node name : %s!!", name);
+                                       mo_node->name = strdup(name);
+
+                                       free(temp);
+                               } else {
+                                       _DEBUG_ERROR("alloc fail !!");
+                                       break;
+                               }
+                       }
+                       break;
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "NodeName")));
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __set_Path(xmlTextReaderPtr reader, sync_agent_dm_mo_node_s * mo_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(mo_node == NULL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       int node_type;
+       char *name = NULL;
+
+       do {
+               xmlTextReaderRead(reader);
+
+               node_type = xmlTextReaderNodeType(reader);
+               name = (char *)xmlTextReaderConstValue(reader);
+
+               if (node_type == XML_TEXT_NODE) {
+                       if (name == NULL) {
+                               name = "";
+                       }
+                       _DEBUG_VERBOSE("name : %s", name);
+                       _DEBUG_VERBOSE("mo_parent_node : %s", mo_node->parent_node->name);
+                       if (!strcmp(name, mo_node->parent_node->name)) {
+                               _DEBUG_VERBOSE("Already <Path> is same root path");
+                               break;
+                       }
+
+                       sync_agent_dm_mo_node_s *parent_node = mo_node->parent_node;
+                       char *last_delimit = name;
+
+                       do {
+                               last_delimit = strchr(last_delimit, '/');
+                               if (last_delimit == NULL) {
+                                       break;
+                               }
+                               last_delimit += 1;
+
+                               char *cursor = last_delimit;
+                               while (*cursor != '\0') {
+                                       if (*cursor == '/') {
+                                               break;
+                                       }
+                                       cursor++;
+                               }
+
+                               int node_len = cursor - last_delimit;
+                               char *node_name = (char *)calloc(node_len + 1, sizeof(char));
+                               if (node_name == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return;
+                               }
+                               strncpy(node_name, last_delimit, node_len);
+
+                               int full_path_len = cursor - name;
+                               char *full_path = (char *)calloc(full_path_len + 1, sizeof(char));
+                               if (full_path == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       free(node_name);
+                                       return;
+                               }
+                               strncpy(full_path, name, full_path_len);
+
+                               _DEBUG_VERBOSE("node_name : %s", node_name);
+                               _DEBUG_VERBOSE("full_path : %s", full_path);
+
+                               /*
+                                * Resetting Link
+                                */
+                               sync_agent_dm_mo_node_s *new_mo_node = (sync_agent_dm_mo_node_s *) calloc(1, sizeof(sync_agent_dm_mo_node_s));
+                               if (new_mo_node == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       free(node_name);
+                                       free(full_path);
+                                       return;
+                               }
+                               new_mo_node->name = node_name;
+                               new_mo_node->full_path = full_path;
+                               new_mo_node->type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+                               new_mo_node->framework_property = (sync_agent_dm_mo_framework_property_s *) calloc(1, sizeof(sync_agent_dm_mo_framework_property_s));
+                               if (new_mo_node->framework_property == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       dm_free_mo(new_mo_node, 1);
+                                       return;
+                               }
+                               new_mo_node->runtime_property = (sync_agent_dm_mo_runtime_property_s *) calloc(1, sizeof(sync_agent_dm_mo_runtime_property_s));
+                               if (new_mo_node->runtime_property == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       dm_free_mo(new_mo_node, 1);
+                                       return;
+                               }
+                               new_mo_node->parent_node = parent_node;
+                               parent_node->child_node_list = new_mo_node;
+
+                               parent_node = new_mo_node;
+
+                       } while (last_delimit != NULL);
+
+                       _DEBUG_VERBOSE("New=========");
+                       /*
+                        * Resetting full_path of mo_node
+                        */
+                       parent_node->child_node_list = mo_node;
+                       mo_node->parent_node = parent_node;
+
+                       if (parent_node->full_path != NULL) {
+                               int full_path_len = strlen(parent_node->full_path) + strlen("/") + strlen(mo_node->name) + 1;
+                               int len = 0;
+                               mo_node->full_path = (char *)calloc(full_path_len, sizeof(char));
+
+                               if (mo_node->full_path != NULL) {
+                                       len = g_strlcat(mo_node->full_path, parent_node->full_path, full_path_len);
+                                       len = g_strlcat(mo_node->full_path, "/", full_path_len);
+                                       len = g_strlcat(mo_node->full_path, mo_node->name, full_path_len);
+
+                                       if (len >= full_path_len) {
+                                               _DEBUG_ERROR("mo_node->full_path buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+
+                                       _DEBUG_VERBOSE("New Full_path : %s, %d", mo_node->full_path, mo_node->type);
+                               }
+                       }
+                       break;
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "Path")));
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __set_Properties(xmlTextReaderPtr reader, sync_agent_dm_mo_framework_property_s * property)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(property == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+
+       do {
+               xmlTextReaderRead(reader);
+
+               node_type = xmlTextReaderNodeType(reader);
+               name = (const char *)xmlTextReaderConstName(reader);
+
+               dm_framework_property_e index = DM_FRAMEWORK_PROPERTY_COUNT;
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       if (!strcmp(name, "AccessType")) {
+                               index = DM_FRAMEWORK_PROPERTY_ACCESSTYPE;
+                       } else if (!strcmp(name, "DefaultValue")) {
+                               index = DM_FRAMEWORK_PROPERTY_DEFAULT_VALUE;
+                       } else if (!strcmp(name, "Description")) {
+                               index = DM_FRAMEWORK_PROPERTY_DESCRIPTION;
+                       } else if (!strcmp(name, "DFFormat")) {
+                               index = DM_FRAMEWORK_PROPERTY_DFF_FORMAT;
+                       } else if (!strcmp(name, "Occurrence")) {
+                               index = DM_FRAMEWORK_PROPERTY_OCCURRENCE;
+                       } else if (!strcmp(name, "Scope")) {
+                               index = DM_FRAMEWORK_PROPERTY_SCOPE;
+                       } else if (!strcmp(name, "DFTitle")) {
+                               index = DM_FRAMEWORK_PROPERTY_DF_TITLE;
+                       } else if (!strcmp(name, "DFType")) {
+                               index = DM_FRAMEWORK_PROPERTY_DF_TYPE;
+                       }
+
+                       if (index != DM_FRAMEWORK_PROPERTY_COUNT) {
+                               parsing_properties[index] (&reader, property);
+                       }
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "DFProperties")));
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/device-manager/mo_ddf_parser.h b/src/framework/device-manager/mo_ddf_parser.h
new file mode 100755 (executable)
index 0000000..8bc60b0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_DDF_PARSER_H_
+#define MO_DDF_PARSER_H_
+
+#include "device-manager/mo_error.h"
+#include "device-manager/mo_struct.h"
+
+/**
+ * @file       mo_ddf_parser.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+/**
+ * API to Construct mo tree from ddf file
+ * @remarks This function is use to construct mo tree from ddf file
+ *
+ * @par Usage:
+ *
+ * @param[in] mo_type mo node type
+ * @param[in] vendar_file defined ddf xml text file
+ * @param[in] root_node mo node struct
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to construct mo tree from ddf file
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_mo_construct_mo_tree_ddf(sync_agent_dm_mo_type_e mo_type, const char *vendar_file, sync_agent_dm_mo_node_s * root_node);
+
+/**
+ *     @}
+ */
+#endif                         /* MO_DDF_PARSER_H_ */
diff --git a/src/framework/device-manager/mo_executor.c b/src/framework/device-manager/mo_executor.c
new file mode 100755 (executable)
index 0000000..9e06af6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include "device-manager/mo_executor.h"
+#include "device-manager/mo_accessor.h"
+#include "plugin/mo_plugin.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+EXPORT_API sync_agent_dm_mo_error_e sync_agent_execute_mo_ext(const char *mo_path, int *err_num, int check_operation)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_path is NULL !!");
+
+       sync_agent_dm_mo_error_e ret = SYNC_AGENT_DM_MO_SUCCESS;
+
+       /* 1. check fumo or lawmo for mo_path */
+       sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+       sync_agent_dm_mo_type_e mo_type;
+       err_code = sync_agent_get_mo_type(mo_path, &mo_type);
+       _DEBUG_INFO("get mo type result : %d", err_code);
+
+       int mo_plugIn_id = plugin_get_mo_plugin_id(mo_type);
+
+       /* 2.  get function pointer  & call */
+       plugin_execute_ext func_point_execute_ext = plugin_get_function_execute_ext(mo_plugIn_id);
+       if (func_point_execute_ext == NULL) {
+               _DEBUG_ERROR("func_point_execute_ext is NULL\n");
+               ret = SYNC_AGENT_DM_MO_FAIL;
+               goto return_part;
+       }
+
+       int err = func_point_execute_ext(mo_path, err_num, check_operation);
+       if (err != 1) {
+               _DEBUG_ERROR("Execute_Ext() Fail!!\n");
+               ret = SYNC_AGENT_DM_MO_FAIL;
+       }
+       _DEBUG_INFO("Execute_Ext() Success!!\n");
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
diff --git a/src/framework/device-manager/mo_parser_properties.c b/src/framework/device-manager/mo_parser_properties.c
new file mode 100755 (executable)
index 0000000..a551e2d
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+#include "utility/sync_util.h"
+
+#include "device-manager/mo_parser_properties.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+void dm_parse_property_access_type(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+//      framework->accessType = 0x00;
+       framework->accessType = SYNC_AGENT_DM_MO_ACCESSTYPE_NO_SET;
+
+       int node_type;
+       const char *name = NULL;
+
+       do {
+               xmlTextReaderRead(*reader);
+
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       if (!strcmp(name, "Add")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_ADD;
+                       } else if (!strcmp(name, "Copy")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_COPY;
+                       } else if (!strcmp(name, "Delete")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE;
+                       } else if (!strcmp(name, "Exec")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC;
+                       } else if (!strcmp(name, "Get")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_GET;
+                       } else if (!strcmp(name, "Replace")) {
+                               framework->accessType = framework->accessType | SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE;
+                       }
+               }
+
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "AccessType")));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_default_value(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+       const char *value = NULL;
+
+       do {
+               xmlTextReaderRead(*reader);
+
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+               value = (const char *)xmlTextReaderConstValue(*reader);
+
+               if (node_type == XML_TEXT_NODE) {
+                       if (value == NULL) {
+                               value = "";
+                       }
+                       framework->defaultValue = strdup(value);
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "DefaultValue")) && (node_type != XML_DTD_NODE));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_description(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+       const char *value = NULL;
+
+       do {
+               xmlTextReaderRead(*reader);
+
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+               value = (const char *)xmlTextReaderConstValue(*reader);
+
+               if (node_type == XML_TEXT_NODE) {
+                       if (value == NULL) {
+                               value = "";
+                       }
+
+                       framework->description = strdup(value);
+
+                       break;
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "Description")) && (node_type != XML_DTD_NODE));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_dffFormat(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       while (1) {
+               xmlTextReaderRead(*reader);
+
+               int node_type = xmlTextReaderNodeType(*reader);
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       const char *name = (const char *)xmlTextReaderConstName(*reader);
+                       if (!strcmp(name, "b64")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_B64;
+                       } else if (!strcmp(name, "bin")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_BIN;
+                       } else if (!strcmp(name, "bool")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_BOOL;
+                       } else if (!strcmp(name, "chr")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_CHR;
+                       } else if (!strcmp(name, "int")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_INT;
+                       } else if (!strcmp(name, "node")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_NODE;
+                       } else if (!strcmp(name, "null")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_NULL;
+                       } else if (!strcmp(name, "xml")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_XML;
+                       } else if (!strcmp(name, "date")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_DATE;
+                       } else if (!strcmp(name, "time")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_TIME;
+                       } else if (!strcmp(name, "float")) {
+                               framework->dffFormat = SYNC_AGENT_DM_MO_FORMAT_FLOAT;
+                       }
+
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_occurrence(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+       int flag = 0;
+
+       do {
+               xmlTextReaderRead(*reader);
+
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       if (!strcmp(name, "One")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ONE;
+                       } else if (!strcmp(name, "ZeroOrOne")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORONE;
+                       } else if (!strcmp(name, "ZeroOrMore")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORMORE;
+                       } else if (!strcmp(name, "OneOrMore")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ONEORMORE;
+                       } else if (!strcmp(name, "ZeroOrN")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ZEROORN;
+                       } else if (!strcmp(name, "OneOrN")) {
+                               framework->occurrence = SYNC_AGENT_DM_MO_OCCURRENCE_ONEORN;
+                       }
+
+                       flag = 1;
+               } else if (node_type == XML_TEXT_NODE && flag == 1) {
+                       const char *occurrence_num = (const char *)xmlTextReaderConstValue(*reader);
+                       if (occurrence_num != NULL) {
+                               framework->occurrence_num = atoi(occurrence_num);
+                       }
+                       break;
+               }
+
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "Occurrence")));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_scope(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       while (1) {
+               xmlTextReaderRead(*reader);
+
+               int node_type = xmlTextReaderNodeType(*reader);
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       const char *name = (const char *)xmlTextReaderConstName(*reader);
+                       if (!strcmp(name, "Permanent")) {
+                               framework->scope = SYNC_AGENT_DM_MO_SCOPE_PERMANENT;
+                       } else if (!strcmp(name, "Dynamic")) {
+                               framework->scope = SYNC_AGENT_DM_MO_SCOPE_DYNAMIC;
+                       }
+
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_df_title(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+       const char *value = NULL;
+
+       do {
+               xmlTextReaderRead(*reader);
+
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+               value = (const char *)xmlTextReaderConstValue(*reader);
+               /*
+                  const char *baseURL = (const char *)xmlTextReaderConstBaseUri(*reader);
+                  const char *localName = (const char *)xmlTextReaderConstLocalName(*reader);
+                  const char *namespace = (const char *)xmlTextReaderConstNamespaceUri(*reader);
+                  const char *prefix = (const char *)xmlTextReaderConstPrefix(*reader);
+                  const char *xmlLang = (const char *)xmlTextReaderConstXmlLang(*reader);
+                */
+               if (node_type == XML_TEXT_NODE) {
+                       if (value == NULL) {
+                               value = "";
+                       }
+
+                       framework->dfTitle = strdup(value);
+
+                       break;
+               } else {
+
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "DFTitle")) && (node_type != XML_DTD_NODE));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void dm_parse_property_df_type(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(framework == NULL, "sync_agent_dm_mo_framework_property_s is NULL !!");
+
+       int node_type;
+       const char *name = NULL;
+       int start_depth = xmlTextReaderDepth(*reader);
+       int flag = 0;
+       do {
+               xmlTextReaderRead(*reader);
+               node_type = xmlTextReaderNodeType(*reader);
+               name = (const char *)xmlTextReaderConstName(*reader);
+               int current_depth = xmlTextReaderDepth(*reader);
+               /* _DEBUG_INFO("node_type : %d, name : %s, isEmpty : %d", node_type, name, isEmpty);        */
+
+               if (node_type == XML_ELEMENT_NODE) {
+                       if (!strcmp(name, "MIME")) {
+                               framework->dfType = SYNC_AGENT_DM_MO_DF_TYPE_MIME;
+                       } else if (!strcmp(name, "DDFName")) {
+                               framework->dfType = SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME;
+                       }
+                       flag = 1;
+               } else if (node_type == XML_TEXT_NODE && flag == 1) {
+                       const char *dfType_Value = (const char *)xmlTextReaderConstValue(*reader);
+                       if (dfType_Value == NULL) {
+                               dfType_Value = "";
+                       }
+                       framework->dfType_Value = strdup(dfType_Value);
+                       break;
+               } else if (node_type == XML_DTD_NODE) {
+                       if (start_depth == current_depth) {
+                               break;
+                       }
+               }
+       } while (!(node_type == XML_ELEMENT_DECL && !strcmp(name, "DFType")));
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/device-manager/mo_parser_properties.h b/src/framework/device-manager/mo_parser_properties.h
new file mode 100755 (executable)
index 0000000..727f5ea
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_PROPERTIES_H_
+#define MO_PROPERTIES_H_
+
+#include <libxml/xmlreader.h>
+
+#include "device-manager/mo_struct.h"
+
+/**
+ * @file       mo_parser_properties.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+typedef enum {
+       DM_FRAMEWORK_PROPERTY_ACCESSTYPE = 0,   /**< framework property accesstype */
+       DM_FRAMEWORK_PROPERTY_DEFAULT_VALUE,    /**< framework property default value */
+       DM_FRAMEWORK_PROPERTY_DESCRIPTION,              /**< framework property description */
+       DM_FRAMEWORK_PROPERTY_DFF_FORMAT,               /**< framework property ddf format */
+       DM_FRAMEWORK_PROPERTY_OCCURRENCE,               /**< framework property occurrence */
+       DM_FRAMEWORK_PROPERTY_SCOPE,                    /**< framework property scope */
+       DM_FRAMEWORK_PROPERTY_DF_TITLE,                 /**< framework property df title */
+       DM_FRAMEWORK_PROPERTY_DF_TYPE,                  /**< framework property df type */
+       DM_FRAMEWORK_PROPERTY_COUNT                             /**< framework property count */
+} dm_framework_property_e;
+
+/**
+ * API to Callback function define
+ * @remarks This function is use to parse mo properties tag
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+typedef void (*dm_mo_parse_properties_cb) (xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property accesstype
+ * @remarks This function is use to parse property accesstype
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property accesstype
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_access_type(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property default value
+ * @remarks This function is use to parse property default value
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property default value
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_default_value(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property description
+ * @remarks This function is use to parse property description
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property description
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_description(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property ddf format
+ * @remarks This function is use to parse property ddf format
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property ddf format
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_dffFormat(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property occurrence
+ * @remarks This function is use to parse property occurrence
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property occurrence
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_occurrence(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property scope
+ * @remarks This function is use to parse property scope
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property scope
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_scope(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property df title
+ * @remarks This function is use to parse property df title
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property df title
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_df_title(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ * API to Parse property df type
+ * @remarks This function is use to parse property df type
+ *
+ * @par Usage:
+ *
+ * @param[in] reader   xmltext reader
+ * @param[in] framework mo framework property
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to parse property df type
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+void dm_parse_property_df_type(xmlTextReaderPtr * reader, sync_agent_dm_mo_framework_property_s * framework);
+
+/**
+ *     @}
+ */
+
+#endif                         /* MO_PROPERTIES_H_ */
diff --git a/src/framework/device-manager/mo_tnds_processor.c b/src/framework/device-manager/mo_tnds_processor.c
new file mode 100755 (executable)
index 0000000..1d60ecf
--- /dev/null
@@ -0,0 +1,615 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <wbxml/wbxml.h>
+
+#include "utility/sync_util.h"
+
+#include "protocol-binder/interface.h"
+#include "device-manager/mo_accessor_internal.h"
+#include "device-manager/mo_accessor.h"
+
+#include "device-manager/mo_tnds_processor.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_MO"
+#endif
+
+typedef struct {
+       sync_agent_dm_tnds_action_e tnds_action;
+       sync_agent_dm_mo_type_e mo_type;
+       char *mo_full_path;
+} dm_tnds_binder_data_s;
+
+static WBXMLTreeNode *__construct_TNDS_NODE(sync_agent_dm_mo_node_s * mo_node, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * ppWbxml_parent_node);
+static WBXMLTreeNode *__recursive_contruct_TNDS(sync_agent_dm_mo_node_s * mo_parent_node, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * ppWbxml_parent_node);
+static void __recursive_contruct_MO_TABLE(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_mo_type_e mo_type, char *mo_parent_path, WBXMLTreeNode * pWbxml_dom_node);
+
+static sync_agent_pb_error_e _mgmttree_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _verdtd_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _node_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _node_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+
+const sync_agent_pb_function_info_s tnds_binder_function_info[] = {
+       {DM_TNDS_TAG_MGMTTREE_START, "MgmtTree", _mgmttree_start_converter_function, NULL, false},
+       {DM_TNDS_TAG_MGMTTREE_END, "/MgmtTree", NULL, NULL, false},
+       {DM_TNDS_TAG_VERDTD, "VerDTD", _verdtd_converter_function, NULL, true},
+       {DM_TNDS_TAG_NODE_START, "Node", _node_start_converter_function, _node_start_reverse_converter_function, false},
+       {DM_TNDS_TAG_NODE_END, "/Node", NULL, NULL, false}
+};
+
+sync_agent_dm_mo_error_e dm_get_tnds_from_db(sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_node_s * root_node, char **output_tnds, unsigned int *byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(root_node == NULL, SYNC_AGENT_DM_MO_FAIL, "sync_agent_dm_mo_node_s is NULL !!");
+
+       sync_agent_dm_mo_error_e mo_error = SYNC_AGENT_DM_MO_SUCCESS;
+
+       sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+       sync_agent_pb_error_e pb_error = sync_agent_init_binder_function_set(sizeof(tnds_binder_function_info) / sizeof(sync_agent_pb_function_info_s),
+                                                                            (sync_agent_pb_function_info_s *) tnds_binder_function_info, &pBinder_function_set);
+
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_ERROR("Failed to sync_agent_init_binder_function_set()");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /* protocol binder initialization */
+       sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+       switch (tnds_type) {
+       case SYNC_AGENT_DM_MO_TNDS_TYPE_XML:
+               {
+                       pBinder = sync_agent_init_protocol_binder(NULL, SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12, NULL, SYNC_AGENT_PB_ENCODING_XML, false, false, false, false, false, NULL, NULL, pBinder_function_set);
+               }
+               break;
+       case SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML:
+               {
+                       pBinder = sync_agent_init_protocol_binder(NULL, SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12, NULL, SYNC_AGENT_PB_ENCODING_WBXML_13, false, false, false, false, false, NULL, NULL, pBinder_function_set);
+               }
+               break;
+       default:
+               _DEBUG_ERROR("TNDS TYPE [%d], Framework could not support!!", tnds_type);
+               break;
+       }
+
+       pb_error = sync_agent_append_element(pBinder, DM_TNDS_TAG_MGMTTREE_START, NULL);
+
+       pb_error = sync_agent_append_element(pBinder, DM_TNDS_TAG_VERDTD, NULL);
+
+       pb_error = sync_agent_append_element(pBinder, DM_TNDS_TAG_NODE_START, root_node);
+       pb_error = sync_agent_append_element(pBinder, DM_TNDS_TAG_NODE_END, NULL);
+
+       pb_error = sync_agent_append_element(pBinder, DM_TNDS_TAG_MGMTTREE_END, NULL);
+
+       pb_error = sync_agent_get_stream_from_protocol_binder(pBinder, output_tnds, byte_size);
+
+       char *xml = NULL;
+       unsigned int xml_size = 0;
+       pb_error = sync_agent_get_xml_from_protocol_binder(pBinder, &xml, &xml_size);
+
+       fprintf(stderr, "xmlsize = %d, xml =\n%s\n", xml_size, xml);
+
+       sync_agent_destroy_protocol_binder(pBinder);
+
+       _EXTERN_FUNC_EXIT;
+
+       return mo_error;
+}
+
+sync_agent_dm_mo_error_e dm_insert_tnds_to_db(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char *input_stream, unsigned int byte_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(mo_full_path == NULL, SYNC_AGENT_DM_MO_FAIL, "mo_full_path is NULL !!");
+
+       sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+       sync_agent_pb_error_e pb_error = sync_agent_init_binder_function_set(sizeof(tnds_binder_function_info) / sizeof(sync_agent_pb_function_info_s),
+                                                                            (sync_agent_pb_function_info_s *) tnds_binder_function_info, &pBinder_function_set);
+
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_ERROR("Failed to sync_agent_init_binder_function_set()");
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       /*
+        * reverse protocol binder initialization
+        * */
+       sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+       sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+       dm_tnds_binder_data_s binder_data;
+       binder_data.tnds_action = tnds_action;
+       binder_data.mo_full_path = (char *)mo_full_path;
+       binder_data.mo_type = mo_type;
+
+       switch (tnds_type) {
+       case SYNC_AGENT_DM_MO_TNDS_TYPE_XML:
+               {
+                       pb_error = sync_agent_init_reverse_protocol_binder(input_stream, byte_size, SYNC_AGENT_PB_DECODING_XML, &protocol, pBinder_function_set, &binder_data, &pBinder);
+               }
+               break;
+       case SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML:
+               {
+                       pb_error = sync_agent_init_reverse_protocol_binder(input_stream, byte_size, SYNC_AGENT_PB_DECODING_WBXML, &protocol, pBinder_function_set, NULL, &pBinder);
+               }
+               break;
+       default:
+               _DEBUG_ERROR("TNDS TYPE [%d], Framework could not support!!", tnds_type);
+               break;
+       }
+
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_ERROR("Failed to sync_agent_init_reverse_protocol_binder()");
+               sync_agent_destroy_reverse_protocol_binder(pBinder);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       if (protocol != SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12) {
+               _DEBUG_ERROR("Failed to sync_agent_init_reverse_protocol_binder()");
+               sync_agent_destroy_reverse_protocol_binder(pBinder);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       Protocol_Element protocol_element;
+       char *protocol_element_name = NULL;
+       Content_Ptr content = NULL;
+
+       pb_error = sync_agent_next_element(pBinder, &protocol_element, &protocol_element_name, &content);
+
+       sync_agent_destroy_reverse_protocol_binder(pBinder);
+
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_ERROR("Failed to sync_agent_next_element()");
+               sync_agent_destroy_reverse_protocol_binder(pBinder);
+               return SYNC_AGENT_DM_MO_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DM_MO_SUCCESS;
+}
+
+/**************************************** Impl static function *******************************************/
+
+static WBXMLTreeNode *__construct_TNDS_NODE(sync_agent_dm_mo_node_s * mo_node, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * ppWbxml_parent_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_node == NULL, NULL, "sync_agent_dm_mo_node_s is NULL !!");
+       retvm_if(pBinder == NULL, NULL, "sync_agent_pb_protocol_binder_info_s is NULL !!");
+
+       WBXMLTreeNode *node_node = NULL;
+
+       if (ppWbxml_parent_node == NULL) {
+               node_node = sync_agent_create_node(pBinder, DM_TNDS_ELEMENT_NODE);
+       } else {
+               node_node = sync_agent_add_child_node(pBinder, ppWbxml_parent_node, DM_TNDS_ELEMENT_NODE);
+       }
+
+       if (node_node == NULL) {
+               return NULL;
+       }
+
+       sync_agent_add_child_text_node(pBinder, node_node, DM_TNDS_ELEMENT_NODENAME, mo_node->name, strlen(mo_node->name));
+
+       WBXMLTreeNode *rtproperties_node = sync_agent_add_child_node(pBinder, node_node, DM_TNDS_ELEMENT_RTPROPERTIES);
+
+       sync_agent_dm_mo_runtime_property_s *runtime_property = mo_node->runtime_property;
+       if (runtime_property != NULL) {
+               int acl_len = 0;
+               if (runtime_property->acl != NULL) {
+                       acl_len = strlen(runtime_property->acl);
+               }
+               sync_agent_add_child_text_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_ACL, runtime_property->acl, acl_len);
+
+               WBXMLTreeNode *format_node = sync_agent_add_child_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_FORMAT);
+               switch (runtime_property->format) {
+               case SYNC_AGENT_DM_MO_FORMAT_B64:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_B64);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_BIN:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_BIN);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_BOOL:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_BOOL);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_CHR:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_CHR);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_INT:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_INT);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_NODE:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_NODE);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_NULL:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_NULL);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_XML:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_XML);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_DATE:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_DATE);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_TIME:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_TIME);
+                       break;
+               case SYNC_AGENT_DM_MO_FORMAT_FLOAT:
+                       sync_agent_add_child_node(pBinder, format_node, DM_TNDS_ELEMENT_FORMAT_FLOAT);
+                       break;
+               default:
+                       break;
+               }
+
+               int title_len = 0;
+               if (runtime_property->title != NULL) {
+                       title_len = strlen(runtime_property->title);
+               }
+               sync_agent_add_child_text_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_TITLE, runtime_property->title, title_len);
+
+               int tstamp_len = 0;
+               if (runtime_property->tStamp != NULL) {
+                       tstamp_len = strlen(runtime_property->tStamp);
+               }
+               sync_agent_add_child_text_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_TSTAMP, runtime_property->tStamp, tstamp_len);
+
+               WBXMLTreeNode *type_node = sync_agent_add_child_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_TYPE);
+               int value_len = 0;
+               if (runtime_property->type_value != NULL) {
+                       value_len = strlen(runtime_property->type_value);
+               }
+               switch (runtime_property->type) {
+               case SYNC_AGENT_DM_MO_DF_TYPE_MIME:
+                       sync_agent_add_child_text_node(pBinder, type_node, DM_TNDS_ELEMENT_TYPE_MIME, runtime_property->type_value, value_len);
+                       break;
+               case SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME:
+                       sync_agent_add_child_text_node(pBinder, type_node, DM_TNDS_ELEMENT_TYPE_DDFNAME, runtime_property->type_value, value_len);
+                       break;
+               default:
+                       break;
+               }
+
+               int verno_len = 0;
+               if (runtime_property->verNo != NULL) {
+                       verno_len = strlen(runtime_property->verNo);
+               }
+               sync_agent_add_child_text_node(pBinder, rtproperties_node, DM_TNDS_ELEMENT_VERNO, runtime_property->verNo, verno_len);
+       }
+
+       if (mo_node->type == SYNC_AGENT_DM_MO_NODE_LEAF) {
+               int value_len = 0;
+               if (mo_node->value != NULL) {
+                       value_len = strlen(mo_node->value);
+               }
+               sync_agent_add_child_text_node(pBinder, node_node, DM_TNDS_ELEMENT_VALUE, mo_node->value, value_len);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return node_node;
+}
+
+static WBXMLTreeNode *__recursive_contruct_TNDS(sync_agent_dm_mo_node_s * mo_parent_node, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * ppWbxml_parent_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(mo_parent_node == NULL, NULL, "sync_agent_dm_mo_node_s is NULL !!");
+       retvm_if(pBinder == NULL, NULL, "sync_agent_pb_protocol_binder_info_s is NULL !!");
+
+       int i = 0;
+       _DEBUG_VERBOSE("%d", mo_parent_node->child_node_cnt);
+       _DEBUG_VERBOSE("%s", mo_parent_node->name);
+
+       for (; i < mo_parent_node->child_node_cnt; i++) {
+               sync_agent_dm_mo_node_s *mo_node = &(mo_parent_node->child_node_list[i]);
+               _DEBUG_VERBOSE("[%d] mo_node->name : %s", i, mo_node->name);
+
+               WBXMLTreeNode *node_node = __construct_TNDS_NODE(mo_node, pBinder, ppWbxml_parent_node);
+
+               __recursive_contruct_TNDS(mo_node, pBinder, node_node);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;
+}
+
+static void __recursive_contruct_MO_TABLE(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_mo_type_e mo_type, char *mo_parent_path, WBXMLTreeNode * wbxml_dom_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(mo_parent_path == NULL, "mo_parent_path is NULL !!");
+       retm_if(wbxml_dom_node == NULL, "WBXMLTreeNode is NULL !!");
+
+       WBXMLTreeNode *pCursor = wbxml_dom_node->children;
+       int hasChildNode = 0;
+       sync_agent_dm_mo_node_s mo_node;
+       sync_agent_dm_mo_runtime_property_s mo_runtime_property;
+       memset(&mo_node, 0x00, sizeof(sync_agent_dm_mo_node_s));
+       memset(&mo_runtime_property, 0x00, sizeof(sync_agent_dm_mo_runtime_property_s));
+       mo_node.runtime_property = &mo_runtime_property;
+
+       while (pCursor != NULL) {
+               if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+                       const char *tag_name = (const char *)wbxml_tag_get_xml_name(pCursor->name);
+                       if (!strcmp(tag_name, DM_TNDS_ELEMENT_NODENAME)) {
+                               char *node_name = NULL;
+                               sync_agent_pb_error_e err_code = sync_agent_get_text_from_node(pCursor, &node_name);
+                               if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                       _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                               }
+
+                               mo_node.name = node_name;
+                               /*
+                                * full_path = mo_parent_path + "/" + node_name
+                                */
+                               int full_path_length = strlen(mo_parent_path) + strlen("/") + strlen(node_name) + 1;
+                               mo_node.full_path = (char *)calloc(full_path_length, sizeof(char));
+
+                               if (mo_node.full_path != NULL) {
+                                       snprintf(mo_node.full_path, full_path_length, "%s/%s", mo_parent_path, node_name);
+                                       _DEBUG_VERBOSE("node_name : %s, full_path : %s", node_name, mo_node.full_path);
+                               }
+                       } else if (!strcmp(tag_name, DM_TNDS_ELEMENT_VALUE)) {
+                               char *node_value = NULL;
+                               sync_agent_pb_error_e err_code = sync_agent_get_text_from_node(pCursor, &node_value);
+                               if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                       _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                               }
+                               _DEBUG_VERBOSE("node_value : %s", node_value);
+                               mo_node.value = node_value;
+                       } else if (!strcmp(tag_name, DM_TNDS_ELEMENT_RTPROPERTIES)) {
+                               sync_agent_pb_error_e err_code = SYNC_AGENT_PB_RETURN_OK;
+                               WBXMLTreeNode *pCursor_rtproperties = pCursor->children;
+                               while (pCursor_rtproperties != NULL) {
+                                       if (pCursor_rtproperties->type == WBXML_TREE_ELEMENT_NODE) {
+                                               const char *rtproperties_tag_name = (const char *)wbxml_tag_get_xml_name(pCursor_rtproperties->name);
+                                               if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_ACL)) {
+                                                       err_code = sync_agent_get_text_from_node(pCursor_rtproperties, &(mo_node.runtime_property->acl));
+                                                       if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                                               _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                                                       }
+                                               } else if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_FORMAT)) {
+                                                       WBXMLTreeNode *pCursor_format = pCursor_rtproperties->children;
+                                                       while (pCursor_format != NULL) {
+                                                               if (pCursor_format->type == WBXML_TREE_ELEMENT_NODE) {
+                                                                       const char *format_tag_name = (const char *)wbxml_tag_get_xml_name(pCursor_format->name);
+                                                                       if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_B64)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_B64;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_BIN)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_BIN;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_BOOL)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_BOOL;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_CHR)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_CHR;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_INT)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_INT;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_NODE)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_NODE;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_NULL)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_NULL;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_XML)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_XML;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_DATE)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_DATE;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_TIME)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_TIME;
+                                                                       } else if (!strcmp(format_tag_name, DM_TNDS_ELEMENT_FORMAT_FLOAT)) {
+                                                                               mo_node.runtime_property->format = SYNC_AGENT_DM_MO_FORMAT_FLOAT;
+                                                                       }
+                                                                       break;
+                                                               }
+                                                               pCursor_format = pCursor_format->next;
+                                                       }
+                                               } else if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_TITLE)) {
+                                                       err_code = sync_agent_get_text_from_node(pCursor_rtproperties, &(mo_node.runtime_property->title));
+                                                       if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                                               _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                                                       }
+                                               } else if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_TSTAMP)) {
+                                                       err_code = sync_agent_get_text_from_node(pCursor_rtproperties, &(mo_node.runtime_property->tStamp));
+                                                       if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                                               _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                                                       }
+                                               } else if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_TYPE)) {
+                                                       WBXMLTreeNode *pCursor_type = pCursor_rtproperties->children;
+                                                       while (pCursor_type != NULL) {
+                                                               if (pCursor_type->type == WBXML_TREE_ELEMENT_NODE) {
+                                                                       const char *type_tag_name = (const char *)wbxml_tag_get_xml_name(pCursor_type->name);
+                                                                       if (!strcmp(type_tag_name, DM_TNDS_ELEMENT_TYPE_DDFNAME)) {
+                                                                               mo_node.runtime_property->type = SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME;
+                                                                       } else if (!strcmp(type_tag_name, DM_TNDS_ELEMENT_TYPE_MIME)) {
+                                                                               mo_node.runtime_property->type = SYNC_AGENT_DM_MO_DF_TYPE_MIME;
+                                                                       }
+                                                                       err_code = sync_agent_get_text_from_node(pCursor_type, &(mo_node.runtime_property->type_value));
+                                                                       if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                                                               _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                                                                       }
+
+                                                                       break;
+                                                               }
+                                                               pCursor_type = pCursor_type->next;
+                                                       }
+                                               } else if (!strcmp(rtproperties_tag_name, DM_TNDS_ELEMENT_VERNO)) {
+                                                       err_code = sync_agent_get_text_from_node(pCursor_rtproperties, &(mo_node.runtime_property->verNo));
+                                                       if (err_code != SYNC_AGENT_PB_RETURN_OK) {
+                                                               _DEBUG_ERROR("Failed to call sync_agent_get_text_from_node()");
+                                                       }
+                                               }
+                                       }
+
+                                       pCursor_rtproperties = pCursor_rtproperties->next;
+                               }
+                       } else if (!strcmp(tag_name, DM_TNDS_ELEMENT_NODE)) {
+                               hasChildNode = 1;
+                       }
+               }
+               pCursor = pCursor->next;
+       }
+
+       mo_node.framework_property = NULL;
+
+       /*
+        * Process sync_agent_dm_mo_node_s
+        */
+       sync_agent_begin_transaction_mo();
+
+       if (hasChildNode) {
+               mo_node.type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+       } else {
+               mo_node.type = SYNC_AGENT_DM_MO_NODE_LEAF;
+       }
+
+       switch (tnds_action) {
+       case SYNC_AGENT_DM_MO_TNDS_ACTION_ADD:
+               {
+                       sync_agent_dm_mo_error_e mo_err = dm_add_mo(mo_type, mo_node.full_path, &mo_node);
+                       if (mo_err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to call sync_agent_add_mo(%d, %s)", mo_type, mo_node.full_path);
+                       }
+               }
+               break;
+       case SYNC_AGENT_DM_MO_TNDS_ACTION_REPLACE:
+               {
+                       sync_agent_dm_mo_error_e mo_err = dm_update_mo(mo_type, &mo_node);
+                       if (mo_err != SYNC_AGENT_DM_MO_SUCCESS) {
+                               _DEBUG_ERROR("Failed to call sync_agent_update_mo(%d, %s)", mo_type, mo_node.full_path);
+                       }
+               }
+               break;
+       }
+
+       sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+
+       /*
+        * Process Child Nodes recursively
+        */
+       if (hasChildNode != 0) {
+               pCursor = wbxml_dom_node->children;
+               while (pCursor != NULL) {
+                       if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+                               const char *tag_name = (const char *)wbxml_tag_get_xml_name(pCursor->name);
+                               if (!strcmp(tag_name, DM_TNDS_ELEMENT_NODE)) {
+                                       __recursive_contruct_MO_TABLE(tnds_action, mo_type, mo_node.full_path, pCursor);
+                               }
+                       }
+
+                       pCursor = pCursor->next;
+               }
+       }
+
+       if (mo_node.full_path != NULL) {
+               free(mo_node.full_path);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static sync_agent_pb_error_e _mgmttree_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(pBinder == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "sync_agent_pb_protocol_binder_info_s is NULL !!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTreeNode *mgmttree_node = sync_agent_create_node(pBinder, DM_TNDS_ELEMENT_MGMTTREE);
+       if (mgmttree_node == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error;
+       }
+
+       *ppWbxml_dom_node = mgmttree_node;
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+
+ error:
+       _DEBUG_ERROR("error :%d", err);
+       return err;
+}
+
+static sync_agent_pb_error_e _verdtd_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(pBinder == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "sync_agent_pb_protocol_binder_info_s is NULL !!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       const char *verdtd = "1.2";     /* todo HardCoding */
+       WBXMLTreeNode *verdtd_node = sync_agent_create_text_node(pBinder, DM_TNDS_ELEMENT_VERDTD, verdtd, strlen(verdtd));
+       if (verdtd_node == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error;
+       }
+
+       *ppWbxml_dom_node = verdtd_node;
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+
+ error:
+       _DEBUG_ERROR("error :%d", err);
+       return err;
+}
+
+static sync_agent_pb_error_e _node_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(pBinder == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "sync_agent_pb_protocol_binder_info_s is NULL !!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       sync_agent_dm_mo_node_s *root_mo_node = (sync_agent_dm_mo_node_s *) pContent;
+
+       WBXMLTreeNode *root_node_node = __construct_TNDS_NODE(root_mo_node, pBinder, 0);
+       if (root_node_node == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error;
+       }
+
+       __recursive_contruct_TNDS(root_mo_node, pBinder, root_node_node);
+
+       *ppWbxml_dom_node = root_node_node;
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+
+ error:
+       _DEBUG_ERROR("error :%d", err);
+       return err;
+}
+
+static sync_agent_pb_error_e _node_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(pReverse_binder == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "sync_agent_pb_protocol_binder_reverse_info_s is NULL !!");
+       retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "WBXMLTreeNode is NULL !!");
+
+       dm_tnds_binder_data_s *binder_data = (dm_tnds_binder_data_s *) sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+
+       __recursive_contruct_MO_TABLE(binder_data->tnds_action, binder_data->mo_type, binder_data->mo_full_path, wbxml_dom_node);
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_PB_RETURN_OK;
+}
diff --git a/src/framework/device-manager/mo_tnds_processor.h b/src/framework/device-manager/mo_tnds_processor.h
new file mode 100755 (executable)
index 0000000..8f98b55
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_TNDS_PROCESSOR_H_
+#define MO_TNDS_PROCESSOR_H_
+
+#include "device-manager/mo_error.h"
+#include "device-manager/mo_struct.h"
+#include "device-manager/mo_accessor.h"
+
+/**
+ * @file       mo_tnds_processor.h
+ * @brief      Definition of framework codes for device manager module
+ */
+
+/** @addtogroup device_manager
+ *     @{
+ */
+
+#define DM_TNDS_ELEMENT_MGMTTREE                       "MgmtTree" /**< xml tnds mo tree MgmtTree tag*/
+#define DM_TNDS_ELEMENT_VERDTD                         "VerDTD"        /**<  xml tnds mo tree VerDTD tag */
+#define DM_TNDS_ELEMENT_MAN                                    "Man"           /**<  xml tnds mo tree Man tag */
+#define DM_TNDS_ELEMENT_MOD                                    "Mod"           /**<  xml tnds mo tree Mod tag */
+#define DM_TNDS_ELEMENT_NODE                                   "Node"  /**<  xml tnds mo tree Node tag */
+#define DM_TNDS_ELEMENT_NODENAME                       "NodeName"      /**<  xml tnds mo tree NodeName tag */
+#define DM_TNDS_ELEMENT_PATH                                   "Path"  /**<  xml tnds mo tree Path tag */
+#define DM_TNDS_ELEMENT_VALUE                                  "Value" /**<  xml tnds mo tree Value tag */
+#define DM_TNDS_ELEMENT_RTPROPERTIES           "RTProperties"  /**<  xml tnds mo tree RTProperties tag */
+#define DM_TNDS_ELEMENT_ACL                                            "ACL"           /**<  xml tnds mo tree ACL tag */
+#define DM_TNDS_ELEMENT_FORMAT                         "Format"                /**<  xml tnds mo tree Format tag */
+#define DM_TNDS_ELEMENT_TITLE                                  "Title" /**<  xml tnds mo tree Title tag */
+#define DM_TNDS_ELEMENT_TSTAMP                         "TStamp"                /**<  xml tnds mo tree TStamp tag */
+#define DM_TNDS_ELEMENT_TYPE                                   "Type"          /**<  xml tnds mo tree Type tag */
+#define DM_TNDS_ELEMENT_VERNO                                  "VerNo" /**<  xml tnds mo tree VerNo tag */
+
+#define DM_TNDS_ELEMENT_TYPE_DDFNAME   "DDFName"                       /**<  xml tnds mo tree DDFName value */
+#define DM_TNDS_ELEMENT_TYPE_MIME                      "MIME"                  /**<  xml tnds mo tree MIME value */
+
+#define DM_TNDS_ELEMENT_FORMAT_B64             "b64"                           /**< xml tnds mo tree b64 value */
+#define DM_TNDS_ELEMENT_FORMAT_BIN             "bin"                           /**< xml tnds mo tree bin value */
+#define DM_TNDS_ELEMENT_FORMAT_BOOL            "bool"                  /**< xml tnds mo tree bool value */
+#define DM_TNDS_ELEMENT_FORMAT_CHR             "chr"                           /**< xml tnds mo tree chr value */
+#define DM_TNDS_ELEMENT_FORMAT_INT                     "int"                   /**< xml tnds mo tree int value */
+#define DM_TNDS_ELEMENT_FORMAT_NODE            "node"                  /**< xml tnds mo tree node value */
+#define DM_TNDS_ELEMENT_FORMAT_NULL            "null"                  /**< xml tnds mo tree null value */
+#define DM_TNDS_ELEMENT_FORMAT_XML             "xml"                           /**< xml tnds mo tree xml value */
+#define DM_TNDS_ELEMENT_FORMAT_DATE            "date"                  /**< xml tnds mo tree date value */
+#define DM_TNDS_ELEMENT_FORMAT_TIME            "time"                  /**< xml tnds mo tree time value */
+#define DM_TNDS_ELEMENT_FORMAT_FLOAT   "float"                 /**< xml tnds mo tree float value */
+
+typedef enum {
+       DM_TNDS_TAG_MGMTTREE_START,             /**< tnds mgmtree start */
+       DM_TNDS_TAG_MGMTTREE_END,               /**< tnds mgmtree end */
+       DM_TNDS_TAG_VERDTD,                             /**< tnds verseion dtd tag */
+       DM_TNDS_TAG_NODE_START,                 /**< tnds node start */
+       DM_TNDS_TAG_NODE_END                            /**< tnds node end */
+} dm_tnds_tag_e;
+
+/**
+ * API to Get tnds from mo db
+ * @remarks This function is use to get tnds from mo db
+ *
+ * @par Usage:
+ *
+ * @param[in] tnds_type wbxml, xml
+ * @param[in] root_node root node struct
+ * @param[out] output_tnds output tnds stream
+ * @param[out] byte_size output size
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to get tnds from mo db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_get_tnds_from_db(sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_node_s * root_node, char **output_tnds, unsigned int *byte_size);
+
+/**
+ * API to Insert tnds to db
+ * @remarks This function is use to insert tnds to db
+ *
+ * @par Usage:
+ *
+ * @param[in] tnds_action insert type add, replace
+ * @param[in] tnds_type tnds type wbxml, xml
+ * @param[in] mo_type mo type
+ * @param[in] mo_full_path mo node path
+ * @param[in] input_tnds input tnds stream
+ * @param[in] byte_size input size
+ *
+ * @return SYNC_AGENT_DM_MO_SUCCESS on success, SYNC_AGENT_DM_MO_FAIL on error
+ *
+ * @pre  This function should be called if need to insert tnds to db
+ * @post
+ *
+ * @par Since:
+ *
+ *
+ * @see
+ *
+ */
+sync_agent_dm_mo_error_e dm_insert_tnds_to_db(sync_agent_dm_tnds_action_e tnds_action, sync_agent_dm_tnds_type_e tnds_type, sync_agent_dm_mo_type_e mo_type, const char *mo_full_path, char *input_stream, unsigned int byte_size);
+
+/**
+ *     @}
+ */
+#endif                         /* MO_TNDS_PROCESSOR_H_ */
diff --git a/src/framework/device/executor.c b/src/framework/device/executor.c
new file mode 100755 (executable)
index 0000000..aff55ec
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdarg.h>
+
+#include "device/executor.h"
+#include "plugin/device_info_plugin.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DCI"
+#endif
+
+EXPORT_API sync_agent_dev_return_e sync_agent_execute_dev_function(int device_plugin_id, char *function_name, int args_cnt, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(function_name == NULL, SYNC_AGENT_DEV_RETURN_FAIL, "function name is NULL !!");
+
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+       plugin_execute_dev_function_cb func_point_execute_dev_function = plugin_get_function_execute_dev_function(device_plugin_id);
+       if (func_point_execute_dev_function == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !! \n", __func__);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DEV_RETURN_FAIL;
+       }
+
+       va_list ap;
+       va_start(ap, args_cnt);
+
+       int err = func_point_execute_dev_function(function_name, args_cnt, ap);
+       if (err != 1) {
+               _DEBUG_INFO("fail !!\n");
+       } else {
+               _DEBUG_INFO("success !! \n");
+       }
+
+       va_end(ap);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+/* TODO */
+/*sync_agent_dev_return_e DCI_Execute_Dev_App_Install(const char *platform, char *file_name, char *application_id)
+{
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       const char *plugin_name = 0;
+
+       _DEBUG_INFO("platform type : %s\n", platform);
+       if (!strcmp(platform, "FW_SLP")) {
+               plugin_name = "slp";
+       }
+
+       Execute_Dev_App_Install pFunc_Execute_Dev_App_Install = getFunction_DeviceInfo_Execute_Dev_App_Install(plugin_name);
+       if (pFunc_Execute_Dev_App_Install == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !! \n", __func__);
+       }
+
+       int err = pFunc_Execute_Dev_App_Install(file_name, application_id);
+       if (err != 1) {
+               _DEBUG_INFO("fail !!\n");
+       } else {
+               _DEBUG_INFO("success !! \n");
+       }
+
+       return res;
+}
+*/
+
+/*
+sync_agent_dev_return_e DCI_Execute_Dev_App_UnInstall(const char *platform, char *application_id)
+{
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       const char *plugin_name = 0;
+
+       _DEBUG_INFO("platform type : %s\n", platform);
+       if (!strcmp(platform, "FW_SLP")) {
+               plugin_name = "slp";
+       }
+
+       Execute_Dev_App_UnInstall pFunc_Execute_Dev_App_UnInstall = getFunction_DeviceInfo_Execute_Dev_App_UnInstall(plugin_name);
+       if (pFunc_Execute_Dev_App_UnInstall == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !! \n", __func__);
+       }
+
+       int err = pFunc_Execute_Dev_App_UnInstall(application_id);
+       if (err != 1) {
+               _DEBUG_INFO("fail !!\n");
+       } else {
+               _DEBUG_INFO("success !! \n");
+       }
+
+       return res;
+}
+*/
+
+/*sync_agent_dev_return_e DCI_Execute_Dev_App_Activate(const char *platform, char *application_id, int activate_status)
+{
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       const char *plugin_name = 0;
+
+       _DEBUG_INFO("platform type : %s\n", platform);
+       if (!strcmp(platform, "FW_SLP")) {
+               plugin_name = "slp";
+       }
+
+       Execute_Dev_App_Activate pFunc_Execute_Dev_App_Activate = getFunction_DeviceInfo_Execute_Dev_App_Activate(plugin_name);
+       if (pFunc_Execute_Dev_App_Activate == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !! \n", __func__);
+       }
+
+       int err = pFunc_Execute_Dev_App_Activate(application_id, activate_status);
+       if (err != 1) {
+               _DEBUG_INFO("fail !!\n");
+       } else {
+               _DEBUG_INFO("success !! \n");
+       }
+
+       return res;
+}*/
diff --git a/src/framework/device/information.c b/src/framework/device/information.c
new file mode 100755 (executable)
index 0000000..97389c0
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+#include "utility/sync_util.h"
+#include "device/information.h"
+#include "device/information_internal.h"
+#include "plugin/device_info_plugin.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_DCI"
+#endif
+
+sync_agent_dev_return_e dev_init_dev(int device_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+       _DEBUG_INFO("[%s] plug-in id : %d\n", __func__, device_plugin_id);
+
+       plugin_load_devinfo_cb func_point_load_dev_info = plugin_get_function_load_devinfo(device_plugin_id);
+
+       retvm_if(func_point_load_dev_info == NULL, SYNC_AGENT_DEV_RETURN_FAIL, "cannot get plugin_load_devinfo_cb !!");
+
+       int err = func_point_load_dev_info();
+       if (err != 1) {
+               _DEBUG_INFO("[%s] fail !!\n", __func__);
+               res = SYNC_AGENT_DEV_RETURN_FAIL;
+       } else {
+               _DEBUG_INFO("[%s] success !! \n", __func__);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_dev_return_e sync_agent_get_devinfo(int device_plugin_id, char *info_name, char **value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+       if (info_name == NULL || !strcmp(info_name, ""))
+               return SYNC_AGENT_DEV_RETURN_FAIL;
+
+       plugin_get_devinfo_cb func_point_get_devInfo = plugin_get_function_get_devinfo(device_plugin_id);
+
+       retvm_if(func_point_get_devInfo == NULL, SYNC_AGENT_DEV_RETURN_FAIL, "cannot get plugin_get_devinfo_cb !!");
+
+       int err = func_point_get_devInfo(info_name, value);
+       _DEBUG_INFO("[%s] info name : %s\n", __func__, info_name);
+       _DEBUG_INFO("[%s] value : %s\n", __func__, *value);
+
+       if (err == 0) {
+               _DEBUG_INFO("[%s] fail - value is null !!\n", __func__);
+               res = SYNC_AGENT_DEV_RETURN_DEVINFO_VALUE_IS_NULL;
+       } else if (err == -1) {
+               _DEBUG_INFO("[%s] fail - not exist this information !!\n", __func__);
+               res = SYNC_AGENT_DEV_RETURN_NOT_EXIST_DEVINFO;
+       } else {
+               _DEBUG_INFO("[%s] success !! \n", __func__);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_dev_return_e dev_destroy_dev(int device_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dev_return_e res = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+       plugin_clear_devinfo_cb func_point_clear_devInfo = plugin_get_function_clear_devinfo(device_plugin_id);
+
+       retvm_if(func_point_clear_devInfo == NULL, SYNC_AGENT_DEV_RETURN_FAIL, "cannot get plugin_clear_devinfo_cb !!");
+
+       int err = func_point_clear_devInfo();
+       if (err != 1) {
+               _DEBUG_INFO("[%s] fail !!\n", __func__);
+               res = SYNC_AGENT_DEV_RETURN_FAIL;
+       } else {
+               _DEBUG_INFO("[%s] success !! \n", __func__);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
diff --git a/src/framework/device/information_internal.h b/src/framework/device/information_internal.h
new file mode 100755 (executable)
index 0000000..2351b76
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INFORMATION_INTERNAL_H_
+#define INFORMATION_INTERNAL_H_
+
+#include "device/information.h"
+
+/**
+ * @file information_internal.h
+ * @brief Defines device information APIs
+ */
+
+/** @addtogroup device
+ *     @{
+ */
+
+/**
+ * @brief Load device information on the memory
+ * @remarks Run only once at the beginning of the process
+ * @par Usage:
+ * @code
+               sync_agent_dev_return_e res = DICI_Init(1);
+ * @endcode
+ * @param[in] device_plugin_id Device plugIn ID
+ * @return Operation result
+ * @retval DICI_SUCCESS success
+ * @retval SYNC_AGENT_DEV_RETURN_FAIL error
+ */
+sync_agent_dev_return_e dev_init_dev(int device_plugin_id);
+
+/**
+ * @brief Free memory for device information on the memory
+ * @par Usage:
+ * @code
+               sync_agent_dev_return_e res = DICI_Destroy(1);
+ * @endcode
+ * @param[in] device_plugin_id Device plugIn ID
+ * @return Operation result
+ * @retval DICI_SUCCESS success
+ * @retval DICI_FAIL Operation error
+ */
+sync_agent_dev_return_e dev_destroy_dev(int device_plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* INFORMATION_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/graph_edge_pool.c b/src/framework/engine-controller/graph_edge_pool.c
new file mode 100755 (executable)
index 0000000..166f98c
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>            /* TODO : replace with framework assert */
+#include <glib.h>
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/graph_edge_pool.h"
+#include "engine-controller/hash_set.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+struct ec_graph_edge_pool_s {
+       GHashTable *from_graph_node_hash;       /* containing ec_hash_set_t* to_graph_nodes */
+};
+
+ec_graph_edge_pool_t *ec_graph_edge_pool_new(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_graph_edge_pool_t *pool = (ec_graph_edge_pool_t *) calloc(1, sizeof(ec_graph_edge_pool_t));
+       if (pool == NULL) {
+               goto error_part;
+       }
+
+       pool->from_graph_node_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
+       if (pool->from_graph_node_hash == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pool;
+
+ error_part:
+       ec_graph_edge_pool_free(pool);
+       return NULL;
+}
+
+void ec_graph_edge_pool_free(ec_graph_edge_pool_t * pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pool != NULL) {
+               if (pool->from_graph_node_hash != NULL) {
+                       g_hash_table_destroy(pool->from_graph_node_hash);
+               }
+               free(pool);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* return add success or not */
+/* if already exist edge added, then return false */
+sync_agent_ec_boolean ec_graph_edge_pool_add_edge(ec_graph_edge_pool_t * pool, sync_agent_ec_constpointer from_node, sync_agent_ec_constpointer to_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_boolean add_success = false;
+       ec_hash_set_t *to_node_set = NULL;
+
+       to_node_set = g_hash_table_lookup(pool->from_graph_node_hash, from_node);
+       if (to_node_set == NULL) {
+               to_node_set = ec_hash_set_create();
+               if (to_node_set == NULL) {
+                       assert(false);
+               }
+               g_hash_table_insert(pool->from_graph_node_hash, (gpointer) from_node, (gpointer) to_node_set);
+       }
+
+       add_success = ec_hash_set_add(to_node_set, to_node);
+
+       _EXTERN_FUNC_EXIT;
+
+       return add_success;
+}
+
+GList *ec_graph_edge_pool_query_to_node_list(ec_graph_edge_pool_t * pool, sync_agent_ec_constpointer from_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pool == NULL, NULL, "ec_graph_edge_pool_t is NULL !!");
+
+       GList *to_nodes_list = NULL;
+
+       ec_hash_set_t *to_node_set = NULL;
+       to_node_set = g_hash_table_lookup(pool->from_graph_node_hash, from_node);
+       if (to_node_set == NULL) {
+               goto return_part;
+       }
+
+       to_nodes_list = ec_hash_set_get_element_list(to_node_set);
+
+ return_part:
+
+       _EXTERN_FUNC_EXIT;
+
+       return to_nodes_list;
+}
diff --git a/src/framework/engine-controller/graph_edge_pool.h b/src/framework/engine-controller/graph_edge_pool.h
new file mode 100755 (executable)
index 0000000..2cc30d5
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GRAPH_EDGE_POOL_H_
+#define GRAPH_EDGE_POOL_H_
+
+#include <glib.h>
+#include "engine-controller/fundamental_type.h"
+
+/**
+ * @file               graph_edge_pool.h
+ * @brief      Internal API for graph edge pool
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @breif Structure for graph edge pool
+ */
+typedef struct ec_graph_edge_pool_s ec_graph_edge_pool_t;
+
+/**
+ * @brief Create initialized ec_graph_edge_pool_t instance
+ * @return graph_edge_pool instance on success, NULL on error
+ */
+ec_graph_edge_pool_t *ec_graph_edge_pool_new(void);
+
+/**
+ * @brief Free ec_graph_edge_pool_t instance provided
+ * @param[in] pool ec_graph_edge_pool_t instance to free
+ */
+void ec_graph_edge_pool_free(ec_graph_edge_pool_t * pool);
+
+/**
+ * @brief Add edge to graph node hash in graph edge pool
+ * @param[in] pool graph edge pool
+ * @param[in] from_node starting point node
+ * @param[in] to_node end point node
+ * @return if already exist edge added, then return false
+ * @retval true success
+ * @retval false error
+ */
+sync_agent_ec_boolean ec_graph_edge_pool_add_edge(ec_graph_edge_pool_t * pool, sync_agent_ec_constpointer from_node, sync_agent_ec_constpointer to_node);
+
+/**
+ * @brief Get node list contained from_node from graph node hash in graph edge pool
+ * @param[in] pool graph edge pool
+ * @param[in] from_node target node
+ * @return Operation result
+ * @retval node list success
+ * @retval NULL error
+ */
+GList *ec_graph_edge_pool_query_to_node_list(ec_graph_edge_pool_t * pool, sync_agent_ec_constpointer from_node);
+
+/**
+ *     @}
+ */
+
+#endif                         /* GRAPH_EDGE_POOL_H_ */
diff --git a/src/framework/engine-controller/hash_set.c b/src/framework/engine-controller/hash_set.c
new file mode 100755 (executable)
index 0000000..c464a9f
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "utility/sync_util.h"
+#include "engine-controller/hash_set.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+ec_hash_set_t *ec_hash_set_create(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_hash_set_t *hash_set = (ec_hash_set_t *) calloc(1, sizeof(ec_hash_set_t));
+       if (hash_set == NULL) {
+               goto error_part;
+       }
+
+       hash_set->hash_table = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return hash_set;
+
+ error_part:
+       return NULL;
+}
+
+void ec_hash_set_free(ec_hash_set_t * hash_set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (hash_set != NULL) {
+               if (hash_set->hash_table != NULL) {
+                       g_hash_table_destroy(hash_set->hash_table);
+               }
+
+               free(hash_set);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_hash_set_add(ec_hash_set_t * hash_set, sync_agent_ec_constpointer element)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_boolean success = true;
+
+       if (hash_set == NULL) {
+               _DEBUG_ERROR("hash_set == NULL\n");
+               success = false;
+               goto return_part;
+       }
+
+       if (hash_set->hash_table == NULL) {
+               hash_set->hash_table = g_hash_table_new(g_direct_hash, g_direct_equal);
+       }
+
+       g_hash_table_insert(hash_set->hash_table, (gpointer) element, (gpointer) element);
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return success;
+}
+
+GList *ec_hash_set_get_element_list(ec_hash_set_t * hash_set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GList *element_list = NULL;
+       if (hash_set == NULL) {
+               _DEBUG_ERROR("hash_set == NULL\n");
+               goto error_part;
+       }
+
+       if (hash_set->hash_table != NULL) {
+               element_list = g_hash_table_get_values(hash_set->hash_table);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return element_list;
+
+ error_part:
+
+       return NULL;
+}
diff --git a/src/framework/engine-controller/hash_set.h b/src/framework/engine-controller/hash_set.h
new file mode 100755 (executable)
index 0000000..23ad4e7
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HASH_SET_H_
+#define HASH_SET_H_
+
+#include "engine-controller/fundamental_type.h"
+#include <glib.h>
+
+/**
+ * @file               hash_set.h
+ * @brief      Internal API for hash set
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Type definition of struct ec_hash_set_s
+ */
+typedef struct ec_hash_set_s ec_hash_set_t;
+/**
+ * @brief Structure of hash table instance
+ */
+struct ec_hash_set_s {
+       GHashTable *hash_table; /**< hash table */
+};
+
+/**
+ * @brief Create initialized ec_hash_set_t instance
+ * @return ec_hash_set_t instance on success, NULL on error
+ */
+ec_hash_set_t *ec_hash_set_create(void);
+
+/**
+ * @brief Free ec_hash_set_t instance provided
+ * @param[in] hash_set ec_hash_set_t instance to free
+ */
+void ec_hash_set_free(ec_hash_set_t * hash_set);
+
+/**
+ * @brief Add element to hash set
+ * @param[in] hash_set hash set
+ * @param[in] element element
+ * @return when same element added, it will do nothing and return true
+ * @retval true success
+ * @retval false error
+ */
+sync_agent_ec_boolean ec_hash_set_add(ec_hash_set_t * hash_set, sync_agent_ec_constpointer element);
+
+/**
+ * @brief Get element list from hash set
+ * @param[in] hash_set hash set
+ * @return Operation result
+ * @retval element list success
+ * @retval NULL error
+ */
+GList *ec_hash_set_get_element_list(ec_hash_set_t * hash_set);
+
+/**
+ *     @}
+ */
+
+#endif                         /* HASH_SET_H_ */
diff --git a/src/framework/engine-controller/interface.c b/src/framework/engine-controller/interface.c
new file mode 100755 (executable)
index 0000000..e4a24ca
--- /dev/null
@@ -0,0 +1,875 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include "utility/fw_assert.h"
+#include "utility/sync_util.h"
+#include "utility/fw_async_queue_internal.h"
+#include "engine-controller/interface.h"
+#include "engine-controller/interface_internal.h"
+#include "engine-controller/internal.h"
+#include "engine-controller/task_message.h"
+#include "engine-controller/task_spec.h"
+#include "engine-controller/task_pool.h"
+#include "engine-controller/task_spec_internal.h"
+#include "engine-controller/task_error_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+GPrivate *ec_cancel_task = NULL;
+
+typedef void *(*ec_engine_controller_logic_func_cb) (ec_engine_controller_t *);
+
+typedef void *(*ec_thread_start_routine_cb) (void *);
+
+static ec_engine_controller_t *global_engine_controller = NULL;
+static ec_engine_controller_receiver_t *global_engine_controller_receiver = NULL;
+
+typedef struct ec_sync_task_output_s ec_sync_task_output_t;
+struct ec_sync_task_output_s {
+       pthread_mutex_t mutex;
+       pthread_cond_t output_set_done_cond;
+       sync_agent_ec_boolean output_set_done;
+       sync_agent_ec_task_error_e task_error;
+       sync_agent_ec_uint out_param_cnt;
+       sync_agent_ec_param_param_s **out_param_array;
+};
+
+static ec_sync_task_output_t *_alloc_and_init_sync_task_output(void)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_sync_task_output_t *output = (ec_sync_task_output_t *) calloc(1, sizeof(ec_sync_task_output_t));
+       if (output == NULL) {
+               goto error_part;
+       }
+
+       output->output_set_done = false;
+       pthread_mutex_init(&(output->mutex), NULL);
+       pthread_cond_init(&(output->output_set_done_cond), NULL);
+
+       _INNER_FUNC_EXIT;
+
+       return output;
+
+ error_part:
+       return NULL;
+}
+
+static void _destory_sync_task_output(ec_sync_task_output_t * output)
+{
+       _INNER_FUNC_ENTER;
+
+       if (output != NULL) {
+               pthread_cond_destroy(&(output->output_set_done_cond));
+               pthread_mutex_destroy(&(output->mutex));
+
+               free(output);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _static_sync_task_finish_callback(sync_agent_ec_task_error_e task_error, sync_agent_ec_uint out_param_cnt, sync_agent_ec_param_param_s ** out_param_array, sync_agent_ec_pointer usr_data)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(usr_data == NULL, "ec_sync_task_output_t is NULL !!");
+
+       ec_sync_task_output_t *output = (ec_sync_task_output_t *) usr_data;
+
+       pthread_mutex_lock(&(output->mutex));
+       /* set output */
+       output->task_error = task_error;
+       output->out_param_cnt = out_param_cnt;
+       output->out_param_array = out_param_array;
+
+       g_atomic_int_set(&(output->output_set_done), true);
+       _DEBUG_TRACE("before conditional signal\n");
+       /* wake up receiver */
+       pthread_cond_signal(&(output->output_set_done_cond));
+       pthread_mutex_unlock(&(output->mutex));
+       _DEBUG_TRACE("after conditional signal\n");
+
+       _DEBUG_TRACE("finished\n");
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _send_parent_EC_TASK_DONE_msg_to_itseft(ec_task_t * parent_task)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("called. task_name = %s\n", parent_task->task_spec->task_name);
+       ec_task_message_t *new_task_msg = ec_task_message_create(EC_TASK_DONE, parent_task, 0);
+       if (new_task_msg == NULL) {
+               _DEBUG_ERROR("error. out of memory. we can not create parent container done message.");
+               assert(false);
+               /* TODO : error handling */
+       }
+       ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _send_new_runnerable_child_task_msgs_to_itself(GSList * runnable_child_task_list, ec_task_message_t * received_task_msg)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(runnable_child_task_list == NULL, "GSList is NULL !!");
+       retm_if(received_task_msg == NULL, "ec_task_message_t is NULL !!");
+
+       ec_task_message_t *new_task_msg = NULL;
+       ec_task_t *child_task = NULL;
+       GSList *iter = NULL;
+       for (iter = runnable_child_task_list; iter != NULL; iter = g_slist_next(iter)) {
+               child_task = (ec_task_t *) (iter->data);
+               new_task_msg = ec_task_message_create(EC_TASK_START, child_task, 0);
+               if (received_task_msg->task_state == EC_TASK_START) {
+                       /* note that we have to prepend task message in front of other messages with same priority */
+                       /* otherwise, child task in container task always has penalty then new task input */
+                       ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+               } else if (received_task_msg->task_state == EC_TASK_DONE) {
+                       ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+               } else {
+                       _DEBUG_ERROR("task msg has invalid task state");
+                       assert(false);
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void *_engine_controller_logic(ec_engine_controller_t * engine_controller)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(engine_controller == NULL, NULL, "ec_engine_controller_t is NULL !!");
+
+       sync_agent_util_async_queue_s *queue = engine_controller->queue;
+       ec_thread_pool_t *pool = engine_controller->thread_pool;
+       ec_task_pool_t *task_pool = engine_controller->task_pool;
+       ec_task_t *task = NULL;
+       ec_task_t *parent_task = NULL;
+       sync_agent_ec_int child_task_index_in_parent_task = -1;
+       ec_task_message_t *received_task_msg = NULL;
+       GSList *runnable_child_task_list = NULL;
+
+       while (true) {
+               /* receive msg */
+               received_task_msg = sync_agent_receive_msg_async_queue(queue);
+               if (received_task_msg == NULL) {
+                       _DEBUG_ERROR("null returned from receive_msg_fw_async_queue\n");
+                       continue;
+               }
+
+               if (received_task_msg->task_state == EC_TASK_ROOT_START) {
+                       task = ec_task_ref_task(received_task_msg->u.task);
+                       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+                       _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_ROOT_START] task(msg id : %d, task name : %s, task spec id : %d) ========= \n\n", request_msg->msg_head.msg_id, task->task_spec->task_name, request_msg->task_spec_id);
+
+                       assert(ec_task_is_root_task(task));
+                       ec_task_pool_add_task(task_pool, request_msg->msg_head.msg_id, task);
+
+                       ec_task_message_t *new_task_msg = ec_task_message_create(EC_TASK_START, task, 0);
+                       if (new_task_msg == NULL) {
+                               /* TODO */
+                               assert(false);
+                       }
+                       ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+                       ec_task_unref_task(task);
+
+               } else if (received_task_msg->task_state == EC_TASK_START) {
+                       task = ec_task_ref_task(received_task_msg->u.task);
+                       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+                       _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_START] =========\ntask(task name : %s) related to root_task(msg id : %d, task spec id : %d)\n\n", task->task_spec->task_name, request_msg->msg_head.msg_id, request_msg->task_spec_id);
+
+                       /* queuing if task applied to queuing rule */
+                       sync_agent_ec_boolean is_pending_task = ec_task_add_pending_task_list_of_first_progress_blocking_realized_entity(task);
+                       if (is_pending_task) {
+                               _DEBUG_TRACE("task name : %s pending by queuing rule\n", task->task_spec->task_name);
+                               ec_task_unref_task(task);
+                               goto last;
+                       }
+
+                       if (ec_task_is_simple_task(task)) {
+                               ec_thread_pool_push_task(pool, task);
+                       }
+
+                       if (ec_task_is_container_task(task)) {
+                               /* update progress blocking realized entity when dynamic task case */
+                               /* this can be done since other dynamic case conditions can be ignored now */
+                               if (ec_task_spec_is_dynamic_container(task->task_spec)) {
+                                       ec_task_update_progress_blocking_realized_entity_and_pop_if_possible(task);
+                               }
+
+                               /* check runnable child task */
+                               runnable_child_task_list = ec_collect_firstly_runnable_child_tasks(task);
+                               if (runnable_child_task_list == NULL) {
+                                       _DEBUG_ERROR("no runnable child task exist.\n");
+                                       assert(false);
+                               }
+
+                               /* send task message to engine controller itself */
+                               _send_new_runnerable_child_task_msgs_to_itself(runnable_child_task_list, received_task_msg);
+                       }
+
+                       ec_task_unref_task(task);
+
+               } else if (received_task_msg->task_state == EC_TASK_ROOT_DONE) {
+                       task = ec_task_ref_task(received_task_msg->u.task);
+                       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+
+                       _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_ROOT_DONE] task(result : %s), msg id : %d, task name : %s, task spec id : %d) ========= \n\n", ec_task_error_string(task->task_error), request_msg->msg_head.msg_id,
+                                    task->task_spec->task_name, request_msg->task_spec_id);
+
+                       ec_task_pool_remove_task(task_pool, request_msg->msg_head.msg_id);
+                       ec_task_call_task_finish_callback(task);
+                       _DEBUG_TRACE("root task ec_task_call_task_finish_callback done\n");
+                       _DEBUG_TRACE("root task done\n");
+               } else if (received_task_msg->task_state == EC_TASK_DONE) {
+                       task = ec_task_ref_task(received_task_msg->u.task);
+                       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+
+                       /* loggiing */
+                       _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_DONE : %s] =========\ntask(task name : %s) related to root_task(msg id : %d, task spec id : %d)\n\n", ec_task_error_string(task->task_error), task->task_spec->task_name,
+                                    request_msg->msg_head.msg_id, request_msg->task_spec_id);
+
+                       ec_task_update_progress_blocking_realized_entity_and_pop_if_possible(task);
+
+                       if (ec_task_is_root_task(task)) {
+
+                               ec_task_message_t *new_task_msg = ec_task_message_create(EC_TASK_ROOT_DONE, task, 0);
+                               if (new_task_msg == NULL) {
+                                       /* TODO */
+                                       assert(false);
+                               }
+                               ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+                       } else {
+                               switch (task->task_error) {
+                               case SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS:
+                                       {
+                                               parent_task = ec_task_get_parent_task(task);
+                                               child_task_index_in_parent_task = ec_task_get_child_index_in_parent_task(task);
+
+                                               ec_task_decrease_left_child_to_run(parent_task);
+
+                                               if (ec_task_is_parent_EC_TASK_DONE(parent_task)) {
+                                                       ec_task_set_task_error(parent_task, SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS);
+
+                                                       /* get parent task output from child tasks */
+                                                       ec_task_collect_parent_task_output_parameter(parent_task);
+
+                                                       /* send parent task done message to engine controller itself */
+                                                       _send_parent_EC_TASK_DONE_msg_to_itseft(parent_task);
+
+                                                       /* TODO : update */
+                                               } else {
+                                                       /* remove dependencies related to done operation */
+                                                       /* if some operations has no dependency, then push in thread_pool */
+                                                       runnable_child_task_list = ec_collect_become_runnable_child_tasks_by_remove_control_flow(parent_task, child_task_index_in_parent_task);
+
+                                                       /* send task message to engine controller itself */
+                                                       _send_new_runnerable_child_task_msgs_to_itself(runnable_child_task_list, received_task_msg);
+                                               }
+                                       }
+                                       break;
+                               case SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED:
+                               case SYNC_AGENT_EC_TASK_ERROR_CANCELED:
+                                       parent_task = ec_task_get_parent_task(task);
+
+                                       if (ec_task_is_not_yet_run(parent_task)) {
+                                               /* FIXME : do i have to wait other child task finished? */
+                                               ec_task_set_task_error(parent_task, task->task_error);
+
+                                               /* send parent task done message to engine controller itself */
+                                               _send_parent_EC_TASK_DONE_msg_to_itseft(parent_task);
+                                       }
+                                       break;
+                               default:        /* TODO : other task error must be handled */
+                                       break;
+                               }
+                       }
+
+                       ec_task_unref_task(task);
+
+               } else if (received_task_msg->task_state == EC_TASK_CANCEL) {
+                       task = ec_task_pool_fetch_task(task_pool, received_task_msg->u.request_msg_id);
+                       if (task != NULL) {
+                               ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+                               _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_CANCEL] =========\ncancel task(request message id : %d, task name : %s) related to root_task(msg id : %d, task spec id : %d)\n\n", received_task_msg->u.request_msg_id,
+                                            task->task_spec->task_name, request_msg->msg_head.msg_id, request_msg->task_spec_id);
+
+                               ec_task_do_cancellation(task);
+                               ec_task_unref_task(task);
+                       } else {
+                               /* TODO : task request may be not handled yet. becuase cancel request has high priority */
+                               _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_CANCEL] =========\ncancel task(request message id : %d) received, " "but  no such task exist. it could be already executed or you never requested\n\n",
+                                            received_task_msg->u.request_msg_id);
+                       }
+               } else if (received_task_msg->task_state == EC_TASK_CANCEL_ALL) {
+                       _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_CANCEL_ALL] =========\n\n\n");
+
+                       GList *all_tasks_list = ec_task_pool_fetch_all_tasks(task_pool);
+                       GList *iter = NULL;
+                       ec_task_t *task = NULL;
+                       sync_agent_ec_uint i = 0;
+                       ec_request_msg_t *request_msg = NULL;
+                       for (i = 0, iter = all_tasks_list; iter != NULL; i++, iter = g_list_next(iter)) {
+                               task = iter->data;
+                               request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+                               _DEBUG_TRACE("\n\n======= [CONTROLLER : EC_TASK_CANCEL_ALL_DETAIL (%d)] =========\ncancel task(request message id : %d, task name : %s) related to root_task(msg id : %d, task spec id : %d)\n\n", i,
+                                            received_task_msg->u.request_msg_id, task->task_spec->task_name, request_msg->msg_head.msg_id, request_msg->task_spec_id);
+
+                               ec_task_do_cancellation(task);
+                               ec_task_unref_task(task);
+                       }
+
+                       if (all_tasks_list != NULL)
+                               g_list_free(all_tasks_list);
+               } else {
+                       _DEBUG_ERROR("task msg has invalid task state\n");
+                       assert(false);
+               }
+
+ last:
+               ec_task_message_free(received_task_msg);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;            /* TODO */
+}
+
+static void *_engine_controller_receiver_logic(ec_engine_controller_receiver_t * engine_controller_receiver)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(engine_controller_receiver == NULL, NULL, "ec_engine_controller_receiver_t is NULL !!");
+
+       sync_agent_util_async_queue_s *queue = engine_controller_receiver->queue;
+       ec_task_info_pool_t *task_info_pool = engine_controller_receiver->task_info_pool;
+       ec_queuing_rule_spec_pool_t *queuing_rule_spec_pool = engine_controller_receiver->queuing_rule_spec_pool;
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       ec_task_message_t *task_msg = NULL;
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(queue != NULL, "engine controller receiver has no queue\n");
+
+       while (true) {
+               void *msg = sync_agent_receive_msg_async_queue(queue);
+               if (ec_msg_is_register_msg(msg)) {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : REGISTER TASK SPEC MSG] =========\n\n");
+                       ec_register_msg_t *register_msg = (ec_register_msg_t *) msg;
+
+                       /* create task info and add to task info pool */
+                       ec_task_info_t *task_info = ec_task_info_new(register_msg->task_spec_id, register_msg->task_spec);
+
+                       ec_task_info_pool_add_task_info(task_info_pool, task_info, false);
+                       /* TODO */
+
+                       ec_msg_free_register_msg(register_msg);
+               } else if (ec_msg_is_unregister_msg(msg)) {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : UNREGISTER TASK SPEC MSG] =========\n\n");
+                       /* TODO */
+               } else if (ec_msg_is_register_queuing_rule_spec_msg(msg)) {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : REGISTER QUEUING RULE SPEC MSG] =========\n\n");
+                       sync_agent_ec_uint queuing_rule_id = 0;
+                       ec_register_queuing_rule_spec_msg_t *queuing_rule_register_msg = (ec_register_queuing_rule_spec_msg_t *) msg;
+
+                       ec_error = ec_queuing_rule_spec_pool_add_queuing_rule_spec(queuing_rule_spec_pool, queuing_rule_register_msg->spec, &queuing_rule_id);
+
+                       if (queuing_rule_register_msg->register_finish_callback != NULL) {
+                               queuing_rule_register_msg->register_finish_callback(ec_error, queuing_rule_id, queuing_rule_register_msg->usr_data);
+                       }
+                       /* TODO */
+               } else if (ec_msg_is_cancel_msg(msg)) {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : CANCEL MSG] =========\n\n");
+                       ec_cancel_msg_t *cancel_msg = ((ec_cancel_msg_t *) msg);
+
+                       task_msg = ec_task_message_create(EC_TASK_CANCEL, NULL, cancel_msg->request_msg_id_to_cancel);
+                       if (task_msg == NULL) {
+                               _DEBUG_ERROR("out of memory during ec_task_message_create\n");
+                               assert(false);
+                               continue;
+                       }
+
+                       ec_send_msg_to_engine_controller_with_compare_priority(task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+               } else if (ec_msg_is_cancel_all_msg(msg)) {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : CANCEL ALL MSG] =========\n\n");
+
+                       task_msg = ec_task_message_create(EC_TASK_CANCEL_ALL, NULL, 0);
+                       if (task_msg == NULL) {
+                               _DEBUG_ERROR("out of memory during ec_task_message_create\n");
+                               assert(false);
+                               continue;
+                       }
+
+                       ec_send_msg_to_engine_controller_with_compare_priority(task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+               } else if (ec_msg_is_request_msg(msg)) {
+
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : REQUEST MSG] =========\n\n");
+                       ec_request_msg_t *request_msg = ((ec_request_msg_t *) msg);
+
+                       ec_task_info_t *task_info = ec_task_info_pool_search_task_info(task_info_pool, request_msg->task_spec_id);
+                       sync_agent_ec_task_spec_s *task_spec = NULL;
+                       ec_task_t *task = NULL;
+
+                       if (task_info == NULL) {
+                               _DEBUG_TRACE("no msg spec found\n");
+                       } else {
+                               /* create task */
+                               task_spec = task_info->task_spec;
+                               task = ec_task_alloc_root_task(task_spec, request_msg, task_info_pool);
+                               if (task == NULL) {
+                                       _DEBUG_ERROR("out of memory during ec_task_alloc_root_task\n");
+                                       assert(false);
+                                       continue;
+                               }
+
+                               task_msg = ec_task_message_create(EC_TASK_ROOT_START, task, 0);
+                               if (task_msg == NULL) {
+                                       _DEBUG_ERROR("out of memory during ec_task_message_create\n");
+                                       assert(false);
+                                       continue;
+                               }
+
+                               ec_send_msg_to_engine_controller_with_compare_priority(task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+                               ec_task_unref_task(task);
+                       }
+               } else {
+                       _DEBUG_TRACE("\n\n======= [RECEIVER : UNKNOWN MSG] =========\n\n");
+                       /* unknown msg type */
+                       _DEBUG_ERROR("unknown msg type\n");
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;            /* TODO */
+}
+
+ec_engine_controller_t *ec_alloc_engine_controller(sync_agent_ec_uint max_thread_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_engine_controller_t *engine_controller = (ec_engine_controller_t *) calloc(1, sizeof(ec_engine_controller_t));
+       if (engine_controller == NULL) {
+               goto return_part;
+       }
+
+       engine_controller->queue = sync_agent_alloc_async_queue();
+       if (engine_controller->queue == NULL) {
+               goto error_part;
+       }
+
+       engine_controller->task_pool = ec_task_pool_create_task_pool();
+       if (engine_controller->task_pool == NULL) {
+               goto error_part;
+       }
+
+       engine_controller->queuing_rule_spec_pool = NULL;
+
+       engine_controller->thread_pool = ec_thread_pool_alloc_and_init(max_thread_count);
+       if (engine_controller->thread_pool == NULL) {
+               goto error_part;
+       }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       ec_cancel_task = ec_thread_pool_get_cancel_task(engine_controller->thread_pool);
+#else
+       ec_cancel_task = ec_thread_pool_get_cancel_task();
+#endif
+       if (ec_cancel_task == NULL) {
+               goto error_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return engine_controller;
+
+ error_part:
+       ec_free_engine_controller(engine_controller);
+       return NULL;
+}
+
+void ec_free_engine_controller(ec_engine_controller_t * engine_controller)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller == NULL, "ec_engine_controller_t is NULL !!");
+
+       if (engine_controller != NULL) {
+               if (engine_controller->thread_pool) {
+                       ec_thread_pool_destroy(engine_controller->thread_pool);
+                       engine_controller->thread_pool = NULL;
+               }
+               if (engine_controller->queuing_rule_spec_pool) {
+                       ec_queuing_rule_spec_pool_free(engine_controller->queuing_rule_spec_pool);
+                       engine_controller->queuing_rule_spec_pool = NULL;
+               }
+               if (engine_controller->task_pool) {
+                       ec_task_pool_free_task_pool(engine_controller->task_pool);
+                       engine_controller->task_pool = NULL;
+               }
+               if (engine_controller->queue) {
+                       util_destroy_async_queue(engine_controller->queue);
+                       engine_controller->queue = NULL;
+               }
+
+               free(engine_controller);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* TODO error handling */
+void ec_run_engine_controller(ec_engine_controller_t * engine_controller)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller == NULL, "ec_engine_controller_t is NULL !!");
+
+       pthread_create(&(engine_controller->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_logic, (void *)engine_controller);
+       pthread_detach(engine_controller->thread_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_stop_engine_controller(ec_engine_controller_t * engine_controller)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller == NULL, "ec_engine_controller_t is NULL !!");
+
+       pthread_cancel(engine_controller->thread_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_engine_controller_receiver_t *ec_alloc_engine_controller_receiver(ec_engine_controller_t * engine_controller)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(engine_controller == NULL, NULL, "ec_engine_controller_t is NULL !!");
+
+       ec_engine_controller_receiver_t *receiver = NULL;
+
+       receiver = (ec_engine_controller_receiver_t *) calloc(1, sizeof(ec_engine_controller_receiver_t));
+       if (receiver == NULL) {
+               goto return_part;
+       }
+
+       receiver->next_msg_id = 0;
+
+       receiver->queue = sync_agent_alloc_async_queue();
+       if (receiver->queue == NULL) {
+               goto error_part;
+       }
+
+       receiver->task_info_pool = ec_task_info_pool_alloc();
+       if (receiver->task_info_pool == NULL) {
+               goto error_part;
+       }
+
+       /* TODO : remove below 1024 hard coding */
+       receiver->queuing_rule_spec_pool = ec_queuing_rule_spec_pool_alloc(1024, receiver->task_info_pool);
+       if (receiver->queuing_rule_spec_pool == NULL) {
+               goto error_part;
+       }
+
+       receiver->engine_controller = engine_controller;
+
+       /* TODO */
+       engine_controller->queuing_rule_spec_pool = receiver->queuing_rule_spec_pool;
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return receiver;
+
+ error_part:
+       ec_free_engine_controller_receiver(receiver);
+       return NULL;
+}
+
+void ec_free_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller_receiver == NULL, "ec_engine_controller_receiver_t is NULL !!");
+
+       if (engine_controller_receiver != NULL) {
+               if (engine_controller_receiver->queuing_rule_spec_pool) {
+                       ec_queuing_rule_spec_pool_free(engine_controller_receiver->queuing_rule_spec_pool);
+                       engine_controller_receiver->queuing_rule_spec_pool = NULL;
+               }
+               if (engine_controller_receiver->task_info_pool) {
+                       ec_task_info_pool_free(engine_controller_receiver->task_info_pool);
+                       engine_controller_receiver->task_info_pool = NULL;
+               }
+               if (engine_controller_receiver->queue) {
+                       util_destroy_async_queue(engine_controller_receiver->queue);
+                       engine_controller_receiver->queue = NULL;
+               }
+
+               free(engine_controller_receiver);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* TODO error handling */
+void ec_run_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller_receiver == NULL, "ec_engine_controller_receiver_t is NULL !!");
+
+       /* TODO */
+       pthread_create(&(engine_controller_receiver->thread_id), NULL, (ec_thread_start_routine_cb) _engine_controller_receiver_logic, (void *)engine_controller_receiver);
+       pthread_detach(engine_controller_receiver->thread_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_stop_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(engine_controller_receiver == NULL, "ec_engine_controller_receiver_t is NULL !!");
+
+       pthread_cancel(engine_controller_receiver->thread_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_send_msg_to_engine_controller_receiver(ec_msg_head_t * msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(msg == NULL, "ec_msg_head_t is NULL !!");
+
+       /* msg id management */
+
+//      g_atomic_int_exchange_and_add() to be deprecated
+//      msg->msg_id = g_atomic_int_exchange_and_add(&(global_engine_controller_receiver->next_msg_id), 1);
+       msg->msg_id = global_engine_controller_receiver->next_msg_id;
+       g_atomic_int_add(&(global_engine_controller_receiver->next_msg_id), 1);
+
+       _DEBUG_INFO("============= msg id = %d =============\n", msg->msg_id);
+
+       sync_agent_send_msg_async_queue(global_engine_controller_receiver->queue, (void *)msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_send_msg_to_engine_controller(ec_task_message_t * task_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task_msg == NULL, "ec_task_message_t is NULL !!");
+
+       sync_agent_send_msg_async_queue(global_engine_controller->queue, (void *)task_msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_send_msg_to_engine_controller_with_compare_priority(ec_task_message_t * task_msg, ec_compare_task_msg_priority_func_cb ctmp_func, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task_msg == NULL, "ec_task_message_t is NULL !!");
+
+       util_send_msg_async_queue_with_compare_priority(global_engine_controller->queue, (void *)task_msg, (sync_agent_compare_priority_cb) ctmp_func, (void *)user_data);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* external interfaces */
+bool ec_init_engine_controller(unsigned int max_thread_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = true;
+       ec_engine_controller_t *engine_controller = NULL;
+       ec_engine_controller_receiver_t *engine_controller_receiver = NULL;
+
+       /* alloc engine controller */
+       engine_controller = ec_alloc_engine_controller(max_thread_count);
+       if (engine_controller == NULL) {
+               success = false;
+               goto return_part;
+       }
+
+       /* alloc engine controller receiver */
+       engine_controller_receiver = ec_alloc_engine_controller_receiver(engine_controller);
+       if (engine_controller_receiver == NULL) {
+               success = false;
+               goto return_part;
+       }
+
+       /* run engine controller */
+       ec_run_engine_controller(engine_controller);
+       ec_run_engine_controller_receiver(engine_controller_receiver);
+
+ return_part:
+       if (success) {
+               global_engine_controller = engine_controller;
+               global_engine_controller_receiver = engine_controller_receiver;
+       } else {
+               /* TODO : stop engine controller & receiver & free */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+void ec_deinit_engine_controller()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_stop_engine_controller_receiver(global_engine_controller_receiver);
+       ec_stop_engine_controller(global_engine_controller);
+
+       ec_free_engine_controller_receiver(global_engine_controller_receiver);
+       global_engine_controller_receiver = NULL;
+       ec_free_engine_controller(global_engine_controller);
+       global_engine_controller = NULL;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* TODO : error handling */
+EXPORT_API void sync_agent_register_task_spec(sync_agent_ec_uint task_spec_id, sync_agent_ec_char * task_spec_name, sync_agent_ec_task_spec_s * task_spec, sync_agent_calculate_identifier_cb cal_func)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task_spec == NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       ec_register_msg_t *register_msg = ec_msg_create_register_msg(task_spec_id, task_spec, cal_func);
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) register_msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_register_async_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_register_finish_cb register_finish_callback, sync_agent_ec_pointer usr_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_register_queuing_rule_spec_msg_t *msg = ec_msg_create_register_queuing_rule_spec_msg(spec, register_finish_callback, usr_data);
+
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_register_sync_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_ec_error_e * ec_error, sync_agent_ec_uint * registered_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* TODO : error handling */
+EXPORT_API void sync_agent_request_async_task(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                             sync_agent_ec_pointer * in_param_value_array, sync_agent_task_finish_cb task_finish_callback, sync_agent_ec_pointer simple_task_finish_callback_usr_data, sync_agent_ec_int * request_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_request_msg_t *msg = ec_msg_create_request_msg(task_spec_id, identifier, cnt_in_param,
+                                                         in_param_index_array, in_param_value_type_array, in_param_value_array,
+                                                         task_finish_callback, simple_task_finish_callback_usr_data);
+
+       retm_if(msg == NULL, "ec_request_msg_t is NULL !!");
+
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) msg);
+       *request_id = msg->msg_head.msg_id;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_request_sync_task(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                            sync_agent_ec_pointer * in_param_value_array, sync_agent_ec_int * request_id, sync_agent_ec_task_error_e * task_error, sync_agent_ec_uint * out_param_cnt, sync_agent_ec_param_param_s *** out_param_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_task_finish_cb sync_task_finish_callback = _static_sync_task_finish_callback;
+       ec_sync_task_output_t *sync_task_output = _alloc_and_init_sync_task_output();
+       if (sync_task_output == NULL) {
+               return;         /* error */
+       }
+
+       ec_request_msg_t *msg = ec_msg_create_request_msg(task_spec_id, identifier, cnt_in_param,
+                                                         in_param_index_array, in_param_value_type_array, in_param_value_array,
+                                                         sync_task_finish_callback, sync_task_output);
+
+       retm_if(msg == NULL, "ec_request_msg_t is NULL !!");
+
+       pthread_mutex_lock(&(sync_task_output->mutex));
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) msg);
+
+       while (!g_atomic_int_get(&(sync_task_output->output_set_done))) {
+               pthread_cond_wait(&(sync_task_output->output_set_done_cond), &(sync_task_output->mutex));
+       }
+
+       pthread_mutex_unlock(&(sync_task_output->mutex));
+
+       *request_id = msg->msg_head.msg_id;
+       *task_error = sync_task_output->task_error;
+       *out_param_cnt = sync_task_output->out_param_cnt;
+       *out_param_array = sync_task_output->out_param_array;
+
+       _destory_sync_task_output(sync_task_output);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_cancel_task(sync_agent_ec_int request_id_to_cancel)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_cancel_msg_t *cancel_msg = ec_msg_create_cancel_msg(request_id_to_cancel);
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) cancel_msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_cancel_all_tasks()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_cancel_all_msg_t *cancel_all_msg = ec_msg_create_cancel_all_msg();
+       ec_send_msg_to_engine_controller_receiver((ec_msg_head_t *) cancel_all_msg);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/interface_internal.h b/src/framework/engine-controller/interface_internal.h
new file mode 100755 (executable)
index 0000000..7f9be5a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENGINE_CONTROLLER_INTERFACE_INTERNAL_H_
+#define ENGINE_CONTROLLER_INTERFACE_INTERNAL_H_
+
+//#include "define.h"
+//#include "task_spec.h"
+//#include "queuing_rule_spec.h"
+#include "engine-controller/interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file interface_internal.h
+ * @brief Provides APIs to support task registration and request
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Registers user created sychronous queuing rule spec
+ * @param[in] spec User created queuing rule spec to register
+ * @param[in] ec_error Result of the registration
+ * @param[in] registered_id ID issued as a result of the registration
+ */
+       void ec_register_sync_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_ec_error_e * ec_error, sync_agent_ec_uint * registered_id);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* ENGINE_CONTROLLER_INTERFACE_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/internal.h b/src/framework/engine-controller/internal.h
new file mode 100755 (executable)
index 0000000..2aa73a6
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENGINE_CONTROLLER_INTERNAL_H_
+#define ENGINE_CONTROLLER_INTERNAL_H_
+
+#include <glib.h>
+#include <pthread.h>
+#include "utility/fw_async_queue.h"
+#include "engine-controller/thread_pool.h"
+#include "engine-controller/task_info_pool.h"
+#include "engine-controller/queuing_rule_spec_pool.h"
+#include "engine-controller/message.h"
+#include "engine-controller/task_message.h"
+#include "engine-controller/task_pool.h"
+
+/**
+ * @file               internal.h
+ * @brief              Provides APIs to manipulate Engine Controller and Engine Controller Receiver instance
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief              Type definition of struct ec_engine_controller_s
+ */
+typedef struct ec_engine_controller_s ec_engine_controller_t;
+/**
+ * @brief              Structure engine controller
+ */
+struct ec_engine_controller_s {
+       sync_agent_util_async_queue_s *queue;   /**< receive operation_message */
+       ec_task_pool_t *task_pool;                              /**< managing root tasks */
+       ec_queuing_rule_spec_pool_t *queuing_rule_spec_pool; /**< managing queuing rule tasks */
+
+       pthread_t thread_id;                                            /**< thread id */
+       ec_thread_pool_t *thread_pool;                  /**< thread pool */
+};
+
+/**
+ * @brief Alloc engine controller stuct
+ * @param[in] max_thread_count for init thread pool
+ * @return ec_engine_controller_t engine controller struct
+ */
+ec_engine_controller_t *ec_alloc_engine_controller(sync_agent_ec_uint max_thread_count);
+
+/**
+ * @brief Free engine controller stuct
+ * @param[in] engine_contorller engine controller stuct
+ * @return
+ */
+void ec_free_engine_controller(ec_engine_controller_t * engine_controller);
+
+/**
+ * @brief Run engine controller
+ * @param[in] engine_contorller engine controller stuct
+ * @return
+ */
+void ec_run_engine_controller(ec_engine_controller_t * engine_controller);
+
+void ec_stop_engine_controller(ec_engine_controller_t * engine_controller);
+
+/**
+ * @brief              Type definition of struct engine_controller_receiver_s
+ */
+typedef struct engine_controller_receiver_s ec_engine_controller_receiver_t;
+/**
+ * @brief              Structrure engine controller receiver
+ */
+struct engine_controller_receiver_s {
+       sync_agent_ec_int next_msg_id;                  /**< msg id management */
+
+       sync_agent_util_async_queue_s *queue;   /**< receive message */
+       pthread_t thread_id;                                            /** thread id */
+       ec_task_info_pool_t *task_info_pool;    /** thread pool */
+       ec_queuing_rule_spec_pool_t *queuing_rule_spec_pool;    /** queuing rule task pool */
+       ec_engine_controller_t *engine_controller;                      /** engine controller struct */
+};
+
+/**
+ * @brief Alloc engine controller receiver
+ * @param[in] engine_contorller created engine controller stuct
+ * @return ec_engine_controller_receiver_t engine controller receiver struct
+ */
+ec_engine_controller_receiver_t *ec_alloc_engine_controller_receiver(ec_engine_controller_t * engine_controller);
+
+/**
+ * @brief Free engine controller receiver
+ * @param[in] engine_controller_receiver created engine controller stuct
+ * @return
+ */
+void ec_free_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver);
+
+/**
+ * @brief Run engine controller receiver
+ * @param[in] engine_controller_receiver created engine controller stuct
+ * @return
+ */
+void ec_run_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver);
+
+void ec_stop_engine_controller_receiver(ec_engine_controller_receiver_t * engine_controller_receiver);
+
+/**
+ * @brief Send msg to engine controller receiver
+ * @param[in] msg msg head
+ * @return
+ */
+void ec_send_msg_to_engine_controller_receiver(ec_msg_head_t * msg);
+
+/**
+ * @brief Send msg to engine controller
+ * @param[in] msg msg head
+ * @return
+ */
+void ec_send_msg_to_engine_controller(ec_task_message_t * task_msg);
+
+/**
+ * @brief Send msg to engine controller receiver with compare priority
+ * @param[in] msg msg head
+ * @param[in] ctmp_func priority function
+ * @param[in] user_data user data
+ * @return
+ */
+void ec_send_msg_to_engine_controller_with_compare_priority(ec_task_message_t * task_msg, ec_compare_task_msg_priority_func_cb ctmp_func, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Init engine controller
+ * @param[in] max_thread_count max count thread in thread pool
+ * @return
+ */
+bool ec_init_engine_controller(unsigned int max_thread_count);
+
+/**
+ * @brief Deinit engine controller
+ * @return true on success, false on error
+ */
+void ec_deinit_engine_controller();
+
+/**
+ *     @}
+ */
+
+#endif                         /* ENGINE_CONTROLLER_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/message.c b/src/framework/engine-controller/message.c
new file mode 100755 (executable)
index 0000000..fda2678
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "utility/sync_util.h"
+#include "engine-controller/message.h"
+#include "engine-controller/queuing_rule_spec_internal.h"
+#include "engine-controller/task_spec_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+void ec_msg_set_msg_head(ec_msg_head_t * msg_head, ec_msg_type_t msg_type, sync_agent_ec_uint msg_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (msg_head != NULL) {
+               msg_head->msg_id = msg_id;
+               msg_head->msg_type = msg_type;
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_register_msg_t *ec_msg_create_register_msg(sync_agent_ec_uint task_spec_id, sync_agent_ec_task_spec_s * task_spec, sync_agent_calculate_identifier_cb id_calc_func)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_spec == NULL, NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       ec_register_msg_t *register_msg = (ec_register_msg_t *) calloc(1, sizeof(ec_register_msg_t));
+       if (register_msg == NULL) {
+               goto error_part;
+       }
+
+       ec_msg_set_msg_head(&(register_msg->msg_head), EC_REGISTER_MSG_TYPE, 0);
+
+       register_msg->task_spec_id = task_spec_id;
+       register_msg->task_spec = ec_task_spec_ref(task_spec);
+       if (id_calc_func != NULL) {
+               register_msg->id_calc_func = id_calc_func;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return register_msg;
+ error_part:
+       ec_msg_free_register_msg(register_msg);
+       return NULL;
+}
+
+void ec_msg_free_register_msg(ec_register_msg_t * register_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (register_msg != NULL) {
+               if (register_msg->task_spec != NULL) {
+                       ec_task_spec_unref(register_msg->task_spec);
+               }
+
+               free(register_msg);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_register_queuing_rule_spec_msg_t *ec_msg_create_register_queuing_rule_spec_msg(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_register_finish_cb register_finish_callback, sync_agent_ec_pointer usr_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_register_queuing_rule_spec_msg_t *msg = (ec_register_queuing_rule_spec_msg_t *) calloc(1, sizeof(ec_register_queuing_rule_spec_msg_t));
+       if (msg == NULL) {
+               goto error_part;
+       }
+
+       ec_msg_set_msg_head(&(msg->msg_head), EC_REGISTER_QUEUING_RULE_SPEC_MSG_TYPE, 0);
+       msg->spec = ec_ref_queuing_rule_spec(spec);
+
+       msg->register_finish_callback = register_finish_callback;
+       msg->usr_data = usr_data;
+
+       _EXTERN_FUNC_EXIT;
+
+       return msg;
+ error_part:
+       ec_msg_free_register_queuing_rule_spec_msg(msg);
+       return NULL;
+}
+
+void ec_msg_free_register_queuing_rule_spec_msg(ec_register_queuing_rule_spec_msg_t * msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(msg == NULL, "ec_register_queuing_rule_spec_msg_t is NULL !!");
+
+       if (msg != NULL) {
+               /* TODO */
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_request_msg_t *ec_msg_create_request_msg(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                           sync_agent_ec_pointer * in_param_value_array, sync_agent_task_finish_cb task_finish_callback, sync_agent_ec_pointer simple_task_finish_callback_usr_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_request_msg_t *msg = (ec_request_msg_t *) calloc(1, sizeof(ec_request_msg_t));
+       sync_agent_ec_int i = 0;
+       if (msg == NULL) {
+               goto error_part;
+       }
+
+       ec_msg_set_msg_head(&(msg->msg_head), EC_REQUEST_MSG_TYPE, 0);
+       msg->task_spec_id = task_spec_id;
+       msg->identifier = identifier;
+       msg->cnt_in_param = cnt_in_param;
+       if (cnt_in_param > 0) {
+               msg->in_param_index_array = (sync_agent_ec_int *) malloc(cnt_in_param * sizeof(sync_agent_ec_int));
+               if (msg->in_param_index_array == NULL) {
+                       goto error_part;
+               }
+               memcpy(msg->in_param_index_array, in_param_index_array, cnt_in_param * sizeof(sync_agent_ec_int));
+
+               msg->in_param_value_array = (sync_agent_ec_param_value_u *) calloc(cnt_in_param, sizeof(sync_agent_ec_param_value_u));
+               if (msg->in_param_value_array == NULL) {
+                       goto error_part;
+               }
+
+               for (i = 0; i < cnt_in_param; i++) {
+                       sync_agent_set_param_value(&(msg->in_param_value_array[i]), in_param_value_type_array[i], in_param_value_array[i]);
+               }
+       }
+       msg->task_finish_callback = task_finish_callback;
+       msg->simple_task_finish_callback_usr_data = simple_task_finish_callback_usr_data;
+
+       _EXTERN_FUNC_EXIT;
+
+       return msg;
+
+ error_part:
+       ec_msg_free_request_msg(msg);
+       return NULL;
+}
+
+void ec_msg_free_request_msg(ec_request_msg_t * msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (msg != NULL) {
+               /* TODO */
+
+               free(msg);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_cancel_all_msg_t *ec_msg_create_cancel_all_msg()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_cancel_all_msg_t *cancel_all_msg = (ec_cancel_all_msg_t *) calloc(1, sizeof(ec_cancel_all_msg_t));
+       if (cancel_all_msg == NULL) {
+               goto error_part;
+       }
+
+       ec_msg_set_msg_head(&(cancel_all_msg->msg_head), EC_CANCEL_ALL_MSG_TYPE, 0);
+
+       _EXTERN_FUNC_EXIT;
+
+       return cancel_all_msg;
+ error_part:
+       ec_msg_free_cancel_all_msg(cancel_all_msg);
+       return NULL;
+}
+
+void ec_msg_free_cancel_all_msg(ec_cancel_all_msg_t * cancel_all_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_all_msg != NULL) {
+               /* TODO */
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_cancel_msg_t *ec_msg_create_cancel_msg(sync_agent_ec_uint request_msg_id_to_cancel)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_cancel_msg_t *cancel_msg = (ec_cancel_msg_t *) calloc(1, sizeof(ec_cancel_msg_t));
+       if (cancel_msg == NULL) {
+               goto error_part;
+       }
+
+       ec_msg_set_msg_head(&(cancel_msg->msg_head), EC_CANCEL_MSG_TYPE, 0);
+       cancel_msg->request_msg_id_to_cancel = request_msg_id_to_cancel;
+
+       _EXTERN_FUNC_EXIT;
+
+       return cancel_msg;
+ error_part:
+       ec_msg_free_cancel_msg(cancel_msg);
+       return NULL;
+}
+
+void ec_msg_free_cancel_msg(ec_cancel_msg_t * cancel_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_msg != NULL) {
+               /* TODO */
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_msg_check_same_msg_type(ec_msg_head_t * pHead, ec_msg_type_t msg_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pHead->msg_type == msg_type) {
+               return true;
+       } else {
+               return false;
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_msg_is_register_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_msg_check_same_msg_type(pHead, EC_REGISTER_MSG_TYPE);
+}
+
+sync_agent_ec_boolean ec_msg_is_unregister_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_msg_check_same_msg_type(pHead, EC_UNREGISTER_MSG_TYPE);
+}
+
+sync_agent_ec_boolean ec_msg_is_register_queuing_rule_spec_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_msg_check_same_msg_type(pHead, EC_REGISTER_QUEUING_RULE_SPEC_MSG_TYPE);
+}
+
+sync_agent_ec_boolean ec_msg_is_request_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       return ec_msg_check_same_msg_type(pHead, EC_REQUEST_MSG_TYPE);
+}
+
+sync_agent_ec_boolean ec_msg_is_cancel_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_msg_check_same_msg_type(pHead, EC_CANCEL_MSG_TYPE);
+}
+
+sync_agent_ec_boolean ec_msg_is_cancel_all_msg(ec_msg_head_t * pHead)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_msg_check_same_msg_type(pHead, EC_CANCEL_ALL_MSG_TYPE);
+}
diff --git a/src/framework/engine-controller/message.h b/src/framework/engine-controller/message.h
new file mode 100755 (executable)
index 0000000..1a3d112
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MESSAGE_H_
+#define MESSAGE_H_
+
+/**
+ * @file               message.h
+ * @brief              Provides APIs to manipulate various type of Engine Controller message
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+#include <limits.h>
+
+#include "engine-controller/define.h"
+#include "engine-controller/interface.h"
+#include "engine-controller/param_value.h"
+#include "engine-controller/param_spec.h"
+#include "engine-controller/task_spec.h"
+
+/**
+ * @brief              Enum msg type
+ */
+typedef enum engine_controller_msg_type_e {
+       EC_UNKNOWN_MSG_TYPE = 0,                                                /**< engine controller msg type none */
+       EC_REGISTER_MSG_TYPE,                                           /**< engine controller msg type register */
+       EC_UNREGISTER_MSG_TYPE,                                         /**< engine controller msg type unregister */
+       EC_REGISTER_QUEUING_RULE_SPEC_MSG_TYPE, /**< engine controller msg type queuing rule */
+       EC_REQUEST_MSG_TYPE,                                                    /**< engine controller msg type request */
+       EC_CANCEL_MSG_TYPE,                                                     /**< engine controller msg type cancel */
+       EC_CANCEL_ALL_MSG_TYPE,                                         /**< engine controller msg type cancel all */
+} ec_msg_type_t;
+
+/**
+ * @brief              Type definition of struct ec_msg_head_s
+ */
+typedef struct ec_msg_head_s ec_msg_head_t;
+
+/**
+ * @brief              Structure engine controller msg
+ */
+struct ec_msg_head_s {
+       ec_msg_type_t msg_type;         /**<  */
+       sync_agent_ec_int msg_id;       /**<  */
+};
+
+/**
+ * @brief              Type definition of struct ec_request_msg_s
+ */
+typedef struct ec_request_msg_s ec_request_msg_t;
+
+/**
+ * @brief              Structure request msg
+ */
+struct ec_request_msg_s {
+       ec_msg_head_t msg_head;                                                                                                 /**< msg type */
+
+       sync_agent_ec_uint task_spec_id;                                                                                /**< task spec id */
+
+       /** input data */
+       sync_agent_ec_uint identifier;                                                                                  /**< defined task id by agent */
+       sync_agent_ec_int cnt_in_param;                                                                                 /**< param count */
+       sync_agent_ec_int *in_param_index_array;                                                                /**< param index array */
+       sync_agent_ec_param_value_u *in_param_value_array;                                      /**< param value array */
+
+       /** aynchronous finish callback */
+       sync_agent_task_finish_cb task_finish_callback;                                         /**< finish callback */
+       sync_agent_ec_pointer simple_task_finish_callback_usr_data;                     /**< finish callback pointer  */
+};
+
+/**
+ * @brief              Type definition of struct ec_cancel_all_msg_s
+ */
+typedef struct ec_cancel_all_msg_s ec_cancel_all_msg_t;
+/**
+ * @brief      Structure cancell all msg
+ */
+struct ec_cancel_all_msg_s {
+       ec_msg_head_t msg_head;                                                         /**< msg type */
+};
+
+/**
+ * @brief              Type definition of struct ec_cancel_msg_s
+ */
+typedef struct ec_cancel_msg_s ec_cancel_msg_t;
+/**
+ * @brief              Structure cancel msg
+ */
+struct ec_cancel_msg_s {
+       ec_msg_head_t msg_head;                                                         /**< msg type */
+
+       sync_agent_ec_uint request_msg_id_to_cancel;            /**< msg id */
+};
+
+/**
+ * @brief              Type definition of struct ec_register_msg_s
+ */
+typedef struct ec_register_msg_s ec_register_msg_t;
+/**
+ * @brief              Struct resiter msg
+ */
+struct ec_register_msg_s {
+       ec_msg_head_t msg_head;                                                                 /**< msg type */
+
+       sync_agent_ec_uint task_spec_id;                                                /**< task id */
+       sync_agent_ec_task_spec_s *task_spec;                                   /**< task spec struct */
+       sync_agent_calculate_identifier_cb id_calc_func;                /**< calculate function */
+};
+
+/**
+ * @brief              Type definition of struct ec_register_queuing_rule_spec_msg_s
+ */
+typedef struct ec_register_queuing_rule_spec_msg_s ec_register_queuing_rule_spec_msg_t;
+/**
+ * @brief              Structure queuing rule spec msg
+ */
+struct ec_register_queuing_rule_spec_msg_s {
+       ec_msg_head_t msg_head;                                                                         /**< msg type */
+
+       sync_agent_ec_queuing_rule_spec_s *spec;                                        /**< queuing rule spec */
+
+       /** aynchronous finish callback */
+       sync_agent_register_finish_cb register_finish_callback; /**< register finish callback */
+       sync_agent_ec_pointer usr_data;                                                         /**< user data */
+};
+
+/**
+ * @brief Set msg type to task spec
+ * @param[in] msg_head task spec's msg head
+ * @param[in] msg_type set msg type (EC_REGISTER_MSG_TYPE)
+ * @param[in] msg_id msg id (0)
+ * @return
+ */
+void ec_msg_set_msg_head(ec_msg_head_t * msg_head, ec_msg_type_t msg_type, sync_agent_ec_uint msg_id);
+
+/**
+ * @brief Create a msg for register msg
+ * @param[in] task_spec_id task spec id
+ * @param[in] task_spec task spec struct
+ * @param[in] id_calc_func calc function pointer
+ * @return ec_register_msg_t created register msg struct
+ */
+ec_register_msg_t *ec_msg_create_register_msg(sync_agent_ec_uint task_spec_id, sync_agent_ec_task_spec_s * task_spec, sync_agent_calculate_identifier_cb id_calc_func);
+
+/**
+ * @brief Free a msg msg
+ * @param[in] register_msg free a created register msg
+ * @return
+ */
+void ec_msg_free_register_msg(ec_register_msg_t * register_msg);
+
+/**
+ * @brief Create a msg about queuing rule spec
+ * @param[in] spec queuing rull spec
+ * @param[in] register_finish_callback this function will call when finish task
+ * @param[in] usr_data user data
+ * @return ec_register_queuing_rule_spec_msg_t queuing rull spec msg struct
+ */
+ec_register_queuing_rule_spec_msg_t *ec_msg_create_register_queuing_rule_spec_msg(sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_register_finish_cb register_finish_callback, sync_agent_ec_pointer usr_data);
+
+/**
+ * @brief Free a msg about queuing rule spec
+ * @param[in] msg queuing rull spec msg struct
+ * @return
+ */
+void ec_msg_free_register_queuing_rule_spec_msg(ec_register_queuing_rule_spec_msg_t * msg);
+
+/**
+ * @brief Create a msg for request msg
+ * @param[in] task_spec_id task spec id
+ * @param[in] identifier defined task id by agent
+ * @param[in] cnt_in_param count param array
+ * @param[in] in_param_index_array insert param index array
+ * @param[in] in_param_value_type_array insert param value type array
+ * @param[in] in_param_value_array insert param value array
+ * @param[in] task_finish_callback this is finish callback function
+ * @param[in] simple_task_finish_callback_usr_data simple task finish call back for free user data
+ *
+ * @return ec_request_msg_t request msg struct
+ */
+ec_request_msg_t *ec_msg_create_request_msg(sync_agent_ec_uint task_spec_id, sync_agent_ec_uint identifier, sync_agent_ec_int cnt_in_param, sync_agent_ec_int * in_param_index_array, sync_agent_ec_value_type_e * in_param_value_type_array,
+                                           sync_agent_ec_pointer * in_param_value_array, sync_agent_task_finish_cb task_finish_callback, sync_agent_ec_pointer simple_task_finish_callback_usr_data);
+
+/**
+ * @brief Free a msg about request msg
+ * @param[in] msg request msg struct
+ * @return
+ */
+void ec_msg_free_request_msg(ec_request_msg_t * msg);
+
+/**
+ * @brief Create msg for cancel all msg
+ * @return ec_cancel_all_msg_t cancel all msg struct
+ */
+ec_cancel_all_msg_t *ec_msg_create_cancel_all_msg();
+
+/**
+ * @brief Free cancel all msg
+ * @param[in] cancel_all_msg cancel all msg struct
+ * @return
+ */
+void ec_msg_free_cancel_all_msg(ec_cancel_all_msg_t * cancel_all_msg);
+
+/**
+ * @brief Create cancel msg
+ * @param[in] request_msg_id_to_cancel msg id
+ * @return
+ */
+ec_cancel_msg_t *ec_msg_create_cancel_msg(sync_agent_ec_uint request_msg_id_to_cancel);
+
+/**
+ * @brief Free cancel msg
+ * @param[in] cancel_msg cancel msg struct
+ * @return
+ */
+void ec_msg_free_cancel_msg(ec_cancel_msg_t * cancel_msg);
+
+/**
+ * @brief Check msg type
+ * @param[in] pHead head msg for compare
+ * @param[in] msg_type msg type
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_check_same_msg_type(ec_msg_head_t * pHead, ec_msg_type_t msg_type);
+
+/**
+ * @brief Check register msg type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_register_msg(ec_msg_head_t * pHead);
+
+/**
+ * @brief Check nnregister msg type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_unregister_msg(ec_msg_head_t * pHead);
+
+/**
+ * @brief Check register msg queuing rule spec type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_register_queuing_rule_spec_msg(ec_msg_head_t * pHead);
+
+/**
+ * @brief Check request msg type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_request_msg(ec_msg_head_t * pHead);
+
+/**
+ * @brief Check cancel msg type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_cancel_msg(ec_msg_head_t * pHead);
+
+/**
+ * @brief Check cancel all msg type
+ * @param[in] pHead head msg for register msg
+ * @return true, false
+ */
+sync_agent_ec_boolean ec_msg_is_cancel_all_msg(ec_msg_head_t * pHead);
+
+/**
+ *     @}
+ */
+
+#endif                         /* MESSAGE_H_ */
diff --git a/src/framework/engine-controller/param.c b/src/framework/engine-controller/param.c
new file mode 100755 (executable)
index 0000000..17eee9c
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/param.h"
+#include "engine-controller/param_internal.h"
+#include "engine-controller/param_spec_internal.h"
+#include "engine-controller/param_value_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+sync_agent_ec_param_param_s *ec_alloc_param(sync_agent_ec_uint read_ref_count, sync_agent_ec_uint write_ref_count, sync_agent_ec_param_spec_s * param_spec, sync_agent_ec_param_value_u * param_value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(param_spec == NULL, NULL, "sync_agent_ec_param_spec_s is NULL !!");
+
+       sync_agent_ec_param_param_s *pParam = (sync_agent_ec_param_param_s *) calloc(1, sizeof(sync_agent_ec_param_param_s));
+       if (pParam == NULL) {
+               goto error_part;
+       }
+
+       pParam->read_ref_count = read_ref_count;
+       pParam->write_ref_count = write_ref_count;
+       pParam->pParam_spec = ec_ref_param_spec(param_spec);
+
+       if (param_value != NULL) {
+               ec_set_param_value_with_other_param_value(&(pParam->param_value), param_value);
+       } else {
+               if (param_spec->flags & SYNC_AGENT_EC_PARAM_FLAG_INPUT) {
+                       ec_set_param_value_with_other_param_value(&(pParam->param_value), &(param_spec->default_value));
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam;
+ error_part:
+       ec_free_param(pParam);
+       return NULL;
+}
+
+void ec_free_param(sync_agent_ec_param_param_s * param)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (param != NULL) {
+               if (param->pParam_spec != NULL) {
+                       sync_agent_unref_param_spec(param->pParam_spec);
+               }
+               free(param);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/param_internal.h b/src/framework/engine-controller/param_internal.h
new file mode 100755 (executable)
index 0000000..c953e60
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_INTERNAL_H_
+#define PARAM_INTERNAL_H_
+
+#include "param_value.h"
+#include "param_spec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file param_internal.h
+ * @brief Provides alloc and free of param structure
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Alocates and returns param_t type of structure using given param spec and param value
+ * @param[in] read_ref_count Reference count to set for read
+ * @param[in] write_ref_count Reference count to set for write
+ * @param[in] param_spec param spec to use
+ * @param[in] param_value param value to push in
+ * @return Newly alloced pointer of param_t type of structure
+ */
+       sync_agent_ec_param_param_s *ec_alloc_param(sync_agent_ec_uint read_ref_count, sync_agent_ec_uint write_ref_count, sync_agent_ec_param_spec_s * param_spec, sync_agent_ec_param_value_u * param_value);
+
+/**
+ * @brief Provides free operation for param_t type of structure
+ * @param[in] param param_t type of structure to free
+ */
+       void ec_free_param(sync_agent_ec_param_param_s * param);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* PARAM_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/param_spec.c b/src/framework/engine-controller/param_spec.c
new file mode 100755 (executable)
index 0000000..a9a3660
--- /dev/null
@@ -0,0 +1,733 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <assert.h>            /* TODO : replace with fw_assert.h */
+#include <glib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/param_spec.h"
+#include "engine-controller/param_spec_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+static inline sync_agent_ec_boolean _is_flag_on(sync_agent_ec_param_flags_e flags, sync_agent_ec_param_flags_e check_flag);
+static inline void _on_flag(sync_agent_ec_param_flags_e * flags, sync_agent_ec_param_flags_e _on_flag);
+
+/* TODO */
+static void _free_param_spec(sync_agent_ec_param_spec_s * pParam_spec);
+
+/* internal */
+static sync_agent_ec_boolean _param_char_validate_func(sync_agent_ec_int8 value, sync_agent_ec_int8 minimum, sync_agent_ec_int8 maximum);
+static sync_agent_ec_boolean _param_uchar_validate_func(sync_agent_ec_uint8 value, sync_agent_ec_uint8 minimum, sync_agent_ec_uint8 maximum);
+static sync_agent_ec_boolean _param_int_validate_func(sync_agent_ec_int value, sync_agent_ec_int minimum, sync_agent_ec_int maximum);
+static sync_agent_ec_boolean _param_uint_validate_func(sync_agent_ec_uint value, sync_agent_ec_uint minimum, sync_agent_ec_uint maximum);
+static sync_agent_ec_boolean _param_float_validate_func(sync_agent_ec_float value, sync_agent_ec_float minimum, sync_agent_ec_float maximum);
+static sync_agent_ec_boolean _param_double_validate_func(sync_agent_ec_double value, sync_agent_ec_double minimum, sync_agent_ec_double maximum);
+
+static ec_param_spec_char_validate_s *_alloc_init_param_spec_char_validate(sync_agent_ec_int8 minimum, sync_agent_ec_int8 maximum, ec_char_validate_func_cb valid_func);
+static ec_param_spec_uchar_validate_s *_alloc_init_param_spec_uchar_validate(sync_agent_ec_uint8 minimum, sync_agent_ec_uint8 maximum, ec_uchar_validate_func_cb valid_func);
+static ec_param_spec_int_validate_s *_alloc_init_param_spec_int_validate(sync_agent_ec_int minimum, sync_agent_ec_int maximum, ec_int_validate_func_cb valid_func);
+static ec_param_spec_uint_validate_s *_alloc_init_param_spec_uint_validate(sync_agent_ec_uint minimum, sync_agent_ec_uint maximum, ec_uint_validate_func_cb valid_func);
+static ec_param_spec_float_validate_s *_alloc_init_param_spec_float_validate(sync_agent_ec_float minimum, sync_agent_ec_float maximum, ec_float_validate_func_cb valid_func);
+static ec_param_spec_double_validate_s *_alloc_init_param_spec_double_validate(sync_agent_ec_double minimum, sync_agent_ec_double maximum, ec_double_validate_func_cb valid_func);
+
+static sync_agent_ec_boolean _alloc_and_init_param_spec_number_type_validate(const sync_agent_ec_value_type_e value_type, sync_agent_ec_constpointer minimum, sync_agent_ec_constpointer maximum, ec_private_validate_u * pPrivate_validate);
+
+static sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_default(const sync_agent_ec_value_type_e value_type, const sync_agent_ec_char * name);
+
+static sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_number_type(const sync_agent_ec_value_type_e value_type, const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output,
+                                                                         sync_agent_ec_boolean input_validate_on, sync_agent_ec_constpointer input_minimum, sync_agent_ec_constpointer input_maximum, sync_agent_ec_boolean input_default_on,
+                                                                         sync_agent_ec_constpointer input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_constpointer output_minimum, sync_agent_ec_constpointer output_maximum);
+
+static inline sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_struct_type(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on,
+                                                                                sync_agent_validate_struct_cb input_val_func, sync_agent_ec_boolean input_default_on, sync_agent_ec_constpointer input_default_value, sync_agent_ec_boolean output_validate_on,
+                                                                                sync_agent_validate_struct_cb output_val_func, sync_agent_copy_struct_cb copy_func, sync_agent_free_struct_cb free_func);
+
+static sync_agent_ec_boolean _param_char_validate_func(sync_agent_ec_int8 value, sync_agent_ec_int8 minimum, sync_agent_ec_int8 maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static sync_agent_ec_boolean _param_uchar_validate_func(sync_agent_ec_uint8 value, sync_agent_ec_uint8 minimum, sync_agent_ec_uint8 maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static sync_agent_ec_boolean _param_int_validate_func(sync_agent_ec_int value, sync_agent_ec_int minimum, sync_agent_ec_int maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static sync_agent_ec_boolean _param_uint_validate_func(sync_agent_ec_uint value, sync_agent_ec_uint minimum, sync_agent_ec_uint maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static sync_agent_ec_boolean _param_float_validate_func(sync_agent_ec_float value, sync_agent_ec_float minimum, sync_agent_ec_float maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static sync_agent_ec_boolean _param_double_validate_func(sync_agent_ec_double value, sync_agent_ec_double minimum, sync_agent_ec_double maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       if (value < minimum)
+               return false;
+       if (value > maximum)
+               return false;
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static ec_param_spec_char_validate_s *_alloc_init_param_spec_char_validate(sync_agent_ec_int8 minimum, sync_agent_ec_int8 maximum, ec_char_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_char_validate_s *pValid = (ec_param_spec_char_validate_s *) malloc(sizeof(ec_param_spec_char_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static ec_param_spec_uchar_validate_s *_alloc_init_param_spec_uchar_validate(sync_agent_ec_uint8 minimum, sync_agent_ec_uint8 maximum, ec_uchar_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_uchar_validate_s *pValid = (ec_param_spec_uchar_validate_s *) malloc(sizeof(ec_param_spec_uchar_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static ec_param_spec_int_validate_s *_alloc_init_param_spec_int_validate(sync_agent_ec_int minimum, sync_agent_ec_int maximum, ec_int_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_int_validate_s *pValid = (ec_param_spec_int_validate_s *) malloc(sizeof(ec_param_spec_int_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static ec_param_spec_uint_validate_s *_alloc_init_param_spec_uint_validate(sync_agent_ec_uint minimum, sync_agent_ec_uint maximum, ec_uint_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_uint_validate_s *pValid = (ec_param_spec_uint_validate_s *) malloc(sizeof(ec_param_spec_uint_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static ec_param_spec_float_validate_s *_alloc_init_param_spec_float_validate(sync_agent_ec_float minimum, sync_agent_ec_float maximum, ec_float_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_float_validate_s *pValid = (ec_param_spec_float_validate_s *) malloc(sizeof(ec_param_spec_float_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static ec_param_spec_double_validate_s *_alloc_init_param_spec_double_validate(sync_agent_ec_double minimum, sync_agent_ec_double maximum, ec_double_validate_func_cb valid_func)
+{
+       _INNER_FUNC_ENTER;
+
+       ec_param_spec_double_validate_s *pValid = (ec_param_spec_double_validate_s *) malloc(sizeof(ec_param_spec_double_validate_s));
+       if (pValid == NULL) {
+               return NULL;
+       }
+
+       pValid->minimum = minimum;
+       pValid->maximum = maximum;
+       pValid->valid_func = valid_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pValid;
+}
+
+static sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_default(const sync_agent_ec_value_type_e value_type, const sync_agent_ec_char * name)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(name == NULL, NULL, "sync_agent_ec_char is NULL !!");
+
+       sync_agent_ec_param_spec_s *pParam_spec = (sync_agent_ec_param_spec_s *) calloc(1, sizeof(sync_agent_ec_param_spec_s));
+       if (pParam_spec == NULL) {
+               return NULL;
+       }
+
+       sync_agent_ec_char *dup_name = strdup(name);
+       if (dup_name == NULL) {
+               _free_param_spec(pParam_spec);
+               return NULL;
+       }
+
+       pParam_spec->ref_count = 1;
+       pParam_spec->value_type = value_type;
+       pParam_spec->name = dup_name;
+       pParam_spec->flags = SYNC_AGENT_EC_PARAM_FLAG_DEFAULT;
+
+       _INNER_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+static sync_agent_ec_boolean _alloc_and_init_param_spec_number_type_validate(const sync_agent_ec_value_type_e value_type, sync_agent_ec_constpointer minimum, sync_agent_ec_constpointer maximum, ec_private_validate_u * pPrivate_validate)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(pPrivate_validate == NULL, false, "ec_private_validate_u is NULL !!");
+
+       sync_agent_ec_boolean success = false;
+       switch (value_type) {
+       case SYNC_AGENT_EC_VALUE_TYPE_CHAR:
+               {
+                       ec_param_spec_char_validate_s *pValid = _alloc_init_param_spec_char_validate(*(sync_agent_ec_int8 *) minimum, *(sync_agent_ec_int8 *) maximum, _param_char_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->char_validate = pValid;
+               }
+               break;
+       case SYNC_AGENT_EC_VALUE_TYPE_UCHAR:
+               {
+                       ec_param_spec_uchar_validate_s *pValid = _alloc_init_param_spec_uchar_validate(*(sync_agent_ec_uint8 *) minimum, *(sync_agent_ec_uint8 *) maximum, _param_uchar_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->uchar_validate = pValid;
+               }
+               break;
+       case SYNC_AGENT_EC_VALUE_TYPE_INT:
+               {
+                       ec_param_spec_int_validate_s *pValid = _alloc_init_param_spec_int_validate(*(sync_agent_ec_int *) minimum, *(sync_agent_ec_int *) maximum, _param_int_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->int_validate = pValid;
+               }
+               break;
+       case SYNC_AGENT_EC_VALUE_TYPE_UINT:
+               {
+                       ec_param_spec_uint_validate_s *pValid = _alloc_init_param_spec_uint_validate(*(sync_agent_ec_uint *) minimum, *(sync_agent_ec_uint *) maximum, _param_uint_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->uint_validate = pValid;
+               }
+               break;
+       case SYNC_AGENT_EC_VALUE_TYPE_FLOAT:
+               {
+                       ec_param_spec_float_validate_s *pValid = _alloc_init_param_spec_float_validate(*(sync_agent_ec_float *) minimum, *(sync_agent_ec_float *) maximum, _param_float_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->float_validate = pValid;
+               }
+               break;
+       case SYNC_AGENT_EC_VALUE_TYPE_DOUBLE:
+               {
+                       ec_param_spec_double_validate_s *pValid = _alloc_init_param_spec_double_validate(*(sync_agent_ec_double *) minimum, *(sync_agent_ec_double *) maximum, _param_double_validate_func);
+                       if (pValid == NULL) {
+                               goto return_part;
+                       }
+                       pPrivate_validate->double_validate = pValid;
+               }
+               break;
+       default:
+               assert(false);
+       }
+
+       success = true;
+
+ return_part:
+       _INNER_FUNC_EXIT;
+       return success;
+}
+
+static sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_number_type(const sync_agent_ec_value_type_e value_type, const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output,
+                                                                         sync_agent_ec_boolean input_validate_on, sync_agent_ec_constpointer input_minimum, sync_agent_ec_constpointer input_maximum, sync_agent_ec_boolean input_default_on,
+                                                                         sync_agent_ec_constpointer input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_constpointer output_minimum, sync_agent_ec_constpointer output_maximum)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_boolean success = true;
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_default(value_type, name);
+       if (pParam_spec == NULL) {
+               goto error_part;
+       }
+
+       if (is_input) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT);
+
+               if (input_validate_on) {
+                       _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT_VALIDATE_ON);
+                       success = _alloc_and_init_param_spec_number_type_validate(value_type, input_minimum, input_maximum, &(pParam_spec->input_validate));
+                       if (!success) {
+                               goto error_part;
+                       }
+               }
+
+               if (input_default_on) {
+                       _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON);
+                       sync_agent_set_param_value(&(pParam_spec->default_value), value_type, input_default_value);
+               }
+       }
+
+       if (is_output) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_OUTPUT);
+               success = _alloc_and_init_param_spec_number_type_validate(value_type, output_minimum, output_maximum, &(pParam_spec->output_validate));
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pParam_spec;
+
+ error_part:
+       _free_param_spec(pParam_spec);
+       return NULL;
+}
+
+static inline sync_agent_ec_param_spec_s *_alloc_and_init_param_spec_struct_type(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on,
+                                                                                sync_agent_validate_struct_cb input_val_func, sync_agent_ec_boolean input_default_on, sync_agent_ec_constpointer input_default_value, sync_agent_ec_boolean output_validate_on,
+                                                                                sync_agent_validate_struct_cb output_val_func, sync_agent_copy_struct_cb copy_func, sync_agent_free_struct_cb free_func)
+{
+       _INNER_FUNC_ENTER;
+
+//      sync_agent_ec_boolean success = true;
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_default(SYNC_AGENT_EC_VALUE_TYPE_STRUCT, name);
+       if (pParam_spec == NULL) {
+               goto error_part;
+       }
+
+       if (is_input) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT);
+
+               if (input_validate_on) {
+                       _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT_VALIDATE_ON);
+                       pParam_spec->input_validate.struct_validate_func = input_val_func;
+
+//                      if (!success) {
+//                              goto error_part;
+//                      }
+               }
+
+               if (input_default_on) {
+                       _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON);
+                       sync_agent_set_param_value(&(pParam_spec->default_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, input_default_value);
+               }
+       }
+
+       if (is_output) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_OUTPUT);
+               pParam_spec->output_validate.struct_validate_func = output_val_func;
+       }
+
+       pParam_spec->copy_struct_func = copy_func;
+       pParam_spec->free_struct_func = free_func;
+
+       _INNER_FUNC_EXIT;
+
+       return pParam_spec;
+
+ error_part:
+       _free_param_spec(pParam_spec);
+       return NULL;
+}
+
+inline sync_agent_ec_boolean ec_param_is_input_flag_on(sync_agent_ec_param_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_flag_on(flags, SYNC_AGENT_EC_PARAM_FLAG_INPUT);
+}
+
+inline sync_agent_ec_boolean ec_param_is_output_flag_on(sync_agent_ec_param_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_flag_on(flags, SYNC_AGENT_EC_PARAM_FLAG_OUTPUT);
+}
+
+inline sync_agent_ec_boolean ec_param_is_input_validate_on_flag_on(sync_agent_ec_param_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_flag_on(flags, SYNC_AGENT_EC_PARAM_FLAG_INPUT_VALIDATE_ON);
+}
+
+inline sync_agent_ec_boolean ec_param_is_output_validate_on_flag_on(sync_agent_ec_param_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_flag_on(flags, SYNC_AGENT_EC_PARAM_FLAG_OUTPUT_VALIDATE_ON);
+}
+
+inline sync_agent_ec_boolean ec_param_is_input_default_value_on_flag_on(sync_agent_ec_param_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_flag_on(flags, SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON);
+}
+
+inline sync_agent_ec_boolean _is_flag_on(sync_agent_ec_param_flags_e flags, sync_agent_ec_param_flags_e check_flag)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return (flags & check_flag);
+}
+
+static inline void _on_flag(sync_agent_ec_param_flags_e * flags, sync_agent_ec_param_flags_e _on_flag)
+{
+       _INNER_FUNC_ENTER;
+
+       *flags |= _on_flag;
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _free_param_spec(sync_agent_ec_param_spec_s * pParam_spec)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pParam_spec != NULL) {
+               if (pParam_spec->name != NULL) {
+                       free(pParam_spec->name);
+               }
+
+               /* note : don't free pParam_spec->task */
+
+               /* TODO : free other element */
+               free(pParam_spec);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+/* external */
+sync_agent_ec_param_spec_s *ec_ref_param_spec(sync_agent_ec_param_spec_s * param_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (param_spec == NULL) {
+               return NULL;
+       }
+
+       g_atomic_int_inc(&(param_spec->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return param_spec;
+}
+
+EXPORT_API void sync_agent_unref_param_spec(sync_agent_ec_param_spec_s * param_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (param_spec == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_dec_and_test(&(param_spec->ref_count))) {
+               _free_param_spec(param_spec);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_boolean(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_default_on, sync_agent_ec_boolean input_default_value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_value_type_e value_type = SYNC_AGENT_EC_VALUE_TYPE_BOOLEAN;
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_default(value_type, name);
+       if (pParam_spec == NULL) {
+               goto error_part;
+       }
+
+       if (is_input) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT);
+
+               if (input_default_on) {
+                       _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON);
+                       sync_agent_set_param_value(&(pParam_spec->default_value), value_type, &input_default_value);
+               }
+       }
+
+       if (is_output) {
+               _on_flag(&(pParam_spec->flags), SYNC_AGENT_EC_PARAM_FLAG_OUTPUT);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+
+ error_part:
+       _free_param_spec(pParam_spec);
+       return NULL;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_char(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_int8 input_minimum,
+                                                    sync_agent_ec_int8 input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_int8 input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_int8 output_minimum,
+                                                    sync_agent_ec_int8 output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_CHAR, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_uchar(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_uint8 input_minimum,
+                                                     sync_agent_ec_uint8 input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_uint8 input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_uint8 output_minimum,
+                                                     sync_agent_ec_uint8 output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_UCHAR, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+EXPORT_API sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_int(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_int input_minimum,
+                                                                      sync_agent_ec_int input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_int input_default_value, sync_agent_ec_boolean output_validate_on,
+                                                                      sync_agent_ec_int output_minimum, sync_agent_ec_int output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_INT, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_uint(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_uint input_minimum,
+                                                    sync_agent_ec_uint input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_uint input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_uint output_minimum,
+                                                    sync_agent_ec_uint output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_UINT, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_float(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_float input_minimum,
+                                                     sync_agent_ec_float input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_float input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_float output_minimum,
+                                                     sync_agent_ec_float output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_FLOAT, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_double(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_double input_minimum,
+                                                      sync_agent_ec_double input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_double input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_double output_minimum,
+                                                      sync_agent_ec_double output_maximum)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_param_spec_s *pParam_spec = _alloc_and_init_param_spec_number_type(SYNC_AGENT_EC_VALUE_TYPE_DOUBLE, name,
+                                                                                        is_input, is_output,
+                                                                                        input_validate_on, &input_minimum, &input_maximum,
+                                                                                        input_default_on, &input_default_value,
+                                                                                        output_validate_on, &output_minimum, &output_maximum);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+EXPORT_API sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_structure(const sync_agent_ec_char * name, sync_agent_copy_struct_cb copy_func, sync_agent_free_struct_cb free_func, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output,
+                                                                            sync_agent_ec_boolean input_validate_on, sync_agent_validate_struct_cb in_val_func, sync_agent_ec_boolean input_default_on, sync_agent_ec_pointer pDefault_Struct,
+                                                                            sync_agent_ec_boolean output_validate_on, sync_agent_validate_struct_cb out_val_func)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _alloc_and_init_param_spec_struct_type(name, is_input, is_output, input_validate_on, in_val_func, input_default_on, pDefault_Struct, output_validate_on, out_val_func, copy_func, free_func);
+}
+
+const sync_agent_ec_value_type_e ec_get_param_spec_value_type(sync_agent_ec_param_spec_s * pParam_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pParam_spec == NULL) {
+               return SYNC_AGENT_EC_VALUE_TYPE_UNKNOWN;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec->value_type;
+}
+
+const sync_agent_ec_char *ec_get_param_spec_name(sync_agent_ec_param_spec_s * pParam_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pParam_spec == NULL) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pParam_spec->name;
+}
diff --git a/src/framework/engine-controller/param_spec_internal.h b/src/framework/engine-controller/param_spec_internal.h
new file mode 100755 (executable)
index 0000000..4bf3ef0
--- /dev/null
@@ -0,0 +1,338 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_SPEC_INTERNAL_H_
+#define PARAM_SPEC_INTERNAL_H_
+
+#include "engine-controller/param_value.h"
+#include "engine-controller/param_spec.h"
+
+/**
+ * @file param_spec_internal.h
+ * @brief Provides alloc and free of param spec structure
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Type define of callback function used for char type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_char_validate_func_cb) (sync_agent_ec_int8 value, sync_agent_ec_int8 minimum, sync_agent_ec_int8 maximum);
+/**
+ * @brief Type define of callback function used for uchar type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_uchar_validate_func_cb) (sync_agent_ec_uint8 value, sync_agent_ec_uint8 minimum, sync_agent_ec_uint8 maximum);
+/**
+ * @brief Type define of callback function used for int type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_int_validate_func_cb) (sync_agent_ec_int value, sync_agent_ec_int minimum, sync_agent_ec_int maximum);
+/**
+ * @brief Type define of callback function used for uint type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_uint_validate_func_cb) (sync_agent_ec_uint value, sync_agent_ec_uint minimum, sync_agent_ec_uint maximum);
+/**
+ * @brief Type define of callback function used for float type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_float_validate_func_cb) (sync_agent_ec_float value, sync_agent_ec_float minimum, sync_agent_ec_float maximum);
+/**
+ * @brief Type define of callback function used for double type of param spec validlation
+ */
+typedef sync_agent_ec_boolean(*ec_double_validate_func_cb) (sync_agent_ec_double value, sync_agent_ec_double minimum, sync_agent_ec_double maximum);
+
+/**
+ * @brief Type define of struct _ec_param_spec_char_validate
+ */
+typedef struct _ec_param_spec_char_validate ec_param_spec_char_validate_s;
+/**
+ * @brief Type define of struct _ec_param_spec_uchar_validate
+ */
+typedef struct _ec_param_spec_uchar_validate ec_param_spec_uchar_validate_s;
+/**
+ * @brief Type define of struct _ec_param_spec_int_validate
+ */
+typedef struct _ec_param_spec_int_validate ec_param_spec_int_validate_s;
+/**
+ * @brief Type define of struct _ec_param_spec_uint_validate
+ */
+typedef struct _ec_param_spec_uint_validate ec_param_spec_uint_validate_s;
+/**
+ * @brief Type define of struct _ec_param_spec_float_validate
+ */
+typedef struct _ec_param_spec_float_validate ec_param_spec_float_validate_s;
+/**
+ * @brief Type define of struct _ec_param_spec_double_validate
+ */
+typedef struct _ec_param_spec_double_validate ec_param_spec_double_validate_s;
+
+/**
+ * @brief Structure of validation propert for char type of param spec
+ */
+struct _ec_param_spec_char_validate {
+       sync_agent_ec_int8 minimum;     /**< minimum value expected */
+       sync_agent_ec_int8 maximum;     /**< maximum value expected */
+       ec_char_validate_func_cb valid_func;    /**< callback function used for validation */
+};
+
+/**
+ * @brief Structure of validation propert for uchar type of param spec
+ */
+struct _ec_param_spec_uchar_validate {
+       sync_agent_ec_uint8 minimum;    /**< minimum value expected */
+       sync_agent_ec_uint8 maximum;    /**< maximum value expected */
+       ec_uchar_validate_func_cb valid_func;   /**< callback function used for validation */
+};
+
+/**
+ * @brief Structure of validation propert for int type of param spec
+ */
+struct _ec_param_spec_int_validate {
+       sync_agent_ec_int minimum;      /**< minimum value expected */
+       sync_agent_ec_int maximum;      /**< maximum value expected */
+       ec_int_validate_func_cb valid_func;     /**< callback function used for validation */
+};
+
+/**
+ * @brief Structure of validation propert for uint type of param spec
+ */
+struct _ec_param_spec_uint_validate {
+       sync_agent_ec_uint minimum;     /**< minimum value expected */
+       sync_agent_ec_uint maximum;     /**< maximum value expected */
+       ec_uint_validate_func_cb valid_func;    /**< callback function used for validation */
+};
+
+/**
+ * @brief Structure of validation propert for float type of param spec
+ */
+struct _ec_param_spec_float_validate {
+       sync_agent_ec_float minimum;    /**< minimum value expected */
+       sync_agent_ec_float maximum;    /**< maximum value expected */
+       ec_float_validate_func_cb valid_func;   /**< callback function used for validation */
+};
+
+/**
+ * @brief Structure of validation propert for double type of param spec
+ */
+struct _ec_param_spec_double_validate {
+       sync_agent_ec_double minimum;           /**< minimum value expected */
+       sync_agent_ec_double maximum;   /**< maximum value expected */
+       ec_double_validate_func_cb valid_func;  /**< callback function used for validation */
+};
+
+/**
+ * @brief Union of validation property types
+ */
+typedef union {
+       ec_param_spec_char_validate_s *char_validate;   /**< char type of validation property */
+       ec_param_spec_uchar_validate_s *uchar_validate; /**< uchar type of validation property */
+       ec_param_spec_int_validate_s *int_validate;     /**< int type of validation property */
+       ec_param_spec_uint_validate_s *uint_validate;   /**< uint type of validation property */
+       ec_param_spec_float_validate_s *float_validate; /**< float type of validation property */
+       ec_param_spec_double_validate_s *double_validate;       /**< double type of validation property */
+       sync_agent_validate_struct_cb struct_validate_func;     /**< pointer type of validation property using callback*/
+} ec_private_validate_u;
+
+/**
+ * @brief Structure of param spec instance
+ */
+struct sync_agent_ec_param_param_spec {
+       sync_agent_ec_int ref_count;    /**< reference count of instance */
+       sync_agent_ec_value_type_e value_type;  /**< type of param */
+       sync_agent_ec_char *name;       /**< name of param */
+       sync_agent_ec_param_flags_e flags;      /**< flags to specify on this param */
+
+       sync_agent_ec_param_value_u default_value;      /**< default value that this param may have */
+       ec_private_validate_u input_validate;   /**< validation property on input case */
+       ec_private_validate_u output_validate;  /**< validation property on output case */
+
+       sync_agent_copy_struct_cb copy_struct_func;     /**< callback function pointer used to copy param values */
+       sync_agent_free_struct_cb free_struct_func;     /**< callback function pointer used to free param values */
+};
+
+/**
+ * @brief Check if 'input' flag is on
+ * @param[in] flags sync_agent_ec_param_flags_e type of flag to check
+ * @return true if flag is on, otherwise false
+ */
+inline sync_agent_ec_boolean ec_param_is_input_flag_on(sync_agent_ec_param_flags_e flags);
+/**
+ * @brief Check if 'output' flag is on
+ * @param[in] flags sync_agent_ec_param_flags_e type of flag to check
+ * @return true if flag is on, otherwise false
+ */
+inline sync_agent_ec_boolean ec_param_is_output_flag_on(sync_agent_ec_param_flags_e flags);
+/**
+ * @brief Check if 'intput validate' flag is on
+ * @param[in] flags sync_agent_ec_param_flags_e type of flag to check
+ * @return true if flag is on, otherwise false
+ */
+inline sync_agent_ec_boolean ec_param_is_input_validate_on_flag_on(sync_agent_ec_param_flags_e flags);
+/**
+ * @brief Check if 'output validate' flag is on
+ * @param[in] flags sync_agent_ec_param_flags_e type of flag to check
+ * @return true if flag is on, otherwise false
+ */
+inline sync_agent_ec_boolean ec_param_is_output_validate_on_flag_on(sync_agent_ec_param_flags_e flags);
+/**
+ * @brief Check if 'intput default value' flag is on
+ * @param[in] flags sync_agent_ec_param_flags_e type of flag to check
+ * @return true if flag is on, otherwise false
+ */
+inline sync_agent_ec_boolean ec_param_is_input_default_value_on_flag_on(sync_agent_ec_param_flags_e flags);
+
+/**
+ * @brief Increases reference count of parameter spec
+ * @param[in] param_spec Pointer of parameter spec to increase ref count
+ * @return Pointer of parameter spec itself on success, otherwise NULL
+ */
+sync_agent_ec_param_spec_s *ec_ref_param_spec(sync_agent_ec_param_spec_s * param_spec);
+
+/**
+ * @brief Allocs and returns boolean type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_boolean(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_default_on, sync_agent_ec_boolean input_default_value);
+
+/**
+ * @brief Allocs and returns char type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_char(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_int8 input_minimum,
+                                                    sync_agent_ec_int8 input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_int8 input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_int8 output_minimum,
+                                                    sync_agent_ec_int8 output_maximum);
+
+/**
+ * @brief Allocs and returns unsigned char type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_uchar(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_uint8 input_minimum,
+                                                     sync_agent_ec_uint8 input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_uint8 input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_uint8 output_minimum,
+                                                     sync_agent_ec_uint8 output_maximum);
+
+/**
+ * @brief Allocs and returns unsigned int type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_uint(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_uint input_minimum,
+                                                    sync_agent_ec_uint input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_uint input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_uint output_minimum,
+                                                    sync_agent_ec_uint output_maximum);
+
+/**
+ * @brief Allocs and returns float type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_float(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_float input_minimum,
+                                                     sync_agent_ec_float input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_float input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_float output_minimum,
+                                                     sync_agent_ec_float output_maximum);
+
+/**
+ * @brief Allocs and returns double type of parameter spec
+ * @param[in] name Name of parameter which user defined
+ * @param[in] is_input On if this parameter to be used as input
+ * @param[in] is_output On if this parameter to be used as output
+ * @param[in] input_validate_on On if want to perform input parameter value validation
+ * @param[in] input_minimum Minimum value of valid input parameter value range
+ * @param[in] input_maximum Maximum value of valid input parameter value range
+ * @param[in] input_default_on On if this parameter to contain default value
+ * @param[in] input_default_value Default value for this parameter to contain
+ * @param[in] output_validate_on On if want to perform output parameter value validation
+ * @param[in] output_minimum Minimum value of valid output parameter value range
+ * @param[in] output_maximum Maximum value of valid output parameter value range
+ * @return Pointer of parameter spec which defined as ordered type
+ */
+sync_agent_ec_param_spec_s *ec_alloc_param_spec_double(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_double input_minimum,
+                                                      sync_agent_ec_double input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_double input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_double output_minimum,
+                                                      sync_agent_ec_double output_maximum);
+
+/**
+ * @brief Provides data type of requested parameter spec
+ * @param[in] pParam_spec Parameter spec to get data type from
+ * @return sync_agent_ec_value_type_e Type of enumeration value
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_UNKNOWN Unknown type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_BOOLEAN Boolean type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_CHAR Char type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_UCHAR Unsigned char type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_INT Integer type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_UINT Unsigned integer type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_FLOAT Float type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_DOUBLE Double type
+ * @retval SYNC_AGENT_EC_VALUE_TYPE_STRUCT Structure(Pointer) type
+ */
+const sync_agent_ec_value_type_e ec_get_param_spec_value_type(sync_agent_ec_param_spec_s * pParam_spec);
+
+/**
+ * @brief Provides name of requested parameter spec
+ * @param[in] param_spec Parameter spec to get data type from
+ * @return Name of parameter spec which user assigned on spec creation
+ */
+const sync_agent_ec_char *ec_get_param_spec_name(sync_agent_ec_param_spec_s * param_spec);
+
+/**
+ *     @}
+ */
+
+#endif                         /* PARAM_SPEC_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/param_value.c b/src/framework/engine-controller/param_value.c
new file mode 100755 (executable)
index 0000000..78e30ab
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include "utility/sync_util.h"
+#include "engine-controller/param_value.h"
+#include "engine-controller/param_value_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+EXPORT_API void sync_agent_set_param_value(sync_agent_ec_param_value_u * param_value, sync_agent_ec_value_type_e value_type, sync_agent_ec_constpointer pValue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(param_value == NULL, "sync_agent_ec_param_value_u is NULL !!");
+
+       if (pValue != NULL) {
+               switch (value_type) {
+               case SYNC_AGENT_EC_VALUE_TYPE_BOOLEAN:
+                       param_value->boolean_value = *(sync_agent_ec_boolean *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_CHAR:
+                       param_value->char_value = *(sync_agent_ec_char *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_UCHAR:
+                       param_value->uchar_value = *(sync_agent_ec_uchar *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_INT:
+                       param_value->int_value = *(sync_agent_ec_int *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_UINT:
+                       param_value->uint_value = *(sync_agent_ec_uint *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_FLOAT:
+                       param_value->float_value = *(sync_agent_ec_float *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_DOUBLE:
+                       param_value->double_value = *(sync_agent_ec_double *) pValue;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_STRUCT:
+                       param_value->pointer_value = *(sync_agent_ec_pointer *) pValue;
+                       break;
+               default:
+                       assert(false);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_set_param_value_with_other_param_value(sync_agent_ec_param_value_u * dest_param_value, sync_agent_ec_param_value_u * src_param_value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(dest_param_value == NULL, "sync_agent_ec_param_value_u is NULL !!");
+
+       memcpy(dest_param_value, src_param_value, sizeof(sync_agent_ec_param_value_u));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_get_param_value(sync_agent_ec_param_value_u * param_value, sync_agent_ec_value_type_e value_type, sync_agent_ec_pointer value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(param_value == NULL, "sync_agent_ec_param_value_u is NULL !!");
+
+       if (value != NULL) {
+               switch (value_type) {
+               case SYNC_AGENT_EC_VALUE_TYPE_BOOLEAN:
+                       *(sync_agent_ec_boolean *) value = param_value->boolean_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_CHAR:
+                       *(sync_agent_ec_char *) value = param_value->char_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_UCHAR:
+                       *(sync_agent_ec_uchar *) value = param_value->uchar_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_INT:
+                       *(sync_agent_ec_int *) value = param_value->int_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_UINT:
+                       *(sync_agent_ec_uint *) value = param_value->uint_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_FLOAT:
+                       *(sync_agent_ec_float *) value = param_value->float_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_DOUBLE:
+                       *(sync_agent_ec_double *) value = param_value->double_value;
+                       break;
+               case SYNC_AGENT_EC_VALUE_TYPE_STRUCT:
+                       *(sync_agent_ec_pointer *) value = param_value->pointer_value;
+                       break;
+               default:
+                       assert(false);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/param_value_internal.h b/src/framework/engine-controller/param_value_internal.h
new file mode 100755 (executable)
index 0000000..c7572a8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARAM_VALUE_INTERNAL_H_
+#define PARAM_VALUE_INTERNAL_H_
+
+//#include "fundamental_type.h"
+//#include "define.h"
+#include "engine-controller/param_value.h"
+
+/**
+ * @file param_value_internal.h
+ * @brief Provides set/get operation of parameter value
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Provides set operation from existing param_value_t type of variable
+ * @param[in] dest_param_value param_value_t type of variable to set value to
+ * @param[in] src_param_value param_value_t type of variable to get value from
+ */
+void ec_set_param_value_with_other_param_value(sync_agent_ec_param_value_u * dest_param_value, sync_agent_ec_param_value_u * src_param_value);
+
+/**
+ *     @}
+ */
+
+#endif                         /* PARAM_VALUE_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/queuing_rule_spec.c b/src/framework/engine-controller/queuing_rule_spec.c
new file mode 100755 (executable)
index 0000000..39736e9
--- /dev/null
@@ -0,0 +1,761 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <glib.h>
+#include "utility/fw_assert.h"
+#include "utility/sync_util.h"
+#include "engine-controller/queuing_rule_spec.h"
+#include "engine-controller/queuing_rule_spec_internal.h"
+#include "engine-controller/task_spec_internal.h"
+#include "engine-controller/task.h"
+#include "engine-controller/task_message.h"
+#include "engine-controller/internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+static ec_progress_blocking_entity_t *_queuing_rule_spec_get_progress_blocking_entity(sync_agent_ec_queuing_rule_spec_s * rule, sync_agent_ec_uint root_task_spec_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(rule == NULL, NULL, "sync_agent_ec_queuing_rule_spec_s is NULL !!");
+
+       GSList *iter = NULL;
+       ec_progress_blocking_entity_t *entity = NULL;
+       for (iter = rule->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+               entity = (ec_progress_blocking_entity_t *) (iter->data);
+               if (entity->root_task_spec_id == root_task_spec_id) {
+                       return entity;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;
+}
+
+static sync_agent_ec_boolean _queuing_rule_spec_is_valid_child_path(sync_agent_ec_task_spec_s * root_task_spec, sync_agent_ec_uint child_depth, va_list ap)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(root_task_spec == NULL, false, "sync_agent_ec_task_spec_s is NULL !!");
+
+       sync_agent_ec_uint i = 0;
+       sync_agent_ec_boolean is_dynamic = false;
+       sync_agent_ec_int dynamic_case = 0;
+       sync_agent_ec_int child_index = 0;
+
+       sync_agent_ec_task_spec_s *parent_task_spec = root_task_spec;
+       sync_agent_ec_boolean parent_is_dynamic = false;
+       sync_agent_ec_task_spec_s *child_task_spec = NULL;
+
+       for (i = 0; i < child_depth; i++) {
+               is_dynamic = va_arg(ap, sync_agent_ec_boolean);
+               dynamic_case = va_arg(ap, sync_agent_ec_int);
+               child_index = va_arg(ap, sync_agent_ec_int);
+
+               /* not container or dynamic container case */
+               if (ec_task_spec_is_simple(parent_task_spec)) {
+                       return false;
+               }
+
+               /* check dynamic equality */
+               parent_is_dynamic = ec_task_spec_is_dynamic_container(parent_task_spec);
+               if ((is_dynamic && !parent_is_dynamic) || (!is_dynamic && parent_is_dynamic)) {
+                       return false;
+               }
+
+               if (is_dynamic) {
+                       if (SYNC_AGENT_EC_OK != ec_task_spec_valididate_child_task_index_on_dynamic_case(dynamic_case, parent_task_spec, child_index)) {
+                               return false;
+                       }
+                       child_task_spec = ec_task_spec_get_child_task_spec_on_dynamic_case(dynamic_case, parent_task_spec, child_index);
+               } else {
+                       if (SYNC_AGENT_EC_OK != ec_task_spec_valididate_child_task_index(parent_task_spec, child_index)) {
+                               return false;
+                       }
+                       child_task_spec = ec_task_spec_get_child_task_spec(parent_task_spec, child_index);
+               }
+
+               SYNC_AGENT_UTIL_ASSERT_CONDITION(child_task_spec != NULL, "valid child but can ec_task_spec_get_child_task_spec or ec_task_spec_get_child_task_spec_on_dynamic_case return NULL\n");
+
+               parent_task_spec = child_task_spec;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+static void _queuing_rule_spec_free_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * rule)
+{
+       _INNER_FUNC_ENTER;
+
+       if (rule != NULL) {
+               if (rule->name != NULL) {
+                       free(rule->name);
+               }
+
+               if (rule->progress_blocking_entity_list != NULL) {
+                       GSList *iter = NULL;
+                       ec_progress_blocking_entity_t *entity = NULL;
+                       for (iter = rule->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+                               entity = (ec_progress_blocking_entity_t *) (iter->data);
+                               ec_progress_blocking_entity_free(entity);
+                       }
+
+                       g_slist_free(rule->progress_blocking_entity_list);
+               }
+
+               if (rule->progress_blocking_queue != NULL) {
+                       g_queue_free(rule->progress_blocking_queue);
+               }
+
+               free(rule);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+/* implementation of queuing_rule_spec_internal.h */
+
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_new(sync_agent_ec_boolean blocking_flag, sync_agent_ec_uint tree_level, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case, sync_agent_ec_uint child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_n_ary_tree_node_with_flag_t *node = (ec_n_ary_tree_node_with_flag_t *) malloc(sizeof(ec_n_ary_tree_node_with_flag_t));
+       if (node == NULL) {
+               goto error_part;
+       }
+
+       node->blocking_flag = blocking_flag;
+
+       node->tree_level = tree_level;
+       node->is_dynamic_child = is_dynamic_child;
+       node->dynamic_case = dynamic_case;
+       node->child_index = child_index;
+
+       node->parent_node = NULL;
+       node->first_child_node = NULL;
+       node->next_sibling_node = NULL;
+       node->prev_sibling_node = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+
+ error_part:
+       ec_n_ary_tree_node_with_flag_free_1(node);
+       return NULL;
+}
+
+void ec_n_ary_tree_node_with_flag_free_1(ec_n_ary_tree_node_with_flag_t * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (node != NULL) {
+               free(node);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_n_ary_tree_node_with_flag_free_subtree(ec_n_ary_tree_node_with_flag_t * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(node == NULL, "ec_n_ary_tree_node_with_flag_t is NULL !!");
+
+       if (node->parent_node != NULL) {
+               ec_n_ary_tree_node_with_flag_unlink_child_node(node->parent_node, node);
+       }
+
+       /* destroy all children without using recursive call */
+       ec_n_ary_tree_node_with_flag_t *current_node = node;
+       ec_n_ary_tree_node_with_flag_t *previous_node = NULL;
+
+       sync_agent_ec_boolean end_of_walk = false;
+       sync_agent_ec_boolean has_to_check_child = true;
+       while (!end_of_walk) {
+               previous_node = current_node;
+               if (has_to_check_child) {
+                       if (current_node->first_child_node == NULL) {
+                               if (current_node->next_sibling_node == NULL) {
+                                       current_node = current_node->parent_node;
+                                       has_to_check_child = false;
+                               } else {
+                                       current_node = current_node->next_sibling_node;
+                                       has_to_check_child = true;
+                               }
+                               ec_n_ary_tree_node_with_flag_free_1(previous_node);
+                       } else {
+                               /* goto leaf node step by step */
+                               current_node = current_node->first_child_node;
+
+                               /* note that we do not free prev node in this case */
+                       }
+               } else {
+                       if (current_node->next_sibling_node == NULL) {
+                               current_node = current_node->parent_node;
+                       } else {
+                               /* goto next sibling since all children of current node are freed */
+                               current_node = current_node->next_sibling_node;
+                               has_to_check_child = true;
+                       }
+                       ec_n_ary_tree_node_with_flag_free_1(previous_node);
+               }
+
+               if (current_node == NULL) {
+                       end_of_walk = true;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_uint ec_n_ary_tree_node_with_flag_count_subtree_flag_on_number(ec_n_ary_tree_node_with_flag_t * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_uint count_flag_on = 0;
+
+       /* visit all children to count flag on number without using recursive call */
+       ec_n_ary_tree_node_with_flag_t *current_node = node;
+       ec_n_ary_tree_node_with_flag_t *previous_node = NULL;
+
+       sync_agent_ec_boolean end_of_walk = false;
+       sync_agent_ec_boolean has_to_check_child = true;
+       while (!end_of_walk) {
+               previous_node = current_node;
+               if (has_to_check_child) {
+                       if (current_node->first_child_node == NULL) {
+                               /* set next current node */
+                               if (current_node->next_sibling_node == NULL) {
+                                       current_node = current_node->parent_node;
+                                       has_to_check_child = false;
+                               } else {
+                                       current_node = current_node->next_sibling_node;
+                                       has_to_check_child = true;
+                               }
+
+                               if (ec_n_ary_tree_node_with_flag_is_blocking_flag_on(previous_node)) {
+                                       count_flag_on++;
+                               }
+                       } else {
+                               /* goto leaf node step by step */
+                               current_node = current_node->first_child_node;
+
+                               /* note that we do not free prev node in this case */
+                       }
+               } else {
+                       if (current_node->next_sibling_node == NULL) {
+                               current_node = current_node->parent_node;
+                       } else {
+                               /* goto next sibling since all children of current node are freed */
+                               current_node = current_node->next_sibling_node;
+                               has_to_check_child = true;
+                       }
+
+                       if (ec_n_ary_tree_node_with_flag_is_blocking_flag_on(previous_node)) {
+                               count_flag_on++;
+                       }
+               }
+
+               if (current_node == node->parent_node || current_node == node->next_sibling_node) {
+                       end_of_walk = true;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return count_flag_on;
+}
+
+void ec_n_ary_tree_node_with_flag_set_blocking_flag_on(ec_n_ary_tree_node_with_flag_t * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(node == NULL, "ec_n_ary_tree_node_with_flag_t is NULL !!");
+
+       node->blocking_flag = true;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_n_ary_tree_node_with_flag_is_blocking_flag_on(ec_n_ary_tree_node_with_flag_t * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return node->blocking_flag;
+}
+
+sync_agent_ec_boolean ec_n_ary_tree_node_with_flag_has_same_content_without_blocking_flag(ec_n_ary_tree_node_with_flag_t * node, sync_agent_ec_uint tree_level, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case,
+                                                                                         sync_agent_ec_uint child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (node->tree_level == tree_level && node->is_dynamic_child == is_dynamic_child) {
+               if (is_dynamic_child) {
+                       if (node->dynamic_case == dynamic_case && node->child_index == child_index) {
+                               _EXTERN_FUNC_EXIT;
+                               return true;
+                       }
+               } else {
+                       if (node->child_index == child_index) {
+                               _EXTERN_FUNC_EXIT;
+                               return true;
+                       }
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return false;
+}
+
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_add_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, sync_agent_ec_boolean blocking_flag, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case,
+                                                                           sync_agent_ec_uint child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_node == NULL, NULL, "ec_n_ary_tree_node_with_flag_t is NULL !!");
+
+       ec_n_ary_tree_node_with_flag_t *child_node = ec_n_ary_tree_node_with_flag_new(blocking_flag, parent_node->tree_level + 1,
+                                                                                     is_dynamic_child, dynamic_case, child_index);
+       if (child_node == NULL) {
+               return NULL;
+       }
+
+       ec_n_ary_tree_node_with_flag_link_child_node(parent_node, child_node);
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_node;
+}
+
+void ec_n_ary_tree_node_with_flag_link_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, ec_n_ary_tree_node_with_flag_t * child_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(parent_node == NULL, "ec_n_ary_tree_node_with_flag_t is NULL !!");
+
+       /* set parent */
+       child_node->parent_node = parent_node;
+
+       /* set child */
+       if (parent_node->first_child_node != NULL) {
+               parent_node->first_child_node->prev_sibling_node = child_node;
+       }
+       child_node->next_sibling_node = parent_node->first_child_node;
+       parent_node->first_child_node = child_node;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_n_ary_tree_node_with_flag_unlink_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, ec_n_ary_tree_node_with_flag_t * child_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (parent_node == NULL) {
+               return;
+       }
+
+       if (parent_node->first_child_node == child_node) {
+               parent_node->first_child_node = child_node->next_sibling_node;
+       }
+
+       child_node->parent_node = NULL;
+
+       /* unlink sibling list */
+       if (child_node->prev_sibling_node != NULL) {
+               child_node->prev_sibling_node->next_sibling_node = child_node->next_sibling_node;
+       }
+       if (child_node->next_sibling_node != NULL) {
+               child_node->next_sibling_node->prev_sibling_node = child_node->prev_sibling_node;
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_get_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case, sync_agent_ec_uint child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_node == NULL, NULL, "ec_n_ary_tree_node_with_flag_t is NULL !!");
+
+       ec_n_ary_tree_node_with_flag_t *child_node = NULL;
+       for (child_node = parent_node->first_child_node; child_node != NULL; child_node = child_node->next_sibling_node) {
+               if (ec_n_ary_tree_node_with_flag_has_same_content_without_blocking_flag(child_node, parent_node->tree_level + 1, is_dynamic_child, dynamic_case, child_index)) {
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_node;
+}
+
+ec_progress_blocking_element_set_t *ec_progress_blocking_element_set_new()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_progress_blocking_element_set_t *set = (ec_progress_blocking_element_set_t *) calloc(1, sizeof(ec_progress_blocking_element_set_t));
+       if (set == NULL) {
+               goto error_part;
+       }
+
+       set->progress_blocking_element_cnt = 0;
+       set->n_ary_tree_with_flag = ec_n_ary_tree_node_with_flag_new(false, 0, 0, 0, 0);        /* set root node */
+       if (set->n_ary_tree_with_flag == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return set;
+
+ error_part:
+       ec_progress_blocking_element_set_free(set);
+       return NULL;
+}
+
+void ec_progress_blocking_element_set_free(ec_progress_blocking_element_set_t * set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (set != NULL) {
+               if (set->n_ary_tree_with_flag != NULL) {
+                       ec_n_ary_tree_node_with_flag_free_subtree(set->n_ary_tree_with_flag);
+                       set->n_ary_tree_with_flag = NULL;
+               }
+
+               free(set);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_error_e ec_progress_blocking_element_add(ec_progress_blocking_element_set_t * set, sync_agent_ec_uint depth, va_list ap)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(set == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_progress_blocking_element_set_t is NULL !!");
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       ec_n_ary_tree_node_with_flag_t *root_node = set->n_ary_tree_with_flag;  /* note that root_node != NULL */
+       ec_n_ary_tree_node_with_flag_t *last_exist_parent_node = NULL;
+       ec_n_ary_tree_node_with_flag_t *first_alloc_node = NULL;
+       ec_n_ary_tree_node_with_flag_t *parent_node = NULL;
+       ec_n_ary_tree_node_with_flag_t *child_node = NULL;
+
+       sync_agent_ec_boolean is_dynamic_child = false;
+       sync_agent_ec_int dynamic_case = 0;
+       sync_agent_ec_uint child_index = 0;
+
+       sync_agent_ec_uint i = 0;
+
+       if (depth == 0) {
+               if (!(root_node->blocking_flag)) {
+                       (set->progress_blocking_element_cnt)++;
+                       ec_n_ary_tree_node_with_flag_set_blocking_flag_on(root_node);
+               }
+
+               return ec_error;
+       }
+
+       parent_node = root_node;
+       for (i = 1; i <= depth; i++) {
+               is_dynamic_child = va_arg(ap, sync_agent_ec_boolean);
+               dynamic_case = va_arg(ap, sync_agent_ec_int);
+               child_index = va_arg(ap, sync_agent_ec_int);
+
+               child_node = ec_n_ary_tree_node_with_flag_get_child_node(parent_node, is_dynamic_child, dynamic_case, child_index);
+
+               if (child_node == NULL) {
+                       last_exist_parent_node = parent_node;
+                       first_alloc_node = ec_n_ary_tree_node_with_flag_add_child_node(parent_node, i == depth, is_dynamic_child, dynamic_case, child_index);
+                       if (first_alloc_node == NULL) {
+                               ec_error = SYNC_AGENT_EC_OUT_OF_MEMORY;
+                               goto error_part;
+                       }
+
+                       if (i == depth) {
+                               (set->progress_blocking_element_cnt)++;
+                               goto return_part;
+                       }
+
+                       parent_node = first_alloc_node;
+                       break;
+               }
+               parent_node = child_node;
+       }
+
+       if (child_node != NULL) {
+               /* already exist child node */
+               if (!(child_node->blocking_flag)) {
+                       ec_n_ary_tree_node_with_flag_set_blocking_flag_on(child_node);
+                       (set->progress_blocking_element_cnt)++;
+               }
+               goto return_part;
+       } else {
+               /* add child node */
+               for (i++; i <= depth; i++) {
+                       is_dynamic_child = va_arg(ap, sync_agent_ec_boolean);
+                       dynamic_case = va_arg(ap, sync_agent_ec_int);
+                       child_index = va_arg(ap, sync_agent_ec_int);
+
+                       child_node = ec_n_ary_tree_node_with_flag_add_child_node(parent_node, (i == depth), is_dynamic_child, dynamic_case, child_index);
+                       if (child_node == NULL) {
+                               goto error_part;
+                       }
+
+                       parent_node = child_node;
+               }
+               (set->progress_blocking_element_cnt)++;
+       }
+
+ return_part:
+       if (last_exist_parent_node == NULL) {   /* when set->n_ary_tree_with_flag == NULL */
+               set->n_ary_tree_with_flag = first_alloc_node;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_error;
+
+ error_part:
+       if (first_alloc_node != NULL) {
+               ec_n_ary_tree_node_with_flag_free_subtree(first_alloc_node);
+       }
+       return ec_error;
+}
+
+ec_progress_blocking_entity_t *ec_progress_blocking_entity_new(sync_agent_ec_uint root_task_spec_id, sync_agent_ec_queuing_rule_spec_s * queuing_rule_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_progress_blocking_entity_t *entity = (ec_progress_blocking_entity_t *) calloc(1, sizeof(ec_progress_blocking_entity_t));
+       if (entity == NULL) {
+               goto error_part;
+       }
+
+       entity->ref_count = 1;
+       entity->root_task_spec_id = root_task_spec_id;
+       entity->queuing_rule_spec = ec_ref_queuing_rule_spec(queuing_rule_spec);
+       entity->element_set = ec_progress_blocking_element_set_new();
+       if (entity->element_set == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return entity;
+
+ error_part:
+       ec_progress_blocking_entity_free(entity);
+       return NULL;
+}
+
+void ec_progress_blocking_entity_free(ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (entity != NULL) {
+               if (entity->element_set != NULL) {
+                       ec_progress_blocking_element_set_free(entity->element_set);
+               }
+               if (entity->queuing_rule_spec != NULL) {
+                       sync_agent_unref_queuing_rule_spec(entity->queuing_rule_spec);
+               }
+               free(entity);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_progress_blocking_entity_t *ec_progress_blocking_entity_ref(ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (entity == NULL) {
+               return NULL;
+       }
+
+       g_atomic_int_inc(&(entity->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return entity;
+}
+
+void ec_progress_blocking_entity_unref(ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (entity == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_dec_and_test(&(entity->ref_count))) {
+               ec_progress_blocking_entity_free(entity);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* implementation of queuing_rule_spec.h */
+
+EXPORT_API sync_agent_ec_queuing_rule_spec_s *sync_agent_create_queuing_rule_spec_outline(sync_agent_ec_char * queuing_rule_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(queuing_rule_name == NULL, NULL, "sync_agent_ec_char is NULL !!");
+
+       sync_agent_ec_queuing_rule_spec_s *rule = (sync_agent_ec_queuing_rule_spec_s *) calloc(1, sizeof(sync_agent_ec_queuing_rule_spec_s));
+       if (rule == NULL) {
+               goto error_part;
+       }
+
+       rule->ref_count = 1;
+       rule->name = strdup(queuing_rule_name);
+       if (rule->name == NULL) {
+               goto error_part;
+       }
+
+       rule->total_progress_blocking_element_cnt = 0;
+       rule->progress_blocking_entity_list = NULL;
+
+       rule->progress_blocking_queue = g_queue_new();
+       if (rule->progress_blocking_queue == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return rule;
+
+ error_part:
+       _queuing_rule_spec_free_queuing_rule_spec(rule);
+       return NULL;
+}
+
+/* TODO : better performance expected if validation & check duplication & add new queuing element are done by one scanning */
+EXPORT_API sync_agent_ec_error_e sync_agent_add_progress_blocking_element(sync_agent_ec_queuing_rule_spec_s * rule, sync_agent_ec_uint root_task_spec_id, sync_agent_ec_task_spec_s * root_task_spec, sync_agent_ec_uint child_depth, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* sync_agent_ec_boolean is_dynamic, sync_agent_ec_int dynamic_case, sync_agent_ec_int child_index */
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+       sync_agent_ec_boolean new_entity = false;
+
+       va_list ap;
+       va_start(ap, child_depth);
+
+       /* check validity of child path */
+       if (!_queuing_rule_spec_is_valid_child_path(root_task_spec, child_depth, ap)) {
+               ec_error = SYNC_AGENT_EC_INVALID_CHILD_PATH;
+               va_end(ap);
+
+               goto return_part;
+       }
+
+       va_end(ap);
+       va_start(ap, child_depth);
+
+       /* find progress blocking entity */
+       ec_progress_blocking_entity_t *entity = _queuing_rule_spec_get_progress_blocking_entity(rule, root_task_spec_id);
+       if (entity == NULL) {
+               entity = ec_progress_blocking_entity_new(root_task_spec_id, rule);
+               if (entity == NULL) {
+                       ec_error = SYNC_AGENT_EC_OUT_OF_MEMORY;
+                       va_end(ap);
+                       goto return_part;
+               } else {
+                       new_entity = true;
+               }
+       }
+
+       /* add_child_path to blocking entity */
+       ec_error = ec_progress_blocking_element_add(entity->element_set, child_depth, ap);
+       if (ec_error != SYNC_AGENT_EC_OK) {
+               va_end(ap);
+               goto return_part;
+       }
+
+       va_end(ap);
+
+       if (new_entity) {
+               rule->total_progress_blocking_element_cnt++;
+               rule->progress_blocking_entity_list = g_slist_prepend(rule->progress_blocking_entity_list, entity);
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+
+/*
+error_part:
+       if (new_entity) {
+               ec_progress_blocking_entity_unref(entity);
+       }
+       return ec_error;
+*/
+}
+
+sync_agent_ec_queuing_rule_spec_s *ec_ref_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * rule)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(rule != NULL, "error. rule == NULL\n");
+
+       g_atomic_int_inc(&(rule->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return rule;
+}
+
+EXPORT_API void sync_agent_unref_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * rule)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (rule == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_get(&(rule->ref_count)) <= 0) {
+               _DEBUG_ERROR("ref count <= 0\n");
+       }
+
+       if (g_atomic_int_dec_and_test(&(rule->ref_count))) {
+               _queuing_rule_spec_free_queuing_rule_spec(rule);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/queuing_rule_spec_internal.h b/src/framework/engine-controller/queuing_rule_spec_internal.h
new file mode 100755 (executable)
index 0000000..321b846
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QUEUING_RULE_SPEC_INTERNAL_H_
+#define QUEUING_RULE_SPEC_INTERNAL_H_
+
+#include <stdarg.h>
+#include "engine-controller/queuing_rule_spec.h"
+
+/**
+ * @file queuing_rule_spec_internal.h
+ * @brief Manupulates progress blocking entity which internally has n-ary tree node containing progress blocking element instances
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Type define of struct n_ary_tree_node_with_flag_s
+ */
+typedef struct n_ary_tree_node_with_flag_s ec_n_ary_tree_node_with_flag_t;
+/**
+ * @brief Structure of n-ary tree node instance used for queuing order
+ */
+struct n_ary_tree_node_with_flag_s {
+       sync_agent_ec_boolean blocking_flag;            /** flag indicating if blocked */
+       sync_agent_ec_uint tree_level;  /** depth of current node */
+       sync_agent_ec_boolean is_dynamic_child; /** flag indicating if child is 'dynamic' type of task */
+       sync_agent_ec_int dynamic_case; /** if it is dynamic case */
+       sync_agent_ec_uint child_index; /** number of child node */
+       ec_n_ary_tree_node_with_flag_t *parent_node;    /** pointer to parent node */
+       ec_n_ary_tree_node_with_flag_t *first_child_node;       /** pointer to first child node */
+       ec_n_ary_tree_node_with_flag_t *next_sibling_node;      /** pointer to next sibling node */
+       ec_n_ary_tree_node_with_flag_t *prev_sibling_node;      /** pointer to previous sibling node */
+};
+
+/**
+* @brief Allocates and returns newly initialized ec_n_ary_tree_node_with_flag_t type of tree node
+* @param[in] blocking_flag 
+* @param[in] tree_level depth of new tree node
+* @param[in] is_dynamic_child if node is dynamic child
+* @param[in] dynamic_case number of dynamic case
+* @param[in] child_index index of child
+* @return ec_n_ary_tree_node_with_flag_t type of tree node on success, otherwise error value
+*/
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_new(sync_agent_ec_boolean blocking_flag, sync_agent_ec_uint tree_level, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case, sync_agent_ec_uint child_index);
+
+/**
+* @brief Frees ec_n_ary_tree_node_with_flag_t type of given tree node without its members
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node
+*/
+void ec_n_ary_tree_node_with_flag_free_1(ec_n_ary_tree_node_with_flag_t * node);
+/**
+* @brief Frees ec_n_ary_tree_node_with_flag_t type of given tree node with its members
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node
+*/
+void ec_n_ary_tree_node_with_flag_free_subtree(ec_n_ary_tree_node_with_flag_t * node);
+
+/**
+* @brief Returns count of ec_n_ary_tree_node_with_flag_t type of node with blocking flag on
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node to get count of flag on
+* @return number of node with blocking flag on
+*/
+sync_agent_ec_uint ec_n_ary_tree_node_with_flag_count_subtree_flag_on_number(ec_n_ary_tree_node_with_flag_t * node);
+
+/**
+* @brief Sets blocking flag on in specified ec_n_ary_tree_node_with_flag_t type of node
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node to set blocking count on
+*/
+void ec_n_ary_tree_node_with_flag_set_blocking_flag_on(ec_n_ary_tree_node_with_flag_t * node);
+/**
+* @brief Checks of blocking count is on in specified ec_n_ary_tree_node_with_flag_t type of node
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node to get count of flag on
+* @return true if blocking flag is on, false if not
+*/
+sync_agent_ec_boolean ec_n_ary_tree_node_with_flag_is_blocking_flag_on(ec_n_ary_tree_node_with_flag_t * node);
+
+/**
+* @brief Checks if specified ec_n_ary_tree_node_with_flag_t type of node has given contents
+* @param[in] node ec_n_ary_tree_node_with_flag_t type of tree node to get count of flag on
+* @param[in] tree_level value of tree_level member to compare
+* @param[in] is_dynamic_child value of is_dynamic_child member to compare
+* @param[in] dynamic_case value of dynamic_case member to compare
+* @param[in] child_index value of child_index member to compare
+* @return true if identical, false if not
+*/
+sync_agent_ec_boolean ec_n_ary_tree_node_with_flag_has_same_content_without_blocking_flag(ec_n_ary_tree_node_with_flag_t * node, sync_agent_ec_uint tree_level, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case,
+                                                                                         sync_agent_ec_uint child_index);
+
+/**
+* @brief Creates and links child node to given ec_n_ary_tree_node_with_flag_t type of parent node
+* @param[in] parent_node ec_n_ary_tree_node_with_flag_t type of parent tree node
+* @param[in] blocking_flag blocking flag setting
+* @param[in] is_dynamic_child if node is dynamic child
+* @param[in] dynamic_case number of dynamic case
+* @param[in] child_index index of child
+* @return added ec_n_ary_tree_node_with_flag_t type of tree node on success, otherwise error value
+*/
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_add_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, sync_agent_ec_boolean blocking_flag, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case,
+                                                                           sync_agent_ec_uint child_index);
+
+/**
+* @brief Links child node to given ec_n_ary_tree_node_with_flag_t type of parent node
+* @param[in] parent_node ec_n_ary_tree_node_with_flag_t type of parent tree node
+* @param[in] child_node reference to ec_n_ary_tree_node_with_flag_t type of child node to add
+*/
+void ec_n_ary_tree_node_with_flag_link_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, ec_n_ary_tree_node_with_flag_t * child_node);
+
+/**
+* @brief Unlinks child node from given ec_n_ary_tree_node_with_flag_t type of parent node
+* @param[in] parent_node ec_n_ary_tree_node_with_flag_t type of parent tree node
+* @param[in] child_node reference to ec_n_ary_tree_node_with_flag_t type of child node to delete
+*/
+void ec_n_ary_tree_node_with_flag_unlink_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, ec_n_ary_tree_node_with_flag_t * child_node);
+
+/**
+* @brief Fetches child node from given ec_n_ary_tree_node_with_flag_t type of node
+* @param[in] parent_node ec_n_ary_tree_node_with_flag_t type of parent tree node
+* @param[in] is_dynamic_child if node is dynamic child
+* @param[in] dynamic_case number of dynamic case
+* @param[in] child_index index of child to get
+* @return ec_n_ary_tree_node_with_flag_t type of tree node on success, otherwise error value
+*/
+ec_n_ary_tree_node_with_flag_t *ec_n_ary_tree_node_with_flag_get_child_node(ec_n_ary_tree_node_with_flag_t * parent_node, sync_agent_ec_boolean is_dynamic_child, sync_agent_ec_int dynamic_case, sync_agent_ec_uint child_index);
+
+/**
+ * @brief Type define of struct progress_blocking_element_set_s
+ */
+typedef struct progress_blocking_element_set_s ec_progress_blocking_element_set_t;
+/**
+ * @brief Structure of progress blocking element set
+ */
+struct progress_blocking_element_set_s {
+       sync_agent_ec_uint progress_blocking_element_cnt;       /** number of progress blocking elements */
+       ec_n_ary_tree_node_with_flag_t *n_ary_tree_with_flag;   /** n-ary tree structure containing progress blocking element properties  */
+};
+
+/**
+* @brief Allocates and returns progress blocking element set instance initialized
+* @return ec_progress_blocking_element_set_t type of progress blocking element set instance on success, otherwise NULL
+*/
+ec_progress_blocking_element_set_t *ec_progress_blocking_element_set_new();
+/**
+* @brief Frees progress blocking element set instance specified
+* @param[in] set progress blocking element set to free
+*/
+void ec_progress_blocking_element_set_free(ec_progress_blocking_element_set_t * set);
+/**
+* @brief Adds progress blocking element to specified progress blocking element set
+* @param[in] set progress blocking element set to add to
+* @param[in] depth depth of progress blocking element to add
+* @param[in] ap 'depth' number of set of bool is_dynamic_child, sync_agent_ec_int dynamic_case, sync_agent_ec_int child_index
+* @return SYNC_AGENT_EC_OK on success, otherwise error value
+*/
+sync_agent_ec_error_e ec_progress_blocking_element_add(ec_progress_blocking_element_set_t * set, sync_agent_ec_uint depth, va_list ap);
+
+/**
+ * @brief Type define of struct progress_blocking_entity_s
+ */
+typedef struct progress_blocking_entity_s ec_progress_blocking_entity_t;
+/**
+ * @brief Structure of progress blocking entity
+ */
+struct progress_blocking_entity_s {
+       sync_agent_ec_int ref_count;    /** reference count of progress blocking entity instance */
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule_spec;   /** reference of queuing rule spec connected to */
+       sync_agent_ec_uint root_task_spec_id;   /** id of root task spec */
+       ec_progress_blocking_element_set_t *element_set;        /** progress blocking element set */
+};
+
+/**
+* @brief Allocates and returns progress blocking entity instance initialized
+* @param[in] root_task_spec_id spec id of root task related to this progress blocking entity
+* @param[in] queuing_rule_spec reference to queuing rule spec related to this progress blocking entity
+* @return ec_progress_blocking_entity_t type of progress blocking entity instance on success, otherwise NULL
+*/
+ec_progress_blocking_entity_t *ec_progress_blocking_entity_new(sync_agent_ec_uint root_task_spec_id, sync_agent_ec_queuing_rule_spec_s * queuing_rule_spec);
+/**
+* @brief Frees progress blocking entity instance specified
+* @param[in] entity progress blocking entity to free
+*/
+void ec_progress_blocking_entity_free(ec_progress_blocking_entity_t * entity);
+/**
+* @brief Increases reference count of given progress blocking entity instance
+* @param[in] entity progress blocking entity to increase reference count
+* @return ec_progress_blocking_entity_t type of progress blocking entity instance on success, otherwise NULL
+*/
+ec_progress_blocking_entity_t *ec_progress_blocking_entity_ref(ec_progress_blocking_entity_t * entity);
+/**
+* @brief Decreases reference count of given progress blocking entity instance
+* @param[in] entity progress blocking entity to decrease reference count
+*/
+void ec_progress_blocking_entity_unref(ec_progress_blocking_entity_t * entity);
+
+/**
+ * @brief Structure of queuing rule spec instance
+ */
+struct engine_controller_queuing_rule_spec {
+       sync_agent_ec_int ref_count;    /** referecen count for this queuing rule spec instance */
+       sync_agent_ec_uint id;          /** id of queuing rule spec */
+       sync_agent_ec_char *name;               /** name of queuing rule spec */
+       sync_agent_ec_uint total_progress_blocking_element_cnt; /** number of progres blocking elements in the list below */
+       GSList *progress_blocking_entity_list;  /** list of ec_progress_blocking_entity_t type of pointer */
+       GQueue *progress_blocking_queue;                /** queue of progress blocking elements in order */
+};
+
+/**
+* @brief Increases reference count of queuing rule spec
+* @param[in] rule pointer of queuing rule spec to increase ref count
+* @return Pointer of queuing rule spec itself on success, otherwise NULL
+*/
+sync_agent_ec_queuing_rule_spec_s *ec_ref_queuing_rule_spec(sync_agent_ec_queuing_rule_spec_s * rule);
+
+/**
+ *     @}
+ */
+
+#endif                         /* QUEUING_RULE_SPEC_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/queuing_rule_spec_pool.c b/src/framework/engine-controller/queuing_rule_spec_pool.c
new file mode 100755 (executable)
index 0000000..23bfd75
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include "utility/sync_util.h"
+#include "engine-controller/queuing_rule_spec_pool.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+ec_queuing_rule_spec_pool_t *ec_queuing_rule_spec_pool_alloc(sync_agent_ec_uint queuing_rule_max_cnt, ec_task_info_pool_t * task_info_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_info_pool == NULL, NULL, "ec_task_info_pool_t is NULL !!");
+
+       ec_queuing_rule_spec_pool_t *pool = NULL;
+       if (queuing_rule_max_cnt == 0) {
+               goto error_part;
+       }
+
+       pool = (ec_queuing_rule_spec_pool_t *) calloc(1, sizeof(ec_queuing_rule_spec_pool_t));
+       if (pool == NULL) {
+               goto return_part;
+       }
+
+       pool->id_provider = util_create_id_provider(queuing_rule_max_cnt - 1, 12, false);
+       if (pool->id_provider == NULL) {
+               goto error_part;
+       }
+
+       pool->queuing_rule_spec_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) sync_agent_unref_queuing_rule_spec);
+       if (pool->queuing_rule_spec_hash == NULL) {
+               goto error_part;
+       }
+
+       pool->task_info_pool = task_info_pool;
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return pool;
+
+ error_part:
+       ec_queuing_rule_spec_pool_free(pool);
+       return NULL;
+}
+
+void ec_queuing_rule_spec_pool_free(ec_queuing_rule_spec_pool_t * pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pool != NULL) {
+               if (pool->id_provider != NULL) {
+                       util_destroy_id_provider(pool->id_provider);
+                       pool->id_provider = NULL;
+               }
+               if (pool->queuing_rule_spec_hash != NULL) {
+                       g_hash_table_destroy(pool->queuing_rule_spec_hash);
+                       pool->queuing_rule_spec_hash = NULL;
+               }
+               if (pool->task_info_pool != NULL) {
+                       ec_task_info_pool_free(pool->task_info_pool);
+                       pool->task_info_pool = NULL;
+               }
+               free(pool);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_error_e ec_queuing_rule_spec_pool_add_queuing_rule_spec(ec_queuing_rule_spec_pool_t * pool, sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_ec_uint * queuing_rule_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pool == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_queuing_rule_spec_pool_t is NULL !!");
+       retvm_if(spec == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "sync_agent_ec_queuing_rule_spec_s is NULL !!");
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       ec_task_info_pool_t *task_info_pool = pool->task_info_pool;
+
+       /* generate id */
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       sync_agent_ec_uint new_id = 0;
+
+       id_error = util_provide_id(pool->id_provider, &new_id);
+       if (id_error != UTIL_ID_PROVIDER_OK) {
+               if (id_error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID) {
+                       ec_error = SYNC_AGENT_EC_OUT_OF_FREE_ID;
+               } else {
+                       ec_error = SYNC_AGENT_EC_UNKNOWN_ERROR;
+               }
+               goto error_part;
+       }
+
+       /* TODO : error handling */
+
+       /* add queuing_rule_spec info to each task_specs */
+       ec_progress_blocking_entity_t *entity = NULL;
+       ec_task_info_t *task_info = NULL;
+       GSList *iter = NULL;
+       for (iter = spec->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+               entity = (ec_progress_blocking_entity_t *) (iter->data);
+
+               task_info = ec_task_info_pool_search_task_info(task_info_pool, entity->root_task_spec_id);
+               ec_error = ec_task_info_add_progress_blocking_entity(task_info, entity);
+               if (ec_error != SYNC_AGENT_EC_OK) {
+                       /* undo */
+                       GSList *iter2 = NULL;
+                       ec_progress_blocking_entity_t *pEntity2 = NULL;
+                       for (iter2 = spec->progress_blocking_entity_list; iter2 != iter; iter2 = g_slist_next(iter2)) {
+                               pEntity2 = (ec_progress_blocking_entity_t *) (iter2->data);
+                               ec_task_info_remove_blocking_entity(task_info, pEntity2);
+                       }
+
+                       assert(UTIL_ID_PROVIDER_OK == util_delete_id(pool->id_provider, new_id));
+                       goto error_part;
+               }
+       }
+
+       g_hash_table_insert(pool->queuing_rule_spec_hash, (gpointer) new_id, spec);
+
+       *queuing_rule_id = new_id;
+
+ error_part:
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+}
+
+sync_agent_ec_queuing_rule_spec_s *ec_queueing_rule_spec_pool_search_queuing_rule_spec(ec_queuing_rule_spec_pool_t * pool, sync_agent_ec_uint queuing_rule_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pool == NULL, NULL, "ec_queuing_rule_spec_pool_t is NULL !!");
+
+       sync_agent_ec_queuing_rule_spec_s *queuing_rule_spec = g_hash_table_lookup(pool->queuing_rule_spec_hash, (gconstpointer) queuing_rule_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return queuing_rule_spec;
+}
diff --git a/src/framework/engine-controller/queuing_rule_spec_pool.h b/src/framework/engine-controller/queuing_rule_spec_pool.h
new file mode 100755 (executable)
index 0000000..e6bc66b
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef QUEUING_RULE_SPEC_POOL_H_
+#define QUEUING_RULE_SPEC_POOL_H_
+
+#include <glib.h>
+#include "engine-controller/fundamental_type.h"
+#include "engine-controller/define.h"
+#include "engine-controller/queuing_rule_spec.h"
+#include "engine-controller/task_info_pool.h"
+#include "utility/fw_sequential_id_provider.h"
+
+/**
+ * @file queuing_rule_spec_pool.h
+ * @brief Manupulates queuing rule spec pool
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Type define of struct ec_queuing_rule_spec_pool_s
+ */
+typedef struct ec_queuing_rule_spec_pool_s ec_queuing_rule_spec_pool_t;
+/**
+ * @brief Structure of queuing rule spec pool instance
+ */
+struct ec_queuing_rule_spec_pool_s {
+       util_id_provider_s *id_provider;                /** unique id provider instance assigned to pool */
+       GHashTable *queuing_rule_spec_hash;             /** spec hash table, key: queuing_rule_spec_id, value: sync_agent_ec_queuing_rule_spec_s* */
+       ec_task_info_pool_t *task_info_pool;    /** task info pool related to queuing rule, when register queuing_rule_spec to pool we have to update task_info */
+};
+
+/**
+* @brief Allocates queuing rule spec pool instance
+* @param[in] queuing_rule_max_cnt 
+* @param[in] task_info_pool 
+* @return ec_queuing_rule_spec_pool_t type of queuing rule spec pool instance on sucess, otherwise NULL
+*/
+ec_queuing_rule_spec_pool_t *ec_queuing_rule_spec_pool_alloc(sync_agent_ec_uint queuing_rule_max_cnt, ec_task_info_pool_t * task_info_pool);
+
+/**
+* @brief Frees queuing rule spec pool instance
+* @param[in] pool 
+*/
+void ec_queuing_rule_spec_pool_free(ec_queuing_rule_spec_pool_t * pool);
+
+/**
+* @brief Add a queuing rule spec to specified queuing rule spec pool
+* @param[in] pool queuing rule spec pool to add to
+* @param[in] spec queuing rule spec to add
+* @param[out] queuing_rule_id issued id of the queuing rule spec adde to pool
+* @return SYNC_AGENT_EC_OK on success, otherwise error value
+*/
+sync_agent_ec_error_e ec_queuing_rule_spec_pool_add_queuing_rule_spec(ec_queuing_rule_spec_pool_t * pool, sync_agent_ec_queuing_rule_spec_s * spec, sync_agent_ec_uint * queuing_rule_id);
+
+/**
+* @brief Searches queuing rule spec from specified queuing rule spec pool
+* @param[in] pool queuing rule spec pool to search queuing rule spec from
+* @param[in] queuing_rule_id id of queuing rule spec desired to search
+* @return sync_agent_ec_queuing_rule_spec_s type of queuing rule spec on success, otherwise NULL
+*/
+sync_agent_ec_queuing_rule_spec_s *ec_queueing_rule_spec_pool_search_queuing_rule_spec(ec_queuing_rule_spec_pool_t * pool, sync_agent_ec_uint queuing_rule_id);
+
+/**
+* @brief Deletes queuing rule spec from specified queuing rule spec pool
+* @param[in] pool queuing rule spec pool to delete queuing rule spec from
+* @param[in] queuing_rule_id id of queuing rule spec desired to delete
+* @return SYNC_AGENT_EC_OK on success, otherwise error value
+*/
+sync_agent_ec_error_e ec_queuing_rule_spec_pool_remove_queuing_rule_spec(ec_queuing_rule_spec_pool_t * pool, sync_agent_ec_uint queuing_rule_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* QUEUING_RULE_SPEC_POOL_H_ */
diff --git a/src/framework/engine-controller/task.c b/src/framework/engine-controller/task.c
new file mode 100755 (executable)
index 0000000..6ca75ed
--- /dev/null
@@ -0,0 +1,1207 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "utility/fw_ref.h"
+#include "utility/fw_assert.h"
+#include "utility/sync_util.h"
+#include "engine-controller/internal.h"
+#include "engine-controller/task.h"
+#include "engine-controller/task_spec_internal.h"
+#include "engine-controller/param_spec_internal.h"
+#include "engine-controller/param_value_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+static sync_agent_ec_param_param_s *_task_fetch_from_param(ec_task_t * parent_task, sync_agent_ec_int to_child_task_index, sync_agent_ec_int to_param_index);
+static void _task_free_task(ec_task_t * task);
+
+static sync_agent_ec_param_param_s *_task_fetch_from_param(ec_task_t * parent_task, sync_agent_ec_int to_child_task_index, sync_agent_ec_int to_param_index)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(parent_task == NULL, NULL, "ec_task_t is NULL !!");
+
+       sync_agent_ec_param_param_s *fetched_param = NULL;
+       sync_agent_ec_task_spec_s *parent_task_spec = parent_task->task_spec;
+       ec_child_tasks_info_t *child_task_info = NULL;
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_child_tasks_info(parent_task_spec);
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_case_specific_child_tasks_info(parent_task_spec, parent_task->dynamic_case);
+       } else {
+               assert(false);
+       }
+
+       ec_data_flow_edges_t *data_flow_edges;
+
+       if (child_task_info != NULL) {
+               data_flow_edges = child_task_info->data_flow_edges;
+       } else {
+               goto error_part;
+       }
+
+       sync_agent_ec_int from_task_index = 0;
+       sync_agent_ec_int from_param_index = 0;
+       sync_agent_ec_boolean find_success = ec_data_flow_edges_get_from_param_info(data_flow_edges,
+                                                                                   to_child_task_index, to_param_index,
+                                                                                   &from_task_index, &from_param_index);
+       if (find_success) {
+               if (from_task_index == -1) {
+                       /* get from parent_task */
+                       fetched_param = parent_task->param_array[from_param_index];
+               } else {
+                       /* validation from_task_index */
+                       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+                       if (ec_task_spec_is_container(parent_task_spec)) {
+                               ec_error = ec_task_spec_valididate_child_task_index(parent_task_spec, from_task_index);
+                       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+                               ec_error = ec_task_spec_valididate_child_task_index_on_dynamic_case(parent_task->dynamic_case, parent_task_spec, from_task_index);
+                       }
+                       if (ec_error != SYNC_AGENT_EC_OK) {
+                               goto error_part;
+                       }
+
+                       /* get from child task */
+                       ec_task_t *child_task = parent_task->child_task_array[from_task_index];
+                       fetched_param = child_task->param_array[from_param_index];
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return fetched_param;
+
+ error_part:
+       return NULL;
+}
+
+/* TODO : handling error case */
+GSList *ec_task_construct_progress_blocking_realized_entity_list(ec_task_info_t * task_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *progress_blocking_realized_entity_list = NULL;
+
+       /* add progress blocking entity according to queuing rule */
+       GSList *iter = NULL;
+       ec_progress_blocking_entity_t *entity = NULL;
+       ec_progress_blocking_realized_entity_t *realized_entity = NULL;
+       for (iter = task_info->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+               entity = (ec_progress_blocking_entity_t *) (iter->data);
+
+               realized_entity = ec_progress_blocking_realized_entity_new(entity);
+
+               progress_blocking_realized_entity_list = g_slist_prepend(progress_blocking_realized_entity_list, realized_entity);
+
+               /* create progress_queuing_entity */
+               g_queue_push_tail(entity->queuing_rule_spec->progress_blocking_queue, realized_entity);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return progress_blocking_realized_entity_list;
+}
+
+/* TODO : handling error case */
+GSList *ec_task_construct_current_node_in_progress_blocking_entity_list(ec_task_info_t * task_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *current_node_in_progress_blocking_entity_list = NULL;
+
+       /* add progress blocking entity according to queuing rule */
+       GSList *iter = NULL;
+       ec_progress_blocking_entity_t *entity = NULL;
+       for (iter = task_info->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+               entity = (ec_progress_blocking_entity_t *) (iter->data);
+
+               current_node_in_progress_blocking_entity_list = g_slist_prepend(current_node_in_progress_blocking_entity_list, entity->element_set->n_ary_tree_with_flag);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return current_node_in_progress_blocking_entity_list;
+}
+
+GSList *ec_task_construct_current_node_in_progress_blocking_entity_list_from_parent_task(ec_task_t * parent_task, sync_agent_ec_int child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *current_node_in_progress_blocking_entity_list = NULL;
+
+       /* add progress blocking entity according to queuing rule */
+       GSList *iter = NULL;
+       ec_n_ary_tree_node_with_flag_t *parent_tree_node = NULL;
+       ec_n_ary_tree_node_with_flag_t *child_tree_node = NULL;
+       for (iter = parent_task->current_node_in_progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+               parent_tree_node = (ec_n_ary_tree_node_with_flag_t *) (iter->data);
+               if (parent_tree_node == NULL) {
+                       child_tree_node = NULL;
+               } else {
+                       child_tree_node = ec_n_ary_tree_node_with_flag_get_child_node(parent_tree_node, ec_task_spec_is_dynamic_container(parent_task->task_spec), parent_task->dynamic_case, child_index);
+                       /* note that child_tree_node could be NULL */
+               }
+
+               current_node_in_progress_blocking_entity_list = g_slist_prepend(current_node_in_progress_blocking_entity_list, child_tree_node);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return current_node_in_progress_blocking_entity_list;
+}
+
+ec_task_t *ec_task_alloc_root_task(sync_agent_ec_task_spec_s * task_spec, ec_request_msg_t * request_msg, ec_task_info_pool_t * task_info_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_t *task = NULL;
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_uint child_task_cnt = 0;
+
+       if (task_spec == NULL) {
+               _DEBUG_INFO("input task is NULL");
+               goto error_part;
+       }
+
+       task = (ec_task_t *) calloc(1, sizeof(ec_task_t));
+       if (task == NULL) {
+               goto error_part;
+       }
+
+       task->ref_count = 1;
+       task->task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+
+       task->task_info = ec_task_info_pool_search_task_info(task_info_pool, request_msg->task_spec_id);
+
+       task->progress_blocking_realized_entity_list = ec_task_construct_progress_blocking_realized_entity_list(task->task_info);
+
+       task->current_node_in_progress_blocking_entity_list = ec_task_construct_current_node_in_progress_blocking_entity_list(task->task_info);
+
+       task->parent_task = NULL;
+       task->child_task_index_in_parent_task = 0;      /* meaningless value */
+
+       task->param_array = (sync_agent_ec_param_param_s **) calloc(task_spec->task_param_cnt, sizeof(sync_agent_ec_param_param_s *));
+       if (task->param_array == NULL) {
+               goto error_part;
+       }
+
+       /* set parameter values in param_array */
+       int index = 0;
+       for (i = 0; i < request_msg->cnt_in_param; i++) {
+               index = request_msg->in_param_index_array[i];
+               task->param_array[index] = ec_alloc_param(1, 1, /* TODO : set ref count */
+                                                         task_spec->task_param_spec_array[index], &(request_msg->in_param_value_array[i]));
+       }
+
+       /* set output parameter values */
+       for (i = 0; i < task_spec->task_param_cnt; i++) {
+               if (task->param_array[i] == NULL) {
+                       task->param_array[i] = ec_alloc_param(1, 1,     /* TODO : set ref count */
+                                                             task_spec->task_param_spec_array[i], NULL);
+               }
+       }
+
+       if (ec_task_spec_is_container(task_spec)) {
+               child_task_cnt = ec_task_spec_get_child_task_cnt(task_spec);
+       } else if (ec_task_spec_is_dynamic_container(task_spec)) {
+               /* compute case */
+               sync_agent_calculate_case_cb calculate_case_func = ec_task_spec_get_calculate_case_callback_func(task_spec);
+               if (calculate_case_func == NULL) {
+                       _DEBUG_ERROR("sync_agent_calculate_case_cb is NULL !!");
+                       goto error_part;
+               }
+
+               task->dynamic_case = calculate_case_func(task_spec->task_param_cnt, task->param_array);
+
+               child_task_cnt = ec_task_spec_get_child_task_cnt_on_dynamic_case(task_spec, task->dynamic_case);
+       }
+
+       if (child_task_cnt > 0) {
+               task->child_task_array = (ec_task_t **) calloc(child_task_cnt, sizeof(ec_task_t *));
+               if (task->child_task_array == NULL) {
+                       goto error_part;
+               }
+       }
+
+       ec_task_set_left_child_to_run(task, child_task_cnt);
+
+       if (ec_task_spec_is_container(task_spec)) {
+               /* copy child_task_control_flow_in_degree */
+               task->current_child_task_control_flow_in_degree_array = ec_task_spec_duplicate_child_task_control_flow_in_degree(task_spec);
+               if (task->current_child_task_control_flow_in_degree_array == NULL) {
+                       goto error_part;
+               }
+       } else if (ec_task_spec_is_dynamic_container(task_spec)) {
+               task->current_child_task_control_flow_in_degree_array = ec_task_spec_duplicate_child_task_control_flow_in_degree_on_dynamic_case(task_spec, task->dynamic_case);
+               if (task->current_child_task_control_flow_in_degree_array == NULL) {
+                       goto error_part;
+               }
+       } else {
+               task->current_child_task_control_flow_in_degree_array = NULL;
+       }
+
+       task->task_spec = ec_task_spec_ref(task_spec);
+       sync_agent_util_ref_object_s *pRequest_Msg_ref = sync_agent_create_referenced_object(request_msg, NULL);        /* TODO : free fucntion */
+       if (pRequest_Msg_ref == NULL) {
+               goto error_part;
+       }
+       task->request_msg = pRequest_Msg_ref;
+
+       task->cancel_information = ec_task_cancel_info_init(pRequest_Msg_ref);
+       if (task->cancel_information == NULL) {
+               goto error_part;
+       }
+
+       if (-1 == gettimeofday(&(task->create_time), NULL)) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task;
+
+ error_part:
+       _task_free_task(task);
+       return NULL;
+}
+
+ec_task_t *ec_task_alloc_child_task(ec_task_t * parent_task, sync_agent_ec_int child_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_task == NULL, NULL, "ec_task_t is NULL !!");
+
+       ec_task_t *child_task = NULL;
+       sync_agent_ec_task_spec_s *parent_task_spec = parent_task->task_spec;
+       ec_child_tasks_info_t *child_tasks_info = NULL;
+
+       /* validation & get child_task_info */
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               sync_agent_ec_error_e ec_error = ec_task_spec_valididate_child_task_index(parent_task_spec, child_index);
+               if (ec_error != SYNC_AGENT_EC_OK) {
+                       _DEBUG_ERROR("invalid child index, child_index = %d\n", child_index);
+                       goto error_part;
+               }
+
+               child_tasks_info = ec_task_spec_find_child_tasks_info(parent_task_spec);
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               sync_agent_ec_error_e ec_error = ec_task_spec_valididate_child_task_index_on_dynamic_case(parent_task->dynamic_case, parent_task_spec, child_index);
+               if (ec_error != SYNC_AGENT_EC_OK) {
+                       _DEBUG_ERROR("invalid child index, child_index = %d\n", child_index);
+                       goto error_part;
+               }
+
+               child_tasks_info = ec_task_spec_find_case_specific_child_tasks_info(parent_task_spec, parent_task->dynamic_case);
+       }
+
+       sync_agent_ec_task_spec_s *child_task_spec;
+
+       if (child_tasks_info != NULL) {
+               child_task_spec = child_tasks_info->child_task_array[child_index];
+       } else {
+               goto error_part;
+       }
+
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_uint grand_child_task_cnt = 0;
+
+       child_task = (ec_task_t *) calloc(1, sizeof(ec_task_t));
+       if (child_task == NULL) {
+               goto error_part;
+       }
+
+       child_task->ref_count = 1;
+       child_task->task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+       child_task->parent_task = parent_task;
+       child_task->child_task_index_in_parent_task = child_index;
+
+       child_task->progress_blocking_realized_entity_list = parent_task->progress_blocking_realized_entity_list;
+       child_task->current_node_in_progress_blocking_entity_list = ec_task_construct_current_node_in_progress_blocking_entity_list_from_parent_task(parent_task, child_index);
+
+       child_task->param_array = (sync_agent_ec_param_param_s **) calloc(child_task_spec->task_param_cnt, sizeof(sync_agent_ec_param_param_s *));
+       if (child_task->param_array == NULL) {
+               goto error_part;
+       }
+
+       /* set parameter values */
+       for (i = 0; i < child_task_spec->task_param_cnt; i++) {
+               sync_agent_ec_param_param_s *from_param = _task_fetch_from_param(parent_task, child_index, i);
+               child_task->param_array[i] = ec_alloc_param(1, 1,       /* TODO : set ref count */
+                                                           child_task_spec->task_param_spec_array[i], from_param != NULL ? &(from_param->param_value) : NULL);
+       }
+
+       if (ec_task_spec_is_container(child_task_spec)) {
+               grand_child_task_cnt = ec_task_spec_get_child_task_cnt(child_task_spec);
+       } else if (ec_task_spec_is_dynamic_container(child_task_spec)) {
+               /* compute dynamic case */
+               sync_agent_calculate_case_cb calculate_case_func = ec_task_spec_get_calculate_case_callback_func(child_task_spec);
+               if (calculate_case_func == NULL) {
+                       _DEBUG_ERROR("sync_agent_calculate_case_cb is NULL !!");
+                       goto error_part;
+               }
+               child_task->dynamic_case = calculate_case_func(child_task_spec->task_param_cnt, child_task->param_array);
+
+               grand_child_task_cnt = ec_task_spec_get_child_task_cnt_on_dynamic_case(child_task_spec, child_task->dynamic_case);
+       }
+       child_task->child_task_array = (ec_task_t **) calloc(grand_child_task_cnt, sizeof(ec_task_t *));
+       if (child_task->child_task_array == NULL) {
+               goto error_part;
+       }
+
+       ec_task_set_left_child_to_run(child_task, grand_child_task_cnt);
+
+       if (ec_task_spec_is_container(child_task_spec)) {
+               /* copy child_task_control_flow_in_degree */
+               child_task->current_child_task_control_flow_in_degree_array = ec_task_spec_duplicate_child_task_control_flow_in_degree(child_task_spec);
+               if (child_task->current_child_task_control_flow_in_degree_array == NULL) {
+                       goto error_part;
+               }
+       } else if (ec_task_spec_is_dynamic_container(child_task_spec)) {
+               child_task->current_child_task_control_flow_in_degree_array = ec_task_spec_duplicate_child_task_control_flow_in_degree_on_dynamic_case(child_task_spec, child_task->dynamic_case);
+               if (child_task->current_child_task_control_flow_in_degree_array == NULL) {
+                       goto error_part;
+               }
+       } else {
+               child_task->current_child_task_control_flow_in_degree_array = NULL;
+       }
+
+       child_task->task_info = ec_task_info_ref(parent_task->task_info);
+       child_task->task_spec = ec_task_spec_ref(child_task_spec);
+       child_task->request_msg = sync_agent_get_referenced_object(parent_task->request_msg);
+       child_task->cancel_information = ec_task_cancel_info_ref(parent_task->cancel_information);
+
+       if (-1 == gettimeofday(&(child_task->create_time), NULL)) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_task;
+
+ error_part:
+
+       if (child_task != NULL) {
+               _task_free_task(child_task);
+       }
+       return NULL;
+}
+
+static void _task_free_task(ec_task_t * task)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("called\n");
+       if (task != NULL) {
+               /* TODO */
+
+               ec_task_cancel_info_unref(task->cancel_information);
+               free(task);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+ec_task_t *ec_task_ref_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(task != NULL, "error. task == NULL\n");
+
+       g_atomic_int_inc(&(task->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return task;
+}
+
+void ec_task_unref_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_get(&(task->ref_count)) <= 0) {
+               _DEBUG_ERROR("ref count <= 0\n");
+       }
+
+       if (g_atomic_int_dec_and_test(&(task->ref_count))) {
+               _task_free_task(task);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_is_simple_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_INFO("task == NULL\n");
+               return false;
+       }
+
+       sync_agent_ec_task_spec_s *task_spec = task->task_spec;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_spec_is_simple(task_spec);
+}
+
+sync_agent_ec_boolean ec_task_is_container_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_INFO("task == NULL\n");
+               return false;
+       }
+
+       sync_agent_ec_task_spec_s *task_spec = task->task_spec;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (ec_task_spec_is_container(task_spec) || ec_task_spec_is_dynamic_container(task_spec));
+}
+
+sync_agent_ec_boolean ec_task_is_root_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_t *parent_task = ec_task_get_parent_task(task);
+       if (parent_task == NULL) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+sync_agent_ec_int ec_task_get_param_cnt(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_spec_get_param_cnt(task->task_spec);
+}
+
+sync_agent_ec_boolean ec_task_get_output_param_info(ec_task_t * task, sync_agent_ec_int * pOutput_param_cnt, sync_agent_ec_int ** pOutput_param_index_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL");
+               return false;
+       }
+
+       if (task->task_spec == NULL) {
+               _DEBUG_ERROR("task->task_spec == NULL\n");
+               return false;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_spec_get_output_param_info(task->task_spec, pOutput_param_cnt, pOutput_param_index_array);
+}
+
+sync_agent_ec_uint ec_task_get_child_task_cnt(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_spec_get_child_task_cnt(task->task_spec);
+}
+
+ec_task_t *ec_task_get_parent_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task->parent_task;
+}
+
+sync_agent_ec_int ec_task_get_child_index_in_parent_task(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task->child_task_index_in_parent_task;
+}
+
+void ec_task_set_task_error(ec_task_t * task, sync_agent_ec_task_error_e task_error)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       task->task_error = task_error;
+}
+
+sync_agent_ec_boolean ec_task_check_same_task_error(ec_task_t * task, sync_agent_ec_task_error_e task_error)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task == NULL) {
+               _DEBUG_ERROR("task == NULL\n");
+               return false;
+       }
+
+       if (task->task_error == task_error) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+sync_agent_ec_boolean ec_task_is_not_yet_run(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_check_same_task_error(task, SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN);
+}
+
+void ec_task_do_cancellation(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_lock(task->cancel_information->cancel_info_mutex);
+#else
+       g_mutex_lock(&(task->cancel_information->cancel_info_mutex));
+#endif
+
+       ec_task_cancel_info_set_cancel_flag_atomic(task->cancel_information);
+       _DEBUG_INFO("task->cancel_information->cancel_flag = %d\n", task->cancel_information->cancel_flag);
+       ec_task_cancel_info_call_cancel_callbacks_unlocked(task->cancel_information);
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_unlock(task->cancel_information->cancel_info_mutex);
+#else
+       g_mutex_unlock(&(task->cancel_information->cancel_info_mutex));
+#endif
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_task_call_task_finish_callback(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task == NULL, "ec_task_t is NULL !!");
+
+       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(task->request_msg);
+       sync_agent_task_finish_cb task_finish_callback = request_msg->task_finish_callback;
+       sync_agent_ec_pointer simple_task_finish_callback_usr_data = request_msg->simple_task_finish_callback_usr_data;
+       if (task_finish_callback != NULL) {
+               _DEBUG_INFO("call finish callback\n");
+               sync_agent_ec_task_error_e task_error = task->task_error;
+               sync_agent_ec_int i = 0;
+               sync_agent_ec_int cnt_out_param = 0;
+               sync_agent_ec_int out_param_index = 0;
+               sync_agent_ec_int *out_param_index_array = NULL;
+               sync_agent_ec_param_param_s **out_param_array = NULL;
+               if (!ec_task_get_output_param_info(task, &cnt_out_param, &out_param_index_array)) {
+                       _DEBUG_ERROR("out of memory during ec_task_get_output_param_info\n");
+                       assert(false);
+               }
+
+               if (cnt_out_param > 0 && out_param_index_array != NULL) {
+                       out_param_array = (sync_agent_ec_param_param_s **) calloc(cnt_out_param, sizeof(sync_agent_ec_param_param_s *));
+                       if (out_param_array == NULL) {
+                               _DEBUG_ERROR("out of memory during ec_task_get_output_param_info\n");
+                               assert(false);
+                       }
+
+                       for (i = 0; i < cnt_out_param; i++) {
+                               out_param_index = out_param_index_array[i];
+                               out_param_array[i] = task->param_array[out_param_index];
+                       }
+               }
+
+               if (out_param_index_array != NULL) {
+                       free(out_param_index_array);
+               }
+
+               /* call task_finish_callback */
+               task_finish_callback(task_error, cnt_out_param, out_param_array, simple_task_finish_callback_usr_data);
+
+       } else {
+               _DEBUG_INFO("cannot call finish callback\n");
+               /* TODO : remove output parameters since we have to nothing to return but prevent memory leak */
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_task_remove_control_flow(ec_task_t * parent_task, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (parent_task == NULL) {
+               _DEBUG_ERROR("parent_task == NULL\n");
+               return;
+       }
+
+       sync_agent_ec_task_spec_s *parent_task_spec = parent_task->task_spec;
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               ec_error = ec_task_spec_valididate_child_task_index(parent_task_spec, to_task_index);
+
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               ec_error = ec_task_spec_valididate_child_task_index_on_dynamic_case(parent_task->dynamic_case, parent_task_spec, to_task_index);
+       }
+
+       if (ec_error != SYNC_AGENT_EC_OK) {
+               _DEBUG_ERROR("invalid to_task_index. to_task_index = %d\n", to_task_index);
+               return;
+       }
+
+       /* remove in_degree of to_task */
+       parent_task->current_child_task_control_flow_in_degree_array[to_task_index] -= 1;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_task_set_left_child_to_run(ec_task_t * parent_task, sync_agent_ec_uint number)
+{
+       _EXTERN_FUNC_ENTER;
+
+       parent_task->cnt_left_child_task_to_finish = number;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_is_left_child_to_run_zero(ec_task_t * parent_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (parent_task->cnt_left_child_task_to_finish == 0);
+}
+
+void ec_task_decrease_left_child_to_run(ec_task_t * parent_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       (parent_task->cnt_left_child_task_to_finish)--;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_is_parent_EC_TASK_DONE(ec_task_t * parent_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (ec_task_is_left_child_to_run_zero(parent_task)) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+void ec_task_collect_parent_task_output_parameter(ec_task_t * parent_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (parent_task == NULL) {
+               _DEBUG_ERROR("parent_task == NULL\n");
+               return;
+       }
+
+       if (!ec_task_is_container_task(parent_task)) {
+               _DEBUG_ERROR("parent_task is not container task\n");
+               return;
+       }
+
+       sync_agent_ec_param_param_s *to_param = NULL;
+       sync_agent_ec_param_spec_s *to_param_spec = NULL;
+       sync_agent_ec_param_param_s *from_param = NULL;
+
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_int param_cnt = ec_task_get_param_cnt(parent_task);
+       for (i = 0; i < param_cnt; i++) {
+               to_param = parent_task->param_array[i];
+               to_param_spec = to_param->pParam_spec;
+
+               if (ec_param_is_output_flag_on(to_param_spec->flags)) {
+                       from_param = _task_fetch_from_param(parent_task, -1, i);
+
+                       if (from_param != NULL) {
+                               /* set output parameter values */
+                               ec_set_param_value_with_other_param_value(&(to_param->param_value), &(from_param->param_value));
+                       }
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+GSList *ec_collect_firstly_runnable_child_tasks(ec_task_t * parent_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *runnable_child_task_list = NULL;
+       if (!ec_task_is_container_task(parent_task)) {
+               goto error_part;
+       }
+
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_task_spec_s *parent_task_spec = parent_task->task_spec;
+       ec_child_tasks_info_t *child_task_info = NULL;
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_child_tasks_info(parent_task_spec);
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_case_specific_child_tasks_info(parent_task_spec, parent_task->dynamic_case);
+       } else {
+               assert(false);
+       }
+
+       sync_agent_ec_int child_task_cnt;
+       sync_agent_ec_uint *child_task_control_flow_in_degree;
+
+       if (child_task_info != NULL) {
+               child_task_cnt = child_task_info->child_task_cnt;
+               child_task_control_flow_in_degree = child_task_info->child_task_control_flow_in_degree;
+       } else {
+               goto error_part;
+       }
+
+       ec_task_t *child_task = NULL;
+       for (i = 0; i < child_task_cnt; i++) {
+               if (child_task_control_flow_in_degree[i] == 0) {
+                       child_task = ec_task_alloc_child_task(parent_task, i);
+                       if (child_task == NULL) {
+                               goto error_part;
+                       }
+
+                       parent_task->child_task_array[i] = child_task;
+                       runnable_child_task_list = g_slist_append(runnable_child_task_list, child_task);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return runnable_child_task_list;
+
+ error_part:
+       if (runnable_child_task_list != NULL) {
+               GSList *iter = NULL;
+               for (iter = runnable_child_task_list; iter != NULL; iter = g_slist_next(iter)) {
+                       child_task = (ec_task_t *) (iter->data);
+                       ec_task_unref_task(child_task);
+               }
+               g_slist_free(runnable_child_task_list);
+       }
+
+       return NULL;
+}
+
+GSList *ec_collect_become_runnable_child_tasks_by_remove_control_flow(ec_task_t * parent_task, sync_agent_ec_int from_child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *runnable_child_task_list = NULL;
+       if (!ec_task_is_container_task(parent_task)) {
+               goto error_part;
+       }
+
+       /* validation */
+       sync_agent_ec_task_spec_s *parent_task_spec = parent_task->task_spec;
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               ec_error = ec_task_spec_valididate_child_task_index(parent_task_spec, from_child_task_index);
+
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               ec_error = ec_task_spec_valididate_child_task_index_on_dynamic_case(parent_task->dynamic_case, parent_task_spec, from_child_task_index);
+       }
+       if (ec_error != SYNC_AGENT_EC_OK) {
+               _DEBUG_ERROR("invalid from child task index. from child task index = %d\n", from_child_task_index);
+               goto error_part;
+       }
+
+       ec_child_tasks_info_t *child_task_info = NULL;
+       if (ec_task_spec_is_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_child_tasks_info(parent_task_spec);
+       } else if (ec_task_spec_is_dynamic_container(parent_task_spec)) {
+               child_task_info = ec_task_spec_find_case_specific_child_tasks_info(parent_task_spec, parent_task->dynamic_case);
+       } else {
+               assert(false);
+       }
+
+       ec_graph_edge_pool_t *control_edge_pool;
+
+       if (child_task_info != NULL) {
+               control_edge_pool = child_task_info->control_edge_pool;
+       } else {
+               goto error_part;
+       }
+
+       /* get to node list from child_index */
+       /* note that to nodes_list containing sync_agent_ec_int */
+       GList *to_node_list = ec_graph_edge_pool_query_to_node_list(control_edge_pool, (sync_agent_ec_constpointer) from_child_task_index);
+
+       /* remove control flow from child task at child_index of parent task */
+       GList *iter = NULL;
+       sync_agent_ec_int to_child_task_index = 0;
+       ec_task_t *to_child_task = NULL;
+       for (iter = to_node_list; iter != NULL; iter = g_list_next(iter)) {
+               to_child_task_index = (sync_agent_ec_int) (iter->data);
+               ec_task_remove_control_flow(parent_task, from_child_task_index, to_child_task_index);
+
+               /* if zero in-degree of control flow detected, make child task and append runnable_child_task_list */
+               if (parent_task->current_child_task_control_flow_in_degree_array[to_child_task_index] == 0) {
+                       to_child_task = ec_task_alloc_child_task(parent_task, to_child_task_index);
+                       if (to_child_task == NULL) {
+                               _DEBUG_ERROR("out of memory\n");
+                               goto error_part;
+                       }
+
+                       parent_task->child_task_array[to_child_task_index] = to_child_task;
+                       runnable_child_task_list = g_slist_append(runnable_child_task_list, to_child_task);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return runnable_child_task_list;
+
+ error_part:
+       if (runnable_child_task_list != NULL) {
+               GSList *iter = NULL;
+               ec_task_t *child_task;
+               for (iter = runnable_child_task_list; iter != NULL; iter = g_slist_next(iter)) {
+                       child_task = (ec_task_t *) (iter->data);
+                       ec_task_unref_task(child_task);
+               }
+               g_slist_free(runnable_child_task_list);
+       }
+
+       return NULL;
+}
+
+sync_agent_ec_task_error_e ec_task_run_simple_task(ec_task_t * pSimple_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(pSimple_task == NULL, SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK, "ec_task_t is NULL !!");
+
+       sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+
+       sync_agent_ec_task_spec_s *task_spec = pSimple_task->task_spec;
+       ec_task_cancel_info_t *cancel_info = pSimple_task->cancel_information;
+
+       sync_agent_util_ref_object_s *request_msg_ref = pSimple_task->request_msg;
+       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(request_msg_ref);
+
+       sync_agent_ec_int request_msg_id = request_msg->msg_head.msg_id;
+
+       if (-1 == gettimeofday(&(pSimple_task->run_time), NULL)) {
+               _DEBUG_INFO("setting run time error\n");
+       }
+
+       if (ec_task_cancel_info_get_cancel_flag_atomic(cancel_info)) {
+               _DEBUG_INFO("cancel flag on case\n");
+
+               /* do not run task if cancellation flag on */
+               task_error = SYNC_AGENT_EC_TASK_ERROR_CANCELED;
+       } else {
+               _DEBUG_INFO("cancel flag off case\n");
+               task_error = task_spec->u.task_process(pSimple_task->task_spec->task_param_cnt, pSimple_task->param_array);
+       }
+
+       if (-1 == gettimeofday(&(pSimple_task->finish_time), NULL)) {
+               _DEBUG_ERROR("setting finish time error\n");
+       }
+
+       /* set task error information */
+       ec_task_set_task_error(pSimple_task, task_error);
+
+       if (task_spec->post_func != NULL) {
+               task_spec->post_func(task_spec->usr_post_task_func_data, request_msg_id);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_error;
+}
+
+sync_agent_ec_boolean ec_task_add_pending_task_list_of_first_progress_blocking_realized_entity(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_boolean is_pending_task = false;
+
+       GSList *iter_current_node = NULL;
+       GSList *iter_realized_entity = NULL;
+       ec_n_ary_tree_node_with_flag_t *current_node = NULL;
+       ec_progress_blocking_realized_entity_t *realized_entity = NULL;
+       ec_progress_blocking_realized_entity_t *prev_realized_entity = NULL;
+       GQueue *progress_blocking_queue = NULL;
+
+       /* iterate all queuing rules related to task */
+       for (iter_current_node = task->current_node_in_progress_blocking_entity_list, iter_realized_entity = task->progress_blocking_realized_entity_list; iter_current_node != NULL && iter_realized_entity != NULL;
+            iter_current_node = g_slist_next(iter_current_node), iter_realized_entity = g_slist_next(iter_realized_entity)) {
+               current_node = (ec_n_ary_tree_node_with_flag_t *) (iter_current_node->data);
+               realized_entity = (ec_progress_blocking_realized_entity_t *) (iter_realized_entity->data);
+
+               progress_blocking_queue = realized_entity->entity->queuing_rule_spec->progress_blocking_queue;
+               if (current_node != NULL && ec_n_ary_tree_node_with_flag_is_blocking_flag_on(current_node) && g_queue_peek_head(progress_blocking_queue) != realized_entity) {
+                       /* pending condition */
+                       GList *realized_entity_node = g_queue_find(progress_blocking_queue, realized_entity);
+                       GList *prev_realized_entity_node = realized_entity_node->prev;
+
+                       prev_realized_entity = (ec_progress_blocking_realized_entity_t *) (prev_realized_entity_node->data);
+                       ec_progress_blocking_realized_entity_add_pending_task(prev_realized_entity, task);
+                       is_pending_task = true;
+                       break;  /* note that only append first found queue */
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return is_pending_task;
+}
+
+void ec_task_update_progress_blocking_realized_entity_and_pop_if_possible(ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task == NULL, "ec_task_t is NULL !!");
+
+       GSList *iter_current_node = NULL;
+       GSList *iter_realized_entity = NULL;
+       ec_n_ary_tree_node_with_flag_t *current_node = NULL;
+       ec_progress_blocking_realized_entity_t *realized_entity = NULL;
+       GQueue *progress_blocking_queue = NULL;
+
+       for (iter_current_node = task->current_node_in_progress_blocking_entity_list, iter_realized_entity = task->progress_blocking_realized_entity_list; iter_current_node != NULL && iter_realized_entity != NULL;
+            iter_current_node = g_slist_next(iter_current_node), iter_realized_entity = g_slist_next(iter_realized_entity)) {
+               current_node = (ec_n_ary_tree_node_with_flag_t *) (iter_current_node->data);
+               realized_entity = (ec_progress_blocking_realized_entity_t *) (iter_realized_entity->data);
+               if (ec_progress_blocking_realized_entity_update_and_test_left_progress_blocking_element_cnt(realized_entity, current_node, task)) {
+                       /* pop realized_entity in queue */
+                       progress_blocking_queue = realized_entity->entity->queuing_rule_spec->progress_blocking_queue;
+                       g_queue_remove(progress_blocking_queue, realized_entity);
+
+                       /* restart pending tasks due to realized_entity */
+                       ec_progress_blocking_realized_entity_restart_pending_task(realized_entity);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+#include "engine-controller/task_message.h"
+
+ec_progress_blocking_realized_entity_t *ec_progress_blocking_realized_entity_new(ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_progress_blocking_realized_entity_t *realized_entity = (ec_progress_blocking_realized_entity_t *) calloc(1, sizeof(ec_progress_blocking_realized_entity_t));
+       if (realized_entity == NULL) {
+               goto error_part;
+       }
+
+       realized_entity->entity = ec_progress_blocking_entity_ref(entity);
+       realized_entity->left_progress_blocking_element_cnt = entity->element_set->progress_blocking_element_cnt;
+       realized_entity->pending_task_list = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return realized_entity;
+
+ error_part:
+       ec_progress_blocking_realized_entity_free(realized_entity);
+       return NULL;
+}
+
+void ec_progress_blocking_realized_entity_free(ec_progress_blocking_realized_entity_t * realized_entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (realized_entity != NULL) {
+               if (realized_entity->entity != NULL) {
+                       ec_progress_blocking_entity_unref(realized_entity->entity);
+               }
+
+               if (realized_entity->pending_task_list != NULL) {
+                       GSList *iter = NULL;
+                       ec_task_t *pending_task = NULL;
+                       for (iter = realized_entity->pending_task_list; iter != NULL; iter = g_slist_next(iter)) {
+                               pending_task = (ec_task_t *) (iter->data);
+                               ec_task_unref_task(pending_task);
+                       }
+
+                       g_slist_free(realized_entity->pending_task_list);
+               }
+
+               free(realized_entity);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_progress_blocking_realized_entity_restart_pending_task(ec_progress_blocking_realized_entity_t * realized_entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(realized_entity == NULL, "ec_progress_blocking_realized_entity_t is NULL !!");
+
+       GSList *iter = NULL;
+       ec_task_t *pending_task = NULL;
+       ec_request_msg_t *request_msg = NULL;
+       ec_task_message_t *new_task_msg = NULL;
+       for (iter = realized_entity->pending_task_list; iter != NULL; iter = g_slist_next(iter)) {
+               pending_task = (ec_task_t *) (iter->data);
+               request_msg = (ec_request_msg_t *) sync_agent_get_original_object(pending_task->request_msg);
+
+               _DEBUG_INFO("pending task (request msg id = %d, task spec id = %d, task spec name = %s) by queuing rule restarted\n", request_msg->msg_head.msg_id, pending_task->task_info->task_spec_id, pending_task->task_info->task_spec->task_name);
+
+               /* send msg to engine controller itself */
+               new_task_msg = ec_task_message_create(EC_TASK_START, pending_task, 0);
+               ec_send_msg_to_engine_controller_with_compare_priority(new_task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+               /* TODO : error handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_progress_blocking_realized_entity_add_pending_task(ec_progress_blocking_realized_entity_t * entity, ec_task_t * pending_task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(entity == NULL, "ec_progress_blocking_realized_entity_t is NULL !!");
+
+       entity->pending_task_list = g_slist_append(entity->pending_task_list, ec_task_ref_task(pending_task));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_progress_blocking_realized_entity_update_and_test_left_progress_blocking_element_cnt(ec_progress_blocking_realized_entity_t * realized_entity, ec_n_ary_tree_node_with_flag_t * current_node, ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (ec_progress_blocking_realized_entity_is_zero_left_progress_blocking_element_cnt(realized_entity)) {
+               return false;
+       }
+
+       sync_agent_ec_boolean become_zero_after_update = false;
+
+       switch (task->task_error) {
+       case SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK:
+               _DEBUG_INFO("invalid task error returned\n");
+               break;
+       case SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED:
+       case SYNC_AGENT_EC_TASK_ERROR_CANCELED:
+               become_zero_after_update = true;
+               realized_entity->left_progress_blocking_element_cnt = 0;
+               break;
+       case SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS:
+               if (current_node != NULL && ec_n_ary_tree_node_with_flag_is_blocking_flag_on(current_node)) {
+                       (realized_entity->left_progress_blocking_element_cnt)--;
+
+                       if (ec_progress_blocking_realized_entity_is_zero_left_progress_blocking_element_cnt(realized_entity)) {
+                               become_zero_after_update = true;
+                       }
+               }
+               break;
+       case SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN:
+               if (current_node != NULL && ec_task_spec_is_dynamic_container(task->task_spec)) {
+                       /* we can remove other dynamic case progress_blocking_element */
+
+                       sync_agent_ec_uint can_remove_flag_on_cnt = 0;
+
+                       ec_n_ary_tree_node_with_flag_t *child_node = NULL;
+                       for (child_node = current_node->first_child_node; child_node != NULL; child_node = child_node->next_sibling_node) {
+                               if (child_node->dynamic_case != task->dynamic_case) {
+                                       can_remove_flag_on_cnt += ec_n_ary_tree_node_with_flag_count_subtree_flag_on_number(child_node);
+                               }
+                       }
+
+                       if (can_remove_flag_on_cnt > 0) {
+                               (realized_entity->left_progress_blocking_element_cnt) -= can_remove_flag_on_cnt;
+
+                               if (ec_progress_blocking_realized_entity_is_zero_left_progress_blocking_element_cnt(realized_entity)) {
+                                       become_zero_after_update = true;
+                               }
+                       }
+               }
+               break;
+       default:
+               _DEBUG_INFO("unknown task error returned\n");
+               become_zero_after_update = true;
+               realized_entity->left_progress_blocking_element_cnt = 0;
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return become_zero_after_update;
+}
+
+sync_agent_ec_boolean ec_progress_blocking_realized_entity_is_zero_left_progress_blocking_element_cnt(ec_progress_blocking_realized_entity_t * realized_entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return realized_entity->left_progress_blocking_element_cnt == 0;
+}
diff --git a/src/framework/engine-controller/task.h b/src/framework/engine-controller/task.h
new file mode 100755 (executable)
index 0000000..1088123
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_H_
+#define TASK_H_
+
+#include <sys/time.h>
+#include <glib.h>
+#include "engine-controller/param.h"
+#include "engine-controller/param_internal.h"
+#include "engine-controller/task_spec.h"
+#include "engine-controller/task_cancel_info.h"
+#include "engine-controller/message.h"
+#include "engine-controller/task_info_pool.h"
+#include "utility/fw_ref.h"
+
+/**
+ * @file               task.h
+ * @brief      Defines engine controller task APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for task
+ */
+typedef struct ec_task_s ec_task_t;
+
+/**
+ * @brief Structure for task
+ */
+struct ec_task_s {
+       sync_agent_ec_int ref_count;            /**< Reference count */
+
+       sync_agent_ec_task_error_e task_error;          /**< Task error */
+
+       ec_task_info_t *task_info;                                      /**< Task information */
+       GSList *progress_blocking_realized_entity_list; /**< containing ec_progress_blocking_realized_entity_t* */
+       GSList *current_node_in_progress_blocking_entity_list;  /**< containing ec_n_ary_tree_node_with_flag_t* */
+
+       sync_agent_ec_task_spec_s *task_spec;           /**< Task spec */
+       sync_agent_util_ref_object_s *request_msg;      /**< Request message(containing ec_request_msg_t*) */
+
+       ec_task_cancel_info_t *cancel_information;              /**< Cancel information */
+       sync_agent_ec_param_param_s **param_array;              /**< Parameter array */
+
+       /* information of dynamic case */
+       sync_agent_ec_int dynamic_case;                 /**< dynamic case(only use when task spec is dynamic) */
+
+       /* information of parent link */
+       ec_task_t *parent_task;                                 /**< Parent task */
+       sync_agent_ec_int child_task_index_in_parent_task;                      /**< Child task index in parent task */
+
+       /* information of child link */
+       ec_task_t **child_task_array;                   /**< Child task array */
+
+       sync_agent_ec_uint cnt_left_child_task_to_finish;                       /**< Left child task count to finish */
+
+       sync_agent_ec_uint *current_child_task_control_flow_in_degree_array;            /**< Current child task control flow in degree array */
+
+       struct timeval create_time;                     /**< Create time */
+       struct timeval run_time;                        /**< Run time */
+       struct timeval finish_time;                     /**< Finish time */
+};
+
+/**
+ * @brief Construct progress_blocking_realized_entity_list
+ * @param[in] task_info ec_task_info_t
+ * @return progress_blocking_realized_entity_list on success, NULL on fail
+ * @retval progress_blocking_realized_entity_list Successful
+ * @retval NULL Fail
+ */
+GSList *ec_task_construct_progress_blocking_realized_entity_list(ec_task_info_t * task_info);
+
+/**
+ * @brief Allocate root task
+ * @param[in] task_spec sync_agent_ec_task_spec_s
+ * @param[in] request_msg ec_request_msg_t
+ * @param[in] task_info_pool ec_task_info_pool_t
+ * @return ec_task_t on success, NULL on fail
+ * @retval root task Successful
+ * @retval NULL Fail
+ */
+ec_task_t *ec_task_alloc_root_task(sync_agent_ec_task_spec_s * task_spec, ec_request_msg_t * request_msg, ec_task_info_pool_t * task_info_pool);
+
+/**
+ * @brief Allocate child task
+ * @param[in] parent_task ec_task_t
+ * @param[in] child_index sync_agent_ec_int
+ * @return ec_task_t on success, NULL on fail
+ * @retval child task Successful
+ * @retval NULL Fail
+ */
+ec_task_t *ec_task_alloc_child_task(ec_task_t * parent_task, sync_agent_ec_int child_index);
+
+/**
+ * @brief Increase task reference count
+ * @param[in] task ec_task_t
+ * @return ec_task_t on success, NULL on fail
+ * @retval task Successful
+ */
+ec_task_t *ec_task_ref_task(ec_task_t * task);
+
+/**
+ * @brief Decrease task reference count
+ * @param[in] task ec_task_t
+ */
+void ec_task_unref_task(ec_task_t * task);
+
+/**
+ * @brief Check that inputted task is simple task or not
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true Simple task
+ * @retval false Others
+ */
+sync_agent_ec_boolean ec_task_is_simple_task(ec_task_t * task);
+
+/**
+ * @brief Check that inputted task is container task or not
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true Container task
+ * @retval false Others
+ */
+sync_agent_ec_boolean ec_task_is_container_task(ec_task_t * task);
+
+/**
+ * @brief Check that inputted task is root task or not
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true Root task
+ * @retval false Others
+ */
+sync_agent_ec_boolean ec_task_is_root_task(ec_task_t * task);
+
+/**
+ * @brief Get parameter count
+ * @param[in] task ec_task_t
+ * @return Parameter count
+ */
+sync_agent_ec_int ec_task_get_param_cnt(ec_task_t * task);
+
+/**
+ * @brief Get output parameter information
+ * @param[in] task ec_task_t
+ * @param[out] pOutput_param_cnt output parameter count
+ * @param[out] pOutput_param_index_array output parameter index array
+ * @return true on success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_int ec_task_get_output_param_info(ec_task_t * task, sync_agent_ec_int * pOutput_param_cnt, sync_agent_ec_int ** pOutput_param_index_array);
+
+/**
+ * @brief Get child task count
+ * @param[in] task ec_task_t
+ * @return Child task count
+ */
+sync_agent_ec_uint ec_task_get_child_task_cnt(ec_task_t * task);
+
+/**
+ * @brief Get parent task
+ * @param[in] task ec_task_t
+ * @return parent task on success, NULL on fail
+ * @retval parent task Successful
+ * @retval NULL Fail
+ */
+ec_task_t *ec_task_get_parent_task(ec_task_t * task);
+
+/**
+ * @brief Get child index in parent task
+ * @param[in] task ec_task_t
+ * @return child index
+ */
+sync_agent_ec_int ec_task_get_child_index_in_parent_task(ec_task_t * task);
+
+/**
+ * @brief Set task error
+ * @param[in] task ec_task_t
+ * @param[in] task_error sync_agent_ec_task_error_e
+ */
+void ec_task_set_task_error(ec_task_t * task, sync_agent_ec_task_error_e task_error);
+
+/**
+ * @brief Check same task error
+ * @param[in] task ec_task_t
+ * @param[in] task_error sync_agent_ec_task_error_e
+ * @return true on success, false on fail
+ * @retval true same task
+ * @retval false not same task
+ */
+sync_agent_ec_boolean ec_task_check_same_task_error(ec_task_t * task, sync_agent_ec_task_error_e task_error);
+
+/**
+ * @brief Check inputted task is not yet run
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true not run
+ * @retval false already run
+ */
+sync_agent_ec_boolean ec_task_is_not_yet_run(ec_task_t * task);
+
+/**
+ * @brief Request cancel
+ * @param[in] task ec_task_t
+ */
+void ec_task_do_cancellation(ec_task_t * task);
+
+/**
+ * @brief Call task finish callback
+ * @param[in] task ec_task_t
+ */
+void ec_task_call_task_finish_callback(ec_task_t * task);
+
+/**
+ * @brief Remove control flow
+ * @param[in] parent_task ec_task_t
+ * @param[in] from_task_index from index
+ * @param[in] to_task_index to index
+ */
+void ec_task_remove_control_flow(ec_task_t * parent_task, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index);
+
+/**
+ * @brief Set left child to run
+ * @param[in] parent_task ec_task_t
+ * @param[in] number left child count
+ */
+void ec_task_set_left_child_to_run(ec_task_t * parent_task, sync_agent_ec_uint number);
+
+/**
+ * @brief Check inputted parent task has no more left child to run
+ * @param[in] parent_task ec_task_t
+ * @return true on success, false on fail
+ * @retval true no more child to run
+ * @retval false child task left
+ */
+sync_agent_ec_boolean ec_task_is_left_child_to_run_zero(ec_task_t * parent_task);
+
+/**
+ * @brief Decrease left child to run
+ * @param[in] parent_task ec_task_t
+ */
+void ec_task_decrease_left_child_to_run(ec_task_t * parent_task);
+
+/**
+ * @brief check inputted parent task is EC_TASK_DONE
+ * @param[in] parent_task ec_task_t
+ * @return true on success, false on fail
+ * @retval true EC_TASK_DONE
+ * @retval false others
+ */
+sync_agent_ec_boolean ec_task_is_parent_EC_TASK_DONE(ec_task_t * parent_task);
+
+/**
+ * @brief Collect parent task output parameter
+ * @param[in] parent_task ec_task_t
+ */
+void ec_task_collect_parent_task_output_parameter(ec_task_t * parent_task);
+
+/**
+ * @brief Collect firstly runnable child tasks
+ * @param[in] parent_task ec_task_t
+ * @return runnable child tasks on success, false on fail
+ * @retval runnable child tasks Successful
+ * @retval NULL Fail
+ */
+GSList *ec_collect_firstly_runnable_child_tasks(ec_task_t * parent_task);
+
+/**
+ * @brief Collect become runnable child tasks by remove control flow
+ * @param[in] parent_task ec_task_t
+ * @param[in] from_child_task_index child task index
+ * @return runnable child tasks on success, false on fail
+ * @retval runnable child tasks Successful
+ * @retval NULL Fail
+ */
+GSList *ec_collect_become_runnable_child_tasks_by_remove_control_flow(ec_task_t * parent_task, sync_agent_ec_int from_child_task_index);
+
+/**
+ * @brief Run simple task
+ * @param[in] pSimple_task ec_task_t
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success, otherwise error value
+ * @retval SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS Successful
+ * @retval SYNC_AGENT_EC_TASK_ERROR_CANCELED Fail
+ */
+sync_agent_ec_task_error_e ec_task_run_simple_task(ec_task_t * pSimple_task);
+
+/**
+ * @brief Add pending task list of first progress blocking realized entity
+ * @remarks return true if pending is done
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_task_add_pending_task_list_of_first_progress_blocking_realized_entity(ec_task_t * task);
+
+/**
+ * @brief Update progress blocking realized entity and pop if possible
+ * @param[in] task ec_task_t
+ */
+void ec_task_update_progress_blocking_realized_entity_and_pop_if_possible(ec_task_t * task);
+
+/**
+ * @brief Structure for progress blocking realized entity
+ */
+typedef struct ec_progress_blocking_realized_entity_s ec_progress_blocking_realized_entity_t;
+
+/**
+ * @brief Structure for progress blocking realized entity
+ */
+struct ec_progress_blocking_realized_entity_s {
+       sync_agent_ec_uint left_progress_blocking_element_cnt;                  /**< Left progress blocking element count */
+
+       ec_progress_blocking_entity_t *entity;                                          /**< Blocking entity */
+       GSList *pending_task_list;                                                                      /**< Pending task list(containing ec_task_t*) */
+};
+
+/**
+ * @brief Create ec_progress_blocking_realized_entity_t
+ * @param[in] entity ec_progress_blocking_entity_t
+ * @return progress blocking realized entity on success, NULL on fail
+ * @retval ec_progress_blocking_realized_entity_t Successful
+ * @retval NULL Fail
+ */
+ec_progress_blocking_realized_entity_t *ec_progress_blocking_realized_entity_new(ec_progress_blocking_entity_t * entity);
+
+/**
+ * @brief Free ec_progress_blocking_realized_entity_t
+ * @param[in] realized_entity ec_progress_blocking_realized_entity_t
+ */
+void ec_progress_blocking_realized_entity_free(ec_progress_blocking_realized_entity_t * realized_entity);
+
+/**
+ * @brief Restart pending task
+ * @param[in] realized_entity ec_progress_blocking_realized_entity_t
+ */
+void ec_progress_blocking_realized_entity_restart_pending_task(ec_progress_blocking_realized_entity_t * realized_entity);
+
+/**
+ * @brief Add pending task
+ * @param[in] entity ec_progress_blocking_realized_entity_t
+ * @param[in] pending_task ec_task_t
+ */
+void ec_progress_blocking_realized_entity_add_pending_task(ec_progress_blocking_realized_entity_t * entity, ec_task_t * pending_task);
+
+/**
+ * @brief Update progress blocking realized entity and test left progress blocking element count
+ * @remarks return true when left_progress_blocking_element_cnt are updated and become zero
+ * @param[in] realized_entity ec_progress_blocking_realized_entity_t
+ * @param[in] current_node ec_n_ary_tree_node_with_flag_t
+ * @param[in] task ec_task_t
+ * @return true on success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_progress_blocking_realized_entity_update_and_test_left_progress_blocking_element_cnt(ec_progress_blocking_realized_entity_t * realized_entity, ec_n_ary_tree_node_with_flag_t * current_node, ec_task_t * task);
+
+/**
+ * @brief Check left progress blocking element count
+ * @remarks return true when left_progress_blocking_element_cnt are updated and become zero
+ * @param[in] realized_entity ec_progress_blocking_realized_entity_t
+ * @return true on success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_progress_blocking_realized_entity_is_zero_left_progress_blocking_element_cnt(ec_progress_blocking_realized_entity_t * realized_entity);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_H_ */
diff --git a/src/framework/engine-controller/task_cancel_info.c b/src/framework/engine-controller/task_cancel_info.c
new file mode 100755 (executable)
index 0000000..1217394
--- /dev/null
@@ -0,0 +1,330 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/task_message.h"
+#include "engine-controller/task_cancel_info.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_EC"
+#endif
+
+static void _ec_task_cancel_info_destroy(ec_task_cancel_info_t * info)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(info == NULL, "ec_task_cancel_info_t is NULL !!");
+
+       if (info != NULL) {
+               if (info->request_msg != NULL) {
+                       sync_agent_unref_referenced_object(info->request_msg);
+               }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+               if (info->cancel_info_mutex != NULL) {
+                       g_mutex_free(info->cancel_info_mutex);
+#else
+               if (&(info->cancel_info_mutex) != NULL) {
+                       g_mutex_clear(&(info->cancel_info_mutex));
+#endif
+               }
+               if (info->cancel_callback_infos != NULL) {
+                       GSList *iter = NULL;
+                       ec_cancel_callback_info_t *cancel_callback_info = NULL;
+                       for (iter = info->cancel_callback_infos; iter != NULL; iter = g_slist_next(iter)) {
+                               cancel_callback_info = iter->data;
+                               ec_cancel_callback_info_destroy(cancel_callback_info);
+                       }
+                       g_slist_free(info->cancel_callback_infos);
+               }
+               free(info);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+ec_cancel_callback_info_t *ec_cancel_callback_info_init(GThread * who_registered, ec_cancel_callback_cb how_to_do, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(who_registered == NULL, NULL, "GThread is NULL !!");
+
+       ec_cancel_callback_info_t *cancel_callback_info = (ec_cancel_callback_info_t *) malloc(sizeof(ec_cancel_callback_info_t));
+       if (cancel_callback_info == NULL) {
+               goto error_part;
+       }
+
+       cancel_callback_info->who_registered = who_registered;
+       cancel_callback_info->how_to_do = how_to_do;
+       cancel_callback_info->user_data = user_data;
+
+       _EXTERN_FUNC_EXIT;
+
+       return cancel_callback_info;
+
+ error_part:
+       ec_cancel_callback_info_destroy(cancel_callback_info);
+       return NULL;
+}
+
+sync_agent_ec_boolean ec_cancel_callback_info_compare(ec_cancel_callback_info_t * cancel_callback_info, GThread * who_registered, ec_cancel_callback_cb how_to_do, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(who_registered == NULL, false, "GThread is NULL !!");
+
+       sync_agent_ec_boolean is_same = false;
+       if (cancel_callback_info == NULL) {
+               _DEBUG_INFO("cancel_callback_info == NULL\n");
+               goto return_part;
+       }
+
+       if (cancel_callback_info->who_registered == who_registered && cancel_callback_info->how_to_do == how_to_do && cancel_callback_info->user_data == user_data) {
+               is_same = true;
+       }
+
+ return_part:
+       _DEBUG_INFO("ended with return = %d\n", is_same);
+       _EXTERN_FUNC_EXIT;
+       return is_same;
+}
+
+void ec_cancel_callback_info_call_callback(ec_cancel_callback_info_t * cancel_callback_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_callback_info != NULL) {
+               /* call callback */
+               _DEBUG_INFO("cancel callback will be called by thread (thread structure = %p)\n", cancel_callback_info->who_registered);
+               _DEBUG_INFO("before call cancel callback\n");
+               cancel_callback_info->how_to_do(cancel_callback_info->user_data);
+               _DEBUG_INFO("after call cancel callback\n");
+       } else {
+               _DEBUG_INFO("cancel_callback_info = NULL. Do nothing\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_cancel_callback_info_destroy(ec_cancel_callback_info_t * cancel_callback_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_callback_info != NULL) {
+               free(cancel_callback_info);
+       } else {
+               _DEBUG_INFO("cancel_callback_info = NULL. Do nothing\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_task_cancel_info_t *ec_task_cancel_info_init(sync_agent_util_ref_object_s * request_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_cancel_info_t *info = (ec_task_cancel_info_t *) calloc(1, sizeof(ec_task_cancel_info_t));
+       if (info == NULL) {
+               goto error_part;
+       }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       info->cancel_info_mutex = g_mutex_new();
+       if (info->cancel_info_mutex == NULL) {
+               goto error_part;
+       }
+#else
+       g_mutex_init(&(info->cancel_info_mutex));
+//      if (&(info->cancel_info_mutex) == NULL) {
+//              goto error_part;
+//      }
+#endif
+
+       info->cancel_flag = false;
+       info->request_msg = sync_agent_get_referenced_object(request_msg);
+       info->ref_count = 1;
+
+       _EXTERN_FUNC_EXIT;
+
+       return info;
+
+ error_part:
+       _ec_task_cancel_info_destroy(info);
+       return NULL;
+}
+
+ec_task_cancel_info_t *ec_task_cancel_info_ref(ec_task_cancel_info_t * info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (info == NULL) {
+               return NULL;
+       }
+
+       g_atomic_int_inc(&(info->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return info;
+}
+
+void ec_task_cancel_info_unref(ec_task_cancel_info_t * info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (info == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_dec_and_test(&(info->ref_count))) {
+               _ec_task_cancel_info_destroy(info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_cancel_info_get_cancel_flag_atomic(ec_task_cancel_info_t * cancel_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               return false;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_atomic_int_get(&(cancel_info->cancel_flag));
+}
+
+void ec_task_cancel_info_set_cancel_flag_atomic(ec_task_cancel_info_t * cancel_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               return;
+       }
+       g_atomic_int_set(&(cancel_info->cancel_flag), true);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_int ec_task_cancel_info_get_request_msg_id(ec_task_cancel_info_t * cancel_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               return -1;
+       }
+       if (cancel_info->request_msg == NULL) {
+               _DEBUG_ERROR("cancel_info->request_msg == NULL\n");
+               return -1;
+       }
+
+       ec_request_msg_t *request_msg = (ec_request_msg_t *) sync_agent_get_original_object(cancel_info->request_msg);
+       _DEBUG_INFO("end with return = %d\n", request_msg->msg_head.msg_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return request_msg->msg_head.msg_id;
+}
+
+void ec_task_cancel_info_call_cancel_callbacks_unlocked(ec_task_cancel_info_t * cancel_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               return;
+       }
+
+       GSList *iter = NULL;
+       ec_cancel_callback_info_t *cancel_callback_info = NULL;
+       _DEBUG_INFO("%d number of cancel callback is registered by threads of thread pool\n", g_slist_length(cancel_info->cancel_callback_infos));
+       for (iter = cancel_info->cancel_callback_infos; iter != NULL; iter = g_slist_next(iter)) {
+               cancel_callback_info = iter->data;
+               ec_cancel_callback_info_call_callback(cancel_callback_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_error_e ec_task_cancel_info_register_cancel_callback_unlocked(ec_task_cancel_info_t * cancel_info, ec_cancel_callback_cb callback_func, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               ec_error = SYNC_AGENT_EC_INVALID_PARAMETER;
+               goto return_part;
+       }
+
+       /* create cancel callback info */
+       ec_cancel_callback_info_t *cancel_callback_info = ec_cancel_callback_info_init(g_thread_self(), callback_func, user_data);
+       if (cancel_callback_info == NULL) {
+               _DEBUG_ERROR("ec_cancel_callback_info_init failed because of out of memory\n");
+               ec_error = SYNC_AGENT_EC_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       cancel_info->cancel_callback_infos = g_slist_prepend(cancel_info->cancel_callback_infos, cancel_callback_info);
+
+ return_part:
+       _DEBUG_INFO("end with return = %d\n", ec_error);
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+}
+
+sync_agent_ec_error_e ec_task_cancel_info_unregister_cancel_callback_unlocked(ec_task_cancel_info_t * cancel_info, ec_cancel_callback_cb callback_func, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       if (cancel_info == NULL) {
+               _DEBUG_ERROR("cancel_info == NULL\n");
+               ec_error = SYNC_AGENT_EC_INVALID_PARAMETER;
+               goto return_part;
+       }
+
+       /* remove in callback list */
+       GThread *current_thread = g_thread_self();
+       GSList *iter = NULL;
+       ec_cancel_callback_info_t *cancel_callback_info = NULL;
+       sync_agent_ec_boolean is_same = false;
+       for (iter = cancel_info->cancel_callback_infos; iter != NULL; iter = g_slist_next(iter)) {
+               cancel_callback_info = iter->data;
+
+               is_same = ec_cancel_callback_info_compare(cancel_callback_info, current_thread, callback_func, user_data);
+               if (is_same) {
+                       ec_cancel_callback_info_destroy(cancel_callback_info);
+                       cancel_info->cancel_callback_infos = g_slist_delete_link(cancel_info->cancel_callback_infos, iter);
+                       break;
+               }
+       }
+
+       _DEBUG_INFO("no same callback exist in the list\n");
+
+ return_part:
+       _DEBUG_INFO("end with return = %d\n", ec_error);
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+}
diff --git a/src/framework/engine-controller/task_cancel_info.h b/src/framework/engine-controller/task_cancel_info.h
new file mode 100755 (executable)
index 0000000..e1f979c
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EC_TASK_CANCEL_INFO_H_
+#define EC_TASK_CANCEL_INFO_H_
+
+#include <sys/time.h>
+#include <glib.h>
+#include "utility/fw_ref.h"
+#include "engine-controller/define.h"
+
+/**
+ * @file task_cancel_info.h
+ * @brief Provides enum definition for task status
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Cancel callback
+ */
+typedef void (*ec_cancel_callback_cb) (void *user_data);
+
+/**
+ * @brief Structure for cancel callback information
+ */
+typedef struct ec_cancel_callback_info_s ec_cancel_callback_info_t;
+
+/**
+ * @brief Structure for cancel callback information
+ */
+struct ec_cancel_callback_info_s {
+       GThread *who_registered;                        /**< Register thread */
+       ec_cancel_callback_cb how_to_do;        /**< Cancel callback */
+       sync_agent_ec_pointer user_data;        /**< User data */
+};
+
+/**
+ * @brief Initialize ec_cancel_callback_info_t
+ * @param[in] who_registered GThread
+ * @param[in] how_to_do ec_cancel_callback_cb
+ * @param[in] user_data user data
+ * @return ec_cancel_callback_info_t on Success, NULL on fail
+ * @retval ec_cancel_callback_info_t Successful
+ * @retval NULL Fail
+ */
+ec_cancel_callback_info_t *ec_cancel_callback_info_init(GThread * who_registered, ec_cancel_callback_cb how_to_do, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Compare ec_cancel_callback_info_t
+ * @param[in] cancel_callback_info ec_cancel_callback_info_t
+ * @param[in] who_registered GThread
+ * @param[in] how_to_do ec_cancel_callback_cb
+ * @param[in] user_data user data
+ * @return true is same callback information , false is note same callback information
+ * @retval true is same callback information
+ * @retval false is not same callback information
+ */
+sync_agent_ec_boolean ec_cancel_callback_info_compare(ec_cancel_callback_info_t * cancel_callback_info, GThread * who_registered, ec_cancel_callback_cb how_to_do, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Call registered callback
+ * @param[in] cancel_callback_info ec_cancel_callback_info_t
+ */
+void ec_cancel_callback_info_call_callback(ec_cancel_callback_info_t * cancel_callback_info);
+
+/**
+ * @brief Destroy ec_cancel_callback_info_t
+ * @param[in] cancel_callback_info ec_cancel_callback_info_t
+ */
+void ec_cancel_callback_info_destroy(ec_cancel_callback_info_t * cancel_callback_info);
+
+/**
+ * @brief Structure for cancel information
+ */
+typedef struct ec_task_cancel_info_s ec_task_cancel_info_t;
+
+/**
+ * @brief Structure for cancel information
+ */
+struct ec_task_cancel_info_s {
+       sync_agent_ec_int ref_count;            /**< Reference count */
+
+       sync_agent_ec_boolean cancel_flag;      /**< Cancel flag */
+       sync_agent_util_ref_object_s *request_msg;      /**< Request message(containing ec_request_msg_t*) */
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       GMutex *cancel_info_mutex;              /**< Cancel information mutex */
+#else
+       GMutex cancel_info_mutex;               /**< Cancel information mutex */
+#endif
+       struct timeval cancel_time;             /**< Cancel time */
+       GSList *cancel_callback_infos;  /**< Cancel callback informations(containing ec_cancel_callback_info_t*) */
+};
+
+/**
+ * @brief Initialize ec_task_cancel_info_t
+ * @param[in] request_msg sync_agent_util_ref_object_s
+ * @return ec_task_cancel_info_t on success , NULL on fail
+ * @retval ec_task_cancel_info_t Successful
+ * @retval NULL Fail
+ */
+ec_task_cancel_info_t *ec_task_cancel_info_init(sync_agent_util_ref_object_s * request_msg);
+
+/**
+ * @brief Increase cancel information reference
+ * @param[in] info ec_task_cancel_info_t
+ * @return ec_task_cancel_info_t on success
+ * @retval ec_task_cancel_info_t Successful
+ */
+ec_task_cancel_info_t *ec_task_cancel_info_ref(ec_task_cancel_info_t * info);
+
+/**
+ * @brief Decrease cancel information reference
+ * @param[in] info ec_task_cancel_info_t
+ */
+void ec_task_cancel_info_unref(ec_task_cancel_info_t * info);
+
+/**
+ * @brief Get cancel flag
+ * @param[in] cancel_info ec_task_cancel_info_t
+ * @return sync_agent_ec_boolean
+ * @retval true on cancel flag is on
+ * @retval false on cancel flag is off
+ */
+sync_agent_ec_boolean ec_task_cancel_info_get_cancel_flag_atomic(ec_task_cancel_info_t * cancel_info);
+
+/**
+ * @brief Set cancel flag
+ * @param[in] cancel_info ec_task_cancel_info_t
+ */
+void ec_task_cancel_info_set_cancel_flag_atomic(ec_task_cancel_info_t * cancel_info);
+
+/**
+ * @brief Get request message id
+ * @param[in] cancel_info ec_task_cancel_info_t
+ * @return sync_agent_ec_int
+ * @retval request message id
+ */
+sync_agent_ec_int ec_task_cancel_info_get_request_msg_id(ec_task_cancel_info_t * cancel_info);
+
+/**
+ * @brief Call all registered callback
+ * @param[in] cancel_info ec_task_cancel_info_t
+ */
+void ec_task_cancel_info_call_cancel_callbacks_unlocked(ec_task_cancel_info_t * cancel_info);
+
+/**
+ * @brief Register cancel callback
+ * @param[in] cancel_info ec_task_cancel_info_t
+ * @param[in] callback_func ec_cancel_callback_cb callback_func
+ * @param[in] user_data user data
+ * @return SYNC_AGENT_EC_OK on success, otherwise error value
+ * @retval SYNC_AGENT_EC_INVALID_PARAMETER when invalid parameter is inputted
+ * @retval SYNC_AGENT_EC_OUT_OF_MEMORY when memory allocation is failed
+ */
+sync_agent_ec_error_e ec_task_cancel_info_register_cancel_callback_unlocked(ec_task_cancel_info_t * cancel_info, ec_cancel_callback_cb callback_func, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Unregister cancel callback
+ * @param[in] cancel_info ec_task_cancel_info_t
+ * @param[in] callback_func ec_cancel_callback_cb callback_func
+ * @param[in] user_data user data
+ * @return SYNC_AGENT_EC_OK on success, otherwise error value
+ * @retval SYNC_AGENT_EC_INVALID_PARAMETER when invalid parameter is inputted
+ */
+sync_agent_ec_error_e ec_task_cancel_info_unregister_cancel_callback_unlocked(ec_task_cancel_info_t * cancel_info, ec_cancel_callback_cb callback_func, sync_agent_ec_pointer user_data);
+
+/**
+ *     @}
+ */
+
+#endif                         /* EC_TASK_CANCEL_INFO_H_ */
diff --git a/src/framework/engine-controller/task_error.c b/src/framework/engine-controller/task_error.c
new file mode 100755 (executable)
index 0000000..0df0285
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "engine-controller/task_error.h"
+#include "engine-controller/task_error_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+typedef struct ec_task_error_map_s ec_task_error_map_t;
+struct ec_task_error_map_s {
+       sync_agent_ec_task_error_e err;
+       sync_agent_ec_char *str;
+};
+
+static ec_task_error_map_t ec_task_error_string_tbl[5] = {
+       {SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN, "not yet run"},
+       {SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS, "success"},
+       {SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "failed"},
+       {SYNC_AGENT_EC_TASK_ERROR_CANCELED, "canceled"},
+       {SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK, "invalid"}
+};
+
+sync_agent_ec_char *ec_task_error_string(sync_agent_ec_task_error_e error)
+{
+       _EXTERN_FUNC_ENTER;
+       sync_agent_ec_char *str = ec_task_error_string_tbl[4].str;
+       sync_agent_ec_int i = 0;
+       for (i = 0; i < 5; i++) {
+               if (error == ec_task_error_string_tbl[i].err) {
+                       str = ec_task_error_string_tbl[i].str;
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return str;
+}
diff --git a/src/framework/engine-controller/task_error_internal.h b/src/framework/engine-controller/task_error_internal.h
new file mode 100755 (executable)
index 0000000..ca7047b
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_ERROR_INTERNAL_H_
+#define TASK_ERROR_INTERNAL_H_
+
+//#include "fundamental_type.h"
+#include "engine-controller/task_error.h"
+
+/**
+ * @file task_error_internal.h
+ * @brief Provides enum definition for task status
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Provides readable expressiong of task error cases
+ * @param[in] error sync_agent_ec_task_error_e type of enumeration
+ * @return Error string of given error case
+ */
+sync_agent_ec_char *ec_task_error_string(sync_agent_ec_task_error_e error);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_ERROR_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/task_info_pool.c b/src/framework/engine-controller/task_info_pool.c
new file mode 100755 (executable)
index 0000000..7a36418
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/task_info_pool.h"
+#include "engine-controller/queuing_rule_spec.h"
+#include "engine-controller/task_spec_internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+ec_task_info_t *ec_task_info_new(sync_agent_ec_int task_spec_id, sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_info_t *task_info = (ec_task_info_t *) calloc(1, sizeof(ec_task_info_t));
+       if (task_info == NULL) {
+               goto error_part;
+       }
+
+       task_info->task_spec_id = task_spec_id;
+       task_info->progress_blocking_entity_list = NULL;
+       task_info->task_spec = ec_task_spec_ref(task_spec);
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_info;
+
+ error_part:
+       ec_task_info_free(task_info);
+       return NULL;
+}
+
+void ec_task_info_free(ec_task_info_t * task_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_info != NULL) {
+               if (task_info->task_spec != NULL) {
+                       ec_task_spec_unref(task_info->task_spec);
+               }
+
+               if (task_info->progress_blocking_entity_list != NULL) {
+                       GSList *iter = NULL;
+                       ec_progress_blocking_entity_t *entity = NULL;
+                       for (iter = task_info->progress_blocking_entity_list; iter != NULL; iter = g_slist_next(iter)) {
+                               entity = (ec_progress_blocking_entity_t *) (iter->data);
+                               ec_progress_blocking_entity_unref(entity);
+                       }
+                       g_slist_free(task_info->progress_blocking_entity_list);
+               }
+
+               free(task_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_task_info_t *ec_task_info_ref(ec_task_info_t * task_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_info == NULL, NULL, "ec_task_info_t is NULL !!");
+
+       /* TODO */
+
+       _EXTERN_FUNC_EXIT;
+       return task_info;
+}
+
+void ec_task_info_unref(ec_task_info_t * task_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_info_is_progress_blocking_entity_exist(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GSList *found_node = g_slist_find(task_info->progress_blocking_entity_list, entity);
+       if (found_node != NULL) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+sync_agent_ec_error_e ec_task_info_add_progress_blocking_entity(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_info == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_task_info_t is NULL !!");
+       retvm_if(entity == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_progress_blocking_entity_t is NULL !!");
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       if (ec_task_info_is_progress_blocking_entity_exist(task_info, entity)) {
+               _DEBUG_INFO("task info has already same entity");
+               goto return_part;
+       }
+
+       task_info->progress_blocking_entity_list = g_slist_prepend(task_info->progress_blocking_entity_list, entity);
+       /* TODO : error handling */
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+}
+
+sync_agent_ec_error_e ec_task_info_remove_blocking_entity(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_info == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_task_info_t is NULL !!");
+       retvm_if(entity == NULL, SYNC_AGENT_EC_UNKNOWN_ERROR, "ec_progress_blocking_entity_t is NULL !!");
+
+       sync_agent_ec_error_e ec_error = SYNC_AGENT_EC_OK;
+
+       if (!ec_task_info_is_progress_blocking_entity_exist(task_info, entity)) {
+               _DEBUG_INFO("task info has no such entity");
+               goto return_part;
+       }
+
+       task_info->progress_blocking_entity_list = g_slist_remove(task_info->progress_blocking_entity_list, entity);
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return ec_error;
+}
+
+ec_task_info_pool_t *ec_task_info_pool_alloc()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_info_pool_t *task_info_pool = (ec_task_info_pool_t *) calloc(1, sizeof(ec_task_info_pool_t));
+       if (task_info_pool == NULL) {
+               goto return_part;
+       }
+
+       task_info_pool->task_info_pool = g_hash_table_new(g_direct_hash, g_direct_equal);
+       if (task_info_pool->task_info_pool == NULL) {
+               goto error_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return task_info_pool;
+
+ error_part:
+       ec_task_info_pool_free(task_info_pool);
+       return NULL;
+}
+
+void ec_task_info_pool_free(ec_task_info_pool_t * task_info_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_info_pool != NULL) {
+               if (task_info_pool->task_info_pool != NULL) {
+                       g_hash_table_destroy(task_info_pool->task_info_pool);
+                       task_info_pool->task_info_pool = NULL;
+               }
+               free(task_info_pool);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_info_pool_add_task_info(ec_task_info_pool_t * task_info_pool, ec_task_info_t * task_info, sync_agent_ec_boolean replace)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_info_pool == NULL, false, "ec_task_info_pool_t is NULL !!");
+       retvm_if(task_info == NULL, false, "ec_task_info_t is NULL !!");
+
+       sync_agent_ec_boolean success = false;
+
+       GHashTable *hash = task_info_pool->task_info_pool;
+       if (replace) {
+               g_hash_table_replace(hash, (gpointer) (task_info->task_spec_id), task_info);    /* TODO : check free well done */
+               success = true;
+       } else {
+               gpointer tmp = g_hash_table_lookup(hash, (gpointer) (task_info->task_spec_id));
+               if (tmp != NULL) {
+                       success = false;
+               } else {
+                       g_hash_table_insert(hash, (gpointer) (task_info->task_spec_id), task_info);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+sync_agent_ec_boolean ec_task_info_pool_remove_task_info(ec_task_info_pool_t * task_info_pool, sync_agent_ec_uint msg_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+
+       _EXTERN_FUNC_EXIT;
+
+       return true;
+}
+
+ec_task_info_t *ec_task_info_pool_search_task_info(ec_task_info_pool_t * task_info_pool, sync_agent_ec_uint msg_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       GHashTable *hash = task_info_pool->task_info_pool;
+       ec_task_info_t *task_info = NULL;
+
+       task_info = (ec_task_info_t *) g_hash_table_lookup(hash, (gpointer) msg_type);
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_info;
+}
diff --git a/src/framework/engine-controller/task_info_pool.h b/src/framework/engine-controller/task_info_pool.h
new file mode 100755 (executable)
index 0000000..14ec25f
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_INFO_POOL_H_
+#define TASK_INFO_POOL_H_
+
+#include <glib.h>
+#include "engine-controller/fundamental_type.h"
+#include "message.h"
+
+#include "engine-controller/task_spec.h"
+#include "engine-controller/queuing_rule_spec_internal.h"
+
+/**
+ * @file               task_info_pool.h
+ * @brief      Defines engine controller task information pool APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for task information
+ */
+typedef struct ec_task_info_s ec_task_info_t;
+
+/**
+ * @brief Structure for task information
+ */
+struct ec_task_info_s {
+       sync_agent_ec_int task_spec_id;                         /**< task spec id */
+       sync_agent_ec_task_spec_s *task_spec;                   /**< task spec */
+       GSList *progress_blocking_entity_list;  /**< related to queuing rule(containing progress_blocking_entities related to task_spec) */
+};
+
+/**
+ * @brief Create ec_task_info_t
+ * @param[in] task_spec_id task spec id
+ * @param[in] task_spec sync_agent_ec_task_spec_s
+ * @return ec_task_info_t on Success, NULL on fail
+ * @retval ec_task_info_t Successful
+ * @retval NULL Fail
+ */
+ec_task_info_t *ec_task_info_new(sync_agent_ec_int task_spec_id, sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Free ec_task_info_t
+ * @param[in] task_info ec_task_info_t
+ */
+void ec_task_info_free(ec_task_info_t * task_info);
+
+/**
+ * @brief Increase reference count
+ * @param[in] task_info ec_task_info_t
+ * @return ec_task_info_t on Success, NULL on fail
+ * @retval ec_task_info_t Successful
+ * @retval NULL Fail
+ */
+ec_task_info_t *ec_task_info_ref(ec_task_info_t * task_info);
+
+/**
+ * @brief Decrease reference count
+ * @param[in] task_info ec_task_info_t
+ */
+void ec_task_info_unref(ec_task_info_t * task_info);
+
+/**
+ * @brief Check given progress_blocking_entity is exist
+ * @param[in] task_info ec_task_info_t
+ * @param[in] entity ec_progress_blocking_entity_t
+ * @return true on Success, false on fail
+ * @retval true exist
+ * @retval false not exist
+ */
+sync_agent_ec_boolean ec_task_info_is_progress_blocking_entity_exist(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity);
+
+/**
+ * @brief Add progress_blocking_entity
+ * @param[in] task_info ec_task_info_t
+ * @param[in] entity ec_progress_blocking_entity_t
+ * @return SYNC_AGENT_EC_OK on Success, otherwise error value
+ * @retval SYNC_AGENT_EC_OK Successful
+ */
+sync_agent_ec_error_e ec_task_info_add_progress_blocking_entity(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity);
+
+/**
+ * @brief Remove progress_blocking_entity
+ * @param[in] task_info ec_task_info_t
+ * @param[in] entity ec_progress_blocking_entity_t
+ * @return SYNC_AGENT_EC_OK on Success, otherwise error value
+ * @retval SYNC_AGENT_EC_OK Successful
+ */
+sync_agent_ec_error_e ec_task_info_remove_blocking_entity(ec_task_info_t * task_info, ec_progress_blocking_entity_t * entity);
+
+/**
+ * @brief Structure for task information pool
+ */
+typedef struct ec_task_info_pool_s ec_task_info_pool_t;
+
+/**
+ * @brief Structure for task information pool
+ */
+struct ec_task_info_pool_s {
+       GHashTable *task_info_pool;     /**< key : msg id
+                                          value : ec_task_info_t* */
+};
+
+/**
+ * @brief Allocate ec_task_info_pool_t
+ * @return ec_task_info_pool_t on Success, NULL on fail
+ * @retval ec_task_info_pool_t Successful
+ * @retval NULL Fail
+ */
+ec_task_info_pool_t *ec_task_info_pool_alloc();
+
+/**
+ * @brief Free ec_task_info_pool_t
+ * @param[in] task_info_pool ec_task_info_pool_t
+ */
+void ec_task_info_pool_free(ec_task_info_pool_t * task_info_pool);
+
+/**
+ * @brief Add ec_task_info_t
+ * @param[in] task_info_pool ec_task_info_pool_t
+ * @param[in] task_info ec_task_info_t
+ * @param[in] replace add or replace
+ * @return true on Success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_task_info_pool_add_task_info(ec_task_info_pool_t * task_info_pool, ec_task_info_t * task_info, sync_agent_ec_boolean replace);
+
+/**
+ * @brief Remove ec_task_info_t
+ * @param[in] task_info_pool ec_task_info_pool_t
+ * @param[in] msg_type message type
+ * @return true on Success, false on fail
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_task_info_pool_remove_task_info(ec_task_info_pool_t * task_info_pool, sync_agent_ec_uint msg_type);
+
+/**
+ * @brief Search ec_task_info_t
+ * @param[in] task_info_pool ec_task_info_pool_t
+ * @param[in] msg_type message type
+ * @return ec_task_info_t on Success, NULL on fail
+ * @retval ec_task_info_t Successful
+ * @retval NULL Fail
+ */
+ec_task_info_t *ec_task_info_pool_search_task_info(ec_task_info_pool_t * task_info_pool, sync_agent_ec_uint msg_type);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_INFO_POOL_H_ */
diff --git a/src/framework/engine-controller/task_message.c b/src/framework/engine-controller/task_message.c
new file mode 100755 (executable)
index 0000000..a51e302
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/task_message.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+/* lower priority, more urgent */
+sync_agent_ec_uint ec_task_state_priority(ec_task_state_t state)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_uint priority = 0;
+       switch (state) {
+       case EC_TASK_ROOT_START:
+       case EC_TASK_ROOT_DONE:
+       case EC_TASK_CANCEL:
+       case EC_TASK_CANCEL_ALL:
+               priority = 0;
+               break;
+       case EC_TASK_DONE:
+               priority = 1;
+               break;
+       case EC_TASK_START:
+               priority = 2;
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return priority;
+}
+
+sync_agent_ec_int ec_compare_priority_of_task_message_append_way(ec_task_message_t * task_message1, ec_task_message_t * task_message2, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_message1->priority < task_message2->priority) {
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       } else if (task_message1->priority == task_message2->priority) {
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       }
+}
+
+sync_agent_ec_int ec_compare_priority_of_task_message_prepend_way(ec_task_message_t * task_message1, ec_task_message_t * task_message2, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_message1->priority < task_message2->priority) {
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       }
+}
+
+ec_task_message_t *ec_task_message_create(ec_task_state_t state, ec_task_t * task, sync_agent_ec_uint request_msg_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_message_t *task_msg = (ec_task_message_t *) calloc(1, sizeof(ec_task_message_t));
+       if (task_msg == NULL) {
+               goto error_part;
+       }
+       task_msg->priority = ec_task_state_priority(state);
+       task_msg->task_state = state;
+       if (state == EC_TASK_CANCEL) {
+               task_msg->u.request_msg_id = request_msg_id;
+       } else if (state == EC_TASK_CANCEL_ALL) {
+               /* nothing */
+       } else {
+               task_msg->u.task = ec_task_ref_task(task);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_msg;
+ error_part:
+       ec_task_message_free(task_msg);
+       return NULL;
+}
+
+void ec_task_message_free(ec_task_message_t * task_msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_msg != NULL) {
+               if (task_msg->task_state != EC_TASK_CANCEL) {
+                       if (task_msg->u.task != NULL) {
+                               ec_task_unref_task(task_msg->u.task);
+                       }
+               }
+
+               free(task_msg);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/task_message.h b/src/framework/engine-controller/task_message.h
new file mode 100755 (executable)
index 0000000..1f88ca7
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_MESSAGE_H_
+#define TASK_MESSAGE_H_
+
+#include "engine-controller/task.h"
+
+/**
+ * @file               task_message.h
+ * @brief      Defines engine controller task message APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Enumeration for task state
+ */
+typedef enum ec_task_state_e ec_task_state_t;
+
+/**
+ * @brief Enumeration for task state
+ * @remarks task state also related to priority ( EC_TASK_ROOT_START == EC_TASK_ROOT_DONE == EC_TASK_CANCEL == EC_TASK_CANCEL_ALL > EC_TASK_DONE > EC_TASK_START )
+ * EC_TASK_ROOT_START, EC_TASK_CANCEL, EC_TASK_CANCEL_ALL coming from engine controller receiver, EC_TASK_START, EC_TASK_DONE, EC_TASK_ROOT_DONE coming from engine controller
+ */
+enum ec_task_state_e {
+       EC_TASK_ROOT_START = 0,         /**< root start */
+       EC_TASK_ROOT_DONE,                      /**< root done */
+       EC_TASK_CANCEL,                         /**< cancel */
+       EC_TASK_CANCEL_ALL,                     /**< cancel all */
+       EC_TASK_DONE,                           /**< task done */
+       EC_TASK_START                           /**< task start */
+};
+
+/**
+ * @brief Get state priority
+ * @remarks lower priority, more urgent
+ * @param[in] state ec_task_state_t
+ * @return priority
+ */
+sync_agent_ec_uint ec_task_state_priority(ec_task_state_t state);
+
+/**
+ * @brief Structure for task message
+ */
+typedef struct ec_task_message_s ec_task_message_t;
+
+/**
+ * @brief Structure for task message
+ */
+struct ec_task_message_s {
+       sync_agent_ec_uint priority;            /**< priority */
+       ec_task_state_t task_state;                     /**< task state */
+
+       /**
+        * @brief Union for task
+        */
+       union {
+               ec_task_t *task;                        /**< task */
+               sync_agent_ec_uint request_msg_id;      /**< request message id *//* task_state == EC_TASK_CANCEL */
+               /* nothing *//* task_state == EC_TASK_CANCEL_ALL */
+       } u;
+};
+
+/**
+ * @brief compare task message priority callback
+ * @param[in] task_message1 ec_task_message_t
+ * @param[in] task_message2 ec_task_message_t
+ * @param[in] user_data user data
+ */
+typedef sync_agent_ec_int(*ec_compare_task_msg_priority_func_cb) (ec_task_message_t * task_message1, ec_task_message_t * task_message2, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Compare priority of task message append way
+ * @param[in] task_message1 ec_task_message_t
+ * @param[in] task_message2 ec_task_message_t
+ * @param[in] user_data        user data
+ * @return results
+ * @retval -1 second parameter's priority is bigger than first parameter's priority
+ * @retval 0 Equal
+ * @retval 1 first parameter's priority is bigger than second parameter's priority
+ */
+sync_agent_ec_int ec_compare_priority_of_task_message_append_way(ec_task_message_t * task_message1, ec_task_message_t * task_message2, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Compare priority of task message prepend way
+ * @param[in] task_message1 ec_task_message_t
+ * @param[in] task_message2 ec_task_message_t
+ * @param[in] user_data        user data
+ * @return results
+ * @retval -1 second parameter's priority is bigger than first parameter's priority
+ * @retval 1 other case
+ */
+sync_agent_ec_int ec_compare_priority_of_task_message_prepend_way(ec_task_message_t * task_message1, ec_task_message_t * task_message2, sync_agent_ec_pointer user_data);
+
+/**
+ * @brief Create ec_task_message_t
+ * @param[in] state ec_task_state_t
+ * @param[in] task ec_task_t
+ * @param[in] request_msg_id request message id
+ * @return ec_task_message_t on success, NULL on fail
+ * @retval ec_task_message_t Successful
+ * @retval NULL Fail
+ */
+ec_task_message_t *ec_task_message_create(ec_task_state_t state, ec_task_t * task, sync_agent_ec_uint request_msg_id);
+
+/**
+ * @brief Free ec_task_message_t
+ * @param[in] task_msg ec_task_message_t
+ */
+void ec_task_message_free(ec_task_message_t * task_msg);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_MESSAGE_H_ */
diff --git a/src/framework/engine-controller/task_pool.c b/src/framework/engine-controller/task_pool.c
new file mode 100755 (executable)
index 0000000..fcdf659
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/task_pool.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+ec_task_pool_t *ec_task_pool_create_task_pool()
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_pool_t *task_pool = (ec_task_pool_t *) calloc(1, sizeof(ec_task_pool_t));
+       if (task_pool == NULL) {
+               goto return_part;
+       }
+
+       task_pool->task_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
+       if (task_pool->task_hash == NULL) {
+               goto error_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return task_pool;
+
+ error_part:
+       ec_task_pool_free_task_pool(task_pool);
+       return NULL;
+}
+
+void ec_task_pool_free_task_pool(ec_task_pool_t * task_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_pool != NULL) {
+               GHashTable *task_hash = task_pool->task_hash;
+               if (task_hash != NULL) {
+                       GHashTableIter iter;
+                       sync_agent_ec_int *request_msg_id_key = NULL;
+                       ec_task_t *task = NULL;
+                       g_hash_table_iter_init(&iter, task_hash);
+                       while (g_hash_table_iter_next(&iter, (void **)&request_msg_id_key, (void **)&task)) {
+                               if (task != NULL) {
+                                       ec_task_unref_task(task);
+                               }
+                       }
+
+                       g_hash_table_destroy(task_hash);
+               }
+
+               free(task_pool);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_task_pool_add_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id, ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task_pool == NULL, "ec_task_pool_t is NULL !!");
+
+       g_hash_table_insert(task_pool->task_hash, (gpointer) request_id, (gpointer) ec_task_ref_task(task));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+ec_task_t *ec_task_pool_fetch_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_pool == NULL, NULL, "ec_task_pool_t is NULL !!");
+
+       GHashTable *task_hash = task_pool->task_hash;
+       ec_task_t *task = (ec_task_t *) g_hash_table_lookup(task_hash, (gconstpointer) request_id);
+
+       if (task != NULL) {
+               _EXTERN_FUNC_EXIT;
+               return ec_task_ref_task(task);
+       } else {
+               return NULL;
+       }
+}
+
+GList *ec_task_pool_fetch_all_tasks(ec_task_pool_t * task_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(task_pool == NULL, NULL, "ec_task_pool_t is NULL !!");
+
+       GList *all_task_list = g_hash_table_get_values(task_pool->task_hash);
+       GList *iter = NULL;
+       ec_task_t *task = NULL;
+       for (iter = all_task_list; iter != NULL; iter = g_list_next(iter)) {
+               task = iter->data;
+               ec_task_ref_task(task);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return all_task_list;
+}
+
+void ec_task_pool_remove_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(task_pool == NULL, "ec_task_pool_t is NULL !!");
+
+       GHashTable *task_hash = task_pool->task_hash;
+       ec_task_t *task = (ec_task_t *) g_hash_table_lookup(task_hash, (gconstpointer) request_id);
+       if (task != NULL) {
+               ec_task_unref_task(task);
+               g_hash_table_remove(task_hash, (gconstpointer) request_id);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/task_pool.h b/src/framework/engine-controller/task_pool.h
new file mode 100755 (executable)
index 0000000..894d3f7
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_POOL_H_
+#define TASK_POOL_H_
+
+#include <glib.h>
+#include <stdbool.h>
+#include "engine-controller/task.h"
+
+/**
+ * @file               task_pool.h
+ * @brief      Defines engine controller task pool APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for task pool
+ */
+typedef struct ec_task_pool_s ec_task_pool_t;
+
+/**
+ * @brief Structure for task pool
+ * @remarks it contains only root task
+ */
+struct ec_task_pool_s {
+       GHashTable *task_hash;  /**< key : sync_agent_ec_uint (request_id)
+                                  value : ec_task_t* */
+};
+
+/**
+ * @brief Create task pool
+ * @return ec_task_pool_t on success, NULL on fail
+ * @retval ec_task_pool_t Successful
+ * @retval NULL Fail
+ */
+ec_task_pool_t *ec_task_pool_create_task_pool();
+
+/**
+ * @brief Free task pool
+ * @param[in] task_pool ec_task_pool_t
+ */
+void ec_task_pool_free_task_pool(ec_task_pool_t * task_pool);
+
+/**
+ * @brief Add task
+ * @param[in] task_pool ec_task_pool_t
+ * @param[in] request_id request id
+ * @param[in] task ec_task_t
+ */
+void ec_task_pool_add_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id, ec_task_t * task);
+
+/**
+ * @brief Fetch task
+ * @param[in] task_pool ec_task_pool_t
+ * @param[in] request_id request id
+ * @return ec_task_t on success, NULL on fail
+ * @retval ec_task_t Successful
+ * @retval NULL Fail
+ */
+ec_task_t *ec_task_pool_fetch_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id);
+
+/**
+ * @brief Fetch all tasks
+ * @param[in] task_pool ec_task_pool_t
+ * @return ec_task_t list on success, NULL on fail
+ * @retval ec_task_t list Successful
+ * @retval NULL Fail
+ */
+GList *ec_task_pool_fetch_all_tasks(ec_task_pool_t * task_pool);
+
+/**
+ * @brief remove task
+ * @param[in] task_pool ec_task_pool_t
+ * @param[in] request_id request id
+ */
+void ec_task_pool_remove_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_POOL_H_ */
diff --git a/src/framework/engine-controller/task_process.c b/src/framework/engine-controller/task_process.c
new file mode 100755 (executable)
index 0000000..9db3505
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include "engine-controller/task_process.h"
+#include "engine-controller/task_cancel_info.h"
+#include "utility/sync_util.h"
+#include "utility/fw_assert.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_EC"
+#endif
+
+extern GPrivate *ec_cancel_task;
+
+EXPORT_API sync_agent_ec_boolean sync_agent_check_cancel_flag(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_cancel_info_t *cancel_info = g_private_get(ec_cancel_task);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_cancel_info_get_cancel_flag_atomic(cancel_info);
+}
+
+EXPORT_API void sync_agent_register_cancel_callback(sync_agent_process_cancel_cb callback_func, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_cancel_info_t *cancel_info = g_private_get(ec_cancel_task);
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_lock(cancel_info->cancel_info_mutex);
+#else
+       g_mutex_lock(&(cancel_info->cancel_info_mutex));
+#endif
+       if (!ec_task_cancel_info_get_cancel_flag_atomic(cancel_info)) {
+               _DEBUG_INFO("cancel flag is off. Register cancel callback\n");
+               sync_agent_ec_error_e ec_error = ec_task_cancel_info_register_cancel_callback_unlocked(cancel_info, callback_func, user_data);
+               SYNC_AGENT_UTIL_ASSERT_CONDITION(ec_error == SYNC_AGENT_EC_OK, "ec_task_cancel_info_register_cancel_callback_unlocked failed\n");
+       } else {
+               _DEBUG_INFO("cancel flag is on. Do nothing\n");
+       }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_unlock(cancel_info->cancel_info_mutex);
+#else
+       g_mutex_unlock(&(cancel_info->cancel_info_mutex));
+#endif
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_unregister_cancel_callback(sync_agent_process_cancel_cb callback_func, sync_agent_ec_pointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_cancel_info_t *cancel_info = g_private_get(ec_cancel_task);
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_lock(cancel_info->cancel_info_mutex);
+#else
+       g_mutex_lock(&(cancel_info->cancel_info_mutex));
+#endif
+       if (!ec_task_cancel_info_get_cancel_flag_atomic(cancel_info)) {
+               _DEBUG_INFO("cancel flag is off. Unregister cancel callback\n");
+               sync_agent_ec_error_e ec_error = ec_task_cancel_info_unregister_cancel_callback_unlocked(cancel_info, callback_func, user_data);
+               SYNC_AGENT_UTIL_ASSERT_CONDITION(ec_error == SYNC_AGENT_EC_OK, "ec_task_cancel_info_unregister_cancel_callback_unlocked failed\n");
+       } else {
+               _DEBUG_INFO("cancel flag is on. Do nothing\n");
+       }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_mutex_unlock(cancel_info->cancel_info_mutex);
+#else
+       g_mutex_unlock(&(cancel_info->cancel_info_mutex));
+#endif
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_ec_int sync_agent_get_self_request_id(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ec_task_cancel_info_t *cancel_info = g_private_get(ec_cancel_task);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ec_task_cancel_info_get_request_msg_id(cancel_info);
+}
diff --git a/src/framework/engine-controller/task_spec.c b/src/framework/engine-controller/task_spec.c
new file mode 100755 (executable)
index 0000000..e2bccfb
--- /dev/null
@@ -0,0 +1,1268 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "utility/sync_util.h"
+#include "engine-controller/task_spec.h"
+#include "engine-controller/task_spec_internal.h"
+#include "engine-controller/param_spec_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+static sync_agent_ec_task_spec_s *_task_spec_new_default_task_spec(sync_agent_ec_char * task_name, sync_agent_ec_pointer post_task_func_usr_data, sync_agent_post_task_cb post_task_callback, sync_agent_ec_uint param_cnt,
+                                                                  sync_agent_ec_param_spec_s ** param_spec_array);
+static void _task_spec_free_task_spec(sync_agent_ec_task_spec_s * task_spec);
+
+static ec_child_tasks_info_t *_task_spec_new_child_tasks_info(sync_agent_ec_uint parent_param_cnt, sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array);
+
+static void __task_spec_free_child_tasks_info(ec_child_tasks_info_t * child_task_info);
+
+static ec_dynamic_container_task_specific_t *_task_spec_new_dynamic_container_task_specific(sync_agent_ec_uint parent_param_cnt, sync_agent_calculate_case_cb calculate_case_func, sync_agent_ec_uint case_cnt, sync_agent_ec_int * case_array,
+                                                                                           sync_agent_ec_uint * child_task_cnt_array, sync_agent_ec_task_spec_s *** child_task_array_per_case_array);
+
+static void __task_spec_free_dynamic_container_task_specific(ec_dynamic_container_task_specific_t * pDynamic_container_task_specific);
+
+static sync_agent_ec_param_spec_s *__task_spec_find_param_spec(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int param_index);
+
+static sync_agent_ec_error_e __task_spec_validate_container_task_spec(sync_agent_ec_task_spec_s * container_task_spec);
+
+static sync_agent_ec_error_e _task_spec_validate_dynamic_container_task_spec(sync_agent_ec_task_spec_s * dynamic_container_task_spec);
+
+static sync_agent_ec_error_e __task_spec_validate_param_index(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int param_index);
+
+static sync_agent_ec_error_e _task_spec_validate_set_control_flow_input_parameters(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index);
+
+static sync_agent_ec_error_e _task_spec_validate_set_control_flow_input_parameters_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index);
+
+static sync_agent_ec_error_e _task_spec_validate_set_data_flow_input_parameters(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index,
+                                                                               sync_agent_ec_int to_param_index);
+
+static sync_agent_ec_error_e _task_spec_validate_set_data_flow_input_parameters_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index,
+                                                                                               sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index);
+
+ec_data_flow_edges_t *ec_data_flow_edges_new(sync_agent_ec_int parent_task_param_cnt, sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_int total_param_cnt = 0;
+
+       ec_data_flow_edges_t *data_flow_edges = (ec_data_flow_edges_t *) calloc(1, sizeof(ec_data_flow_edges_t));
+       if (data_flow_edges == NULL) {
+               goto error_part;
+       }
+
+       data_flow_edges->child_task_param_start_index_array = (sync_agent_ec_int *) calloc(child_task_cnt, sizeof(sync_agent_ec_int));
+       if (data_flow_edges->child_task_param_start_index_array == NULL) {
+               goto error_part;
+       }
+
+       /* compute total param cnt and child_task_param_start_index_array */
+       total_param_cnt = parent_task_param_cnt;
+       for (i = 0; i < child_task_cnt; i++) {
+               data_flow_edges->child_task_param_start_index_array[i] = total_param_cnt;
+               total_param_cnt += child_task_array[i]->task_param_cnt;
+       }
+
+       data_flow_edges->child_task_cnt = child_task_cnt;
+       data_flow_edges->total_param_cnt = total_param_cnt;
+
+       sync_agent_ec_int *from_param_array = (sync_agent_ec_int *) malloc(total_param_cnt * sizeof(sync_agent_ec_int));
+       if (from_param_array == NULL) {
+               goto error_part;
+       }
+
+       data_flow_edges->from_param_array = from_param_array;
+       for (i = 0; i < total_param_cnt; i++) {
+               from_param_array[i] = -1;       /* when -1, no from_param exist */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return data_flow_edges;
+
+ error_part:
+       ec_data_flow_edges_free(data_flow_edges);
+       return NULL;
+}
+
+void ec_data_flow_edges_free(ec_data_flow_edges_t * data_flow_edges)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (data_flow_edges != NULL) {
+               if (data_flow_edges->child_task_param_start_index_array != NULL) {
+                       free(data_flow_edges->child_task_param_start_index_array);
+               }
+
+               if (data_flow_edges->from_param_array != NULL) {
+                       free(data_flow_edges->from_param_array);
+               }
+
+               free(data_flow_edges);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_int ec_data_flow_edges_compute_internal_index(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int task_index, sync_agent_ec_int param_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_int *child_task_param_start_index_array = data_flow_edges->child_task_param_start_index_array;
+
+       if (task_index == -1) {
+               _EXTERN_FUNC_EXIT;
+               return param_index;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return param_index + child_task_param_start_index_array[task_index];
+       }
+}
+
+sync_agent_ec_boolean ec_data_flow_edges_compute_task_index_and_param_index(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int internal_index, sync_agent_ec_int * pTask_index, sync_agent_ec_int * pParam_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(data_flow_edges == NULL, false, "ec_data_flow_edges_t is NULL !!");
+
+       sync_agent_ec_boolean valid_internal_index = false;
+       sync_agent_ec_int task_index = -1;
+       sync_agent_ec_int param_index = -1;
+       sync_agent_ec_int i = 0;
+
+       if (internal_index >= 0 && internal_index < data_flow_edges->total_param_cnt) {
+               valid_internal_index = true;
+
+               for (i = 0; i < data_flow_edges->child_task_cnt; i++) {
+                       if (internal_index < data_flow_edges->child_task_param_start_index_array[i]) {
+                               task_index = i - 1;
+
+                               if (i == 0) {
+                                       param_index = internal_index;
+                               } else {
+                                       param_index = internal_index - data_flow_edges->child_task_param_start_index_array[i - 1];
+                               }
+                               break;
+                       }
+               }
+
+               if (i == data_flow_edges->child_task_cnt) {
+                       task_index = i - 1;
+                       param_index = internal_index - data_flow_edges->child_task_param_start_index_array[i - 1];
+               }
+
+               *pTask_index = task_index;
+               *pParam_index = param_index;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return valid_internal_index;
+}
+
+sync_agent_ec_boolean ec_data_flow_edges_add_edge(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_boolean success = false;
+
+       sync_agent_ec_int from_param_internal_index = ec_data_flow_edges_compute_internal_index(data_flow_edges, from_task_index, from_param_index);
+       sync_agent_ec_int to_param_internal_index = ec_data_flow_edges_compute_internal_index(data_flow_edges, to_task_index, to_param_index);
+
+       /* record edge */
+       if (data_flow_edges->from_param_array[to_param_internal_index] == -1) { /* -1 means no from param exist */
+               success = true;
+               data_flow_edges->from_param_array[to_param_internal_index] = from_param_internal_index;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+/* TODO : make this function accessible by other operation file */
+sync_agent_ec_boolean ec_data_flow_edges_get_from_param_info(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index, sync_agent_ec_int * from_task_index, sync_agent_ec_int * from_param_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_boolean from_part_exist = false;
+
+       sync_agent_ec_int to_internal_index = ec_data_flow_edges_compute_internal_index(data_flow_edges, to_task_index, to_param_index);
+       sync_agent_ec_int from_internal_index = data_flow_edges->from_param_array[to_internal_index];
+       if (from_internal_index != -1) {
+               ec_data_flow_edges_compute_task_index_and_param_index(data_flow_edges, from_internal_index, from_task_index, from_param_index);
+               from_part_exist = true;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return from_part_exist;
+}
+
+sync_agent_ec_task_spec_s *ec_get_child_task_spec_from_child_task_info(ec_child_tasks_info_t * child_tasks_info, sync_agent_ec_uint child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(child_tasks_info == NULL, NULL, "ec_child_tasks_info_t is NULL !!");
+
+       if (0 <= child_task_index && child_task_index < child_tasks_info->child_task_cnt) {
+               _EXTERN_FUNC_EXIT;
+               return child_tasks_info->child_task_array[child_task_index];
+       } else {
+               return NULL;
+       }
+}
+
+sync_agent_ec_uint *ec_task_spec_duplicate_child_task_control_flow_in_degree(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_uint *duplcated_child_task_control_flow_in_degree = NULL;
+
+       if (!ec_task_spec_is_container(task_spec)) {
+               goto error_part;
+       }
+
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_child_tasks_info(task_spec);
+
+       retvm_if(child_task_info == NULL, NULL, "ec_child_tasks_info_t is NULL !!");
+
+       sync_agent_ec_uint child_task_cnt = child_task_info->child_task_cnt;
+       sync_agent_ec_uint *child_task_control_flow_in_degree = child_task_info->child_task_control_flow_in_degree;
+
+       duplcated_child_task_control_flow_in_degree = (sync_agent_ec_uint *) malloc(child_task_cnt * sizeof(sync_agent_ec_uint));
+       if (duplcated_child_task_control_flow_in_degree == NULL) {
+               goto error_part;
+       }
+
+       memcpy(duplcated_child_task_control_flow_in_degree, child_task_control_flow_in_degree, child_task_cnt * sizeof(sync_agent_ec_uint));
+
+       _EXTERN_FUNC_EXIT;
+
+       return duplcated_child_task_control_flow_in_degree;
+
+ error_part:
+
+       return NULL;
+}
+
+sync_agent_ec_uint *ec_task_spec_duplicate_child_task_control_flow_in_degree_on_dynamic_case(sync_agent_ec_task_spec_s * dynamic_task_spec, sync_agent_ec_int dynamic_case)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_uint *duplcated_child_task_control_flow_in_degree = NULL;
+
+       if (!ec_task_spec_is_dynamic_container(dynamic_task_spec)) {
+               goto error_part;
+       }
+
+       sync_agent_ec_uint child_task_cnt;
+       sync_agent_ec_uint *child_task_control_flow_in_degree;
+
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_case_specific_child_tasks_info(dynamic_task_spec, dynamic_case);
+       if (child_task_info != NULL) {
+               child_task_cnt = child_task_info->child_task_cnt;
+               child_task_control_flow_in_degree = child_task_info->child_task_control_flow_in_degree;
+       } else {
+               goto error_part;
+       }
+
+       duplcated_child_task_control_flow_in_degree = (sync_agent_ec_uint *) malloc(child_task_cnt * sizeof(sync_agent_ec_uint));
+       if (duplcated_child_task_control_flow_in_degree == NULL) {
+               goto error_part;
+       }
+
+       memcpy(duplcated_child_task_control_flow_in_degree, child_task_control_flow_in_degree, child_task_cnt * sizeof(sync_agent_ec_uint));
+
+       _EXTERN_FUNC_EXIT;
+
+       return duplcated_child_task_control_flow_in_degree;
+
+ error_part:
+
+       return NULL;
+}
+
+static sync_agent_ec_task_spec_s *_task_spec_new_default_task_spec(sync_agent_ec_char * task_name, sync_agent_ec_pointer post_task_func_usr_data, sync_agent_post_task_cb post_task_callback, sync_agent_ec_uint param_cnt,
+                                                                  sync_agent_ec_param_spec_s ** param_spec_array)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(task_name == NULL, NULL, "sync_agent_ec_char is NULL !!");
+
+       int i = 0;
+       sync_agent_ec_task_spec_s *task = NULL;
+
+       /* TODO : input parameter validation */
+
+       task = (sync_agent_ec_task_spec_s *) calloc(1, sizeof(sync_agent_ec_task_spec_s));
+       if (task == NULL) {
+               goto return_part;
+       }
+
+       task->task_name = strdup(task_name);
+       if (task->task_name == NULL) {
+               goto error_part;
+       }
+
+       task->task_param_spec_array = (sync_agent_ec_param_spec_s **) calloc(param_cnt, sizeof(sync_agent_ec_param_spec_s *));
+       if (task->task_param_spec_array == NULL) {
+               goto error_part;
+       }
+
+       task->task_param_cnt = param_cnt;
+       for (i = 0; i < param_cnt; i++) {
+               task->task_param_spec_array[i] = ec_ref_param_spec(param_spec_array[i]);
+       }
+
+       task->usr_post_task_func_data = post_task_func_usr_data;
+       task->post_func = post_task_callback;
+       task->ref_count = 1;
+
+ return_part:
+       _INNER_FUNC_EXIT;
+       return task;
+
+ error_part:
+       _task_spec_free_task_spec(task);
+       return NULL;
+}
+
+static void _task_spec_free_task_spec(sync_agent_ec_task_spec_s * task_spec)
+{
+       _INNER_FUNC_ENTER;
+
+       if (task_spec != NULL) {
+               if (task_spec->task_name != NULL) {
+                       free(task_spec->task_name);
+               }
+
+               if (task_spec->task_param_cnt > 0) {
+                       int i = 0;
+                       for (i = 0; i < task_spec->task_param_cnt; i++) {
+                               sync_agent_unref_param_spec(task_spec->task_param_spec_array[i]);
+                       }
+               }
+
+               /* TODO : child_parallel_task_list when container task */
+               /* TODO : usr_task_data */
+
+               free(task_spec);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static ec_child_tasks_info_t *_task_spec_new_child_tasks_info(sync_agent_ec_uint parent_param_cnt, sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_uint i = 0;
+       ec_child_tasks_info_t *child_task_info = (ec_child_tasks_info_t *) calloc(1, sizeof(ec_child_tasks_info_t));
+       if (child_task_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+
+       child_task_info->child_task_cnt = child_task_cnt;
+       child_task_info->child_task_array = (sync_agent_ec_task_spec_s **) calloc(child_task_cnt, sizeof(sync_agent_ec_task_spec_s *));
+       if (child_task_info->child_task_array == NULL) {
+               goto error_part;
+       }
+
+       for (i = 0; i < child_task_cnt; i++) {
+               child_task_info->child_task_array[i] = ec_task_spec_ref(child_task_array[i]);
+       }
+
+       child_task_info->child_task_control_flow_in_degree = (sync_agent_ec_uint *) calloc(child_task_cnt, sizeof(sync_agent_ec_uint));
+       if (child_task_info->child_task_control_flow_in_degree == NULL) {
+               goto error_part;
+       }
+
+       child_task_info->control_edge_pool = ec_graph_edge_pool_new();
+       if (child_task_info->control_edge_pool == NULL) {
+               goto error_part;
+       }
+
+       child_task_info->data_flow_edges = ec_data_flow_edges_new(parent_param_cnt, child_task_cnt, child_task_array);
+       if (child_task_info->data_flow_edges == NULL) {
+               goto error_part;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return child_task_info;
+
+ error_part:
+       __task_spec_free_child_tasks_info(child_task_info);
+       return NULL;
+}
+
+static void __task_spec_free_child_tasks_info(ec_child_tasks_info_t * child_task_info)
+{
+       _INNER_FUNC_ENTER;
+
+       if (child_task_info != NULL) {
+               sync_agent_ec_uint cnt = child_task_info->child_task_cnt;
+               sync_agent_ec_uint i = 0;
+
+               if (child_task_info->data_flow_edges != NULL) {
+                       ec_data_flow_edges_free(child_task_info->data_flow_edges);
+               }
+
+               if (child_task_info->control_edge_pool != NULL) {
+                       ec_graph_edge_pool_free(child_task_info->control_edge_pool);
+               }
+
+               if (child_task_info->child_task_control_flow_in_degree != NULL) {
+                       free(child_task_info->child_task_control_flow_in_degree);
+               }
+
+               if (child_task_info->child_task_array != NULL) {
+                       for (i = 0; i < cnt; i++) {
+                               ec_task_spec_unref(child_task_info->child_task_array[i]);
+                       }
+                       free(child_task_info->child_task_array);
+               }
+
+               free(child_task_info);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static ec_dynamic_container_task_specific_t *_task_spec_new_dynamic_container_task_specific(sync_agent_ec_uint parent_param_cnt, sync_agent_calculate_case_cb calculate_case_func, sync_agent_ec_uint case_cnt, sync_agent_ec_int * case_array,
+                                                                                           sync_agent_ec_uint * child_task_cnt_array, sync_agent_ec_task_spec_s *** child_task_array_per_case_array)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(case_array == NULL, NULL, "sync_agent_ec_int is NULL !!");
+       retvm_if(child_task_cnt_array == NULL, NULL, "sync_agent_ec_uint is NULL !!");
+
+       sync_agent_ec_uint i = 0;
+       ec_dynamic_container_task_specific_t *pDynamic_container_task_specific = (ec_dynamic_container_task_specific_t *) calloc(1, sizeof(ec_dynamic_container_task_specific_t));
+       if (pDynamic_container_task_specific == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+
+       pDynamic_container_task_specific->calculate_case_func = calculate_case_func;
+       pDynamic_container_task_specific->case_cnt = case_cnt;
+       pDynamic_container_task_specific->case_array = (sync_agent_ec_int *) malloc(case_cnt * sizeof(sync_agent_ec_int));
+       if (pDynamic_container_task_specific->case_array == NULL) {
+               goto error_part;
+       }
+       memcpy(pDynamic_container_task_specific->case_array, case_array, case_cnt * sizeof(sync_agent_ec_int));
+
+       pDynamic_container_task_specific->case_specific_child_task_info_array = (ec_child_tasks_info_t **) calloc(case_cnt, sizeof(ec_child_tasks_info_t *));
+       if (pDynamic_container_task_specific->case_specific_child_task_info_array == NULL) {
+               goto error_part;
+       }
+
+       for (i = 0; i < case_cnt; i++) {
+               pDynamic_container_task_specific->case_specific_child_task_info_array[i] = _task_spec_new_child_tasks_info(parent_param_cnt, child_task_cnt_array[i], child_task_array_per_case_array[i]);
+               if (pDynamic_container_task_specific->case_specific_child_task_info_array[i] == NULL) {
+                       goto error_part;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pDynamic_container_task_specific;
+
+ error_part:
+       __task_spec_free_dynamic_container_task_specific(pDynamic_container_task_specific);
+       return NULL;
+}
+
+static void __task_spec_free_dynamic_container_task_specific(ec_dynamic_container_task_specific_t * pDynamic_container_task_specific)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pDynamic_container_task_specific != NULL) {
+               if (pDynamic_container_task_specific->case_array != NULL)
+                       free(pDynamic_container_task_specific->case_array);
+               int i = 0;
+               if (pDynamic_container_task_specific->case_specific_child_task_info_array != NULL && pDynamic_container_task_specific->case_cnt > 0) {
+                       for (i = 0; i < pDynamic_container_task_specific->case_cnt; i++) {
+                               __task_spec_free_child_tasks_info(pDynamic_container_task_specific->case_specific_child_task_info_array[i]);
+                       }
+                       free(pDynamic_container_task_specific->case_specific_child_task_info_array);
+               }
+               free(pDynamic_container_task_specific);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+ec_child_tasks_info_t *ec_task_spec_find_child_tasks_info(sync_agent_ec_task_spec_s * parent_container_task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_container_task_spec == NULL, NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return parent_container_task_spec->u.container_task_specific;
+}
+
+ec_child_tasks_info_t *ec_task_spec_find_case_specific_child_tasks_info(sync_agent_ec_task_spec_s * parent_dynamic_task_spec, sync_agent_ec_int dynamic_case)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_dynamic_task_spec == NULL, NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       ec_child_tasks_info_t *child_task_info = NULL;
+
+       ec_dynamic_container_task_specific_t *dynmaic_container_task_specific = parent_dynamic_task_spec->u.dynmaic_container_task_specific;
+       sync_agent_ec_uint case_cnt = dynmaic_container_task_specific->case_cnt;
+       sync_agent_ec_int *case_array = dynmaic_container_task_specific->case_array;
+       ec_child_tasks_info_t **case_specific_child_task_info_array = dynmaic_container_task_specific->case_specific_child_task_info_array;
+
+       sync_agent_ec_uint i = 0;
+       for (i = 0; i < case_cnt; i++) {
+               if (case_array[i] == dynamic_case) {
+                       child_task_info = case_specific_child_task_info_array[i];
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_task_info;
+}
+
+static sync_agent_ec_param_spec_s *__task_spec_find_param_spec(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int param_index)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(task_spec == NULL, NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       sync_agent_ec_param_spec_s *pParam_spec = NULL;
+       sync_agent_ec_int param_cnt = ec_task_spec_get_param_cnt(task_spec);
+       sync_agent_ec_param_spec_s **param_spec_array = task_spec->task_param_spec_array;
+
+       if (param_index >= 0 && param_index < param_cnt) {
+               pParam_spec = param_spec_array[param_index];
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pParam_spec;
+}
+
+static sync_agent_ec_error_e __task_spec_validate_container_task_spec(sync_agent_ec_task_spec_s * container_task_spec)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+       if (container_task_spec == NULL) {
+               err = SYNC_AGENT_EC_INVALID_TASK;
+               goto error_part;
+       }
+
+       if (container_task_spec->task_type != EC_TASK_CONTAINER) {
+               if (container_task_spec->task_type == EC_TASK_SIMPLE || container_task_spec->task_type == EC_TASK_DYNAMIC_CONTAINER) {
+                       err = SYNC_AGENT_EC_MUST_USE_CONTAINER_TASK;
+               } else {
+                       err = SYNC_AGENT_EC_INVALID_TASK;
+               }
+               goto error_part;
+       }
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+static sync_agent_ec_error_e _task_spec_validate_dynamic_container_task_spec(sync_agent_ec_task_spec_s * dynamic_container_task_spec)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+       if (dynamic_container_task_spec == NULL) {
+               err = SYNC_AGENT_EC_INVALID_TASK;
+               goto error_part;
+       }
+
+       if (dynamic_container_task_spec->task_type != EC_TASK_DYNAMIC_CONTAINER) {
+               if (dynamic_container_task_spec->task_type == EC_TASK_SIMPLE || dynamic_container_task_spec->task_type == EC_TASK_CONTAINER) {
+                       err = SYNC_AGENT_EC_MUST_USE_DYNAMIC_CONTAINER_TASK;
+               } else {
+                       err = SYNC_AGENT_EC_INVALID_TASK;
+               }
+               goto error_part;
+       }
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+/*
+sync_agent_ec_error_e task_spec_attach_queuing_rule_spec(sync_agent_ec_task_spec_s* spec, sync_agent_ec_queuing_rule_spec_s* queuing_rule_spec)
+{
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+       GSList* listnode = g_slist_find(spec->queuing_rule_spec_list, queuing_rule_spec);
+       if (listnode != NULL) {
+               err = SYNC_AGENT_EC_DUPLICATE_QUEUING_RULE_SPEC;
+               goto error_part;
+       }
+
+       spec->queuing_rule_spec_list = g_slist_prepend(spec->queuing_rule_spec_list, ec_ref_queuing_rule_spec(queuing_rule_spec));
+
+       error_part:
+       return err;
+}
+*/
+
+sync_agent_ec_error_e ec_task_spec_valididate_child_task_index(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       sync_agent_ec_task_spec_s *child_task_spec = ec_task_spec_get_child_task_spec(container_task_spec, child_task_index);
+       if (child_task_spec == NULL) {
+               err = SYNC_AGENT_EC_INVALID_CHILD_TASK_INDEX;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+sync_agent_ec_error_e ec_task_spec_valididate_child_task_index_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       sync_agent_ec_task_spec_s *child_task_spec = ec_task_spec_get_child_task_spec_on_dynamic_case(dynamic_case,
+                                                                                                     dynamic_container_task_spec,
+                                                                                                     child_task_index);
+       if (child_task_spec == NULL) {
+               err = SYNC_AGENT_EC_INVALID_CHILD_TASK_INDEX;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_ec_error_e __task_spec_validate_param_index(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int param_index)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       sync_agent_ec_param_spec_s *pParam_spec = __task_spec_find_param_spec(task_spec, param_index);
+       if (pParam_spec == NULL) {
+               err = SYNC_AGENT_EC_INVALID_PARAM_INDEX;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_ec_error_e _task_spec_validate_set_control_flow_input_parameters(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = __task_spec_validate_container_task_spec(container_task_spec);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       err = ec_task_spec_valididate_child_task_index(container_task_spec, from_task_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       err = ec_task_spec_valididate_child_task_index(container_task_spec, to_task_index);
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+static sync_agent_ec_error_e _task_spec_validate_set_control_flow_input_parameters_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = _task_spec_validate_dynamic_container_task_spec(dynamic_container_task_spec);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       err = ec_task_spec_valididate_child_task_index_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       err = ec_task_spec_valididate_child_task_index_on_dynamic_case(dynamic_case, dynamic_container_task_spec, to_task_index);
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+static sync_agent_ec_error_e _task_spec_validate_set_data_flow_input_parameters(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index,
+                                                                               sync_agent_ec_int to_param_index)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = __task_spec_validate_container_task_spec(container_task_spec);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       sync_agent_ec_task_spec_s *pFrom_task_spec = NULL;
+       sync_agent_ec_task_spec_s *pTo_task_spec = NULL;
+       if (from_task_index != -1) {
+               err = ec_task_spec_valididate_child_task_index(container_task_spec, from_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+
+               pFrom_task_spec = ec_task_spec_get_child_task_spec(container_task_spec, from_task_index);
+       } else {
+               pFrom_task_spec = container_task_spec;
+       }
+       err = __task_spec_validate_param_index(pFrom_task_spec, from_param_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       if (to_task_index != -1) {
+               err = ec_task_spec_valididate_child_task_index(container_task_spec, to_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+
+               pTo_task_spec = ec_task_spec_get_child_task_spec(container_task_spec, to_task_index);
+       } else {
+               pTo_task_spec = container_task_spec;
+       }
+       err = __task_spec_validate_param_index(pTo_task_spec, to_param_index);
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+static sync_agent_ec_error_e _task_spec_validate_set_data_flow_input_parameters_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index,
+                                                                                               sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = _task_spec_validate_dynamic_container_task_spec(dynamic_container_task_spec);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       sync_agent_ec_task_spec_s *pFrom_task_spec = NULL;
+       sync_agent_ec_task_spec_s *pTo_task_spec = NULL;
+       if (from_task_index != -1) {
+               err = ec_task_spec_valididate_child_task_index_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+
+               pFrom_task_spec = ec_task_spec_get_child_task_spec_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index);
+       } else {
+               pFrom_task_spec = dynamic_container_task_spec;
+       }
+       err = __task_spec_validate_param_index(pFrom_task_spec, from_param_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       if (to_task_index != -1) {
+               err = ec_task_spec_valididate_child_task_index_on_dynamic_case(dynamic_case, dynamic_container_task_spec, to_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+
+               pTo_task_spec = ec_task_spec_get_child_task_spec_on_dynamic_case(dynamic_case, dynamic_container_task_spec, to_task_index);
+       } else {
+               pTo_task_spec = dynamic_container_task_spec;
+       }
+       err = __task_spec_validate_param_index(pTo_task_spec, to_param_index);
+
+       _INNER_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+EXPORT_API sync_agent_ec_task_spec_s *sync_agent_alloc_simple_task_spec(sync_agent_ec_char * task_name, sync_agent_task_process_cb task_process, sync_agent_ec_pointer post_task_func_usr_data, sync_agent_post_task_cb post_task_callback,
+                                                                       sync_agent_ec_uint param_cnt, sync_agent_ec_param_spec_s ** param_spec_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_spec_s *task = NULL;
+
+       task = _task_spec_new_default_task_spec(task_name, post_task_func_usr_data, post_task_callback, param_cnt, param_spec_array);
+
+       if (task == NULL) {
+               return NULL;
+       }
+       task->task_type = EC_TASK_SIMPLE;
+       task->u.task_process = task_process;
+
+       _EXTERN_FUNC_EXIT;
+
+       return task;
+}
+
+sync_agent_ec_task_spec_s *ec_task_spec_ref(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL) {
+               return NULL;
+       }
+
+       g_atomic_int_inc(&(task_spec->ref_count));
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_spec;
+}
+
+void ec_task_spec_unref(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL) {
+               return;
+       }
+
+       if (g_atomic_int_dec_and_test(&(task_spec->ref_count))) {
+               _task_spec_free_task_spec(task_spec);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_ec_boolean ec_task_spec_is_same(sync_agent_ec_task_spec_s * task_spec1, sync_agent_ec_task_spec_s * task_spec2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec1 == task_spec2) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+sync_agent_ec_boolean ec_task_spec_is_simple(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL) {
+               _DEBUG_INFO("task_spec == NULL\n");
+               return false;
+       }
+
+       if (task_spec->task_type == EC_TASK_SIMPLE) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+sync_agent_ec_boolean ec_task_spec_is_container(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL) {
+               _DEBUG_INFO("task_spec == NULL\n");
+               return false;
+       }
+
+       if (task_spec->task_type == EC_TASK_CONTAINER) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+sync_agent_ec_boolean ec_task_spec_is_dynamic_container(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL) {
+               _DEBUG_INFO("task_spec == NULL\n");
+               return false;
+       }
+
+       if (task_spec->task_type == EC_TASK_DYNAMIC_CONTAINER) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+sync_agent_ec_uint ec_task_spec_get_child_task_cnt(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (ec_task_spec_is_container(task_spec)) {
+               _EXTERN_FUNC_EXIT;
+               return task_spec->u.container_task_specific->child_task_cnt;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+}
+
+sync_agent_ec_task_spec_s *ec_task_spec_get_child_task_spec(sync_agent_ec_task_spec_s * parent_task_spec, sync_agent_ec_int child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_spec_s *child_task_spec = NULL;
+
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_child_tasks_info(parent_task_spec);
+
+       retvm_if(child_task_info == NULL, NULL, "ec_child_tasks_info_t is NULL !!");
+
+       child_task_spec = ec_get_child_task_spec_from_child_task_info(child_task_info, child_task_index);
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_task_spec;
+}
+
+sync_agent_ec_uint ec_task_spec_get_child_task_cnt_on_dynamic_case(sync_agent_ec_task_spec_s * dynamic_task_spec, sync_agent_ec_int dynamic_case)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (ec_task_spec_is_dynamic_container(dynamic_task_spec)) {
+               ec_child_tasks_info_t *child_task_info = ec_task_spec_find_case_specific_child_tasks_info(dynamic_task_spec, dynamic_case);
+               if (child_task_info != NULL) {
+                       _EXTERN_FUNC_EXIT;
+                       return child_task_info->child_task_cnt;
+               } else {
+                       _EXTERN_FUNC_EXIT;
+                       return 0;
+               }
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+}
+
+sync_agent_ec_task_spec_s *ec_task_spec_get_child_task_spec_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * parent_dynamic_task_spec, sync_agent_ec_int child_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_spec_s *child_task_spec = NULL;
+
+       sync_agent_ec_error_e ec_error = _task_spec_validate_dynamic_container_task_spec(parent_dynamic_task_spec);
+       if (ec_error != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_case_specific_child_tasks_info(parent_dynamic_task_spec, dynamic_case);
+       child_task_spec = ec_get_child_task_spec_from_child_task_info(child_task_info, child_task_index);
+
+       _EXTERN_FUNC_EXIT;
+
+       return child_task_spec;
+
+ error_part:
+       return NULL;
+}
+
+sync_agent_ec_int ec_task_spec_get_param_cnt(sync_agent_ec_task_spec_s * task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_spec->task_param_cnt;
+}
+
+sync_agent_calculate_case_cb ec_task_spec_get_calculate_case_callback_func(sync_agent_ec_task_spec_s * dynamic_container_task_spec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(dynamic_container_task_spec == NULL, NULL, "sync_agent_ec_task_spec_s is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return dynamic_container_task_spec->u.dynmaic_container_task_specific->calculate_case_func;
+}
+
+sync_agent_ec_boolean ec_task_spec_get_output_param_info(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int * output_param_cnt, sync_agent_ec_int ** output_param_index_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (task_spec == NULL || output_param_cnt == NULL || output_param_index_array == NULL) {
+               goto error_part;
+       }
+
+       sync_agent_ec_int i = 0;
+       sync_agent_ec_int param_cnt = ec_task_spec_get_param_cnt(task_spec);
+       sync_agent_ec_param_spec_s **task_param_spec_array = task_spec->task_param_spec_array;
+
+       sync_agent_ec_int output_param_count = 0;
+       sync_agent_ec_int *output_param_index_arr = NULL;
+       output_param_index_arr = (sync_agent_ec_int *) calloc(param_cnt, sizeof(sync_agent_ec_int));
+       if (output_param_index_arr == NULL) {
+               goto error_part;
+       }
+
+       sync_agent_ec_param_spec_s *pParam_spec = NULL;
+       for (i = 0; i < param_cnt; i++) {
+               pParam_spec = task_param_spec_array[i];
+               if (ec_param_is_output_flag_on(pParam_spec->flags)) {
+                       output_param_index_arr[output_param_count] = i;
+                       output_param_count++;
+               }
+       }
+
+       *output_param_cnt = output_param_count;
+       *output_param_index_array = output_param_index_arr;
+
+       _EXTERN_FUNC_EXIT;
+
+       return true;
+
+ error_part:
+       return false;
+}
+
+sync_agent_ec_task_spec_s *ec_alloc_container_task_spec_outline(sync_agent_ec_char * task_name, sync_agent_ec_pointer usr_post_task_func_data, sync_agent_post_task_cb post_func, sync_agent_ec_uint param_cnt, sync_agent_ec_param_spec_s ** param_spec_array,
+                                                               sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       task_spec = _task_spec_new_default_task_spec(task_name, usr_post_task_func_data, post_func, param_cnt, param_spec_array);
+
+       if (task_spec == NULL) {
+               return NULL;
+       }
+       task_spec->task_type = EC_TASK_CONTAINER;
+       task_spec->u.container_task_specific = _task_spec_new_child_tasks_info(param_cnt, child_task_cnt, child_task_array);
+
+       if (task_spec->u.container_task_specific == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_spec;
+
+ error_part:
+       _task_spec_free_task_spec(task_spec);
+       return NULL;
+}
+
+sync_agent_ec_error_e ec_set_data_flow(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       /* validation */
+       err = _task_spec_validate_set_data_flow_input_parameters(container_task_spec, from_task_index, from_param_index, to_task_index, to_param_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       if (from_task_index != -1 && to_task_index != -1) {
+               /* add control flow */
+               err = ec_set_control_flow(container_task_spec, from_task_index, to_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+       }
+
+       /* add data flow */
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_child_tasks_info(container_task_spec);
+       ec_data_flow_edges_t *data_flow_edges = child_task_info->data_flow_edges;
+       if (!ec_data_flow_edges_add_edge(data_flow_edges, from_task_index, from_param_index, to_task_index, to_param_index)) {
+               err = SYNC_AGENT_EC_DUPLICATE_DATA_FLOW_EDGE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+sync_agent_ec_error_e ec_set_data_flow_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index,
+                                                      sync_agent_ec_int to_param_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       /* validation */
+       err = _task_spec_validate_set_data_flow_input_parameters_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index, from_param_index, to_task_index, to_param_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       if (from_task_index != -1 && to_task_index != -1) {
+               /* add control flow */
+               err = ec_task_spec_set_control_flow_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index, to_task_index);
+               if (err != SYNC_AGENT_EC_OK) {
+                       goto error_part;
+               }
+       }
+
+       /* add data flow */
+       ec_data_flow_edges_t *data_flow_edges;
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_case_specific_child_tasks_info(dynamic_container_task_spec, dynamic_case);
+       if (child_task_info != NULL) {
+               data_flow_edges = child_task_info->data_flow_edges;
+       } else {
+               err = SYNC_AGENT_EC_INVALID_TASK;
+               goto error_part;
+       }
+       if (!ec_data_flow_edges_add_edge(data_flow_edges, from_task_index, from_param_index, to_task_index, to_param_index)) {
+               err = SYNC_AGENT_EC_DUPLICATE_DATA_FLOW_EDGE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+sync_agent_ec_error_e ec_set_control_flow(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = _task_spec_validate_set_control_flow_input_parameters(container_task_spec, from_task_index, to_task_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_child_tasks_info(container_task_spec);
+       ec_graph_edge_pool_t *control_edge_pool = child_task_info->control_edge_pool;
+       sync_agent_ec_uint *control_flow_in_degree_array = child_task_info->child_task_control_flow_in_degree;
+
+       /* add edge and in_degree count */
+       if (ec_graph_edge_pool_add_edge(control_edge_pool, (sync_agent_ec_constpointer) from_task_index, (sync_agent_ec_constpointer) to_task_index)) {
+               control_flow_in_degree_array[to_task_index]++;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+sync_agent_ec_error_e ec_task_spec_set_control_flow_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_error_e err = SYNC_AGENT_EC_OK;
+
+       err = _task_spec_validate_set_control_flow_input_parameters_on_dynamic_case(dynamic_case, dynamic_container_task_spec, from_task_index, to_task_index);
+       if (err != SYNC_AGENT_EC_OK) {
+               goto error_part;
+       }
+
+       ec_graph_edge_pool_t *control_edge_pool;
+       ec_child_tasks_info_t *child_task_info = ec_task_spec_find_case_specific_child_tasks_info(dynamic_container_task_spec, dynamic_case);
+       if (child_task_info != NULL) {
+               control_edge_pool = child_task_info->control_edge_pool;
+       } else {
+               err = SYNC_AGENT_EC_INVALID_TASK;
+               goto error_part;
+       }
+       sync_agent_ec_uint *control_flow_in_degree_array = child_task_info->child_task_control_flow_in_degree;
+
+       /* add edge and in_degree count */
+       if (ec_graph_edge_pool_add_edge(control_edge_pool, (sync_agent_ec_constpointer) from_task_index, (sync_agent_ec_constpointer) to_task_index)) {
+               control_flow_in_degree_array[to_task_index]++;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+ error_part:
+       return err;
+}
+
+sync_agent_ec_task_spec_s *ec_alloc_dynamic_container_task_spec_outline(sync_agent_ec_char * task_name, sync_agent_ec_pointer usr_post_task_func_data, sync_agent_post_task_cb post_func, sync_agent_ec_uint param_cnt,
+                                                                       sync_agent_ec_param_spec_s ** param_spec_array, sync_agent_calculate_case_cb calculate_case_func, sync_agent_ec_uint case_cnt, sync_agent_ec_int * case_array,
+                                                                       sync_agent_ec_uint * child_task_cnt_array, sync_agent_ec_task_spec_s *** child_task_array_per_case_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_spec_s *task_spec = NULL;
+
+       task_spec = _task_spec_new_default_task_spec(task_name, usr_post_task_func_data, post_func, param_cnt, param_spec_array);
+
+       if (task_spec == NULL) {
+               return NULL;
+       }
+       task_spec->task_type = EC_TASK_DYNAMIC_CONTAINER;
+       task_spec->u.dynmaic_container_task_specific = _task_spec_new_dynamic_container_task_specific(param_cnt, calculate_case_func, case_cnt, case_array, child_task_cnt_array, child_task_array_per_case_array);
+
+       if (task_spec->u.dynmaic_container_task_specific == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return task_spec;
+
+ error_part:
+       _task_spec_free_task_spec(task_spec);
+       return NULL;
+}
diff --git a/src/framework/engine-controller/task_spec_internal.h b/src/framework/engine-controller/task_spec_internal.h
new file mode 100755 (executable)
index 0000000..936c059
--- /dev/null
@@ -0,0 +1,460 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TASK_SPEC_INTERNAL_H_
+#define TASK_SPEC_INTERNAL_H_
+
+#include <glib.h>
+#include "engine-controller/task_spec.h"
+#include "engine-controller/param_spec.h"
+#include "engine-controller/graph_edge_pool.h"
+#include "engine-controller/queuing_rule_spec.h"
+
+/**
+ * @file               task_spec_internal.h
+ * @brief      Defines engine controller task spec APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for data flow edges
+ */
+typedef struct ec_data_flow_edges_s ec_data_flow_edges_t;
+/* all parameter in container task has unique index which calculated as following */
+/* parent container task param[0] : 0
+ * ...
+ * parent container task param[parent_param_cnt - 1] : parent_param_cnt - 1
+ * ...
+ * child task 1 param[0] : parent_param_cnt
+ * ...
+ * child task 1 param[child_1_param_cnt - 1] : parent_param_cnt + child_1_param_cnt - 1
+ * ...
+ */
+
+/**
+ * @brief Structure for data flow edges
+ */
+struct ec_data_flow_edges_s {
+       sync_agent_ec_int child_task_cnt;                       /**< child task count */
+       sync_agent_ec_int *child_task_param_start_index_array;          /**< child task parameter start index array */
+
+       sync_agent_ec_int total_param_cnt;      /**< total parameter count(total_param_cnt = parent_task_param_cnt + sum of (child_task_param_cnt_array[i]) for all i) */
+       sync_agent_ec_int *from_param_array;    /**< from parameter array (containing data flow (from_param_array[idx] th param -> idx th param )) */
+};
+
+/**
+ * @brief Create ec_data_flow_edges_t
+ * @param[in] parent_task_param_cnt parent task parament count
+ * @param[in] child_task_cnt child task count
+ * @param[in] child_task_array child task array
+ * @return ec_data_flow_edges_t on success, NULL on fail
+ * @retval ec_data_flow_edges_t Successful
+ * @retval NULL Fail
+ */
+ec_data_flow_edges_t *ec_data_flow_edges_new(sync_agent_ec_int parent_task_param_cnt, sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array);
+
+/**
+ * @brief Free ec_data_flow_edges_t
+ * @param[in] data_flow_edges ec_data_flow_edges_t
+ */
+void ec_data_flow_edges_free(ec_data_flow_edges_t * data_flow_edges);
+
+/**
+ * @brief Compute internal index
+ * @param[in] data_flow_edges ec_data_flow_edges_t
+ * @param[in] task_index task index
+ * @param[in] param_index parameter index
+ * @return internal index
+ */
+sync_agent_ec_int ec_data_flow_edges_compute_internal_index(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int task_index, sync_agent_ec_int param_index);
+
+/**
+ * @brief Compute task index and parameter index
+ * @param[in] data_flow_edges ec_data_flow_edges_t
+ * @param[in] internal_index internal index
+ * @param[out] pTask_index task index
+ * @param[out] pParam_index parameter index
+ * @return true when valid internal index used, otherwise false
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_data_flow_edges_compute_task_index_and_param_index(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int internal_index, sync_agent_ec_int * pTask_index, sync_agent_ec_int * pParam_index);
+
+/**
+ * @brief Add edge
+ * @param[in] data_flow_edges ec_data_flow_edges_t
+ * @param[in] from_task_index from task index
+ * @param[in] from_param_index from parameter index
+ * @param[in] to_task_index to task index
+ * @param[in] to_param_index to parameter index
+ * @return true when success, otherwise false
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_data_flow_edges_add_edge(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index);
+
+/**
+ * @brief Get from parameter information
+ * @param[in] data_flow_edges ec_data_flow_edges_t
+ * @param[in] to_task_index to task index
+ * @param[in] to_param_index to parameter index
+ * @param[out] from_task_index from task index
+ * @param[out] from_param_index from parameter index
+ * @return true when from part exist, otherwise false
+ * @retval true Successful
+ * @retval false Fail
+ */
+sync_agent_ec_boolean ec_data_flow_edges_get_from_param_info(ec_data_flow_edges_t * data_flow_edges, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index, sync_agent_ec_int * from_task_index, sync_agent_ec_int * from_param_index);
+
+/**
+ * @brief Structure for child task information
+ */
+typedef struct ec_child_tasks_info_s ec_child_tasks_info_t;
+
+/**
+ * @brief Structure for child task information
+ */
+struct ec_child_tasks_info_s {
+       sync_agent_ec_uint child_task_cnt;                              /**< Child task count */
+       /* node index description */
+       /* -1 : parent node */
+       /* 0 ~ child_task_cnt - 1 : child nodes */
+       sync_agent_ec_task_spec_s **child_task_array;   /**< Child task array */
+
+       /* data, control flows between child tasks */
+       sync_agent_ec_uint *child_task_control_flow_in_degree;          /**< Child task control flow in degree */
+       ec_graph_edge_pool_t *control_edge_pool;        /**< Control edge pool(node type : int) */
+       ec_data_flow_edges_t *data_flow_edges;          /**< data flow edges */
+};
+
+/**
+ * @brief Get child task spec from child task information
+ * @param[in] child_tasks_info ec_child_tasks_info_t
+ * @param[in] child_task_index child task index
+ * @return sync_agent_ec_task_spec_s on success, NULL on fail
+ * @retval sync_agent_ec_task_spec_s Successful
+ * @retval NULL Fail
+ */
+sync_agent_ec_task_spec_s *ec_get_child_task_spec_from_child_task_info(ec_child_tasks_info_t * child_tasks_info, sync_agent_ec_uint child_task_index);
+
+/**
+ * @brief Structure for dynamic container task specific
+ */
+typedef struct ec_dynamic_container_task_specific_s ec_dynamic_container_task_specific_t;
+
+/**
+ * @brief Structure for dynamic container task specific
+ */
+struct ec_dynamic_container_task_specific_s {
+       sync_agent_calculate_case_cb calculate_case_func;                       /**< Calculate case callback */
+
+       sync_agent_ec_uint case_cnt;                                            /**< Case count */
+       sync_agent_ec_int *case_array;                                          /**< Case array */
+
+       ec_child_tasks_info_t **case_specific_child_task_info_array;            /**< Case specific child task information array */
+};
+
+/**
+ * @brief Enumeration for task type
+ */
+typedef enum ec_task_type_e ec_task_type_t;
+
+/**
+ * @brief Enumeration for task type
+ */
+enum ec_task_type_e {
+       EC_TASK_SIMPLE = 0,             /**< simple task */
+       EC_TASK_CONTAINER,                      /**< container */
+       EC_TASK_DYNAMIC_CONTAINER       /**< dynamic container */
+};
+
+/**
+ * @brief Structure for engine controller task spec
+ */
+struct engine_controller_task_spec {
+       sync_agent_ec_int ref_count;                            /**< Reference count */
+       ec_task_type_t task_type;                                       /**< Task type */
+       sync_agent_ec_char *task_name;                          /**< Task name */
+
+       sync_agent_ec_int task_param_cnt;                       /**< Task parameter count */
+       sync_agent_ec_param_spec_s **task_param_spec_array;                     /**< Task parameter spec array */
+
+       void *usr_post_task_func_data;                  /**< User post task function data */
+       sync_agent_post_task_cb post_func;                      /**< Post task callback */
+
+       /**
+        * @brief Union for task type
+        */
+       union {
+               /* simple task */
+               sync_agent_task_process_cb task_process;        /**< Task process callback */
+
+               /* container task */
+               ec_child_tasks_info_t *container_task_specific;         /**< Container task specific */
+
+               /* dynamic container task */
+               ec_dynamic_container_task_specific_t *dynmaic_container_task_specific;          /**< Dynamic container task specific */
+       } u;
+};
+
+/* sync_agent_ec_error_e task_spec_attach_queuing_rule_spec(sync_agent_ec_task_spec_s* spec, sync_agent_ec_queuing_rule_spec_s* queuing_rule_spec); */
+
+/**
+ * @brief Validate child task index
+ * @param[in] container_task_spec sync_agent_ec_task_spec_s
+ * @param[in] child_task_index child task index
+ * @return SYNC_AGENT_EC_OK on success, Ohterwise error value
+ * @retval SYNC_AGENT_EC_OK Successful
+ * @retval SYNC_AGENT_EC_INVALID_CHILD_TASK_INDEX invalid child task index
+ */
+sync_agent_ec_error_e ec_task_spec_valididate_child_task_index(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int child_task_index);
+
+/**
+ * @brief Validate child task index on dynamic case
+ * @param[in] dynamic_case dynamic case
+ * @param[in] dynamic_container_task_spec sync_agent_ec_task_spec_s
+ * @param[in] child_task_index child task index
+ * @return SYNC_AGENT_EC_OK on success, Ohterwise error value
+ * @retval SYNC_AGENT_EC_OK Successful
+ * @retval SYNC_AGENT_EC_INVALID_CHILD_TASK_INDEX invalid child task index
+ */
+sync_agent_ec_error_e ec_task_spec_valididate_child_task_index_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int child_task_index);
+
+/**
+ * @brief Duplicate child task control flow in degree
+ * @param[in] task_spec sync_agent_ec_task_spec_s
+ * @return duplicated child task control flow in degree on success, NULL on fail
+ * @retval duplicated child task control flow in degree Successful
+ * @retval NULL Fail
+ */
+sync_agent_ec_uint *ec_task_spec_duplicate_child_task_control_flow_in_degree(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Duplicate child task control flow in degree on dynamic case
+ * @param[in] dynamic_task_spec sync_agent_ec_task_spec_s
+ * @param[in] dynamic_case dynamic case
+ * @return duplicated child task control flow in degree on success, NULL on fail
+ * @retval duplicated child task control flow in degree Successful
+ * @retval NULL Fail
+ */
+sync_agent_ec_uint *ec_task_spec_duplicate_child_task_control_flow_in_degree_on_dynamic_case(sync_agent_ec_task_spec_s * dynamic_task_spec, sync_agent_ec_int dynamic_case);
+
+/**
+ * @brief Get child tasks information
+ * @param[in] parent_container_task_spec sync_agent_ec_task_spec_s
+ * @return ec_child_tasks_info_t on success
+ * @retval ec_child_tasks_info_t Successful
+ */
+ec_child_tasks_info_t *ec_task_spec_find_child_tasks_info(sync_agent_ec_task_spec_s * parent_container_task_spec);
+
+/**
+ * @brief Get case specific child tasks information
+ * @param[in] parent_dynamic_task_spec sync_agent_ec_task_spec_s
+ * @param[in] dynamic_case dynamic case
+ * @return ec_child_tasks_info_t on success, NULL on fail
+ * @retval ec_child_tasks_info_t Successful
+ * @retval NULL Fail
+ */
+ec_child_tasks_info_t *ec_task_spec_find_case_specific_child_tasks_info(sync_agent_ec_task_spec_s * parent_dynamic_task_spec, sync_agent_ec_int dynamic_case);
+
+/**
+ * @brief Increases reference count of task spec
+ * @param[in] task_spec Pointer of task spec to increase ref count
+ * @return Pointer of task spec itself on success, otherwise NULL
+ */
+sync_agent_ec_task_spec_s *ec_task_spec_ref(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Decreases reference count of task spec
+ * @param[in] task_spec Pointer of task spec to decrease ref count
+ */
+void ec_task_spec_unref(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Comparea if given two task specs are same each other
+ * @param[in] task_spec1 Task spec to compare with
+ * @param[in] task_spec2 Task spec to compare with
+ * @return 1 on positive case, otherwise 0
+ */
+sync_agent_ec_boolean ec_task_spec_is_same(sync_agent_ec_task_spec_s * task_spec1, sync_agent_ec_task_spec_s * task_spec2);
+
+/**
+ * @brief Checks if given task spec is simple task
+ * @param[in] task_spec Task spec to check
+ * @return 1 on positive case, otherwise 0
+ */
+sync_agent_ec_boolean ec_task_spec_is_simple(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Checks if given task spec is container task
+ * @param[in] task_spec Task spec to check
+ * @return 1 on positive case, otherwise 0
+ */
+sync_agent_ec_boolean ec_task_spec_is_container(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Checks if given task spec is dynamic container task
+ * @param[in] task_spec Task spec to check
+ * @return 1 on positive case, otherwise 0
+ */
+sync_agent_ec_boolean ec_task_spec_is_dynamic_container(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Returns number of child task in given task spec
+ * @param[in] task_spec Task spec to get child task count from
+ * @return Number of child task
+ */
+sync_agent_ec_uint ec_task_spec_get_child_task_cnt(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Returns task spec of n'th child task in given parent task spec
+ * @param[in] parent_task_spec Task spec to get child task spec from
+ * @param[in] child_task_index Index of child task to get spec from
+ * @return Task spec of requested child task
+ */
+sync_agent_ec_task_spec_s *ec_task_spec_get_child_task_spec(sync_agent_ec_task_spec_s * parent_task_spec, sync_agent_ec_int child_task_index);
+
+/**
+ * @brief Returns task spec of n'th child task in given parent task spec
+ * @param[in] dynamic_task_spec Dynamic task spec to get child task count from
+ * @param[in] dynamic_case Case number to get child task count from under given dynamic task
+ * @return Count of child task under given dynamic task
+ */
+sync_agent_ec_uint ec_task_spec_get_child_task_cnt_on_dynamic_case(sync_agent_ec_task_spec_s * dynamic_task_spec, sync_agent_ec_int dynamic_case);
+
+/**
+ * @brief Returns task spec of n'th child task in given parent dynamic task spec
+ * @param[in] dynamic_case Case number to get child task count from under given dynamic task
+ * @param[in] parent_dynamic_task_spec Task spec to get child task spec from
+ * @param[in] child_task_index Index of child task to get spec from
+ * @return Task spec of requested child task
+ */
+sync_agent_ec_task_spec_s *ec_task_spec_get_child_task_spec_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * parent_dynamic_task_spec, sync_agent_ec_int child_task_index);
+
+/**
+ * @brief Returns number of input parameters
+ * @param[in] task_spec Case number to get child task count from under given dynamic task
+ * @return Number of parameters in given task spec
+ */
+sync_agent_ec_int ec_task_spec_get_param_cnt(sync_agent_ec_task_spec_s * task_spec);
+
+/**
+ * @brief Returns calculate_case_callback_func of given dynamic container task spec
+ * @param[in] dynamic_container_task_spec Task spec of dynamic container task to get callback function info
+ * @return calculate_case_callback_func type of case calculation callback
+ */
+sync_agent_calculate_case_cb ec_task_spec_get_calculate_case_callback_func(sync_agent_ec_task_spec_s * dynamic_container_task_spec);
+
+/**
+ * @brief Returns output parameter info such as param count and param value array
+ * @param[in] task_spec Task spec to get output parameter info
+ * @param[in] output_param_cnt Count of output parameter
+ * @param[in] output_param_index_array Array of output parameter value
+ * @return 1 when success, otherwise 0
+ */
+sync_agent_ec_boolean ec_task_spec_get_output_param_info(sync_agent_ec_task_spec_s * task_spec, sync_agent_ec_int * output_param_cnt, sync_agent_ec_int ** output_param_index_array);
+
+/**
+ * @brief Checks if all child tasks under given container task are done
+ * @param[in] container_task_spec Task spec of container task to check
+ * @return Enumeration value of sync_agent_ec_error_e
+ */
+sync_agent_ec_error_e ec_task_spec_check_everything_done(sync_agent_ec_task_spec_s * container_task_spec);
+
+/**
+ * @brief Sets control flow on given dynamic case
+ * @param[in] dynamic_case Case number under given dynamic container task
+ * @param[in] dynamic_container_task_spec Dynamic container task spec to set control flow on
+ * @param[in] from_task_index Index of task to take data from
+ * @param[in] to_task_index Index of task to put data to
+ * @return Enumeration value of sync_agent_ec_error_e
+ */
+sync_agent_ec_error_e ec_task_spec_set_control_flow_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index);
+
+/**
+ * @brief Allocs and returns engine_controller_task_spec_s type of structure,using given parameters
+ * @param[in] task_name User defined task name
+ * @param[in] usr_post_task_func_data User data to pass to the post_task_callback_func
+ * @param[in] post_func Callback function called after task running done
+ * @param[in] param_cnt Count of input parameters
+ * @param[in] param_spec_array Array of input parameters
+ * @param[in] child_task_cnt Number of child tasks to put under
+ * @param[in] child_task_array Array of child task specs to put under
+ * @return Newly alloced sync_agent_ec_task_spec_s type of task spec
+ */
+sync_agent_ec_task_spec_s *ec_alloc_container_task_spec_outline(sync_agent_ec_char * task_name, sync_agent_ec_pointer usr_post_task_func_data, sync_agent_post_task_cb post_func, sync_agent_ec_uint param_cnt, sync_agent_ec_param_spec_s ** param_spec_array,
+                                                               sync_agent_ec_uint child_task_cnt, sync_agent_ec_task_spec_s ** child_task_array);
+
+/**
+ * @brief Sets data flow on given container task
+ * @param[in] container_task_spec Container task spec to set data flow on
+ * @param[in] from_task_index Index of task to take data from
+ * @param[in] from_param_index Index of parameter to take data from
+ * @param[in] to_task_index Index of task to put data to
+ * @param[in] to_param_index Index of parameter to put data to
+ * @return Enumeration value of sync_agent_ec_error_e
+ */
+sync_agent_ec_error_e ec_set_data_flow(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index, sync_agent_ec_int to_param_index);
+
+/**
+ * @brief Sets control flow on given container task
+ * @param[in] container_task_spec Container task spec to set control flow on
+ * @param[in] from_task_index Index of task to take data from
+ * @param[in] to_task_index Index of task to put data to
+ * @return Enumeration value of sync_agent_ec_error_e
+ */
+sync_agent_ec_error_e ec_set_control_flow(sync_agent_ec_task_spec_s * container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int to_task_index);
+
+/**
+ * @brief Allocs and returns sync_agent_ec_task_spec_s type of structure,using given parameters
+ * @param[in] task_name User defined task name
+ * @param[in] usr_post_task_func_data User data to pass to the post_task_callback_func
+ * @param[in] post_func Callback function called after task running done
+ * @param[in] param_cnt Count of input parameters
+ * @param[in] param_spec_array Array of input parameters
+ * @param[in] calculate_case_func Function which will calculate result case of dynamic task
+ * @param[in] case_cnt Count of cases in dynamic case
+ * @param[in] case_array Array of cases used in dynamic task
+ * @param[in] child_task_cnt_array Array of count of child task in each case
+ * @param[in] child_task_array_per_case_array Array of array of child task spec in each case
+ * @return Newly alloced sync_agent_ec_task_spec_s type of task spec
+ */
+sync_agent_ec_task_spec_s *ec_alloc_dynamic_container_task_spec_outline(sync_agent_ec_char * task_name, sync_agent_ec_pointer usr_post_task_func_data, sync_agent_post_task_cb post_func, sync_agent_ec_uint param_cnt,
+                                                                       sync_agent_ec_param_spec_s ** param_spec_array, sync_agent_calculate_case_cb calculate_case_func, sync_agent_ec_uint case_cnt, sync_agent_ec_int * case_array,
+                                                                       sync_agent_ec_uint * child_task_cnt_array, sync_agent_ec_task_spec_s *** child_task_array_per_case_array);
+
+/**
+ * @brief Sets data flow on given dynamic case
+ * @param[in] dynamic_case Case number under given dynamic container task
+ * @param[in] dynamic_container_task_spec Dynamic container task spec to set data flow on
+ * @param[in] from_task_index Index of task to take data from
+ * @param[in] from_param_index Index of parameter to take data from
+ * @param[in] to_task_index Index of task to put data to
+ * @param[in] to_param_index Index of parameter to put data to
+ * @return Enumeration value of sync_agent_ec_error_e
+ */
+sync_agent_ec_error_e ec_set_data_flow_on_dynamic_case(sync_agent_ec_int dynamic_case, sync_agent_ec_task_spec_s * dynamic_container_task_spec, sync_agent_ec_int from_task_index, sync_agent_ec_int from_param_index, sync_agent_ec_int to_task_index,
+                                                      sync_agent_ec_int to_param_index);
+
+/**
+ *     @}
+ */
+
+#endif                         /* TASK_SPEC_INTERNAL_H_ */
diff --git a/src/framework/engine-controller/thread_pool.c b/src/framework/engine-controller/thread_pool.c
new file mode 100755 (executable)
index 0000000..d076bd9
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "utility/sync_util.h"
+#include "engine-controller/param_spec.h"
+#include "engine-controller/param_spec_internal.h"
+#include "engine-controller/thread_pool.h"
+#include "engine-controller/task_spec_internal.h"
+#include "engine-controller/message.h"
+#include "engine-controller/task_message.h"
+#include "engine-controller/internal.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EC"
+#endif
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+#else
+static GPrivate cancel_task = G_PRIVATE_INIT(g_free);
+#endif
+
+void ec_thread_pool_run_operation(ec_task_t * task, gpointer user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+       ec_task_message_t *task_msg = NULL;
+       GPrivate *cancel_task = (GPrivate *) user_data;
+
+       if (task != NULL) {
+               sync_agent_ec_task_spec_s *task_spec = task->task_spec;
+               _DEBUG_INFO("run task\n");
+
+               /* set thread specific value related to cancellation */
+               g_private_set(cancel_task, ec_task_cancel_info_ref(task->cancel_information));
+
+               /* run task */
+               if (task_spec->task_type == EC_TASK_SIMPLE) {
+                       err = ec_task_run_simple_task(task);
+               } else if (task_spec->task_type == EC_TASK_CONTAINER) {
+                       err = SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK;
+                       _DEBUG_ERROR("container task! only simple task can be put in thread pool\n");
+               } else {
+                       err = SYNC_AGENT_EC_TASK_ERROR_INVALID_TASK;
+                       _DEBUG_ERROR("invalid task type. task type must be either simple or container\n");
+               }
+
+               /* set thread specific value related to cancellation */
+               /* Note that this part must be done before ec_send_msg_to_engine_controller_with_compare_priority */
+               /* othrewise, we can lost task->cancel_information because of threading race between engine controller & thread inside thread pool */
+               ec_task_cancel_info_unref(task->cancel_information);
+
+               /* send task result report to engine controller */
+               task_msg = ec_task_message_create(EC_TASK_DONE, task, 0);
+               ec_send_msg_to_engine_controller_with_compare_priority(task_msg, ec_compare_priority_of_task_message_append_way, NULL);
+
+               g_private_set(cancel_task, NULL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+/* TODO : change void to GDestroyNotify */
+GPrivate *ec_thread_pool_create_cancel_task(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_private_new(NULL);
+}
+
+GPrivate *ec_thread_pool_get_cancel_task(ec_thread_pool_t * thread_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (thread_pool == NULL) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return thread_pool->cancel_task;
+}
+#else
+GPrivate *ec_thread_pool_get_cancel_task()
+{
+       return &cancel_task;
+}
+#endif
+
+sync_agent_ec_uint ec_thread_pool_get_max_thread_count(ec_thread_pool_t * thread_pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (thread_pool == NULL) {
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return thread_pool->max_thread_count;
+}
+
+ec_thread_pool_t *ec_thread_pool_alloc_and_init(sync_agent_ec_uint max_thread_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+#endif
+
+       ec_thread_pool_t *pool = (ec_thread_pool_t *) calloc(1, sizeof(ec_thread_pool_t));
+       if (pool == NULL) {
+               goto error_part;
+       }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       pool->cancel_task = ec_thread_pool_create_cancel_task();
+       if (pool->cancel_task == NULL) {
+               goto error_part;
+       }
+#endif
+
+       pool->max_thread_count = max_thread_count;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       pool->pool = g_thread_pool_new((GFunc) ec_thread_pool_run_operation, pool->cancel_task, max_thread_count, TRUE, NULL);
+#else
+       pool->pool = g_thread_pool_new((GFunc) ec_thread_pool_run_operation, &cancel_task, max_thread_count, TRUE, NULL);
+#endif
+       if (pool->pool == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pool;
+
+ error_part:
+       ec_thread_pool_destroy(pool);
+       return NULL;
+}
+
+void ec_thread_pool_destroy(ec_thread_pool_t * pool)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pool != NULL) {
+               if (pool->pool != NULL) {
+                       g_thread_pool_free(pool->pool, TRUE, TRUE);
+               }
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+               if (pool->cancel_task != NULL) {
+                       /* TODO : i don't know what to do. May be free need to do */
+               }
+#endif
+
+               free(pool);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void ec_thread_pool_push_task(ec_thread_pool_t * pool, ec_task_t * task)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (pool != NULL && pool->pool != NULL && task != NULL) {
+               g_thread_pool_push(pool->pool, task, NULL);
+       } else {
+               if (pool == NULL || pool->pool == NULL) {
+                       _DEBUG_INFO("invalid thread pool structure. we do nothing in this case\n");
+               } else {
+                       _DEBUG_INFO("valid thread pool structure, but invalid task. we do nothing in this case\n");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/engine-controller/thread_pool.h b/src/framework/engine-controller/thread_pool.h
new file mode 100755 (executable)
index 0000000..918c7a2
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef THREAD_POOL_H_
+#define THREAD_POOL_H_
+
+#include <glib.h>
+#include "engine-controller/task.h"
+
+/**
+ * @file               thread_pool.h
+ * @brief      Defines engine controller thread pool APIs
+ */
+
+/** @addtogroup engine_controller
+ *     @{
+ */
+
+/**
+ * @brief Structure for thread pool
+ */
+typedef struct ec_thread_pool_s ec_thread_pool_t;
+
+/**
+ * @brief Structure for thread pool
+ */
+struct ec_thread_pool_s {
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       GPrivate *cancel_task;                  /**< cancel task */
+#endif
+
+       sync_agent_ec_uint max_thread_count;    /**< max thread count */
+       GThreadPool *pool;                              /**< pool */
+};
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+
+/**
+ * @brief Create cancel task
+ * @return GPrivate on success, NULL on fail
+ * @retval cancel task Successful
+ * @retval NULL Fail
+ */
+GPrivate *ec_thread_pool_create_cancel_task(void);
+
+/**
+ * @brief Get cancel task from thread_pool
+ * @param[in] thread_pool ec_thread_pool_t
+ * @return GPrivate on success, NULL on fail
+ * @retval cancel task Successful
+ * @retval NULL Fail
+ */
+GPrivate *ec_thread_pool_get_cancel_task(ec_thread_pool_t * thread_pool);
+#else
+
+/**
+ * @brief Get cancel task
+ * @return GPrivate on success, NULL on fail
+ * @retval GPrivate Successful
+ * @retval NULL Fail
+ */
+GPrivate *ec_thread_pool_get_cancel_task();
+#endif
+
+/**
+ * @brief get max thread count
+ * @param[in] thread_pool ec_thread_pool_t
+ * @return sync_agent_ec_uint on success, 0 on fail
+ * @retval max thread count Successful
+ * @retval 0 Fail
+ */
+sync_agent_ec_uint ec_thread_pool_get_max_thread_count(ec_thread_pool_t * thread_pool);
+
+/**
+ * @brief allocate and initialize thread pool
+ * @param[in] max_thread_count max thread count
+ * @return ec_thread_pool_t on success, NULL on fail
+ * @retval ec_thread_pool_t Successful
+ * @retval NULL Fail
+ */
+ec_thread_pool_t *ec_thread_pool_alloc_and_init(sync_agent_ec_uint max_thread_count);
+
+/**
+ * @brief destory thread pool
+ * @param[in] pool ec_thread_pool_t
+ */
+void ec_thread_pool_destroy(ec_thread_pool_t * pool);
+
+/**
+ * @brief push task to thread pool
+ * @param[in] pool ec_thread_pool_t
+ * @param[in] task ec_task_t
+ */
+void ec_thread_pool_push_task(ec_thread_pool_t * pool, ec_task_t * task);
+
+/**
+ *     @}
+ */
+
+#endif                         /* THREAD_POOL_H_ */
diff --git a/src/framework/event/config.c b/src/framework/event/config.c
new file mode 100755 (executable)
index 0000000..81154b4
--- /dev/null
@@ -0,0 +1,476 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "event/config.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EVENT"
+#endif
+
+static int current_event_count = 0;
+static event_spec_s *event_spec_list[EVENT_MAX_EVENT_COUNT] = { 0 };
+
+static int current_noti_bag_count = 0;
+noti_spec_bag_s *noti_spec_bag_list[EVENT_MAX_NOTI_COUNT] = { 0 };
+
+static char *__communication_path_event = NULL;
+
+static int _find_noti_spec_bag(const char *noti_key);
+
+static int _find_event_spec(int event_num);
+static int _find_noti_spec(int noti_spec_bag_num, int noti_num);
+
+const char *event_get_noti_path(const char *noti_key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (noti_key == NULL) {
+               if (noti_spec_bag_list[0] != NULL) {
+                       return noti_spec_bag_list[0]->communication_path_noti;
+               } else {
+                       return NULL;
+               }
+       }
+
+       int index = _find_noti_spec_bag(noti_key);
+
+       _EXTERN_FUNC_EXIT;
+
+       return noti_spec_bag_list[index]->communication_path_noti;
+}
+
+const char *event_get_event_path()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return __communication_path_event;
+}
+
+sync_agent_event_error_e event_set_event_spec_from_config_file(const char *event_key, const char *config_file)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(event_key == NULL, SYNC_AGENT_EVENT_FAIL, "event key is NULL !!");
+       retvm_if(config_file == NULL, SYNC_AGENT_EVENT_FAIL, "config file is NULL !!");
+
+       FILE *fp = fopen(config_file, "r");
+       if (fp == NULL) {
+               _DEBUG_ERROR("file open failed [%s]\n", config_file);
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       while (!feof(fp)) {
+               event_spec_s *event_spec = (event_spec_s *) malloc(sizeof(event_spec_s));
+               if (event_spec == NULL) {
+                       _DEBUG_ERROR("MALLOC failed !!!");
+                       if (fp != NULL)
+                               fclose(fp);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+
+               char description[1000];
+               int fscanf_ret = fscanf(fp, "%d, %d, %d, %d, %999s\n", &(event_spec->event_num), (int *)(&(event_spec->event_type)), &(event_spec->relational_noti_num), &(event_spec->pendingtime), (char *)(&description));
+               if (fscanf_ret == -1) {
+                       _DEBUG_ERROR("fscanf failed !!");
+                       if (fp != NULL)
+                               fclose(fp);
+                       free(event_spec);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+
+               event_spec_list[current_event_count] = event_spec;
+               current_event_count++;
+       }
+
+       fclose(fp);
+
+       if (__communication_path_event == NULL) {
+               int comm_path_event_len = strlen(EVENT_COMMUNICATION_PATH_EVENT) + strlen(event_key) + 1;
+               int len = 0;
+               __communication_path_event = (char *)calloc(comm_path_event_len, sizeof(char));
+
+               if (__communication_path_event != NULL) {
+                       len = g_strlcat(__communication_path_event, EVENT_COMMUNICATION_PATH_EVENT, comm_path_event_len);
+                       len = g_strlcat(__communication_path_event, event_key, comm_path_event_len);
+
+                       if (len >= comm_path_event_len) {
+                               _DEBUG_ERROR("__communication_path_event buffer overflow !!");
+                               free(__communication_path_event);
+                               return SYNC_AGENT_EVENT_FAIL;
+                       }
+
+                       _DEBUG_INFO("EVENT_COMMUNICATION_PATH_EVENT : %s", __communication_path_event);
+               } else {
+                       _DEBUG_ERROR("__communication_path_event is NULL");
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_error_e event_clean_event_spec()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("Start: current_event_count = %d", current_event_count);
+       int i = 0;
+       for (; i < current_event_count; i++) {
+               event_spec_s *event_spec = event_spec_list[i];
+               if (event_spec != NULL) {
+                       free(event_spec);
+               }
+
+               event_spec_list[i] = 0;
+       }
+
+       current_event_count = 0;
+       _DEBUG_INFO("End: current_event_count = %d", current_event_count);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_error_e event_set_noti_spec_from_config_file(const char *noti_key, const char *config_file)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (noti_key == NULL || config_file == NULL) {
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       FILE *fp = fopen(config_file, "r");
+       if (fp == NULL) {
+               _DEBUG_ERROR("file open failed [%s]\n", config_file);
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       /*
+        * Create Noti Spec Bag
+        */
+       noti_spec_bag_s *noti_spec_bag = (noti_spec_bag_s *) calloc(1, sizeof(noti_spec_bag_s));
+       if (noti_spec_bag == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               if (fp != NULL)
+                       fclose(fp);
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+       noti_spec_bag->noti_count = 0;
+
+       /*
+        * Setting noti_spec_list
+        */
+       while (!feof(fp)) {
+               noti_spec_s *noti_spec = (noti_spec_s *) calloc(1, sizeof(noti_spec_s));
+               if (noti_spec == NULL) {
+                       if (fp != NULL)
+                               fclose(fp);
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       free(noti_spec_bag);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+
+               char description[1000] = { 0, };
+               int fscanf_ret = fscanf(fp, "%d, %d, %d, %d, %999s\n", &(noti_spec->noti_num), (int *)(&(noti_spec->noti_type)), &(noti_spec->relational_event_num), &(noti_spec->pendingtime), (char *)(&description));
+               if (fscanf_ret == -1) {
+                       _DEBUG_ERROR("fscanf failed !!");
+                       if (fp != NULL)
+                               fclose(fp);
+                       free(noti_spec_bag);
+                       free(noti_spec);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+
+               noti_spec_bag->noti_spec_list[noti_spec_bag->noti_count] = noti_spec;
+               noti_spec_bag->noti_count++;
+       }
+       fclose(fp);
+
+       /*
+        * Setting noti_key
+        */
+       noti_spec_bag->noti_key = strdup(noti_key);
+
+       /*
+        * Setting communication_path_noti
+        */
+       if (noti_spec_bag->communication_path_noti == NULL) {
+               int comm_path_noti_len = strlen(EVENT_COMMUNICATION_PATH_NOTI) + strlen(noti_key) + 1;
+               int len = 0;
+               noti_spec_bag->communication_path_noti = (char *)calloc(comm_path_noti_len, sizeof(char));
+
+               if (noti_spec_bag->communication_path_noti != NULL) {
+                       len = g_strlcat(noti_spec_bag->communication_path_noti, EVENT_COMMUNICATION_PATH_NOTI, comm_path_noti_len);
+                       len = g_strlcat(noti_spec_bag->communication_path_noti, noti_key, comm_path_noti_len);
+
+                       if (len >= comm_path_noti_len) {
+                               _DEBUG_ERROR("noti_spec_bag->communication_path_noti buffer overflow !!");
+                               free(noti_spec_bag->communication_path_noti);
+                               free(noti_spec_bag);
+                               return SYNC_AGENT_EVENT_FAIL;
+                       }
+
+                       _DEBUG_INFO("EVENT_COMMUNICATION_PATH_NOTI : %s", noti_spec_bag->communication_path_noti);
+               } else {
+                       _DEBUG_ERROR("noti_spec_bag->communication_path_not is NULL");
+                       free(noti_spec_bag);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+       }
+
+       /*
+        * Setting communication_path_reply_noti
+        */
+       if (noti_spec_bag->communication_path_reply_noti == NULL) {
+               int comm_path_reply_noti_len = strlen(EVENT_REPLY_COMMUNICATION_PATH_NOTI) + strlen(noti_key) + 1;
+               int len = 0;
+               noti_spec_bag->communication_path_reply_noti = (char *)calloc(comm_path_reply_noti_len, sizeof(char));
+
+               if (noti_spec_bag->communication_path_reply_noti != NULL) {
+                       len = g_strlcat(noti_spec_bag->communication_path_reply_noti, EVENT_REPLY_COMMUNICATION_PATH_NOTI, comm_path_reply_noti_len);
+                       len = g_strlcat(noti_spec_bag->communication_path_reply_noti, noti_key, comm_path_reply_noti_len);
+
+                       if (len >= comm_path_reply_noti_len) {
+                               _DEBUG_ERROR("noti_spec_bag->communication_path_reply_noti buffer overflow !!");
+                               free(noti_spec_bag->communication_path_reply_noti);
+                               free(noti_spec_bag);
+                               return SYNC_AGENT_EVENT_FAIL;
+                       }
+
+                       _DEBUG_INFO("EVENT_REPLY_COMMUNICATION_PATH_NOTI : %s", noti_spec_bag->communication_path_reply_noti);
+               } else {
+                       _DEBUG_ERROR("noti_spec_bag->communication_path_reply_noti is NULL");
+                       free(noti_spec_bag);
+                       return SYNC_AGENT_EVENT_FAIL;
+               }
+       }
+
+       _DEBUG_INFO("before: current_noti_bag_count = %d", current_noti_bag_count);
+       noti_spec_bag_list[current_noti_bag_count] = noti_spec_bag;
+       current_noti_bag_count++;
+       _DEBUG_INFO("after: current_noti_bag_count = %d", current_noti_bag_count);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_error_e event_clean_noti_spec()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("Start: current_noti_bag_count = %d", current_noti_bag_count);
+       int i = 0;
+       for (; i < current_noti_bag_count; i++) {
+               noti_spec_bag_s *noti_spec_bag = noti_spec_bag_list[i];
+               if (noti_spec_bag != NULL) {
+                       _DEBUG_INFO("noti_key = %s, communication_path_noti = %s, communication_path_reply_noti = %s", noti_spec_bag->noti_key, noti_spec_bag->communication_path_noti, noti_spec_bag->communication_path_reply_noti);
+                       free(noti_spec_bag->noti_key);
+                       free(noti_spec_bag->communication_path_noti);
+                       free(noti_spec_bag->communication_path_reply_noti);
+
+                       int k = 0;
+                       for (; k < noti_spec_bag->noti_count; k++) {
+                               noti_spec_s *noti_spec = noti_spec_bag->noti_spec_list[k];
+                               if (noti_spec != NULL) {
+                                       free(noti_spec);
+                               }
+                       }
+
+                       noti_spec_bag_list[i] = 0;
+               }
+       }
+
+       current_noti_bag_count = 0;
+       _DEBUG_INFO("End: current_noti_bag_count = %d", current_noti_bag_count);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_error_e event_register_event_callback(int event_num, sync_agent_event_cb callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_event_spec(event_num);
+       if (index == -1) {
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       event_spec_list[index]->callback = callback;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_error_e event_register_noti_callback(int noti_num, sync_agent_noti_cb callback, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_noti_spec(0, noti_num);
+       if (index == -1) {
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       noti_spec_bag_list[0]->noti_spec_list[index]->callback = callback;
+       noti_spec_bag_list[0]->noti_spec_list[index]->additional_param = data;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+sync_agent_event_cb event_get_event_callback(int event_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_event_spec(event_num);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return event_spec_list[index]->callback;
+}
+
+sync_agent_noti_cb event_get_noti_callback(int noti_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_noti_spec(0, noti_num);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return noti_spec_bag_list[0]->noti_spec_list[index]->callback;
+}
+
+void *event_get_noti_callback_additional_param(int noti_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_noti_spec(0, noti_num);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return noti_spec_bag_list[0]->noti_spec_list[index]->additional_param;
+}
+
+event_type_e event_get_event_type(int event_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_event_spec(event_num);
+       if (index == -1) {
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return event_spec_list[index]->event_type;
+}
+
+noti_type_e event_get_noti_type(const char *noti_key, int noti_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(noti_key == NULL, NOTI_TYPE_UNKNOWN, "noti key is NULL !!");
+
+       int noti_spec_bag_num = _find_noti_spec_bag(noti_key);
+
+       int noti_index = _find_noti_spec(noti_spec_bag_num, noti_num);
+       if (noti_index == -1) {
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return noti_spec_bag_list[noti_spec_bag_num]->noti_spec_list[noti_index]->noti_type;
+}
+
+static int _find_noti_spec_bag(const char *noti_key)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(noti_key == NULL, 0, "noti key is NULL !!");
+
+       int i = 0;
+       for (; i < current_noti_bag_count; i++) {
+               noti_spec_bag_s *noti_spec_bag = noti_spec_bag_list[i];
+               if (noti_spec_bag != NULL) {
+                       if (!strcmp(noti_spec_bag->noti_key, noti_key)) {
+                               _INNER_FUNC_EXIT;
+                               return i;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+static int _find_event_spec(int event_num)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_event_count; i++) {
+               if (event_spec_list[i]->event_num == event_num) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+static int _find_noti_spec(int noti_spec_bag_num, int noti_num)
+{
+       _INNER_FUNC_ENTER;
+
+       noti_spec_bag_s *noti_spec_bag = noti_spec_bag_list[noti_spec_bag_num];
+
+       int i = 0;
+       for (; i < noti_spec_bag->noti_count; i++) {
+               if ((noti_spec_bag->noti_spec_list[i])->noti_num == noti_num) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/event/config.h b/src/framework/event/config.h
new file mode 100755 (executable)
index 0000000..f01911d
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CONFIG_H_
+#define CONFIG_H_
+
+#include "event/error.h"
+#include "event/handler.h"
+#include "event/ui_api.h"
+#include "event/spec.h"
+
+/**
+ * @file       Event_Config.h
+ * @brief      Event/Notification Configuration Manager
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+#define EVENT_COMMUNICATION_PATH_EVENT         "/tmp/agent_fw_event_"
+#define EVENT_REPLY_COMMUNICATION_PATH_EVENT   "/tmp/agent_fw_event_reply_"
+#define EVENT_COMMUNICATION_PATH_NOTI  "/tmp/agent_fw_noti_"
+#define EVENT_REPLY_COMMUNICATION_PATH_NOTI    "/tmp/agent_fw_noti_reply_"
+
+#define EVENT_MAX_STREAM_SIZE 102400
+
+/**
+ * @brief      Get real notification socket path file from noti_key (Agent -> UI)
+ * @param[in]  noti_key notification key string
+ * @return     Operation result
+ * @retval     notification socket path success
+ * @retval     NULL error
+ */
+const char *event_get_noti_path(const char *noti_key);
+
+/**
+ * @brief Get real event socket path file (UI -> Agent)
+ * @return Operation result
+ * @retval event socket path success
+ * @retval NULL error
+ */
+const char *event_get_event_path();
+
+/**
+ * @brief      Load to memory event specification from event specification file
+ * @param[in]  event_key event key string
+ * @param[in]  config_file event specification file
+ * @return Operation result
+ * @retval SYNC_AGENT_EVENT_SUCCESS    success
+ * @retval SYNC_AGENT_EVENT_FAIL error
+ */
+sync_agent_event_error_e event_set_event_spec_from_config_file(const char *event_key, const char *config_file);
+
+/**
+ * @brief      Free event specification from memory
+ * @return Operation result
+ * @retval SYNC_AGENT_EVENT_SUCCESS success
+ * @retval SYNC_AGENT_EVENT_FAIL error
+ */
+sync_agent_event_error_e event_clean_event_spec();
+
+/**
+ * @brief      Load to memory notification specification from notification specification file
+ * @param[in] noti_key notification key string
+ * @param[in]  config_file notification specification file
+ * @return Operation result
+ * @retval SYNC_AGENT_EVENT_SUCCESS success
+ * @retval SYNC_AGENT_EVENT_FAIL error
+ */
+sync_agent_event_error_e event_set_noti_spec_from_config_file(const char *noti_key, const char *config_file);
+
+/**
+ * @brief      Free notification specification from memory
+ * @return Operation result
+ * @retval SYNC_AGENT_EVENT_SUCCESS success
+ * @retval other error code error
+ */
+sync_agent_event_error_e event_clean_noti_spec();
+
+/**
+ * @brief      Register Event Callback function, callback will be called when receive event
+ * @param[in]  event_num event number wrote in event specification file
+ * @param[in]  callback event callback function
+ * @return Operation result
+ * @retval SYNC_AGENT_EVENT_SUCCESS success
+ * @retval SYNC_AGENT_EVENT_FAIL error
+ */
+sync_agent_event_error_e event_register_event_callback(int event_num, sync_agent_event_cb callback);
+
+/**
+ * @brief      Register Notification Callback function, callback will be called when receive event
+ * @param[in]  noti_num notification number wrote in notification specification file
+ * @param[in]  callback notification callback function
+ * @param[in]  data data used in callback function
+ * @return Operation result code
+ * @retval SYNC_AGENT_EVENT_SUCCESS    success
+ * @retval SYNC_AGENT_EVENT_FAIL error
+ */
+sync_agent_event_error_e event_register_noti_callback(int noti_num, sync_agent_noti_cb callback, void *data);  /* only UI */
+
+/**
+ * @brief      Get Event Callback function pointer
+ * @param[in]  event_num event number wrote in event specification file
+ * @return Event Callback function pointer
+ * @retval function pointer success
+ * @retval NULL error
+ */
+sync_agent_event_cb event_get_event_callback(int event_num);
+
+/**
+ * @brief      Get Notification Callback function pointer, this function is for only UI
+ * @param[in]  noti_num notification number wrote in notification specification file
+ * @return Notification Callback function pointer
+ * @retval function pointer success
+ * @retval NULL error
+ */
+sync_agent_noti_cb event_get_noti_callback(int noti_num);
+
+/**
+ * @brief      Get additional notification data, this function is for only UI
+ * @param[in] noti_num notification number wrote in notification specification file
+ * @return additional data
+ * @retval additional data success
+ * @retval NULL error or data not exist
+ */
+void *event_get_noti_callback_additional_param(int noti_num);
+
+/**
+ * @brief      Get event type
+ * @param[in]  event_num event number wrote in notification specification file
+ * @return event type
+ * @retval event type success
+ * @retval 0 error
+ */
+event_type_e event_get_event_type(int event_num);
+
+/**
+ * @brief      Get notification type
+ * @param[in]  noti_key means destination UI
+ * @param[in]  noti_num notification number wrote in notification specification file
+ * @return notification type
+ * @retval notification type success
+ * @retval 0 error
+ */
+noti_type_e event_get_noti_type(const char *noti_key, int noti_num);
+
+/**
+ *     @}
+ */
+
+#endif                         /* CONFIG_H_ */
diff --git a/src/framework/event/data_accessor.c b/src/framework/event/data_accessor.c
new file mode 100755 (executable)
index 0000000..803add0
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+
+#include "event/util.h"
+#include "event/data_accessor.h"
+#include "event/data_accessor_internal.h"
+#include "event/config.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EVENT"
+#endif
+
+static char *_ipc_print_message_size(char *msg_stream);
+static char *_ipc_print_message_type_and_body(char *msg_sub_stream);
+
+EXPORT_API void sync_agent_append_event_data_param(sync_agent_event_data_s * iter, sync_agent_event_param_type_e type, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(iter == NULL, "sync_agent_event_data_s is NULL !!");
+
+       int len = 0;
+       /* increase argument cnt */
+       (iter->size[0])++;
+
+       /* append type */
+       if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+               len = g_strlcat(iter->data, "I", EVENT_MAX_STREAM_SIZE);
+       } else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+               len = g_strlcat(iter->data, "S", EVENT_MAX_STREAM_SIZE);
+       }
+       if (len >= EVENT_MAX_STREAM_SIZE) {
+               _DEBUG_ERROR("iter->data buffer overflow !!");
+               /* todo : exception handling */
+       }
+       iter->data += 1;
+
+       /* append size and data */
+       if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+               /* append data */
+               memcpy(iter->data, data, sizeof(int));
+               iter->data += sizeof(int);
+       } else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+               if (data == NULL) {
+                       /* append size */
+                       int size = 0;
+                       memcpy(iter->data, &size, sizeof(int));
+                       iter->data += sizeof(int);
+               } else {
+                       /* append size */
+                       int size = strlen(data) + 1;
+                       memcpy(iter->data, &size, sizeof(int));
+                       iter->data += sizeof(int);
+
+                       /* append data */
+                       len = g_strlcat(iter->data, data, EVENT_MAX_STREAM_SIZE);
+                       if (len >= EVENT_MAX_STREAM_SIZE) {
+                               _DEBUG_ERROR("iter->data buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       iter->data += size;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_get_event_data_param(sync_agent_event_data_s * iter, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(iter == NULL, "sync_agent_event_data_s is NULL !!");
+       retm_if(data == NULL, "data is NULL !!");
+
+       /* get type */
+       sync_agent_event_param_type_e type = *(iter->data++);
+
+       if (type == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+               /* get data */
+               memcpy(data, iter->data, sizeof(int));
+               iter->data += sizeof(int);
+       } else if (type == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+               int size;
+               /* get size */
+               memcpy(&size, iter->data, sizeof(int));
+               iter->data += sizeof(int);
+
+               if (size > 0) {
+                       /* get data */
+                       char *return_char = (char *)malloc(size * sizeof(char));
+                       if (return_char == NULL) {
+                               _DEBUG_ERROR("Memory malloc FAILED. [return_char]");
+                       } else {
+                               memcpy(return_char, iter->data, size * sizeof(char));
+                       }
+                       iter->data += (sizeof(char) * size);
+
+                       *(char **)data = return_char;
+               } else {
+                       *(char **)data = NULL;
+               }
+       }
+
+       /* setting for next */
+       *(iter->size) -= 1;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void event_print_event_data(char *msg_stream)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(msg_stream == NULL, "msg stream is NULL !!");
+
+       char *ptr = msg_stream;
+       /* print size */
+       ptr = _ipc_print_message_size(ptr);
+
+       retm_if(ptr == NULL, "ptr is NULL !!");
+
+       /* print type and body */
+       while (*ptr != '\0') {
+               ptr = _ipc_print_message_type_and_body(ptr);
+
+               retm_if(ptr == NULL, "ptr is NULL !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_free_event_data(sync_agent_event_data_s * event)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (event != NULL) {
+               if (event->size != NULL) {
+                       free(event->size);
+               }
+
+               free(event);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* return pointer after message size */
+char *_ipc_print_message_size(char *msg_stream)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(msg_stream == NULL, NULL, "msg stream is NULL !!");
+
+       char *ptr = msg_stream;
+
+       /* print size */
+       int size = (int)*((char *)ptr);
+       _DEBUG_TRACE("message size : %d", size);
+       ptr += sizeof(char);
+
+       _INNER_FUNC_EXIT;
+
+       return ptr;
+}
+
+char *_ipc_print_message_type_and_body(char
+                                      *msg_sub_stream)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(msg_sub_stream == NULL, NULL, "msg sub stream is NULL !!");
+
+       /* check type */
+       char *ptr = msg_sub_stream;
+
+       if ((*ptr) == SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER) {
+               _DEBUG_TRACE("type : SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER");
+               ptr++;
+               _DEBUG_TRACE("value : %d", *(int *)ptr);
+               ptr += sizeof(int);
+       } else if ((*ptr) == SYNC_AGENT_EVENT_PARAM_TYPE_STRING) {
+               _DEBUG_TRACE("type : SYNC_AGENT_EVENT_PARAM_TYPE_STRING");
+               ptr++;
+               int size = *(int *)ptr;
+               _DEBUG_TRACE("size : %d", size);
+               ptr += sizeof(int);
+               _DEBUG_TRACE("content : %s", ptr);
+               ptr += size;
+       } else {
+               _DEBUG_ERROR("assertion failed in ipc_print_type_and_body");
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ptr;
+}
diff --git a/src/framework/event/data_accessor_internal.h b/src/framework/event/data_accessor_internal.h
new file mode 100755 (executable)
index 0000000..016cabb
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_ACCESSOR_INTERNAL_H_
+#define DATA_ACCESSOR_INTERNAL_H_
+
+#include "event/data_accessor.h"
+
+/**
+ * @file       data_accessor_internal.h
+ * @brief      Support to access (create, append, get, remove) Event packet structure
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * @brief Print sync_agent_event_data_s' packet contents Heuristically
+ * @remarks for Debugging
+ * @param[in] msg_stream print msg packet
+ */
+void event_print_event_data(char *msg_stream);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DATA_ACCESSOR_INTERNAL_H_ */
diff --git a/src/framework/event/handler.c b/src/framework/event/handler.c
new file mode 100755 (executable)
index 0000000..2a03831
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "fsapi/operation.h"
+
+#include "event/util.h"
+#include "event/data_accessor.h"
+#include "event/data_accessor_internal.h"
+#include "event/config.h"
+#include "event/handler.h"
+
+#define EVENT_RETRY_COUNT              2000
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EVENT"
+#endif
+
+static int _event_server_socket_id = 0;
+
+static pthread_t event_handler_thread_id;
+
+static void *_event_listener(void *arg);
+
+static void __dispatch_event(int event_num, sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+EXPORT_API sync_agent_event_error_e sync_agent_run_event_handler(unsigned long int *thread_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("sync_agent_run_event_handler() start\n");
+
+       pthread_create(&event_handler_thread_id, 0, _event_listener, 0);
+
+       *thread_id = event_handler_thread_id;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+EXPORT_API sync_agent_event_error_e sync_agent_clean_event_handler()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_event_error_e event_err = event_clean_event_spec();
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("Fail event_clean_event_spec : %d", event_err);
+       } else {
+               _DEBUG_INFO("Success event_clean_event_spec : %d", event_err);
+       }
+       event_err = event_clean_noti_spec();
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("Fail event_clean_noti_spec : %d", event_err);
+       } else {
+               _DEBUG_INFO("Success event_clean_noti_spec : %d", event_err);
+       }
+
+       if (_event_server_socket_id != 0) {
+               close(_event_server_socket_id);
+               _event_server_socket_id = 0;
+       }
+
+       pthread_cancel(event_handler_thread_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+EXPORT_API sync_agent_event_error_e sync_agent_set_event_callback(int event_num, sync_agent_event_cb callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return event_register_event_callback(event_num, callback);
+}
+
+EXPORT_API sync_agent_event_data_s *sync_agent_create_noti(int noti_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_event_data_s *noti = (sync_agent_event_data_s *) calloc(1, sizeof(sync_agent_event_data_s));
+       if (noti == NULL) {
+               _DEBUG_ERROR("Memory malloc FAILED. [noti]");
+               return noti;
+       } else {
+               noti->event_num = noti_num;
+       }
+
+       char *serialized_data = (char *)calloc(EVENT_MAX_STREAM_SIZE, sizeof(char));
+       if (serialized_data == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               sync_agent_free_event_data(noti);
+               return NULL;
+       }
+       noti->size = serialized_data;
+       noti->data = serialized_data + 1;
+
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &noti_num);
+
+       _EXTERN_FUNC_EXIT;
+
+       return noti;
+}
+
+EXPORT_API sync_agent_event_data_s *sync_agent_send_noti(const char *noti_key, sync_agent_event_data_s * noti, sync_agent_confirm_ipc_cancel_cb confirm_cancel, void *user_data, sync_agent_event_error_e * error)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (noti_key == NULL) {
+               _DEBUG_ERROR("noti key is NULL !!");
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       if (noti == NULL) {
+               _DEBUG_ERROR("sync_agent_event_data_s is NULL !!");
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       *error = SYNC_AGENT_EVENT_SUCCESS;
+       const char *communication_path = NULL;
+
+       noti_type_e noti_type = event_get_noti_type(noti_key, noti->event_num);
+
+       switch (noti_type) {
+       case NOTI_TYPE_SIMPLE:
+               communication_path = event_get_noti_path(noti_key);
+               break;
+       default:
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+               break;
+       }
+
+       _DEBUG_INFO("noti num : %d", noti->event_num);
+       _DEBUG_INFO("noti_type : %d", noti_type);
+       _DEBUG_INFO("communication_path : %s", communication_path);
+
+       sync_agent_event_data_s *reply_msg = NULL;
+       int send_data_size = (noti->data - noti->size) + 1;
+
+       if (sync_agent_is_existing_fs(communication_path)) {
+               FILE *fp = NULL;
+               fp = fopen(communication_path, "w");
+               if (fp != NULL) {
+                       if (fwrite((void *)(noti->size), sizeof(char), send_data_size, fp) <= 0) {
+                               _DEBUG_ERROR("fwrite() failed !!");
+                               *error = SYNC_AGENT_EVENT_IPC_ERR;
+                               fclose(fp);
+                               return NULL;
+                       } else {
+                               _DEBUG_INFO("fwrite() success !!");
+                               fclose(fp);
+                       }
+               } else {
+                       _DEBUG_ERROR("fopen( %s ) failed  !!", communication_path);
+                       *error = SYNC_AGENT_EVENT_IPC_ERR;
+                       return NULL;
+               }
+       } else {
+               _DEBUG_ERROR("file ( %s ) does not exist !!", communication_path);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return reply_msg;
+}
+
+EXPORT_API void sync_agent_free_noti(sync_agent_event_data_s * noti)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (noti != NULL) {
+               sync_agent_free_event_data(noti);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static void *_event_listener(void *arg)
+{
+       _INNER_FUNC_ENTER;
+
+       signal(SIGPIPE, SIG_IGN);
+
+       int client_sockfd;
+       int state;
+       socklen_t client_len;
+       struct sockaddr_un clientaddr, serveraddr;
+       int buf_len = 0;
+       int result = 0;
+
+       const char *communication_path = event_get_event_path();
+       _DEBUG_TRACE("event_path : %s", communication_path);
+
+       if (sync_agent_is_existing_fs(communication_path)) {
+               _DEBUG_TRACE("%s file is exist !!");
+               if (unlink(communication_path) == -1) { /* when file exist, remove previous file */
+                       _DEBUG_ERROR("unlink failed ( %s ), ERROR NUM [%d] !!", communication_path, errno);
+                       return NULL;
+               } else {
+                       _DEBUG_TRACE("unlink success !!");
+               }
+       } else {
+               _DEBUG_TRACE("%s file is not exist !!");
+       }
+
+       client_len = sizeof(clientaddr);
+       if ((_event_server_socket_id = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+               return NULL;
+       }
+
+       bzero(&serveraddr, sizeof(serveraddr));
+       serveraddr.sun_family = AF_UNIX;
+       if (communication_path != NULL) {
+               buf_len = g_strlcpy(serveraddr.sun_path, communication_path, sizeof(serveraddr.sun_path));
+               if (buf_len >= sizeof(serveraddr.sun_path)) {
+                       _DEBUG_ERROR("serveraddr.sun_path buffer overflow !!");
+                       return NULL;
+               }
+       } else {
+               _DEBUG_ERROR("communication_path is NULL !!");
+               return NULL;
+       }
+
+       state = bind(_event_server_socket_id, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
+       if (state == -1) {
+               _DEBUG_ERROR("bind failed !!");
+               return NULL;
+       }
+
+       mode_t sock_mode = (S_IRWXU | S_IRWXG | S_IRWXO);
+       if (chmod(communication_path, sock_mode) == -1) {
+               _DEBUG_ERROR("chmod failed !! ( err : %d )", errno);
+//              return NULL;
+       }
+
+       state = listen(_event_server_socket_id, 5);
+       if (state == -1) {
+               _DEBUG_ERROR("listen failed !!");
+               return NULL;
+       }
+
+       while (1) {
+               _DEBUG_TRACE("In EventHandler loop=\n");
+
+               char inbuf[EVENT_MAX_STREAM_SIZE + 1];
+               char outbuf[EVENT_MAX_STREAM_SIZE + 1];
+               memset(inbuf, 0x00, EVENT_MAX_STREAM_SIZE + 1);
+               memset(outbuf, 0x00, EVENT_MAX_STREAM_SIZE + 1);
+               sync_agent_event_data_s request;
+               sync_agent_event_data_s response;
+               request.data = inbuf;
+               response.data = outbuf;
+               event_init_event_data_iter(&request);
+               event_init_event_data_iter(&response);
+
+               client_sockfd = accept(_event_server_socket_id, (struct sockaddr *)&clientaddr, &client_len);
+               if (client_sockfd < 0) {
+                       _DEBUG_ERROR("socket accept() failed !!");
+                       return NULL;
+               }
+               _DEBUG_TRACE("accept() was called\n");
+
+               result = read(client_sockfd, (void *)inbuf, EVENT_MAX_STREAM_SIZE);
+               if (result <= 0 || result > EVENT_MAX_STREAM_SIZE) {
+                       _DEBUG_ERROR("read failed !!");
+                       close(client_sockfd);
+                       return NULL;
+               }
+               if (strlen(inbuf) <= 0 || strlen(inbuf) > EVENT_MAX_STREAM_SIZE) {
+                       _DEBUG_ERROR("socket data read : size OUT OF BOUND !!");
+                       close(client_sockfd);
+                       return NULL;
+               }
+
+               int event_num;
+               sync_agent_get_event_data_param(&request, &event_num);
+               _DEBUG_TRACE("Received Event Number : %d\n", event_num);
+
+               __dispatch_event(event_num, &request, &response);
+               /*
+                * need synchronous response case
+                */
+               event_type_e event_type = event_get_event_type(event_num);
+               if (event_type == EVENT_TYPE_NEED_RESPONSE) {
+                       if (event_get_event_data_element_size(&response) > 0) {
+                               int byte_size = event_get_event_data_byte_size(&response);
+                               int write_ret = write(client_sockfd, outbuf, byte_size);
+                               if (write_ret != byte_size) {
+                                       _DEBUG_ERROR("write() failed !!");
+                               }
+                       }
+               }
+
+               close(client_sockfd);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;
+}
+
+static void __dispatch_event(int event_num, sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(request == NULL, "sync_agent_event_data_s is NULL !!");
+       retm_if(response == NULL, "sync_agent_event_data_s is NULL !!");
+
+       sync_agent_event_cb event_callback = event_get_event_callback(event_num);
+       retm_if(event_callback == NULL, "event_get_event_callback return value is NULL !!");
+
+       event_callback(request, response);
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/event/oma_dm_admin_api.c b/src/framework/event/oma_dm_admin_api.c
new file mode 100755 (executable)
index 0000000..0818ac7
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_admin_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_ADMIN_CONFIG_FILE       "/usr/share/oma-dm-cfg/fw-init/omadmadminui_fw_config.xml"
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_ADMIN_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+//      sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_admin_ui");
+//      if (err != SYNC_AGENT_EVENT_SUCCESS) {
+//              _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+//              result = UI_SYNC_AGENT_DM_FAIL;
+//      }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          //   sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          //   if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          //           _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          //           result = UI_SYNC_AGENT_DM_FAIL;
+          //   }
+
+          sync_agent_event_error_e err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_get_fumo_config(int *wifi_only)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_GET_FUMO_CONFIG);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_GET_FUMO_CONFIG);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, wifi_only);
+
+       _DEBUG_VERBOSE("wifi_only : %d", *wifi_only);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_set_fumo_config(int wifi_only)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_SET_FUMO_CONFIG);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_SET_FUMO_CONFIG);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+       _DEBUG_VERBOSE("wifi_only : %d", wifi_only);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_get_profile(int profile_type, sync_agent_dm_setting_data_s ** data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_GET_PROFILE);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_GET_PROFILE);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_type);
+
+       _DEBUG_VERBOSE("profile_type : %d", profile_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->profile_name));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_url));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_id));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_pwd));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_id));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_pwd));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->client_auth_type));
+       sync_agent_get_event_data_param(response_event, &(((sync_agent_dm_setting_data_s *) * data)->server_auth_type));
+
+       _DEBUG_VERBOSE("profile_name : %s", (*data)->profile_name);
+       _DEBUG_VERBOSE("server_url : %s", (*data)->server_url);
+       _DEBUG_VERBOSE("server_id : %s", (*data)->server_id);
+       _DEBUG_VERBOSE("server_pwd : %s", (*data)->server_pwd);
+       _DEBUG_VERBOSE("client_id : %s", (*data)->client_id);
+       _DEBUG_VERBOSE("client_pwd : %s", (*data)->client_pwd);
+       _DEBUG_VERBOSE("client_auth_type : %s", (*data)->client_auth_type);
+       _DEBUG_VERBOSE("server_auth_type : %s", (*data)->server_auth_type);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_set_profile(int profile_type, sync_agent_dm_setting_data_s * data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_SET_PROFILE);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_SET_PROFILE);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->server_url);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->server_id);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->server_pwd);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->client_id);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->client_pwd);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->client_auth_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, data->server_auth_type);
+
+       _DEBUG_VERBOSE("profile_type : %d", profile_type);
+       _DEBUG_VERBOSE("server_url : %s", data->server_url);
+       _DEBUG_VERBOSE("server_id : %s", data->server_id);
+       _DEBUG_VERBOSE("server_pwd : %s", data->server_pwd);
+       _DEBUG_VERBOSE("client_id : %s", data->client_id);
+       _DEBUG_VERBOSE("client_pwd : %s", data->client_pwd);
+       _DEBUG_VERBOSE("client_auth_type : %s", data->client_auth_type);
+       _DEBUG_VERBOSE("server_auth_type : %s", data->server_auth_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_reset_profile(int profile_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_RESET_PROFILE);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_RESET_PROFILE);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_type);
+
+       _DEBUG_VERBOSE("profile_type : %d", profile_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_admin_user_initiate(sync_agent_dm_service_server_type_e server_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+       sync_agent_dm_ui_type_e ui_type = ADMIN_UI;
+
+       request_event = sync_agent_create_event(EVENT_SOFTWARE_UPDATE);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_SOFTWARE_UPDATE);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ui_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &server_type);
+
+       _DEBUG_VERBOSE("server_type : %d", server_type);
+       _DEBUG_VERBOSE("ui_type : %d", ui_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
diff --git a/src/framework/event/oma_dm_alert_api.c b/src/framework/event/oma_dm_alert_api.c
new file mode 100755 (executable)
index 0000000..2a910ec
--- /dev/null
@@ -0,0 +1,880 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_alert_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_ALERT_CONFIG_FILE       "/usr/share/oma-dm-cfg/fw-init/omadmalertui_fw_config.xml"
+
+static int (*_get_alert_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data);
+
+static int __display_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __confirmation_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __input_text_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __single_choice_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __multiple_choice_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data);
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_ALERT_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_alert_ui");
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       int noti_id = NOTI_ALERT_DISPLAY;
+       for (; noti_id < NOTI_NUM; noti_id++) {
+               err = sync_agent_set_noti_callback(noti_id, _get_alert_noti_callback(noti_id), NULL);
+               if (err != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_set_noti_callback(noti_id : %d) failed - err : %d !!", noti_id, err);
+                       result = UI_SYNC_AGENT_DM_FAIL;
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+/*
+sync_agent_dm_error_e sync_agent_alert_display(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // called by setted timer (alert_option->max_t)
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+       uic_type type = UIC_DISPLAY_TYPE;
+
+       request_event = sync_agent_create_event(EVENT_UIC_ALERT);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
+       _DEBUG_VERBOSE("UIC TYPE : %d", type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_FAIL;
+       }
+
+        free request & response event
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}*/
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_confirmation(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /*
+        * called by setted timer (alert_option->max_t)
+        *
+        * or
+        *
+        * called by click button
+        *
+        */
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+       uic_type type = UIC_CONFIRMATION_TYPE;
+
+       request_event = sync_agent_create_event(EVENT_UIC_ALERT);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
+
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+       _DEBUG_VERBOSE("UIC TYPE : %d", type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       /*
+        *
+        * must do destroy UI
+        *
+        * */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_inputtext(int response_type, char *text)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /*
+        * called by setted timer (alert_option->max_t)
+        *
+        * or
+        *
+        * called by click button
+        *
+        */
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       uic_type type = UIC_INPUT_TEXT_TYPE;
+
+       request_event = sync_agent_create_event(EVENT_UIC_ALERT);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, text);
+
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+       _DEBUG_VERBOSE("UIC TYPE : %d", type);
+       _DEBUG_VERBOSE("text : %s", text);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       /*
+        *
+        * must do destroy UI
+        *
+        * */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_single_choice(int response_type, int selected_count, char *selected_number)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /*
+        * called by setted timer (alert_option->max_t)
+        *
+        * or
+        *
+        * called by click button
+        *
+        */
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       uic_type type = UIC_SINGLE_CHOICE_TYPE;
+
+       request_event = sync_agent_create_event(EVENT_UIC_ALERT);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &selected_count);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, selected_number);
+
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+       _DEBUG_VERBOSE("UIC TYPE : %d", type);
+       _DEBUG_VERBOSE("selected_count : %d", selected_count);
+       _DEBUG_VERBOSE("selected_number : %s", selected_number);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       /*
+        *
+        * must do destroy UI
+        *
+        * */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_multiple_choice(int response_type, GList * out_data_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /*
+        * called by setted timer (alert_option->max_t)
+        *
+        * or
+        *
+        * called by click button
+        *
+        */
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       uic_type type = UIC_MULTIPLE_CHOICE_TYPE;
+
+       GList *iter = NULL;
+       int count = g_list_length(out_data_list);
+
+       request_event = sync_agent_create_event(EVENT_UIC_ALERT);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &count);
+
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+       _DEBUG_VERBOSE("UIC TYPE : %d", type);
+       _DEBUG_VERBOSE("selected_count : %d", count);
+
+       for (iter = out_data_list; iter != NULL; iter = g_list_next(iter)) {
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (char *)(iter->data));
+               _DEBUG_VERBOSE("selected_number : %s", (char *)(iter->data));
+       }
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       /*
+        *
+        * must do destroy UI
+        *
+        * */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+static int (*_get_alert_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data) {
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start (noti_type : %d)", noti_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       switch (noti_id) {
+       case NOTI_ALERT_DISPLAY:
+               return __display_noti_cb;
+               break;
+       case NOTI_ALERT_CONFIRMATION:
+               return __confirmation_noti_cb;
+               break;
+       case NOTI_ALERT_INPUTTEXT:
+               return __input_text_noti_cb;
+               break;
+       case NOTI_ALERT_SINGLE_CHOICE:
+               return __single_choice_noti_cb;
+               break;
+       case NOTI_ALERT_MULTIPLE_CHOICE:
+               return __multiple_choice_noti_cb;
+               break;
+       default:
+               return __default_noti_cb;
+               break;
+       }
+
+       return 0;
+}
+
+static int __display_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
+       if (alert_option == NULL) {
+               _DEBUG_ERROR("calloc fail");
+               return 0;
+       }
+       char *display_string = NULL;
+
+       sync_agent_get_event_data_param(request, &(alert_option->min_t));
+       sync_agent_get_event_data_param(request, &(alert_option->max_t));
+       sync_agent_get_event_data_param(request, &(alert_option->default_data));
+       sync_agent_get_event_data_param(request, &(alert_option->maxlen));
+       sync_agent_get_event_data_param(request, &(alert_option->input_type));
+       sync_agent_get_event_data_param(request, &(alert_option->echo_type));
+       sync_agent_get_event_data_param(request, &display_string);
+
+       _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
+       _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
+       _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
+       _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
+       _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
+       _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
+       _DEBUG_VERBOSE("display_string : %s", display_string);
+
+       /*
+        * must coding alert UI
+        * timer setting alert_option->max_t
+        *
+        */
+
+       if (alert_option != NULL) {
+               if (alert_option->min_t != NULL)
+                       g_free(alert_option->min_t);
+               if (alert_option->max_t != NULL)
+                       g_free(alert_option->max_t);
+               if (alert_option->default_data != NULL)
+                       g_free(alert_option->default_data);
+               if (alert_option->maxlen != NULL)
+                       g_free(alert_option->maxlen);
+               if (alert_option->input_type != NULL)
+                       g_free(alert_option->input_type);
+               if (alert_option->echo_type != NULL)
+                       g_free(alert_option->echo_type);
+
+               g_free(alert_option);
+       }
+
+       if (display_string != NULL)
+               g_free(display_string);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __confirmation_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
+       if (alert_option == NULL) {
+               _DEBUG_ERROR("calloc fail");
+               return 0;
+       }
+       char *display_string = NULL;
+
+       sync_agent_get_event_data_param(request, &(alert_option->min_t));
+       sync_agent_get_event_data_param(request, &(alert_option->max_t));
+       sync_agent_get_event_data_param(request, &(alert_option->default_data));
+       sync_agent_get_event_data_param(request, &(alert_option->maxlen));
+       sync_agent_get_event_data_param(request, &(alert_option->input_type));
+       sync_agent_get_event_data_param(request, &(alert_option->echo_type));
+       sync_agent_get_event_data_param(request, &display_string);
+
+       _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
+       _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
+       _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
+       _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
+       _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
+       _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
+       _DEBUG_VERBOSE("display_string : %s", display_string);
+
+       /*
+        * must coding alert UI
+        * timer setting alert_option->max_t
+        *
+        */
+
+       if (alert_option != NULL) {
+               if (alert_option->min_t != NULL)
+                       g_free(alert_option->min_t);
+               if (alert_option->max_t != NULL)
+                       g_free(alert_option->max_t);
+               if (alert_option->default_data != NULL)
+                       g_free(alert_option->default_data);
+               if (alert_option->maxlen != NULL)
+                       g_free(alert_option->maxlen);
+               if (alert_option->input_type != NULL)
+                       g_free(alert_option->input_type);
+               if (alert_option->echo_type != NULL)
+                       g_free(alert_option->echo_type);
+
+               g_free(alert_option);
+       }
+
+       if (display_string != NULL)
+               g_free(display_string);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __input_text_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
+       if (alert_option == NULL) {
+               _DEBUG_ERROR("calloc fail");
+               return 0;
+       }
+       char *display_string = NULL;
+
+       sync_agent_get_event_data_param(request, &(alert_option->min_t));
+       sync_agent_get_event_data_param(request, &(alert_option->max_t));
+       sync_agent_get_event_data_param(request, &(alert_option->default_data));
+       sync_agent_get_event_data_param(request, &(alert_option->maxlen));
+       sync_agent_get_event_data_param(request, &(alert_option->input_type));
+       sync_agent_get_event_data_param(request, &(alert_option->echo_type));
+       sync_agent_get_event_data_param(request, &display_string);
+
+       _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
+       _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
+       _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
+       _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
+       _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
+       _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
+       _DEBUG_VERBOSE("display_string : %s", display_string);
+
+       /*
+        * must coding alert UI
+        * timer setting alert_option->max_t
+        *
+        */
+
+       if (alert_option != NULL) {
+               if (alert_option->min_t != NULL)
+                       g_free(alert_option->min_t);
+               if (alert_option->max_t != NULL)
+                       g_free(alert_option->max_t);
+               if (alert_option->default_data != NULL)
+                       g_free(alert_option->default_data);
+               if (alert_option->maxlen != NULL)
+                       g_free(alert_option->maxlen);
+               if (alert_option->input_type != NULL)
+                       g_free(alert_option->input_type);
+               if (alert_option->echo_type != NULL)
+                       g_free(alert_option->echo_type);
+
+               g_free(alert_option);
+       }
+
+       if (display_string != NULL)
+               g_free(display_string);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __single_choice_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
+       if (alert_option == NULL) {
+               _DEBUG_ERROR("calloc fail");
+               return 0;
+       }
+       char *display_string = NULL;
+       int item_count = 0;
+       char *item = NULL;
+
+       sync_agent_get_event_data_param(request, &(alert_option->min_t));
+       sync_agent_get_event_data_param(request, &(alert_option->max_t));
+       sync_agent_get_event_data_param(request, &(alert_option->default_data));
+       sync_agent_get_event_data_param(request, &(alert_option->maxlen));
+       sync_agent_get_event_data_param(request, &(alert_option->input_type));
+       sync_agent_get_event_data_param(request, &(alert_option->echo_type));
+       sync_agent_get_event_data_param(request, &display_string);
+       sync_agent_get_event_data_param(request, &item_count);
+       sync_agent_get_event_data_param(request, &item);
+
+       _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
+       _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
+       _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
+       _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
+       _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
+       _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
+       _DEBUG_VERBOSE("display_string : %s", display_string);
+       _DEBUG_VERBOSE("item_count : %d", item_count);
+       _DEBUG_VERBOSE("item : %s", item);
+
+       /*
+        * must coding alert UI
+        * timer setting alert_option->max_t
+        *
+        */
+
+       if (alert_option != NULL) {
+               if (alert_option->min_t != NULL)
+                       g_free(alert_option->min_t);
+               if (alert_option->max_t != NULL)
+                       g_free(alert_option->max_t);
+               if (alert_option->default_data != NULL)
+                       g_free(alert_option->default_data);
+               if (alert_option->maxlen != NULL)
+                       g_free(alert_option->maxlen);
+               if (alert_option->input_type != NULL)
+                       g_free(alert_option->input_type);
+               if (alert_option->echo_type != NULL)
+                       g_free(alert_option->echo_type);
+
+               g_free(alert_option);
+       }
+
+       if (display_string != NULL)
+               g_free(display_string);
+
+       if (item != NULL)
+               g_free(item);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __multiple_choice_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
+       if (alert_option == NULL) {
+               _DEBUG_ERROR("calloc fail");
+               return 0;
+       }
+       char *display_string = NULL;
+       int item_count = 0;
+       int i = 0;
+       char *item = NULL;
+       GList *item_list = NULL;
+       GList *iter = NULL;
+
+       sync_agent_get_event_data_param(request, &(alert_option->min_t));
+       sync_agent_get_event_data_param(request, &(alert_option->max_t));
+       sync_agent_get_event_data_param(request, &(alert_option->default_data));
+       sync_agent_get_event_data_param(request, &(alert_option->maxlen));
+       sync_agent_get_event_data_param(request, &(alert_option->input_type));
+       sync_agent_get_event_data_param(request, &(alert_option->echo_type));
+       sync_agent_get_event_data_param(request, &display_string);
+       sync_agent_get_event_data_param(request, &item_count);
+
+       _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
+       _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
+       _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
+       _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
+       _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
+       _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
+       _DEBUG_VERBOSE("display_string : %s", display_string);
+       _DEBUG_VERBOSE("item_count : %d", item_count);
+
+       for (; i < item_count; i++) {
+               char *item = NULL;
+               sync_agent_get_event_data_param(request, &item);
+               _DEBUG_VERBOSE("item : %s", item);
+               item_list = g_list_append(item_list, item);
+       }
+
+       /*
+        * must coding alert UI
+        * timer setting alert_option->max_t
+        *
+        */
+
+       if (alert_option != NULL) {
+               if (alert_option->min_t != NULL)
+                       g_free(alert_option->min_t);
+               if (alert_option->max_t != NULL)
+                       g_free(alert_option->max_t);
+               if (alert_option->default_data != NULL)
+                       g_free(alert_option->default_data);
+               if (alert_option->maxlen != NULL)
+                       g_free(alert_option->maxlen);
+               if (alert_option->input_type != NULL)
+                       g_free(alert_option->input_type);
+               if (alert_option->echo_type != NULL)
+                       g_free(alert_option->echo_type);
+
+               g_free(alert_option);
+       }
+
+       if (display_string != NULL)
+               g_free(display_string);
+
+       if (item_list != NULL) {
+               for (iter = item_list; iter != NULL;) {
+                       item = (char *)(iter->data);
+                       iter = g_list_next(iter);
+                       item_list = g_list_remove(item_list, item);
+                       g_free(item);
+               }
+
+               g_list_free(item_list);
+       }
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
diff --git a/src/framework/event/oma_dm_api_common_internal.h b/src/framework/event/oma_dm_api_common_internal.h
new file mode 100755 (executable)
index 0000000..ea88d9d
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_API_COMMON_INTERNAL_H_
+#define OMA_DM_API_COMMON_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+       typedef enum {
+               CONNECTION_STATUS_FAILURE,
+               CONNECTION_STATUS_SUCCESS,
+               CONNECTION_STATUS_UPTODATA,
+               CONNECTION_STATUS_FAILURE_AUTHENTICATION
+       } sync_agent_dm_connection_status_e;
+
+       typedef enum {
+               EVENT_UNKNOWN = 0,
+
+               /* Fumo UI Common Event */
+               EVENT_SOFTWARE_UPDATE = 1,
+               EVENT_CANCEL,
+               EVENT_DOWNLOAD,
+               EVENT_INSTALL,
+               EVENT_SET_INTERVAL = 5,
+
+               /* Fumo Registration UI Event */
+               EVENT_ACCOUNT_REGISTRATION,
+
+               /* Admin UI Event */
+               EVENT_GET_FUMO_CONFIG,
+               EVENT_SET_FUMO_CONFIG,
+               EVENT_GET_PROFILE,
+               EVENT_SET_PROFILE = 10,
+               EVENT_RESET_PROFILE,
+
+               /* Alert UI Event */
+               EVENT_UIC_ALERT,
+
+               /* CP UI Event */
+               EVENT_CHECK_PIN_CODE,
+
+               /* DMACC_CONTROL UI Event */
+               EVENT_ADD_DMACC,
+               EVENT_REMOVE_DMACC,
+
+               EVENT_NUM
+       } sync_agent_dm_event_e;
+
+       typedef enum {
+               NOTI_UNKNOWN = 0,
+
+               /* Fumo UI Common Noti */
+               NOTI_DOWNLOAD = 1,
+               NOTI_INSTALL,
+               NOTI_DOWNLOAD_INFO,
+
+               /* Fumo UI Util Noti */
+               NOTI_ENGINE_START,
+               NOTI_ENGINE_FAIL = 5,
+               NOTI_WIFI_ONLY_DOWNLOAD_FAIL,
+               NOTI_MEMORY_FULL,
+               NOTI_OVER_BIG_SIZE,
+               NOTI_LOW_BATTERY,
+
+               /* Alert UI Noti */
+               NOTI_ALERT_DISPLAY = 10,
+               NOTI_ALERT_CONFIRMATION,
+               NOTI_ALERT_INPUTTEXT,
+               NOTI_ALERT_SINGLE_CHOICE,
+               NOTI_ALERT_MULTIPLE_CHOICE,
+
+               NOTI_NUM
+       } sync_agent_dm_noti_e;
+
+       typedef enum {
+               FOTA_COMMON_UI,
+               FOTA_NOTI_UI,
+               FOTA_BACKGROUND_UI,
+               ADMIN_UI,
+               ALERT_UI,
+               CP_UI,
+       } sync_agent_dm_ui_type_e;
+
+//2012.11.29
+       typedef enum _uic_type {
+               UIC_NONE_TYPE,
+               UIC_DISPLAY_TYPE,
+               UIC_CONFIRMATION_TYPE,
+               UIC_INPUT_TEXT_TYPE,
+               UIC_SINGLE_CHOICE_TYPE,
+               UIC_MULTIPLE_CHOICE_TYPE
+       } uic_type;
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* OMA_DM_API_COMMON_INTERNAL_H_ */
diff --git a/src/framework/event/oma_dm_cp_api.c b/src/framework/event/oma_dm_cp_api.c
new file mode 100755 (executable)
index 0000000..1e2b8f6
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_cp_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_CP_CONFIG_FILE  "/usr/share/oma-dm-cfg/fw-init/omadmcpui_fw_config.xml"
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_cp_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_CP_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+//      sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_cp_ui");
+//      if (err != SYNC_AGENT_EVENT_SUCCESS) {
+//              _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+//              result = UI_SYNC_AGENT_DM_FAIL;
+//      }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_cp_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_cp_check_pin_code(int ext_id, int response_type, char *user_pin, int *user_pin_val)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_CHECK_PIN_CODE);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_CHECK_PIN_CODE);
+
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ext_id);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
+       if (response_type == UI_RESPONSE_TYPE_OK)
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, user_pin);
+
+       _DEBUG_VERBOSE("ext_id : %d", ext_id);
+       _DEBUG_VERBOSE("response_type : %d", response_type);
+       _DEBUG_VERBOSE("user_pin : %s", user_pin);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, user_pin_val);
+       _DEBUG_VERBOSE("user pin validation value : %d", *user_pin_val);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
diff --git a/src/framework/event/oma_dm_dmacc_control_api.c b/src/framework/event/oma_dm_dmacc_control_api.c
new file mode 100755 (executable)
index 0000000..5fbdf99
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_dmacc_control_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_DMACC_CONFIG_FILE       "/usr/share/oma-dm-cfg/fw-init/omadmdmaccui_fw_config.xml"
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_dmacc_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_DMACC_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_dmacc_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_add_dmacc(sync_agent_dm_service_server_type_e dmacc_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_ADD_DMACC);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_ADD_DMACC);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &dmacc_type);
+       _DEBUG_VERBOSE("DMACC TYPE : %d", dmacc_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return UI_SYNC_AGENT_DM_SUCCESS;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_remove_dmacc(sync_agent_dm_service_server_type_e dmacc_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(EVENT_REMOVE_DMACC);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", EVENT_REMOVE_DMACC);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &dmacc_type);
+       _DEBUG_VERBOSE("DMACC TYPE : %d", dmacc_type);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return UI_SYNC_AGENT_DM_SUCCESS;
+}
diff --git a/src/framework/event/oma_dm_fota_api.c b/src/framework/event/oma_dm_fota_api.c
new file mode 100755 (executable)
index 0000000..e685c0b
--- /dev/null
@@ -0,0 +1,514 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_fota_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_FOTA_CONFIG_FILE        "/usr/share/oma-dm-cfg/fw-init/omadmfotaui_fw_config.xml"
+
+static int (*_get_fota_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data);
+
+static int __download_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __install_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __download_info_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __engine_start_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __engine_fail_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __wifi_only_download_fail_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __memory_full_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __over_big_size_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __low_battery_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data);
+
+static int _fota_event_interface(sync_agent_dm_event_e event_num, int user_data);
+
+static int task_id = 0;
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_FOTA_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_fota_ui");
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       int noti_id = NOTI_DOWNLOAD;
+       for (; noti_id < NOTI_ALERT_DISPLAY; noti_id++) {
+               err = sync_agent_set_noti_callback(noti_id, _get_fota_noti_callback(noti_id), NULL);
+               if (err != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_set_noti_callback(noti_id : %d) failed - err : %d !!", noti_id, err);
+                       result = UI_SYNC_AGENT_DM_FAIL;
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_software_update(sync_agent_dm_service_server_type_e server_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_fota_event_interface(EVENT_SOFTWARE_UPDATE, server_type) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_fota_event_interface(event num : %d) failed !!", EVENT_SOFTWARE_UPDATE);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_fota_event_interface(event num : %d) success !!", EVENT_SOFTWARE_UPDATE);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_cancel()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_fota_event_interface(EVENT_CANCEL, 0) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_fota_event_interface(event num : %d) failed !!", EVENT_CANCEL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_fota_event_interface(event num : %d) success !!", EVENT_CANCEL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_download(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_fota_event_interface(EVENT_DOWNLOAD, response_type) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_fota_event_interface(event num : %d) failed !!", EVENT_DOWNLOAD);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_fota_event_interface(event num : %d) success !!", EVENT_DOWNLOAD);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_install(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_fota_event_interface(EVENT_INSTALL, response_type) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_fota_event_interface(event num : %d) failed !!", EVENT_INSTALL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_fota_event_interface(event num : %d) success !!", EVENT_INSTALL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_set_interval(int interval_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_fota_event_interface(EVENT_SET_INTERVAL, interval_type) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_fota_event_interface(event num : %d) failed !!", EVENT_SET_INTERVAL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_fota_event_interface(event num : %d) success !!", EVENT_SET_INTERVAL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+static int (*_get_fota_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data) {
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start (noti_type : %d)", noti_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       switch (noti_id) {
+       case NOTI_DOWNLOAD:
+               return __download_noti_cb;
+               break;
+       case NOTI_INSTALL:
+               return __install_noti_cb;
+               break;
+       case NOTI_DOWNLOAD_INFO:
+               return __download_info_noti_cb;
+               break;
+       case NOTI_ENGINE_START:
+               return __engine_start_noti_cb;
+               break;
+       case NOTI_ENGINE_FAIL:
+               return __engine_fail_noti_cb;
+               break;
+       case NOTI_WIFI_ONLY_DOWNLOAD_FAIL:
+               return __wifi_only_download_fail_noti_cb;
+               break;
+       case NOTI_MEMORY_FULL:
+               return __memory_full_noti_cb;
+               break;
+       case NOTI_OVER_BIG_SIZE:
+               return __over_big_size_noti_cb;
+               break;
+       case NOTI_LOW_BATTERY:
+               return __low_battery_noti_cb;
+               break;
+       default:
+               return __default_noti_cb;
+               break;
+       }
+
+       return 0;
+}
+
+static int __download_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __install_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __download_info_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int file_size = 0;
+       char *file_path = NULL;
+
+       sync_agent_get_event_data_param(request, &file_size);
+       sync_agent_get_event_data_param(request, &file_path);
+       sync_agent_get_event_data_param(request, &task_id);
+
+       _DEBUG_VERBOSE("file_size : %d", file_size);
+       _DEBUG_VERBOSE("file_path : %s", file_path);
+       _DEBUG_VERBOSE("task id : %d", task_id);
+
+       off_t return_stat;
+       struct stat file_info;
+       long int down_size = 0;
+       double percent = 0.0;
+
+       while (percent != 1.0) {
+               if ((return_stat = stat(file_path, &file_info)) == -1) {
+                       _DEBUG_ERROR("Error: get file size !!");
+                       g_free(file_path);
+                       return 0;
+               }
+               down_size = (long int)(file_info.st_size);
+               percent = ((double)down_size) / ((double)file_size);
+               _DEBUG_VERBOSE("download percent : %d", (int)(percent * 100));
+               usleep(100000);
+       }
+
+       _DEBUG_VERBOSE("download complete !!");
+
+       g_free(file_path);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __engine_start_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       _DEBUG_VERBOSE("task id : %d", task_id);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __engine_fail_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int prev_noti_id = -1;
+       int fail_type = -1;
+
+       sync_agent_get_event_data_param(request, &prev_noti_id);
+       sync_agent_get_event_data_param(request, &fail_type);
+
+       _DEBUG_VERBOSE("previous noti id : %d", prev_noti_id);
+       _DEBUG_VERBOSE("fail type : %d", fail_type);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __wifi_only_download_fail_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __memory_full_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int file_size = 0;
+
+       sync_agent_get_event_data_param(request, &file_size);
+
+       _DEBUG_VERBOSE("file_size : %d", file_size);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __over_big_size_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __low_battery_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       char *battery_level = NULL;
+
+       sync_agent_get_event_data_param(request, &battery_level);
+
+       _DEBUG_VERBOSE("battery level : %s", battery_level);
+
+       g_free(battery_level);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_ERROR("noti_id flow is [%s]", "default");
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int _fota_event_interface(sync_agent_dm_event_e event_num, int user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       request_event = sync_agent_create_event(event_num);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", event_num);
+
+       switch (event_num) {
+       case EVENT_SOFTWARE_UPDATE:
+               {
+                       sync_agent_dm_ui_type_e ui_type = FOTA_COMMON_UI;
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ui_type);
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &task_id);
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &user_data);
+
+                       _DEBUG_VERBOSE("ui_type : FOTA_COMMON_UI");
+                       _DEBUG_VERBOSE("task_id : %d", task_id);
+               }
+               break;
+       case EVENT_CANCEL:
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &task_id);
+
+               _DEBUG_VERBOSE("task_id : %d", task_id);
+               break;
+       case EVENT_DOWNLOAD:
+       case EVENT_INSTALL:
+       case EVENT_SET_INTERVAL:
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &user_data);
+               break;
+       default:
+               break;
+       }
+
+       _DEBUG_VERBOSE("user_data : %d", user_data);
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       _DEBUG_VERBOSE("api_result : %d", api_result);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return api_result;
+}
diff --git a/src/framework/event/oma_dm_noti_api.c b/src/framework/event/oma_dm_noti_api.c
new file mode 100755 (executable)
index 0000000..0492618
--- /dev/null
@@ -0,0 +1,533 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_noti_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_PUSH_CONFIG_FILE        "/usr/share/oma-dm-cfg/fw-init/omadmnotiui_fw_config.xml"
+
+static int (*_get_push_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data);
+
+static int __download_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __install_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __download_info_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __engine_start_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __engine_fail_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __wifi_only_download_fail_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __memory_full_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __over_big_size_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __low_battery_noti_cb(sync_agent_event_data_s * request, void *data);
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data);
+
+static int _push_event_interface(sync_agent_dm_event_e event_num, int user_data, char *server_id, char *session_id);
+
+static int task_id = 0;
+
+typedef enum {
+       PUSH_TYPE_NONE = -1,
+       PUSH_NOT_SPECIFIED = 0,
+       PUSH_BACKGROUND,
+       PUSH_INFORMATIVE,
+       PUSH_INTERACTION
+} sync_agent_dm_push_type;
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_push_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_PUSH_CONFIG_FILE);
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_noti_ui");
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       int noti_id = NOTI_DOWNLOAD;
+       for (; noti_id < NOTI_ALERT_DISPLAY; noti_id++) {
+               err = sync_agent_set_noti_callback(noti_id, _get_push_noti_callback(noti_id), NULL);
+               if (err != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_set_noti_callback(noti_id : %d) failed - err : %d !!", noti_id, err);
+                       result = UI_SYNC_AGENT_DM_FAIL;
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_push_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_update_noti(char *server_id, char *session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if((session_id == NULL || server_id == NULL), UI_SYNC_AGENT_DM_FAIL, "session id is null or server id is null ");
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_push_event_interface(EVENT_SOFTWARE_UPDATE, 0, server_id, session_id) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_push_event_interface(event num : %d) failed !!", EVENT_SOFTWARE_UPDATE);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_push_event_interface(event num : %d) success !!", EVENT_SOFTWARE_UPDATE);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_cancel_noti()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_push_event_interface(EVENT_CANCEL, 0, NULL, NULL) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_push_event_interface(event num : %d) failed !!", EVENT_CANCEL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_push_event_interface(event num : %d) success !!", EVENT_CANCEL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_download_noti(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_push_event_interface(EVENT_DOWNLOAD, response_type, NULL, NULL) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_push_event_interface(event num : %d) failed !!", EVENT_DOWNLOAD);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_push_event_interface(event num : %d) success !!", EVENT_DOWNLOAD);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_install_noti(int response_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_push_event_interface(EVENT_INSTALL, response_type, NULL, NULL) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_push_event_interface(event num : %d) failed !!", EVENT_INSTALL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_push_event_interface(event num : %d) success !!", EVENT_INSTALL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_fota_set_interval_noti(int interval_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       if (_push_event_interface(EVENT_SET_INTERVAL, interval_type, NULL, NULL) != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("_push_event_interface(event num : %d) failed !!", EVENT_SET_INTERVAL);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       } else {
+               _DEBUG_VERBOSE("_push_event_interface(event num : %d) success !!", EVENT_SET_INTERVAL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+static int (*_get_push_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data) {
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start (noti_type : %d)", noti_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       switch (noti_id) {
+       case NOTI_DOWNLOAD:
+               return __download_noti_cb;
+               break;
+       case NOTI_INSTALL:
+               return __install_noti_cb;
+               break;
+       case NOTI_DOWNLOAD_INFO:
+               return __download_info_noti_cb;
+               break;
+       case NOTI_ENGINE_START:
+               return __engine_start_noti_cb;
+               break;
+       case NOTI_ENGINE_FAIL:
+               return __engine_fail_noti_cb;
+               break;
+       case NOTI_WIFI_ONLY_DOWNLOAD_FAIL:
+               return __wifi_only_download_fail_noti_cb;
+               break;
+       case NOTI_MEMORY_FULL:
+               return __memory_full_noti_cb;
+               break;
+       case NOTI_OVER_BIG_SIZE:
+               return __over_big_size_noti_cb;
+               break;
+       case NOTI_LOW_BATTERY:
+               return __low_battery_noti_cb;
+               break;
+       default:
+               return __default_noti_cb;
+               break;
+       }
+
+       return 0;
+}
+
+static int __download_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __install_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __download_info_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int file_size = 0;
+       char *file_path = NULL;
+
+       sync_agent_get_event_data_param(request, &file_size);
+       sync_agent_get_event_data_param(request, &file_path);
+       sync_agent_get_event_data_param(request, &task_id);
+
+       _DEBUG_VERBOSE("file_size : %d", file_size);
+       _DEBUG_VERBOSE("file_path : %s", file_path);
+       _DEBUG_VERBOSE("task id : %d", task_id);
+
+       off_t return_stat;
+       struct stat file_info;
+       long int down_size = 0;
+       double percent = 0.0;
+
+       while (percent != 1.0) {
+               if ((return_stat = stat(file_path, &file_info)) == -1) {
+                       _DEBUG_ERROR("Error: get file size !!");
+                       g_free(file_path);
+                       return 0;
+               }
+               down_size = (long int)(file_info.st_size);
+               percent = ((double)down_size) / ((double)file_size);
+               _DEBUG_VERBOSE("download percent : %d", (int)(percent * 100));
+               usleep(100000);
+       }
+
+       _DEBUG_VERBOSE("download complete !!");
+
+       g_free(file_path);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __engine_start_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_get_event_data_param(request, &task_id);
+
+       _DEBUG_VERBOSE("task id : %d", task_id);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __engine_fail_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int prev_noti_id = -1;
+       int fail_type = -1;
+
+       sync_agent_get_event_data_param(request, &prev_noti_id);
+       sync_agent_get_event_data_param(request, &fail_type);
+
+       _DEBUG_VERBOSE("previous noti id : %d", prev_noti_id);
+       _DEBUG_VERBOSE("fail type : %d", fail_type);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __wifi_only_download_fail_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __memory_full_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int file_size = 0;
+
+       sync_agent_get_event_data_param(request, &file_size);
+
+       _DEBUG_VERBOSE("file_size : %d", file_size);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __over_big_size_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __low_battery_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       char *battery_level = NULL;
+
+       sync_agent_get_event_data_param(request, &battery_level);
+
+       _DEBUG_VERBOSE("battery level : %s", battery_level);
+
+       g_free(battery_level);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int __default_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_ERROR("noti_id flow is [%s]", "default");
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static int _push_event_interface(sync_agent_dm_event_e event_num, int user_data, char *server_id, char *session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+       char *real_session_id = NULL;
+       char *real_server_id = NULL;
+
+       request_event = sync_agent_create_event(event_num);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("request_event is NULL !!");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       _DEBUG_VERBOSE("event num : %d", event_num);
+
+       switch (event_num) {
+       case EVENT_SOFTWARE_UPDATE:
+               {
+                       sync_agent_dm_ui_type_e ui_type = FOTA_NOTI_UI;
+                       real_session_id = strdup(session_id);
+                       real_server_id = strdup(server_id);
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ui_type);
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, real_session_id);
+                       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, real_server_id);
+
+                       _DEBUG_VERBOSE("ui_type : FOTA_NOTI_UI");
+                       _DEBUG_VERBOSE("SESSION_ID : %s", real_session_id);
+                       _DEBUG_VERBOSE("SERVER_ID : %s", real_server_id);
+               }
+               break;
+       case EVENT_CANCEL:
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &task_id);
+
+               _DEBUG_VERBOSE("task_id : %d", task_id);
+               break;
+       case EVENT_DOWNLOAD:
+       case EVENT_INSTALL:
+       case EVENT_SET_INTERVAL:
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &user_data);
+
+               _DEBUG_VERBOSE("user_data : %d", user_data);
+               break;
+       default:
+               break;
+       }
+
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is NULL !!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
+               _DEBUG_ERROR("api_result : failed !!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DM_API_RESULT_FAILURE;
+       }
+
+       _DEBUG_VERBOSE("api_result : %d", api_result);
+
+       /* free request & response event */
+       if (event_num == EVENT_SOFTWARE_UPDATE) {
+               free(real_session_id);
+               free(real_server_id);
+       }
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return api_result;
+}
diff --git a/src/framework/event/oma_dm_registration_api.c b/src/framework/event/oma_dm_registration_api.c
new file mode 100755 (executable)
index 0000000..4c255c3
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//#define COMPONENT_TAG APP
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADM_CLIENT"
+#endif
+
+#include <sync_agent.h>
+
+#include "oma_dm_registration_api.h"
+#include "oma_dm_api_common_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DM_REG_CONFIG_FILE "/usr/share/oma-dm-cfg/fw-init/omadmadminui_fw_config.xml"
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_reg_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_deinit() failed !!");
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+       /*
+          sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+
+          err = sync_agent_clean_event_handler();
+          if (err != SYNC_AGENT_EVENT_SUCCESS) {
+          _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+          result = UI_SYNC_AGENT_DM_FAIL;
+          }
+        */
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_reg_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+//      sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+//      if (err != SYNC_AGENT_EVENT_SUCCESS) {
+//              _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
+//              result = UI_SYNC_AGENT_DM_FAIL;
+//      }
+
+       sync_agent_event_error_e err = sync_agent_clean_event_handler();
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
+               result = UI_SYNC_AGENT_DM_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_dm_error_e sync_agent_dm_reg_account_registration()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
+
+       /*
+        * must coding
+        *
+        */
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
diff --git a/src/framework/event/oma_ds_api.c b/src/framework/event/oma_ds_api.c
new file mode 100755 (executable)
index 0000000..1797ec1
--- /dev/null
@@ -0,0 +1,1317 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "OMADS_CLIENT"
+#endif
+
+//#include <sync_agent.h>
+#include "event/event.h"
+#include "utility/sync_util.h"
+#include "initialization/initialization.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#define OMA_DS_CONFIG_FILE     "/usr/share/oma-ds-cfg/omadsUI_fw_config.xml"
+
+#define SYNC_AGENT_DS_API_RESULT_FAILURE       0
+#define SYNC_AGENT_DS_API_RESULT_SUCCESS       1
+
+typedef enum {
+       SYNC_AGENT_DS_ADD_PROFILE = 1,
+       SYNC_AGENT_DS_UPDATE_PROFILE = 2,
+       SYNC_AGENT_DS_DELETE_PROFILE = 3,
+       SYNC_AGENT_DS_START_SYNC = 4,
+       SYNC_AGENT_DS_STOP_SYNC = 5,
+       SYNC_AGENT_DS_GET_PROFILE = 6,
+       SYNC_AGENT_DS_GET_SYNC_CATEGORY = 7,
+       SYNC_AGENT_DS_GET_SYNC_STATISTICS = 8,
+       SYNC_AGENT_DS_GET_ALL_PROFILES = 9
+} sync_agent_ds_event_e;
+
+typedef enum {
+       SYNC_AGENT_DS_SYNC_CONTACTS = 0,
+       SYNC_AGENT_DS_SYNC_SCHEDULE = 1,
+       SYNC_AGENT_DS_SYNC_MEMO = 2
+} sync_agent_ds_sync_e;
+
+static gboolean _get_sync_category(char *profile_dir_name, int service_type, sync_agent_ds_service_info ** service)
+{
+       _INNER_FUNC_ENTER;
+
+       int event_type = SYNC_AGENT_DS_GET_SYNC_CATEGORY;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       // check mandatory parameter
+       retvm_if(profile_dir_name == NULL, FALSE, "profile_dir_name is null!!");
+       retvm_if(service_type < 0, FALSE, "service_type is wrong!!");
+
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_dir_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &service_type);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       *service = (sync_agent_ds_service_info *) calloc(1, sizeof(sync_agent_ds_service_info));
+       if (*service == NULL) {
+               _DEBUG_ERROR("calloc failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               return FALSE;
+       }
+
+       /* get response parameter from event packet */
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &((*service)->enabled));
+       sync_agent_get_event_data_param(response_event, &((*service)->src_uri));
+       sync_agent_get_event_data_param(response_event, &((*service)->tgt_uri));
+       sync_agent_get_event_data_param(response_event, &((*service)->id));
+       sync_agent_get_event_data_param(response_event, &((*service)->password));
+
+       _DEBUG_TRACE("enabled = %d", (*service)->enabled);
+       _DEBUG_TRACE("src_uri = %s", (*service)->src_uri);
+       _DEBUG_TRACE("tgt_uri = %s", (*service)->tgt_uri);
+       _DEBUG_TRACE("id = %s", (*service)->id);
+       _DEBUG_TRACE("password = %s", (*service)->password);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean _get_sync_statistics(char *profile_dir_name, int service_type, sync_agent_ds_statistics_info ** statistics)
+{
+       _INNER_FUNC_ENTER;
+
+       int event_type = SYNC_AGENT_DS_GET_SYNC_STATISTICS;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       // check mandatory parameter
+       retvm_if(profile_dir_name == NULL, FALSE, "profile_dir_name is null!!");
+       retvm_if(service_type < 0, FALSE, "service_type is wrong!!");
+
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       char *statistics_cat = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_dir_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &service_type);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       *statistics = (sync_agent_ds_statistics_info *) calloc(1, sizeof(sync_agent_ds_statistics_info));
+       if (*statistics == NULL) {
+               _DEBUG_ERROR("calloc failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               return 0;
+       }
+
+       /* get response parameter from event packet */
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       if (service_type == SYNC_AGENT_DS_SYNC_CONTACTS)
+               statistics_cat = "contacts";
+       else if (service_type == SYNC_AGENT_DS_SYNC_SCHEDULE)
+               statistics_cat = "schedule";
+       else if (service_type == SYNC_AGENT_DS_SYNC_MEMO)
+               statistics_cat = "memo";
+
+       sync_agent_get_event_data_param(response_event, &((*statistics)->dbsynced));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->last_session_time));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_total));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofadd));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofdelete));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->server2client_nrofreplace));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_total));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofadd));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofdelete));
+       sync_agent_get_event_data_param(response_event, &((*statistics)->client2server_nrofreplace));
+
+       _DEBUG_TRACE("%s dbSynced = %s", statistics_cat, (*statistics)->dbsynced);
+       _DEBUG_TRACE("%s lastSessionTime = %d", statistics_cat, (*statistics)->last_session_time);
+       _DEBUG_TRACE("%s server2Client_Total = %d", statistics_cat, (*statistics)->server2client_total);
+       _DEBUG_TRACE("%s server2Client_NrOrAdd = %d", statistics_cat, (*statistics)->server2client_nrofadd);
+       _DEBUG_TRACE("%s server2Client_NrOfDelete = %d", statistics_cat, (*statistics)->server2client_nrofdelete);
+       _DEBUG_TRACE("%s server2Client_NrOfReplace = %d", statistics_cat, (*statistics)->server2client_nrofreplace);
+       _DEBUG_TRACE("%s client2Server_Total = %d", statistics_cat, (*statistics)->client2server_total);
+       _DEBUG_TRACE("%s client2Server_NrOfAdd = %d", statistics_cat, (*statistics)->client2server_nrofadd);
+       _DEBUG_TRACE("%s client2Server_NrOfDelete = %d", statistics_cat, (*statistics)->client2server_nrofdelete);
+       _DEBUG_TRACE("%s client2Server_NrOfReplace = %d", statistics_cat, (*statistics)->client2server_nrofreplace);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static void _free_sync_category_info(sync_agent_ds_service_info * data)
+{
+       g_free(data->src_uri);
+       g_free(data->tgt_uri);
+       g_free(data->id);
+       g_free(data->password);
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(OMA_DS_CONFIG_FILE);
+
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("ds init failed");
+               result = SYNC_AGENT_DS_FAIL;
+       }
+
+       sync_agent_event_error_e err = sync_agent_run_noti_listener("omads");
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("RUN NOTILISTNER is failed");
+               result = SYNC_AGENT_DS_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_create_profile_info(ds_profile_h * profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+       sync_agent_ds_profile_info *profile_info = NULL;
+
+       // allocate memory for ds profile info
+       profile_info = (sync_agent_ds_profile_info *) calloc(1, sizeof(sync_agent_ds_profile_info));
+       if (profile_info == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+       // pass memory pointer to ds profile handle
+       *profile_h = profile_info;
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_dir_name, char *profile_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
+       // set profile name
+       profile_info->profile_dir_name = g_strdup(profile_dir_name);
+       profile_info->profile_name = g_strdup(profile_name);
+
+       if (profile_info->profile_dir_name == NULL) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_server_info(ds_profile_h profile_h, char *addr, char *id, char *password)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_server_info *server_info = &profile_info->server_info;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(addr == NULL, SYNC_AGENT_DS_FAIL, "addr is null!!");
+       retvm_if(id == NULL, SYNC_AGENT_DS_FAIL, "id is null!!");
+       retvm_if(password == NULL, SYNC_AGENT_DS_FAIL, "password is null!!");
+
+       // set server info
+       server_info->addr = g_strdup(addr);
+       server_info->id = g_strdup(id);
+       server_info->password = g_strdup(password);
+
+       if ((server_info->addr == NULL)
+           || (server_info->id == NULL)
+           || (server_info->password == NULL)) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, char *sync_mode, char *sync_type, char *interval)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(sync_mode == NULL, SYNC_AGENT_DS_FAIL, "sync_mode is null!!");
+       retvm_if(sync_type == NULL, SYNC_AGENT_DS_FAIL, "sync_type is null!!");
+       retvm_if(interval == NULL, SYNC_AGENT_DS_FAIL, "interval is null!!");
+
+       // set server info
+       sync_info->sync_mode = g_strdup(sync_mode);
+       sync_info->sync_type = g_strdup(sync_type);
+       sync_info->interval = g_strdup(interval);
+
+       if ((sync_info->sync_mode == NULL)
+           || (sync_info->sync_type == NULL)
+           || (sync_info->interval == NULL)) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_service_info *category_info = NULL;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(src_uri == NULL, SYNC_AGENT_DS_FAIL, "src_uri is null!!");
+
+       // allocate memory for sync_category
+       category_info = (sync_agent_ds_service_info *) calloc(1, sizeof(sync_agent_ds_service_info));
+       retvm_if(category_info == NULL, SYNC_AGENT_DS_FAIL, "calloc failed");
+       category_info->service_type = service_type;
+       category_info->enabled = enabled;
+       category_info->src_uri = g_strdup(src_uri);
+       category_info->tgt_uri = g_strdup(tgt_uri);
+
+       profile_info->service_list = g_list_append(profile_info->service_list, category_info);
+
+       if (category_info->src_uri == NULL) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_dir_name, char **profile_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+       *profile_dir_name = g_strdup(profile_info->profile_dir_name);
+       *profile_name = g_strdup(profile_info->profile_name);
+
+       if ((*profile_dir_name == NULL)
+           || (*profile_name == NULL)) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _DEBUG_INFO("profileDirame = %s", *profile_dir_name);
+       _DEBUG_INFO("get_profile_name = %s", *profile_name);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_server_info(ds_profile_h profile_h, sync_agent_ds_server_info * server_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(server_info == NULL, SYNC_AGENT_DS_FAIL, "server_info is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_server_info *ds_server_info = &profile_info->server_info;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+       server_info->addr = g_strdup(ds_server_info->addr);
+       server_info->id = g_strdup(ds_server_info->id);
+       server_info->password = g_strdup(ds_server_info->password);
+
+       if ((server_info->addr == NULL)
+           || (server_info->id == NULL)
+           || (server_info->password == NULL)) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _DEBUG_INFO("get_addr = %s", server_info->addr);
+       _DEBUG_INFO("get_id = %s", server_info->id);
+       _DEBUG_INFO("get_password = %s", server_info->password);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_sync_info(ds_profile_h profile_h, sync_agent_ds_sync_info * sync_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(sync_info == NULL, SYNC_AGENT_DS_FAIL, "sync_info is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_sync_info *ds_sync_info = &profile_info->sync_info;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+       sync_info->sync_mode = g_strdup(ds_sync_info->sync_mode);
+       sync_info->sync_type = g_strdup(ds_sync_info->sync_type);
+       sync_info->interval = g_strdup(ds_sync_info->interval);
+
+       if ((sync_info->sync_mode == NULL)
+           || (sync_info->sync_type == NULL)
+           || (sync_info->interval == NULL)) {
+               _DEBUG_ERROR("g_strdup failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       _DEBUG_INFO("get_sync_mode = %s", sync_info->sync_mode);
+       _DEBUG_INFO("get_sync_type = %s", sync_info->sync_type);
+       _DEBUG_INFO("get_interval = %s", sync_info->interval);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_sync_service_info(ds_profile_h profile_h, GList ** category_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       int category_count = 0;
+       int i = 0;
+       sync_agent_ds_service_info *category_info = NULL;
+
+       *category_list = g_list_copy(profile_info->service_list);
+
+       if (*category_list == NULL) {
+               _DEBUG_ERROR("g_list_copy failed !!");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       category_count = g_list_length(*category_list);
+       for (; i < category_count; i++) {
+               category_info = (sync_agent_ds_service_info *) g_list_nth_data(*category_list, i);
+
+               _DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
+               _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
+               _DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
+               _DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
+               _DEBUG_INFO("category[%d]->password = %s", i, category_info->password);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_sync_statistics(ds_profile_h profile_h, GList ** statistics_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_statistics_info *statistics = NULL;
+
+       gboolean result_sync_category = FALSE;
+
+       /* get last contacts sync result */
+       result_sync_category = _get_sync_statistics(profile_info->profile_dir_name, SYNC_AGENT_DS_SYNC_CONTACTS, &statistics);
+       if (result_sync_category)
+               *statistics_list = g_list_append(*statistics_list, statistics);
+
+       /* get last schedule sync result */
+       statistics = NULL;
+       result_sync_category = _get_sync_statistics(profile_info->profile_dir_name, SYNC_AGENT_DS_SYNC_SCHEDULE, &statistics);
+       if (result_sync_category)
+               *statistics_list = g_list_append(*statistics_list, statistics);
+
+       /* get last memo sync result */
+       statistics = NULL;
+       result_sync_category = _get_sync_statistics(profile_info->profile_dir_name, SYNC_AGENT_DS_SYNC_MEMO, &statistics);
+       if (result_sync_category)
+               *statistics_list = g_list_append(*statistics_list, statistics);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_add_profile(ds_profile_h profile_h, int *profile_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_server_info *server_info = &profile_info->server_info;
+       sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+       GList *list = profile_info->service_list;
+
+       int event_type = SYNC_AGENT_DS_ADD_PROFILE;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       int prof_id = 0;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+       sync_agent_ds_service_info *category_info = NULL;
+       int category_count = 0;
+       int i = 0;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       _DEBUG_INFO("profile_dir_name = %s", profile_info->profile_dir_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+       _DEBUG_INFO("profile_name = %s", profile_info->profile_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
+       _DEBUG_INFO("addr = %s", server_info->addr);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->addr);
+       _DEBUG_INFO("id = %s", server_info->id);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
+       _DEBUG_INFO("password = %s", server_info->password);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
+       _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
+       _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
+       _DEBUG_INFO("interval = %s", sync_info->interval);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
+
+       category_count = g_list_length(list);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
+
+       for (; i < category_count; i++) {
+               category_info = (sync_agent_ds_service_info *) g_list_nth_data(list, i);
+
+               _DEBUG_INFO("category[%d]->service_type = %d", i, category_info->service_type);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->service_type));
+               _DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->enabled));
+               _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
+               _DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
+               _DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->id);
+               _DEBUG_INFO("category[%d]->password = %s", i, category_info->password);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->password);
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+       sync_agent_get_event_data_param(response_event, &api_result);
+
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &prof_id);
+
+       _DEBUG_VERBOSE("profile_id = %d", prof_id);
+       *profile_id = prof_id;
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_profile(char *profile_dir_name, ds_profile_h * profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int event_type = SYNC_AGENT_DS_GET_PROFILE;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       gboolean result_sync_category = FALSE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+       sync_agent_ds_service_info *category = NULL;
+
+       // check mandatory parameter
+       retvm_if(profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
+       //////////////////////////////////
+       //
+       // Phase 1. get profile detail info
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_dir_name);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+
+       result = sync_agent_ds_create_profile_info(profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               return FALSE;
+       }
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) (*profile_h);
+       sync_agent_ds_server_info *server_info = &profile_info->server_info;
+       sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+//      GList * list = profile_info->category_list;
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       profile_info->profile_dir_name = g_strdup(profile_dir_name);
+
+       sync_agent_get_event_data_param(response_event, &profile_info->profile_name);
+       sync_agent_get_event_data_param(response_event, &server_info->addr);
+       sync_agent_get_event_data_param(response_event, &server_info->id);
+       sync_agent_get_event_data_param(response_event, &server_info->password);
+       sync_agent_get_event_data_param(response_event, &sync_info->sync_mode);
+       sync_agent_get_event_data_param(response_event, &sync_info->sync_type);
+       sync_agent_get_event_data_param(response_event, &sync_info->interval);
+       sync_agent_get_event_data_param(response_event, &profile_info->last_sync_status);
+       sync_agent_get_event_data_param(response_event, &profile_info->last_sync_time);
+
+       _DEBUG_INFO("profileDirame = %s", profile_info->profile_name);
+       _DEBUG_INFO("addr = %s", server_info->addr);
+       _DEBUG_INFO("id = %s", server_info->id);
+       _DEBUG_INFO("password = %s", server_info->password);
+       _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
+       _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
+       _DEBUG_INFO("interval = %s", sync_info->interval);
+       _DEBUG_VERBOSE("lastSyncStatus = %d\n", profile_info->last_sync_status);
+       _DEBUG_VERBOSE("lastSyncTime = %d\n", profile_info->last_sync_time);
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       //////////////////////////////////
+       //
+       // Phase 2. get sync category info
+
+       /* get contacts sync_category */
+       result_sync_category = _get_sync_category(profile_dir_name, SYNC_AGENT_DS_SYNC_CONTACTS, &category);
+       if (result_sync_category)
+               profile_info->service_list = g_list_append(profile_info->service_list, category);
+
+       /* get schedule sync_category */
+       category = NULL;
+       result_sync_category = _get_sync_category(profile_dir_name, SYNC_AGENT_DS_SYNC_SCHEDULE, &category);
+       if (result_sync_category)
+               profile_info->service_list = g_list_append(profile_info->service_list, category);
+
+       /* get memo sync_category */
+       category = NULL;
+       result_sync_category = _get_sync_category(profile_dir_name, SYNC_AGENT_DS_SYNC_MEMO, &category);
+       if (result_sync_category)
+               profile_info->service_list = g_list_append(profile_info->service_list, category);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_all_profile(GList ** profile_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int event_type = SYNC_AGENT_DS_GET_ALL_PROFILES;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       ds_profile_h profile_h = NULL;
+       sync_agent_ds_service_info *category_info = NULL;
+
+       int profile_count = 0;
+       int category_count = 0;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       sync_agent_get_event_data_param(response_event, &profile_count);
+       _DEBUG_INFO("profile_count = %d", profile_count);
+
+       int i;
+       for (i = 0; i < profile_count; i++) {
+
+               result = sync_agent_ds_create_profile_info(&profile_h);
+               if (result == SYNC_AGENT_DS_FAIL) {
+                       _DEBUG_ERROR("failed to create profile info!");
+                       sync_agent_free_event(request_event);
+                       sync_agent_free_event_data(response_event);
+                       return FALSE;
+               }
+
+               sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+               sync_agent_ds_server_info *server_info = &profile_info->server_info;
+               sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+
+               sync_agent_get_event_data_param(response_event, &profile_info->profile_dir_name);
+               sync_agent_get_event_data_param(response_event, &profile_info->profile_name);
+               sync_agent_get_event_data_param(response_event, &server_info->addr);
+               sync_agent_get_event_data_param(response_event, &server_info->id);
+               sync_agent_get_event_data_param(response_event, &server_info->password);
+               sync_agent_get_event_data_param(response_event, &sync_info->sync_mode);
+               sync_agent_get_event_data_param(response_event, &sync_info->sync_type);
+               sync_agent_get_event_data_param(response_event, &sync_info->interval);
+               sync_agent_get_event_data_param(response_event, &profile_info->last_sync_status);
+               sync_agent_get_event_data_param(response_event, &profile_info->last_sync_time);
+
+               _DEBUG_INFO("profile_info->profile_dir_name = %s", profile_info->profile_dir_name);
+               _DEBUG_INFO("profile_info->profile_name = %s", profile_info->profile_name);
+               _DEBUG_INFO("profile_info->addr = %s", server_info->addr);
+               _DEBUG_INFO("profile_info->id = %s", server_info->id);
+               _DEBUG_INFO("profile_info->password = %s", server_info->password);
+               _DEBUG_INFO("profile_info->sync_mode = %s", sync_info->sync_mode);
+               _DEBUG_INFO("profile_info->sync_type = %s", sync_info->sync_type);
+               _DEBUG_INFO("profile_info->interval = %s", sync_info->interval);
+               _DEBUG_INFO("profile_info->lastSyncStatus = %d", profile_info->last_sync_status);
+               _DEBUG_INFO("profile_info->lastSyncStatus = %d", profile_info->last_sync_status);
+
+               sync_agent_get_event_data_param(response_event, &category_count);
+
+               int j;
+               for (j = 0; j < category_count; j++) {
+
+                       category_info = (sync_agent_ds_service_info *) calloc(1, sizeof(sync_agent_ds_service_info));
+                       if (category_info == NULL) {
+                               _DEBUG_ERROR("calloc failed");
+                               sync_agent_ds_free_profile_info(profile_h);
+                               sync_agent_free_event(request_event);
+                               sync_agent_free_event_data(response_event);
+                               return FALSE;
+                       }
+
+                       sync_agent_get_event_data_param(response_event, &category_info->service_type);
+                       sync_agent_get_event_data_param(response_event, &category_info->enabled);
+                       sync_agent_get_event_data_param(response_event, &category_info->src_uri);
+                       sync_agent_get_event_data_param(response_event, &category_info->tgt_uri);
+                       sync_agent_get_event_data_param(response_event, &category_info->id);
+                       sync_agent_get_event_data_param(response_event, &category_info->password);
+
+                       _DEBUG_INFO("category_info->service_type = %d", category_info->service_type);
+                       _DEBUG_INFO("category_info->enabled = %d", category_info->enabled);
+                       _DEBUG_INFO("category_info->src_uri = %s", category_info->src_uri);
+                       _DEBUG_INFO("category_info->tgt_uri = %s", category_info->tgt_uri);
+                       _DEBUG_INFO("category_info->id = %s", category_info->id);
+                       _DEBUG_INFO("category_info->password = %s", category_info->password);
+
+                       profile_info->service_list = g_list_append(profile_info->service_list, category_info);
+                       category_info = NULL;
+               }
+
+               *profile_list = g_list_append(*profile_list, profile_h);
+               profile_h = NULL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_get_last_sync_info(ds_profile_h profile_h, int *lastSyncStatus, int *lastSyncTime)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(lastSyncStatus == NULL, SYNC_AGENT_DS_FAIL, "last session status is null!!");
+       retvm_if(lastSyncTime == NULL, SYNC_AGENT_DS_FAIL, "last session time is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       *lastSyncStatus = profile_info->last_sync_status;
+       *lastSyncTime = profile_info->last_sync_time;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_update_profile(ds_profile_h profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+       sync_agent_ds_server_info *server_info = &profile_info->server_info;
+       sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+       GList *list = profile_info->service_list;
+
+       int event_type = SYNC_AGENT_DS_UPDATE_PROFILE;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+       sync_agent_ds_service_info *category_info = NULL;
+       int category_count = 0;
+       int i = 0;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       _DEBUG_INFO("profile_dir_name = %s", profile_info->profile_dir_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+       _DEBUG_INFO("profile_name = %s", profile_info->profile_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
+       _DEBUG_INFO("addr = %s", server_info->addr);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->addr);
+       _DEBUG_INFO("id = %s", server_info->id);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
+       _DEBUG_INFO("password = %s", server_info->password);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
+       _DEBUG_INFO("sync_mode = %s", sync_info->sync_mode);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
+       _DEBUG_INFO("sync_type = %s", sync_info->sync_type);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
+       _DEBUG_INFO("interval = %s", sync_info->interval);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
+
+       category_count = g_list_length(list);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
+
+       for (; i < category_count; i++) {
+               category_info = (sync_agent_ds_service_info *) g_list_nth_data(list, i);
+
+               _DEBUG_INFO("category[%d]->service_type = %d", i, category_info->service_type);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->service_type));
+               _DEBUG_INFO("category[%d]->enabled = %d", i, category_info->enabled);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &(category_info->enabled));
+               _DEBUG_INFO("category[%d]->src_uri = %s", i, category_info->src_uri);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
+               _DEBUG_INFO("category[%d]->tgt_uri = %s", i, category_info->tgt_uri);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
+               _DEBUG_INFO("category[%d]->id = %s", i, category_info->id);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->id);
+               _DEBUG_INFO("category[%d]->password = %s", i, category_info->password);
+               sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->password);
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+       sync_agent_get_event_data_param(response_event, &api_result);
+
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_delete_profile(ds_profile_h profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       int event_type = SYNC_AGENT_DS_DELETE_PROFILE;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       int count = 1;
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &count);
+
+       _DEBUG_INFO("profile_dir_name = %s", profile_info->profile_dir_name);
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+       sync_agent_get_event_data_param(response_event, &api_result);
+
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_start_sync(ds_profile_h profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       int event_type = SYNC_AGENT_DS_START_SYNC;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+       sync_agent_get_event_data_param(response_event, &api_result);
+
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_stop_sync(ds_profile_h profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       int event_type = SYNC_AGENT_DS_STOP_SYNC;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       int api_result = SYNC_AGENT_DS_API_RESULT_SUCCESS;
+
+       // check mandatory parameter
+       retvm_if(profile_h == NULL, SYNC_AGENT_DS_FAIL, "profile handle is null!!");
+       retvm_if(profile_info->profile_dir_name == NULL, SYNC_AGENT_DS_FAIL, "profile_dir_name is null!!");
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* add request parameter to event packet */
+       sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* get response parameter from event packet */
+       sync_agent_get_event_data_param(response_event, &api_result);
+
+       if (api_result == SYNC_AGENT_DS_API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_DS_FAIL;
+       }
+
+       /* free request & response event */
+       sync_agent_free_event(request_event);
+       sync_agent_free_event_data(response_event);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DS_SUCCESS;
+}
+
+EXPORT_API void sync_agent_ds_free_profile_info(ds_profile_h profile_h)
+{
+       _EXTERN_FUNC_ENTER;
+
+       // check mandatory parameter
+       retm_if(profile_h == NULL, "profile handle is null!!");
+
+       sync_agent_ds_profile_info *profile_info = (sync_agent_ds_profile_info *) profile_h;
+
+       sync_agent_ds_server_info *server_info = &profile_info->server_info;
+       sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+       GList *category_list = profile_info->service_list;
+
+       // free profile name
+       g_free(profile_info->profile_dir_name);
+       g_free(profile_info->profile_name);
+
+       // free server information
+       g_free(server_info->addr);
+       g_free(server_info->id);
+       g_free(server_info->password);
+
+       // free sync mode information
+       g_free(sync_info->sync_mode);
+       g_free(sync_info->sync_type);
+       g_free(sync_info->interval);
+
+       // free sync category information
+       g_list_free_full(category_list, (GDestroyNotify) _free_sync_category_info);
+
+       // free profile information
+       g_free(profile_info);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_ds_error_e sync_agent_ds_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_SUCCESS;
+
+       sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
+
+       deinit = sync_agent_deinit();
+       if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
+               _DEBUG_ERROR("sync_agent_clean_event_handler() failed !!");
+               result = SYNC_AGENT_DS_FAIL;
+       }
+//      if (err != SYNC_AGENT_EVENT_SUCCESS) {
+//      sync_agent_event_error_e err = sync_agent_stop_noti_listener();
+//              _DEBUG_INFO("STOP NOTILISTNER is failed");
+//              result = SYNC_AGENT_DS_FAIL;
+//      }
+//
+//      err = sync_agent_clean_event_handler();
+//      if (err != SYNC_AGENT_EVENT_SUCCESS) {
+//              _DEBUG_ERROR("sync_agent_clean_event_handler() failed !!");
+//              result = SYNC_AGENT_DS_FAIL;
+//      }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
diff --git a/src/framework/event/spec.h b/src/framework/event/spec.h
new file mode 100755 (executable)
index 0000000..8488a50
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SPEC_H_
+#define SPEC_H_
+
+#define EVENT_MAX_EVENT_COUNT 100
+#define EVENT_MAX_NOTI_COUNT 100
+
+/**
+ * @file spec.h
+ * @brief      Definition of Event / Noti spec codes for event module
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for event type
+ */
+typedef enum {
+       EVENT_TYPE_UNKNOWN = -1, /**< unknown */
+       EVENT_TYPE_NO_RESPONSE = 0, /**< just send event, no response - will be removed */
+       EVENT_TYPE_NEED_RESPONSE, /**< send event & wait for response for sent event - synchronous processing */
+} event_type_e;
+
+/**
+ * @brief Enumerations for notification type
+ */
+typedef enum {
+       NOTI_TYPE_UNKNOWN = -1, /**< unknown */
+       NOTI_TYPE_SIMPLE = 0, /**< just send noti, no response */
+} noti_type_e;
+
+/**
+ * @brief Structure for event spec in event config file
+ */
+typedef struct {
+       int event_num; /**< event number */
+       event_type_e event_type; /**< event type */
+       int relational_noti_num; /**< noti number associated with event number */
+       int pendingtime; /**< pending time for response */
+       sync_agent_event_cb callback; /**< event callback function */
+} event_spec_s;
+
+/**
+ * @brief Structure for noti spec in noti config file
+ */
+typedef struct {
+       int noti_num; /**< noti number */
+       noti_type_e noti_type; /**< noti type */
+       int relational_event_num; /**< event number associated with noti number */
+       int pendingtime; /**< pending time for response */
+       void *additional_param; /**< additional data used in sync_agent_noti_cb */
+       sync_agent_noti_cb callback; /**< noti callback function */
+} noti_spec_s;
+
+/**
+ * @brief Structure to manage noti spec
+ */
+typedef struct {
+       char *noti_key; /**< destination, described in framework initialization config file /<Noti> tag */
+       char *communication_path_noti; /**< noti path */
+       char *communication_path_reply_noti; /**< noti reply path - will be removed */
+       int noti_count; /**< total number of noti */
+       noti_spec_s *noti_spec_list[EVENT_MAX_NOTI_COUNT]; /**< list of noti spec */
+} noti_spec_bag_s;
+
+/**
+ *     @}
+ */
+
+#endif                         /* SPEC_H_ */
diff --git a/src/framework/event/ui_api.c b/src/framework/event/ui_api.c
new file mode 100755 (executable)
index 0000000..2937e6b
--- /dev/null
@@ -0,0 +1,431 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/inotify.h>
+
+#include "utility/sync_util.h"
+#include "fsapi/operation.h"
+
+#include "event/config.h"
+#include "event/util.h"
+#include "event/data_accessor.h"
+#include "event/data_accessor_internal.h"
+#include "event/ui_api.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EVENT_UI"
+#endif
+
+#define EVENT_SIZE     (sizeof(struct inotify_event))
+
+static int inotify_fd;
+static int inotify_wd;
+static int gsource_id;
+
+static gboolean _agent_noti_listener(GIOChannel * p_src, GIOCondition cond, gpointer p_data);
+
+static void __dispatch_noti(int noti_num, sync_agent_event_data_s * noti, sync_agent_event_error_e * error);
+
+EXPORT_API sync_agent_event_data_s *sync_agent_create_event(int event_num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_event_data_s *event = (sync_agent_event_data_s *) malloc(sizeof(sync_agent_event_data_s));
+       if (event == NULL) {
+               _DEBUG_ERROR("Memory malloc FAILED. [event]");
+               return NULL;
+       }
+       event->event_num = event_num;
+
+       char *serialized_data = (char *)calloc(EVENT_MAX_STREAM_SIZE, sizeof(char));
+       if (serialized_data != NULL) {
+               event->size = serialized_data;
+               event->data = serialized_data + 1;
+
+               sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &event_num);
+       } else {
+               free(event);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return event;
+}
+
+EXPORT_API sync_agent_event_data_s *sync_agent_send_event(sync_agent_event_data_s * event, sync_agent_event_error_e * error)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (event == NULL) {
+               _DEBUG_ERROR("sync_agent_event_data_s is NULL !!");
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       *error = SYNC_AGENT_EVENT_SUCCESS;
+       int client_len;
+       int client_sockfd;
+       struct sockaddr_un clientaddr;
+       int buf_len = 0;
+
+       client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+       if (client_sockfd == -1) {
+               _DEBUG_ERROR("socket create Error!!");
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       bzero(&clientaddr, sizeof(clientaddr));
+       clientaddr.sun_family = AF_UNIX;
+       /*
+        * select socket path, whether event type is response for notification
+        */
+       const char *communication_path = NULL;
+       event_type_e event_type = event_get_event_type(event->event_num);
+       switch (event_type) {
+       case EVENT_TYPE_NO_RESPONSE:
+       case EVENT_TYPE_NEED_RESPONSE:
+               communication_path = event_get_event_path();
+               break;
+       default:
+               break;
+       }
+
+       if (communication_path == NULL) {
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       _DEBUG_INFO("communication_path : %s", communication_path);
+
+       if (communication_path != NULL) {
+               buf_len = g_strlcpy(clientaddr.sun_path, communication_path, sizeof(clientaddr.sun_path));
+               if (buf_len >= sizeof(clientaddr.sun_path)) {
+                       _DEBUG_ERROR("clientaddr.sun_path buffer overflow !!");
+                       close(client_sockfd);
+                       *error = SYNC_AGENT_EVENT_IPC_ERR;
+                       return NULL;
+               }
+       } else {
+               _DEBUG_ERROR("communication_path is NULL !!");
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       client_len = sizeof(clientaddr);
+
+       if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0) {
+               _DEBUG_ERROR("socket connect error ( %d )", errno);
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       int send_data_size = (event->data - event->size) + 1;
+       int write_ret = write(client_sockfd, (void *)(event->size), send_data_size);
+       if (write_ret == -1) {
+               _DEBUG_INFO("write() failed !!");
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+
+       if (event_type != EVENT_TYPE_NEED_RESPONSE) {
+               _DEBUG_INFO("Do not need synchronous response");
+               *error = SYNC_AGENT_EVENT_SUCCESS;
+               close(client_sockfd);
+               return NULL;
+       }
+
+       /*
+        * receive Logic
+        */
+       char *connection_result = (char *)calloc(EVENT_MAX_STREAM_SIZE, sizeof(char));
+       if (connection_result == NULL) {
+               _DEBUG_ERROR("Memory malloc FAILED. [connection_result]");
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_FAIL;
+               return NULL;
+       }
+
+       if (read(client_sockfd, connection_result, EVENT_MAX_STREAM_SIZE) <= 0) {
+               _DEBUG_ERROR("Socket Error - failed to read()");
+               if (connection_result != NULL)
+                       free(connection_result);
+               close(client_sockfd);
+               *error = SYNC_AGENT_EVENT_IPC_ERR;
+               return NULL;
+       }
+       close(client_sockfd);
+
+       event_print_event_data(connection_result);
+
+       sync_agent_event_data_s *reply_msg = (sync_agent_event_data_s *) malloc(sizeof(sync_agent_event_data_s));
+       if (reply_msg == NULL) {
+               _DEBUG_ERROR("Memory malloc FAILED. [reply_msg]");
+               if (connection_result != NULL)
+                       free(connection_result);
+               *error = SYNC_AGENT_EVENT_FAIL;
+               return NULL;
+       }
+       reply_msg->data = connection_result;
+
+       event_init_event_data_iter(reply_msg);
+
+       _EXTERN_FUNC_EXIT;
+
+       return reply_msg;
+}
+
+EXPORT_API sync_agent_event_error_e sync_agent_run_noti_listener(const char *noti_key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(noti_key == NULL, SYNC_AGENT_EVENT_FAIL, "noti key is NULL !!");
+
+       GIOChannel *gio_channel = NULL;
+       GSource *g_source = NULL;
+       int result = 0;
+
+       _DEBUG_TRACE("noti_key : %s", noti_key);
+
+       const char *communication_path = event_get_noti_path(0);
+       _DEBUG_TRACE("Noti communication path : %s", communication_path);
+
+       if (sync_agent_is_existing_fs(communication_path)) {
+               _DEBUG_TRACE("%s file is exist !!");
+               if (unlink(communication_path) == -1) {
+                       _DEBUG_ERROR("unlink failed ( %s ), ERROR NUM [%d] !!", communication_path, errno);
+                       return SYNC_AGENT_EVENT_FAIL;
+               } else {
+                       _DEBUG_TRACE("unlink success !!");
+               }
+       } else {
+               _DEBUG_TRACE("%s file is not exist !!");
+       }
+
+       int fd = creat(communication_path, S_IRWXU | S_IRWXG | S_IRWXO);
+       if (fd < 0) {
+               _DEBUG_ERROR("creat() failed !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       } else {
+               _DEBUG_TRACE("%s file is created !!");
+       }
+
+       /* initialize an inotify instance */
+       inotify_fd = inotify_init();
+       if (inotify_fd == -1) {
+               _DEBUG_ERROR("inotify_init() failed !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       /* change file's attribute */
+       result = fcntl(inotify_fd, F_SETFD, FD_CLOEXEC);
+       if (result == -1) {
+               _DEBUG_ERROR("fcntl() failed !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+       result = fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
+       if (result == -1) {
+               _DEBUG_ERROR("fcntl() failed !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       /* add a watch to an initialized inotify instance */
+       inotify_wd = inotify_add_watch(inotify_fd, communication_path, IN_CLOSE_WRITE);
+       if (inotify_wd == -1) {
+               _DEBUG_ERROR("inotify_add_watch() failed !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       /* create a new GIOChannel given a file descriptor */
+       gio_channel = g_io_channel_unix_new(inotify_fd);
+       if (gio_channel == NULL) {
+               _DEBUG_ERROR("g_io_channel_unix_new() failed  !!");
+               return SYNC_AGENT_EVENT_FAIL;
+       }
+
+       /* turn on nonblocking mode */
+       g_io_channel_set_flags(gio_channel, G_IO_FLAG_NONBLOCK, NULL);
+
+       /* create a GSource that's dispatched when condition is met for the given channel */
+       g_source = g_io_create_watch(gio_channel, G_IO_IN);
+
+       /* sets the priority of a source */
+       g_source_set_priority(g_source, G_PRIORITY_HIGH);
+
+       /* set the callback function for a source */
+       g_source_set_callback(g_source, (GSourceFunc) _agent_noti_listener, (gpointer) noti_key, NULL);
+
+       /* add a GSource to a context so that it will be executed within that context */
+       gsource_id = g_source_attach(g_source, NULL);
+       g_io_channel_unref(gio_channel);
+
+       _EXTERN_FUNC_EXIT;
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+EXPORT_API sync_agent_event_error_e sync_agent_stop_noti_listener()
+{
+       _EXTERN_FUNC_ENTER;
+
+       inotify_rm_watch(inotify_fd, inotify_wd);
+       close(inotify_fd);
+
+       g_source_remove(gsource_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_EVENT_SUCCESS;
+}
+
+EXPORT_API sync_agent_event_error_e sync_agent_set_noti_callback(int notiType, sync_agent_noti_cb callback, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return event_register_noti_callback(notiType, callback, data);
+}
+
+EXPORT_API void sync_agent_free_event(sync_agent_event_data_s * event)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (event != NULL) {
+               sync_agent_free_event_data(event);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static gboolean _agent_noti_listener(GIOChannel * p_src, GIOCondition cond, gpointer p_data)
+{
+       _INNER_FUNC_ENTER;
+
+       int buf_len = 0;
+       struct inotify_event event = { 0, };
+       int event_pos = 0;
+
+       char *noti_key = (char *)p_data;
+       _DEBUG_TRACE("noti key : %s", noti_key);
+
+       const char *communication_path = event_get_noti_path(0);
+       _DEBUG_TRACE("Noti communication path : %s", communication_path);
+
+       buf_len = read(inotify_fd, (void *)&event, sizeof(event));
+       if (buf_len < 0) {
+               _DEBUG_ERROR("read() failed !!");
+               return FALSE;
+       } else {
+               _DEBUG_TRACE("buffer length : %d", buf_len);
+       }
+
+       while (event_pos < buf_len) {
+               sync_agent_event_data_s *noti = (sync_agent_event_data_s *) calloc(1, sizeof(sync_agent_event_data_s));
+               if (noti == NULL) {
+                       _DEBUG_ERROR("calloc failed !!");
+                       return FALSE;
+               }
+
+               char *inbuf = (char *)calloc(EVENT_MAX_STREAM_SIZE, sizeof(char));
+               if (inbuf == NULL) {
+                       _DEBUG_ERROR("calloc failed !!");
+                       free(noti);
+                       return FALSE;
+               }
+
+               noti->data = inbuf;
+               event_init_event_data_iter(noti);
+
+               FILE *fp = NULL;
+               fp = fopen(communication_path, "r");
+               if (fp != NULL) {
+                       if (fread(inbuf, sizeof(char), EVENT_MAX_STREAM_SIZE, fp) <= 0) {
+                               _DEBUG_ERROR("fread() failed !!");
+                               free(inbuf);
+                               free(noti);
+                               fclose(fp);
+                               return FALSE;
+                       } else {
+                               _DEBUG_TRACE("fread() success !!");
+                               fclose(fp);
+                       }
+               } else {
+                       _DEBUG_ERROR("fopen( %s ) failed !!", communication_path);
+                       free(inbuf);
+                       free(noti);
+                       return FALSE;
+               }
+
+               int noti_num;
+               sync_agent_get_event_data_param(noti, &noti_num);
+               _DEBUG_TRACE("Received Noti Number : %d", noti_num);
+
+               sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;;
+               __dispatch_noti(noti_num, noti, &error);
+               if (error != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("__dispatch_noti() failed !!");
+               } else {
+                       _DEBUG_TRACE("__dispatch_noti() success !!");
+               }
+
+               event_pos += EVENT_SIZE + event.len;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static void __dispatch_noti(int noti_num, sync_agent_event_data_s * noti, sync_agent_event_error_e * error)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(noti == NULL, "sync_agent_event_data_s is NULL !!");
+
+       sync_agent_noti_cb noti_callback = event_get_noti_callback(noti_num);
+       void *additional_param = event_get_noti_callback_additional_param(noti_num);
+
+       if (noti_callback != NULL) {
+               noti_callback(noti, additional_param);
+               *error = SYNC_AGENT_EVENT_SUCCESS;
+       } else {
+               *error = SYNC_AGENT_EVENT_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/event/util.c b/src/framework/event/util.c
new file mode 100755 (executable)
index 0000000..687c255
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "utility/sync_util.h"
+#include "event/util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_EVENT"
+#endif
+
+void event_init_event_data_iter(sync_agent_event_data_s * event)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(event == NULL, "sync_agent_event_data_s is NULL !!");
+
+       event->size = event->data;
+       event->data = event->data + 1;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+int event_get_event_data_byte_size(sync_agent_event_data_s * iter)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (iter->data - iter->size + 1);
+}
+
+int event_get_event_data_element_size(sync_agent_event_data_s * iter)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (int)(iter->size[0]);
+}
+
+void event_remove_buffer(sync_agent_event_data_s * event)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (event != NULL) {
+               if (event->size != NULL) {
+                       free(event->size);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/event/util.h b/src/framework/event/util.h
new file mode 100755 (executable)
index 0000000..03d497b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EVENT_UTIL_H_
+#define EVENT_UTIL_H_
+
+#include "event/data_accessor.h"
+
+/**
+ * @file               Event_Util.h
+ * @brief      Event module Internal Utility function set
+ */
+
+/** @addtogroup event
+ *     @{
+ */
+
+/**
+ * @brief      Initialization sync_agent_event_data_s structure
+ * @remarks    Member variable size, data will be initialized
+ * @param[in] event Initialization data
+ */
+void event_init_event_data_iter(sync_agent_event_data_s * event);
+
+/**
+ * @brief Get byte size of event stream
+ * @param[in] iter Event structure
+ * @return byte size
+ */
+int event_get_event_data_byte_size(sync_agent_event_data_s * iter);
+
+/**
+ * @brief Get element size of current iterator
+ * @param[in] iter Event structure
+ * @return byte size
+ */
+int event_get_event_data_element_size(sync_agent_event_data_s * iter);
+
+/**
+ * @brief      Free buffer of Event structure, not Event Structure
+ * @param[in] event Event structure
+ */
+void event_remove_buffer(sync_agent_event_data_s * event);
+
+/**
+ *     @}
+ */
+
+#endif                         /* EVENT_UTIL_H_ */
diff --git a/src/framework/fsapi/operation.c b/src/framework/fsapi/operation.c
new file mode 100755 (executable)
index 0000000..d45cf52
--- /dev/null
@@ -0,0 +1,1108 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/vfs.h>           /* for statfs */
+#include "fsapi/operation.h"
+#include "fsapi/operation_internal.h"
+#include "fsapi/util.h"
+#include "security-assistant/md5.h"
+
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_FS"
+#endif
+
+#define FS_BUFFER_SIZE 2048
+
+static bool file_append_started = FALSE;
+static bool file_read_started = FALSE;
+static char *temp_filename_kept = NULL;
+static char *requested_filename_kept = NULL;
+static FILE *fd_source_kept = NULL;
+
+static unsigned char _wss_str_to_hex_char(unsigned char hex);
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_is_existing_fs(const char *file_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return fs_is_existing(file_name);
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_get_fs_info(char **result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(result == NULL, 0, "result paramter is NULL !!!");
+
+       int ret = 0;
+
+       long double free_size = 0;
+       long double total_size = 0;
+
+       int file_name_len_max = 256;
+       int folder_name_len_max = 256;
+
+       char *file_name_prevenet_char = ":;*?/<>\"";
+       char *folder_name_prevent_char = ":;*?/<>\"";
+
+       int file_name_code_schema = 2;
+       int allow_dup_name = 0;
+       int folder_depth_max = 15;
+
+       ret = sync_agent_get_fs_mem_size("/opt/usr/media", &free_size, &total_size);
+       if (!ret) {
+               _DEBUG_ERROR("[sync_agent_get_fs_info] getting mem size fail");
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       *result = g_strdup_printf("%.0Lf,%d,%s,%d,%d,%d,%d,%s", total_size, file_name_len_max, file_name_prevenet_char, file_name_code_schema, allow_dup_name, folder_depth_max, folder_name_len_max, folder_name_prevent_char);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_free_fs_info(char *result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(result == NULL, 0, "result paramter is NULL !!!");
+
+       if (result != NULL)
+               g_free(result);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_get_fs_mem_size(const char *root, long double *size_free, long double *size_total)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(root == NULL, 0, "root paramter is NULL !!!");
+
+       if (!fs_is_existing(root)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist.\n", __func__, root);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       struct statfs fs_info;
+
+       if (statfs(root, &fs_info) != 0) {
+               _DEBUG_ERROR("[sync_agent_get_fs_mem_size] statfs error.");
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       *size_free = ((long double)fs_info.f_bavail * (long double)fs_info.f_bsize);    /* / 1024; */
+       *size_total = ((long double)fs_info.f_blocks * (long double)fs_info.f_bsize);   /* / 1024; */
+
+       _DEBUG_INFO("[sync_agent_get_fs_mem_size] FS info root : %s.", root);
+       _DEBUG_INFO("[sync_agent_get_fs_mem_size] FS info free size : %.0f", *size_free);
+       _DEBUG_INFO("[sync_agent_get_fs_mem_size] FS info total size : %.0f", *size_total);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+/*
+ * File operation
+ */
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_get_file_size(const char *file_name, unsigned long *size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       if (!fs_is_existing(file_name) || fs_is_directory(file_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       struct stat buf;
+
+       int ret = stat(file_name, &buf);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] stat error : %s", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       *size = (unsigned long)buf.st_size;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+int fs_get_file_date(const char *file_name, char **time_string)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       if (!fs_is_existing(file_name) || fs_is_directory(file_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       struct stat buf;
+       char time[FS_MAX_TIME_STRING_BUF] = { 0 };
+
+       int ret = stat(file_name, &buf);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] stat error : %s", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       fs_get_time_string(&buf.st_mtime, time);
+       *time_string = g_strdup(time);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_copy_file(const char *source, const char *dest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(source == NULL, 0, "source paramter is NULL !!!");
+       retvm_if(dest == NULL, 0, "dest paramter is NULL !!!");
+
+       if (!fs_is_existing(source) || fs_is_directory(source) || fs_is_existing(dest)) {
+               _DEBUG_ERROR("[%s] Requested source instance '%s' not exist or not a file, or\n", __func__, source);
+               _DEBUG_ERROR("[%s] requested dest instance '%s' already exist.\n", __func__, dest);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       FILE *f1 = NULL, *f2 = NULL;
+       int ret = 1;
+       char buf[1024 * 100] = { 0 };
+       unsigned long bytes_read = 0;
+       unsigned long bytes_written = 0;
+
+       f1 = (FILE *) g_fopen(source, "rb");
+       if (f1 == NULL) {
+               _DEBUG_ERROR("[sync_agent_copy_file] file f1 open error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       f2 = (FILE *) g_fopen(dest, "wb");
+       if (f2 == NULL) {
+               _DEBUG_ERROR("[sync_agent_copy_file] file f2 open error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       while ((bytes_read = fread(buf, 1, sizeof(buf), f1)) > 0) {
+               if (bytes_read > sizeof(buf)) {
+                       _DEBUG_ERROR("[sync_agent_copy_file] read error.");
+                       ret = 0;
+                       goto return_part;
+               }
+
+               bytes_written = fwrite(buf, 1, bytes_read, f2);
+               if (!feof(f1) && bytes_written != bytes_read) {
+                       _DEBUG_ERROR("[sync_agent_copy_file] write error.");
+                       ret = 0;
+                       goto return_part;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+ return_part:
+       if (f1 != NULL)
+               fclose(f1);
+       if (f2 != NULL)
+               fclose(f2);
+       return ret;
+
+/*
+       char *body = NULL;
+       unsigned long size;
+
+       if( !File_Read(source, &body, &size) ) {
+               fprintf(stderr, "[%s] File_Read() returned error.\n", __func__);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       if( !File_Write(dest, body, size) ) {
+               fprintf(stderr, "[%s] File_Read() returned error.\n", __func__);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       free(body);
+
+       return SYNC_AGENT_FSAPI_TRUE;
+*/
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_delete_file(const char *file_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       if (!fs_is_existing(file_name) || fs_is_directory(file_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       int ret = g_unlink(file_name);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] g_unlink error : %s\n", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_move_file(const char *source, const char *dest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(source == NULL, 0, "source paramter is NULL !!!");
+       retvm_if(dest == NULL, 0, "dest paramter is NULL !!!");
+
+       if (!fs_is_existing(source) || fs_is_directory(source) || fs_is_existing(dest)) {
+               _DEBUG_ERROR("[%s] Requested source instance '%s' not exist or not a file, or\n", __func__, source);
+               _DEBUG_ERROR("[%s] requested dest instance '%s' already exist.\n", __func__, dest);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       int ret = g_rename(source, dest);
+       if (ret == -1) {
+               _DEBUG_ERROR("[sync_agent_move_file] g_rename error : %s", strerror(errno));
+               _DEBUG_ERROR("[sync_agent_move_file] source : %s target : %s", source, dest);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_rename_file(const char *source, const char *dest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(source == NULL, 0, "source paramter is NULL !!!");
+       retvm_if(dest == NULL, 0, "dest paramter is NULL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return sync_agent_move_file(source, dest);
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_get_file_list(const char *folder_name, GSList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, 0, "folder_name paramter is NULL !!!");
+
+       if (!fs_is_existing(folder_name) || !fs_is_directory(folder_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a directory.\n", __func__, folder_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       struct stat buf;
+       char *path = NULL;
+       char time[FS_MAX_TIME_STRING_BUF] = { 0 };
+       char *list_item = NULL;
+
+       GError *gerror = NULL;
+       GDir *dir = g_dir_open(folder_name, 0, &gerror);
+       if (dir == NULL) {
+               _DEBUG_ERROR("[%s] g_dir_open error : %s\n", __func__, gerror->message);
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       const char *file_name = g_dir_read_name(dir);
+
+       for (; file_name; file_name = g_dir_read_name(dir)) {
+
+               path = g_strdup_printf("%s/%s", folder_name, file_name);
+
+               if (!fs_is_directory(path)) {
+                       int ret = stat(path, &buf);
+                       if (ret == -1) {
+                               _DEBUG_ERROR("[%s] g_stat error : %s\n", __func__, strerror(errno));
+                               return SYNC_AGENT_FSAPI_FALSE;
+                       }
+
+                       fs_get_time_string(&buf.st_mtime, time);
+                       list_item = g_strdup_printf("%s,%ld,%s", file_name, (long)buf.st_size, time);
+
+                       *list = g_slist_append(*list, list_item);
+               }
+       }
+
+       free(path);
+       g_dir_close(dir);
+       dir = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_read_file(const char *file_name, char **required_contents, unsigned long required_length, unsigned long *size_return, bool * is_final)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       if (!fs_is_existing(file_name) || fs_is_directory(file_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       int ret = 1;
+
+       if ((fd_source_kept == NULL) && !file_read_started) {
+               fd_source_kept = (FILE *) g_fopen(file_name, "rb");
+               if (fd_source_kept == NULL) {
+                       _DEBUG_ERROR("[sync_agent_read_file] temp_filename_kept open error.");
+                       ret = 0;
+                       goto return_part;
+               }
+               file_read_started = TRUE;
+       } else if ((fd_source_kept != NULL) && file_read_started) {
+       } else {
+               _DEBUG_ERROR("[%s] internal condition not matching.\n", __func__);
+               ret = 0;
+               goto return_part;
+       }
+
+       *required_contents = (char *)calloc(required_length, sizeof(char));
+       if (*required_contents == NULL) {
+               _DEBUG_ERROR("[sync_agent_read_file] calloc error. [*required_contents]");
+               ret = 0;
+               goto return_part;
+       }
+
+       int bytes_read = 0;
+       bytes_read = fread(*required_contents, 1, required_length, fd_source_kept);
+
+       if ((bytes_read > required_length) || ((!feof(fd_source_kept)) && (bytes_read < required_length))) {
+               _DEBUG_ERROR("[sync_agent_read_file] read error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       *size_return = bytes_read;
+
+       if (feof(fd_source_kept)) {
+               *is_final = TRUE;
+               goto return_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+
+ return_part:
+
+       if (fd_source_kept != NULL) {
+               fclose(fd_source_kept);
+               fd_source_kept = NULL;
+       }
+       file_read_started = FALSE;
+
+       return ret;
+
+/*
+       if( !fs_is_existing(file_name) || fs_is_directory(file_name) ) {
+               fprintf(stderr, "[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       GError *gerror = NULL;
+
+       if( !g_file_get_contents(file_name, contents, (gsize*)length, &gerror) ) {
+               fprintf(stderr, "[%s] g_file_get_contents error : %s\n", __func__, gerror->message);
+
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       return SYNC_AGENT_FSAPI_TRUE;
+*/
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_read_whole_file(const char *file_name, char **required_contents, unsigned long *size_return)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+
+       if (!fs_is_existing(file_name) || fs_is_directory(file_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a file.\n", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       GError *gerror = NULL;
+
+       if (!g_file_get_contents(file_name, required_contents, (gsize *) size_return, &gerror)) {
+               _DEBUG_ERROR("[%s] g_file_get_contents error : %s\n", __func__, gerror->message);
+
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_free_file(char **requested_contents)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(requested_contents == NULL, 0, "requested_contents paramter is NULL !!!");
+
+       if (*requested_contents != NULL)
+               free(*requested_contents);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_write_file(const char *file_name, const char *contents, unsigned long length, bool is_final, bool overwrite)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+       retvm_if(contents == NULL, 0, "contents is NULL !!");
+
+       if (!overwrite) {
+               if (fs_is_existing(file_name)) {
+                       _DEBUG_ERROR("[%s] Requested instance '%s' already exist.\n", __func__, file_name);
+                       return SYNC_AGENT_FSAPI_FALSE;
+               }
+       }
+
+       FILE *fd_temp = NULL;
+       GError *gerror = NULL;
+       int ret = 1;
+       unsigned long temp_size = 0;
+
+       if ((temp_filename_kept == NULL) && !file_append_started) {
+               if (!g_file_open_tmp(NULL, &temp_filename_kept, &gerror)) {
+                       _DEBUG_ERROR("[%s] g_file_open_tmp error : %s\n", __func__, gerror->message);
+
+                       g_error_free(gerror);
+                       ret = 0;
+                       goto return_part;
+               }
+               _DEBUG_INFO("[sync_agent_write_file] Temp file name kept new : %s", temp_filename_kept);
+
+               file_append_started = TRUE;
+               requested_filename_kept = g_strdup(file_name);
+
+       } else if ((temp_filename_kept != NULL) && file_append_started) {
+               if (!fs_is_existing(temp_filename_kept)) {
+                       _DEBUG_ERROR("[%s] Temp file '%s' not existing.\n", __func__, temp_filename_kept);
+                       ret = 0;
+                       goto return_part;
+               }
+               _DEBUG_INFO("[sync_agent_write_file] Temp file %s kept previously, existing", temp_filename_kept);
+
+       } else {
+               _DEBUG_ERROR("[%s] internal condition not matching.\n", __func__);
+               ret = 0;
+               goto return_part;
+       }
+
+       if (temp_filename_kept != NULL) {
+               fd_temp = (FILE *) g_fopen(temp_filename_kept, "ab");
+       } else {
+               goto return_part;
+       }
+
+       if (fd_temp == NULL) {
+               _DEBUG_ERROR("[sync_agent_write_file] temp file open error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       if (fwrite(contents, 1, length, fd_temp) != length) {
+               _DEBUG_ERROR("[sync_agent_write_file] fwrite error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       if (fd_temp != NULL) {
+               fclose(fd_temp);
+               fd_temp = NULL;
+       }
+
+       sync_agent_get_file_size(temp_filename_kept, &temp_size);
+       _DEBUG_INFO("[sync_agent_write_file] temp file size %ld", temp_size);
+
+       if (is_final) {
+               if (overwrite) {
+                       if (fs_is_existing(file_name)) {
+                               if (!sync_agent_delete_file(file_name)) {
+                                       _DEBUG_ERROR("[sync_agent_write_file] deleting destination file for overwriting fail.");
+                                       ret = 0;
+                               } else {
+                                       if (!sync_agent_copy_file(temp_filename_kept, file_name)) {
+                                               _DEBUG_ERROR("[sync_agent_write_file] copying temp file to destination fail.");
+                                               ret = 0;
+                                       } else {
+                                               if (!sync_agent_delete_file(temp_filename_kept)) {
+                                                       _DEBUG_ERROR("[sync_agent_write_file] deleting temp file fail.");
+                                                       ret = 0;
+                                               }
+                                       }
+                               }
+                       } else {
+                               if (!sync_agent_copy_file(temp_filename_kept, file_name)) {
+                                       _DEBUG_ERROR("[sync_agent_write_file] copying temp file to destination fail.");
+                                       ret = 0;
+                               } else {
+                                       if (!sync_agent_delete_file(temp_filename_kept)) {
+                                               _DEBUG_ERROR("[sync_agent_write_file] deleting temp file fail.");
+                                               ret = 0;
+                                       }
+                               }
+                       }
+               } else {
+                       if (!sync_agent_copy_file(temp_filename_kept, file_name)) {
+                               _DEBUG_ERROR("[sync_agent_write_file] copying temp file to destination fail.");
+                               ret = 0;
+                       } else {
+                               if (!sync_agent_delete_file(temp_filename_kept)) {
+                                       _DEBUG_ERROR("[sync_agent_write_file] deleting temp file fail.");
+                                       ret = 0;
+                               }
+                       }
+               }
+               goto return_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+
+ return_part:
+
+       if (fd_temp != NULL)
+               fclose(fd_temp);
+       g_free(temp_filename_kept);
+       g_free(requested_filename_kept);
+       temp_filename_kept = NULL;
+       requested_filename_kept = NULL;
+       file_append_started = FALSE;
+
+       return ret;
+
+/*
+       if( fs_is_existing(file_name) ) {
+               fprintf(stderr, "[%s] Requested instance '%s' already exist.", __func__, file_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       GError *gerror = NULL;
+
+       if( !g_file_set_contents(file_name, contents, length, &gerror) ) {
+               fprintf(stderr, "[%s] g_file_set_contents error : %s\n", __func__, gerror->message);
+
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       return SYNC_AGENT_FSAPI_TRUE;
+*/
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_write_whole_file(const char *file_name, const char *contents, unsigned long length, bool overwrite)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+       retvm_if(contents == NULL, 0, "contents is NULL !!");
+
+       if (fs_is_existing(file_name)) {
+               if (overwrite && !fs_is_directory(file_name)) {
+                       int result = sync_agent_delete_file(file_name);
+                       if (result == 0) {
+                               _DEBUG_ERROR("[%s] sync_agent_delete_file() FAIL !!!.", __func__, file_name);
+                               return SYNC_AGENT_FSAPI_FALSE;
+                       }
+               } else {
+                       _DEBUG_ERROR("[%s] Requested instance '%s' already exist.", __func__, file_name);
+                       return SYNC_AGENT_FSAPI_FALSE;
+               }
+       }
+
+       GError *gerror = NULL;
+
+       if (!g_file_set_contents(file_name, contents, length, &gerror)) {
+               _DEBUG_ERROR("[%s] g_file_set_contents error : %s\n", __func__, gerror->message);
+
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_append_file(const char *file_name, const char *contents, unsigned long length, bool overwrite)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_name == NULL, 0, "file_name paramter is NULL !!!");
+       retvm_if(contents == NULL, 0, "contents is NULL !!");
+
+       if (overwrite) {
+               if (!sync_agent_delete_file(file_name)) {
+                       if (!fs_is_existing(file_name)) {
+                               _DEBUG_ERROR("[%s] The file %s requested to delete for overwriting is not existing, so just continue.", __func__, file_name);
+                       } else {
+                               if (fs_is_directory(file_name)) {
+                                       _DEBUG_ERROR("[%s] Can't overwrite because requested instance '%s' not a file.", __func__, file_name);
+                                       return SYNC_AGENT_FSAPI_FALSE;
+                               } else {
+                                       _DEBUG_ERROR("[%s] FAILED to delete requested file '%s'.", __func__, file_name);
+                                       return SYNC_AGENT_FSAPI_FALSE;
+                               }
+                       }
+               }
+       }
+
+       FILE *fd = NULL;
+       int ret = 1;
+
+       fd = (FILE *) g_fopen(file_name, "ab");
+       if (fd == NULL) {
+               _DEBUG_ERROR("[sync_agent_append_file] file open error.");
+               ret = 0;
+               goto return_part;
+       }
+
+       if (fwrite(contents, 1, length, fd) != length) {
+               _DEBUG_ERROR("[%s] fwrite error '%s'.", __func__, file_name);
+               ret = 0;
+               goto return_part;
+       }
+
+       if (fsync(fileno(fd)) != 0)
+               ret = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+ return_part:
+
+       if (fd != NULL)
+               fclose(fd);
+
+       _DEBUG_INFO("[%s] Returning..", __func__);
+       return ret;
+}
+
+/*
+ * Folder operation
+ */
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_create_directory(const char *folder_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, 0, "folder_name paramter is NULL !!!");
+
+       if (fs_is_existing(folder_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' already exist.\n", __func__, folder_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       int ret = g_mkdir_with_parents(folder_name, 0755);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] g_mkdir error : %s\n", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_delete_directory(const char *folder_name, bool recursive)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, 0, "folder_name paramter is NULL !!!");
+
+       if (!fs_is_existing(folder_name) || !fs_is_directory(folder_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a directory.\n", __func__, folder_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       GError *gerror = NULL;
+       GDir *dir = NULL;
+       int ret = 0;
+       char *path = NULL;
+       char *name = NULL;
+
+       if (recursive) {
+               dir = g_dir_open(folder_name, 0, &gerror);
+               if (dir == NULL) {
+                       _DEBUG_ERROR("[%s] g_dir_open error : %s\n", __func__, gerror->message);
+                       g_error_free(gerror);
+                       return SYNC_AGENT_FSAPI_FALSE;
+               }
+
+               name = (char *)g_dir_read_name(dir);
+
+               for (; name; name = (char *)g_dir_read_name(dir)) {
+
+                       path = g_strdup_printf("%s/%s", folder_name, name);
+
+                       if (fs_is_directory(path)) {
+                               if (!sync_agent_delete_directory(path, true))
+                                       return SYNC_AGENT_FSAPI_FALSE;
+                       } else {
+                               if (!sync_agent_delete_file(path))
+                                       return SYNC_AGENT_FSAPI_FALSE;
+                       }
+               }
+
+               if (path != NULL)
+                       free(path);
+               g_dir_close(dir);
+               dir = NULL;
+       }
+
+       ret = g_rmdir(folder_name);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] g_rmdir error : %s\n", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_empty_directory_contents(const char *folder_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, 0, "folder_name paramter is NULL !!!");
+
+       if (!fs_is_existing(folder_name) || !fs_is_directory(folder_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a directory.\n", __func__, folder_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       GError *gerror = NULL;
+       GDir *dir = NULL;
+       char *path = NULL;
+       char *name = NULL;
+
+       dir = g_dir_open(folder_name, 0, &gerror);
+       if (dir == NULL) {
+               _DEBUG_ERROR("[%s] g_dir_open error : %s\n", __func__, gerror->message);
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       name = (char *)g_dir_read_name(dir);
+
+       for (; name; name = (char *)g_dir_read_name(dir)) {
+
+               path = g_strdup_printf("%s/%s", folder_name, name);
+
+               if (fs_is_directory(path)) {
+                       if (!sync_agent_delete_directory(path, true)) {
+                               _DEBUG_ERROR("[%s] sync_agent_delete_directory error : %s\n", __func__, strerror(errno));
+                               return SYNC_AGENT_FSAPI_FALSE;
+                       }
+               } else {
+                       if (!sync_agent_delete_file(path)) {
+                               _DEBUG_ERROR("[%s] sync_agent_delete_file error : %s\n", __func__, strerror(errno));
+                               return SYNC_AGENT_FSAPI_FALSE;
+                       }
+               }
+       }
+
+       if (path != NULL)
+               free(path);
+       g_dir_close(dir);
+       dir = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_rename_directory(const char *source, const char *dest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(source == NULL, 0, "source paramter is NULL !!!");
+       retvm_if(dest == NULL, 0, "dest paramter is NULL !!!");
+
+       if (!fs_is_existing(source) || !fs_is_directory(source) || fs_is_existing(dest)) {
+               _DEBUG_ERROR("[%s] Requested source instance '%s' not exist or not a directory, or\n", __func__, source);
+               _DEBUG_ERROR("[%s] requested dest instance '%s' already exist.\n", __func__, dest);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       int ret = g_rename(source, dest);
+       if (ret == -1) {
+               _DEBUG_ERROR("[%s] g_rename error : %s\n", __func__, strerror(errno));
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_get_directory_list(const char *folder_name, GSList ** list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, 0, "folder_name paramter is NULL !!!");
+
+       if (!fs_is_existing(folder_name) || !fs_is_directory(folder_name)) {
+               _DEBUG_ERROR("[%s] Requested instance '%s' not exist, or not a directory.\n", __func__, folder_name);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       struct stat buf;
+       char *path = NULL;
+       char time[FS_MAX_TIME_STRING_BUF] = { 0 };
+       char *list_item = NULL;
+
+       GError *gerror = NULL;
+       GDir *dir = g_dir_open(folder_name, 0, &gerror);
+       if (dir == NULL) {
+               _DEBUG_ERROR("[%s] g_dir_open error : %s\n", __func__, gerror->message);
+               g_error_free(gerror);
+               return SYNC_AGENT_FSAPI_FALSE;
+       }
+
+       const char *file_name = g_dir_read_name(dir);
+
+       for (; file_name; file_name = g_dir_read_name(dir)) {
+
+               path = g_strdup_printf("%s/%s", folder_name, file_name);
+
+               if (fs_is_directory(path)) {
+                       int ret = stat(path, &buf);
+                       if (ret == -1) {
+                               _DEBUG_ERROR("[%s] g_stat error : %s\n", __func__, strerror(errno));
+                               return SYNC_AGENT_FSAPI_FALSE;
+                       }
+
+                       fs_get_time_string(&buf.st_mtime, time);
+                       list_item = g_strdup_printf("%s,%ld,%s", file_name, (long)buf.st_nlink - 2, time);
+
+                       *list = g_slist_append(*list, list_item);
+               }
+       }
+
+       free(path);
+       g_dir_close(dir);
+       dir = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_FSAPI_TRUE;
+
+}
+
+EXPORT_API void sync_agent_free_fs_list(GSList * list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(list == NULL, "folder_name paramter is NULL !!!");
+
+       GSList *iter = NULL;
+
+       for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
+               g_free(iter->data);
+       }
+
+       g_slist_free(list);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_fsapi_return_e sync_agent_file_md5_validation(const char *file_path, const char *find_md5_word, bool * is_same)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, 0, "file_path paramter is NULL !!!");
+       retvm_if(find_md5_word == NULL, 0, "find_md5_word paramter is NULL !!!");
+
+       int ret = 1;
+       unsigned char *real_md5_word = NULL;
+
+       _DEBUG_INFO("File_Path = %s\n", file_path);
+
+       /* get file hash key */
+       ret = fs_file_md5_hashkey(file_path, &real_md5_word);
+       if (ret != 1) {
+               _DEBUG_ERROR("fs_file_md5_hashkey() Fail!!\n");
+               goto return_part;
+       }
+
+       /* convert hex char to string (=> hash key) */
+       char szTmp_digest[256] = { 0, };
+       int k;
+       for (k = 0; k < 16; k++) {
+               szTmp_digest[k * 2] = _wss_str_to_hex_char((unsigned char)((real_md5_word[k] >> 4) & 0x0f));
+               szTmp_digest[k * 2 + 1] = _wss_str_to_hex_char((unsigned char)(real_md5_word[k] & 0x0f));
+       }
+
+       _DEBUG_INFO("find_md5_word = %s\n", find_md5_word);
+       _DEBUG_INFO("real_md5_word = %s\n", szTmp_digest);
+
+       /* compare read md5 checksum to file_md5_checksum */
+       if (memcmp(find_md5_word, szTmp_digest, strlen(szTmp_digest))) {
+               _DEBUG_ERROR("MD5 Hash Keys are not equal.\n");
+               *is_same = false;
+               ret = 0;
+               goto return_part;
+       }
+
+       _DEBUG_INFO("MD5 Hash Keys are equal.\n");
+       *is_same = true;
+
+       _EXTERN_FUNC_EXIT;
+
+ return_part:
+
+       if (real_md5_word != NULL)
+               free(real_md5_word);
+
+       return ret;
+}
+
+int fs_file_md5_hashkey(const char *file_path, unsigned char **hash_key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, 0, "file_path paramter is NULL !!!");
+
+       int ret = 1;
+       *hash_key = NULL;
+
+       unsigned long full_file_size = 0;
+       ret = sync_agent_get_file_size(file_path, &full_file_size);
+       _DEBUG_INFO("full_file_size = %d\n", full_file_size);
+
+       /* get MD5 encryption Hash Key */
+       char *required_contents = NULL;
+       unsigned char *real_md5_word = (unsigned char *)calloc(16, sizeof(char));
+       if (real_md5_word == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               ret = 0;
+               goto return_part;
+       }
+       bool isFinal = false;
+       unsigned long read_file_size = 0;
+
+       sa_md5_context_s context;
+
+       sa_md5_init(&context);
+
+       while (isFinal == false) {
+
+               ret = sync_agent_read_file(file_path, &required_contents, FS_BUFFER_SIZE, &read_file_size, &isFinal);
+               if (ret != 1) {
+                       _DEBUG_ERROR("sync_agent_read_file() Fail\n");
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("read_file_size = %d\n", read_file_size);
+               _DEBUG_INFO("isFinal = %d\n", isFinal);
+               sa_md5_update(&context, required_contents, read_file_size);
+       }
+       sa_md5_final(&context, real_md5_word);
+
+       /* print Hex char MD5 */
+       int real_md5_length = strlen((const char *)real_md5_word);
+       _DEBUG_INFO("real_md5_length = %d\n", real_md5_length);
+       _DEBUG_INFO(" real md5 : ");
+       int i = 0;
+       for (; i < real_md5_length; ++i) {
+               _DEBUG_INFO("%02x", real_md5_word[i]);
+       }
+       _DEBUG_INFO("\n");
+
+       *hash_key = real_md5_word;
+
+       _DEBUG_INFO("Free Part");
+       sync_agent_free_file(&required_contents);
+
+       _EXTERN_FUNC_EXIT;
+
+ return_part:
+       return ret;
+}
+
+static unsigned char _wss_str_to_hex_char(unsigned char hex)
+{
+       _INNER_FUNC_ENTER;
+
+       if (0 <= (char)hex && (char)hex <= 9) {
+               _EXTERN_FUNC_EXIT;
+               return '0' + hex;
+       } else {
+               if (10 <= (char)hex && (char)hex <= 15) {
+                       _INNER_FUNC_EXIT;
+                       return 'A' + hex - 10;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return '?';
+}
diff --git a/src/framework/fsapi/operation_internal.h b/src/framework/fsapi/operation_internal.h
new file mode 100755 (executable)
index 0000000..8e1b425
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPERATION_INTERNAL_H_
+#define OPERATION_INTERNAL_H_
+
+/**
+ * @file operation_internal.h
+ * @brief Provides file system related operations such as file/folder create, delete, read, write and etc.
+ */
+
+/** @addtogroup fsapi
+ *     @{
+ */
+
+/**
+ * @brief Provides date information of your file in character stream
+ * @remarks The return char stream format is "Y:m:d H:M:S".
+ * The Date info stream should be freed when no more in use.
+ * @param[in] file_name File path you want to check
+ * @param[out] time_string Double pointer of the char variable you want to load file date info on
+ * @return 1 on success, otherwise 0
+ */
+int fs_get_file_date(const char *file_name, char **time_string);
+
+/**
+ * @brief Provides MD5 hash extraction
+ * @param[in] file_path File path to extract MD5 hash
+ * @param[out] hash_key Char variable to load MD5 hash on
+ * @return 1 on success, otherwise 0
+ */
+int fs_file_md5_hashkey(const char *file_path, unsigned char **hash_key);
+
+/**
+ *     @}
+ */
+
+#endif                         /* OPERATION_INTERNAL_H_ */
diff --git a/src/framework/fsapi/util.c b/src/framework/fsapi/util.c
new file mode 100755 (executable)
index 0000000..1c803ce
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gprintf.h>
+#include "fsapi/util.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_FS"
+#endif
+
+int fs_is_existing(const char *file_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_file_test(file_name, G_FILE_TEST_EXISTS);
+}
+
+int fs_is_directory(const char *file_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_file_test(file_name, G_FILE_TEST_IS_DIR);
+}
+
+int fs_get_time_string(time_t * time_stamp, char *time_string)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(time_string == NULL, 0, "time string is NULL !!");
+
+       struct tm *time;
+       char buf[FS_MAX_TIME_STRING_BUF] = { 0 };
+       int buf_len = 0;
+
+       time = localtime(time_stamp);
+       strftime(buf, FS_MAX_TIME_STRING_BUF, "%Y:%m:%d %H:%M:%S", time);
+       buf_len = g_strlcpy(time_string, buf, FS_MAX_TIME_STRING_BUF);
+       if (buf_len >= FS_MAX_TIME_STRING_BUF) {
+               _DEBUG_ERROR("time_string buffer overflow !!");
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
diff --git a/src/framework/fsapi/util.h b/src/framework/fsapi/util.h
new file mode 100755 (executable)
index 0000000..6c7760d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FSAPI_UTIL_H_
+#define FSAPI_UTIL_H_
+
+#include <time.h>
+
+/**
+ * @file util.h
+ * @brief Provides file system related operations such as file/folder create, delete, read, write and etc.
+ */
+
+/** @addtogroup fsapi
+ *     @{
+ */
+
+#define FS_MAX_TIME_STRING_BUF 20                              /**< max time string buffer */
+
+/**
+ * @brief check that file is exist
+ * @param[in] file_name File path to check exist
+ * @return 1 on success, otherwise 0
+ */
+int fs_is_existing(const char *file_name);
+
+/**
+ * @brief check that file is directory
+ * @param[in] file_name File path to check that given file path is directory
+ * @return 1 on success, otherwise 0
+ */
+int fs_is_directory(const char *file_name);
+
+/**
+ * @brief get time string
+ * @param[in] time_stamp time_t
+ * @param[out] time_string converted time string
+ * @return 1 on success, otherwise 0
+ */
+int fs_get_time_string(time_t * time_stamp, char *time_string);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FSAPI_UTIL_H_ */
diff --git a/src/framework/initialization/interface.c b/src/framework/initialization/interface.c
new file mode 100755 (executable)
index 0000000..c209077
--- /dev/null
@@ -0,0 +1,354 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "utility/fw_mainloop.h"
+#include "utility/fw_mainloop_internal.h"
+
+#include "account/manager.h"
+#include "account/util_internal.h"
+
+#include "plugin/data_connector_plugin.h"
+#include "plugin/account_plugin.h"
+#include "plugin/platform_monitor_plugin.h"
+#include "plugin/network_access_plugin.h"
+#include "plugin/device_info_plugin.h"
+
+#include "data-adapter/interface_service_item.h"
+#include "data-adapter/service_internal.h"
+#include "data-adapter/changelog.h"
+#include "data-adapter/changelog_internal.h"
+
+#include "network-access/interface.h"
+#include "network-access/interface_internal.h"
+#include "network-access/callbacks.h"
+
+#include "device/error.h"
+#include "device/information.h"
+#include "device/information_internal.h"
+
+#include "platform-monitor/error.h"
+
+#include "initialization/parser.h"
+#include "initialization/interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_INIT"
+#endif
+
+static char *config_path = NULL;
+
+EXPORT_API sync_agent_init_error_e sync_agent_init(const char *init_config_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(init_config_path == NULL, SYNC_AGENT_INIT_FAIL, "init config path is NULL !!");
+       retvm_if(config_path != NULL, SYNC_AGENT_INIT_FAIL, "Already initialized !!");
+
+       sync_agent_init_error_e init_error = init_parse_init_config(init_config_path);
+
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               return init_error;
+       }
+
+       const char *agent_key = init_get_agent_key();
+       _DEBUG_INFO("Agent KEY : %s", agent_key);
+
+       int plugIn_dc_count = 0;
+       const plugin_data_connector_s *plugIn_dc_repository = plugin_get_data_connector_plugin_repository(&plugIn_dc_count);
+
+       int plugIn_pm_count = 0;
+       const plugin_platform_monitor_s *plugIn_pm_repository = plugin_get_platform_monitor_plugin_repository(&plugIn_pm_count);
+
+       /*
+        * Account
+        */
+       if (plugIn_dc_count != 0) {
+               int plugIn_acc_id = plugin_get_account_plugin_id();
+               plugin_set_account_repository_name_cb func_point_set_account_reposiory_name = plugin_get_function_set_account_repository_name(plugIn_acc_id);
+               if (func_point_set_account_reposiory_name != NULL) {
+                       func_point_set_account_reposiory_name(agent_key);
+               }
+       }
+
+       /*
+        * DataConnector Process ChangeNoti
+        */
+       int i = 0;
+       for (; i < plugIn_dc_count; i++) {
+               int plugIn_id = plugIn_dc_repository[i].plugin_info.plugin_id;
+
+               if (plugIn_dc_repository[i].handle_change_noti) {
+                       plugin_set_callback_add_item_cb func_point_set_callback_add_item = plugin_get_function_set_callback_add_item(plugIn_id);
+                       plugin_set_callback_delete_item_cb func_point_set_callback_delete_item = plugin_get_function_set_callback_delete_item(plugIn_id);
+                       plugin_set_callback_update_item_cb func_point_set_callback_update_item = plugin_get_function_data_connector_set_callback_update_item(plugIn_id);
+                       plugin_set_callback_get_account_id_list_cb func_point_set_callback_get_account_id_list = plugin_get_function_set_callback_get_account_id_list(plugIn_id);
+                       plugin_start_listening_change_noti_cb func_point_start_listening_change_noti = plugin_get_function_start_listening_change_noti(plugIn_id);
+
+                       sync_agent_da_return_e da_error = sync_agent_open_service(plugIn_id);
+                       if (da_error != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_open_service(%d) Failed!!", plugIn_id);
+                               return SYNC_AGENT_INIT_SERVICE_DB_FAIL;
+                       } else {
+                               _DEBUG_INFO("sync_agent_open_service(%d) Success!!", plugIn_id);
+                       }
+                       func_point_set_callback_add_item(da_handle_add_item);
+                       func_point_set_callback_delete_item(da_handle_del_item);
+                       func_point_set_callback_update_item(da_handle_update_item);
+                       func_point_set_callback_get_account_id_list(acc_get_service_account_id_list);
+
+                       if (plugIn_dc_repository[i].use_main_loop) {
+                               util_register_callback_to_main_loop(func_point_start_listening_change_noti, 0);
+                       }
+               } else {
+                       sync_agent_da_return_e da_error = sync_agent_open_service(plugIn_id);
+                       if (da_error != SYNC_AGENT_DA_SUCCESS) {
+                               _DEBUG_ERROR("sync_agent_open_service(%d) Failed!!", plugIn_id);
+                               return SYNC_AGENT_INIT_SERVICE_DB_FAIL;
+                       } else {
+                               _DEBUG_INFO("sync_agent_open_service(%d) Success!!", plugIn_id);
+                       }
+               }
+       }
+
+       /*
+        * NetworkAccess
+        */
+       int *na_plugIn_id_list = NULL;
+       int na_plugIn_cnt = plugin_get_network_access_plugin_id_list(&na_plugIn_id_list);
+
+       if (na_plugIn_id_list != NULL) {
+               i = 0;
+               for (; i < na_plugIn_cnt; i++) {
+                       sync_agent_na_result_e res = na_init_network_access(na_plugIn_id_list[i]);
+                       if (res == SYNC_AGENT_NA_SUCCESS) {
+                               _DEBUG_INFO("Success NACI_init() : %d", na_plugIn_id_list[i]);
+                       } else {
+                               _DEBUG_ERROR("Failed NACI_init() : %d, %d", res, na_plugIn_id_list[i]);
+                               if (na_plugIn_id_list != 0) {
+                                       free(na_plugIn_id_list);
+                               }
+                               return SYNC_AGENT_INIT_NETWORK_FAIL;
+                       }
+               }
+               free(na_plugIn_id_list);
+       }
+
+       /*
+        * Device Initialization
+        */
+       int *device_info_plugIn_id_list = NULL;
+       int device_info_plugIn_cnt = plugin_get_device_info_plugin_id_list(&device_info_plugIn_id_list);
+
+       if (device_info_plugIn_id_list != NULL) {
+               i = 0;
+               for (; i < device_info_plugIn_cnt; i++) {
+                       sync_agent_dev_return_e res = dev_init_dev(device_info_plugIn_id_list[i]);
+                       if (res == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+                               _DEBUG_INFO("Success SYNC_AGENT_DEV_RETURN_init() : %d", device_info_plugIn_id_list[i]);
+                       } else {
+                               _DEBUG_ERROR("Failed SYNC_AGENT_DEV_RETURN_init() : %d, %d", res, device_info_plugIn_id_list[i]);
+                               if (device_info_plugIn_id_list != 0) {
+                                       free(device_info_plugIn_id_list);
+                               }
+                               return SYNC_AGENT_INIT_DEVICE_FAIL;
+                       }
+               }
+               free(device_info_plugIn_id_list);
+       }
+
+       /*
+        * Platform Monitor Initialization
+        */
+       for (i = 0; i < plugIn_pm_count; i++) {
+               int plugIn_id = plugIn_pm_repository[i].plugin_info.plugin_id;
+               _DEBUG_INFO("plugin id : %d", plugIn_id);
+               plugin_init_service_noti_cb pfunc_init_service_noti = plugin_get_function_init_service_noti(plugIn_id);
+               if (pfunc_init_service_noti == NULL) {
+                       _DEBUG_ERROR("cannot get pfunc_init_service_noti !!");
+                       return SYNC_AGENT_INIT_PM_FAIL;
+               }
+
+               _DEBUG_INFO("registered data count : %d", plugIn_pm_repository[i].reg_data_count);
+
+               if (plugIn_pm_repository[i].reg_data_count > 0) {
+                       int j = 0;
+                       for (; j < plugIn_pm_repository[i].reg_data_count; j++) {
+                               sync_agent_pm_register_data_s *reg_data = NULL;
+                               reg_data = (plugIn_pm_repository[i].reg_data)[j];
+
+                               if (plugIn_pm_repository[i].use_main_loop) {
+                                       _DEBUG_INFO("register_Callback2MainLoop ( init_service_noti ) !!");
+
+                                       if (reg_data->pkg_name != NULL) {
+                                               _DEBUG_INFO("pkg name : %s", reg_data->pkg_name);
+                                       } else {
+                                               _DEBUG_INFO("pkg name is NULL !!");
+                                       }
+
+                                       if (reg_data->additional_data != NULL) {
+                                               _DEBUG_INFO("additional data : %s", reg_data->additional_data);
+                                       } else {
+                                               _DEBUG_INFO("additional data is NULL !!");
+                                       }
+
+                                       util_register_callback_to_main_loop(pfunc_init_service_noti, (void *)reg_data);
+                               } else {
+                                       pfunc_init_service_noti((void *)reg_data);
+                               }
+                       }
+               } else {
+                       if (plugIn_pm_repository[i].use_main_loop) {
+                               _DEBUG_INFO("register_Callback2MainLoop ( init_service_noti ) !!");
+                               util_register_callback_to_main_loop(pfunc_init_service_noti, NULL);
+                       } else {
+                               pfunc_init_service_noti(NULL);
+                       }
+               }
+       }
+
+/*
+       if (init_use_main_loop()) {
+               _DEBUG_INFO("Run Main Loop!!");
+               sync_agent_run_main_loop();
+       }
+*/
+
+       config_path = g_strdup(init_config_path);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+EXPORT_API sync_agent_deinit_error_e sync_agent_deinit()
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(config_path == NULL, SYNC_AGENT_DEINIT_FAIL, "Not initialized before !!");
+
+       sync_agent_deinit_error_e deinit_error = SYNC_AGENT_DEINIT_SUCCESS;
+       int i = 0;
+
+       /*
+        * DataConnector Process ChangeNoti
+        */
+       int plugin_dc_count = 0;
+       const plugin_data_connector_s *plugin_dc_repository = plugin_get_data_connector_plugin_repository(&plugin_dc_count);
+
+       for (; i < plugin_dc_count; i++) {
+               int plugin_id = plugin_dc_repository[i].plugin_info.plugin_id;
+
+               sync_agent_da_return_e da_error = sync_agent_close_service(plugin_id);
+               if (da_error != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_close_service(%d) Failed!!", plugin_id);
+                       return SYNC_AGENT_DEINIT_FAIL;
+               } else {
+                       _DEBUG_INFO("sync_agent_close_service(%d) Success!!", plugin_id);
+               }
+       }
+
+       /*
+        * NetworkAccess
+        */
+       sync_agent_destroy_netowk_access();
+       int *na_plugin_id_list = NULL;
+       int na_plugin_cnt = plugin_get_network_access_plugin_id_list(&na_plugin_id_list);
+
+       if (na_plugin_id_list != NULL) {
+               i = 0;
+               for (; i < na_plugin_cnt; i++) {
+                       int result = na_handle_network_all_cancel(na_plugin_id_list[i], NULL);
+                       if (result == 1) {
+                               _DEBUG_INFO("na_handle_network_all_cancel() success !!");
+                       } else {
+                               _DEBUG_ERROR("na_handle_network_all_cancel() failed !!");
+                               if (na_plugin_id_list != NULL) {
+                                       free(na_plugin_id_list);
+                               }
+                               return SYNC_AGENT_DEINIT_FAIL;
+                       }
+               }
+               free(na_plugin_id_list);
+
+               sync_agent_na_result_e res = sync_agent_destroy_netowk_access();
+               if (res != SYNC_AGENT_NA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_destroy_netowk_access() failed !! [%d]", res);
+                       return SYNC_AGENT_DEINIT_FAIL;
+               } else {
+                       _DEBUG_INFO("sync_agent_destroy_netowk_access() success !!");
+               }
+       }
+
+       /*
+        * Device Initialization
+        */
+       int *device_info_plugin_id_list = NULL;
+       int device_info_plugin_cnt = plugin_get_device_info_plugin_id_list(&device_info_plugin_id_list);
+
+       if (device_info_plugin_id_list != NULL) {
+               i = 0;
+               for (; i < device_info_plugin_cnt; i++) {
+                       sync_agent_dev_return_e res = dev_destroy_dev(device_info_plugin_id_list[i]);
+                       if (res == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+                               _DEBUG_INFO("dev_destroy_dev() success !!");
+                       } else {
+                               _DEBUG_ERROR("dev_destroy_dev() failed !! [%d]", res);
+                               if (device_info_plugin_id_list != NULL) {
+                                       free(device_info_plugin_id_list);
+                               }
+                               return SYNC_AGENT_DEINIT_FAIL;
+                       }
+               }
+               free(device_info_plugin_id_list);
+       }
+
+       /*
+        * Platform Monitor Initialization
+        */
+       int plugin_pm_count = 0;
+       const plugin_platform_monitor_s *plugin_pm_repository = plugin_get_platform_monitor_plugin_repository(&plugin_pm_count);
+
+       for (i = 0; i < plugin_pm_count; i++) {
+               int plugin_id = plugin_pm_repository[i].plugin_info.plugin_id;
+               _DEBUG_INFO("plugin id : %d", plugin_id);
+               plugin_unregister_service_noti_cb pfunc_unregister_service_noti = plugin_get_function_unregister_service_noti(plugin_id);
+               if (pfunc_unregister_service_noti == NULL) {
+                       _DEBUG_ERROR("cannot get pfunc_unregister_service_noti !!");
+                       return SYNC_AGENT_DEINIT_FAIL;
+               }
+       }
+
+       deinit_error = deinit_parse_config(config_path);
+       if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS) {
+               return deinit_error;
+       }
+
+       free(config_path);
+       config_path = NULL;
+
+       sync_agent_stop_main_loop(0);
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DEINIT_SUCCESS;
+}
diff --git a/src/framework/initialization/parser.c b/src/framework/initialization/parser.c
new file mode 100755 (executable)
index 0000000..d2e6d30
--- /dev/null
@@ -0,0 +1,936 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_mainloop.h"
+
+#include "engine-controller/internal.h"
+
+#include "data-adapter/agent.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#include "utility/fw_sequential_id_provider.h"
+
+#include "event/handler.h"
+#include "event/config.h"
+
+#include "plugin/struct.h"
+#include "plugin/data_connector_plugin.h"
+#include "plugin/data_converter_plugin.h"
+#include "plugin/account_plugin.h"
+#include "plugin/network_access_plugin.h"
+#include "plugin/device_info_plugin.h"
+#include "plugin/platform_monitor_plugin.h"
+#include "plugin/mo_plugin.h"
+#include "plugin/manager.h"
+#include "plugin/device_manager_plugin.h"
+
+#include "device-manager/mo_error.h"
+#include "device-manager/mo_database_handler.h"
+
+#include "device/information.h"
+
+#include "network-access/callbacks.h"
+
+#include "initialization/parser.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_INIT"
+#endif
+
+static char *agent_key = NULL;
+
+static int use_main_loop = 0;
+
+static sync_agent_init_error_e _process_node(xmlNode * root_element);
+
+static sync_agent_deinit_error_e _process_node_deinit(xmlNode * root_element);
+
+static sync_agent_init_error_e __process_engine_controller(xmlNode * engine_controller_node);
+
+static sync_agent_init_error_e __process_framework_db(xmlNode * framework_db_node);
+
+static sync_agent_init_error_e __process_id_provider(xmlNode * id_provider_node);
+
+static sync_agent_init_error_e __process_event(xmlNode * event_node);
+
+static sync_agent_init_error_e __process_noti(xmlNode * event_node);
+
+static sync_agent_init_error_e __process_plugin(xmlNode * plugin_mgr_node);
+
+static sync_agent_deinit_error_e __process_plugin_deinit(xmlNode * plugin_mgr_node);
+
+static sync_agent_init_error_e __process_device_manage(xmlNode * device_manage_node);
+
+static char *__get_child_node_content(xmlNode * parent_node, const char *node_name);
+
+static int __compare_uchar_with_char(const xmlChar * str, const char *str2);
+
+sync_agent_init_error_e init_parse_init_config(const char *init_config_file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       xmlDoc *doc = NULL;
+       xmlNode *root_element = NULL;
+
+       doc = xmlReadFile(init_config_file_path, 0, 0);
+       if (doc == NULL) {
+               _DEBUG_ERROR("Failed to parse %s", init_config_file_path);
+               return SYNC_AGENT_INIT_FAIL;
+       }
+
+       root_element = xmlDocGetRootElement(doc);
+
+       sync_agent_init_error_e init_err = _process_node(root_element);
+
+       xmlFreeDoc(doc);
+
+       _DEBUG_INFO("[End]");
+
+       _EXTERN_FUNC_EXIT;
+
+       return init_err;
+}
+
+sync_agent_deinit_error_e deinit_parse_config(const char *config_file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       xmlDoc *doc = NULL;
+       xmlNode *root_element = NULL;
+
+       doc = xmlReadFile(config_file_path, 0, 0);
+       if (doc == NULL) {
+               _DEBUG_ERROR("Failed to parse %s", config_file_path);
+               return SYNC_AGENT_DEINIT_FAIL;
+       }
+
+       root_element = xmlDocGetRootElement(doc);
+
+       sync_agent_deinit_error_e deinit_err = _process_node_deinit(root_element);
+
+       xmlFreeDoc(doc);
+
+       _DEBUG_INFO("[End]");
+
+       _EXTERN_FUNC_EXIT;
+
+       return deinit_err;
+}
+
+char *init_get_agent_key(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return agent_key;
+}
+
+int init_use_main_loop(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return use_main_loop;
+}
+
+static sync_agent_init_error_e _process_node(xmlNode * root_element)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_init_error_e init_error = SYNC_AGENT_INIT_SUCCESS;
+
+       if (root_element == NULL) {
+               return SYNC_AGENT_INIT_FAIL;
+       }
+
+       xmlNode *cursor_node = root_element->children;
+       while (cursor_node != NULL) {
+               if (cursor_node->type == XML_ELEMENT_NODE) {
+                       _DEBUG_TRACE("%s", cursor_node->name);
+                       if (__compare_uchar_with_char(cursor_node->name, "Agent-Key")) {
+                               agent_key = (char *)xmlNodeGetContent(cursor_node);
+                               _DEBUG_TRACE("Agent-Key : %s", agent_key);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "MainLoop")) {
+                               xmlChar *main_loop = xmlNodeGetContent(cursor_node);
+                               if (__compare_uchar_with_char(main_loop, "1")) {
+                                       use_main_loop = 1;
+                               }
+                       } else if (__compare_uchar_with_char(cursor_node->name, "EngineController")) {
+                               init_error = __process_engine_controller(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "FrameworkDB")) {
+                               init_error = __process_framework_db(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "ID-Provider")) {
+                               init_error = __process_id_provider(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "Event")) {
+                               init_error = __process_event(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "Noti")) {
+                               init_error = __process_noti(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "PlugIn-Mgr")) {
+                               init_error = __process_plugin(cursor_node);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "DeviceManage")) {
+                               init_error = __process_device_manage(cursor_node);
+                       }
+               }
+
+               cursor_node = cursor_node->next;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return init_error;
+}
+
+static sync_agent_deinit_error_e _process_node_deinit(xmlNode * root_element)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_deinit_error_e deinit_error = SYNC_AGENT_DEINIT_SUCCESS;
+
+       if (root_element == NULL) {
+               return SYNC_AGENT_DEINIT_FAIL;
+       }
+
+       xmlNode *cursor_node = root_element->children;
+       while (cursor_node != NULL) {
+               if (cursor_node->type == XML_ELEMENT_NODE) {
+                       _DEBUG_TRACE("%s", cursor_node->name);
+                       if (__compare_uchar_with_char(cursor_node->name, "Agent-Key")) {
+                               agent_key = (char *)xmlNodeGetContent(cursor_node);
+                               _DEBUG_TRACE("Agent-Key : %s", agent_key);
+                       } else if (__compare_uchar_with_char(cursor_node->name, "FrameworkDB")) {
+                               sync_agent_da_return_e da_error = sync_agent_close_agent();
+                               if (da_error != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("sync_agent_close_agent() failed !! [%d]", da_error);
+                                       return SYNC_AGENT_DEINIT_FAIL;
+                               } else {
+                                       _DEBUG_TRACE("sync_agent_close_agent() success !!");
+                               }
+
+                               da_error = da_free_agentdb_handler_mgr();
+                               if (da_error != SYNC_AGENT_DA_SUCCESS) {
+                                       _DEBUG_ERROR("da_free_agentdb_handler_mgr() failed !! [%d]", da_error);
+                                       return SYNC_AGENT_DEINIT_FAIL;
+                               } else {
+                                       _DEBUG_TRACE("da_free_agentdb_handler_mgr() success !!");
+                               }
+                       } else if (__compare_uchar_with_char(cursor_node->name, "Event") || __compare_uchar_with_char(cursor_node->name, "Noti")) {
+                               sync_agent_event_error_e event_error = sync_agent_clean_event_handler();
+                               if (event_error != SYNC_AGENT_EVENT_SUCCESS) {
+                                       _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! [%d]", event_error);
+                                       return SYNC_AGENT_DEINIT_FAIL;
+                               } else {
+                                       _DEBUG_TRACE("sync_agent_clean_event_handler() success !!");
+                               }
+                       } else if (__compare_uchar_with_char(cursor_node->name, "PlugIn-Mgr")) {
+                               deinit_error = __process_plugin_deinit(cursor_node);
+                               if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS) {
+                                       _DEBUG_ERROR("__process_plugin_deinit() failed !! [%d]", deinit_error);
+                                       return deinit_error;
+                               } else {
+                                       _DEBUG_TRACE("__process_plugin_deinit() success !!");
+                               }
+                       } else if (__compare_uchar_with_char(cursor_node->name, "DeviceManage")) {
+                               sync_agent_dm_mo_error_e mo_error = dm_mo_close();
+                               if (mo_error != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("Failed to dm_mo_close() : %d", mo_error);
+                                       return SYNC_AGENT_DEINIT_FAIL;
+                               }
+
+                               mo_error = dm_mo_free_modb_handler_mgr();
+                               if (mo_error != SYNC_AGENT_DM_MO_SUCCESS) {
+                                       _DEBUG_ERROR("dm_mo_free_modb_handler_mgr() failed !! [%d]", mo_error);
+                                       return SYNC_AGENT_DEINIT_FAIL;
+                               } else {
+                                       _DEBUG_TRACE("dm_mo_free_modb_handler_mgr() success !!");
+                               }
+                       }
+               }
+
+               cursor_node = cursor_node->next;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return deinit_error;
+}
+
+/********************** Implement static function *************************/
+
+static sync_agent_init_error_e __process_engine_controller(xmlNode * engine_controller_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(engine_controller_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       xmlNode *max_thread = engine_controller_node->children;
+       if (max_thread == NULL) {
+               return SYNC_AGENT_INIT_PARSER_FAIL;
+       }
+
+       char *max_thread_count_str = __get_child_node_content(engine_controller_node, "Max-Thread");
+       int max_thread_count = atoi(max_thread_count_str);
+
+       if (max_thread_count <= 0) {
+               return SYNC_AGENT_INIT_ENGINE_CONTROLLER_FAIL;
+       }
+
+       bool init_success = ec_init_engine_controller(max_thread_count);
+       if (init_success) {
+               _DEBUG_VERBOSE("Engine controller initialize success");
+       } else {
+               _DEBUG_ERROR("Engine controller initialize fail");
+               return SYNC_AGENT_INIT_ENGINE_CONTROLLER_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_framework_db(xmlNode * framework_db_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(framework_db_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       const char *use_DB_str = (char *)xmlGetProp(framework_db_node, (xmlChar *) "use");
+       int use_DB = atoi(use_DB_str);
+       if (!use_DB) {
+               _DEBUG_VERBOSE("Not Use Framework Common DB");
+               return SYNC_AGENT_INIT_SUCCESS;
+       }
+
+       char *db_path = __get_child_node_content(framework_db_node, "Path");
+       _DEBUG_VERBOSE("Common DB Path : %s", db_path);
+
+       da_set_agent_db_file_path(db_path);
+
+       sync_agent_da_return_e da_err = da_alloc_agentdb_handler_mgr();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               return SYNC_AGENT_INIT_COMMON_DB_FAIL;
+       }
+
+       da_err = sync_agent_open_agent();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               return SYNC_AGENT_INIT_COMMON_DB_FAIL;
+       }
+
+       da_err = da_create_agent_default_table_wrapper();
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               return SYNC_AGENT_INIT_COMMON_DB_FAIL;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_id_provider(xmlNode * id_provider_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(id_provider_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       char *code_str = __get_child_node_content(id_provider_node, "Code");
+       char *max_id_str = __get_child_node_content(id_provider_node, "MaxID");
+       char *page_size_str = __get_child_node_content(id_provider_node, "PageSize");
+
+       unsigned int code = atoi(code_str);
+       unsigned int id_max = atoi(max_id_str);
+       unsigned int log2_page_size = atoi(page_size_str);
+
+       util_id_provider_error_e error = util_create_id_persistent_provider(code, id_max, log2_page_size);
+       if (error == UTIL_ID_PROVIDER_OK) {
+               _DEBUG_VERBOSE("Done sync_agent_create_id_persistent_provider : %d", error);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_event(xmlNode * event_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(event_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       char *event_key = __get_child_node_content(event_node, "Event-Key");
+       char *event_configfile = __get_child_node_content(event_node, "Event-Config");
+       xmlChar *run_eventHandler = (xmlChar *) __get_child_node_content(event_node, "RunEventHandler");
+
+       sync_agent_event_error_e event_err = event_set_event_spec_from_config_file(event_key, event_configfile);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("Fail Load event config");
+               return SYNC_AGENT_INIT_SYNC_AGENT_EVENT_FAIL;
+       } else {
+               _DEBUG_VERBOSE("Success Load event config");
+       }
+
+       if (__compare_uchar_with_char(run_eventHandler, "1")) {
+               unsigned long int thread_id;
+               event_err = sync_agent_run_event_handler(&thread_id);
+               if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+                       _DEBUG_ERROR("Failed to sync_agent_run_event_handler()");
+                       return SYNC_AGENT_INIT_SYNC_AGENT_EVENT_FAIL;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_noti(xmlNode * event_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(event_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       char *noti_key = __get_child_node_content(event_node, "Noti-Key");
+       char *noti_configfile = __get_child_node_content(event_node, "Noti-Config");
+
+       sync_agent_event_error_e event_err = event_set_noti_spec_from_config_file(noti_key, noti_configfile);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("Fail Load noti config : %s", noti_configfile);
+               return SYNC_AGENT_INIT_SYNC_AGENT_EVENT_FAIL;
+       } else {
+               _DEBUG_VERBOSE("Success Load noti config");
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_plugin(xmlNode * plugin_mgr_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(plugin_mgr_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       xmlNode *domain_node = plugin_mgr_node->children;
+       while (domain_node != NULL) {
+               if (domain_node->type == XML_ELEMENT_NODE) {
+                       const xmlChar *domain_name = xmlGetProp(domain_node, (xmlChar *) "name");
+                       const xmlChar *domain_count = xmlGetProp(domain_node, (xmlChar *) "count");
+                       int d_count = 0;
+                       if (domain_count != NULL) {
+                               d_count = atoi((char *)domain_count);
+                       }
+                       _DEBUG_VERBOSE("Domain : %s ( count : %d ) =====================", domain_name, d_count);
+
+                       xmlNode *plugIn_node = domain_node->children;
+                       while (plugIn_node != NULL) {
+                               if (plugIn_node->type == XML_ELEMENT_NODE) {
+                                       plugin_info_s plugIn_Info;
+
+                                       char *plugIn_ID = __get_child_node_content(plugIn_node, "ID");
+                                       char *plugIn_path = __get_child_node_content(plugIn_node, "Path");
+
+                                       plugIn_Info.plugin_id = atoi(plugIn_ID);
+
+                                       plugin_error_e plugIn_error;
+                                       plugIn_Info.plugin_handle = plugin_load_plugin(plugIn_path, &plugIn_error);
+                                       if (plugIn_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("load_PlugIn Failed [%s]", plugIn_path);
+                                               return SYNC_AGENT_INIT_PLUGIN_FAIL;
+                                       }
+
+                                       _DEBUG_VERBOSE("plugIn_ID : %d", plugIn_Info.plugin_id);
+                                       _DEBUG_VERBOSE("plugIn_Path : %s", plugIn_path);
+
+                                       if (__compare_uchar_with_char(domain_name, "DataConnector")) {
+                                               plugin_data_connector_s plugIn_dc;
+                                               char *dataConverter = __get_child_node_content(plugIn_node, "DataConverter-PlugIn");
+                                               char *handleChangeNoti = __get_child_node_content(plugIn_node, "Handle-ChangeNoti");
+                                               char *useMainLoop = __get_child_node_content(plugIn_node, "Use-MainLoop");
+
+                                               plugIn_dc.plugin_info = plugIn_Info;
+                                               plugIn_dc.data_converter_id = atoi(dataConverter);
+                                               plugIn_dc.handle_change_noti = atoi(handleChangeNoti);
+                                               plugIn_dc.use_main_loop = atoi(useMainLoop);
+                                               plugIn_dc.func_set = plugin_get_data_connector_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_data_connector(plugIn_dc);
+                                       } else if (__compare_uchar_with_char(domain_name, "DataConverter")) {
+                                               plugin_data_converter_s plugIn_dataconverter;
+
+                                               plugIn_dataconverter.plugin_info = plugIn_Info;
+                                               plugIn_dataconverter.func_set = plugin_get_data_converter_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_data_converter(plugIn_dataconverter);
+                                       } else if (__compare_uchar_with_char(domain_name, "Account")) {
+                                               plugin_account_s plugIn_acc;
+
+                                               plugIn_acc.plugin_info = plugIn_Info;
+                                               plugIn_acc.func_set = plugin_get_plugin_account_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_account(plugIn_acc);
+                                       } else if (__compare_uchar_with_char(domain_name, "NetworkAccess")) {
+                                               plugin_network_access_s plugIn_na;
+
+                                               plugIn_na.plugin_info = plugIn_Info;
+                                               plugIn_na.func_set = plugin_get_network_access_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               char *use_network = __get_child_node_content(plugIn_node, "UseNetwork");
+                                               plugIn_na.use_network = atoi(use_network);
+
+                                               plugin_register_plugin_network_access(plugIn_na);
+                                       } else if (__compare_uchar_with_char(domain_name, "DeviceInfo")) {
+                                               plugin_device_info_s plugIn_device;
+
+                                               plugIn_device.plugin_info = plugIn_Info;
+                                               plugIn_device.func_set = plugin_get_device_info_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_device_info(plugIn_device);
+
+                                               char *depends_on = __get_child_node_content(plugIn_node, "DependsOn");
+                                               if (depends_on != NULL) {
+                                                       /*
+                                                        * Setting dependant DeviceInfo interface
+                                                        */
+                                                       int plugIn_id = atoi(depends_on);
+                                                       if (plugin_is_exsist_device_info_plugin()) {
+                                                               _DEBUG_INFO("Dependent DeviceInfo PlulgIn ID : %d", plugIn_id);
+
+                                                               plugin_set_common_devinfo_function_cb func_point_set_common_devinfo_function = plugin_get_function_set_common_devinfo_function(plugIn_Info.plugin_id);
+                                                               if (func_point_set_common_devinfo_function != 0) {
+                                                                       func_point_set_common_devinfo_function(sync_agent_get_devinfo);
+                                                               } else {
+                                                                       _DEBUG_ERROR("func_point_set_func_get_device_info_common is NULL!!");
+                                                               }
+                                                               plugin_set_common_execute_dev_function_cb func_point_set_common_execute_dev_function = plugin_get_function_set_common_execute_dev_function(plugIn_Info.plugin_id);
+                                                               if (func_point_set_common_execute_dev_function != 0) {
+                                                                       func_point_set_common_execute_dev_function(sync_agent_execute_dev_function);
+                                                               } else {
+                                                                       _DEBUG_ERROR("func_point_set_func_execute_device_function_common is NULL!!");
+                                                               }
+                                                       } else {
+                                                               _DEBUG_ERROR("FAIL!! Depending DeviceInfo PlulgIn not existing!!");
+                                                       }
+                                               }
+                                       } else if (__compare_uchar_with_char(domain_name, "PlatformMonitor")) {
+                                               int r_count = 0;
+                                               plugin_platform_monitor_s plugIn_pm;
+                                               sync_agent_pm_register_data_s **reg_data = NULL;
+
+                                               char *useMainLoop = __get_child_node_content(plugIn_node, "Use-MainLoop");
+                                               plugIn_pm.use_main_loop = atoi(useMainLoop);
+
+                                               xmlNode *cursor_node = plugIn_node->children;
+                                               while (cursor_node != NULL) {
+                                                       if (__compare_uchar_with_char(cursor_node->name, "Register-Data")) {
+                                                               char *reg_count = (char *)xmlGetProp(cursor_node, (xmlChar *) "count");
+                                                               if (reg_count != NULL) {
+                                                                       r_count = atoi(reg_count);
+                                                               }
+                                                               _DEBUG_VERBOSE("Register-Data count : %d", r_count);
+
+                                                               if (r_count > 0) {
+                                                                       _DEBUG_VERBOSE("exist Register-Data ( count : %d ) !!", r_count);
+                                                                       xmlNode *cursor_child_node = cursor_node->children;
+
+                                                                       reg_data = (sync_agent_pm_register_data_s **) calloc(r_count, sizeof(sync_agent_pm_register_data_s *));
+                                                                       if (reg_data == NULL) {
+                                                                               _DEBUG_ERROR("calloc failed !!");
+                                                                               return SYNC_AGENT_INIT_FAIL;
+                                                                       }
+
+                                                                       int i = 0;
+                                                                       while (cursor_child_node != NULL) {
+                                                                               if (__compare_uchar_with_char(cursor_child_node->name, "Data")) {
+                                                                                       char *pkg_name = __get_child_node_content(cursor_child_node, "Pkg-Name");
+                                                                                       char *additional_data = __get_child_node_content(cursor_child_node, "Additional-Data");
+
+                                                                                       reg_data[i] = (sync_agent_pm_register_data_s *) calloc(1, sizeof(sync_agent_pm_register_data_s));
+                                                                                       if (reg_data[i] == NULL) {
+                                                                                               _DEBUG_ERROR("calloc failed !!");
+                                                                                               if (reg_data != NULL)
+                                                                                                       free(reg_data);
+                                                                                               return SYNC_AGENT_INIT_FAIL;
+                                                                                       }
+
+                                                                                       if (pkg_name != NULL) {
+                                                                                               reg_data[i]->pkg_name = strdup(pkg_name);
+                                                                                               _DEBUG_VERBOSE("pkg_name : %s", reg_data[i]->pkg_name);
+                                                                                       } else {
+                                                                                               _DEBUG_VERBOSE("pkg_name is NULL !!");
+                                                                                       }
+
+                                                                                       if (additional_data != NULL) {
+                                                                                               reg_data[i]->additional_data = strdup(additional_data);
+                                                                                               _DEBUG_VERBOSE("additional_data : %s", reg_data[i]->additional_data);
+                                                                                       } else {
+                                                                                               _DEBUG_VERBOSE("additional_data is NULL !!");
+                                                                                       }
+
+                                                                                       i++;
+                                                                               }
+                                                                               cursor_child_node = cursor_child_node->next;
+                                                                       }
+                                                               } else {
+                                                                       _DEBUG_VERBOSE("not exist Register-Data !!");
+                                                               }
+
+                                                               break;
+                                                       }
+                                                       cursor_node = cursor_node->next;
+                                               }
+
+                                               if ((r_count == 0) && (strstr(plugIn_path, "sysnoti-network-connection") != NULL)) {
+                                                       _DEBUG_VERBOSE("set network connection cb data !!");
+                                                       reg_data = (sync_agent_pm_register_data_s **) calloc(1, sizeof(sync_agent_pm_register_data_s *));
+                                                       if (reg_data == NULL) {
+                                                               _DEBUG_ERROR("calloc failed !!");
+                                                               _INNER_FUNC_EXIT;
+                                                               return SYNC_AGENT_INIT_FAIL;
+                                                       }
+
+                                                       *reg_data = (sync_agent_pm_register_data_s *) calloc(1, sizeof(sync_agent_pm_register_data_s));
+                                                       if (*reg_data == NULL) {
+                                                               _DEBUG_ERROR("calloc failed !!");
+                                                               if (reg_data != NULL)
+                                                                       free(reg_data);
+                                                               _INNER_FUNC_EXIT;
+                                                               return SYNC_AGENT_INIT_FAIL;
+                                                       }
+
+                                                       sync_agent_user_callback_cb_plugin *usr_cb = (sync_agent_user_callback_cb_plugin *) calloc(2, sizeof(sync_agent_user_callback_cb_plugin));
+                                                       if (usr_cb == NULL) {
+                                                               _DEBUG_ERROR("calloc failed !!");
+                                                               if (*reg_data != NULL)
+                                                                       free(*reg_data);
+                                                               if (reg_data != NULL)
+                                                                       free(reg_data);
+                                                               _INNER_FUNC_EXIT;
+                                                               return SYNC_AGENT_INIT_FAIL;
+                                                       }
+
+                                                       usr_cb[0] = na_handle_network_status;
+                                                       usr_cb[1] = na_handle_network_all_cancel;
+
+                                                       (*reg_data)->user_data = (void *)usr_cb;
+
+                                                       r_count = 1;
+                                               }
+
+                                               plugIn_pm.reg_data = reg_data;
+                                               plugIn_pm.reg_data_count = r_count;
+                                               plugIn_pm.plugin_info = plugIn_Info;
+                                               plugIn_pm.func_set = plugin_get_platform_monitor_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_platform_monitor(plugIn_pm);
+                                       } else if (__compare_uchar_with_char(domain_name, "MO")) {
+                                               plugin_mo_s plugIn_mo;
+
+                                               plugIn_mo.plugin_info = plugIn_Info;
+                                               plugIn_mo.func_set = plugin_get_mo_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               char *mo_type = __get_child_node_content(plugIn_node, "Type");
+                                               if (mo_type != NULL) {
+                                                       if (!strcmp(mo_type, "DEVDETAIL")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
+                                                       } else if (!strcmp(mo_type, "DEVINFO")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_DEVINFO;
+                                                       } else if (!strcmp(mo_type, "FUMO")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_FUMO;
+                                                       } else if (!strcmp(mo_type, "DMACC")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+                                                       } else if (!strcmp(mo_type, "LAWMO")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_LAWMO;
+                                                       } else if (!strcmp(mo_type, "SCOMO")) {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_SCOMO;
+                                                       } else {
+                                                               plugIn_mo.mo_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
+                                                       }
+
+                                                       plugin_register_plugin_mo(plugIn_mo);
+                                               }
+                                       } else if (__compare_uchar_with_char(domain_name, "DeviceManager")) {
+                                               plugin_device_manager_s plugIn_device_manager;
+
+                                               plugIn_device_manager.plugin_info = plugIn_Info;
+                                               plugIn_device_manager.func_set = plugin_get_device_manager_func_set(plugIn_Info.plugin_handle, &plugIn_error);
+
+                                               plugin_register_plugin_device_manager(plugIn_device_manager);
+                                       }
+                               }
+
+                               plugIn_node = plugIn_node->next;
+                       }
+               }
+               domain_node = domain_node->next;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_deinit_error_e __process_plugin_deinit(xmlNode * plugin_mgr_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(plugin_mgr_node == NULL, SYNC_AGENT_DEINIT_FAIL, "xmlNode is NULL !!");
+
+       plugin_error_e plugin_error = PLUGIN_SUCCESS;
+       xmlNode *domain_node = plugin_mgr_node->children;
+       while (domain_node != NULL) {
+               if (domain_node->type == XML_ELEMENT_NODE) {
+                       const xmlChar *domain_name = xmlGetProp(domain_node, (xmlChar *) "name");
+                       const xmlChar *domain_count = xmlGetProp(domain_node, (xmlChar *) "count");
+                       int d_count = 0;
+                       if (domain_count != NULL) {
+                               d_count = atoi((char *)domain_count);
+                       }
+                       _DEBUG_VERBOSE("Domain : %s ( count : %d ) =====================", domain_name, d_count);
+
+                       int i;
+                       int plugin_count = 0;
+                       if (__compare_uchar_with_char(domain_name, "DataConnector")) {
+                               const plugin_data_connector_s *plugin_dc_repository = plugin_get_data_connector_plugin_repository(&plugin_count);
+
+                               /* unload DataConnector's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_dc_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_dc_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_dc_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear DataConnector's plug-in repository */
+                               plugin_clear_plugin_data_connector();
+                       } else if (__compare_uchar_with_char(domain_name, "DataConverter")) {
+//                              int plugin_count = 0;
+                               const plugin_data_converter_s *plugin_dc_repository = plugin_get_data_converter_plugin_repository(&plugin_count);
+
+                               /* unload DataConnector's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_dc_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_dc_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_dc_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear DataConverter's plug-in repository */
+                               plugin_clear_plugin_data_converter();
+                       } else if (__compare_uchar_with_char(domain_name, "Account")) {
+                               const plugin_account_s plugin_acc_repository = plugin_get_account_plugin_repository();
+
+                               /* unload Account's plug-in */
+                               plugin_error = plugin_unload_plugin(plugin_acc_repository.plugin_info.plugin_handle);
+                               if (plugin_error != PLUGIN_SUCCESS) {
+                                       _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_acc_repository.plugin_info.plugin_id);
+                               } else {
+                                       _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_acc_repository.plugin_info.plugin_id);
+                               }
+
+                               /* clear Account's plug-in repository */
+                               plugin_clear_plugin_account();
+                       } else if (__compare_uchar_with_char(domain_name, "NetworkAccess")) {
+//                              int plugin_count = 0;
+                               const plugin_network_access_s *plugin_na_repository = plugin_get_network_access_plugin_repository(&plugin_count);
+
+                               /* unload NetworkAccess's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_na_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_na_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_na_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear NetworkAccess's plug-in repository */
+                               plugin_clear_plugin_network_access();
+                       } else if (__compare_uchar_with_char(domain_name, "DeviceInfo")) {
+//                              int plugin_count = 0;
+                               const plugin_device_info_s *plugin_di_repository = plugin_get_device_info_plugin_repository(&plugin_count);
+
+                               /* unload DeviceInfo's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_di_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_di_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_di_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear DeviceInfo's plug-in repository */
+                               plugin_clear_plugin_device_info();
+                       } else if (__compare_uchar_with_char(domain_name, "PlatformMonitor")) {
+//                              int plugin_count = 0;
+                               const plugin_platform_monitor_s *plugin_pm_repository = plugin_get_platform_monitor_plugin_repository(&plugin_count);
+
+                               /* unload PlatformMonitor's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_pm_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_pm_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_pm_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                       } else if (__compare_uchar_with_char(domain_name, "MO")) {
+//                              int plugin_count = 0;
+                               const plugin_mo_s *plugin_mo_repository = plugin_get_mo_plugin_repository(&plugin_count);
+
+                               /* unload MO's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_mo_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_mo_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_mo_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear MO's plug-in repository */
+                               plugin_clear_plugin_mo();
+                       } else if (__compare_uchar_with_char(domain_name, "DeviceManager")) {
+//                              int plugin_count = 0;
+                               const plugin_device_manager_s *plugin_dm_repository = plugin_get_device_manager_plugin_repository(&plugin_count);
+
+                               /* unload DeviceManager's plug-in */
+                               for (i = 0; i < plugin_count; i++) {
+                                       plugin_error = plugin_unload_plugin(plugin_dm_repository[i].plugin_info.plugin_handle);
+                                       if (plugin_error != PLUGIN_SUCCESS) {
+                                               _DEBUG_ERROR("plugin_unload_plugin() - %s [ID : %d] failed !!", domain_name, plugin_dm_repository[i].plugin_info.plugin_id);
+                                       } else {
+                                               _DEBUG_VERBOSE("plugin_unload_plugin() - %s [ID : %d] success !!", domain_name, plugin_dm_repository[i].plugin_info.plugin_id);
+                                       }
+                               }
+
+                               /* clear DeviceManager's plug-in repository */
+                               plugin_clear_plugin_device_manager();
+                       }
+               }
+               domain_node = domain_node->next;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static sync_agent_init_error_e __process_device_manage(xmlNode * device_manage_node)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(device_manage_node == NULL, SYNC_AGENT_INIT_FAIL, "xmlNode is NULL !!");
+
+       sync_agent_dm_mo_error_e mo_err = dm_mo_alloc_modb_handler_mgr();
+       if (mo_err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_alloc_modb_handler_mgr() : %d", mo_err);
+               return SYNC_AGENT_INIT_DM_FAIL;
+       }
+
+       /*
+        * Setting MO PlugIn DeviceInfo
+        */
+       char *mo_db_path_str = __get_child_node_content(device_manage_node, "MO-DB-Path");
+
+//      mo_err = dm_mo_open("/opt/dbspace/.momanager.db");
+       mo_err = dm_mo_open(mo_db_path_str);
+       if (mo_err != SYNC_AGENT_DM_MO_SUCCESS) {
+               _DEBUG_ERROR("Failed to dm_mo_open() : %d", mo_err);
+               return SYNC_AGENT_INIT_DM_FAIL;
+       }
+
+       dm_mo_create_mo_table_wraper();
+
+       char *dependent_devinfo_id_str = __get_child_node_content(device_manage_node, "DependentDevInfoID");
+       int dependent_devinfo_id = atoi(dependent_devinfo_id_str);
+
+       if (plugin_is_exsist_device_info_plugin()) {
+               _DEBUG_VERBOSE("Dependent device Info PlulgIn ID : %d", dependent_devinfo_id);
+
+               int *mo_plugIn_id_list = NULL;
+               int mo_plugIn_cnt = plugin_get_mo_plugin_id_list(&mo_plugIn_id_list);
+
+               _DEBUG_VERBOSE("Loaded MO PlugIn Count : %d", mo_plugIn_cnt);
+
+               int i = 0;
+               for (; i < mo_plugIn_cnt; i++) {
+                       plugin_set_func_get_device_info func_point_set_func_get_device_info = plugin_get_function_set_func_get_device_info(mo_plugIn_id_list[i]);
+                       if (func_point_set_func_get_device_info != 0) {
+                               func_point_set_func_get_device_info(sync_agent_get_devinfo);
+                       } else {
+                               _DEBUG_ERROR("func_point_set_func_get_device_info is NULL!!");
+                       }
+               }
+
+               free(mo_plugIn_id_list);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return SYNC_AGENT_INIT_SUCCESS;
+}
+
+static char *__get_child_node_content(xmlNode * parent_node, const char *node_name)
+{
+       _INNER_FUNC_ENTER;
+
+       if (parent_node == NULL || node_name == NULL) {
+               return NULL;
+       }
+
+       xmlNode *cursor_node = parent_node->children;
+
+       while (cursor_node != NULL) {
+               if (cursor_node->type == XML_ELEMENT_NODE) {
+                       const xmlChar *compare_name = cursor_node->name;
+                       if (__compare_uchar_with_char(compare_name, node_name)) {
+                               _INNER_FUNC_EXIT;
+                               return (char *)xmlNodeGetContent(cursor_node);
+                       }
+               }
+               cursor_node = cursor_node->next;
+       }
+
+       return NULL;
+}
+
+static int __compare_uchar_with_char(const xmlChar * str, const char *str2)
+{
+       _INNER_FUNC_ENTER;
+
+       if (str == NULL || str2 == NULL) {
+               return 0;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return xmlStrEqual(str, (const xmlChar *)str2);
+}
diff --git a/src/framework/initialization/parser.h b/src/framework/initialization/parser.h
new file mode 100755 (executable)
index 0000000..893965a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARSER_H_
+#define PARSER_H_
+
+#include "initialization/error.h"
+
+/**
+ * @file       parser.h
+ * @brief      Parsing F/W Initialization configuration file
+ */
+
+/** @addtogroup initialization
+ *     @{
+ */
+
+/**
+ * @brief      parse F/W Initialization configuration file
+ * @param[in]  init_config_file_path F/W config file path
+ * @return     Error Code
+ * @retval     SYNC_AGENT_INIT_SUCCESS on success
+ * @retval     other INIT Error code failed
+ */
+sync_agent_init_error_e init_parse_init_config(const char *init_config_file_path);
+
+/**
+ * @brief      parse F/W Deinitialization configuration file
+ * @param[in]  config_file_path F/W config file path
+ * @return     Error Code
+ * @retval     SYNC_AGENT_INIT_SUCCESS on success
+ * @retval     other INIT Error code failed
+ */
+sync_agent_deinit_error_e deinit_parse_config(const char *config_file_path);
+
+/**
+ * @brief      Get F/W Agent Key, this info is wrote in F/W Initialization configuration file
+ * @return
+ * @retval     Agent Key               on success
+ * @retval     null pointer    failed, if Agent Key not exist
+ */
+char *init_get_agent_key(void);
+
+/**
+ * @brief      whether Agent use main loop, it wrote in F/W Initialization configuration file
+ * @return
+ * @retval     1 or 0
+ * @retval     1       use main loop
+ * @retval 0   not use main loop
+ */
+int init_use_main_loop(void);
+
+/**
+ *     @}
+ */
+
+#endif                         /* PARSER_H_ */
diff --git a/src/framework/network-access/callbacks.c b/src/framework/network-access/callbacks.c
new file mode 100755 (executable)
index 0000000..6a21fb8
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "network-access/callbacks.h"
+#include "network-access/session_manager.h"
+#include "plugin/network_access_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_NACI"
+#endif
+
+int na_handle_network_status(int na_plugIn_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int err = na_set_network_info(na_plugIn_id, data);
+       if (err != 1) {
+               _DEBUG_ERROR("na_set_network_info() is fail !!");
+               return err;
+       } else {
+               _DEBUG_INFO("na_set_network_info() is success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+int na_handle_network_all_cancel(int na_plugIn_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+       GList *session_list = NULL;
+
+       int err = na_get_all_session(&session_list);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_all_session() is fail !!");
+               return -1;
+       } else {
+               _DEBUG_INFO("na_get_all_session() is success !!");
+       }
+
+       plugin_cancel_message_cb func_point_cancel_message = plugin_get_function_cancel_message(na_plugIn_id);
+
+       if (func_point_cancel_message == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !!\n", __func__);
+               return -1;
+       }
+
+       if (session_list != NULL) {
+               GList *iter = NULL;
+               void *session = NULL;
+
+               for (iter = session_list; iter != NULL; iter = g_list_next(iter)) {
+                       session = (void *)(iter->data);
+
+                       if (session != NULL) {
+                               _DEBUG_INFO("session : %d", session);
+                               err = func_point_cancel_message(session);
+
+                               if (err != 1) {
+                                       _DEBUG_ERROR("cancel message() is fail !!");
+                                       return -1;
+                               } else {
+                                       _DEBUG_INFO("cancel message() is success !!");
+                               }
+                       } else {
+                               _DEBUG_ERROR("session is NULL !!");
+                               return -1;
+                       }
+               }
+       } else {
+               _DEBUG_INFO("session_list is NULL !!");
+       }
+
+       err = na_remove_all_session_info();
+
+       if (err != 1) {
+               _DEBUG_ERROR("na_remove_all_session_info() is fail !!");
+               return -1;
+       } else {
+               _DEBUG_INFO("na_remove_all_session_info() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
diff --git a/src/framework/network-access/callbacks.h b/src/framework/network-access/callbacks.h
new file mode 100755 (executable)
index 0000000..3675b24
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CALLBACKS_H_
+#define CALLBACKS_H_
+
+/**
+ * @file callbacks.h
+ * @brief Provides callback operation for network data communication
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Set current network status (callback function used in slp-sysnoti-plugIn)
+ * @param[in] na_plugIn_id     NetworkAccess PlugIn ID , means protocol type
+ * @param[in] data user data
+ * @return     Operation result
+ * @retval     1       Successful
+ * @retval     0       Operation failed
+ */
+int na_handle_network_status(int na_plugIn_id, void *data);
+
+/**
+ * @brief Request cancel and disconnect connection about all network session (callback function used in slp-sysnoti-plugIn)
+ * @param[in] na_plugIn_id NetworkAccess PlugIn ID , means protocol type
+ * @param[in] data     user data
+ * @return     Operation result
+ * @retval     1       Successful
+ * @retval     0       Operation failed
+ */
+int na_handle_network_all_cancel(int na_plugIn_id, void *data);
+
+/**
+ *     @}
+ */
+
+#endif                         /* CALLBACKS_H_ */
diff --git a/src/framework/network-access/interface.c b/src/framework/network-access/interface.c
new file mode 100755 (executable)
index 0000000..504b5d6
--- /dev/null
@@ -0,0 +1,930 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib-object.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "utility/sync_util.h"
+#include "network-access/interface.h"
+#include "network-access/interface_internal.h"
+#include "network-access/external.h"
+#include "plugin/network_access_plugin.h"
+#include "fsapi/operation.h"
+
+#include "utility/fw_mainloop.h"
+#include "utility/fw_mainloop_internal.h"
+
+#include "network-access/network_status.h"
+
+#include "network-access/session_manager.h"
+
+#define NA_RETRY_CNT           3
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_NACI"
+#endif
+
+sync_agent_na_result_e na_init_network_access(int na_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       na_init_session_manager();
+       plugin_register_fw_mainloop_na_cb func_point_register_fw_mainloop_na = plugin_get_function_register_fw_mainloop_na(na_plugin_id);
+       if (func_point_register_fw_mainloop_na == NULL) {
+               _DEBUG_ERROR("cannot get pFunc !!");
+               res = SYNC_AGENT_NA_INIT_FAIL;
+       } else {
+               util_register_callback_to_main_loop(func_point_register_fw_mainloop_na, NULL);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_open_connection(int na_plugin_id, int timeout, unsigned int *session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+
+       int err = na_create_session_info(&session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_create_session_info() fail !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("na_create_session_info() success !!");
+       }
+
+       err = na_provide_session_id(session_id);
+       if (err != 1) {
+               _DEBUG_ERROR("na_provide_session_id() fail !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("na_provide_session_id() success !!");
+               _DEBUG_INFO("session id : %d", *session_id);
+       }
+
+       err = na_set_timeout(*session_id, timeout);
+       if (err != 1) {
+               _DEBUG_ERROR("na_set_timeout() fail !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("na_set_timeout() success !!");
+       }
+
+       if (plugin_use_network(na_plugin_id) == 1) {
+               /* use http plug-in */
+               switch (na_get_network_status()) {
+               case SYNC_AGENT_NA_NETWORK_UNKNOWN:
+               case SYNC_AGENT_NA_NETWORK_OFF:
+                       {
+                               _DEBUG_ERROR("network OFF !!");
+                               err = na_remove_session_info(*session_id);
+                               if (err != 1) {
+                                       _DEBUG_ERROR("na_remove_session_info() fail !!");
+                               } else {
+                                       _DEBUG_INFO("na_remove_session_info() success !!");
+                               }
+                               return SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+                       }
+                       break;
+               case SYNC_AGENT_NA_NETWORK_ON:
+                       {
+                               _DEBUG_INFO("network ON !!");
+                               /*FW_NETWORK_TYPE fw_net_type = get_network_type(); */
+                               sync_agent_na_network_connection_state_e conn_state = na_get_connection_state();
+                               /*if ((fw_net_type == NETWORK_NONE) || (fw_net_type == NETWORK_3G_OFF) || (fw_net_type == NETWORK_WIFI_OFF) || (fw_net_type == NETWORK_WIFI_ON_NOT_CONNECTED)) { */
+                               if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
+                                   (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE) ||
+                                   (SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED)) {
+                                       _DEBUG_ERROR("network ON but  not connected !!");
+                                       err = na_remove_session_info(*session_id);
+                                       if (err != 1) {
+                                               _DEBUG_ERROR("na_remove_session_info() fail !!");
+                                       } else {
+                                               _DEBUG_INFO("na_remove_session_info() success !!");
+                                       }
+                                       return SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+                               }
+                       }
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       plugin_open_connection_cb func_point_open_connection = plugin_get_function_connection(na_plugin_id);
+
+       if (func_point_open_connection == NULL) {
+               _DEBUG_ERROR("cannot get func_point_open_connection !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       }
+
+       err = func_point_open_connection(&session, na_get_proxy(), timeout);
+       if (err != 1) {
+               _DEBUG_ERROR("Open_Connection() fail !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("Open_Connection() success !!");
+       }
+
+       err = na_set_session(*session_id, session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_set_session() fail !!");
+               return SYNC_AGENT_NA_OPEN_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("na_set_session() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_close_connection(int na_plugin_id, unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+
+       _DEBUG_INFO("session id : %d", session_id);
+       int err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_INFO("get session() fail !!");
+               return SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("get session() success !!");
+       }
+
+       plugin_close_connection_cb func_point_close_connection = plugin_get_function_close_connection(na_plugin_id);
+
+       if (func_point_close_connection == NULL) {
+               _DEBUG_ERROR("cannot get func_point_close_connection !!");
+               return SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL;
+       }
+
+       err = func_point_close_connection(session);
+       if (err != 1) {
+               _DEBUG_ERROR("Close_Connection() fail !!");
+               return SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("Close_Connection() success !!");
+       }
+
+       err = na_remove_session_info(session_id);
+       if (err != 1) {
+               _DEBUG_ERROR("na_remove_session_info() fail !!");
+               return SYNC_AGENT_NA_CLOSE_CONNECTION_FAIL;
+       } else {
+               _DEBUG_INFO("na_remove_session_info() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_send_msg(GList * header_info, int na_plugin_id, char *send_msg, unsigned int send_msg_length, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length, sync_agent_na_send_type_e send_type,
+                                                     unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+       void *msg = NULL;
+       int try_again_cnt = 0;
+
+       /* check current network status */
+       if (plugin_use_network(na_plugin_id) == 1) {
+               res = sync_agent_check_network_status(0, 1);
+               if (res == SYNC_AGENT_NA_NETWORK_UNAVAILABLE) {
+                       _DEBUG_INFO("network is unavailable !!");
+//                      int err = na_remove_session_info(session_id, 0);
+//                      if (err != 1) {
+//                              _DEBUG_ERROR("na_remove_session_info() fail !!");
+//                      } else {
+//                              _DEBUG_INFO("na_remove_session_info() success !!");
+//                      }
+                       return res;
+               } else if (res == SYNC_AGENT_NA_NETWORK_CHANGING) {
+                       _DEBUG_INFO("network type is changing !!");
+                       _DEBUG_INFO("retry sync_agent_check_network_status() after 3 seconds !!");
+                       sleep(3);
+                       /* retry checking network status */
+                       res = sync_agent_check_network_status(0, 1);
+                       if (res == SYNC_AGENT_NA_NETWORK_UNAVAILABLE) {
+                               _DEBUG_INFO("network is unavailable !!");
+                               return res;
+                       } else {
+                               _DEBUG_INFO("network is available !!");
+                       }
+               } else {
+                       _DEBUG_INFO("network is available !!");
+               }
+       }
+
+       /*
+        *      Header Binding
+        */
+       plugin_header_binding_cb func_point_header_binding = plugin_get_function_header_binding(na_plugin_id);
+
+       if (func_point_header_binding == NULL) {
+               _DEBUG_ERROR("cannot get func_point_header_binding !!");
+               return SYNC_AGENT_NA_HEADER_BINDING_FAIL;
+       }
+
+       int err = na_get_msg(session_id, &msg);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_msg() fail !!");
+               return SYNC_AGENT_NA_HEADER_BINDING_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_msg() success !!");
+       }
+
+       unsigned int recv_msg_size = 0;
+
+       err = func_point_header_binding(header_info, &msg);
+       if (err != 1) {
+               _DEBUG_ERROR("Header_Binding() fail !!");
+               return SYNC_AGENT_NA_HEADER_BINDING_FAIL;
+       } else {
+               _DEBUG_INFO("Header_Binding() success !!");
+       }
+
+       /*
+        *      Send Message
+        */
+       err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_session() fail !!");
+               return SYNC_AGENT_NA_SEND_MSG_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_session() success !!");
+       }
+
+       if (send_type == SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE) {
+               plugin_send_message_cb func_point_send_message = plugin_get_function_send_message(na_plugin_id);
+
+               if (func_point_send_message == NULL) {
+                       _DEBUG_ERROR("cannot get func_point_send_message !!");
+                       return SYNC_AGENT_NA_SEND_MSG_FAIL;
+               }
+
+ send_message:
+               err = func_point_send_message(session, &msg, send_msg, send_msg_length, &recv_msg_size);
+               if (err != 1) {
+                       if (err == -408) {      /* FIXME : request time-out (temporary) */
+                               _DEBUG_ERROR("request time-out !!");
+                               return SYNC_AGENT_NA_TIME_OUT_SEND_MSG;
+                       } else if (err == -1) { /* FIXME : cancel message (temporary) */
+                               _DEBUG_INFO("send message canceled !!");
+                               return SYNC_AGENT_NA_SEND_MSG_CANCEL;
+                       } else if (err == -8) { /* try again - retry 3 times */
+                               _DEBUG_ERROR("send message try again ( %d ) !!", try_again_cnt);
+
+                               if (try_again_cnt < NA_RETRY_CNT) {
+                                       _DEBUG_INFO("re-make session !!");
+
+                                       try_again_cnt++;
+
+                                       session = NULL;
+
+#if 0
+                                       plugin_open_connection_cb func_point_open_connection = plugin_get_function_connection(na_plugin_id);
+                                       if (func_point_open_connection == NULL) {
+                                               _DEBUG_ERROR("cannot get func_point_open_connection !!");
+                                               return SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN;
+                                       }
+
+                                       int timeout = 0;
+                                       int er = na_get_timeout(session_id, &timeout);
+                                       if (er != 1) {
+                                               _DEBUG_ERROR("na_get_timeout() fail !!");
+                                               return SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN;
+                                       }
+
+                                       err = func_point_open_connection(&session, na_get_proxy(), timeout);
+                                       if (err != 1) {
+                                               _DEBUG_ERROR("Open_Connection() fail !!");
+                                               return SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN;
+                                       } else {
+                                               _DEBUG_INFO("Open_Connection() success !!");
+                                       }
+
+                                       err = na_set_session(session_id, session);
+                                       if (err != 1) {
+                                               _DEBUG_ERROR("na_set_session() fail !!");
+                                               return SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN;
+                                       } else {
+                                               _DEBUG_INFO("na_set_session() success !!");
+                                       }
+#endif
+                                       goto send_message;
+                               } else {
+                                       _DEBUG_ERROR("try again count over 3 times !!");
+                                       _DEBUG_ERROR("Send_Messasge() fail !!");
+
+                                       return SYNC_AGENT_NA_SEND_MSG_TRY_AGAIN;
+                               }
+                       } else if (err == -10) {        /* untrusted certificate */
+                               _DEBUG_INFO("untrusted certificate !!");
+                               return SYNC_AGENT_NA_UNTRUSTED_CERTIFICATE;
+                       } else {
+                               _DEBUG_ERROR("Send_Message() fail !! : %d", err);
+                               return SYNC_AGENT_NA_SEND_MSG_FAIL;
+                       }
+               } else {
+                       _DEBUG_INFO("Send_Message success !!");
+               }
+       } else if (send_type == SYNC_AGENT_NA_SEND_TYPE_JUST_SEND) {
+               plugin_just_send_message_cb func_point_just_send_message = plugin_get_function_just_send_message(na_plugin_id);
+
+               if (func_point_just_send_message == NULL) {
+                       _DEBUG_ERROR("cannot get func_point_just_send_message !!");
+                       return SYNC_AGENT_NA_JUST_SEND_MSG_FAIL;
+               }
+
+               err = func_point_just_send_message(session, &msg, send_msg, send_msg_length);
+               if (err != 1) {
+                       _DEBUG_ERROR("Just_Send_Message() fail !!");
+                       return SYNC_AGENT_NA_JUST_SEND_MSG_FAIL;
+               } else {
+                       _DEBUG_INFO("Just_Send_Message() success !!");
+                       _EXTERN_FUNC_EXIT;
+                       return res;
+               }
+       }
+
+       /*
+        *      Header Unbinding
+        */
+       plugin_header_unbinding_cb func_point_header_unbinding = plugin_get_function_header_unbinding(na_plugin_id);
+
+       if (func_point_header_unbinding == NULL) {
+               _DEBUG_ERROR("cannot get func_point_header_unbinding !!");
+               return SYNC_AGENT_NA_HEADER_UNBINDING_FAIL;
+       }
+
+       /*
+        *      extract header/body information using message from server
+        */
+       err = func_point_header_unbinding(msg, recv_msg_size, recv_header, recv_msg, recv_msg_length);
+       if (err != 1) {
+               _DEBUG_ERROR("Header_Unbinding() fail !!");
+               return SYNC_AGENT_NA_HEADER_UNBINDING_FAIL;
+       } else {
+               _DEBUG_INFO("Header_Unbinding() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_cancel_msg(int na_plugin_id, unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+
+       plugin_cancel_message_cb func_point_cancel_message = plugin_get_function_cancel_message(na_plugin_id);
+
+       if (func_point_cancel_message == NULL) {
+               _DEBUG_ERROR("cannot get func_point_cancel_message !!");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_NA_FAIL;
+       }
+
+       int err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_session() fail !!");
+               return SYNC_AGENT_NA_CANCEL_MSG_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_session() success !!");
+       }
+
+       _DEBUG_INFO("session id : %d", session_id);
+       err = func_point_cancel_message(session);
+       if (err != 1) {
+               _DEBUG_ERROR("Cancel_Message() fail !!");
+               return SYNC_AGENT_NA_CANCEL_MSG_FAIL;
+       } else {
+               _DEBUG_INFO("Cancel_Message() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_destroy_netowk_access()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       na_destroy_session_manager();
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_get_header_info(int na_plugin_id, GList * header_info, char *key, char **value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(header_info == NULL, SYNC_AGENT_NA_FAIL, "GList is NULL !!");
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       plugin_get_header_info_cb func_point_get_header_info = plugin_get_function_get_header_info(na_plugin_id);
+
+       if (func_point_get_header_info == NULL) {
+               _DEBUG_ERROR("cannot get func_point_get_header_info !!");
+               _EXTERN_FUNC_EXIT;
+               return SYNC_AGENT_NA_FAIL;
+       }
+
+       int err = func_point_get_header_info(header_info, key, value);
+       if (err != 1) {
+               _DEBUG_ERROR("Get_Header_Info() fail !!");
+               return SYNC_AGENT_NA_GET_HEADER_INFO_FAIL;
+       } else {
+               _DEBUG_INFO("Get_Header_Info() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_na_result_e na_free_recv_header_info(GList * header_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       if (header_info != NULL) {
+               GList *iter = NULL;
+               sync_agent_na_common_header_info_s *iter_data;
+
+               for (iter = header_info; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = ((sync_agent_na_common_header_info_s *) (iter->data));
+
+                       iter = g_list_next(iter);
+                       header_info = g_list_remove(header_info, iter_data);
+
+                       if (iter_data->key != NULL)
+                               free(iter_data->key);
+                       if (iter_data->value != NULL)
+                               free(iter_data->value);
+                       free(iter_data);
+               }
+
+               g_list_free(header_info);
+
+               _DEBUG_INFO("header_info is free !!");
+       } else {
+               _DEBUG_INFO("header_info is NULL !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_check_network_status(int interval, int retry_cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(interval < 0, SYNC_AGENT_NA_FAIL, "interval paramter is 0 !!!");
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       int i = 0;
+
+       for (; i < retry_cnt; i++) {
+               switch (na_get_network_status()) {
+               case SYNC_AGENT_NA_NETWORK_UNKNOWN:
+               case SYNC_AGENT_NA_NETWORK_OFF:
+                       {
+                               _DEBUG_ERROR("network OFF !!");
+                               res = SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+                       }
+                       break;
+               case SYNC_AGENT_NA_NETWORK_ON:
+                       {
+                               _DEBUG_INFO("[%s] network ON \n", __func__);
+                               /*FW_NETWORK_TYPE fw_net_type = get_network_type(); */
+                               sync_agent_na_network_connection_state_e conn_state = na_get_connection_state();
+                               /*if ((fw_net_type == NETWORK_NONE) || (fw_net_type == NETWORK_3G_OFF) || (fw_net_type == NETWORK_WIFI_OFF) || (fw_net_type == NETWORK_WIFI_ON_NOT_CONNECTED)) { */
+                               if ((SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED) ||
+                                   (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (conn_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE) ||
+                                   (SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED <= conn_state && conn_state <= SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED)) {
+                                       _DEBUG_ERROR("network ON but  not connected !!");
+                                       res = SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+                               } else {
+                                       res = SYNC_AGENT_NA_SUCCESS;
+                                       _EXTERN_FUNC_EXIT;
+                                       return res;
+                               }
+                       }
+                       break;
+               case SYNC_AGENT_NA_NETWORK_CHANGE:
+                       {
+                               _DEBUG_INFO("[%s] network CHANGE \n", __func__);
+                               res = SYNC_AGENT_NA_NETWORK_CHANGING;
+                               _EXTERN_FUNC_EXIT;
+                               return res;
+                       }
+                       break;
+               default:
+                       break;
+               }
+               sleep(interval);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_get_connection_type(int *conn_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(conn_type == NULL, SYNC_AGENT_NA_FAIL, "conn_type paramter is NULL !!!");
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       *conn_type = na_get_connection_type();
+       _DEBUG_INFO("current connection type : %d", *conn_type);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_get_connection_state(int *conn_state)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(conn_state == NULL, SYNC_AGENT_NA_FAIL, "conn_state paramter is NULL !!!");
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+
+       *conn_state = na_get_connection_state();
+       _DEBUG_INFO("current connection state : %d", *conn_state);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_na_result_e na_download_data(GList * header_info, int na_plugin_id, unsigned char *download_folder, unsigned int download_start_size, unsigned int download_body_size, unsigned char **out_download_path, sync_agent_na_send_type_e send_type,
+                                       unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(header_info == NULL, SYNC_AGENT_NA_FAIL, "GList is NULL !!");
+       retvm_if(download_folder == NULL, SYNC_AGENT_NA_FAIL, "download folder path is NULL !!");
+
+       GList *recv_header_info = 0;
+       /* char *recvMsg = 0; */
+       unsigned char *recvMsg = NULL;
+       unsigned int recvMsg_size = 0;
+
+       unsigned int download_current_size = download_start_size;
+       /* unsigned int download_total_size = 0; */
+       int download_total_size = 0;
+       char *current_download_range = NULL;
+       char *download_file_name = NULL;
+
+       GList *backup_send_head_info_list = NULL;
+       GList *iter = NULL;
+
+       int count = 0;          /* for test log */
+       sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+       while (download_total_size == 0 || download_current_size < download_total_size - 1) {
+
+               _DEBUG_INFO("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+               _DEBUG_INFO("############# %d th download", ++count);
+               _DEBUG_INFO("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+
+               /* back up the header list TODO */
+               /* GSList *backup_send_head_info_list = 0; */
+               backup_send_head_info_list = NULL;
+               iter = NULL;
+               for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+                       sync_agent_na_common_header_info_s *header_item_info = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+                       if (header_item_info == NULL) {
+                               _DEBUG_ERROR("calloc failed !!");
+                               ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                               goto return_part;
+                       }
+
+                       if (((sync_agent_na_common_header_info_s *) (iter->data))->key != NULL) {
+                               header_item_info->key = strdup(((sync_agent_na_common_header_info_s *) (iter->data))->key);
+
+                               if (((sync_agent_na_common_header_info_s *) (iter->data))->value != NULL) {
+                                       header_item_info->value = strdup(((sync_agent_na_common_header_info_s *) (iter->data))->value);
+                               } else {
+                                       _DEBUG_ERROR("key : %s, value is NULL !!", header_item_info->key);
+                                       header_item_info->value = NULL;
+                               }
+
+                               backup_send_head_info_list = g_list_append(backup_send_head_info_list, header_item_info);
+                       } else {
+                               _DEBUG_ERROR("key is NULL !!");
+                               header_item_info->key = NULL;
+                               header_item_info->value = NULL;
+                       }
+
+                       /*backup_send_head_info_list = g_list_append(backup_send_head_info_list, header_item_info); */
+                       if (header_item_info->key != NULL) {
+                               if (strcmp(header_item_info->key, "Range") == 0)
+                                       _DEBUG_INFO("[Before] key : %s, value : %s", header_item_info->key, header_item_info->value);
+                       }
+               }
+
+               /* send_msg */
+               ret = sync_agent_send_msg(backup_send_head_info_list, na_plugin_id, 0, 0, &recv_header_info, &recvMsg, &recvMsg_size, send_type, session_id);
+               if (ret != SYNC_AGENT_NA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_send_msg() fail");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("RecvMSg_Size = %d", recvMsg_size);
+               _DEBUG_INFO("############# sync_agent_send_msg() success !!");
+
+               /* get download total size, download current range */
+               plugin_get_data_download_info_cb func_point_get_data_down_info = plugin_get_function_get_data_download_info(na_plugin_id);
+               if (func_point_get_data_down_info == NULL) {
+                       _DEBUG_ERROR("cannot get func_point_get_data_down_info !!");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               ret = func_point_get_data_down_info(header_info, recv_header_info, &download_total_size, &current_download_range, &download_file_name);
+               if (ret != SYNC_AGENT_NA_SUCCESS) {
+                       _DEBUG_ERROR("Get_Data_Down_Info() fail !!");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("############# Get_Data_Down_Info() success !!");
+               if (current_download_range == NULL || download_total_size == 0 || download_file_name == NULL) {
+                       _DEBUG_ERROR("current_download_range == NULL || download_total_size == 0 || download_file_name == NULL");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("download_total_size = %d", download_total_size);
+               _DEBUG_INFO("current_download_range = %s", current_download_range);
+               _DEBUG_INFO("download_file_name = %s", download_file_name);
+
+               /* download path setting */
+               if (*out_download_path == NULL) {
+                       *out_download_path = (unsigned char *)g_strdup_printf("%s/%s", download_folder, download_file_name);
+                       _DEBUG_INFO("*out_download_path = %s", *out_download_path);
+               }
+
+               /* increment download count */
+               char *del = "-";
+               /* int down_size = 0; */
+               char *ptr = strtok(current_download_range, del);
+               if (ptr != NULL) {
+
+                       int start_size = 0;
+                       int end_size = 0;
+
+                       _DEBUG_INFO("start_size = %s", ptr);
+                       start_size = atoi(ptr);
+
+                       ptr = strtok(NULL, del);
+                       _DEBUG_INFO("end_size = %s", ptr);
+                       end_size = atoi(ptr);
+
+                       _DEBUG_INFO("prev download_current_size = %d", download_current_size);
+                       _DEBUG_INFO("Gap = %d", end_size - start_size);
+
+                       download_current_size += (end_size - start_size + 1);
+                       _DEBUG_INFO("after download_current_size = %d", download_current_size);
+               }
+
+               bool isFinal = false;
+               if (download_current_size >= download_total_size - 1)
+                       isFinal = true;
+
+               /* set file */
+               _DEBUG_INFO("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RecvMSg_Size = %d", recvMsg_size);
+               ret = sync_agent_append_file((char *)(*out_download_path), (char *)recvMsg, recvMsg_size, false);
+               if (ret != SYNC_AGENT_NA_SUCCESS) {
+                       _DEBUG_ERROR("sync_agent_write_file() fail !!");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               } else {
+                       _DEBUG_INFO("############# sync_agent_write_file() success !!");
+               }
+
+               /* set download total size, download current range */
+               plugin_set_data_download_info_cb func_point_set_data_down_info = plugin_get_function_set_data_download_info(na_plugin_id);
+               if (func_point_set_data_down_info == NULL) {
+                       _DEBUG_ERROR("cannot get func_point_set_data_down_info !!");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               char *new_download_range = g_strdup_printf("%d-%d", download_current_size, download_current_size + (download_body_size - 1));
+               ret = func_point_set_data_down_info(header_info, new_download_range);
+               if (ret != SYNC_AGENT_NA_SUCCESS) {
+                       _DEBUG_ERROR("Set_Data_Down_Info() fail !!");
+                       ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+                       goto return_part;
+               }
+
+               _DEBUG_INFO("############# Set_Data_Down_Info() success !!");
+
+       }
+
+ return_part:
+
+       if (backup_send_head_info_list != NULL) {
+               sync_agent_na_result_e result = na_free_recv_header_info(backup_send_head_info_list);
+               if (result != SYNC_AGENT_NA_SUCCESS)
+                       _DEBUG_ERROR("na_free_recv_header_info() fail !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_add_authentication_info(int na_plugin_id, char *id, char *password, unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id == NULL, SYNC_AGENT_NA_FAIL, "id is NULL !!");
+       retvm_if(password == NULL, SYNC_AGENT_NA_FAIL, "password is NULL !!");
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+
+       plugin_add_authentication_info_cb func_point_add_authentication_info = plugin_get_function_add_authentication_info(na_plugin_id);
+
+       if (func_point_add_authentication_info == NULL) {
+               _DEBUG_ERROR("cannot get func_point_add_authentication_info !!");
+               return SYNC_AGENT_NA_ADD_AUTH_INFO_FAIL;
+       }
+
+       int err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_session() fail !!");
+               return SYNC_AGENT_NA_ADD_AUTH_INFO_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_session() success !!");
+       }
+
+       _DEBUG_INFO("session id : %d", session_id);
+
+       err = func_point_add_authentication_info(session, id, password);
+       if (err != 1) {
+               _DEBUG_ERROR("Add_Authentication_Info() fail !!");
+               return SYNC_AGENT_NA_ADD_AUTH_INFO_FAIL;
+       } else {
+               _DEBUG_INFO("Add_Authentication_Info() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_na_result_e na_set_property(int na_plugin_id, unsigned int session_id, sync_agent_na_property_e property, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+       va_list va;
+
+       plugin_set_property_cb func_point_set_property = plugin_get_function_set_property(na_plugin_id);
+
+       if (func_point_set_property == NULL) {
+               _DEBUG_ERROR("cannot get SetProperty !!");
+               return SYNC_AGENT_NA_FAIL;
+       }
+
+       int err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_session() fail !!");
+               return SYNC_AGENT_NA_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_session() success !!");
+       }
+
+       _DEBUG_INFO("session id : %d", session_id);
+
+       va_start(va, property);
+       err = func_point_set_property(session, property, va);
+       if (err != 1) {
+               _DEBUG_ERROR("SetProperty() fail !!");
+               va_end(va);
+               return SYNC_AGENT_NA_FAIL;
+       } else {
+               _DEBUG_INFO("SetProperty() success !!");
+       }
+       va_end(va);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_na_result_e sync_agent_get_status(int na_plugin_id, unsigned int session_id, sync_agent_na_status_e status, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+       void *session = NULL;
+       va_list va;
+
+       plugin_get_status_cb func_point_get_status = plugin_get_function_get_status(na_plugin_id);
+
+       if (func_point_get_status == NULL) {
+               _DEBUG_ERROR("cannot get func_point_get_status !!");
+               return SYNC_AGENT_NA_FAIL;
+       }
+
+       int err = na_get_session(session_id, &session);
+       if (err != 1) {
+               _DEBUG_ERROR("na_get_session() fail !!");
+               return SYNC_AGENT_NA_FAIL;
+       } else {
+               _DEBUG_INFO("na_get_session() success !!");
+       }
+
+       _DEBUG_INFO("session id : %d", session_id);
+
+       va_start(va, status);
+       err = func_point_get_status(session, status, va);
+       if (err != 1) {
+               _DEBUG_ERROR("GetStatus() fail !!");
+               va_end(va);
+               return SYNC_AGENT_NA_FAIL;
+       } else {
+               _DEBUG_INFO("GetStatus() success !!");
+       }
+       va_end(va);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API void sync_agent_free_na_common_header_info(sync_agent_na_common_header_info_s * header_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (header_info == NULL)
+               return;
+
+       if (header_info->key != NULL) {
+               free(header_info->key);
+       }
+       if (header_info->value != NULL) {
+               free(header_info->value);
+       }
+
+       free(header_info);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/network-access/interface_internal.h b/src/framework/network-access/interface_internal.h
new file mode 100755 (executable)
index 0000000..cb7637a
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_INTERFACE_INTERNAL_H_
+#define NETWORK_ACCESS_INTERFACE_INTERNAL_H_
+
+#include "network-access/interface.h"
+
+/**
+ * @file interface.h
+ * @brief Provides network data communication operation
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Initialize NACI
+ * @remarks Run only once at the beginning of the process
+ * @param[in] na_plugin_id     NetworkAccess PlugIn ID, means protocol type
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_FAIL Operation failed
+ */
+sync_agent_na_result_e na_init_network_access(int na_plugin_id);
+
+/**
+ * @brief Memory free for the header information received from the server
+ * @param[in] header_info Header information received from the server
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_FAIL Operation failed
+ * @pre The application should be called sync_agent_get_header_info() and returned SYNC_AGENT_NA_SUCCESS
+ */
+sync_agent_na_result_e na_free_recv_header_info(GList * header_info);
+
+/**
+ * @brief Download data from server
+ * @param[in] header_info Header information that depending on the protocol type
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] download_folder Folder path for download
+ * @param[in] download_start_size Download start size
+ * @param[in] download_body_size Download message size
+ * @param[out] out_download_path File path to download
+ * @param[in] send_type Type of send message
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval SYNC_AGENT_NA_SUCCESS Successful
+ * @retval SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL Operation failed
+ */
+sync_agent_na_result_e na_download_data(GList * header_info, int na_plugin_id, unsigned char *download_folder, unsigned int download_start_size, unsigned int download_body_size, unsigned char **out_download_path, sync_agent_na_send_type_e send_type,
+                                       unsigned int session_id);
+
+/**
+ * @brief              set property of Network Plugin
+ * @param[in] na_plugin_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] session_id Session id
+ * @param[in] property sync_agent_na_property_e
+ * @param[in] ...      timeout
+ * @return             operation result
+ * @retval             SYNC_AGENT_NA_SUCCESS                                                                   success
+ * @retval             SYNC_AGENT_NA_FAIL                                                                              fail
+ */
+sync_agent_na_result_e na_set_property(int na_plugin_id, unsigned int session_id, sync_agent_na_property_e property, ...);
+
+/**
+ *     @}
+ */
+
+#endif                         /* NETWORK_ACCESS_INTERFACE_INTERNAL_H_ */
diff --git a/src/framework/network-access/session_manager.c b/src/framework/network-access/session_manager.c
new file mode 100755 (executable)
index 0000000..39c5b55
--- /dev/null
@@ -0,0 +1,1034 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include "network-access/session_manager.h"
+
+#include "utility/fw_sequential_id_provider.h"
+#include "utility/sync_util.h"
+
+#include "plugin/network_access_plugin.h"
+
+#define NA_MAX_ID_CNT          1000
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_NA_SM"
+#endif
+
+static na_session_manager_s session_manager;
+static util_id_provider_s *pid_provider;
+
+static int _remove_all_session(int na_plugIn_id);
+static int _create_all_session(int na_plugIn_id);
+static void _set_ip_n_proxy(char *ip, char *proxy);
+static int _change_all_session_info(int na_plugIn_id);
+
+void na_init_session_manager(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       session_manager.session_info_list = NULL;
+       session_manager.ip = NULL;
+       session_manager.proxy = NULL;
+       session_manager.fw_network_status = SYNC_AGENT_NA_NETWORK_UNKNOWN;
+//      session_manager.fw_network_type = NETWORK_NONE;
+       session_manager.fw_connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN;
+       session_manager.fw_connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+
+       pid_provider = util_create_id_provider(NA_MAX_ID_CNT, 12, true);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void na_destroy_session_manager(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+/*
+if (session_manager.session_info_list != NULL) {
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       for (iter = session_manager.session_info_list; iter != NULL;) {
+               iter_data = NULL;
+               iter_data = ((na_session_info_s*)(iter->data));
+               iter = g_list_next(iter);
+               session_manager.session_info_list = g_list_remove(session_manager.session_info_list, iter_data);
+
+               if (iter_data != NULL) {
+                       if (((na_session_info_s*)iter_data)->session != NULL)
+                               free(((na_session_info_s*)iter_data)->session);
+                       if (((na_session_info_s*)iter_data)->msg != NULL)
+                               free(((na_session_info_s*)iter_data)->msg);
+
+                       free((na_session_info_s*)iter_data);
+               }
+       }
+
+       g_list_free(session_manager.session_info_list);
+       session_manager.session_info_list = NULL;
+}
+
+_DEBUG_INFO("clear session_info_list !!");
+*/
+
+       int err = na_remove_all_session_info();
+       if (err != 1) {
+               _DEBUG_ERROR("na_remove_all_session_info() fail !!");
+               /* todo : exception handling */
+       } else {
+               _DEBUG_INFO("na_remove_all_session_info() success !!");
+       }
+
+       if (session_manager.ip != NULL) {
+               free(session_manager.ip);
+               session_manager.ip = NULL;
+       }
+       _DEBUG_INFO("free ip address !!");
+
+       if (session_manager.proxy != NULL) {
+               free(session_manager.proxy);
+               session_manager.proxy = NULL;
+       }
+       _DEBUG_INFO("free proxy !!");
+
+       session_manager.fw_network_status = SYNC_AGENT_NA_NETWORK_UNKNOWN;
+//      session_manager.fw_network_type = NETWORK_NONE;
+       session_manager.fw_connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN;
+       session_manager.fw_connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+       _DEBUG_INFO("clear network info !!");
+
+       util_destroy_id_provider(pid_provider);
+       pid_provider = NULL;
+       _DEBUG_INFO("id_provider_destroy() success !!");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+int na_create_session_info(void **session)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+       na_session_info_s *session_info;
+
+       /* memory alloc - session_info  */
+       session_info = (na_session_info_s *) calloc(1, sizeof(na_session_info_s));
+       if (session_info == NULL) {
+               _DEBUG_ERROR("session_info calloc fail !!");
+               return -1;
+       }
+       _DEBUG_INFO("session_info calloc success !!");
+
+       session_info->msg = NULL;
+       session_info->id = NULL;
+       session_info->password = NULL;
+
+       session_info->session = NULL;
+       *session = session_info->session;
+
+       /* append session_info to session_info_list */
+       session_manager.session_info_list = g_list_append(session_manager.session_info_list, session_info);
+       _DEBUG_INFO("append session_info");
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_provide_session_id(unsigned int *session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       int res = 1;
+
+       /* check session validation */
+       /* if (session == NULL) {
+          _DEBUG_ERROR("session is NULL !!");
+
+          na_session_info_s *session_info = (na_session_info_s*)(g_list_last(session_manager.session_info_list));
+          session_manager.session_info_list = g_list_remove(session_manager.session_info_list, session_info);
+          if (session_info != NULL) {
+          free((na_session_info_s*)(session_info));
+          }
+          _DEBUG_INFO("remove & free last session_info !!");
+
+          return -1;
+          } */
+
+       /* generate session id */
+       id_error = util_provide_id(pid_provider, session_id);
+       if (id_error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID) {
+               _DEBUG_ERROR("provided session id is full !!");
+               /* todo : reset NA_MAX_ID_CNT & re-generate */
+               return -1;
+       }
+       _DEBUG_INFO("session id : %d", *session_id);
+
+       /* add session & session_id to session_info */
+       ((na_session_info_s *) ((g_list_last(session_manager.session_info_list))->data))->session_id = *session_id;
+       _DEBUG_INFO("add session_id success !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_get_session(unsigned int session_id, void **session)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               *session = ((na_session_info_s *) iter_data)->session;
+
+               _DEBUG_INFO("na_get_session() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_set_session(unsigned int session_id, void *session)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               /* iter_data->session = (void*)calloc(1, sizeof(iter_data->session));
+                  if( iter_data->session == NULL ) {
+                  _DEBUG_ERROR("CALLOC failed !!!");
+                  res = -1;
+                  return res;
+                  }
+                  memcpy(iter_data->session, session, sizeof(iter_data->session)); */
+
+               iter_data->session = session;
+
+               _DEBUG_INFO("iter_data->session : %d", iter_data->session);
+               /* *session = ((na_session_info_s*)iter_data)->session; */
+
+               _DEBUG_INFO("na_set_session() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+sync_agent_na_network_status_e na_get_network_status(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return session_manager.fw_network_status;
+}
+
+int na_set_network_status(sync_agent_na_network_status_e network_status)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+       session_manager.fw_network_status = network_status;
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+//FW_NETWORK_TYPE get_network_type()
+//{
+//      return session_manager.fw_network_type;
+//}
+sync_agent_na_network_connection_state_e na_get_connection_state(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return session_manager.fw_connection_state;
+}
+
+sync_agent_na_network_connection_type_e na_get_connection_type(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return session_manager.fw_connection_type;
+}
+
+char *na_get_proxy(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return session_manager.proxy;
+}
+
+int na_get_msg(unsigned int session_id, void **msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               *msg = ((na_session_info_s *) iter_data)->msg;
+
+               _DEBUG_INFO("na_get_msg() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_get_timeout(unsigned int session_id, int *timeout)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               *timeout = ((na_session_info_s *) iter_data)->timeout;
+               _DEBUG_INFO("timeout : %d", *timeout);
+
+               _DEBUG_INFO("na_get_timeout() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_set_timeout(unsigned int session_id, int timeout)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               ((na_session_info_s *) iter_data)->timeout = timeout;
+               _DEBUG_INFO("timeout : %d", ((na_session_info_s *) iter_data)->timeout);
+
+               _DEBUG_INFO("na_set_timeout() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_get_id_n_password(unsigned int session_id, char **id, char **password)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       if (iter_data != NULL) {
+               *id = ((na_session_info_s *) iter_data)->id;
+               _DEBUG_INFO("id : %s", *id);
+
+               *password = ((na_session_info_s *) iter_data)->password;
+               _DEBUG_INFO("password : %s", *password);
+
+               _DEBUG_INFO("na_get_id_n_password() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_set_id_n_password(unsigned int session_id, char *id, char *password)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       /* na_session_info_s *iter_data; */
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               /* iter_data = NULL; */
+               if (iter->data != NULL) {
+                       if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                               if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                                       _DEBUG_INFO("find session_id : %d", session_id);
+
+                                       if ((iter->data) != NULL) {
+                                               ((na_session_info_s *) (iter->data))->id = strdup(id);
+                                               _DEBUG_INFO("id : %s", ((na_session_info_s *) (iter->data))->id);
+                                               ((na_session_info_s *) (iter->data))->password = strdup(password);
+                                               _DEBUG_INFO("password : %s", ((na_session_info_s *) (iter->data))->password);
+
+                                               _DEBUG_INFO("na_set_id_n_password() is success !!");
+                                       } else {
+                                               _DEBUG_ERROR("iter_data is NULL !!");
+                                               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+                                               res = -1;
+                                       }
+                                       break;
+                               }
+                       } else {
+                               _DEBUG_ERROR("invalid session_id : -1 !!");
+                               /*res = -1; */
+                               return -1;
+                               /* todo : exception handling */
+                       }
+               } else {
+                       _DEBUG_ERROR("iter->data is NULL !!");
+                       /*res = -1; */
+                       return -1;
+                       /* todo : exception handling */
+               }
+       }
+
+/* if (iter_data != NULL) {
+               ((na_session_info_s *) iter_data)->id = strdup(id);
+               _DEBUG_INFO("id : %s", ((na_session_info_s *) iter_data)->id);
+
+               ((na_session_info_s *) iter_data)->password = strdup(password);
+               _DEBUG_INFO("password : %s", ((na_session_info_s *) iter_data)->password);
+
+               _DEBUG_INFO("na_set_id_n_password() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+                todo : exception handling
+       } */
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_get_all_session(GList ** session_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       if (session_manager.session_info_list != NULL) {
+               GList *iter = NULL;
+               na_session_info_s *iter_data;
+
+               for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+                       iter_data = NULL;
+                       iter_data = ((na_session_info_s *) (iter->data));
+
+                       if (iter_data != NULL) {
+                               _DEBUG_INFO("session : %d", iter_data->session);
+                               *session_list = g_list_append(*session_list, (void *)(iter_data->session));
+                       } else {
+                               _DEBUG_ERROR("iter_data is NULL !!");
+                               return -1;
+                               /* todo : exception handling */
+                       }
+               }
+       } else {
+               _DEBUG_INFO("session_info_list is NULL !!");
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_remove_session_info(unsigned int session_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       na_session_info_s *iter_data;
+
+       /* find same session_id in session_info_list */
+       for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               if (((na_session_info_s *) (iter->data))->session_id != -1) {
+                       if (((na_session_info_s *) (iter->data))->session_id == session_id) {
+                               iter_data = (na_session_info_s *) (iter->data);
+                               _DEBUG_INFO("find session_id : %d", session_id);
+                               break;
+                       }
+               } else {
+                       _DEBUG_ERROR("invalid session_id : -1 !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+       }
+
+       /* remove session_info */
+       if (iter_data != NULL) {
+               session_manager.session_info_list = g_list_remove(session_manager.session_info_list, iter_data);
+
+//              if (((na_session_info_s *) (iter_data))->session != NULL)
+//                      free(((na_session_info_s *) iter_data)->session);
+
+               if (((na_session_info_s *) iter_data)->msg != NULL)
+                       free(((na_session_info_s *) iter_data)->msg);
+
+               if (((na_session_info_s *) iter_data)->id != NULL)
+                       free(((na_session_info_s *) iter_data)->id);
+
+               if (((na_session_info_s *) iter_data)->password != NULL)
+                       free(((na_session_info_s *) iter_data)->password);
+
+               int err = util_delete_id(pid_provider, session_id);
+               if (err != UTIL_ID_PROVIDER_OK) {
+                       _DEBUG_ERROR("id_provider_delete_id() is fail !!");
+                       res = -1;
+                       /* todo : exception handling */
+               }
+
+               free((na_session_info_s *) iter_data);
+
+               _DEBUG_INFO("na_remove_session_info() is success !!");
+       } else {
+               _DEBUG_ERROR("iter_data is NULL !!");
+               _DEBUG_ERROR("not exist session_id ( %d ) in session_info_list !!", session_id);
+               res = -1;
+               /* todo : exception handling */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_remove_all_session_info(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       if (session_manager.session_info_list != NULL) {
+               GList *iter = NULL;
+               na_session_info_s *iter_data;
+
+               for (iter = session_manager.session_info_list; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = ((na_session_info_s *) (iter->data));
+                       iter = g_list_next(iter);
+                       session_manager.session_info_list = g_list_remove(session_manager.session_info_list, iter_data);
+
+                       if (iter_data != NULL) {
+
+//                              if (((na_session_info_s *) iter_data)->session != NULL)
+//                                      free(((na_session_info_s *) iter_data)->session);
+
+                               if (((na_session_info_s *) iter_data)->msg != NULL)
+                                       free(((na_session_info_s *) iter_data)->msg);
+
+                               if (((na_session_info_s *) iter_data)->id != NULL)
+                                       free(((na_session_info_s *) iter_data)->id);
+
+                               if (((na_session_info_s *) iter_data)->password != NULL)
+                                       free(((na_session_info_s *) iter_data)->password);
+
+                               int err = util_delete_id(pid_provider, ((na_session_info_s *) iter_data)->session_id);
+                               if (err != UTIL_ID_PROVIDER_OK) {
+                                       _DEBUG_ERROR("id_provider_delete_id() is fail !!");
+                                       res = -1;
+                                       /* todo : exception handling */
+                               }
+
+                               ((na_session_info_s *) iter_data)->timeout = 0;
+
+                               free((na_session_info_s *) iter_data);
+                       }
+               }
+
+               g_list_free(session_manager.session_info_list);
+               session_manager.session_info_list = NULL;
+       } else {
+               _DEBUG_INFO("session_info_list is NULL !!");
+               /* todo : exception handling */
+       }
+       _DEBUG_INFO("clear session_info_list !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+int na_set_network_info(int na_plugIn_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       if (data == NULL) {
+               _DEBUG_ERROR("data is NULL !!");
+               return -1;
+       }
+
+       na_pmci_network_connection_s *net_con = (na_pmci_network_connection_s *) data;
+       _DEBUG_INFO("network status : %d", net_con->fw_network_status);
+       _DEBUG_INFO("connection type : %d", net_con->fw_connection_type);
+       _DEBUG_INFO("connection state : %d", net_con->fw_connection_state);
+       _DEBUG_INFO("ip : %s", net_con->ip);
+       _DEBUG_INFO("proxy : %s", net_con->proxy);
+
+       /* set network status */
+       session_manager.fw_network_status = net_con->fw_network_status;
+
+       /* set connection type */
+       session_manager.fw_connection_type = net_con->fw_connection_type;
+
+       /* set connection state */
+       session_manager.fw_connection_state = net_con->fw_connection_state;
+
+       /* session_info_list == NULL : first case */
+       if (session_manager.session_info_list == NULL) {        /* or g_list_length(session_manager.session_info_list) == 0     */
+               /* set ip & proxy */
+               _set_ip_n_proxy(net_con->ip, net_con->proxy);
+       } else {
+               /* comparison existing ip & proxy data */
+//              if ((net_status == SYNC_AGENT_NA_NETWORK_ON) && ((net_type == NETWORK_3G_ON) || (net_type == NETWORK_WIFI_ON) || (net_type == NETWORK_WIFI_3G_ON))) {
+               if ((net_con->fw_network_status == SYNC_AGENT_NA_NETWORK_ON) &&
+                   ((net_con->fw_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI) ||
+                    (net_con->fw_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR) || (net_con->fw_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET))) {
+                       /* ip */
+//                      if ((session_manager.ip != NULL) && (ip != NULL)) {
+//                              if (!strcmp(session_manager.ip, ip)) {
+//                                      _DEBUG_INFO("same ip : do nothing !!");
+//                              } else {
+//                                      _DEBUG_INFO("different ip : change all session !!");
+//
+//                                      /* set ip & proxy */
+//                                      _set_ip_n_proxy(ip, proxy);
+//
+//                                      /* change all session info */
+//                                      int err = _change_all_session_info(na_plugIn_id);
+//                                      if (err != 1) {
+//                                              _DEBUG_ERROR("_change_all_session_info() is fail !!");
+//                                              return -1;
+//                                              /* todo : exception handling */
+//                                      } else {
+//                                              _DEBUG_INFO("_change_all_session_info() is success !!");
+//                                      }
+//                              }
+//                      } else if (((session_manager.ip == NULL) && (ip != NULL)) || ((session_manager.ip != NULL) && (ip == NULL))) {
+//                              _DEBUG_INFO("different ip : change all session !!");
+//
+//                              /* set ip & proxy */
+//                              _set_ip_n_proxy(ip, proxy);
+//
+//                              /* change all session info */
+//                              int err = _change_all_session_info(na_plugIn_id);
+//                              if (err != 1) {
+//                                      _DEBUG_ERROR("_change_all_session_info() is fail !!");
+//                                      return -1;
+//                                      /* todo : exception handling */
+//                              } else {
+//                                      _DEBUG_INFO("_change_all_session_info() is success !!");
+//                              }
+//                      } else {        /* if ((session_manager.ip == NULL) && (ip == NULL)) { */
+//                              _DEBUG_INFO("same ip : do nothing !!");
+//                      }
+
+                       /* proxy */
+                       if ((session_manager.proxy != NULL) && (net_con->proxy != NULL)) {
+                               if (!strcmp(session_manager.proxy, net_con->proxy)) {
+                                       _DEBUG_INFO("same proxy : do nothing !!");
+                               } else {
+                                       _DEBUG_INFO("different proxy : change all session !!");
+
+                                       /* set ip & proxy */
+                                       _set_ip_n_proxy(net_con->ip, net_con->proxy);
+
+                                       /* change all session info */
+                                       int err = _change_all_session_info(na_plugIn_id);
+                                       if (err != 1) {
+                                               _DEBUG_ERROR("_change_all_session_info() failed !!");
+                                               return -1;
+                                               /* todo : exception handling */
+                                       } else {
+                                               _DEBUG_INFO("_change_all_session_info() success !!");
+                                       }
+                               }
+                       } else if (((session_manager.proxy == NULL) && (net_con->proxy != NULL)) || ((session_manager.proxy != NULL) && (net_con->proxy == NULL))) {
+                               _DEBUG_INFO("different ip : change all session !!");
+
+                               /* set ip & proxy */
+                               _set_ip_n_proxy(net_con->ip, net_con->proxy);
+
+                               /* change all session info */
+                               int err = _change_all_session_info(na_plugIn_id);
+                               if (err != 1) {
+                                       _DEBUG_ERROR("_change_all_session_info() failed !!");
+                                       return -1;
+                                       /* todo : exception handling */
+                               } else {
+                                       _DEBUG_INFO("_change_all_session_info() success !!");
+                               }
+                       } else {        /* if ((session_manager.proxy == NULL) && (proxy == NULL)) { */
+                               _DEBUG_INFO("same proxy : do nothing !!");
+                       }
+               } else {
+                       /* set ip & proxy */
+                       _set_ip_n_proxy(net_con->ip, net_con->proxy);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+static int _remove_all_session(int na_plugIn_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+
+       plugin_cancel_message_cb func_point_cancel_message = plugin_get_function_cancel_message(na_plugIn_id);
+
+       if (func_point_cancel_message == NULL) {
+               _DEBUG_ERROR("cannot get pFunc !!");
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+
+       if (session_manager.session_info_list != NULL) {
+               GList *iter = NULL;
+               na_session_info_s *iter_data;
+               int err = 0;
+
+               for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+                       iter_data = NULL;
+                       iter_data = ((na_session_info_s *) (iter->data));
+
+                       if (iter_data != NULL) {
+                               err = func_point_cancel_message(((na_session_info_s *) iter_data)->session);
+                               if (err != 1) {
+                                       _DEBUG_ERROR("cancel message fail !!");
+                                       return -1;
+                                       /* todo : exception handling */
+                               } else {
+                                       _DEBUG_TRACE("cancel message success !!");
+                               }
+                               iter_data->session = NULL;
+
+                               if (((na_session_info_s *) iter_data)->msg != NULL) {
+                                       free(((na_session_info_s *) iter_data)->msg);
+                                       iter_data->msg = NULL;
+                               }
+                       } else {
+                               _DEBUG_ERROR("iter_data is NULL !!");
+                               return -1;
+                               /* todo : exception handling */
+                       }
+               }
+       } else {
+               _DEBUG_ERROR("session_info_list is NULL !!");
+               return -1;
+               /* todo : exception handling */
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static int _create_all_session(int na_plugIn_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       /* int connection_type = 0; *//* for mobex */
+       _DEBUG_TRACE("protocol_type : %d", na_plugIn_id);
+
+       plugin_open_connection_cb func_point_open_connection = plugin_get_function_connection(na_plugIn_id);
+
+       if (func_point_open_connection == NULL) {
+               _DEBUG_ERROR("[%s] cannot get pFunc !!\n", __func__);
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+
+       if (session_manager.session_info_list != NULL) {
+               GList *iter = NULL;
+               na_session_info_s *iter_data;
+               int err = 0;
+
+               for (iter = session_manager.session_info_list; iter != NULL; iter = g_list_next(iter)) {
+                       iter_data = NULL;
+                       iter_data = ((na_session_info_s *) (iter->data));
+
+                       if (iter_data != NULL) {
+                               err = func_point_open_connection(&iter_data->session, session_manager.proxy, iter_data->timeout);
+                               if (err != 1) {
+                                       _DEBUG_ERROR("open connection fail !!");
+                                       return -1;
+                                       /* todo : exception handling */
+                               } else {
+                                       _DEBUG_TRACE("open connection success !!");
+                               }
+                       } else {
+                               _DEBUG_ERROR("iter_data is NULL !!");
+                               return -1;
+                               /* todo : exception handling */
+                       }
+               }
+       } else {
+               _DEBUG_ERROR("session_info_list is NULL !!");
+               return -1;
+               /* todo : exception handling */
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static void _set_ip_n_proxy(char *ip, char *proxy)
+{
+       _INNER_FUNC_ENTER;
+
+       /*
+        *      check & set proxy info
+        */
+//      if ((proxy != NULL) && (strcmp(proxy, "") != 0) && (strstr(proxy, "0.0.0.0") == NULL)) {
+       if ((proxy != NULL) && (strcmp(proxy, "") != 0)) {
+               _DEBUG_TRACE("The proxy host is ( %s )", proxy);
+
+               if ((strlen(proxy) < 5) || (proxy[0] == ':')) {
+                       _DEBUG_TRACE("invalid proxy value !!");
+                       session_manager.proxy = NULL;
+                       _DEBUG_TRACE("session_manager.proxy : %s", session_manager.proxy);
+               } else {
+                       if ((strstr(proxy, "http://") != NULL) || (strstr(proxy, "https://") != NULL)) {
+                               _DEBUG_TRACE("proxy value is complete format !!");
+                               session_manager.proxy = strdup(proxy);
+                               _DEBUG_TRACE("session_manager.proxy : %s", session_manager.proxy);
+                       } else {
+                               _DEBUG_TRACE("proxy value is incomplete format !!");
+                               char FullProxyAddr[100] = { 0, };
+                               snprintf(FullProxyAddr, sizeof(FullProxyAddr), "http://%s", proxy);
+                               _DEBUG_TRACE("fullproxyaddr : %s ( %d )", FullProxyAddr, strlen(FullProxyAddr));
+
+                               session_manager.proxy = strdup(FullProxyAddr);
+                               _DEBUG_TRACE("session_manager.proxy : %s", session_manager.proxy);
+                       }
+               }
+       } else {
+               _DEBUG_TRACE("proxy is NULL !!");
+               session_manager.proxy = NULL;
+               _DEBUG_TRACE("session_manager.proxy : %s", session_manager.proxy);
+       }
+
+       /*
+        *      set ip info
+        */
+       if (ip != NULL) {
+               session_manager.ip = strdup(ip);
+               _DEBUG_TRACE("session_manager.ip : %s", session_manager.ip);
+//              free(ip);
+       } else {
+               session_manager.ip = NULL;
+               _DEBUG_TRACE("ip is NULL !!");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _change_all_session_info(int na_plugIn_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+
+       /* 1. remove all session */
+       int err = _remove_all_session(na_plugIn_id);
+       if (err != 1) {
+               _DEBUG_ERROR("na_remove_all_session_info() is fail !!");
+               return -1;
+       } else {
+               _DEBUG_TRACE("na_remove_all_session_info() is success !!");
+       }
+
+       /* 2. create all session */
+       err = _create_all_session(na_plugIn_id);
+       if (err != 1) {
+               _DEBUG_ERROR("_create_all_session() is fail !!");
+               return -1;
+       } else {
+               _DEBUG_TRACE("_create_all_session() is success !!");
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
diff --git a/src/framework/network-access/session_manager.h b/src/framework/network-access/session_manager.h
new file mode 100755 (executable)
index 0000000..f5f5e60
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SESSION_MANAGER_H_
+#define SESSION_MANAGER_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#include "network-access/network_status.h"
+
+/**
+ * @file session_manager.h
+ * @brief Provides session manager operation
+ */
+
+/** @addtogroup network_access
+ *     @{
+ */
+
+/**
+ * @brief Structure for network connection
+ */
+typedef struct {
+//      int protocol_type;
+       int fw_network_status;                  /**< network status */
+       int fw_connection_type;                 /**< connection type */
+       int fw_connection_state;                /**< connection state */
+       char *proxy;                                    /**< proxy */
+       char *ip;                                               /**< ip */
+} na_pmci_network_connection_s;
+
+/**
+ * @brief Structure for multiple sessions management
+ */
+typedef struct {
+       GList *session_info_list;                               /**< session information list */
+       char *ip;                                                               /**< ip */
+       char *proxy;                                                    /**< proxy */
+       sync_agent_na_network_status_e fw_network_status;                       /**< newtork status */
+       /*FW_NETWORK_TYPE fw_network_type; */
+       sync_agent_na_network_connection_type_e fw_connection_type;                     /**< connection type */
+       sync_agent_na_network_connection_state_e fw_connection_state;           /**< connection state */
+} na_session_manager_s;
+
+/**
+ * @brief Structure for Session information
+ */
+typedef struct {
+       int session_id;                 /**< session id */
+       void *session;                  /**< session */
+       void *msg;                                      /**< msg */
+       int timeout;                            /**< timeout */
+       char *id;                                               /**< id */
+       char *password;                                 /**< password */
+} na_session_info_s;
+
+/**
+ * @brief Initialize session manager
+ */
+void na_init_session_manager(void);
+
+/**
+ * @brief Destroy session manager
+ */
+void na_destroy_session_manager(void);
+
+/**
+ * @brief Create session information
+ * @param[out] session Address of session in session information
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_create_session_info(void **session);
+
+/**
+ *     @brief Provide session id for the created session
+ *     @param[out] session_id Session id to provide the user
+ *     @return Operation result
+ *     @retval 1 Successful
+ *     @retval -1 Operation failed
+ */
+int na_provide_session_id(unsigned int *session_id);
+
+/**
+ * @brief Get session by using session id
+ * @param[in] session_id Session id to provide the user
+ * @param[out] session Address of session in session information
+ * @return Operation result
+ * @retval 1 Successful
+ *  @retval -1 Operation failed
+ */
+int na_get_session(unsigned int session_id, void **session);
+
+/**
+ * @brief Set session by using session id
+ * @param[in] session_id Session id to provide the user
+ * @param[in] session Address of session in session information
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_set_session(unsigned int session_id, void *session);
+
+/**
+ * @brief Get current network status
+ * @return Information about current network status provided by framework
+ * @retval SYNC_AGENT_NA_NETWORK_UNKNOWN Initial network status
+ * @retval SYNC_AGENT_NA_NETWORK_ON Network connection
+ * @retval SYNC_AGENT_NA_NETWORK_OFF Network disconnection
+ * @retval SYNC_AGENT_NA_NETWORK_CHANGE Change ip/proxy information
+ */
+sync_agent_na_network_status_e na_get_network_status(void);
+
+/**
+ * @brief Set current network status (exception case : for mobex)
+ * @param[in] network_status about current network status provided by framework
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_set_network_status(sync_agent_na_network_status_e network_status);
+
+/**
+ * @brief Get current network type
+ * @return Information about current network connection type provided by framework
+ * @retval NETWORK_NONE Initial network type
+ * @retval NETWORK_3G_ON Network UMTS on
+ * @retval NETWORK_3G_OFF Network UMTS off
+ * @retval NETWORK_WIFI_ON Network WIFI on
+ * @retval NETWORK_WIFI_ON_NOT_CONNECTED Network WIFI on but not connected
+ * @retval NETWORK_WIFI_OFF Network WIFI off
+ * @retval NETWORK_WIFI_3G_ON Network UMTS and WIFI on
+ */
+/*FW_NETWORK_TYPE get_network_type();*/
+
+/**
+ * @brief Get current network connection state
+ * @return Information about current network connection state provided by framework
+ * @retval SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE Initial network connection state
+ * @retval SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED WIFI - deactivated connection state
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED WIFI - disconnected connection state
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED WIFI - connected connection state
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE Cellular - out of service
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_FLIGHT_MODE Cellular - flight mode
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_ROAMING_OFF Cellular - roaming is turned off
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE Cellular - call is only available
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE Cellular - not connected yet
+ * @retval  SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE Cellular - connected
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED Ethernet - deactivated connection state
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED Ethernet - disconnected connection state
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED Ethernet - connected connection state
+ */
+sync_agent_na_network_connection_state_e na_get_connection_state(void);
+
+/**
+ * @brief Get current network connection type
+ * @return     Information about current network connection type provided by framework
+ * @retval SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN Initial network connection type
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED Disconnected network connection
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI Wi-Fi is used for default connection
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR Cellular is used for default connection
+ * @retval     SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET Ethernet is used for default connection
+ */
+sync_agent_na_network_connection_type_e na_get_connection_type(void);
+
+/**
+ * @brief Get current proxy information
+ * @return Current proxy information
+ * @retval Current proxy information (ex> http://xxx.xxx.xxx.xxx or https://xxx.xxx.xxx.xxx)
+ */
+char *na_get_proxy(void);
+
+/**
+ * @brief Get message by using session id
+ * @param[in] session_id Session id to provide the user
+ * @param[out] msg Message
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1  Operation failed
+ */
+int na_get_msg(unsigned int session_id, void **msg);
+
+/**
+ * @brief Get timeout time by using session id
+ * @param[in] session_id Session id to provide the user
+ * @param[out] timeout Timeout time
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_get_timeout(unsigned int session_id, int *timeout);
+
+/**
+ * @brief Set timeout time
+ * @param[in] session_id Session id to provide the user
+ * @param[in] timeout Timeout time
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_set_timeout(unsigned int session_id, int timeout);
+
+/**
+ * @brief Get user id and password by using session id (not used)
+ * @param[in] session_id Session id to provide the user
+ * @param[out] id User id
+ * @param[out] password User password
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_get_id_n_password(unsigned int session_id, char **id, char **password);
+
+/**
+ * @brief Set user id and password for authentication at EAS
+ * @param[in] session_id Session id to provide the user
+ * @param[in] id User id
+ * @param[in] password User password
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_set_id_n_password(unsigned int session_id, char *id, char *password);
+
+/**
+ * @brief Get all sessions in session manager
+ * @param[out] session_list List of sessions
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_get_all_session(GList ** session_list);
+
+/**
+ * @brief Remove session information that has specific session id
+ * @param[in] session_id Session id to provide the user
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_remove_session_info(unsigned int session_id);
+
+/**
+ * @brief Remove all session information
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_remove_all_session_info(void);
+
+/**
+ * @brief Set network information (network status/type) in session manager
+ * @param[in] na_plugIn_id NetworkAccess PlugIn ID, means protocol type
+ * @param[in] data     user data
+ * @return Operation result
+ * @retval 1 Successful
+ * @retval -1 Operation failed
+ */
+int na_set_network_info(int na_plugIn_id, void *data);
+
+/**
+ *     @}
+ */
+
+#endif                         /* SESSION_MANAGER_H_ */
diff --git a/src/framework/platform-monitor/interface.c b/src/framework/platform-monitor/interface.c
new file mode 100755 (executable)
index 0000000..ce67761
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "platform-monitor/interface.h"
+#include "plugin/platform_monitor_plugin.h"
+#include "utility/fw_mainloop.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_PMCI"
+#endif
+
+EXPORT_API sync_agent_pm_return_e sync_agnet_register_user_callback(int pm_plugin_id, const char *user_data, int callback_cnt, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+
+       plugin_set_user_callback_cb func_point_set_user_callback = plugin_get_function_set_user_callback(pm_plugin_id);
+       if (func_point_set_user_callback == NULL) {
+               _DEBUG_ERROR("func_point_set_user_callback is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       va_list list;
+       va_start(list, callback_cnt);
+
+       func_point_set_user_callback(callback_cnt, list);
+
+       va_end(list);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_unregister_service_noti(int pm_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+
+       plugin_unregister_service_noti_cb func_point_unregister_service_noti = plugin_get_function_unregister_service_noti(pm_plugin_id);
+       if (func_point_unregister_service_noti == NULL) {
+               _DEBUG_ERROR("func_point_unregister_service_noti is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       res = func_point_unregister_service_noti();
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_add_service_data(int pm_plugin_id, void *add_data, int *added_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+
+       plugin_add_service_data_cb func_point_add_service_data = plugin_get_function_add_service_data(pm_plugin_id);
+       if (func_point_add_service_data == NULL) {
+               _DEBUG_ERROR("func_point_add_service_data is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       res = func_point_add_service_data(add_data, added_data_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_remove_service_data(int pm_plugin_id, int remove_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+
+       plugin_remove_service_data_cb func_point_remove_service_data = plugin_get_function_remove_service_noti(pm_plugin_id);
+       if (func_point_remove_service_data == NULL) {
+               _DEBUG_ERROR("func_point_remove_service_data is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       res = func_point_remove_service_data(remove_data_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_get_service_data(int pm_plugin_id, int get_data_id, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+
+       plugin_get_service_data_cb func_point_get_service_data = plugin_get_function_get_service_data(pm_plugin_id);
+       if (func_point_get_service_data == NULL) {
+               _DEBUG_ERROR("func_point_get_service_data is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       res = func_point_get_service_data(get_data_id, service_data);
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
diff --git a/src/framework/plugin/account_plugin.c b/src/framework/plugin/account_plugin.c
new file mode 100755 (executable)
index 0000000..166ec70
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "utility/sync_util.h"
+#include "plugin/account_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int is_exist_plugin = 0;
+
+static plugin_account_s plugin_repository;     /* singleton */
+
+plugin_account_func_set_s plugin_get_plugin_account_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_account_func_set_s func_set;
+
+       func_set.func_set_account_repository_name = dlsym(plugin_handle, "sync_agent_plugin_set_account_repository_name");
+       func_set.func_add_platform_account = dlsym(plugin_handle, "sync_agent_plugin_add_platform_account");
+       func_set.func_set_platform_account_service = dlsym(plugin_handle, "sync_agent_plugin_set_platform_account_service");
+       func_set.func_delete_platform_account = dlsym(plugin_handle, "sync_agent_plugin_delete_platform_account");
+       func_set.func_delete_platform_account_service = dlsym(plugin_handle, "sync_agent_plugin_delete_platform_account_service");
+       func_set.func_has_platform_account_service = dlsym(plugin_handle, "sync_agent_plugin_has_platform_account_service");
+       func_set.func_get_service_account_id = dlsym(plugin_handle, "sync_agent_plugin_get_service_account_id");
+       func_set.func_get_fw_account_id = dlsym(plugin_handle, "sync_agent_plugin_get_fw_account_id");
+       func_set.func_get_service_account_info = dlsym(plugin_handle, "sync_agent_plugin_get_service_account_info");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_account(plugin_account_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_repository = plugin;
+
+       is_exist_plugin = 1;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_account()
+{
+       _EXTERN_FUNC_ENTER;
+
+       memset(&(plugin_repository.plugin_info), 0x00, sizeof(plugin_info_s));
+       memset(&(plugin_repository.func_set), 0x00, sizeof(plugin_account_func_set_s));
+       memset(&plugin_repository, 0x00, sizeof(plugin_account_s));
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_account_s plugin_get_account_plugin_repository()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+int plugin_get_account_plugin_id(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.plugin_info.plugin_id;
+       }
+
+       return -1;
+}
+
+plugin_set_account_repository_name_cb plugin_get_function_set_account_repository_name(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_set_account_repository_name;
+       }
+
+       return NULL;
+}
+
+plugin_add_platform_account_cb plugin_get_function_add_platform_account(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_add_platform_account;
+       }
+
+       return NULL;
+}
+
+plugin_set_platform_account_service_cb plugin_get_function_set_platform_account_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_set_platform_account_service;
+       }
+
+       return NULL;
+}
+
+plugin_delete_platform_account_cb plugin_get_function_delete_platform_account(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_delete_platform_account;
+       }
+
+       return NULL;
+}
+
+plugin_delete_platform_account_service_cb plugin_get_function_delete_platform_account_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_delete_platform_account_service;
+       }
+
+       return NULL;
+}
+
+plugin_has_platform_account_service_cb plugin_get_function_has_platform_account_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_has_platform_account_service;
+       }
+
+       return NULL;
+}
+
+plugin_get_service_account_id_cb plugin_get_function_get_service_account_id(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_get_service_account_id;
+       }
+
+       return NULL;
+}
+
+plugin_get_fw_account_id_cb plugin_get_function_get_fw_account_id(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_get_fw_account_id;
+       }
+
+       return NULL;
+}
+
+plugin_get_service_account_info_cb plugin_get_function_get_service_account_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (is_exist_plugin) {
+               _EXTERN_FUNC_EXIT;
+               return plugin_repository.func_set.func_get_service_account_info;
+       }
+
+       return NULL;
+}
diff --git a/src/framework/plugin/account_plugin.h b/src/framework/plugin/account_plugin.h
new file mode 100755 (executable)
index 0000000..0865bc9
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACCOUNT_PLUGIN_H_
+#define ACCOUNT_PLUGIN_H_
+
+#include "plugin/error.h"
+#include "plugin/struct.h"
+#include "account/service.h"
+
+/**
+ * @file account_plugin.h
+ * @brief      Provides function pointer manipulate operation for account module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Prototype of plugin function for setting account repository name
+ * @param[in] agent_name repository name - described in sync-agent-framework config xml file <Agent-Key>
+ */
+typedef void (*plugin_set_account_repository_name_cb) (const char *agent_name);
+
+/**
+ * @brief Prototype of plugin function for adding account to platform
+ * @param[in] fw_account_id sync-agent-framework account id
+ */
+typedef void (*plugin_add_platform_account_cb) (int fw_account_id);
+
+/**
+ * @brief Prototype of plugin function for setting mapping relationship between sync-agent-framework account id and service account id
+ * @param[in] fw_account_id
+ * @param[in] service_type
+ * @param[in] service_account_id
+ */
+typedef void (*plugin_set_platform_account_service_cb) (int fw_account_id, int service_type, int service_account_id);
+
+/**
+ * @brief Prototype of plugin function for removing mapping relationship between sync-agent-framework account id and platform account id
+ * @param[in] fw_account_id sync-agent-framework account id
+ */
+typedef void (*plugin_delete_platform_account_cb) (int fw_account_id);
+
+/**
+ * @brief Prototype of plugin function for removing mapping relationship between sync-agent-framework account id and service account id
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ */
+typedef void (*plugin_delete_platform_account_service_cb) (int fw_account_id, int service_type);
+
+/**
+ * @brief Prototype of plugin function for confirming whether sync-agent-framework account id has the service account id
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @return 1 if has, otherwise 0
+ */
+typedef int (*plugin_has_platform_account_service_cb) (int fw_account_id, int service_type);
+
+/**
+ * @brief Prototype of plugin function for getting service account id mapped with sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @return service account id if it exist mapping relationship, otherwise -100
+ */
+typedef int (*plugin_get_service_account_id_cb) (int service_type, int fw_account_id);
+
+/**
+ * @brief Prototype of plugin function for getting sync-agent-framework account id mapped with service account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] service_account_id service account id
+ * @param[in] index possible mapping one service account with multiple sync-agent-framework account, so need index of sync-agent-framework account
+ * @return sync-agent-framework account id if it exist mapping relationship, otherwise -1
+ */
+typedef int (*plugin_get_fw_account_id_cb) (int service_type, int service_account_id, int index);
+
+/**
+ * @brief Prototype of plugin function for getting service account information
+ * @param[in] fw_account_id sync-agent-framework account id
+ * @param[in] service_type service type - service data connector plugin's id described in sync-agent-framework config xml file
+ * @param[in] account_info as returned by plugin_get_service_account_info_cb
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_get_service_account_info_cb) (int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info);
+
+/**
+ * @brief Structure for account plugin function pointer set
+ */
+typedef struct {
+       plugin_set_account_repository_name_cb func_set_account_repository_name; /**< function pointer of plugin_set_account_repository_name_cb */
+       plugin_add_platform_account_cb func_add_platform_account; /**< function pointer of plugin_add_platform_account_cb */
+       plugin_set_platform_account_service_cb func_set_platform_account_service; /**< function pointer of plugin_set_platform_account_service_cb */
+       plugin_delete_platform_account_cb func_delete_platform_account; /**< function pointer of plugin_delete_platform_account_cb */
+       plugin_delete_platform_account_service_cb func_delete_platform_account_service; /**< function pointer of plugin_delete_platform_account_service_cb */
+       plugin_has_platform_account_service_cb func_has_platform_account_service; /**< function pointer of plugin_has_platform_account_service_cb */
+       plugin_get_service_account_id_cb func_get_service_account_id; /**< function pointer of plugin_get_service_account_id_cb */
+       plugin_get_fw_account_id_cb func_get_fw_account_id; /**< function pointer of plugin_get_fw_account_id_cb */
+       plugin_get_service_account_info_cb func_get_service_account_info; /**< function pointer of plugin_get_service_account_info_cb */
+} plugin_account_func_set_s;
+
+/**
+ * @brief Structure for account plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_account_func_set_s func_set; /**< account plugin function pointer set */
+} plugin_account_s;
+
+/**
+ * @brief Get account plugin function pointer set
+ * @param[in] plugin_handle handle of account plugin (result of dlopen for account plugin)
+ * @param[in] error_code as returned by plugin_get_plugin_account_func_set() - plugin error
+ * @return plugin_account_func_set_s instance
+ */
+plugin_account_func_set_s plugin_get_plugin_account_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register account plugin instance to the account plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_account_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_account(plugin_account_s plugin);
+
+/**
+ * @brief Clear account plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_account();
+
+/**
+ * @brief Get account plugin repository
+ * @return account plugin repository being maintained as a singleton
+ */
+const plugin_account_s plugin_get_account_plugin_repository();
+
+/**
+ * @brief Get account plugin id
+ * @return account plugin id on success, -1 on error
+ */
+int plugin_get_account_plugin_id(void);
+
+/**
+ * @brief Get function pointer of plugin_set_account_reposiory_name_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_set_account_reposiory_name_cb on success, NULL on error
+ */
+plugin_set_account_repository_name_cb plugin_get_function_set_account_repository_name(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_platform_account_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_add_platform_account_cb on success, NULL on error
+ */
+plugin_add_platform_account_cb plugin_get_function_add_platform_account(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_platform_account_service_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_set_platform_account_service_cb on success, NULL on error
+ */
+plugin_set_platform_account_service_cb plugin_get_function_set_platform_account_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_platform_account_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_delete_platform_account_cb on success, NULL on error
+ */
+plugin_delete_platform_account_cb plugin_get_function_delete_platform_account(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_platform_account_service_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_delete_platform_account_service_cb on success, NULL on error
+ */
+plugin_delete_platform_account_service_cb plugin_get_function_delete_platform_account_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_has_platform_account_service_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_has_platform_account_service_cb on success, NULL on error
+ */
+plugin_has_platform_account_service_cb plugin_get_function_has_platform_account_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_service_account_id_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_get_service_account_id_cb on success, NULL on error
+ */
+plugin_get_service_account_id_cb plugin_get_function_get_service_account_id(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_fw_account_id_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_get_fw_account_id_cb on success, NULL on error
+ */
+plugin_get_fw_account_id_cb plugin_get_function_get_fw_account_id(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_service_account_info_cb
+ * @param[in] plugin_id account plugin id
+ * @return function pointer of plugin_get_service_account_info_cb
+ */
+plugin_get_service_account_info_cb plugin_get_function_get_service_account_info(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* ACCOUNT_PLUGIN_H_ */
diff --git a/src/framework/plugin/data_connector_plugin.c b/src/framework/plugin/data_connector_plugin.c
new file mode 100755 (executable)
index 0000000..955dfcd
--- /dev/null
@@ -0,0 +1,640 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <string.h>
+
+#include "utility/sync_util.h"
+#include "plugin/data_connector_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_data_connector = 0;
+
+static plugin_data_connector_s plugin_repository[PLUGIN_MAX_DATA_CONNECTOR];
+
+static int _find_data_connector_plugin(int plugin_id);
+
+plugin_data_connector_func_set_s plugin_get_data_connector_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_data_connector_func_set_s func_set;
+
+       func_set.func_open_service = dlsym(plugin_handle, "sync_agent_plugin_open_service");
+       func_set.func_close_service = dlsym(plugin_handle, "sync_agent_plugin_close_service");
+       func_set.func_begin_transaction = dlsym(plugin_handle, "sync_agent_plugin_begin_transaction");
+       func_set.func_end_transaction = dlsym(plugin_handle, "sync_agent_plugin_end_transaction");
+       func_set.func_add_item = dlsym(plugin_handle, "sync_agent_plugin_add_item");
+       func_set.func_update_item = dlsym(plugin_handle, "sync_agent_plugin_update_item");
+       func_set.func_delete_item = dlsym(plugin_handle, "sync_agent_plugin_delete_item");
+       func_set.func_delete_all_items = dlsym(plugin_handle, "sync_agent_plugin_delete_all_items");
+       func_set.func_get_item = dlsym(plugin_handle, "sync_agent_plugin_get_item");
+       func_set.func_add_folder = dlsym(plugin_handle, "sync_agent_plugin_add_folder");
+       func_set.func_delete_folder = dlsym(plugin_handle, "sync_agent_plugin_delete_folder");
+       func_set.func_get_folder = dlsym(plugin_handle, "sync_agent_plugin_get_folder");
+       func_set.func_execute = dlsym(plugin_handle, "sync_agent_plugin_execute");
+       func_set.func_get_used_item_cnt = dlsym(plugin_handle, "sync_agent_plugin_get_used_item_count");
+       func_set.func_get_used_cnt_for_folder = dlsym(plugin_handle, "sync_agent_plugin_get_used_item_count_for_folder");
+       func_set.func_get_folder_id_list = dlsym(plugin_handle, "sync_agent_plugin_get_folder_id_list");
+       func_set.func_get_account_id_list = dlsym(plugin_handle, "sync_agent_plugin_get_account_id_list");
+       func_set.func_backup_service_items_to_file = dlsym(plugin_handle, "sync_agent_plugin_backup_service_items_to_file");
+       func_set.func_restore_service_items_from_file = dlsym(plugin_handle, "sync_agent_plugin_restore_service_items_from_file");
+       func_set.func_get_chaned_item_for_folder_add = dlsym(plugin_handle, "sync_agent_plugin_get_changed_item_for_folder_add");
+       func_set.func_get_chaned_item_for_folder_delete = dlsym(plugin_handle, "sync_agent_plugin_get_changed_item_for_folder_delete");
+       func_set.func_get_chaned_item_for_folder_update = dlsym(plugin_handle, "sync_agent_plugin_get_changed_item_for_folder_update");
+       func_set.func_get_last_change_point = dlsym(plugin_handle, "sync_agent_plugin_get_last_change_point");
+       func_set.func_start_listening_change_noti = dlsym(plugin_handle, "sync_agent_plugin_start_listening_change_noti");
+       func_set.func_set_callback_add_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_add_item");
+       func_set.func_set_callback_delete_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_delete_item");
+       func_set.func_set_callback_update_item = dlsym(plugin_handle, "sync_agent_plugin_set_callback_update_item");
+       func_set.func_set_callback_get_account_id_list = dlsym(plugin_handle, "sync_agent_plugin_set_callback_get_account_id_list");
+       func_set.func_get_max_item_count = dlsym(plugin_handle, "sync_agent_plugin_get_max_item_count");
+       func_set.func_get_max_field_length = dlsym(plugin_handle, "sync_agent_plugin_get_max_field_length");
+       func_set.func_get_max_field_count = dlsym(plugin_handle, "sync_agent_plugin_get_max_field_count");
+       func_set.func_get_field_value = dlsym(plugin_handle, "sync_agent_plugin_get_field_value");
+       func_set.func_get_is_support_feature = dlsym(plugin_handle, "sync_agent_plugin_get_is_support_feature");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_data_connector(plugin_data_connector_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_data_connector >= PLUGIN_MAX_DATA_CONNECTOR) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugin_repository[current_plugin_count_data_connector] = plugin;
+
+       current_plugin_count_data_connector++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_data_connector()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_data_connector; i++) {
+               memset(&(plugin_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugin_repository[i].func_set), 0x00, sizeof(plugin_data_connector_func_set_s));
+               memset(&(plugin_repository[i]), 0x00, sizeof(plugin_data_connector_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_data_connector_s *plugin_get_data_connector_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_data_connector;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+int plugin_get_data_converter_plugin_id(int dc_plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(dc_plugin_id);
+       if (index == -1) {
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].data_converter_id;
+}
+
+int *plugin_get_data_connector_plugin_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int *dc_plugin_id_list = NULL;
+       *count = 0;
+
+       if (current_plugin_count_data_connector > 0) {
+               *count = current_plugin_count_data_connector;
+               dc_plugin_id_list = (int *)calloc(current_plugin_count_data_connector, sizeof(int));
+               if (dc_plugin_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               int i = 0;
+               for (; i < current_plugin_count_data_connector; i++) {
+                       dc_plugin_id_list[i] = plugin_repository[i].plugin_info.plugin_id;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return dc_plugin_id_list;
+}
+
+plugin_open_service_cb plugin_get_function_open_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_open_service;
+}
+
+plugin_close_service_cb plugin_get_function_close_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_close_service;
+}
+
+plugin_begin_transaction_cb plugin_get_function_begin_transaction(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_begin_transaction;
+}
+
+plugin_end_transaction_cb plugin_get_function_end_transaction(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_end_transaction;
+}
+
+plugin_add_item_cb plugin_get_function_add_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_add_item;
+}
+
+plugin_update_item_cb plugin_get_function_update_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_update_item;
+}
+
+plugin_delete_item_cb plugin_get_function_del_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_delete_item;
+}
+
+plugin_delete_all_items_cb plugin_get_function_del_all_items(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_delete_all_items;
+}
+
+plugin_get_item_cb plugin_get_function_get_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_item;
+}
+
+plugin_add_folder_cb plugin_get_function_add_folder(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_add_folder;
+}
+
+plugin_delete_folder_cb plugin_get_function_delete_folder(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_delete_folder;
+}
+
+plugin_get_folder_cb plugin_get_function_get_folder(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_folder;
+}
+
+plugin_execute_cb plugin_get_function_execute(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_execute;
+}
+
+plugin_get_used_item_count_cb plugin_get_function_get_used_item_count(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_used_item_cnt;
+
+}
+
+plugin_get_used_count_for_folder_cb plugin_get_function_get_used_count_for_folder(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_used_cnt_for_folder;
+
+}
+
+plugin_get_folder_id_list_cb plugin_get_function_get_folder_id_list(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_folder_id_list;
+}
+
+plugin_get_account_id_list_cb plugin_get_function_get_account_id_list(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_account_id_list;
+}
+
+plugin_backup_service_items_to_file_cb plugin_get_function_backup_service_items_to_file(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_backup_service_items_to_file;
+}
+
+plugin_restore_service_items_from_file_cb plugin_get_function_restore_service_items_from_file(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_restore_service_items_from_file;
+}
+
+plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_chaned_item_for_folder_add(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_chaned_item_for_folder_add;
+}
+
+plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_chaned_item_for_folder_delete(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_chaned_item_for_folder_delete;
+}
+
+plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_chaned_item_for_folder_update(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_chaned_item_for_folder_update;
+}
+
+plugin_get_last_change_point_cb plugin_get_function_get_last_change_point(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_last_change_point;
+}
+
+plugin_start_listening_change_noti_cb plugin_get_function_start_listening_change_noti(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_start_listening_change_noti;
+}
+
+plugin_set_callback_add_item_cb plugin_get_function_set_callback_add_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_callback_add_item;
+}
+
+plugin_set_callback_delete_item_cb plugin_get_function_set_callback_delete_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_callback_delete_item;
+}
+
+plugin_set_callback_update_item_cb plugin_get_function_data_connector_set_callback_update_item(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_callback_update_item;
+}
+
+plugin_set_callback_get_account_id_list_cb plugin_get_function_set_callback_get_account_id_list(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_callback_get_account_id_list;
+}
+
+plugin_get_max_item_count_cb plugin_get_function_get_max_item_count(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_max_item_count;
+}
+
+plugin_get_max_field_length_cb plugin_get_function_get_max_field_length(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_max_field_length;
+}
+
+plugin_get_max_field_count_cb plugin_get_function_get_max_field_count(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_max_field_count;
+}
+
+plugin_get_field_value_cb plugin_get_function_get_field_value(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_field_value;
+}
+
+plugin_get_is_support_feature_cb plugin_get_function_get_is_support_feature(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_connector_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_is_support_feature;
+}
+
+static int _find_data_connector_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_data_connector; i++) {
+               if (plugin_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/plugin/data_connector_plugin.h b/src/framework/plugin/data_connector_plugin.h
new file mode 100755 (executable)
index 0000000..7a5cff6
--- /dev/null
@@ -0,0 +1,631 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONNECTOR_PLUGIN_H_
+#define DATA_CONNECTOR_PLUGIN_H_
+
+#include "error.h"
+#include "struct.h"
+#include "plugin/data_connector_resource.h"
+#include "data-adapter/error.h"
+
+/**
+ * @file data_connector_plugin.h
+ * @brief      Provides function pointer manipulate operation for data connector module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of data-connector plugin
+ */
+#define PLUGIN_MAX_DATA_CONNECTOR              20
+
+/**
+ * @brief Prototype of plugin function for connecting(open) to the service
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_open_service_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for disconnecting(close) to the service
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_close_service_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for starting transaction for service storage
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_begin_transaction_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for ending transaction for service storage
+ * @param[in] is_success flag to decide commit/rollback        (1:commit, 0:rollback)
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_end_transaction_cb) (int is_success);
+
+/**
+ * @brief Prototype of plugin function for inserting item into service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] data data to add to the service
+ * @param[in] item_id as returned by plugin_add_item_cb - success : id of the newly item added to the service, error : NULL
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_add_item_cb) (int account_id, char *folder_id, void *data, char **item_id);
+
+/**
+ * @brief Prototype of plugin function for updating item from service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] item_id service item id
+ * @param[in] data data to update to the service
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_update_item_cb) (int account_id, char *folder_id, char *item_id, void *data);
+
+/**
+ * @brief Prototype of plugin function for deleting item from service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] item_id service id of item expected to be deleted
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_delete_item_cb) (int account_id, char *folder_id, char *item_id);
+
+/**
+ * @brief Prototype of plugin function for deleting all items from service storage
+ * @param[in] account_id service account id
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_delete_all_items_cb) (int account_id);
+
+/**
+ * @brief Prototype of plugin function for getting item from service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] item_id expected to get service item id
+ * @param[in] data as returned by plugin_get_item_cb - success : item info, error : NULL
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_get_item_cb) (int account_id, char *folder_id, char *item_id, void **data);
+
+/**
+ * @brief Prototype of plugin function for inserting folder into service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_name folder name
+ * @param[in] folder_type folder type
+ * @param[in] folder_id as returned by plugin_add_folder_cb - success : id of the newly folder added to the service, fail : NULL
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_add_folder_cb) (int account_id, const char *folder_name, int folder_type, char **folder_id);
+
+/**
+ * @brief Prototype of plugin function for deleting folder from service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_delete_folder_cb) (int account_id, const char *folder_id);
+
+/**
+ * @brief Prototype of plugin function for getting folder info from service storage
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] folder_name as returned by plugin_get_folder_cb - success : folder name, fail : NULL
+ * @param[in] folder_type as returned by plugin_get_folder_cb - success : folder type, fail : -1
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_get_folder_cb) (int account_id, const char *folder_id, char **folder_name, int *folder_type);
+
+/**
+ * @brief Prototype of plugin function for executing data into service
+ * @param[in] account_id service account id
+ * @param[in] execute_key execute key
+ * @param[in] execute_values execute values
+ * @param[in] result as returned by plugin_execute_cb -        extension result info
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_execute_cb) (int account_id, const char *execute_key, void *execute_values, void **result);
+
+/**
+ * @brief Prototype of plugin function for getting item used count
+ * @return current_item_count on success, negative value on error
+ */
+typedef int (*plugin_get_used_item_count_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for getting item used count for folder
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @return current_item_count on success, negative value on error
+ */
+typedef int (*plugin_get_used_count_for_folder_cb) (int account_id, const char *folder_id);
+
+/**
+ * @brief Prototype of plugin function for writing data store items to file
+ * @param[in] account_id service account id
+ * @param[in] file_path written file path
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_backup_service_items_to_file_cb) (int account_id, char **file_path);
+
+/**
+ * @brief Prototype of plugin function for adding file-written item to data store
+ * @param[in] account_id service account id
+ * @param[in] file_path file path
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_restore_service_items_from_file_cb) (int account_id, const char *file_path);
+
+/**
+ * @brief Prototype of plugin function for getting folder id list of a account
+ * @param[in] account_id service account id
+ * @param[in] folder_count as returned by plugin_get_folder_id_list_cb - success : folder count,       fail or not exist : 0
+ * @param[in] folder_type_list as returned by plugin_get_folder_id_list_cb - success : list,   fail or not exist : NULL
+ * @return folder_id_list on success, NULL on error or not exist
+ */
+typedef char **(*plugin_get_folder_id_list_cb) (int account_id, int *folder_count, int **folder_type_list);
+
+/**
+ * @brief Prototype of plugin function for getting all account id list that service has currently
+ * @param[in] count as returned by plugin_get_account_id_list_cb - success : count of account id,      fail or not exist : 0
+ * @return account_id_list on success, NULL on fail or not exist
+ */
+typedef int *(*plugin_get_account_id_list_cb) (int *count);
+
+/**
+ * @brief Prototype of plugin function for getting added item list after specific point
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] chage_point specific point
+ * @param[in] change_count as returned by plugin_get_changed_item_for_folder_add_cb - success : added item count, fail or not exist : NULL
+ * @return added_item_info_list (if exist) on success, NULL on error or not exist
+ */
+typedef sync_agent_plugin_item_node_s *(*plugin_get_changed_item_for_folder_add_cb) (int account_id, const char *folder_id, int chage_point, int *change_count);
+
+/**
+ * @brief Prototype of plugin function for getting deleted item list after specific point
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] chage_point specific point
+ * @param[in] change_count as returned by plugin_get_changed_item_for_folder_delete_cb - success : deleted item count, fail or not exist : NULL
+ * @return deleted_item_info_list      (if exist) on success, NULL on error or not exist
+ */
+typedef sync_agent_plugin_item_node_s *(*plugin_get_changed_item_for_folder_delete_cb) (int account_id, const char *folder_id, int chage_point, int *change_count);
+
+/**
+ * @brief Prototype of plugin function for getting updated item list after specific point
+ * @param[in] account_id service account id
+ * @param[in] folder_id service folder id
+ * @param[in] chage_point specific point
+ * @param[in] change_count as returned by plugin_get_changed_item_for_folder_update_cb - success : updated item count, fail or not exist : NULL
+ * @return updated_item_info_list      (if exist) on success, NULL on error or not exist
+ */
+typedef sync_agent_plugin_item_node_s *(*plugin_get_changed_item_for_folder_update_cb) (int account_id, const char *folder_id, int chage_point, int *change_count);
+
+/**
+ * @brief Prototype of plugin function for getting last storage change point information
+ * @return last storage changing point information on success, 0 on error
+ */
+typedef int (*plugin_get_last_change_point_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for checking notification for the storage change
+ * @param[in] filter_flag user data
+ */
+typedef void (*plugin_start_listening_change_noti_cb) (void *filter_flag);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to handle added item to storage
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ */
+typedef void (*plugin_set_callback_add_item_cb) (sync_agent_add_item_cb_plugin callback);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to handle deleted item to storage
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ */
+typedef void (*plugin_set_callback_delete_item_cb) (sync_agent_del_item_cb_plugin callback);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to handle updated item to storage
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ */
+typedef void (*plugin_set_callback_update_item_cb) (sync_agent_update_item_cb_plugin callback);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to get service account id list mapped sync-agent-framework account id
+ * @param[in] callback callback function - this function is provided from sync-agent-framework
+ */
+typedef void (*plugin_set_callback_get_account_id_list_cb) (sync_agent_get_account_id_list_cb_plugin callback);
+
+/********************* Get Meta Info ******************/
+
+/**
+ * @brief Prototype of plugin function for getting max item count per folder
+ * @param[in] folder_type folder type provided plugin
+ * @return max item count on success, -1 on error
+ */
+typedef int (*plugin_get_max_item_count_cb) (int folder_type);
+
+/**
+ * @brief Prototype of plugin function for getting service data's available field length
+ * @param[in] field_name field_name provided data-connector plugin
+ * @param[in] child_field_name child field name provided data-connector plugin
+ * @return
+ */
+typedef int (*plugin_get_max_field_length_cb) (int field_name, int child_field_name);
+
+/**
+ * @brief Prototype of plugin function for getting service data's available field count
+ * @param[in] field_name field_name provided data-connector plugin
+ * @param[in] child_field_name child field name provided data-connector plugin
+ * @return
+ */
+typedef int (*plugin_get_max_field_count_cb) (int field_name, int child_field_name);
+
+/**
+ * @brief Prototype of plugin function for getting service data's available field value's domain
+ * @param[in] field_name field name provided data-connector plugin
+ * @param[in] child_field_name child field name provided data-connector plugin
+ * @param[in] str_val as returned by plugin_get_field_value_cb - when domain value is string
+ * @param[in] num_val1 returned by plugin_get_field_value_cb - when domain value is integer (ex minimum value)
+ * @param[in] num_val2 as returned by plugin_get_field_value_cb - when domain value is integer (ex maximum value)
+ * @return 1 on success, -1 on error
+ */
+typedef int (*plugin_get_field_value_cb) (int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2);
+
+/**
+ * @brief Prototype of plugin function for getting service data's available field count
+ * @param[in] feature feature provided data-connector plugin
+ * @return 1 : support, 0 : not support on success, -1 on error
+ */
+typedef int (*plugin_get_is_support_feature_cb) (int feature);
+
+/**
+ * @brief Structure for data-connector plugin function pointer set
+ */
+typedef struct {
+       plugin_open_service_cb func_open_service; /**< function pointer of plugin_open_service_cb */
+       plugin_close_service_cb func_close_service; /**< function pointer of plugin_close_service_cb */
+       plugin_begin_transaction_cb func_begin_transaction; /**< function pointer of plugin_begin_transaction_cb */
+       plugin_end_transaction_cb func_end_transaction; /**< function pointer of plugin_end_transaction_cb */
+       plugin_add_item_cb func_add_item; /**< function pointer of plugin_add_item_cb */
+       plugin_update_item_cb func_update_item; /**< function pointer of plugin_update_item_cb */
+       plugin_delete_item_cb func_delete_item; /**< function pointer of plugin_delete_item_cb */
+       plugin_delete_all_items_cb func_delete_all_items; /**< function pointer of plugin_delete_all_items_cb */
+       plugin_get_item_cb func_get_item; /**< function pointer of plugin_get_item_cb */
+       plugin_add_folder_cb func_add_folder; /**< function pointer of plugin_add_folder_cb */
+       plugin_delete_folder_cb func_delete_folder; /**< function pointer of plugin_delete_folder_cb */
+       plugin_get_folder_cb func_get_folder; /**< function pointer of plugin_get_folder_cb */
+       plugin_execute_cb func_execute; /**< function pointer of plugin_execute_cb */
+       plugin_get_used_item_count_cb func_get_used_item_cnt; /**< function pointer of plugin_get_used_item_count_cb */
+       plugin_get_used_count_for_folder_cb func_get_used_cnt_for_folder; /**< function pointer of plugin_get_used_count_for_folder_cb */
+       plugin_backup_service_items_to_file_cb func_backup_service_items_to_file; /**< function pointer of plugin_backup_service_items_to_file_cb */
+       plugin_restore_service_items_from_file_cb func_restore_service_items_from_file; /**< function pointer of plugin_restore_service_items_from_file_cb */
+
+       plugin_get_folder_id_list_cb func_get_folder_id_list; /**< function pointer of plugin_get_folder_id_list_cb */
+       plugin_get_account_id_list_cb func_get_account_id_list; /**< function pointer of plugin_get_account_id_list_cb */
+       plugin_get_changed_item_for_folder_add_cb func_get_chaned_item_for_folder_add; /**< function pointer of plugin_get_changed_item_for_folder_add_cb */
+       plugin_get_changed_item_for_folder_delete_cb func_get_chaned_item_for_folder_delete; /**< function pointer of plugin_get_changed_item_for_folder_delete_cb */
+       plugin_get_changed_item_for_folder_update_cb func_get_chaned_item_for_folder_update; /**< function pointer of plugin_get_changed_item_for_folder_update_cb */
+       plugin_get_last_change_point_cb func_get_last_change_point; /**< function pointer of plugin_get_last_change_point_cb */
+       plugin_start_listening_change_noti_cb func_start_listening_change_noti; /**< function pointer of plugin_start_listening_change_noti_cb */
+       plugin_set_callback_add_item_cb func_set_callback_add_item; /**< function pointer of plugin_set_callback_add_item_cb */
+       plugin_set_callback_delete_item_cb func_set_callback_delete_item; /**< function pointer of plugin_set_callback_delete_item_cb */
+       plugin_set_callback_update_item_cb func_set_callback_update_item; /**< function pointer of plugin_set_callback_update_item_cb */
+       plugin_set_callback_get_account_id_list_cb func_set_callback_get_account_id_list; /**< function pointer of plugin_set_callback_get_account_id_list_cb */
+       plugin_get_max_item_count_cb func_get_max_item_count; /**< function pointer of plugin_get_max_item_count_cb */
+       plugin_get_max_field_length_cb func_get_max_field_length; /**< function pointer of plugin_get_max_field_length_cb */
+       plugin_get_max_field_count_cb func_get_max_field_count; /**< function pointer of plugin_get_max_field_count_cb */
+       plugin_get_field_value_cb func_get_field_value; /**< function pointer of plugin_get_field_value_cb */
+       plugin_get_is_support_feature_cb func_get_is_support_feature; /**< function pointer of plugin_get_is_support_feature_cb */
+} plugin_data_connector_func_set_s;
+
+/**
+ * @brief Structure for data-connector plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_data_connector_func_set_s func_set; /**< data-connector plugin function pointer set */
+       int data_converter_id; /**< data converter id */
+       int handle_change_noti; /**< whether to use change noti feature - described in framework initialization config file /<tagHandle-ChangeNoti> */
+       int use_main_loop; /**< whether to use main loop */
+} plugin_data_connector_s;
+
+/**
+ * @brief Get data-connector plugin function pointer set
+ * @param[in] plugin_handle handle of data-connector plugin (result of dlopen for data-connector plugin)
+ * @param[in] error_code as returned by plugin_get_data_connector_func_set() - plugin error
+ * @return plugin_data_connector_func_set_s instance
+ */
+plugin_data_connector_func_set_s plugin_get_data_connector_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register data-connector plugin instance to the data-connector plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_data_connector_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_data_connector(plugin_data_connector_s plugin);
+
+/**
+ * @brief Clear data-connector plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_data_connector();
+
+/**
+ * @brief Get data-connector plugin repository
+ * @param[in] count as returned by plugin_get_data_connector_plugin_repository() - the number of data-connector plugin
+ * @return data-connector plugin repository being maintained as a singleton
+ */
+const plugin_data_connector_s *plugin_get_data_connector_plugin_repository(int *count);
+
+/**
+ * @brief Get data-converter plugin id related with specific data-connector plugin
+ * @param[in] dc_plugin_id data-connector plugin id
+ * @return data-converter plugin id (positive value) on success, -1 on error
+ */
+int plugin_get_data_converter_plugin_id(int dc_plugin_id);
+
+/**
+ * @brief Get list of data-connector plugin id
+ * @param[in] count as returned by plugin_get_data_connector_plugin_id_list() - the number of data-connector plugin
+ * @return list of data-connector plugin id on success, NULL on error
+ */
+int *plugin_get_data_connector_plugin_id_list(int *count);
+
+/**
+ * @brief Get function pointer of plugin_open_service_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_open_service_cb on success, NULL on error
+ */
+plugin_open_service_cb plugin_get_function_open_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_close_service_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_close_service_cb on success, NULL on error
+ */
+plugin_close_service_cb plugin_get_function_close_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_begin_transaction_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_begin_transaction_cb on success, NULL on error
+ */
+plugin_begin_transaction_cb plugin_get_function_begin_transaction(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_end_transaction_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_end_transaction_cb on success, NULL on error
+ */
+plugin_end_transaction_cb plugin_get_function_end_transaction(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_add_item_cb on success, NULL on error
+ */
+plugin_add_item_cb plugin_get_function_add_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_update_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_update_item_cb on success, NULL on error
+ */
+plugin_update_item_cb plugin_get_function_update_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_delete_item_cb on success, NULL on error
+ */
+plugin_delete_item_cb plugin_get_function_del_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_all_items_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_delete_all_items_cb on success, NULL on error
+ */
+plugin_delete_all_items_cb plugin_get_function_del_all_items(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_item_cb on success, NULL on error
+ */
+plugin_get_item_cb plugin_get_function_get_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_folder_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_add_folder_cb on success, NULL on error
+ */
+plugin_add_folder_cb plugin_get_function_add_folder(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_delete_folder_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_delete_folder_cb on success, NULL on error
+ */
+plugin_delete_folder_cb plugin_get_function_delete_folder(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_folder_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_folder_cb on success, NULL on error
+ */
+plugin_get_folder_cb plugin_get_function_get_folder(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_execute_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_execute_cb on success, NULL on error
+ */
+plugin_execute_cb plugin_get_function_execute(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_used_item_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_used_item_count_cb on success, NULL on error
+ */
+plugin_get_used_item_count_cb plugin_get_function_get_used_item_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_used_count_for_folder_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_used_count_for_folder_cb on success, NULL on error
+ */
+plugin_get_used_count_for_folder_cb plugin_get_function_get_used_count_for_folder(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_folder_id_list_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_folder_id_list_cb on success, NULL on error
+ */
+plugin_get_folder_id_list_cb plugin_get_function_get_folder_id_list(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_account_id_list_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_account_id_list_cb on success, NULL on error
+ */
+plugin_get_account_id_list_cb plugin_get_function_get_account_id_list(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_backup_service_items_to_file_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_backup_service_items_to_file_cb on success, NULL on error
+ */
+plugin_backup_service_items_to_file_cb plugin_get_function_backup_service_items_to_file(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_restore_service_items_from_file_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_restore_service_items_from_file_cb on success, NULL on error
+ */
+plugin_restore_service_items_from_file_cb plugin_get_function_restore_service_items_from_file(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_changed_item_for_folder_add_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_changed_item_for_folder_add_cb on success, NULL on error
+ */
+plugin_get_changed_item_for_folder_add_cb plugin_get_function_get_chaned_item_for_folder_add(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_changed_item_for_folder_delete_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_changed_item_for_folder_delete_cb on success, NULL on error
+ */
+plugin_get_changed_item_for_folder_delete_cb plugin_get_function_get_chaned_item_for_folder_delete(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_changed_item_for_folder_update_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_changed_item_for_folder_update_cb on success, NULL on error
+ */
+plugin_get_changed_item_for_folder_update_cb plugin_get_function_get_chaned_item_for_folder_update(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_last_change_point_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_last_change_point_cb on success, NULL on error
+ */
+plugin_get_last_change_point_cb plugin_get_function_get_last_change_point(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_start_listening_change_noti_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_start_listening_change_noti_cb on success, NULL on error
+ */
+plugin_start_listening_change_noti_cb plugin_get_function_start_listening_change_noti(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_callback_add_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_set_callback_add_item_cb on success, NULL on error
+ */
+plugin_set_callback_add_item_cb plugin_get_function_set_callback_add_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_callback_delete_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_set_callback_delete_item_cb on success, NULL on error
+ */
+plugin_set_callback_delete_item_cb plugin_get_function_set_callback_delete_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_callback_update_item_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_set_callback_update_item_cb on success, NULL on error
+ */
+plugin_set_callback_update_item_cb plugin_get_function_data_connector_set_callback_update_item(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_callback_get_account_id_list_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_set_callback_get_account_id_list_cb on success, NULL on error
+ */
+plugin_set_callback_get_account_id_list_cb plugin_get_function_set_callback_get_account_id_list(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_max_item_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_max_item_count_cb on success, NULL on error
+ */
+plugin_get_max_item_count_cb plugin_get_function_get_max_item_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_max_field_length_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_max_field_length_cb on success, NULL on error
+ */
+plugin_get_max_field_length_cb plugin_get_function_get_max_field_length(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_max_field_count_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_max_field_count_cb on success, NULL on error
+ */
+plugin_get_max_field_count_cb plugin_get_function_get_max_field_count(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_field_value_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_field_value_cb on success, NULL on error
+ */
+plugin_get_field_value_cb plugin_get_function_get_field_value(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_is_support_feature_cb
+ * @param[in] plugin_id data-connector plugin id
+ * @return function pointer of plugin_get_is_support_feature_cb on success, NULL on error
+ */
+plugin_get_is_support_feature_cb plugin_get_function_get_is_support_feature(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DATA_CONNECTOR_PLUGIN_H_ */
diff --git a/src/framework/plugin/data_converter_plugin.c b/src/framework/plugin/data_converter_plugin.c
new file mode 100755 (executable)
index 0000000..ed14e83
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "utility/sync_util.h"
+#include "plugin/data_converter_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_dataconverter = 0;
+
+static plugin_data_converter_s plugIn_repository[PLUGIN_MAX_DATA_CONVERTER];
+
+static int _find_data_converter_plugin(int plugin_id);
+
+plugin_data_converter_func_set_s plugin_get_data_converter_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_data_converter_func_set_s func_set;
+
+       func_set.func_converter = dlsym(plugin_handle, "sync_agent_plugin_converter");
+       func_set.func_replace_converter = dlsym(plugin_handle, "sync_agent_plugin_replace_converter");
+       func_set.func_reverse_converter = dlsym(plugin_handle, "sync_agent_plugin_reverse_converter");
+       func_set.func_alloc_object = dlsym(plugin_handle, "sync_agent_plugin_alloc_object");
+       func_set.func_free_object = dlsym(plugin_handle, "sync_agent_plugin_free_object");
+       func_set.func_set_value = dlsym(plugin_handle, "sync_agent_plugin_set_value");
+       func_set.func_get_value = dlsym(plugin_handle, "sync_agent_plugin_get_value");
+       func_set.func_get_obj_info = dlsym(plugin_handle, "sync_agent_plugin_get_obj_info");
+       func_set.func_free_obj_info = dlsym(plugin_handle, "sync_agent_plugin_free_obj_info");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_data_converter(plugin_data_converter_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_dataconverter >= PLUGIN_MAX_DATA_CONVERTER) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugIn_repository[current_plugin_count_dataconverter] = plugin;
+
+       current_plugin_count_dataconverter++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_data_converter()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_dataconverter; i++) {
+               memset(&(plugIn_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugIn_repository[i].func_set), 0x00, sizeof(plugin_data_converter_func_set_s));
+               memset(&(plugIn_repository[i]), 0x00, sizeof(plugin_data_converter_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_data_converter_s *plugin_get_data_converter_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_dataconverter;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository;
+}
+
+plugin_converter_cb plugin_get_function_converter(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_converter;
+}
+
+plugin_replace_converter_cb plugin_get_function_replace_converter(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_replace_converter;
+}
+
+plugin_reverse_converter_cb plugin_get_function_reverse_converter(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_reverse_converter;
+}
+
+plugin_alloc_object_cb plugin_get_function_alloc_object(int plugIn_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugIn_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_alloc_object;
+}
+
+plugin_free_object_cb plugin_get_function_free_object(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_free_object;
+}
+
+plugin_set_value_cb plugin_get_function_set_value_to_object(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_set_value;
+}
+
+plugin_get_value_cb plugin_get_function_get_value_to_object(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_get_value;
+}
+
+plugin_get_obj_info_cb plugin_get_function_get_obj_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_get_obj_info;
+}
+
+plugin_free_obj_info_cb plugin_get_function_free_obj_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_data_converter_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_free_obj_info;
+}
+
+static int _find_data_converter_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_dataconverter; i++) {
+               if (plugIn_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/plugin/data_converter_plugin.h b/src/framework/plugin/data_converter_plugin.h
new file mode 100755 (executable)
index 0000000..f458f87
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DATA_CONVERTER_PLUGIN_H_
+#define DATA_CONVERTER_PLUGIN_H_
+
+#include "struct.h"
+#include "error.h"
+#include "data-adapter/error.h"
+#include "plugin/data_converter_resource.h"
+
+/**
+ * @file data_converter_plugin.h
+ * @brief      Provides function pointer manipulate operation for data converter module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of data-converter plugin
+ */
+#define PLUGIN_MAX_DATA_CONVERTER 10
+
+/**
+ * @brief Prototype of plugin function for converting agent type data to service structure format data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ * @param[in] agent_data agent data
+ * @param[in] service_data as returned by plugin_converter_cb - created service data
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_converter_cb) (const void *agent_data, void **service_data);
+
+/**
+ * @brief Prototype of plugin function for converting result of the merge agent data with old service data to service structure format data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ * @param[in] old_service_data old service data
+ * @param[in] agent_data agent data
+ * @param[in] new_service_data as returned by plugin_replace_converter_cb - created service data
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_replace_converter_cb) (void *old_service_data, const void *agent_data, void **new_service_data);
+
+/**
+ * @brief Prototype of plugin function for converting service structure format data to agent type data
+ * @remarks    agent data's type can be v-object. (vcard, vcalendar .. )
+ * @param[in] service_data created service data
+ * @param[in] agent_data as returned by plugin_reverse_converter_cb - agent data
+ * @return SYNC_AGENT_DA_SUCCESS on success, otherwise error
+ */
+typedef sync_agent_da_return_e(*plugin_reverse_converter_cb) (void *service_data, void **agent_data);
+
+/**
+ * @brief Prototype of plugin function for allocating internal object for content type
+ * @return internal_struct_pointer on success, NULL on error
+ */
+typedef void *(*plugin_alloc_object_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for free internal object for content type
+ * @param[in] in_object internal object pointer
+ * @return SYNC_AGENT_DA_SUCCESS on success, SYNC_AGENT_DA_ERRORS on error
+ */
+typedef int (*plugin_free_object_cb) (void *in_object);
+
+/**
+ * @brief Prototype of plugin function for setting value for internal object
+ * @param[in] in_object internal object pointer
+ * @param[in] key key
+ * @param[in] extension_key extension key
+ * @param[in] set_value value
+ * @return new object pointer on success, NULL on error
+ */
+typedef void *(*plugin_set_value_cb) (void *in_object, int key, char *extension_key, void *set_value);
+
+/**
+ * @brief Prototype of plugin function for getting value for specific key
+ * @param[in] in_object internal object pointer
+ * @param[in] key key
+ * @param[in] extension_key extension key
+ * @return value pointer on success, NULL on error
+ */
+typedef void *(*plugin_get_value_cb) (void *in_object, int key, char *extension_key);
+
+/**
+ * @brief Prototype of plugin function for getting meta information of internal object
+ * @return value pointer on success, NULL on error
+ */
+typedef sync_agent_plugin_object_info_s *(*plugin_get_obj_info_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for free information of internal object
+ * @param[in] obj_info object info
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_free_obj_info_cb) (sync_agent_plugin_object_info_s * obj_info);
+
+/**
+ * @brief Structure for data-converter plugin function pointer set
+ */
+typedef struct {
+       plugin_converter_cb func_converter; /**< function pointer of plugin_converter_cb */
+       plugin_replace_converter_cb func_replace_converter; /**< function pointer of plugin_replace_converter_cb */
+       plugin_reverse_converter_cb func_reverse_converter; /**< function pointer of plugin_reverse_converter_cb */
+       plugin_alloc_object_cb func_alloc_object; /**< function pointer of plugin_alloc_object_cb */
+       plugin_free_object_cb func_free_object; /**< function pointer of plugin_free_object_cb */
+       plugin_set_value_cb func_set_value; /**< function pointer of plugin_set_value_cb */
+       plugin_get_value_cb func_get_value; /**< function pointer of plugin_get_value_cb */
+       plugin_get_obj_info_cb func_get_obj_info; /**< function pointer of plugin_get_obj_info_cb */
+       plugin_free_obj_info_cb func_free_obj_info; /**< function pointer of plugin_free_obj_info_cb */
+} plugin_data_converter_func_set_s; /**< function pointer of plugin_data_converter_func_set_s */
+
+/**
+ * @brief Structure for data-converter plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_data_converter_func_set_s func_set; /**< data-converter plugin function pointer set */
+} plugin_data_converter_s;
+
+/**
+ * @brief Get data-converter plugin function pointer set
+ * @param[in] plugin_handle handle of data-converter plugin (result of dlopen for data-converter plugin)
+ * @param[in] error_code as returned by plugin_get_data_converter_func_set() - plugin error
+ * @return plugin_data_converter_func_set_s instance
+ */
+plugin_data_converter_func_set_s plugin_get_data_converter_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register data-converter plugin instance to the data-converter plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_data_converter_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_data_converter(plugin_data_converter_s plugin);
+
+/**
+ * @brief Clear data-converter plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_data_converter();
+
+/**
+ * @brief Get data-converter plugin repository
+ * @param[in] count as returned by plugin_get_data_converter_plugin_repository() - the number of data-converter plugin
+ * @return data-converter plugin repository being maintained as a singleton
+ */
+const plugin_data_converter_s *plugin_get_data_converter_plugin_repository(int *count);
+
+/**
+ * @brief Get function pointer of plugin_converter_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_converter_cb on success, NULL on error
+ */
+plugin_converter_cb plugin_get_function_converter(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_replace_converter_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_replace_converter_cb on success, NULL on error
+ */
+plugin_replace_converter_cb plugin_get_function_replace_converter(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_reverse_converter_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_reverse_converter_cb on success, NULL on error
+ */
+plugin_reverse_converter_cb plugin_get_function_reverse_converter(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_alloc_object_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_alloc_object_cb on success, NULL on error
+ */
+plugin_alloc_object_cb plugin_get_function_alloc_object(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_free_object_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_free_object_cb on success, NULL on error
+ */
+plugin_free_object_cb plugin_get_function_free_object(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_value_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_set_value_cb on success, NULL on error
+ */
+plugin_set_value_cb plugin_get_function_set_value_to_object(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_value_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_get_value_cb on success, NULL on error
+ */
+plugin_get_value_cb plugin_get_function_get_value_to_object(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_obj_info_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_get_obj_info_cb on success, NULL on error
+ */
+plugin_get_obj_info_cb plugin_get_function_get_obj_info(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_free_obj_info_cb
+ * @param[in] plugin_id data-converter plugin id
+ * @return function pointer of plugin_free_obj_info_cb on success, NULL on error
+ */
+plugin_free_obj_info_cb plugin_get_function_free_obj_info(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DATA_CONVERTER_PLUGIN_H_ */
diff --git a/src/framework/plugin/device_info_plugin.c b/src/framework/plugin/device_info_plugin.c
new file mode 100755 (executable)
index 0000000..682d060
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "utility/sync_util.h"
+#include "plugin/device_info_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_device_info = 0;
+
+static plugin_device_info_s plugin_repository[PLUGIN_MAX_DEVICE_INFO];
+
+static int _find_device_info_plugin(int plugin_id);
+
+plugin_device_info_func_set_s plugin_get_device_info_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_device_info_func_set_s func_set;
+
+       func_set.func_load_devinfo = dlsym(plugin_handle, "sync_agent_plugin_load_devinfo");
+       func_set.func_get_devinfo = dlsym(plugin_handle, "sync_agent_plugin_get_devinfo");
+       func_set.func_clear_devinfo = dlsym(plugin_handle, "sync_agent_plugin_clear_devinfo");
+       func_set.func_execute_dev_function = dlsym(plugin_handle, "sync_agent_plugin_execute_dev_function");
+       func_set.func_set_common_devinfo_function = dlsym(plugin_handle, "sync_agent_plugin_set_common_devinfo_function");
+       func_set.func_set_common_execute_dev_function = dlsym(plugin_handle, "sync_agent_plugin_set_common_execute_dev_function");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_device_info(plugin_device_info_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_device_info >= PLUGIN_MAX_DEVICE_INFO) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugin_repository[current_plugin_count_device_info] = plugin;
+
+       current_plugin_count_device_info++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_device_info()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_device_info; i++) {
+               memset(&(plugin_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugin_repository[i].func_set), 0x00, sizeof(plugin_device_info_func_set_s));
+               memset(&(plugin_repository[i]), 0x00, sizeof(plugin_device_info_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_device_info_s *plugin_get_device_info_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_device_info;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+int plugin_is_exsist_device_info_plugin(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_device_info < 1) {
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int plugin_get_device_info_plugin_id_list(int **plugin_id_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_device_info <= 0) {
+               return 0;
+       }
+
+       *plugin_id_list = (int *)calloc(current_plugin_count_device_info, sizeof(int));
+       if (*plugin_id_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+
+       int i = 0;
+       for (; i < current_plugin_count_device_info; i++) {
+               (*plugin_id_list)[i] = plugin_repository[i].plugin_info.plugin_id;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return current_plugin_count_device_info;
+}
+
+plugin_load_devinfo_cb plugin_get_function_load_devinfo(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_load_devinfo;
+}
+
+plugin_get_devinfo_cb plugin_get_function_get_devinfo(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_devinfo;
+}
+
+plugin_clear_devinfo_cb plugin_get_function_clear_devinfo(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_clear_devinfo;
+}
+
+plugin_execute_dev_function_cb plugin_get_function_execute_dev_function(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_execute_dev_function;
+}
+
+plugin_set_common_devinfo_function_cb plugin_get_function_set_common_devinfo_function(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_common_devinfo_function;
+}
+
+plugin_set_common_execute_dev_function_cb plugin_get_function_set_common_execute_dev_function(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_info_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_common_execute_dev_function;
+}
+
+static int _find_device_info_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_device_info; i++) {
+               if (plugin_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+/* TODO */
+/*
+Execute_Dev_App_Install getFunction_DeviceInfo_Execute_Dev_App_Install(int plugIn_id)
+{
+      int index = __findPlugIn_DeviceInfo(plugIn_id);
+      _DEBUG_INFO("index : %d", index);
+
+      return plugIn_repository[index].func_set.pFunc_Execute_Dev_App_Install;
+}
+
+Execute_Dev_App_UnInstall getFunction_DeviceInfo_Execute_Dev_App_UnInstall(int plugIn_id)
+{
+      int index = __findPlugIn_DeviceInfo(plugIn_id);
+      _DEBUG_INFO("index : %d", index);
+
+      return plugIn_repository[index].func_set.pFunc_Execute_Dev_App_UnInstall;
+}
+
+Execute_Dev_App_Activate getFunction_DeviceInfo_Execute_Dev_App_Activate(int plugIn_id)
+{
+      int index = __findPlugIn_DeviceInfo(plugIn_id);
+      _DEBUG_INFO("index : %d", index);
+
+      return plugIn_repository[index].func_set.pFunc_Execute_Dev_App_Activate;
+}
+*/
diff --git a/src/framework/plugin/device_info_plugin.h b/src/framework/plugin/device_info_plugin.h
new file mode 100755 (executable)
index 0000000..fa2ffe4
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_INFO_PLUGIN_H_
+#define DEVICE_INFO_PLUGIN_H_
+
+#include <glib.h>
+#include <stdarg.h>
+
+#include "struct.h"
+#include "error.h"
+#include "device/information.h"
+#include "device/executor.h"
+
+/**
+ * @file device_info_plugin.h
+ * @brief      Provides function pointer manipulate operation for device info module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of device-info plugin
+ */
+#define PLUGIN_MAX_DEVICE_INFO 10
+
+/**
+ * @brief Prototype of plugin function for getting device information in the system and load this information on the memory
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_load_devinfo_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for getting device information on the memory that user want to know
+ * @param[in] info_name name of device information
+ * @param[in] value as returned by plugin_get_devinfo_cb - value of device information
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_get_devinfo_cb) (char *info_name, char **value);
+
+/**
+ * @brief Prototype of plugin function for clearing device information on the memory (free memory)
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_clear_devinfo_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for executing device function
+ * @param[in] function_name name of device function
+ * @param[in] args_cnt number of following parameters
+ * @param[in] ap varius type of parameters
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_execute_dev_function_cb) (char *function_name, int args_cnt, va_list ap);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to get device common info
+ * @param[in] func callback function for getting particular device information on the memory
+ */
+typedef void (*plugin_set_common_devinfo_function_cb) (sync_agent_get_devinfo_cb func);
+
+/**
+ * @brief Prototype of plugin function for setting callback function to execute device common feature
+ * @param[in] func callback function for executing particular device feature
+ */
+typedef void (*plugin_set_common_execute_dev_function_cb) (sync_agent_execute_dev_cb func);
+
+/* TODO: */
+/*
+typedef int (*Execute_Dev_App_Install)(char *file_name, char *application_id);
+typedef int (*Execute_Dev_App_UnInstall)(char *application_id);
+typedef int (*Execute_Dev_App_Activate)(char *application_id, int activate_status);
+*/
+
+/**
+ * @brief Structure for device-info plugin function pointer set
+ */
+typedef struct {
+       plugin_load_devinfo_cb func_load_devinfo; /**< function pointer of plugin_load_devinfo_cb */
+       plugin_get_devinfo_cb func_get_devinfo; /**< function pointer of plugin_get_devinfo_cb */
+       plugin_clear_devinfo_cb func_clear_devinfo; /**< function pointer of plugin_clear_devinfo_cb */
+
+       /* execute function */
+       plugin_execute_dev_function_cb func_execute_dev_function; /**< function pointer of plugin_execute_dev_function_cb */
+       plugin_set_common_devinfo_function_cb func_set_common_devinfo_function; /**< function pointer of plugin_set_common_devinfo_function_cb */
+       plugin_set_common_execute_dev_function_cb func_set_common_execute_dev_function; /**< function pointer of plugin_set_common_execute_dev_function_cb */
+
+        /*TODO*/
+           /*
+              Execute_Dev_App_Install pFunc_Execute_Dev_App_Install;
+              Execute_Dev_App_UnInstall pFunc_Execute_Dev_App_UnInstall;
+              Execute_Dev_App_Activate pFunc_Execute_Dev_App_Activate;
+            */
+} plugin_device_info_func_set_s;
+
+/**
+ * @brief Structure for device-info plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_device_info_func_set_s func_set; /**< device-info plugin function pointer set */
+} plugin_device_info_s;
+
+/**
+ * @brief Get device-info plugin function pointer set
+ * @param[in] plugin_handle handle of device-info plugin (result of dlopen for device-info plugin)
+ * @param[in] error_code as returned by plugin_get_device_info_func_set() - plugin error
+ * @return plugin_device_info_func_set_s instance
+ */
+plugin_device_info_func_set_s plugin_get_device_info_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register device-info plugin instance to the device-info plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_device_info_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_device_info(plugin_device_info_s plugin);
+
+/**
+ * @brief Clear device-info plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_device_info();
+
+/**
+ * @brief Get device-info plugin repository
+ * @param[in] count as returned by plugin_get_device_info_plugin_repository() - the number of data-converter plugin
+ * @return device-info plugin repository being maintained as a singleton
+ */
+const plugin_device_info_s *plugin_get_device_info_plugin_repository(int *count);
+
+/**
+ * @brief Confirm whether device info plugin exist
+ * @return 1 exist, 0 not exist
+ */
+int plugin_is_exsist_device_info_plugin(void);
+
+/**
+ * @brief Get list of device-info plugin id
+ * @param[in] plugin_id_list as returned by plugin_get_device_info_plugin_id_list() - list of device-info plugin id
+ * @return the number of device-info plugin on success (positive value), 0 on error
+ */
+int plugin_get_device_info_plugin_id_list(int **plugin_id_list);
+
+/**
+ * @brief Get function pointer of plugin_load_devinfo_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_load_devinfo_cb on success, NULL on error
+ */
+plugin_load_devinfo_cb plugin_get_function_load_devinfo(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_devinfo_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_get_devinfo_cb on success, NULL on error
+ */
+plugin_get_devinfo_cb plugin_get_function_get_devinfo(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_clear_devinfo_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_clear_devinfo_cb on success, NULL on error
+ */
+plugin_clear_devinfo_cb plugin_get_function_clear_devinfo(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_execute_dev_function_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_execute_dev_function_cb on success, NULL on error
+ */
+plugin_execute_dev_function_cb plugin_get_function_execute_dev_function(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_common_devinfo_function_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_set_common_devinfo_function_cb on success, NULL on error
+ */
+plugin_set_common_devinfo_function_cb plugin_get_function_set_common_devinfo_function(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_common_execute_dev_function_cb
+ * @param[in] plugin_id device-info plugin id
+ * @return function pointer of plugin_set_common_execute_dev_function_cb on success, NULL on error
+ */
+plugin_set_common_execute_dev_function_cb plugin_get_function_set_common_execute_dev_function(int plugin_id);
+
+/* TODO: */
+/*
+Execute_Dev_App_Install getFunction_DeviceInfo_Execute_Dev_App_Install(int plugIn_id);
+Execute_Dev_App_UnInstall getFunction_DeviceInfo_Execute_Dev_App_UnInstall(int plugIn_id);
+Execute_Dev_App_Activate getFunction_DeviceInfo_Execute_Dev_App_Activate(int plugIn_id);
+*/
+
+/**
+ *     @}
+ */
+
+#endif                         /* DEVICE_INFO_PLUGIN_H_ */
diff --git a/src/framework/plugin/device_manager_plugin.c b/src/framework/plugin/device_manager_plugin.c
new file mode 100755 (executable)
index 0000000..1aac3b0
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "utility/sync_util.h"
+#include "plugin/device_manager_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_device_manager = 0;
+
+static plugin_device_manager_s plugin_repository[PLUGIN_MAX_DEVICE_MANAGER];
+
+static int _find_device_manager_plugin(int plugin_id);
+
+plugin_device_manager_func_set_s plugin_get_device_manager_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_device_manager_func_set_s func_set;
+
+       func_set.func_start_service = dlsym(plugin_handle, "sync_agent_plugin_start_service");
+       func_set.func_stop_service = dlsym(plugin_handle, "sync_agent_plugin_stop_service");
+       func_set.func_set_device_manager_value = dlsym(plugin_handle, "sync_agent_plugin_set_device_manager_value");
+       func_set.func_get_device_manager_value = dlsym(plugin_handle, "sync_agent_plugin_get_device_manager_value");
+       func_set.func_execute_device_manager = dlsym(plugin_handle, "sync_agent_plugin_execute_device_manager");
+       func_set.func_register_device_manager_callback = dlsym(plugin_handle, "sync_agent_plugin_register_device_manager_cb");
+       func_set.func_deregister_device_manager_callback = dlsym(plugin_handle, "sync_agent_plugin_deregister_device_manager_cb");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_device_manager(plugin_device_manager_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_device_manager >= PLUGIN_MAX_DEVICE_MANAGER) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugin_repository[current_plugin_count_device_manager++] = plugin;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_device_manager()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_device_manager; i++) {
+               memset(&(plugin_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugin_repository[i].func_set), 0x00, sizeof(plugin_device_manager_func_set_s));
+               memset(&(plugin_repository[i]), 0x00, sizeof(plugin_device_manager_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_device_manager_s *plugin_get_device_manager_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_device_manager;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+plugin_start_service_cb plugin_get_function_start_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_start_service;
+}
+
+plugin_stop_service_cb plugin_get_function_stop_service(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_stop_service;
+}
+
+plugin_set_device_manager_value_cb plugin_get_function_set_device_manager_value(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_device_manager_value;
+}
+
+plugin_get_device_manager_value_cb plugin_get_function_get_device_manager_value(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_device_manager_value;
+}
+
+plugin_execute_device_manager_cb plugin_get_function_execute_device_manager(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_execute_device_manager;
+}
+
+plugin_register_device_manager_callback_cb plugin_get_function_register_device_manager_callback(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_register_device_manager_callback;
+}
+
+plugin_deregister_device_manager_callback_cb plugin_get_function_deregister_device_manager_callback(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_device_manager_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_deregister_device_manager_callback;
+}
+
+static int _find_device_manager_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_device_manager; i++) {
+               if (plugin_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+       return -1;
+}
diff --git a/src/framework/plugin/device_manager_plugin.h b/src/framework/plugin/device_manager_plugin.h
new file mode 100755 (executable)
index 0000000..b9dd140
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEVICE_MANAGER_PLUGIN_H_
+#define DEVICE_MANAGER_PLUGIN_H_
+
+#include <glib.h>
+
+#include "struct.h"
+#include "error.h"
+#include "device-manager/mdm_type.h"
+#include "device-manager/mdm_error.h"
+#include "device-manager/mdm_control_code.h"
+
+/**
+ * @file device_manager_plugin.h
+ * @brief      Provides function pointer manipulate operation for device manager module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of device-manager plugin
+ */
+#define PLUGIN_MAX_DEVICE_MANAGER 1
+
+/**
+ * @brief Prototype of plugin function for registering client to the service
+ * @param[in] pkg_name client package name
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_start_service_cb) (char *pkg_name);
+
+/**
+ * @brief Prototype of plugin function for deregistering client to the service
+ * @param[in] pkg_name client package name
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_stop_service_cb) (char *pkg_name);
+
+/**
+ * @brief Prototype of plugin function for setting user value to the service
+ * @param[in] ctrl item that user want to set
+ * @param[in] va user value
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_set_device_manager_value_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * @brief Prototype of plugin function for getting value that user want to know
+ * @param[in] ctrl item that user want to know
+ * @param[in] va as returned by plugin_get_device_manager_value_cb - service value
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_get_device_manager_value_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * @brief Prototype of plugin function for executing service that user want to do
+ * @param[in] ctrl item that user want to execute
+ * @param[in] va user value
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_execute_device_manager_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
+
+/**
+ * @brief Prototype of plugin function for registering user callback function for each service event
+ * @remarks not supported api
+ * @param[in] event service event
+ * @param[in] callback user callback function
+ * @param[in] user_data additional user data
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef int (*plugin_register_device_manager_callback_cb) (sync_agent_dm_mdm_event_e event, sync_agent_device_manager_cb callback, void *user_data);
+
+/**
+ * @brief Prototype of plugin function for deregistering user callback function that was previously registered to the service
+ * @remarks not supported api
+ * @param[in] handle
+ * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
+ */
+typedef sync_agent_dm_mdm_return_e(*plugin_deregister_device_manager_callback_cb) (int handle);
+
+/**
+ * @brief Structure for device-manager plugin function pointer set
+ */
+typedef struct {
+       plugin_start_service_cb func_start_service; /**< function pointer of plugin_start_service_cb */
+       plugin_stop_service_cb func_stop_service; /**< function pointer of plugin_stop_service_cb */
+       plugin_set_device_manager_value_cb func_set_device_manager_value; /**< function pointer of plugin_set_device_manager_value_cb */
+       plugin_get_device_manager_value_cb func_get_device_manager_value; /**< function pointer of plugin_get_device_manager_value_cb */
+       plugin_execute_device_manager_cb func_execute_device_manager; /**< function pointer of plugin_execute_device_manager_cb */
+       plugin_register_device_manager_callback_cb func_register_device_manager_callback; /**< function pointer of plugin_register_device_manager_callback_cb */
+       plugin_deregister_device_manager_callback_cb func_deregister_device_manager_callback; /**< function pointer of plugin_deregister_device_manager_callback_cb */
+} plugin_device_manager_func_set_s;
+
+/**
+ * @brief Structure for device-manager plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_device_manager_func_set_s func_set; /**< device-manager plugin function pointer set */
+} plugin_device_manager_s;
+
+/**
+ * @brief Get device-manager plugin function pointer set
+ * @param[in] plugin_handle handle of device-manager plugin (result of dlopen for device-manager plugin)
+ * @param[in] error_code as returned by plugin_get_device_manager_func_set() - plugin error
+ * @return plugin_device_manager_func_set_s instance
+ */
+plugin_device_manager_func_set_s plugin_get_device_manager_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register device-manager plugin instance to the device-manager plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_device_manager_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_device_manager(plugin_device_manager_s plugin);
+
+/**
+ * @brief Clear device-manager plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_device_manager();
+
+/**
+ * @brief Get device-manager plugin repository
+ * @param[in] count as returned by plugin_get_device_manager_plugin_repository() - the number of device-manager plugin
+ * @return device-manager plugin repository being maintained as a singleton
+ */
+const plugin_device_manager_s *plugin_get_device_manager_plugin_repository(int *count);
+
+/**
+ * @brief Get function pointer of plugin_start_service_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_start_service_cb on success, NULL on error
+ */
+plugin_start_service_cb plugin_get_function_start_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_stop_service_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_stop_service_cb on success, NULL on error
+ */
+plugin_stop_service_cb plugin_get_function_stop_service(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_device_manager_value_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_set_device_manager_value_cb on success, NULL on error
+ */
+plugin_set_device_manager_value_cb plugin_get_function_set_device_manager_value(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_device_manager_value_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_get_device_manager_value_cb on success, NULL on error
+ */
+plugin_get_device_manager_value_cb plugin_get_function_get_device_manager_value(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_execute_device_manager_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_execute_device_manager_cb on success, NULL on error
+ */
+plugin_execute_device_manager_cb plugin_get_function_execute_device_manager(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_device_manager_register_callback_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_device_manager_register_callback_cb on success, NULL on error
+ */
+plugin_register_device_manager_callback_cb plugin_get_function_register_device_manager_callback(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_device_manager_deregister_callback_cb
+ * @param[in] plugin_id device-manager plugin id
+ * @return function pointer of plugin_device_manager_deregister_callback_cb on success, NULL on error
+ */
+plugin_deregister_device_manager_callback_cb plugin_get_function_deregister_device_manager_callback(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* DEVICE_MANAGER_PLUGIN_H_ */
diff --git a/src/framework/plugin/error.h b/src/framework/plugin/error.h
new file mode 100755 (executable)
index 0000000..f1aafc3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_ERROR_H_
+#define PLUGIN_ERROR_H_
+
+/**
+ * @file error.h
+ * @brief      Defines plugin errors
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+   @brief Error Code about Operation result concern with Plug-In
+ */
+typedef enum {
+       PLUGIN_SUCCESS, /**< when Plug In Operation is succeed */
+       PLUGIN_FAIL, /**< when Plug In Operation is failed */
+       PLUGIN_LOAD_FAIL, /**< when Plug In Operation is failed for loading */
+       PLUGIN_DEPENDENCY_FAIL, /**< when Plug In Operation is failed because dependency */
+       PLUGIN_FULL_CAPACITY, /**< when Plug In Operation is failed for full capacity */
+       PLUGIN_INVALID_PARAM, /**< when Plug In Operation is failed for invalid parameter */
+       PLUGIN_UNLOAD_FAIL, /**< when Plug In Operation is failed for unloading */
+} plugin_error_e;
+
+/**
+ *     @}
+ */
+
+#endif                         /* PLUGIN_ERROR_H_ */
diff --git a/src/framework/plugin/manager.c b/src/framework/plugin/manager.c
new file mode 100755 (executable)
index 0000000..8f16af9
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "utility/sync_util.h"
+
+#include "plugin/manager.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+void *plugin_load_plugin(const char *plugin_path, plugin_error_e * error)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error = PLUGIN_SUCCESS;
+
+//      void *handler = dlopen(plugin_path, RTLD_LAZY);
+       void *handler = dlopen(plugin_path, RTLD_NOW);
+       if (handler == NULL) {
+               _DEBUG_ERROR("dlopen error msg : %s", dlerror());
+               *error = PLUGIN_LOAD_FAIL;
+       } else {
+               _DEBUG_INFO("plugin_handle : %d", handler);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return handler;
+}
+
+//plugin_error_e plugin_unload_plugin(plugin_domain_e domain, const char *plugin_name)
+//{
+//      _EXTERN_FUNC_ENTER;
+//
+//      _EXTERN_FUNC_EXIT;
+//
+//      return PLUGIN_SUCCESS;
+//}
+
+plugin_error_e plugin_unload_plugin(void *plugin_handle)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_error_e plugin_err = PLUGIN_SUCCESS;
+
+       if (plugin_handle != NULL) {
+               _DEBUG_INFO("plugin_handle : %d", plugin_handle);
+               int result = dlclose(plugin_handle);
+               if (result != 0) {
+                       _DEBUG_ERROR("dlclose error msg : %s", dlerror());
+                       plugin_err = PLUGIN_UNLOAD_FAIL;
+               } else {
+                       _DEBUG_INFO("dlclose() success !!");
+               }
+       } else {
+               _DEBUG_INFO("plugin_handle is NULL !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_err;
+}
diff --git a/src/framework/plugin/manager.h b/src/framework/plugin/manager.h
new file mode 100755 (executable)
index 0000000..7593a87
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_MANAGER_H_
+#define PLUGIN_MANAGER_H_
+
+#include "plugin/error.h"
+
+/**
+ * @file manager.h
+ * @brief      Defines plugin manager operation
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Enumerations for plugin domain
+ */
+typedef enum {
+       PLUGIN_DATA_CONNECTOR = 0, /**< data-connector */
+       PLUGIN_DATA_CONVERTER, /**< data-converter */
+       PLUGIN_NETWORK_ACCESS, /**< network-access */
+       PLUGIN_ACCOUNT, /**< account */
+       PLUGIN_DEVICE_INFO, /**< device-info */
+       PLUGIN_MO, /**< mo */
+       PLUGIN_DEVICE_MANAGER, /**< device-manager */
+       PLUGIN_PLATFORM_MONITOR, /**< platform-monitor */
+
+       PLUGIN_DOMAIN_CNT
+} plugin_domain_e;
+
+/**
+ * @brief      Load the Plug-In
+ * Received a Plug-In as a parameter will be loaded
+ * @param[in]  plugin_path To Load Plug-In's path
+ * @param[in] error as returned by plugin_load_plugin() - Error Code
+ * @return plugIn handle on succeed , NULL on error
+ */
+void *plugin_load_plugin(const char *plugin_path, plugin_error_e * error);
+
+/**
+ * @brief UnLoad the Plug-In
+ * By default, Received a Plug-In as a parameter will be Unloaded
+ * but If another Plug-In is dependent on Plug-In, this function will be failed
+ * @param[in] domain To Load Plug-In's domain name (ex) SA, DataConnector, NetworkAccess ...
+ * @param[in] plugin_name To Load Plug-In's name
+ * @return PLUGIN_SUCCESS on success, otherwise error
+ */
+//plugin_error_e plugin_unload_plugin(plugin_domain_e domain, const char *plugin_name);
+
+/**
+ * @brief Unload the plug-in
+ * @param[in] plugin_handle plugin handle
+ * @return PLUGIN_SUCCESS on success, otherwise error
+ */
+plugin_error_e plugin_unload_plugin(void *plugin_handle);
+
+/**
+ *     @}
+ */
+
+#endif                         /* PLUGIN_MANAGER_H_ */
diff --git a/src/framework/plugin/mo_plugin.c b/src/framework/plugin/mo_plugin.c
new file mode 100755 (executable)
index 0000000..e19a2f3
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "utility/sync_util.h"
+#include "plugin/mo_plugin.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_mo = 0;
+
+static plugin_mo_s plugin_repository[PLUGIN_MAX_MO];
+
+static int _find_mo_plugin(int plugin_id);
+
+plugin_mo_func_set_s plugin_get_mo_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_mo_func_set_s func_set;
+
+       func_set.func_get_mo_value = dlsym(plugin_handle, "sync_agent_plugin_get_mo_value");
+       func_set.func_setfunc_get_device_info = dlsym(plugin_handle, "sync_agent_plugin_set_function_get_devinfo");
+       func_set.func_execute_ext = dlsym(plugin_handle, "sync_agent_plugin_execute_ext");
+       func_set.func_get_server_id_list = dlsym(plugin_handle, "sync_agent_plugin_get_server_id_list");
+       func_set.func_initialize = dlsym(plugin_handle, "sync_agent_plugin_initialize");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_mo(plugin_mo_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_mo >= PLUGIN_MAX_MO) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugin_repository[current_plugin_count_mo] = plugin;
+
+       current_plugin_count_mo++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_mo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_mo; i++) {
+               memset(&(plugin_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugin_repository[i].func_set), 0x00, sizeof(plugin_mo_func_set_s));
+               memset(&(plugin_repository[i]), 0x00, sizeof(plugin_mo_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_mo_s *plugin_get_mo_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_mo;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+int plugin_get_mo_plugin_id(sync_agent_dm_mo_type_e mo_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_mo; i++) {
+               if (plugin_repository[i].mo_type == mo_type) {
+                       _EXTERN_FUNC_EXIT;
+                       return plugin_repository[i].plugin_info.plugin_id;
+               }
+       }
+
+       return -1;
+}
+
+int plugin_get_mo_plugin_id_list(int **plugin_id_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_mo <= 0) {
+               return 0;
+       }
+
+       *plugin_id_list = (int *)calloc(current_plugin_count_mo, sizeof(int));
+       if (*plugin_id_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+
+       int i = 0;
+       for (; i < current_plugin_count_mo; i++) {
+               (*plugin_id_list)[i] = plugin_repository[i].plugin_info.plugin_id;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return current_plugin_count_mo;
+}
+
+plugin_get_server_id_list_cb plugin_get_function_get_server_id_list(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_mo_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_server_id_list;
+}
+
+plugin_get_mo_value_cb plugin_get_function_get_mo_value(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_mo_plugin(plugin_id);
+       _DEBUG_INFO("PLUGIN index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_mo_value;
+}
+
+plugin_set_func_get_device_info plugin_get_function_set_func_get_device_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_mo_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_setfunc_get_device_info;
+}
+
+plugin_execute_ext plugin_get_function_execute_ext(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_mo_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_execute_ext;
+}
+
+plugin_initialize plugin_get_function_initialize(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_mo_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_initialize;
+}
+
+static int _find_mo_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_mo; i++) {
+               if (plugin_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/plugin/mo_plugin.h b/src/framework/plugin/mo_plugin.h
new file mode 100755 (executable)
index 0000000..3649237
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MO_PLUGIN_H_
+#define MO_PLUGIN_H_
+
+#include "device/information.h"
+#include "device/error.h"
+#include "device-manager/mo_struct.h"
+
+#include "error.h"
+#include "struct.h"
+
+/**
+ * @file mo_plugin.h
+ * @brief      Provides function pointer manipulate operation for mo module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+#define PLUGIN_MAX_MO  15
+
+typedef char **(*plugin_get_server_id_list_cb) (int *server_id_list_cnt);
+
+typedef int (*plugin_get_mo_value_cb) (const char *mo_pull_path, const char *mo_name, char **mo_value);
+
+typedef void (*plugin_set_func_get_device_info) (sync_agent_get_devinfo_cb func);
+
+typedef int (*plugin_execute_ext) (const char *mo_path, int *err_num, int check_operation);
+
+typedef int (*plugin_initialize) ();
+
+typedef struct {
+       plugin_get_server_id_list_cb func_get_server_id_list;
+       plugin_get_mo_value_cb func_get_mo_value;
+       plugin_set_func_get_device_info func_setfunc_get_device_info;
+       plugin_execute_ext func_execute_ext;
+       plugin_initialize func_initialize;
+} plugin_mo_func_set_s;
+
+typedef struct {
+       plugin_info_s plugin_info;
+       plugin_mo_func_set_s func_set;
+       sync_agent_dm_mo_type_e mo_type;
+} plugin_mo_s;
+
+plugin_mo_func_set_s plugin_get_mo_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+plugin_error_e plugin_register_plugin_mo(plugin_mo_s plugin);
+
+/**
+ * @brief Clear mo plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_mo();
+
+/**
+ * @brief Get mo plugin repository
+ * @param[in] count as returned by plugin_get_mo_plugin_repository() - the number of mo plugin
+ * @return mo plugin repository being maintained as a singleton
+ */
+const plugin_mo_s *plugin_get_mo_plugin_repository(int *count);
+
+int plugin_get_mo_plugin_id(sync_agent_dm_mo_type_e mo_type);
+
+int plugin_get_mo_plugin_id_list(int **plugin_id_list);
+
+plugin_get_server_id_list_cb plugin_get_function_get_server_id_list(int plugin_id);
+
+plugin_get_mo_value_cb plugin_get_function_get_mo_value(int plugin_id);
+
+plugin_set_func_get_device_info plugin_get_function_set_func_get_device_info(int plugin_id);
+
+plugin_execute_ext plugin_get_function_execute_ext(int plugin_id);
+
+plugin_initialize plugin_get_function_initialize(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* MO_PLUGIN_H_ */
diff --git a/src/framework/plugin/network_access_plugin.c b/src/framework/plugin/network_access_plugin.c
new file mode 100755 (executable)
index 0000000..b991206
--- /dev/null
@@ -0,0 +1,366 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "plugin/network_access_plugin.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_network_access = 0;
+
+static plugin_network_access_s plugin_repository[PLUGIN_MAX_NETWORK_ACCESS];
+
+static int _find_network_access_plugin(int plugin_id);
+
+plugin_network_access_func_set_s plugin_get_network_access_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *error_code = PLUGIN_SUCCESS;
+
+       plugin_network_access_func_set_s func_set;
+
+       func_set.func_open_connection = dlsym(plugin_handle, "sync_agent_plugin_open_connection");
+       func_set.func_header_binding = dlsym(plugin_handle, "sync_agent_plugin_header_binding");
+       func_set.func_send_message = dlsym(plugin_handle, "sync_agent_plugin_send_message");
+       func_set.func_header_unbinding = dlsym(plugin_handle, "sync_agent_plugin_header_unbinding");
+       func_set.func_close_connection = dlsym(plugin_handle, "sync_agent_plugin_close_connection");
+       func_set.func_cancel_message = dlsym(plugin_handle, "sync_agent_plugin_cancel_message");
+       func_set.func_just_send_message = dlsym(plugin_handle, "sync_agent_plugin_just_send_message");
+       func_set.func_get_header_info = dlsym(plugin_handle, "sync_agent_plugin_get_header_info");
+       func_set.func_set_data_down_info = dlsym(plugin_handle, "sync_agent_plugin_set_data_download_info");
+       func_set.func_get_data_down_info = dlsym(plugin_handle, "sync_agent_plugin_get_data_download_info");
+       func_set.func_add_authentication_info = dlsym(plugin_handle, "sync_agent_plugin_add_authentication_info");
+       func_set.func_register_fw_mainloop_na = dlsym(plugin_handle, "sync_agent_plugin_register_fw_main_loop_network_access");
+       func_set.func_set_property = dlsym(plugin_handle, "sync_agent_plugin_set_property");
+       func_set.func_get_status = dlsym(plugin_handle, "sync_agent_plugin_get_status");
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_network_access(plugin_network_access_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_network_access >= PLUGIN_MAX_NETWORK_ACCESS) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugin_repository[current_plugin_count_network_access] = plugin;
+
+       current_plugin_count_network_access++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_network_access()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < current_plugin_count_network_access; i++) {
+               memset(&(plugin_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugin_repository[i].func_set), 0x00, sizeof(plugin_network_access_func_set_s));
+               memset(&(plugin_repository[i]), 0x00, sizeof(plugin_network_access_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_network_access_s *plugin_get_network_access_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_network_access;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository;
+}
+
+int plugin_use_network(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       if (index == -1) {
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].use_network;
+}
+
+int plugin_get_network_access_plugin_id_list(int **plugin_id_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_network_access <= 0) {
+               return 0;
+       }
+
+       *plugin_id_list = (int *)calloc(current_plugin_count_network_access, sizeof(int));
+       if (*plugin_id_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+
+       int i = 0;
+       for (; i < current_plugin_count_network_access; i++) {
+               (*plugin_id_list)[i] = plugin_repository[i].plugin_info.plugin_id;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return current_plugin_count_network_access;
+}
+
+plugin_open_connection_cb plugin_get_function_connection(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_open_connection;
+}
+
+plugin_header_binding_cb plugin_get_function_header_binding(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_header_binding;
+}
+
+plugin_send_message_cb plugin_get_function_send_message(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_send_message;
+}
+
+plugin_header_unbinding_cb plugin_get_function_header_unbinding(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_header_unbinding;
+}
+
+plugin_close_connection_cb plugin_get_function_close_connection(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_close_connection;
+}
+
+plugin_cancel_message_cb plugin_get_function_cancel_message(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_cancel_message;
+}
+
+plugin_just_send_message_cb plugin_get_function_just_send_message(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_just_send_message;
+}
+
+plugin_get_header_info_cb plugin_get_function_get_header_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_header_info;
+}
+
+plugin_set_data_download_info_cb plugin_get_function_set_data_download_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_data_down_info;
+}
+
+plugin_get_data_download_info_cb plugin_get_function_get_data_download_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_data_down_info;
+}
+
+plugin_add_authentication_info_cb plugin_get_function_add_authentication_info(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_add_authentication_info;
+}
+
+plugin_register_fw_mainloop_na_cb plugin_get_function_register_fw_mainloop_na(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_register_fw_mainloop_na;
+}
+
+plugin_set_property_cb plugin_get_function_set_property(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_set_property;
+}
+
+plugin_get_status_cb plugin_get_function_get_status(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_network_access_plugin(plugin_id);
+       _DEBUG_INFO("index : %d", index);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugin_repository[index].func_set.func_get_status;
+}
+
+static int _find_network_access_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_network_access; i++) {
+               if (plugin_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/plugin/network_access_plugin.h b/src/framework/plugin/network_access_plugin.h
new file mode 100755 (executable)
index 0000000..8413065
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NETWORK_ACCESS_PLUGIN_H_
+#define NETWORK_ACCESS_PLUGIN_H_
+
+#include <glib.h>
+
+#include "struct.h"
+#include "error.h"
+#include "network-access/property.h"
+#include "network-access/status.h"
+
+/**
+ * @file network_access_plugin.h
+ * @brief      Provides function pointer manipulate operation for networ_access module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of network-access plugin
+ */
+#define PLUGIN_MAX_NETWORK_ACCESS      10
+
+/**
+ * @brief Prototype of plugin function for opening network connection
+ * @param[in] session as returned by plugin_open_connection_cb - network session information
+ * @param[in] proxy proxy information
+ * @param[in] timeout user preferred time-out seconds used in sending message (ex> 30 means 30seconds)
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_open_connection_cb) (void **session, char *proxy, int timeout);
+
+/**
+ * @brief Prototype of plugin function for binding header information for each network protocol
+ * @param[in] header_info header information for each network protocol
+ * @param[in] header_binding as returned by plugin_header_binding_cb - header information bound each network protocol
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_header_binding_cb) (GList * header_info, void **header_binding);
+
+/**
+ * @brief Prototype of plugin function for sending message to server and receive message from the server
+ * @param[in] session network session information
+ * @param[in] header_binding as returned by plugin_send_message_cb - header binding information
+ * @param[in] send_msg body message
+ * @param[in] send_msg_length length of body message
+ * @param[in] recv_msg_size as returned by plugin_send_message_cb - the size of received message from the server
+ * @return 1 on success, 0 on error
+ * @retval 0 operation failed
+ * @retval -1 cancel message
+ * @retval -8 try again
+ * @retval -408 request timeout
+ */
+typedef int (*plugin_send_message_cb) (void *session, void **header_binding, char *send_msg, unsigned int send_msg_length, unsigned int *recv_msg_size);
+
+/**
+ * @brief Prototype of plugin function for dividing header/body information using received message from the server
+ * @param[in] msg received message from the server
+ * @param[in] msg_size the size of received message from the server
+ * @param[in] recv_header as returned by plugin_header_unbinding_cb - header information of received message from the server
+ * @param[in] recv_msg as returned by plugin_header_unbinding_cb - information of received message from the server
+ * @param[in] recv_msg_length as returned by plugin_header_unbinding_cb - the length of body information
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_header_unbinding_cb) (void *msg, unsigned int msg_size, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length);
+
+/**
+ * @brief Prototype of plugin function for closing network connection
+ * @param[in] session network session information
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_close_connection_cb) (void *session);
+
+/**
+ * @brief Prototype of plugin function for cancel operation about message being sent to the server
+ * @param[in] session network session information
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_cancel_message_cb) (void *session);
+
+/**
+ * @brief Prototype of plugin function for just sending message to the server (do not receive message from the server)
+ * @param[in] session network session information
+ * @param[in] header_binding as returned by plugin_just_send_message_cb - header binding information
+ * @param[in] send_msg body message
+ * @param[in] send_msg_length length of body message
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_just_send_message_cb) (void *session, void **header_binding, char *send_msg, unsigned int send_msg_length);
+
+/**
+ * @brief Prototype of plugin function for getting network header information about specific keyword
+ * @param[in] header_info list of network header information (key-value pair)
+ * @param[in] key specific keyword of header information that user want to know
+ * @param[in] value as returned by plugin_get_header_info_cb - value for the key
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_get_header_info_cb) (GList * header_info, char *key, char **value);
+
+/**
+ * @brief Prototype of plugin function for setting download information(download range) to download header information of specific network protocol
+ * @param[in] down_info download header information of specific network protocol
+ * @param[in] current_down_range download current range
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_set_data_download_info_cb) (void *down_info, char *current_down_range);
+
+/**
+ * @brief Prototype of plugin function for getting download information(download range, filename) to download header information of specific network protocol
+ * @param[in] http_req_info http request information
+ * @param[in] down_info download header information of specific network protocol
+ * @param[in] total_down_size as returned by plugin_get_data_download_info_cb - total download size
+ * @param[in] current_down_range as returned by plugin_get_data_download_info_cb - current download range
+ * @param[in] down_file_name as retured by plugin_get_data_download_info_cb - download file name
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_get_data_download_info_cb) (void *http_req_info, void *down_info, int *total_down_size, char **current_down_range, char **down_file_name);
+
+/**
+ * @brief Prototype of plugin function for adding user authentication information (id, password) to session and
+ * @param[in] session network session information
+ * @param[in] id user id
+ * @param[in] password user password
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_add_authentication_info_cb) (void *session, char *id, char *password);
+
+/**
+ * @brief Prototype of plugin function for setting network communication property
+ * @param[in] session network session information
+ * @param[in] property network communication property (time out, retry count, ...)
+ * @param[in] va property value
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_set_property_cb) (void *session, sync_agent_na_property_e property, va_list va);
+
+/**
+ * @brief Prototype of plugin function for getting network communication status
+ * @param[in] session network session information
+ * @param[in] status network communication status (response code, elapsed time, connection time, ...)
+ * @param[in] va status value
+ * @return 1 on success, 0 on error
+ */
+typedef int (*plugin_get_status_cb) (void *session, sync_agent_na_status_e status, va_list va);
+
+/**
+ * @brief Prototype of plugin function for connecting service and registering to the sync-agent-framework mainloop for data connection
+ * @param[in] data user data (meaningless value)
+ * @return 1 on success, 0 on error
+ */
+typedef void (*plugin_register_fw_mainloop_na_cb) (void *data);
+
+/**
+ * @brief Structure for network-access plugin function pointer set
+ */
+typedef struct {
+       plugin_open_connection_cb func_open_connection; /**< function pointer of plugin_open_connection_cb */
+       plugin_header_binding_cb func_header_binding; /**< function pointer of plugin_header_binding_cb */
+       plugin_send_message_cb func_send_message; /**< function pointer of plugin_send_message_cb */
+       plugin_header_unbinding_cb func_header_unbinding; /**< function pointer of plugin_header_unbinding_cb */
+       plugin_close_connection_cb func_close_connection; /**< function pointer of plugin_close_connection_cb */
+       plugin_cancel_message_cb func_cancel_message; /**< function pointer of plugin_cancel_message_cb */
+       plugin_just_send_message_cb func_just_send_message; /**< function pointer of plugin_just_send_message_cb */
+       plugin_get_header_info_cb func_get_header_info; /**< function pointer of plugin_get_header_info_cb */
+       plugin_set_data_download_info_cb func_set_data_down_info; /**< function pointer of plugin_set_data_download_info_cb */
+       plugin_get_data_download_info_cb func_get_data_down_info; /**< function pointer of plugin_get_data_download_info_cb */
+       plugin_add_authentication_info_cb func_add_authentication_info; /**< function pointer of plugin_add_authentication_info_cb */
+       plugin_register_fw_mainloop_na_cb func_register_fw_mainloop_na; /**< function pointer of plugin_register_fw_mainloop_na_cb */
+       plugin_set_property_cb func_set_property; /**< function pointer of plugin_set_property_cb */
+       plugin_get_status_cb func_get_status; /**< function pointer of plugin_get_status_cb */
+} plugin_network_access_func_set_s;
+
+/**
+ * @brief Structure for network-access plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_network_access_func_set_s func_set; /**< account plugin function pointer set */
+       int use_network; /**< whether to use network */
+} plugin_network_access_s;
+
+/**
+ * @brief Get network-access plugin function pointer set
+ * @param[in] plugin_handle handle of network-access plugin (result of dlopen for network-access plugin)
+ * @param[in] error_code as returned by plugin_get_network_access_func_set() - plugin error
+ * @return plugin_network_access_func_set_s instance
+ */
+plugin_network_access_func_set_s plugin_get_network_access_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register network-access plugin instance to the network-access plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_network_access_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_network_access(plugin_network_access_s plugin);
+
+/**
+ * @brief Clear network-access plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_network_access();
+
+/**
+ * @brief Get network-access plugin repository
+ * param[in] count as returned by plugin_get_network_access_plugin_repository() - the number of network-access plugin
+ * @return network-access plugin repository being maintained as a singleton
+ */
+const plugin_network_access_s *plugin_get_network_access_plugin_repository(int *count);
+
+/**
+ * @brief Get use_network value
+ * @param[in] plugin plugin_network_access_s instance
+ * @return plugin_network_access_s's use_network value on success (1 or 0), -1 on error
+ */
+int plugin_use_network(int plugin_id);
+
+/**
+ * @brief Get list of network-access plugin id
+ * @param[in] plugin_id_list as returned by plugin_get_network_access_plugin_id_list() - list of network-access plugin id
+ * @return the number of network-access plugin on success (positive value), 0 on error
+ */
+int plugin_get_network_access_plugin_id_list(int **plugin_id_list);
+
+/**
+ * @brief Get function pointer of plugin_open_connection_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_open_connection_cb on success, NULL on error
+ */
+plugin_open_connection_cb plugin_get_function_connection(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_header_binding_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_header_binding_cb on success, NULL on error
+ */
+plugin_header_binding_cb plugin_get_function_header_binding(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_send_message_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_send_message_cb on success, NULL on error
+ */
+plugin_send_message_cb plugin_get_function_send_message(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_header_unbinding_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_header_unbinding_cb on success, NULL on error
+ */
+plugin_header_unbinding_cb plugin_get_function_header_unbinding(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_close_connection_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_close_connection_cb on success, NULL on error
+ */
+plugin_close_connection_cb plugin_get_function_close_connection(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_cancel_message_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_cancel_message_cb on success, NULL on error
+ */
+plugin_cancel_message_cb plugin_get_function_cancel_message(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_just_send_message_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_just_send_message_cb on success, NULL on error
+ */
+plugin_just_send_message_cb plugin_get_function_just_send_message(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_header_info_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_get_header_info_cb on success, NULL on error
+ */
+plugin_get_header_info_cb plugin_get_function_get_header_info(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_data_download_info_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_set_data_download_info_cb on success, NULL on error
+ */
+plugin_set_data_download_info_cb plugin_get_function_set_data_download_info(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_data_download_info_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_get_data_download_info_cb on success, NULL on error
+ */
+plugin_get_data_download_info_cb plugin_get_function_get_data_download_info(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_authentication_info_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_add_authentication_info_cb on success, NULL on error
+ */
+plugin_add_authentication_info_cb plugin_get_function_add_authentication_info(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_register_fw_mainloop_na_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_register_fw_mainloop_na_cb on success, NULL on error
+ */
+plugin_register_fw_mainloop_na_cb plugin_get_function_register_fw_mainloop_na(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_property_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_set_property_cb on success, NULL on error
+ */
+plugin_set_property_cb plugin_get_function_set_property(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_status_cb
+ * @param[in] plugin_id network-access plugin id
+ * @return function pointer of plugin_get_status_cb on success, NULL on error
+ */
+plugin_get_status_cb plugin_get_function_get_status(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* NETWORK_ACCESS_PLUGIN_H_ */
diff --git a/src/framework/plugin/platform_monitor_plugin.c b/src/framework/plugin/platform_monitor_plugin.c
new file mode 100755 (executable)
index 0000000..743da3a
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "plugin/platform_monitor_plugin.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PlugIn"
+#endif
+
+static int current_plugin_count_platform_monitor = 0;
+
+static plugin_platform_monitor_s plugIn_repository[PLUGIN_MAX_PLATFORM_MONITOR];
+
+static int _find_platform_monitor_plugin(int plugin_id);
+
+plugin_platform_monitor_func_set_s plugin_get_platform_monitor_func_set(void *plugin_handle, plugin_error_e * error_code)
+{
+       _EXTERN_FUNC_ENTER;
+
+       plugin_platform_monitor_func_set_s func_set;
+
+       func_set.func_init_service_noti = dlsym(plugin_handle, "sync_agent_plugin_init_service_noti");
+       func_set.func_unregister_service_noti = dlsym(plugin_handle, "sync_agent_plugin_unregister_service_noti");
+       func_set.func_add_service_data = dlsym(plugin_handle, "sync_agent_plugin_add_service_data");
+       func_set.func_remove_service_data = dlsym(plugin_handle, "sync_agent_plugin_remove_service_data");
+       func_set.func_get_service_data = dlsym(plugin_handle, "sync_agent_plugin_get_service_data");
+       func_set.func_set_user_callback = dlsym(plugin_handle, "sync_agent_plugin_set_user_callback");
+
+       *error_code = PLUGIN_SUCCESS;   /* todo */
+
+       _EXTERN_FUNC_EXIT;
+
+       return func_set;
+}
+
+plugin_error_e plugin_register_plugin_platform_monitor(plugin_platform_monitor_s plugin)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_platform_monitor >= PLUGIN_MAX_PLATFORM_MONITOR) {
+               return PLUGIN_FULL_CAPACITY;
+       }
+
+       plugIn_repository[current_plugin_count_platform_monitor] = plugin;
+
+       current_plugin_count_platform_monitor++;
+
+       _EXTERN_FUNC_EXIT;
+
+       return PLUGIN_SUCCESS;
+}
+
+void plugin_clear_plugin_platform_monitor()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i;
+       int j;
+       for (i = 0; i < current_plugin_count_platform_monitor; i++) {
+               memset(&(plugIn_repository[i].plugin_info), 0x00, sizeof(plugin_info_s));
+               memset(&(plugIn_repository[i].func_set), 0x00, sizeof(plugin_platform_monitor_func_set_s));
+               if (plugIn_repository[i].reg_data != NULL) {
+                       for (j = 0; i < plugIn_repository[i].reg_data_count; j++) {
+                               if ((plugIn_repository[i].reg_data)[j] != NULL) {
+                                       if ((plugIn_repository[i].reg_data)[j]->pkg_name != NULL)
+                                               free((plugIn_repository[i].reg_data)[j]->pkg_name);
+                                       if ((plugIn_repository[i].reg_data)[j]->additional_data != NULL)
+                                               free((plugIn_repository[i].reg_data)[j]->additional_data);
+                                       if ((plugIn_repository[i].reg_data)[j]->user_data != NULL)
+                                               free((plugIn_repository[i].reg_data)[j]->user_data);
+                                       free((plugIn_repository[i].reg_data)[j]);
+                               }
+                               (plugIn_repository[i].reg_data)[j] = NULL;
+                       }
+                       free(plugIn_repository[i].reg_data);
+               }
+               plugIn_repository[i].reg_data = NULL;
+               memset(&(plugIn_repository[i]), 0x00, sizeof(plugin_platform_monitor_s));
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+const plugin_platform_monitor_s *plugin_get_platform_monitor_plugin_repository(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *count = current_plugin_count_platform_monitor;
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository;
+}
+
+int plugin_get_platform_monitor_plugin_id(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (current_plugin_count_platform_monitor < 1) {
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[0].plugin_info.plugin_id;
+}
+
+plugin_init_service_noti_cb plugin_get_function_init_service_noti(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_init_service_noti;
+}
+
+plugin_unregister_service_noti_cb plugin_get_function_unregister_service_noti(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_unregister_service_noti;
+}
+
+plugin_add_service_data_cb plugin_get_function_add_service_data(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_add_service_data;
+}
+
+plugin_remove_service_data_cb plugin_get_function_remove_service_noti(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_remove_service_data;
+}
+
+plugin_get_service_data_cb plugin_get_function_get_service_data(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_get_service_data;
+}
+
+plugin_set_user_callback_cb plugin_get_function_set_user_callback(int plugin_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = _find_platform_monitor_plugin(plugin_id);
+       if (index == -1) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return plugIn_repository[index].func_set.func_set_user_callback;
+}
+
+static int _find_platform_monitor_plugin(int plugin_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (; i < current_plugin_count_platform_monitor; i++) {
+               if (plugIn_repository[i].plugin_info.plugin_id == plugin_id) {
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/framework/plugin/platform_monitor_plugin.h b/src/framework/plugin/platform_monitor_plugin.h
new file mode 100755 (executable)
index 0000000..d0fc0f9
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORM_MONITOR_PLUGIN_H_
+#define PLATFORM_MONITOR_PLUGIN_H_
+
+#include <glib.h>
+
+#include "struct.h"
+#include "error.h"
+#include "plugin/platform_monitor_resource.h"
+#include "platform-monitor/common.h"
+
+/**
+ * @file platform_monitor_plugin.h
+ * @brief      Provides function pointer manipulate operation for platform monitor module
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+ * @brief Maximum number of platform-monitor plugin
+ */
+#define PLUGIN_MAX_PLATFORM_MONITOR    10
+
+/**
+ * @brief Prototype of plugin function for connecting to the service and registering client for receiving service notification
+ * @param[in] data data formatted by sync_agent_pm_register_data_s
+ */
+typedef void (*plugin_init_service_noti_cb) (void *data);
+
+/**
+ * @brief Prototype of plugin function for disconnecting service and unregistering client to the service
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ */
+typedef sync_agent_pm_return_e(*plugin_unregister_service_noti_cb) (void);
+
+/**
+ * @brief Prototype of plugin function for adding user data to the service
+ * @param[in] add_data data to add to the service
+ * @param[in] added_data_id as returned by plugin_add_service_data_cb - id of the newly data added to the service
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ */
+typedef sync_agent_pm_return_e(*plugin_add_service_data_cb) (void *add_data, int *added_data_id);
+
+/**
+ * @brief Prototype of plugin function for removing user data to the service
+ * @param[in] remove_data_id service id of data expected to be deleted
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ */
+typedef sync_agent_pm_return_e(*plugin_remove_service_data_cb) (int remove_data_id);
+
+/**
+ * @brief Prototype of plugin function for getting service data
+ * @param[in] get_data_id service id of data that user want to get
+ * @param[in] service_data as returned by plugin_get_service_data_cb - service data that user want to get
+ * @return SYNC_AGENT_PM_SUCCESS on success, SYNC_AGENT_PM_FAIL on error
+ */
+typedef sync_agent_pm_return_e(*plugin_get_service_data_cb) (int get_data_id, void **service_data);
+
+/**
+ * @brief Prototype of plugin function for setting user callback function pointer to the pre-registered service callback function
+ * @param[in] callback_counts the number of callback functions
+ * @param[in] list variable number of callback functions (type : 'sync_agent_specific_type_cb')
+ */
+typedef void (*plugin_set_user_callback_cb) (int callback_counts, va_list list);
+
+/**
+ * @brief Structure for platform-monitor plugin function pointer set
+ */
+typedef struct {
+       plugin_init_service_noti_cb func_init_service_noti; /**< function pointer of plugin_init_service_noti_cb */
+       plugin_unregister_service_noti_cb func_unregister_service_noti; /**< function pointer of plugin_unregister_service_noti_cb */
+       plugin_add_service_data_cb func_add_service_data; /**< function pointer of plugin_add_service_data_cb */
+       plugin_remove_service_data_cb func_remove_service_data; /**< function pointer of plugin_remove_service_data_cb */
+       plugin_get_service_data_cb func_get_service_data; /**< function pointer of plugin_get_service_data_cb */
+       plugin_set_user_callback_cb func_set_user_callback; /**< function pointer of plugin_set_user_callback_cb */
+} plugin_platform_monitor_func_set_s;
+
+/**
+ * @brief Structure for platform-monitor plugin management
+ */
+typedef struct {
+       plugin_info_s plugin_info; /**< plugin info */
+       plugin_platform_monitor_func_set_s func_set; /**< platform-monitor plugin function pointer set */
+       int use_main_loop; /**< whether to use main loop */
+       int reg_data_count; /**< number of registration data */
+       sync_agent_pm_register_data_s **reg_data; /**< registration data */
+} plugin_platform_monitor_s;
+
+/**
+ * @brief Get platform-monitor plugin function pointer set
+ * @param[in] plugin_handle handle of platform-monitor plugin (result of dlopen for platform-monitor plugin)
+ * @param[in] error_code as returned by plugin_get_platform_monitor_func_set() - plugin error
+ * @return plugin_platform_monitor_func_set_s instance
+ */
+plugin_platform_monitor_func_set_s plugin_get_platform_monitor_func_set(void *plugin_handle, plugin_error_e * error_code);
+
+/**
+ * @brief Register platform-monitor plugin instance to the platform-monitor plugin repository being maintained as a singleton
+ * @param[in] plugin plugin_platform_monitor_s instance
+ * @return PLUGIN_SUCCESS on success, otherwise on error
+ */
+plugin_error_e plugin_register_plugin_platform_monitor(plugin_platform_monitor_s plugin);
+
+/**
+ * @brief Clear platform-monitor plugin repository being maintained as a singleton
+ */
+void plugin_clear_plugin_platform_monitor();
+
+/**
+ * @brief Get platform-monitor plugin repository
+ * @param[in] count as returned by plugin_get_platform_monitor_plugin_repository() - the number of platform-monitor plugin
+ * @return platform-monitor plugin repository being maintained as a singleton
+ */
+const plugin_platform_monitor_s *plugin_get_platform_monitor_plugin_repository(int *count);
+
+/**
+ * @brief Get platform-monitor plugin id
+ * @return platform-monitor plugin id on success, -1 on error
+ */
+int plugin_get_platform_monitor_plugin_id(void);
+
+/**
+ * @brief Get function pointer of plugin_init_service_noti_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_init_service_noti_cb on success, NULL on error
+ */
+plugin_init_service_noti_cb plugin_get_function_init_service_noti(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_unregister_service_noti_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_unregister_service_noti_cb on success, NULL on error
+ */
+plugin_unregister_service_noti_cb plugin_get_function_unregister_service_noti(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_add_service_data_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_add_service_data_cb on success, NULL on error
+ */
+plugin_add_service_data_cb plugin_get_function_add_service_data(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_remove_service_data_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_remove_service_data_cb on success, NULL on error
+ */
+plugin_remove_service_data_cb plugin_get_function_remove_service_noti(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_get_service_data_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_get_service_data_cb on success, NULL on error
+ */
+plugin_get_service_data_cb plugin_get_function_get_service_data(int plugin_id);
+
+/**
+ * @brief Get function pointer of plugin_set_user_callback_cb
+ * @param[in] plugin_id platform-monitor plugin id
+ * @return function pointer of plugin_set_user_callback_cb on success, NULL on error
+ */
+plugin_set_user_callback_cb plugin_get_function_set_user_callback(int plugin_id);
+
+/**
+ *     @}
+ */
+
+#endif                         /* PLATFORM_MONITOR_PLUGIN_H_ */
diff --git a/src/framework/plugin/struct.h b/src/framework/plugin/struct.h
new file mode 100755 (executable)
index 0000000..a8ad7ef
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef STRUCT_H_
+#define STRUCT_H_
+
+/**
+ * @file struct.h
+ * @brief      Defines plugin information structure
+ */
+
+/** @addtogroup plugin
+ *     @{
+ */
+
+/**
+   @brief This structure represents one of the PlugIn.
+ */
+struct plugin_info {
+       int plugin_id; /**< plugin id */
+       void *plugin_handle; /**< plugin handle */
+};
+
+typedef struct plugin_info plugin_info_s;
+
+/**
+ *     @}
+ */
+
+#endif                         /* STRUCT_H_ */
diff --git a/src/framework/protocol-binder/interface.c b/src/framework/protocol-binder/interface.c
new file mode 100755 (executable)
index 0000000..e00f93a
--- /dev/null
@@ -0,0 +1,1214 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "protocol-binder/internal.h"
+#include "protocol-binder/interface_internal.h"
+#include "protocol-binder/util_internal.h"
+#include "utility/sync_util.h"
+#include "utility/fw_assert.h"
+#include <assert.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PB"
+#endif
+
+/* internal functions */
+
+static sync_agent_pb_error_e _init_encoder(WBXMLLanguage lang, WBXMLCharsetMIBEnum orig_charset, sync_agent_pb_encoding_e enc, bool produce_anonymous, bool text_public_id, WBXMLEncoder ** encoder)
+{
+       _INNER_FUNC_ENTER;
+
+       WBXMLError err = WBXML_OK;
+       WBXMLEncoder *out_encoder = NULL;
+
+       if ((out_encoder = wbxml_encoder_create()) == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error_part;
+       }
+
+       /* set language and orig charset */
+       wbxml_encoder_set_lang(out_encoder, lang);
+       wbxml_encoder_set_text_public_id(out_encoder, text_public_id);
+       wbxml_encoder_set_output_charset(out_encoder, orig_charset);
+
+       wbxml_encoder_set_flow_mode(out_encoder, true);
+       wbxml_encoder_set_produce_anonymous(out_encoder, produce_anonymous);
+
+       /* ignore whitespaces */
+       wbxml_encoder_set_ignore_empty_text(out_encoder, true);
+       wbxml_encoder_set_remove_text_blanks(out_encoder, true);
+
+       if (enc == SYNC_AGENT_PB_ENCODING_XML) {
+               wbxml_encoder_set_output_type(out_encoder, WBXML_ENCODER_OUTPUT_XML);
+       } else {
+               wbxml_encoder_set_output_type(out_encoder, WBXML_ENCODER_OUTPUT_WBXML);
+               WBXMLVersion wbxml_version = pb_get_wbxml_version(enc);
+
+               assert(wbxml_version != WBXML_VERSION_UNKNOWN);
+               wbxml_encoder_set_wbxml_version(out_encoder, wbxml_version);
+       }
+
+       if (out_encoder != NULL) {
+               *encoder = out_encoder;
+       }
+
+       _DEBUG_TRACE("ended with pEncoder = %p", out_encoder);
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+
+ error_part:
+       _DEBUG_TRACE("error occurred");
+       return err;
+}
+
+static sync_agent_pb_error_e _build_lookup_tbl_of_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * set)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       int i;
+       int cnt = set->set_size;
+
+       sync_agent_pb_function_info_s *info_array = set->info_array;
+       GHashTable *protocol_element_lookup_tbl = NULL;
+       GHashTable *protocol_element_xml_name_lookup_tbl = NULL;
+
+       protocol_element_lookup_tbl = g_hash_table_new(g_int_hash, g_int_equal);
+       if (protocol_element_lookup_tbl == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       protocol_element_xml_name_lookup_tbl = g_hash_table_new(g_str_hash, g_str_equal);
+       if (protocol_element_xml_name_lookup_tbl == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       for (i = 0; i < cnt; i++) {
+               g_hash_table_insert(protocol_element_lookup_tbl, &(info_array[i].protocol_element), &(info_array[i]));
+
+               if (info_array[i].protocol_element_xml_name != NULL) {
+                       _DEBUG_TRACE("xml name g str hash  index : %d , name : %s", i, info_array[i].protocol_element_xml_name);
+                       g_hash_table_insert(protocol_element_xml_name_lookup_tbl, info_array[i].protocol_element_xml_name, &(info_array[i]));
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               set->protocol_element_lookup_tbl = protocol_element_lookup_tbl;
+               set->protocol_element_xml_name_lookup_tbl = protocol_element_xml_name_lookup_tbl;
+       } else {
+               if (protocol_element_lookup_tbl != NULL) {
+                       g_hash_table_destroy(protocol_element_lookup_tbl);
+               }
+       }
+       return err;
+}
+
+static sync_agent_pb_error_e _lookup_binder_function(sync_agent_pb_protocol_binder_function_set_s * binder_function_set, Protocol_Element protocol_element, char *protocol_element_xml_name, sync_agent_pb_function_info_s ** function_info)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("started : protocol_element = %d, protocol_element_xml_name = %s\n", protocol_element, protocol_element_xml_name);
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       GHashTable *lookup_tbl = NULL;
+       void *key = NULL;
+       if (binder_function_set == NULL) {
+               err = SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_NOT_DEFINED;
+               goto return_part;
+       }
+
+       if (protocol_element_xml_name != NULL) {
+               key = protocol_element_xml_name;
+               lookup_tbl = binder_function_set->protocol_element_xml_name_lookup_tbl;
+       } else {
+               key = &protocol_element;
+               lookup_tbl = binder_function_set->protocol_element_lookup_tbl;
+       }
+
+       if (lookup_tbl == NULL) {
+               err = SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_LOOKUP_TBL_NOT_DEFINED;
+               goto return_part;
+       }
+
+       sync_agent_pb_function_info_s *binder_function_info = g_hash_table_lookup(lookup_tbl, key);
+       if (binder_function_info == NULL) {
+               err = SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL_ELEMENT;
+               goto return_part;
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *function_info = binder_function_info;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return err;
+}
+
+static void _remove_contents_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
+{
+       _INNER_FUNC_ENTER;
+
+       if (binder_function_set != NULL) {
+               if (binder_function_set->info_array != NULL) {
+                       free(binder_function_set->info_array);
+                       binder_function_set->info_array = NULL;
+               }
+               if (binder_function_set->protocol_element_lookup_tbl != NULL) {
+                       g_hash_table_destroy(binder_function_set->protocol_element_lookup_tbl);
+                       binder_function_set->protocol_element_lookup_tbl = NULL;
+               }
+               if (binder_function_set->protocol_element_xml_name_lookup_tbl != NULL) {
+                       g_hash_table_destroy(binder_function_set->protocol_element_xml_name_lookup_tbl);
+                       binder_function_set->protocol_element_xml_name_lookup_tbl = NULL;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+/*static char *duplicate_byte_stream(char *byte_stream, unsigned int byte_stream_len)
+{
+       char *ret_byte_stream = malloc(byte_stream_len + 1);
+       if (ret_byte_stream == NULL) {
+               goto return_part;
+       }
+
+       memcpy(ret_byte_stream, byte_stream, byte_stream_len * sizeof(char));
+       ret_byte_stream[byte_stream_len] = '\0';
+return_part:
+       return ret_byte_stream;
+}*/
+
+/* external functions */
+
+/* binder function set */
+
+EXPORT_API void sync_agent_free_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (binder_function_set != NULL) {
+               _remove_contents_binder_function_set(binder_function_set);
+
+               free(binder_function_set);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_init_binder_function_set(unsigned int binder_function_cnt, sync_agent_pb_function_info_s * info_array, sync_agent_pb_protocol_binder_function_set_s ** binder_function_set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(info_array == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "info_array is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       sync_agent_pb_protocol_binder_function_set_s *pSet = (sync_agent_pb_protocol_binder_function_set_s *) calloc(1, sizeof(sync_agent_pb_protocol_binder_function_set_s));
+       if (pSet == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       pSet->set_size = binder_function_cnt;
+       pSet->info_array = (sync_agent_pb_function_info_s *) malloc(binder_function_cnt * sizeof(sync_agent_pb_function_info_s));
+       if (pSet->info_array == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+       memcpy(pSet->info_array, info_array, binder_function_cnt * sizeof(sync_agent_pb_function_info_s));
+
+       /* build lookup table */
+       err = _build_lookup_tbl_of_binder_function_set(pSet);
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               goto return_part;
+       }
+
+ return_part:
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_INFO("error occurred\n");
+               if (pSet != NULL) {
+                       sync_agent_free_binder_function_set(pSet);
+               }
+       } else {
+               *binder_function_set = pSet;
+               _DEBUG_INFO("end with return pBinder_function_set = %p\n", pSet);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+/*
+ * @brief              ignore previous binder function set built and rebuild binder function set with new function informations
+ * @param[in]  binder_function_set                     binder function set
+ * @param[in]  binder_function_info_cnt                number of new binder function informations
+ * @param[in]  info_array_to_be_added          array of new binder function informations
+ * @return                     protocol binder error
+ */
+sync_agent_pb_error_e pb_reset_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set, unsigned int new_binder_function_info_cnt, sync_agent_pb_function_info_s * new_info_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder_function_set == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder_function_set is NULL, FAIL !!!");
+       retvm_if(new_info_array == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "new_info_array is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e pb_error = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_protocol_binder_function_set_s *set = binder_function_set;
+       sync_agent_pb_protocol_binder_function_set_s backup_set;
+
+       /* make backup set */
+       memcpy(&backup_set, set, sizeof(sync_agent_pb_protocol_binder_function_set_s));
+
+       /* reset contents */
+       set->set_size = new_binder_function_info_cnt;
+       set->info_array = (sync_agent_pb_function_info_s *) malloc(new_binder_function_info_cnt * sizeof(sync_agent_pb_function_info_s));
+       if (set->info_array == NULL) {
+               pb_error = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error_part;
+       }
+       memcpy(set->info_array, new_info_array, new_binder_function_info_cnt * sizeof(sync_agent_pb_function_info_s));
+
+       /* build lookup table */
+       pb_error = _build_lookup_tbl_of_binder_function_set(set);
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               goto error_part;
+       }
+
+       /* remove previous binder set */
+       _remove_contents_binder_function_set(&backup_set);
+
+       _DEBUG_INFO("success\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return pb_error;
+
+ error_part:
+       if (set->info_array != NULL) {
+               free(set->info_array);
+       }
+
+       /* restore pBinder_function_set */
+       memcpy(set, &backup_set, sizeof(sync_agent_pb_protocol_binder_function_set_s));
+
+       _DEBUG_INFO("error occurred with pb_error = %d\n", pb_error);
+       return pb_error;
+}
+
+/*
+ * @brief              add more function informations to binder function set
+ * @note               you should notice that if same value of protocol_element or protocol_element_xml_name are
+ *                                     already existed in binder function set, then previous information is removed from binder function set
+ * @param[in]  binder_function_set                     binder function set
+ * @param[in]  binder_function_info_cnt                number of new binder function informations to be added
+ * @param[in]  info_array_to_be_added          array of new binder function informations to be added
+ * @return                                     protocol binder error
+ */
+EXPORT_API sync_agent_pb_error_e sync_agent_add_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set, unsigned int binder_function_info_cnt, sync_agent_pb_function_info_s * info_array_to_be_added)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder_function_set == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder_function_set is NULL, FAIL !!!");
+       retvm_if(info_array_to_be_added == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "info_array_to_be_added is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e pb_error = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_protocol_binder_function_set_s *set = binder_function_set;
+       unsigned int prev_set_size = set->set_size;
+       sync_agent_pb_function_info_s *prev_info_array = set->info_array;
+
+       /* reset set_size and info_array */
+       unsigned int new_set_size = prev_set_size + binder_function_info_cnt;
+       sync_agent_pb_function_info_s *new_info_array = (sync_agent_pb_function_info_s *) malloc(new_set_size * sizeof(sync_agent_pb_function_info_s));
+       if (new_info_array == NULL) {
+               pb_error = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto error_part;
+       }
+
+       memcpy(new_info_array, prev_info_array, prev_set_size * sizeof(sync_agent_pb_function_info_s));
+
+       memcpy(new_info_array + prev_set_size, info_array_to_be_added, binder_function_info_cnt * sizeof(sync_agent_pb_function_info_s));
+
+       /* update binder function set */
+       pb_error = pb_reset_binder_function_set(set, new_set_size, new_info_array);
+       if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+               goto error_part;
+       }
+
+       _DEBUG_INFO("success");
+
+       _EXTERN_FUNC_EXIT;
+
+       if (new_info_array != NULL) {
+               free(new_info_array);
+       }
+
+       return pb_error;
+
+ error_part:
+       if (new_info_array != NULL) {
+               free(new_info_array);
+       }
+
+       _DEBUG_INFO("error with pb_error = %d", pb_error);
+       return pb_error;
+}
+
+/* protocol binder */
+
+EXPORT_API sync_agent_pb_protocol_binder_info_s *sync_agent_init_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_protocol_e protocol, Protocol_Option_Ptr option, sync_agent_pb_encoding_e enc, bool encode_xml_header,
+                                                                                bool use_strtbl, bool produce_anonymous, bool use_flow_mode, bool text_public_id, GList * restrict_params, sync_agent_restrict_condition_checker_cb restrict_condition_checker,
+                                                                                sync_agent_pb_protocol_binder_function_set_s * binder_function_set)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(protocol == SYNC_AGENT_PB_PROTOCOL_UNKNOWN, NULL, "protocol is INVALID, FAIL !!!");
+       retvm_if(enc == SYNC_AGENT_PB_ENCODING_UNKNOWN, NULL, "enc is INVALID, FAIL !!!");
+       retvm_if(binder_function_set == NULL, NULL, "binder_function_set is INVALID, FAIL !!!");
+
+       _DEBUG_INFO("started with input pBinder = %p\n", binder);
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       /* TODO : validation input parameters */
+
+       if (binder == NULL) {
+               binder = (sync_agent_pb_protocol_binder_info_s *) malloc(sizeof(sync_agent_pb_protocol_binder_info_s));
+               if (binder == NULL) {
+                       _DEBUG_ERROR("malloc failed !!");
+                       goto error_part;
+               }
+       }
+
+       if (binder != NULL) {
+               memset(binder, 0x00, sizeof(sync_agent_pb_protocol_binder_info_s));
+               /* TODO : check validity of input parameters */
+               binder->protocol = protocol;
+               binder->option = option;
+               binder->enc = enc;
+               binder->encode_xml_header = encode_xml_header;
+               binder->use_strtbl = use_strtbl;
+               binder->produce_anonymous = produce_anonymous;
+               binder->use_flow_mode = use_flow_mode;
+               binder->restrict_params = restrict_params;
+               binder->restrict_condition_checker = restrict_condition_checker;
+               binder->binder_functions = binder_function_set;
+
+               WBXMLCharsetMIBEnum orig_charset = WBXML_PARSER_DEFAULT_CHARSET;
+
+               WBXMLLanguage lang = pb_get_wbxml_language(protocol);
+               _DEBUG_INFO("lang = %d\n", lang);
+
+               binder->lang_table = (WBXMLLangEntry *) wbxml_tables_get_table(lang);
+               /* SVACE : NULL check routine added. */
+               if (binder->lang_table == NULL) {
+                       _DEBUG_ERROR("language table is not found\n");
+                       goto error_part;
+               }
+               binder->prev_lang_table = NULL;
+
+               _DEBUG_INFO("Binder has follwing information\n"
+                           "protocol = %d, encoding = %d, string table option = %d, " "flow mode option = %d, lang = %d, lang table pointer = %p\n" "lang table detail info (langID = %d, Public ID = (xmlPublicID : %s, xmlRootElt : %s, xmlDTD : %s))",
+                           protocol, enc, use_strtbl, use_flow_mode, lang, binder->lang_table, binder->lang_table->langID, binder->lang_table->publicID->xmlPublicID, binder->lang_table->publicID->xmlRootElt, binder->lang_table->publicID->xmlDTD);
+
+               if (use_flow_mode) {
+                       err = _init_encoder(lang, orig_charset, enc, produce_anonymous, text_public_id, &(binder->wbxml_encoder));
+                       if (err != SYNC_AGENT_PB_RETURN_OK) {
+                               goto error_part;
+                       }
+               } else {
+                       binder->tree = wbxml_tree_create(lang, orig_charset);
+                       if (binder->tree == NULL) {
+                               goto error_part;
+                       }
+
+                       binder->tree_node_stack = NULL;
+               }
+       }
+
+       _DEBUG_INFO("ended with pBinder = %p\n", binder);
+
+       _EXTERN_FUNC_EXIT;
+
+       return binder;
+
+ error_part:
+       _DEBUG_ERROR("error occurred\n");
+
+       sync_agent_destroy_protocol_binder(binder);
+
+       return NULL;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_append_element(sync_agent_pb_protocol_binder_info_s * binder, Protocol_Element protocol_element, Content_Ptr content)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLError wbxml_err = WBXML_OK;
+
+       sync_agent_pb_protocol_binder_function_set_s *binder_function_set = binder->binder_functions;
+       sync_agent_binder_object_converter_cb binder_object_converter_function = NULL;
+       sync_agent_pb_function_info_s *functioninfo = NULL;
+
+       WBXMLTreeNode *wbxml_tree_node = NULL;
+       WBXMLTreeNode *current_parent_tree_node = NULL;
+       bool is_terminal = false;
+       bool is_start_tag = false;
+
+       if (binder_function_set == NULL) {
+               err = SYNC_AGENT_PB_RETURN_BINDER_FUNCTION_SET_NOT_DEFINED;
+               goto return_part;
+       }
+
+       /* get binder_function by content_id */
+       err = _lookup_binder_function(binder_function_set, protocol_element, NULL, &functioninfo);
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               err = SYNC_AGENT_PB_RETURN_APPEND_INVALID_PROTOCOL_ELEMENT;
+               goto return_part;
+       }
+       binder_object_converter_function = functioninfo->binder_object_converter_function;
+       is_start_tag = (functioninfo->protocol_element_xml_name[0] != '/');
+       is_terminal = functioninfo->isTerminal;
+       binder->is_current_node_terminal = is_terminal;
+
+       if (is_start_tag) {
+               /* execute binder_object_converter_function */
+               if (binder_object_converter_function != NULL) {
+                       _DEBUG_INFO("calling binder_object_converter_function");
+                       err = binder_object_converter_function(binder, content, &wbxml_tree_node);
+                       if (err != SYNC_AGENT_PB_RETURN_OK) {
+                               _DEBUG_ERROR("error occurred during calling binder_object_converter_function");
+                               goto return_part;
+                       }
+
+                       if (wbxml_tree_node == NULL) {
+                               _DEBUG_ERROR("after calling binder_object_converter_function, we get NULL wbxml_tree_node");
+                               err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;       /* TODO : define new err code */
+                               goto return_part;
+                       }
+                       _DEBUG_INFO("after calling binder_object_converter_function, we get wbxml_tree_node = %p", wbxml_tree_node);
+
+                       if (binder->use_flow_mode) {
+                               /* since encoder has bug with has content flag, we do below meaningless work */
+                               if (!is_terminal && wbxml_tree_node->children == NULL) {
+                                       /* TODO : error handling */
+                                       WBXMLTreeNode *text_node = wbxml_tree_node_create_text(NULL, 0);
+                                       wbxml_tree_node_add_child(wbxml_tree_node, text_node);
+                               }
+
+                               /* TODO : error handling */
+                               wbxml_err = wbxml_encoder_encode_node_with_elt_end(binder->wbxml_encoder, wbxml_tree_node, is_terminal);
+                               if (wbxml_err != WBXML_OK) {
+                                       err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+                                       _DEBUG_ERROR("wbxml_encoder_encode_node_with_elt_end failed. err(%d) : %s", wbxml_err, wbxml_errors_string(wbxml_err));
+                                       goto return_part;
+                               }
+
+                               if (is_terminal) {
+                                       if (wbxml_tree_node != NULL) {
+                                               _DEBUG_INFO("free wbxml tree node when non terminal case");
+                                               wbxml_tree_node_destroy_all(wbxml_tree_node);
+                                               wbxml_tree_node = NULL;
+                                       }
+                               }
+                       } else {
+                               /* append node to wbxml dom tree */
+                               if (binder->tree_node_stack != NULL) {
+                                       current_parent_tree_node = (WBXMLTreeNode *) (binder->tree_node_stack->data);
+                               }
+
+                               WB_BOOL add_node_success = wbxml_tree_add_node(binder->tree, current_parent_tree_node, wbxml_tree_node);
+                               if (!add_node_success) {
+                                       /* TODO : error handling */
+                                       _DEBUG_INFO("wbxml_tree_add_node failed\n");
+                                       err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;       /* TODO : define new err code */
+                                       goto return_part;
+                               }
+                       }
+
+                       /* save wbxml_tree_node in stack */
+                       if (!is_terminal) {
+                               /* TODO : error handling */
+                               binder->tree_node_stack = g_slist_prepend(binder->tree_node_stack, wbxml_tree_node);
+                       }
+               }
+       } else {
+               if (binder->tree_node_stack == NULL) {
+                       _DEBUG_INFO("end tag not exist. failed\n");
+                       err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;       /* TODO : define new err code */
+                       goto return_part;
+               }
+
+               /* pop one tree node from stack */
+               GSList *tmp_node = binder->tree_node_stack;
+               if (binder->use_flow_mode) {
+                       /* TODO : error handling */
+                       WBXMLTreeNode *current_parent_node = (WBXMLTreeNode *) (tmp_node->data);
+                       wbxml_encoder_encode_raw_elt_end(binder->wbxml_encoder, current_parent_node, true);
+                       if (current_parent_node != NULL) {
+                               _DEBUG_INFO("free wbxml tree node when pop in tree node stack");
+                               wbxml_tree_node_destroy_all(current_parent_node);
+                       }
+               }
+
+               binder->tree_node_stack = g_slist_next(binder->tree_node_stack);
+               g_slist_free_1(tmp_node);
+       }
+
+ return_part:
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               _DEBUG_INFO("error occurred");
+               if (wbxml_tree_node != NULL) {
+                       wbxml_tree_node_destroy_all(wbxml_tree_node);
+               }
+       } else {
+               _DEBUG_INFO("end : protocol_element_xml_name = %s\n", functioninfo->protocol_element_xml_name);
+
+               _EXTERN_FUNC_EXIT;
+       }
+       return err;
+}
+
+EXPORT_API void sync_agent_destroy_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (binder != NULL) {
+               _DEBUG_INFO("pBinder != NULL");
+               if (binder->binder_functions != NULL) {
+                       _DEBUG_INFO("free binder functions");
+                       sync_agent_free_binder_function_set(binder->binder_functions);
+               }
+
+               if (binder->use_flow_mode) {
+                       if (binder->wbxml_encoder != NULL) {
+                               _DEBUG_INFO("free wbxml_encoder");
+                               wbxml_encoder_destroy(binder->wbxml_encoder);
+                       }
+               } else {
+                       if (binder->tree != NULL) {
+                               _DEBUG_INFO("free tree");
+                               wbxml_tree_destroy(binder->tree);
+                       }
+               }
+
+               if (binder->tree_node_stack != NULL) {
+                       _DEBUG_INFO("free tree node stack");
+                       g_slist_free(binder->tree_node_stack);
+               }
+
+               free(binder);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_stream_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, char **byte_stream, unsigned int *byte_stream_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       unsigned char *temp_byte_stream = NULL;
+       unsigned int temp_byte_stream_size = 0;
+
+       WBXMLError wbxml_err = WBXML_OK;
+
+       if (byte_stream == NULL || byte_stream_size == NULL) {
+               err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+               goto return_part;
+       }
+
+       _DEBUG_INFO("flow mode = %d, encoding = %d\n", binder->use_flow_mode, binder->enc);
+
+       /* flow mode */
+       if (binder->use_flow_mode) {
+               wbxml_err = wbxml_encoder_get_output(binder->wbxml_encoder, &temp_byte_stream, &temp_byte_stream_size);
+               /* TODO : how to apply produce_anonymous */
+               /* not in flow mode */
+       } else {
+               WBXMLTree *tree = binder->tree;
+
+               if (binder->enc == SYNC_AGENT_PB_ENCODING_XML) {
+                       WBXMLGenXMLParams params = { WBXML_GEN_XML_INDENT, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, 4, FALSE };
+                       wbxml_err = wbxml_tree_to_xml(tree, &temp_byte_stream, &temp_byte_stream_size, &params);
+               } else {
+                       WBXMLGenWBXMLParams params;
+
+                       /* set encoding language */
+                       params.wbxml_version = pb_get_wbxml_version(binder->enc);
+                       params.keep_ignorable_ws = FALSE;
+                       params.use_strtbl = binder->use_strtbl;
+                       params.produce_anonymous = binder->produce_anonymous;
+
+                       wbxml_err = wbxml_tree_to_wbxml(tree, &temp_byte_stream, &temp_byte_stream_size, &params);
+               }
+       }
+
+       if (wbxml_err != WBXML_OK) {
+               _DEBUG_ERROR("wbxml err = (%d) %s\n", wbxml_err, wbxml_errors_string(wbxml_err));
+               err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+               goto return_part;
+       }
+
+       if (binder->enc == SYNC_AGENT_PB_ENCODING_XML && !(binder->encode_xml_header)) {
+               /* remove xml header */
+               temp_byte_stream_size = pb_remove_xml_header((char *)temp_byte_stream, temp_byte_stream_size);
+       }
+
+       /* for debugging printing result in xml */
+       if (binder->enc != SYNC_AGENT_PB_ENCODING_XML) {
+               char *xml_result = NULL;
+               unsigned int xml_result_len = 0;
+               sync_agent_get_xml_from_protocol_binder(binder, &xml_result, &xml_result_len);
+
+               _DEBUG_INFO("============= binder wbxml logging start ==============\n");
+               _DEBUG_INFO("wbxml_conv_wbxml2xml_withlen err = (%d) %s\n", err, wbxml_errors_string(err));
+               if (wbxml_err == WBXML_OK) {
+                       _DEBUG_INFO("wbxml : %s\n", temp_byte_stream);
+                       _DEBUG_INFO("wbxml len : %u\n", temp_byte_stream_size);
+                       _DEBUG_INFO("converted xml : %s\n", xml_result);
+                       _DEBUG_INFO("converted xml len : %u\n", xml_result_len);
+               }
+               _DEBUG_INFO("============= binder wbxml logging end ==============\n");
+
+               if (xml_result != NULL) {
+                       free(xml_result);
+               }
+       } else {
+               _DEBUG_INFO("============= binder xml logging start ==============\n");
+               _DEBUG_INFO("xml : %s\n", temp_byte_stream);
+               _DEBUG_INFO("xml len : %u\n", temp_byte_stream_size);
+               _DEBUG_INFO("============= binder xml logging end ==============\n");
+       }
+
+ return_part:
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               if (temp_byte_stream != NULL) {
+                       free(temp_byte_stream);
+               }
+       } else {
+               *byte_stream = (char *)temp_byte_stream;
+               *byte_stream_size = temp_byte_stream_size;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_xml_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, char **xml, unsigned int *xml_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       unsigned char *wbxml = NULL;
+       unsigned int wbxml_len = 0;
+       WBXMLError wbxml_err = WBXML_OK;
+
+       unsigned char *out_xml = NULL;
+       unsigned int out_xml_len = 0;
+       WBXMLConvWBXML2XML *conv = NULL;
+       WBXMLGenXMLParams xml_params = { WBXML_GEN_XML_INDENT, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, 4, TRUE };
+
+       if (binder->enc == SYNC_AGENT_PB_ENCODING_XML) {
+               err = SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_ENCODING;
+               goto return_part;
+       }
+
+       _DEBUG_INFO("flow mode = %d\n", binder->use_flow_mode);
+
+       if (binder->use_flow_mode) {
+               wbxml_err = wbxml_encoder_get_output(binder->wbxml_encoder, &wbxml, &wbxml_len);
+               if (wbxml_err != WBXML_OK) {
+                       _DEBUG_ERROR("wbxml_encoder_get_output error occurred.\n");
+                       goto wbxml_error_part;
+               }
+
+               wbxml_err = wbxml_conv_wbxml2xml_create(&conv);
+               if (wbxml_err != WBXML_OK) {
+                       _DEBUG_ERROR("wbxml_conv_wbxml2xml_create error occurred.\n");
+                       goto wbxml_error_part;
+               }
+
+               wbxml_conv_wbxml2xml_set_gen_type(conv, xml_params.gen_type);
+               wbxml_conv_wbxml2xml_set_language(conv, xml_params.lang);
+               wbxml_conv_wbxml2xml_set_charset(conv, xml_params.charset);
+               wbxml_conv_wbxml2xml_set_indent(conv, xml_params.indent);
+               if (xml_params.keep_ignorable_ws)
+                       wbxml_conv_wbxml2xml_enable_preserve_whitespaces(conv);
+
+               wbxml_err = wbxml_conv_wbxml2xml_run(conv, wbxml, wbxml_len, &out_xml, &out_xml_len);
+               if (wbxml_err != WBXML_OK) {
+                       _DEBUG_ERROR("wbxml_conv_wbxml2xml_run error occurred.\n");
+                       goto wbxml_error_part;
+               }
+               wbxml_conv_wbxml2xml_destroy(conv);
+               conv = NULL;
+
+       } else {
+               WBXMLTree *tree = binder->tree;
+               wbxml_err = wbxml_tree_to_xml(tree, &out_xml, &out_xml_len, &xml_params);
+       }
+
+ wbxml_error_part:
+       if (wbxml_err != WBXML_OK) {
+               _DEBUG_ERROR("wbxml err = (%d) %s\n", err, wbxml_errors_string(err));
+               err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+               goto return_part;
+       }
+
+ return_part:
+       if (wbxml != NULL) {
+               free(wbxml);
+       }
+
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *xml = (char *)out_xml;
+               *xml_size = out_xml_len;
+       } else {
+               if (out_xml != NULL) {
+                       free(out_xml);
+               }
+       }
+
+       if (conv != NULL)
+               wbxml_conv_wbxml2xml_destroy(conv);
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_stream_size_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, unsigned int *byte_stream_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       char *out_byte_stream = NULL;
+       unsigned int out_byte_stream_size = 0;
+
+       if (binder->use_flow_mode) {
+               out_byte_stream_size = wbxml_encoder_get_output_len(binder->wbxml_encoder);
+       } else {
+               err = sync_agent_get_stream_from_protocol_binder(binder, &out_byte_stream, &out_byte_stream_size);
+               if (out_byte_stream != NULL) {
+                       free(out_byte_stream);
+               }
+       }
+
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *byte_stream_size = out_byte_stream_size;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_encoding_from_protocol_binder(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e * enc)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       *enc = binder->enc;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+/* reverse protocol binder */
+
+EXPORT_API sync_agent_pb_error_e sync_agent_init_reverse_protocol_binder(char *byte_stream, unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_e * protocol, sync_agent_pb_protocol_binder_function_set_s * binder_function_set,
+                                                                        void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(protocol == SYNC_AGENT_PB_PROTOCOL_UNKNOWN, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "protocol is INVALID, FAIL !!!");
+       retvm_if(dec == SYNC_AGENT_PB_DECODING_UNKNOWN, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "dec is INVALID, FAIL !!!");
+       retvm_if(binder_function_set == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder_function_set is INVALID, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       sync_agent_pb_protocol_binder_reverse_info_s *temp_binder = NULL;
+       WBXMLTree *wbxml_tree = NULL;
+       sync_agent_pb_protocol_e input_protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+       if (protocol != NULL) {
+               input_protocol = *protocol;
+               if (!pb_validate_protocol(input_protocol)) {
+                       err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+                       goto return_part;
+               }
+       }
+
+       if (byte_stream == NULL || byte_stream_len == 0) {
+               err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+               goto return_part;
+       }
+
+       sync_agent_pb_protocol_e output_protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+       WBXMLLanguage input_wbxml_lang = pb_get_wbxml_language(input_protocol);
+
+       switch (dec) {
+       case SYNC_AGENT_PB_DECODING_WBXML:
+               {
+                       err = pb_get_wbxml_tree_from_wbxml(byte_stream, byte_stream_len, input_wbxml_lang, &wbxml_tree);
+                       if (err != SYNC_AGENT_PB_RETURN_OK) {
+                               goto return_part;
+                       }
+#ifndef NDEBUG
+                       pb_print_wbxml_dom_in_xml(wbxml_tree);
+#endif
+               }
+               break;
+       case SYNC_AGENT_PB_DECODING_XML:
+               {
+                       err = pb_get_wbxml_tree_from_xml(byte_stream, byte_stream_len, input_wbxml_lang, &wbxml_tree);
+                       if (err != SYNC_AGENT_PB_RETURN_OK) {
+                               goto return_part;
+                       }
+               }
+               break;
+       default:
+               err = SYNC_AGENT_PB_RETURN_UNKNOWN_ENCODING;
+               goto return_part;
+       }
+
+       assert(wbxml_tree != NULL);
+       assert(wbxml_tree->lang != NULL);
+       /* SVACE : wbxml_tree->lang NULL check added. */
+
+       output_protocol = pb_get_protocol_from_wbxml_lang(wbxml_tree->lang->langID);
+
+       /* allocation sync_agent_pb_protocol_binder_reverse_info_s */
+       temp_binder = (sync_agent_pb_protocol_binder_reverse_info_s *) calloc(1, sizeof(sync_agent_pb_protocol_binder_reverse_info_s));
+       if (temp_binder == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       /* set property */
+       temp_binder->protocol = output_protocol;
+       temp_binder->dec = dec;
+       temp_binder->binder_functions = binder_function_set;
+       temp_binder->user_data = user_data;
+
+       temp_binder->tree = wbxml_tree;
+       temp_binder->tree_stack = NULL;
+       temp_binder->current_tree_node = NULL;
+       temp_binder->current_tree_node_first_visit = true;
+
+       temp_binder->no_tree_node_visited = true;
+       temp_binder->all_tree_node_visited = false;
+
+ return_part:
+       if (err != SYNC_AGENT_PB_RETURN_OK) {
+               if (temp_binder == NULL) {
+                       if (wbxml_tree != NULL) {
+                               wbxml_tree_destroy(wbxml_tree);
+                       }
+               }
+       } else {
+               *binder = temp_binder;
+               if (protocol != NULL)
+                       *protocol = output_protocol;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API void sync_agent_set_user_data_in_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder, void *user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(binder == NULL, "binder is NULL, FAIL !!!");
+
+       binder->user_data = user_data;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void *sync_agent_get_user_data_from_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL, FAIL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return binder->user_data;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_next_element(sync_agent_pb_protocol_binder_reverse_info_s * binder, Protocol_Element * protocol_element, char **protocol_element_name, Content_Ptr * content)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       char *ret_protocol_element = NULL;
+
+       WBXMLTreeNode *current_tree_node = binder->current_tree_node;
+       bool first_visit = binder->current_tree_node_first_visit;
+
+       sync_agent_pb_function_info_s *function_info = NULL;
+       sync_agent_reverse_binder_object_converter_cb reverse_binder_object_converter_function = NULL;
+       bool is_element_node = false;
+       bool is_tree_node = false;
+       char *current_tree_node_protocol_element_name = NULL;
+       char *search_element_name = NULL;
+
+       /* if all node already visited, then "SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT" error occurs */
+       if (binder->all_tree_node_visited) {
+               err = SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT;
+               goto return_part;
+       }
+
+       /* find next element which has callback */
+       do {
+               /* get next tree node (order : depth-first) */
+               if (binder->no_tree_node_visited) {
+                       current_tree_node = binder->tree->root;
+                       binder->no_tree_node_visited = false;
+               } else {
+
+                       is_tree_node = pb_has_wbxml_node_same_type(current_tree_node, WBXML_TREE_TREE_NODE);
+                       if (!is_tree_node) {
+                               current_tree_node = pb_get_next_node_of_element_node(current_tree_node, &first_visit);
+
+                               /* get subtree node when all nodes of subtree are visited */
+                               if (current_tree_node == NULL && binder->tree_stack != NULL) {
+                                       first_visit = false;
+                                       current_tree_node = (WBXMLTreeNode *) (binder->tree_stack->data);
+                                       continue;
+                               }
+                       } else {
+                               /* if root tree has sub-tree which has different language,
+                                * then save it to tree stack */
+                               if (first_visit) {
+                                       /* push sub-tree into tree stack */
+                                       binder->tree_stack = g_slist_prepend(binder->tree_stack, current_tree_node);
+                               } else {
+                                       /* pop sub-tree from tree stack */
+                                       binder->tree_stack = g_slist_delete_link(binder->tree_stack, binder->tree_stack);       /* remove the head */
+                               }
+                               current_tree_node = pb_get_next_node_of_tree_node(current_tree_node, &first_visit);
+                       }
+               }
+
+               /* break when no next node to get */
+               if (current_tree_node == NULL)
+                       break;
+
+               is_element_node = pb_has_wbxml_node_same_type(current_tree_node, WBXML_TREE_ELEMENT_NODE);
+               if (!is_element_node) {
+                       continue;
+               }
+
+               /* get callback */
+               err = sync_agent_get_name_from_element_node(current_tree_node, &current_tree_node_protocol_element_name);
+               assert(err == SYNC_AGENT_PB_RETURN_OK);
+
+               assert(current_tree_node_protocol_element_name != NULL);
+               if (first_visit) {
+                       _DEBUG_INFO("currently traversing element name = %s first\n", current_tree_node_protocol_element_name);
+               } else {
+                       _DEBUG_INFO("currently traversing element name = %s second\n", current_tree_node_protocol_element_name);
+               }
+
+               sync_agent_pb_protocol_binder_function_set_s *binder_functions = binder->binder_functions;
+
+               if (first_visit) {
+                       search_element_name = strdup(current_tree_node_protocol_element_name);
+               } else {
+                       unsigned int protocol_element_name_len = strlen(current_tree_node_protocol_element_name);
+                       search_element_name = malloc(protocol_element_name_len + 2);
+                       if (search_element_name == NULL) {
+                               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+                               goto return_part;
+                       }
+
+                       search_element_name[0] = '/';
+                       memcpy(search_element_name + 1, current_tree_node_protocol_element_name, protocol_element_name_len);
+                       search_element_name[protocol_element_name_len + 1] = '\0';
+               }
+               if (search_element_name == NULL) {
+                       err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+                       goto return_part;
+               }
+
+               err = _lookup_binder_function(binder_functions, 0, search_element_name, &function_info);
+
+               assert(search_element_name != NULL);
+               _DEBUG_INFO("search_element_name = %s\n", search_element_name);
+               free(search_element_name);
+               _DEBUG_INFO("search_element_name free success\n");
+               search_element_name = NULL;
+
+               if (err != SYNC_AGENT_PB_RETURN_OK) {
+                       continue;       /* TODO */
+               }
+
+               reverse_binder_object_converter_function = function_info->reverse_binder_object_converter_function;
+
+       } while (reverse_binder_object_converter_function == NULL);
+
+       /* all xml tags are visited case */
+       if (current_tree_node == NULL) {
+               err = SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT;
+               goto return_part;
+       }
+       /* get next callback case */
+       else {
+               assert(reverse_binder_object_converter_function != NULL);
+
+               /* logging */
+               _DEBUG_INFO("reverse callback call at <%s>\n", function_info->protocol_element_xml_name);
+
+               /* reverse convert */
+               err = reverse_binder_object_converter_function(binder, current_tree_node, content);
+               if (err != SYNC_AGENT_PB_RETURN_OK) {
+                       goto return_part;
+               }
+
+               /* set protocol element, protocol element name */
+               ret_protocol_element = strdup(function_info->protocol_element_xml_name);
+               if (ret_protocol_element == NULL) {
+                       err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+                       goto return_part;
+               }
+
+               err = SYNC_AGENT_PB_RETURN_OK;
+               goto return_part;
+       }
+
+ return_part:
+       _DEBUG_INFO("return part : err = %d\n", err);
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               binder->current_tree_node = current_tree_node;
+               binder->current_tree_node_first_visit = first_visit;
+
+               *protocol_element = function_info->protocol_element;
+               if (protocol_element_name != NULL) {
+                       *protocol_element_name = ret_protocol_element;
+               } else {
+                       if (ret_protocol_element != NULL)
+                               free(ret_protocol_element);
+               }
+
+               _EXTERN_FUNC_EXIT;
+       }
+
+       return err;
+}
+
+EXPORT_API void sync_agent_destroy_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(binder == NULL, "binder is NULL, FAIL !!!");
+
+       if (binder != NULL) {
+               if (binder->tree != NULL) {
+                       wbxml_tree_destroy(binder->tree);
+                       binder->tree = NULL;
+               }
+               if (binder->tree_stack != NULL) {
+                       g_slist_free(binder->tree_stack);
+                       binder->tree_stack = NULL;
+               }
+               if (binder->current_tree_node != NULL) {
+                       binder->current_tree_node = NULL;       /* DO NOT FREE THIS NODE */
+               }
+               if (binder->binder_functions != NULL) {
+                       binder->binder_functions = NULL;        /* DO NOT FREE THIS */
+               }
+
+               free(binder);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_xml_from_reverse_protocol_binder(sync_agent_pb_protocol_binder_reverse_info_s * binder, char **xml, unsigned int *xml_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL, FAIL !!!");
+
+       _DEBUG_INFO("reverse_protocol_binder_xml_print started\n");
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       unsigned char *out_xml = NULL;
+       unsigned int out_xml_len = 0;
+
+       if (binder->tree == NULL) {
+               err = SYNC_AGENT_PB_RETURN_INIT_REQUIRED_OR_INVALID_BINDER;
+               goto return_part;
+       }
+
+       if (binder->dec == SYNC_AGENT_PB_DECODING_XML) {
+               err = SYNC_AGENT_PB_RETURN_NOT_SUPPORT_FOR_XML_DECODING;
+               goto return_part;
+       }
+
+       WBXMLGenXMLParams params = { WBXML_GEN_XML_INDENT, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, 4, FALSE };
+       WBXMLError wbxml_err = wbxml_tree_to_xml(binder->tree, &out_xml, &out_xml_len, &params);
+       if (wbxml_err != WBXML_OK) {
+               err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+               goto return_part;
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *xml = (char *)out_xml;
+               *xml_size = out_xml_len;
+       }
+
+       _DEBUG_INFO("reverse_protocol_binder_xml_print ended, err = %d\n", err);
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
diff --git a/src/framework/protocol-binder/interface_internal.h b/src/framework/protocol-binder/interface_internal.h
new file mode 100755 (executable)
index 0000000..b867ec3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef INTERFACE_INTERNAL_H_
+#define INTERFACE_INTERNAL_H_
+
+#include "protocol-binder/interface.h"
+
+/**
+ * @file interface_internal.h
+ * @brief Provides binder/reverse binder operation
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/**
+ * @brief Ignore previous binder function set built and rebuild binder function set with new function informations
+ * @param[in] binder_function_set Binder function set
+ * @param[in] new_binder_function_info_cnt Number of new binder function informations
+ * @param[in] new_info_array Array of new binder function informations
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY Out of memory
+ */
+sync_agent_pb_error_e pb_reset_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set, unsigned int new_binder_function_info_cnt, sync_agent_pb_function_info_s * new_info_array);
+
+/**
+ *     @}
+ */
+
+#endif                         /* INTERFACE_INTERNAL_H_ */
diff --git a/src/framework/protocol-binder/internal.h b/src/framework/protocol-binder/internal.h
new file mode 100755 (executable)
index 0000000..1138c43
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PROTOCOL_BINDER_INTERNAL_H_
+#define PROTOCOL_BINDER_INTERNAL_H_
+
+#include "protocol-binder/common.h"
+#include "protocol-binder/interface.h"
+#include <glib.h>
+#include <stdbool.h>
+
+/* protocol binder */
+
+/**
+ * @file internal.h
+ * @brief define binder/reverse binder structure
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/**
+ * @brief Structure for Binder function set
+ */
+struct protocol_binder_function_set {
+       unsigned int set_size;                                          /**< function set size*/
+       sync_agent_pb_function_info_s *info_array;      /**< function info array*/
+
+       GHashTable *protocol_element_lookup_tbl;                        /**< protocol element lookup table*/
+       GHashTable *protocol_element_xml_name_lookup_tbl;       /**< protocol element xml name lookup table*/
+};
+
+/**
+ * @brief Structure for protocol binder
+ */
+struct protocol_binder_info {
+       sync_agent_pb_protocol_e protocol;                      /**< protocol */
+       Protocol_Option_Ptr option;                                     /**< option pointer */
+       sync_agent_pb_encoding_e enc;                           /**< encoding */
+       bool encode_xml_header; /**< encode xml header(use only when enc = SYNC_AGENT_PB_ENCODING_XML) */
+       bool use_strtbl;        /**< use string table(use only when enc = ENCODING_WBXML_...) */
+       bool produce_anonymous; /**< produce anonymous(use only when enc = ENCODING_WBXML_...) */
+       bool use_flow_mode;                     /**< use flow mode */
+       GList *restrict_params;         /**< restrict parameters */
+       sync_agent_restrict_condition_checker_cb restrict_condition_checker;            /**< restrict condition checker */
+       sync_agent_pb_protocol_binder_function_set_s *binder_functions;                 /**< binder functions */
+
+       WBXMLLangEntry *lang_table;             /**< language table */
+       WBXMLLangEntry *prev_lang_table;                        /**< previous language table */
+       /* use only if flow_mode = false */
+       WBXMLTree *tree;                                /**< tree */
+
+       /* use only if flow mode = true */
+       WBXMLEncoder *wbxml_encoder;            /**< wbxml encoder */
+
+       GSList *tree_node_stack;                        /**< tree node stack */
+       bool is_current_node_terminal;          /**< whether current node is terminal or not */
+};
+
+/* reverse protocol binder */
+
+/**
+ * @brief Structure for reverse protocol binder
+ */
+struct protocol_binder_reverse_info {
+       sync_agent_pb_protocol_e protocol;                      /**< protocol */
+       sync_agent_pb_decoding_e dec;                           /**< decoding */
+       sync_agent_pb_protocol_binder_function_set_s *binder_functions;                 /**< function set */
+       void *user_data;                                        /**< user data */
+
+       WBXMLTree *tree;        /**< tree */
+       GSList *tree_stack;     /**< tree_stack(this part is needed for traversing wbxml tree with two language) */
+       WBXMLTreeNode *current_tree_node;       /**< current tree node */
+       bool current_tree_node_first_visit;             /**< whether current node is terminal or not */
+
+       bool no_tree_node_visited;                      /**< no tree node visited */
+       bool all_tree_node_visited;                     /**< all tree node visited */
+};
+
+/**
+ *     @}
+ */
+
+#endif                         /* PROTOCOL_BINDER_INTERNAL_H_ */
diff --git a/src/framework/protocol-binder/util.c b/src/framework/protocol-binder/util.c
new file mode 100755 (executable)
index 0000000..fa765f2
--- /dev/null
@@ -0,0 +1,1019 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <libxml/parser.h>
+
+#include "protocol-binder/util_internal.h"
+#include "protocol-binder/internal.h"
+#include "utility/sync_util.h"
+#include "utility/fw_assert.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_PB_UTIL"
+#endif
+
+/* internal function */
+unsigned int pb_remove_xml_header(char *xml, unsigned int xml_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* note that xml generated by wbxml library always have <!DOCTYPE */
+       char *doctype_part_start = strstr(xml, "<!DOCTYPE");
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(doctype_part_start != NULL, "<!DOCTYPE part missing in XML\n");
+
+       unsigned int xml_len_before_doctype_part_start = doctype_part_start - xml;
+       _DEBUG_INFO("doctype_part_start = %s\n", doctype_part_start);
+
+       char *doctype_part_end = strchr(doctype_part_start, '>');
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(doctype_part_end != NULL, "<!DOCTYPE part doesn't finished\n");
+
+       char *after_doctype_part = strchr(doctype_part_end, '<');
+       SYNC_AGENT_UTIL_ASSERT_CONDITION(doctype_part_end != NULL, "No xml tag after xml header part\n");
+
+       unsigned int xml_len_doctype_part = after_doctype_part - doctype_part_start;
+       _DEBUG_INFO("after_doctype_part = %s\n", after_doctype_part);
+
+       unsigned int xml_len_after_doctype_part = xml_len - xml_len_before_doctype_part_start - xml_len_doctype_part;
+       _DEBUG_INFO("ret_xml_len = %d, xml_len_before_doctype_part_start = %d, xml_len_doctype_part = %d\n", xml_len, xml_len_before_doctype_part_start, xml_len_doctype_part);
+
+#ifndef NDEBUG
+       unsigned int xml_len_after_doctype_part_expected = strlen(after_doctype_part);
+       _DEBUG_INFO("real = %d, expected = %d\n", xml_len_after_doctype_part, xml_len_after_doctype_part_expected);
+#endif                         /* NDEBUG */
+
+       memmove(xml, after_doctype_part, xml_len_after_doctype_part + 1);
+       _DEBUG_INFO("xml without header = %s\n", xml);
+
+       _EXTERN_FUNC_EXIT;
+
+       return xml_len_after_doctype_part;
+}
+
+/* external functions */
+EXPORT_API sync_agent_pb_error_e sync_agent_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_protocol_e protocol)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WBXMLLanguage lang = pb_get_wbxml_language(protocol);
+       if (lang == WBXML_LANG_UNKNOWN) {
+               err = SYNC_AGENT_PB_RETURN_INVALID_PROTOCOL;
+               goto return_part;
+       }
+
+       if (binder->prev_lang_table != NULL) {
+               err = SYNC_AGENT_PB_RETURN_ALREADY_SWITCH_PROTOCOL;
+               goto return_part;
+       }
+
+       binder->prev_lang_table = binder->lang_table;
+       binder->lang_table = (WBXMLLangEntry *) wbxml_tables_get_table(lang);
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_undo_switch_protocol(sync_agent_pb_protocol_binder_info_s * binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       if (binder->prev_lang_table == NULL) {
+               err = SYNC_AGENT_PB_RETURN_HAS_NO_UNDO_SWITCH_PROTOCOL;
+               goto return_part;
+       }
+
+       binder->lang_table = binder->prev_lang_table;
+       binder->prev_lang_table = NULL;
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+EXPORT_API WBXMLTree *sync_agent_create_wbxml_tree(const sync_agent_pb_protocol_binder_info_s * binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+
+       WBXMLCharsetMIBEnum orig_charset = WBXML_PARSER_DEFAULT_CHARSET;
+       WBXMLLanguage lang = binder->lang_table->langID;
+
+       _EXTERN_FUNC_EXIT;
+
+       return wbxml_tree_create(lang, orig_charset);
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_add_wbxml_tree_to_wbxml_node(WBXMLTreeNode * parent_node, WBXMLTree * tree)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent_node == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent_node is NULL. FAIL !!!");
+       retvm_if(tree == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "tree is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WBXMLTreeNode *tree_node = wbxml_tree_node_create(WBXML_TREE_TREE_NODE);
+       if (tree_node == NULL) {
+               err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       WB_BOOL success = wbxml_tree_node_add_child(parent_node, tree_node);
+       if (!success) {
+               err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+               wbxml_tree_node_destroy(tree_node);
+               goto return_part;
+       }
+
+       tree_node->tree = tree;
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_set_wbxml_tree_root(WBXMLTree * tree, WBXMLTreeNode * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(node == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "node is NULL. FAIL !!!");
+       retvm_if(tree == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "tree is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WB_BOOL success = wbxml_tree_add_node(tree, NULL, node);
+       if (!success) {
+               err = SYNC_AGENT_PB_RETURN_TREE_ALREADY_HAS_ROOT;
+               goto return_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_create_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return wbxml_tree_node_create_xml_elt(binder->lang_table, (unsigned char *)xml_name);
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_create_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+       retvm_if(name_space == NULL, NULL, "name_space is NULL. FAIL !!!");
+       retvm_if(xml_name == NULL, NULL, "xml_name is NULL. FAIL !!!");
+
+       WBXMLTreeNode *node = NULL;
+
+       const WBXMLTagEntry *tag_entry = NULL;
+       WBXMLTag *tag = NULL;
+       WB_UTINY code_page = 0;
+
+       code_page = wbxml_tables_get_code_page(binder->lang_table->nsTable, name_space);
+       if ((tag_entry = wbxml_tables_get_tag_from_xml(binder->lang_table, code_page, (unsigned char *)xml_name)) != NULL) {
+               /* token tag */
+               tag = wbxml_tag_create_token(tag_entry);
+       } else {
+               tag = wbxml_tag_create_literal((unsigned char *)xml_name);
+       }
+
+       if (tag == NULL)
+               return NULL;
+
+       /* Create a new Node */
+       if ((node = wbxml_tree_node_create(WBXML_TREE_ELEMENT_NODE)) == NULL) {
+               wbxml_tag_destroy(tag);
+               return NULL;
+       }
+
+       /* Set Node Tag */
+       node->name = tag;
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_create_text_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return wbxml_tree_node_create_xml_elt_with_text(binder->lang_table, (unsigned char *)xml_name, (unsigned char *)text, text_len);
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_create_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *name_space, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+       retvm_if(name_space == NULL, NULL, "name_space is NULL. FAIL !!!");
+       retvm_if(xml_name == NULL, NULL, "xml_name is NULL. FAIL !!!");
+       retvm_if(text == NULL, NULL, "text is NULL. FAIL !!!");
+
+       WBXMLTreeNode *node = NULL;
+       WBXMLTreeNode *text_node = NULL;
+
+       node = sync_agent_create_node_with_namespace(binder, xml_name, name_space);
+       if (node == NULL) {
+               return NULL;
+       }
+
+       /* Create text node */
+       if ((text_node = wbxml_tree_node_create_text((unsigned char *)text, text_len)) == NULL) {
+               wbxml_tree_node_destroy(node);
+               return NULL;
+       }
+
+       /* Add text node to element node */
+       if (!wbxml_tree_node_add_child(node, text_node)) {
+               wbxml_tree_node_destroy(node);
+               wbxml_tree_node_destroy(text_node);
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_create_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, const char *xml_name, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, NULL, "binder is NULL. FAIL !!!");
+       retvm_if(xml_name == NULL, NULL, "xml_name is NULL. FAIL !!!");
+       retvm_if(text == NULL, NULL, "text is NULL. FAIL !!!");
+
+       bool success = false;
+       WBXMLTreeNode *wbxml_tree_node = wbxml_tree_node_create_xml_elt(binder->lang_table, (unsigned char *)xml_name);
+       if (wbxml_tree_node == NULL) {
+               goto return_part;
+       }
+
+       if (text != NULL) {
+               WBXMLTreeNode *text_node = wbxml_tree_node_create_cdata((unsigned char *)text, text_len);
+               if (text_node == NULL) {
+                       success = false;
+                       goto return_part;
+               }
+
+               success = sync_agent_wbxml_node_add_child_node(wbxml_tree_node, text_node);
+               if (!success) {
+                       wbxml_tree_node_destroy(text_node);
+                       goto return_part;
+               }
+       }
+
+ return_part:
+       if (!success) {
+               if (wbxml_tree_node != NULL) {
+                       wbxml_tree_node_destroy(wbxml_tree_node);
+                       wbxml_tree_node = NULL;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return wbxml_tree_node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *new_node = sync_agent_create_node(binder, xml_name);
+       if (new_node == NULL) {
+               return new_node;
+       }
+
+       bool success = sync_agent_wbxml_node_add_child_node(parent_node, new_node);
+       if (success) {
+               _EXTERN_FUNC_EXIT;
+               return new_node;
+       } else {
+               wbxml_tree_node_destroy(new_node);
+               return NULL;
+       }
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *new_node = sync_agent_create_node_with_namespace(binder,
+                                                                       xml_name,
+                                                                       name_space);
+       if (new_node == NULL) {
+               return NULL;
+       }
+
+       bool success = sync_agent_wbxml_node_add_child_node(parent_node, new_node);
+       if (success) {
+               _EXTERN_FUNC_EXIT;
+               return new_node;
+       } else {
+               wbxml_tree_node_destroy(new_node);
+               return NULL;
+       }
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_text_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *new_node = sync_agent_create_text_node(binder, xml_name, text, text_len);
+       if (new_node == NULL) {
+               return new_node;
+       }
+
+       bool success = sync_agent_wbxml_node_add_child_node(parent_node, new_node);
+       if (success) {
+               _EXTERN_FUNC_EXIT;
+               return new_node;
+       } else {
+               wbxml_tree_node_destroy(new_node);
+               return NULL;
+       }
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_text_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *new_node = sync_agent_create_text_node_with_namespace(binder,
+                                                                            xml_name,
+                                                                            name_space,
+                                                                            text,
+                                                                            text_len);
+
+       bool success = sync_agent_wbxml_node_add_child_node(parent_node, new_node);
+       if (success) {
+               _EXTERN_FUNC_EXIT;
+               return new_node;
+       } else {
+               wbxml_tree_node_destroy(new_node);
+               return NULL;
+       }
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_cdata_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *text, unsigned int text_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *new_node = sync_agent_create_cdata_node(binder, xml_name, text, text_len);
+       if (new_node == NULL) {
+               return new_node;
+       }
+
+       bool success = sync_agent_wbxml_node_add_child_node(parent_node, new_node);
+       if (success) {
+               _EXTERN_FUNC_EXIT;
+               return new_node;
+       } else {
+               wbxml_tree_node_destroy(new_node);
+               return NULL;
+       }
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_int_node(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const int num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *node = NULL;
+       char *num_string = g_strdup_printf("%d", num);
+       if (num_string == NULL) {
+               return NULL;
+       }
+
+       node = sync_agent_add_child_text_node(binder, parent_node, xml_name, num_string, strlen(num_string));
+       g_free(num_string);
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_int_node_with_namespace(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const int num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *node = NULL;
+       char *num_string = g_strdup_printf("%d", num);
+       if (num_string == NULL) {
+               return NULL;
+       }
+
+       node = sync_agent_add_child_text_node_with_namespace(binder, parent_node, xml_name, name_space, num_string, strlen(num_string));
+       g_free(num_string);
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_wbxml_node_using_xml_name_with_unsigned_int(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const unsigned int num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *node = NULL;
+       char *num_string = g_strdup_printf("%u", num);
+       if (num_string == NULL) {
+               return NULL;
+       }
+
+       node = sync_agent_add_child_text_node(binder, parent_node, xml_name, num_string, strlen(num_string));
+       g_free(num_string);
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API WBXMLTreeNode *sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_unsigned_int(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const unsigned int num)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLTreeNode *node = NULL;
+       char *num_string = g_strdup_printf("%u", num);
+       if (num_string == NULL) {
+               return NULL;
+       }
+
+       node = sync_agent_add_child_text_node_with_namespace(binder, parent_node, xml_name, name_space, num_string, strlen(num_string));
+       g_free(num_string);
+
+       _EXTERN_FUNC_EXIT;
+
+       return node;
+}
+
+EXPORT_API bool sync_agent_wbxml_node_add_child_node(WBXMLTreeNode * parent, WBXMLTreeNode * child)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return wbxml_tree_node_add_child(parent, child);
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_name_from_element_node(const WBXMLTreeNode * element_node, char **element_xml_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(element_node == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "element_node is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       char *out_element_xml_name = NULL;
+
+       if (!pb_has_wbxml_node_same_type((WBXMLTreeNode *) element_node, WBXML_TREE_ELEMENT_NODE)) {
+               err = SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE;
+               goto return_part;
+       }
+
+       if (element_node->name != NULL) {
+               out_element_xml_name = (char *)wbxml_tag_get_xml_name(element_node->name);
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *element_xml_name = out_element_xml_name;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_namespace_from_element_node(const sync_agent_pb_protocol_binder_reverse_info_s * binder, const WBXMLTreeNode * element_node, char **name_space)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(binder == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "binder is NULL. FAIL !!!");
+       retvm_if(element_node == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "element_node is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       char *out_namespace = NULL;
+
+       if (!pb_has_wbxml_node_same_type((WBXMLTreeNode *) element_node, WBXML_TREE_ELEMENT_NODE)) {
+               err = SYNC_AGENT_PB_RETURN_TREE_NODE_IS_NOT_ELEMENT_NODE;
+               goto return_part;
+       }
+
+       if (element_node->name != NULL && element_node->name->type == WBXML_VALUE_TOKEN) {
+               const WBXMLLangEntry *pLang = pb_get_current_subtree_lang((sync_agent_pb_protocol_binder_reverse_info_s *) binder);
+               assert(pLang != NULL);
+
+               out_namespace = (char *)wbxml_tables_get_xmlns(pLang->nsTable, element_node->name->u.token->wbxmlCodePage);
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *name_space = out_namespace;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_text_from_node(WBXMLTreeNode * parent, char **text_pointer)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       if (parent->children != NULL && parent->children->type == WBXML_TREE_TEXT_NODE && parent->children->content != NULL) {
+               *text_pointer = (char *)wbxml_buffer_get_cstr(parent->children->content);
+       } else {
+               *text_pointer = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_binary_from_node(WBXMLTreeNode * parent, char **binary_pointer, unsigned int *binary_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       if (parent->children != NULL && parent->children->type == WBXML_TREE_TEXT_NODE && parent->children->content != NULL) {
+               *binary_pointer = (char *)wbxml_buffer_get_cstr(parent->children->content);
+               *binary_size = wbxml_buffer_len(parent->children->content);
+       } else {
+               err = SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_int_from_node(WBXMLTreeNode * parent, int *value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       char *text_pointer = NULL;
+       err = sync_agent_get_text_from_node(parent, &text_pointer);
+       /*if (err != SYNC_AGENT_PB_RETURN_OK) {
+          assert(err == SYNC_AGENT_PB_RETURN_UTIL_NO_TEXT_VALUE);
+          err = SYNC_AGENT_PB_RETURN_UTIL_NO_INT_VALUE;
+          return err;
+          } */
+
+       if (text_pointer != NULL) {
+               *value = atoi(text_pointer);
+       } else {
+               err = SYNC_AGENT_PB_RETURN_UTIL_NO_INT_VALUE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_text_from_cdata_node(WBXMLTreeNode * parent, char **text_pointer)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTreeNode *cdata_node = parent->children;
+
+       if (cdata_node != NULL && cdata_node->type == WBXML_TREE_CDATA_NODE) {
+               err = sync_agent_get_text_from_node(cdata_node, text_pointer);
+       } else {
+               *text_pointer = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_get_binary_pointer_from_wbxml_cdata_node(WBXMLTreeNode * parent, char **binary_pointer, unsigned int *binary_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(parent == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "parent is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTreeNode *cdata_node = parent->children;
+
+       if (cdata_node != NULL && cdata_node->type == WBXML_TREE_CDATA_NODE) {
+               err = sync_agent_get_binary_from_node(cdata_node, binary_pointer, binary_size);
+       } else {
+               err = SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+EXPORT_API sync_agent_pb_error_e sync_agent_destroy_wbxml_node(WBXMLTreeNode * node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(node == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "node is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       wbxml_tree_node_destroy_all(node);
+       node = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+sync_agent_pb_error_e pb_get_wbxml_tree_from_wbxml(char *byte_stream, int byte_stream_len, WBXMLLanguage wbxml_lang, WBXMLTree ** wbxml_tree)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(byte_stream == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "byte_stream is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTree *ret_wbxml_tree = NULL;
+
+       _DEBUG_INFO("start with byte_stream = %x, byte_stream_len = %d\n", byte_stream, byte_stream_len);
+       WBXMLError wbxml_err = wbxml_tree_from_wbxml((unsigned char *)byte_stream, byte_stream_len, wbxml_lang, WBXML_CHARSET_UNKNOWN, &ret_wbxml_tree);
+
+       if (wbxml_err != WBXML_OK) {
+               _DEBUG_ERROR("wbxml_tree_from_wbxml error occurred. wbxml error(%d) = %s", wbxml_err, wbxml_errors_string(wbxml_err));
+               err = SYNC_AGENT_PB_RETURN_WBXML_PARSE_FAIL;
+               goto return_part;
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *wbxml_tree = ret_wbxml_tree;
+       }
+       _DEBUG_INFO("ended with err = %d\n", err);
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+sync_agent_pb_error_e pb_get_wbxml_tree_from_xml(char *byte_stream, int byte_stream_len, WBXMLLanguage wbxml_lang, WBXMLTree ** wbxml_tree)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(byte_stream == NULL, SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER, "byte_stream is NULL. FAIL !!!");
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTree *ret_wbxml_tree = NULL;
+
+       _DEBUG_INFO("start with byte_stream = %x, byte_stream_len = %d\n", byte_stream, byte_stream_len);
+       WBXMLError wbxml_err = wbxml_tree_from_xml_with_lang((unsigned char *)byte_stream, byte_stream_len, wbxml_lang, &ret_wbxml_tree);
+
+       if (wbxml_err != WBXML_OK) {
+               _DEBUG_ERROR("wbxml_tree_from_xml error occurred. wbxml error(%d) = %s", wbxml_err, wbxml_errors_string(wbxml_err));
+               err = SYNC_AGENT_PB_RETURN_XML_PARSE_FAIL;
+               goto return_part;
+       }
+
+ return_part:
+       if (err == SYNC_AGENT_PB_RETURN_OK) {
+               *wbxml_tree = ret_wbxml_tree;
+       }
+       _DEBUG_INFO("ended with err = %d\n", err);
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+bool pb_validate_protocol(sync_agent_pb_protocol_e protocol)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (SYNC_AGENT_PB_PROTOCOL_UNKNOWN <= protocol && protocol < SYNC_AGENT_PB_PROTOCOL_MAX_COUNT) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+WBXMLLanguage pb_get_wbxml_language(sync_agent_pb_protocol_e protocol)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLLanguage lang = WBXML_LANG_UNKNOWN;
+
+       switch (protocol) {
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML10:
+               lang = WBXML_LANG_SYNCML_SYNCML10;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML11:
+               lang = WBXML_LANG_SYNCML_SYNCML11;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12:
+               lang = WBXML_LANG_SYNCML_SYNCML12;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF10:
+               lang = WBXML_LANG_SYNCML_DEVINF10;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF11:
+               lang = WBXML_LANG_SYNCML_DEVINF11;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12:
+               lang = WBXML_LANG_SYNCML_DEVINF12;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF10:
+               lang = WBXML_LANG_SYNCML_METINF10;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF11:
+               lang = WBXML_LANG_SYNCML_METINF11;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF12:
+               lang = WBXML_LANG_SYNCML_METINF12;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12:
+               lang = WBXML_LANG_SYNCML_DMDDF12;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_ACTIVESYNC:
+               lang = WBXML_LANG_ACTIVESYNC;
+               break;
+       case SYNC_AGENT_PB_PROTOCOL_PROV10:
+               lang = WBXML_LANG_PROV10;
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return lang;
+}
+
+sync_agent_pb_protocol_e pb_get_protocol_from_wbxml_lang(WBXMLLanguage wbxml_lang)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+
+       switch (wbxml_lang) {
+       case WBXML_LANG_SYNCML_SYNCML10:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML10;
+               break;
+       case WBXML_LANG_SYNCML_SYNCML11:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML11;
+               break;
+       case WBXML_LANG_SYNCML_SYNCML12:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12;
+               break;
+       case WBXML_LANG_SYNCML_DEVINF10:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF10;
+               break;
+       case WBXML_LANG_SYNCML_DEVINF11:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF11;
+               break;
+       case WBXML_LANG_SYNCML_DEVINF12:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12;
+               break;
+       case WBXML_LANG_SYNCML_METINF10:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF10;
+               break;
+       case WBXML_LANG_SYNCML_METINF11:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF11;
+               break;
+       case WBXML_LANG_SYNCML_METINF12:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_METINF12;
+               break;
+       case WBXML_LANG_SYNCML_DMDDF12:
+               protocol = SYNC_AGENT_PB_PROTOCOL_SYNCML_DMDDF12;
+               break;
+       case WBXML_LANG_ACTIVESYNC:
+               protocol = SYNC_AGENT_PB_PROTOCOL_ACTIVESYNC;
+               break;
+       case WBXML_LANG_PROV10:
+               protocol = SYNC_AGENT_PB_PROTOCOL_PROV10;
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return protocol;
+}
+
+WBXMLVersion pb_get_wbxml_version(sync_agent_pb_encoding_e enc)
+{
+       _EXTERN_FUNC_ENTER;
+
+       WBXMLVersion version = WBXML_VERSION_UNKNOWN;
+       switch (enc) {
+       case SYNC_AGENT_PB_ENCODING_WBXML_10:
+               version = WBXML_VERSION_10;
+               break;
+       case SYNC_AGENT_PB_ENCODING_WBXML_11:
+               version = WBXML_VERSION_11;
+               break;
+       case SYNC_AGENT_PB_ENCODING_WBXML_12:
+               version = WBXML_VERSION_12;
+               break;
+       case SYNC_AGENT_PB_ENCODING_WBXML_13:
+               version = WBXML_VERSION_13;
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return version;
+}
+
+WBXMLTreeNode *pb_get_next_node_of_tree_node(WBXMLTreeNode * node, bool * first_visit)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(node == NULL, NULL, "node is NULL. FAIL !!!");
+
+       WBXMLTreeNode *next_node = NULL;
+
+       if (*first_visit) {
+               /* *first_visit = true; */
+
+               /* get tree node */
+               next_node = node->tree->root;
+
+               /* if child node does not exist, then mark second visit and set current_node as next_node */
+               if (next_node == NULL) {
+                       *first_visit = false;
+                       next_node = node;
+               }
+       } else {
+               next_node = node->next;
+
+               /* if next node exist */
+               if (next_node != NULL) {
+                       *first_visit = true;
+               }
+               /* if next node does not exist, then set next node as parent node */
+               else {
+                       /* *first_visit = false; */
+                       next_node = node->parent;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return next_node;
+}
+
+WBXMLTreeNode *pb_get_next_node_of_element_node(WBXMLTreeNode * node, bool * first_visit)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(node == NULL, NULL, "node is NULL. FAIL !!!");
+
+       WBXMLTreeNode *next_node = NULL;
+
+       if (*first_visit) {
+               /* *first_visit = true; */
+
+               /* get child node */
+               next_node = node->children;
+
+               /* if child node does not exist, then mark second visit and set current_node as next_node */
+               if (next_node == NULL) {
+                       *first_visit = false;
+                       next_node = node;
+               }
+       } else {
+               next_node = node->next;
+
+               /* if next node exist */
+               if (next_node != NULL) {
+                       *first_visit = true;
+               }
+               /* if next node does not exist, then set next node as parent node */
+               else {
+                       /* *first_visit = false; */
+                       next_node = node->parent;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return next_node;
+}
+
+const WBXMLLangEntry *pb_get_current_subtree_lang(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(reverse_binder == NULL, NULL, "reverse_binder is NULL. FAIL !!!");
+
+       const WBXMLLangEntry *lang = NULL;
+
+       if (reverse_binder->tree_stack != NULL) {
+               /* current node belongs to subtree of root tree */
+               WBXMLTreeNode *tree_node = (WBXMLTreeNode *) (reverse_binder->tree_stack->data);
+               assert(tree_node != NULL);
+               assert(pb_has_wbxml_node_same_type(tree_node, WBXML_TREE_TREE_NODE));
+
+               lang = tree_node->tree->lang;
+       } else {
+               lang = reverse_binder->tree->lang;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return lang;
+}
+
+bool pb_has_wbxml_node_same_type(WBXMLTreeNode * node, WBXMLTreeNodeType type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(node == NULL, NULL, "node is NULL. FAIL !!!");
+
+       bool ret = false;
+       if (node->type == type) {
+               ret = true;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+void pb_print_wbxml_dom_in_xml(const WBXMLTree * tree)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(tree == NULL, "tree is NULL. FAIL !!!");
+
+       /* debugging */
+       unsigned char *xml = NULL;
+       unsigned int xml_len = 0;
+       WBXMLGenXMLParams params = { WBXML_GEN_XML_INDENT, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, 4, FALSE };
+       WBXMLError wbxml_err = wbxml_tree_to_xml((WBXMLTree *) tree, &xml, &xml_len, &params);
+
+       if (wbxml_err != WBXML_OK) {
+               /* TODO : _DEBUG_ERROR using wbxml_errors_string(wbxml_err) */
+               return;
+       }
+
+       _DEBUG_INFO("xml printing : \n%s\n", xml);
+       if (xml != NULL) {
+               free(xml);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+}
diff --git a/src/framework/protocol-binder/util_internal.h b/src/framework/protocol-binder/util_internal.h
new file mode 100755 (executable)
index 0000000..de6b11f
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UTIL_INTERNAL_H_
+#define UTIL_INTERNAL_H_
+
+#include "protocol-binder/util.h"
+
+/**
+ * @file util_internal.h
+ * @brief Provides protocol-binder utility operation set
+ */
+
+/** @addtogroup protocol_binder
+ *     @{
+ */
+
+/**
+ * @brief XML document adjusting
+ * @remarks Remove XML header from XML msg
+ * @param[in] xml Pointer of XML message
+ * @param[in] xml_len Length of XML
+ * @return Length of XML after remove header
+ */
+unsigned int pb_remove_xml_header(char *xml, unsigned int xml_len);
+
+/* wbxml related part */
+/**
+ * @brief Validate protocol
+ * @remarks Validate that protocol is supported by portocol binder
+ * @param[in] protocol Enum value that means specific protocol
+ * @return True on success, False on fail
+ */
+bool pb_validate_protocol(sync_agent_pb_protocol_e protocol);
+
+/**
+ * @brief Get WBXMLLanguage enum value
+ * @remarks Convert to WBXMLLanguage from Protocol
+ * @param[in] protocol Enum value that means specific protocol
+ * @return WBXMLLanguage enum value on success
+ */
+WBXMLLanguage pb_get_wbxml_language(sync_agent_pb_protocol_e protocol);
+
+/**
+ * @brief Get Protocol enum value
+ * @remarks Convert to Protocol from WBXMLLanguage
+ * @param[in] wbxml_lang WBXMLLanguage enum value
+ * @return Protocol enum value on success
+ */
+sync_agent_pb_protocol_e pb_get_protocol_from_wbxml_lang(WBXMLLanguage wbxml_lang);
+
+/**
+ * @brief Get WBXMLVersion enum value
+ * @remarks Convert to WBXMLVersion from sync_agent_pb_encoding_e
+ * @param[in] enc WBXMLVersion enum value
+ * @return WBXMLVersion enum value on success
+ */
+WBXMLVersion pb_get_wbxml_version(sync_agent_pb_encoding_e enc);
+
+/**
+ * @brief Get WBXML tree from WBXML byte stream
+ * @remarks Parse WBXML byte stream and build WBXMLTree
+ * @param[in] byte_stream Byte stream of WBXML message
+ * @param[in] byte_stream_len Length of WBXML message
+ * @param[in] wbxml_lang WBXMLLanguage enum value
+ * @param[out] wbxml_tree WBXMLTree
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_WBXML_PARSE_FAIL Parse failed
+ */
+sync_agent_pb_error_e pb_get_wbxml_tree_from_wbxml(char *byte_stream, int byte_stream_len, WBXMLLanguage wbxml_lang, WBXMLTree ** wbxml_tree);
+
+/**
+ * @brief Get WBXML tree from XML byte stream
+ * @remarks Parse WBXML byte stream and build WBXMLTree using libwbxml library
+ * @param[in] byte_stream Byte stream of XML message
+ * @param[in] byte_stream_len Length of XML message
+ * @param[in] wbxml_lang WBXMLLanguage enum value
+ * @param[out] wbxml_tree WBXMLTree
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_WBXML_PARSE_FAIL Parse failed
+ */
+sync_agent_pb_error_e pb_get_wbxml_tree_from_xml(char *byte_stream, int byte_stream_len, WBXMLLanguage wbxml_lang, WBXMLTree ** wbxml_tree);
+
+/**
+ * @brief Get next WBXMLTreeNode from current WBXMLTreeNode
+ * @remarks if current WBXMLTreeNode's type is
+ * WBXML_TREE_TREE_NODE(WBXMLTree has a subtree as a tree node),
+ * use this API to get next WBXMLTreeNode of subtree
+ * @param[in] node Current WBXMLTreeNode
+ * @param[out] first_visit Whether first visit for this tree node or not
+ * @return WBXMLTreeNode on success
+ */
+WBXMLTreeNode *pb_get_next_node_of_tree_node(WBXMLTreeNode * node, bool * first_visit);
+
+/**
+ * @brief Get next WBXMLTreeNode from current WBXMLTreeNode
+ * @remarks if current WBXMLTreeNode's type is not  WBXML_TREE_TREE_NODE,
+ * use this API to get next WBXMLTreeNode of current WBXMLTreeNode
+ * @param[in] node Current WBXMLTreeNode
+ * @param[out] first_visit Whether first visit for this tree node or not
+ * @return WBXMLTreeNode on success
+ */
+WBXMLTreeNode *pb_get_next_node_of_element_node(WBXMLTreeNode * node, bool * first_visit);
+
+/**
+ * @brief Get WBXMLLangEntry of subtree
+ * @param[in] reverse_binder sync_agent_pb_protocol_binder_reverse_info_s
+ * @return WBXMLLangEntry on success
+ */
+const WBXMLLangEntry *pb_get_current_subtree_lang(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder);
+
+/**
+ * @brief whether node has a same type as inputted type
+ * @param[in] node WBXMLTreeNode
+ * @param[in] type WBXMLTreeNodeType
+ * @return true is node has a type which is inputted, false is not
+ */
+bool pb_has_wbxml_node_same_type(WBXMLTreeNode * node, WBXMLTreeNodeType type);
+
+/**
+ * @brief print XML from current WBXMLTree
+ * @param[in] tree WBXMLTree
+ */
+void pb_print_wbxml_dom_in_xml(const WBXMLTree * tree);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name with unsigned int content, and add WBXMLTreeNode to parent node as a child node
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] num Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ */
+WBXMLTreeNode *sync_agent_add_child_wbxml_node_using_xml_name_with_unsigned_int(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const unsigned int num);
+
+/**
+ * @brief Create WBXMLTreeNode using XML element name and XML name space with unsigned int content, and add WBXMLTreeNode to parent node as a child node
+ * @param[in] binder sync_agent_pb_protocol_binder_info_s
+ * @param[in] parent_node Parent node
+ * @param[in] xml_name XML element name
+ * @param[in] name_space XML name space
+ * @param[in] num Content
+ * @return WBXMLTreeNode on success, NULL on fail
+ */
+WBXMLTreeNode *sync_agent_add_child_wbxml_node_using_xml_name_and_namespace_with_unsigned_int(const sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, const char *xml_name, const char *name_space, const unsigned int num);
+
+/**
+ * @brief Add WBXMLTreeNode to parent node as a child node
+ * @param[in] parent Parent node
+ * @param[in] child Child node
+ * @return WBXMLTreeNode on success, NULL on fail
+ */
+bool sync_agent_wbxml_node_add_child_node(WBXMLTreeNode * parent, WBXMLTreeNode * child);
+
+/**
+ * @brief Get pointer of binary content from WBXMLTreeNode(cdata node)
+ * @param[in] element_node WBXMLTreeNode
+ * @param[out] binary_pointer Pointer of binary content
+ * @param[out] binary_size Size of binary content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval SYNC_AGENT_PB_RETURN_OK Successful
+ * @retval SYNC_AGENT_PB_RETURN_UTIL_NO_BINARY_VALUE Invalid parameter(element_node)
+ */
+sync_agent_pb_error_e sync_agent_get_binary_pointer_from_wbxml_cdata_node(WBXMLTreeNode * element_node, char **binary_pointer, unsigned int *binary_size);
+
+/**
+ *     @}
+ */
+
+#endif                         /* UTIL_INTERNAL_H_ */
diff --git a/src/framework/security-assistant/cryptograhic_hash_function.c b/src/framework/security-assistant/cryptograhic_hash_function.c
new file mode 100755 (executable)
index 0000000..cf0db1e
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "security-assistant/cryptograhic_hash_function.h"
+#include <gcrypt.h>
+#include <gpg-error.h>
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_SA"
+#endif
+
+static unsigned char *_crypt_crytograhic_hash_function(int algo, const char *data, int data_len, const char *key, int key_len, int flags);
+static unsigned char *_crypt_symmetric_cipher_function(const char *plain, int plain_len, const char *key, int key_len, int flags);
+
+unsigned char *sa_crypt_des(const char *plain, int plain_len, const char *key, int key_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int flags = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _crypt_symmetric_cipher_function(plain, plain_len, key, key_len, flags);
+}
+
+unsigned char *sa_crypt_md5(sync_agent_sa_cryptographic_hash_function_flags_e flags, const char *plain, int plain_len, const char *key, int key_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned char *crypt_data = NULL;
+
+       switch (flags) {
+       case SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC:
+               {
+                       _DEBUG_INFO("SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC");
+                       crypt_data = _crypt_crytograhic_hash_function(GCRY_MD_MD5, plain, plain_len, key, key_len, GCRY_MD_FLAG_HMAC);
+               }
+               break;
+       default:
+               {
+                       _DEBUG_INFO("default");
+                       crypt_data = _crypt_crytograhic_hash_function(GCRY_MD_MD5, plain, plain_len, 0, 0, 0);
+               }
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return crypt_data;
+}
+
+unsigned char *sa_crypt_sha1(sync_agent_sa_cryptographic_hash_function_flags_e flags, const char *plain, int plain_len, const char *key, int key_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned char *crypt_data = NULL;
+
+       switch (flags) {
+       case SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC:
+               {
+                       _DEBUG_INFO("SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC");
+                       crypt_data = _crypt_crytograhic_hash_function(GCRY_MD_SHA1, plain, plain_len, key, key_len, GCRY_MD_FLAG_HMAC);
+               }
+               break;
+       default:
+               {
+                       _DEBUG_INFO("default");
+                       crypt_data = _crypt_crytograhic_hash_function(GCRY_MD_SHA1, plain, plain_len, 0, 0, 0);
+               }
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return crypt_data;
+}
+
+static unsigned char *_crypt_crytograhic_hash_function(int algo, const char *data, int data_len, const char *key, int key_len, int flags)
+{
+       _INNER_FUNC_ENTER;
+
+       gcry_md_hd_t hd, hd2;
+       unsigned char *crypt_data = NULL;
+       unsigned char *p = NULL;
+       int crypt_data_len = 0;
+       int i;
+       gcry_error_t err = 0;
+
+       err = gcry_md_open(&hd, algo, flags);
+       if (err) {
+               _DEBUG_TRACE("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror(err));
+               return NULL;
+       }
+
+       crypt_data_len = gcry_md_get_algo_dlen(algo);
+       if (crypt_data_len < 1 || crypt_data_len > 500) {
+               _DEBUG_TRACE("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, crypt_data_len);
+               return NULL;
+       }
+
+       if (flags != 0) {
+               gcry_md_setkey(hd, key, key_len);
+               if (err) {
+                       _DEBUG_TRACE("algo %d, grcy_md_setkey failed: %s\n", algo, gpg_strerror(err));
+                       return NULL;
+               }
+       }
+
+       if (*data == '!' && !data[1]) { /* hash one million times a "a" */
+               char aaa[1000];
+
+               /* Write in odd size chunks so that we test the buffering.  */
+               memset(aaa, 'a', 1000);
+               for (i = 0; i < 1000; i++)
+                       gcry_md_write(hd, aaa, 1000);
+       } else {
+               gcry_md_write(hd, data, data_len);
+       }
+
+       err = gcry_md_copy(&hd2, hd);
+       if (err) {
+               _DEBUG_TRACE("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror(err));
+       }
+
+       gcry_md_close(hd);
+
+       p = gcry_md_read(hd2, algo);
+       if (p != NULL) {
+               crypt_data = (unsigned char *)strdup((const char *)p);
+       }
+
+       gcry_md_close(hd2);
+
+       _INNER_FUNC_EXIT;
+
+       return crypt_data;
+}
+
+static unsigned char *_crypt_symmetric_cipher_function(const char *plain, int plain_len, const char *key, int key_len, int flags)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return NULL;
+}
diff --git a/src/framework/security-assistant/cryptograhic_hash_function.h b/src/framework/security-assistant/cryptograhic_hash_function.h
new file mode 100755 (executable)
index 0000000..285293e
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CRYPTOGRAHIC_HASH_FUNCTION_H_
+#define CRYPTOGRAHIC_HASH_FUNCTION_H_
+
+#include "security-assistant/encryption_decryption.h"
+
+/**
+ * @file cryptograhic_hash_function.h
+ * @brief Provides encryption hash operation for plain text
+ */
+
+/** @addtogroup security_assistant
+ *     @{
+ */
+
+/**
+ * @brief api to get des
+ * @param[in] plain                    plain
+ * @param[in] plain_len                plain length
+ * @param[in] key                      key
+ * @param[in] key_len          key length
+ * @return encrypted string on success, NULL on fail.
+ * @retval encrypted string Successful
+ * @retval NULL Fail
+ */
+unsigned char *sa_crypt_des(const char *plain, int plain_len, const char *key, int key_len);
+
+/**
+ * @brief api to get md5
+ * @param[in] flags                    sync_agent_sa_cryptographic_hash_function_flags_e
+ * @param[in] plain                    plain
+ * @param[in] plain_len                plain length
+ * @param[in] key                      key
+ * @param[in] key_len          key length
+ * @return encrypted string on success, NULL on fail.
+ * @retval encrypted string Successful
+ * @retval NULL Fail
+ */
+unsigned char *sa_crypt_md5(sync_agent_sa_cryptographic_hash_function_flags_e flags, const char *plain, int plain_len, const char *key, int key_len);
+
+/**
+ * @brief api to get sha1
+ * @param[in] flags                    sync_agent_sa_cryptographic_hash_function_flags_e
+ * @param[in] plain                    plain
+ * @param[in] plain_len                plain length
+ * @param[in] key                      key
+ * @param[in] key_len          key length
+ * @return encrypted string on success, NULL on fail.
+ * @retval encrypted string Successful
+ * @retval NULL Fail
+ */
+unsigned char *sa_crypt_sha1(sync_agent_sa_cryptographic_hash_function_flags_e flags, const char *plain, int plain_len, const char *key, int key_len);
+
+/**
+ *     @}
+ */
+
+#endif                         /* CRYPTOGRAHIC_HASH_FUNCTION_H_ */
diff --git a/src/framework/security-assistant/encryption_decryption.c b/src/framework/security-assistant/encryption_decryption.c
new file mode 100755 (executable)
index 0000000..1d02f5f
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "security-assistant/encryption_decryption.h"
+#include "security-assistant/encryption_decryption_internal.h"
+#include "security-assistant/md5.h"
+#include "security-assistant/cryptograhic_hash_function.h"
+
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_SA"
+#endif
+
+static unsigned char *_encrypt_cryptograhic_hash(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len, const char *key, int key_len, sync_agent_sa_cryptographic_hash_function_flags_e flags);
+
+EXPORT_API unsigned char *sync_agent_get_encryption_value(sync_agent_sa_encryption_type_e encryption_type, char *plain, int plain_length)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(plain == NULL, NULL, "plain parameter is NULL !!!");
+       retvm_if(plain_length == 0, NULL, "plain_length parameter is 0 !!!");
+
+       unsigned char *encryption_text = NULL;
+
+       switch (encryption_type) {
+       case SYNC_AGENT_SA_ENCRYPTION_BASIC:
+               {
+                       _DEBUG_INFO("SYNC_AGENT_SA_ENCRYPTION_BASIC");
+               }
+               break;
+       case SYNC_AGENT_SA_ENCRYPTION_MD5:
+               {
+                       _DEBUG_INFO("SYNC_AGENT_SA_ENCRYPTION_MD5");
+                       unsigned char *digest = (unsigned char *)calloc(16, sizeof(unsigned char));
+                       if (digest == NULL) {
+                               _DEBUG_ERROR("CALLOC failed !!!");
+                               return NULL;
+                       }
+                       sa_md5_get_digest(plain, plain_length, digest);
+
+                       /* print */
+                       int i;
+                       for (i = 0; i < strlen((const char *)digest); i++) {
+                               _DEBUG_INFO("%x", digest[i]);
+                       }
+                       _DEBUG_INFO("\n");
+
+                       encryption_text = digest;
+
+               }
+               break;
+       default:
+               /* no case  */
+               break;
+       }
+
+       _DEBUG_INFO("plain_text = %s, length = %d", plain, plain_length);
+       _DEBUG_INFO("encrption_text = %s", encryption_text);
+       return encryption_text;
+}
+
+char *sa_get_decryption_value(sync_agent_sa_encryption_type_e decryption_type, char *encryption_text)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *decyption_text = NULL;
+
+       switch (decryption_type) {
+       case SYNC_AGENT_SA_ENCRYPTION_BASIC:
+               {
+                       _DEBUG_INFO("SA_DECRYPTION_BASIC");
+               }
+               break;
+       case SYNC_AGENT_SA_ENCRYPTION_MD5:
+               {
+                       _DEBUG_INFO("SA_DECRYPTION_MD5");
+               }
+               break;
+       default:
+               /* no case  */
+               break;
+       }
+
+       _DEBUG_INFO("encryption_text = %s", encryption_text);
+       _DEBUG_INFO("decyption_text = %s", decyption_text);
+
+       _EXTERN_FUNC_EXIT;
+
+       return decyption_text;
+}
+
+EXPORT_API unsigned char *sync_agent_encrypt_cryptograhic_hash(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(plain == NULL, NULL, "plain parameter is NULL !!!");
+       retvm_if(plain_len == 0, NULL, "plain_length parameter is 0 !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return _encrypt_cryptograhic_hash(type, plain, plain_len, 0, 0, 0);
+}
+
+EXPORT_API unsigned char *sync_agent_encrypt_cryptograhic_hash_with_flags(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len, const char *key, int key_len, sync_agent_sa_cryptographic_hash_function_flags_e flags)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(plain == NULL, NULL, "plain parameter is NULL !!!");
+       retvm_if(plain_len == 0, NULL, "plain_length parameter is 0 !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return _encrypt_cryptograhic_hash(type, plain, plain_len, key, key_len, flags);
+}
+
+static unsigned char *_encrypt_cryptograhic_hash(sync_agent_sa_cryptographic_hash_function_type_e type, const char *plain, int plain_len, const char *key, int key_len, sync_agent_sa_cryptographic_hash_function_flags_e flags)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned char *crypt_data = NULL;
+
+       switch (type) {
+       case SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5:
+               {
+                       _DEBUG_TRACE("SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5");
+                       crypt_data = sa_crypt_md5(flags, plain, plain_len, key, key_len);
+               }
+               break;
+       case SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1:
+               {
+                       _DEBUG_TRACE("SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1");
+                       crypt_data = sa_crypt_sha1(flags, plain, plain_len, key, key_len);
+               }
+               break;
+       default:
+               {
+                       _DEBUG_TRACE("default");
+               }
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return crypt_data;
+}
diff --git a/src/framework/security-assistant/encryption_decryption_internal.h b/src/framework/security-assistant/encryption_decryption_internal.h
new file mode 100755 (executable)
index 0000000..87fae57
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENCRYPTION_DECRYPTION_INTERNAL_H_
+#define ENCRYPTION_DECRYPTION_INTERNAL_H_
+
+#include "security-assistant/encryption_decryption.h"
+
+/**
+ * @file cryptograhic_hash_function.h
+ * @brief Provides encryption/decryption operation for plain text
+ */
+
+/** @addtogroup security_assistant
+ *     @{
+ */
+
+/**
+ * @brief api to get decryption value
+ * @param[in] decryption_type                  sync_agent_sa_encryption_type_e
+ * @param[in] encryption_text                  encryption string
+ * @return decrypted string on success, NULL on fail.
+ * @retval decrypted string Successful
+ * @retval NULL Fail
+ */
+char *sa_get_decryption_value(sync_agent_sa_encryption_type_e decryption_type, char *encryption_text);
+
+/**
+ *     @}
+ */
+
+#endif                         /* ENCRYPTION_DECRYPTION_INTERNAL_H_ */
diff --git a/src/framework/security-assistant/md5.c b/src/framework/security-assistant/md5.c
new file mode 100755 (executable)
index 0000000..347fbfc
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include "utility/sync_util.h"
+#include "security-assistant/md5.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_SA"
+#endif
+
+static gint _ie = 0x44332211;
+static union sa_endian_u {
+       gint i;
+       gchar b[4];
+} *_endian = (union sa_endian_u *)&_ie;
+#define        SA_IS_BIG_ENDIAN()              (_endian->b[0] == '\x44')
+#define        SA_IS_LITTLE_ENDIAN()   (_endian->b[0] == '\x11')
+
+static void _md5_transform(unsigned long int buf[4], const unsigned long int in[16]);
+static void _byte_reverse(unsigned char *buf, unsigned int longs);
+
+void sa_md5_get_digest(const char *buffer, int buffer_size, unsigned char *digest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sa_md5_context_s ctx;
+
+       sa_md5_init(&ctx);
+       sa_md5_update(&ctx, buffer, buffer_size);
+       sa_md5_final(&ctx, digest);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void sa_md5_init(sa_md5_context_s * ctx)
+{
+       _EXTERN_FUNC_ENTER;
+
+       ctx->buf[0] = 0x67452301;
+       ctx->buf[1] = 0xefcdab89;
+       ctx->buf[2] = 0x98badcfe;
+       ctx->buf[3] = 0x10325476;
+
+       ctx->bits[0] = 0;
+       ctx->bits[1] = 0;
+
+       if (SA_IS_BIG_ENDIAN()) {
+               ctx->doByteReverse = 1;
+       } else {
+               ctx->doByteReverse = 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void sa_md5_update(sa_md5_context_s * ctx, const char *buf, unsigned long int len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int t;
+
+       /* Update bitcount */
+
+       t = ctx->bits[0];
+       if ((ctx->bits[0] = t + ((unsigned int)len << 3)) < t)
+               ctx->bits[1]++; /* Carry from low to high */
+       ctx->bits[1] += len >> 29;
+
+       t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */
+
+       /* Handle any leading odd-sized chunks */
+
+       if (t) {
+               unsigned char *p = (unsigned char *)ctx->in + t;
+
+               t = 64 - t;
+               if (len < t) {
+                       memcpy(p, buf, len);
+                       return;
+               }
+               memcpy(p, buf, t);
+               if (ctx->doByteReverse)
+                       _byte_reverse(ctx->in, 16);
+               _md5_transform(ctx->buf, (const long unsigned int *)ctx->in);
+               buf += t;
+               len -= t;
+       }
+       /* Process data in 64-byte chunks */
+
+       while (len >= 64) {
+               memcpy(ctx->in, buf, 64);
+               if (ctx->doByteReverse)
+                       _byte_reverse(ctx->in, 16);
+               _md5_transform(ctx->buf, (const long unsigned int *)ctx->in);
+               buf += 64;
+               len -= 64;
+       }
+
+       /* Handle any remaining bytes of data. */
+
+       memcpy(ctx->in, buf, len);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static void _md5_transform(unsigned long int buf[4], const unsigned long int in[16])
+{
+       _INNER_FUNC_ENTER;
+
+       register unsigned int a, b, c, d;
+
+       a = buf[0];
+       b = buf[1];
+       c = buf[2];
+       d = buf[3];
+
+       SA_MD5_STEP(SA_F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+       SA_MD5_STEP(SA_F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+       SA_MD5_STEP(SA_F1, c, d, a, b, in[2] + 0x242070db, 17);
+       SA_MD5_STEP(SA_F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+       SA_MD5_STEP(SA_F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+       SA_MD5_STEP(SA_F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+       SA_MD5_STEP(SA_F1, c, d, a, b, in[6] + 0xa8304613, 17);
+       SA_MD5_STEP(SA_F1, b, c, d, a, in[7] + 0xfd469501, 22);
+       SA_MD5_STEP(SA_F1, a, b, c, d, in[8] + 0x698098d8, 7);
+       SA_MD5_STEP(SA_F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+       SA_MD5_STEP(SA_F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+       SA_MD5_STEP(SA_F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+       SA_MD5_STEP(SA_F1, a, b, c, d, in[12] + 0x6b901122, 7);
+       SA_MD5_STEP(SA_F1, d, a, b, c, in[13] + 0xfd987193, 12);
+       SA_MD5_STEP(SA_F1, c, d, a, b, in[14] + 0xa679438e, 17);
+       SA_MD5_STEP(SA_F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+       SA_MD5_STEP(SA_F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+       SA_MD5_STEP(SA_F2, d, a, b, c, in[6] + 0xc040b340, 9);
+       SA_MD5_STEP(SA_F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+       SA_MD5_STEP(SA_F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+       SA_MD5_STEP(SA_F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+       SA_MD5_STEP(SA_F2, d, a, b, c, in[10] + 0x02441453, 9);
+       SA_MD5_STEP(SA_F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+       SA_MD5_STEP(SA_F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+       SA_MD5_STEP(SA_F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+       SA_MD5_STEP(SA_F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+       SA_MD5_STEP(SA_F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+       SA_MD5_STEP(SA_F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+       SA_MD5_STEP(SA_F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+       SA_MD5_STEP(SA_F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+       SA_MD5_STEP(SA_F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+       SA_MD5_STEP(SA_F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+       SA_MD5_STEP(SA_F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+       SA_MD5_STEP(SA_F3, d, a, b, c, in[8] + 0x8771f681, 11);
+       SA_MD5_STEP(SA_F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+       SA_MD5_STEP(SA_F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+       SA_MD5_STEP(SA_F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+       SA_MD5_STEP(SA_F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+       SA_MD5_STEP(SA_F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+       SA_MD5_STEP(SA_F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+       SA_MD5_STEP(SA_F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+       SA_MD5_STEP(SA_F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+       SA_MD5_STEP(SA_F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+       SA_MD5_STEP(SA_F3, b, c, d, a, in[6] + 0x04881d05, 23);
+       SA_MD5_STEP(SA_F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+       SA_MD5_STEP(SA_F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+       SA_MD5_STEP(SA_F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+       SA_MD5_STEP(SA_F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+       SA_MD5_STEP(SA_F4, a, b, c, d, in[0] + 0xf4292244, 6);
+       SA_MD5_STEP(SA_F4, d, a, b, c, in[7] + 0x432aff97, 10);
+       SA_MD5_STEP(SA_F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+       SA_MD5_STEP(SA_F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+       SA_MD5_STEP(SA_F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+       SA_MD5_STEP(SA_F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+       SA_MD5_STEP(SA_F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+       SA_MD5_STEP(SA_F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+       SA_MD5_STEP(SA_F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+       SA_MD5_STEP(SA_F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+       SA_MD5_STEP(SA_F4, c, d, a, b, in[6] + 0xa3014314, 15);
+       SA_MD5_STEP(SA_F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+       SA_MD5_STEP(SA_F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+       SA_MD5_STEP(SA_F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+       SA_MD5_STEP(SA_F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+       SA_MD5_STEP(SA_F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+       buf[0] += a;
+       buf[1] += b;
+       buf[2] += c;
+       buf[3] += d;
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _byte_reverse(unsigned char *buf, unsigned int longs)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int t;
+       do {
+               t = (unsigned int)((unsigned int)buf[3] << 8 | buf[2]) << 16 | ((unsigned int)buf[1] << 8 | buf[0]);
+               *(unsigned int *)buf = t;
+               buf += 4;
+       } while (--longs);
+
+       _INNER_FUNC_EXIT;
+}
+
+void sa_md5_final(sa_md5_context_s * ctx, unsigned char *digest)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int count;
+       unsigned char *p;
+
+       /* Compute number of bytes mod 64 */
+       count = (ctx->bits[0] >> 3) & 0x3F;
+
+       /* Set the first char of padding to 0x80.  This is safe since there is
+          always at least one byte free */
+       p = ctx->in + count;
+       *p++ = 0x80;
+
+       /* Bytes of padding needed to make 64 bytes */
+       count = 64 - 1 - count;
+
+       /* Pad out to 56 mod 64 */
+       if (count < 8) {
+               /* Two lots of padding:  Pad the first block to 64 bytes */
+               memset(p, 0, count);
+               if (ctx->doByteReverse)
+                       _byte_reverse(ctx->in, 16);
+               _md5_transform(ctx->buf, (const long unsigned int *)ctx->in);
+
+               /* Now fill the next block with 56 bytes */
+               memset(ctx->in, 0, 56);
+       } else {
+               /* Pad block to 56 bytes */
+               memset(p, 0, count - 8);
+       }
+       if (ctx->doByteReverse)
+               _byte_reverse(ctx->in, 14);
+
+       /* Append length in bits and transform */
+       ((unsigned int *)ctx->in)[14] = ctx->bits[0];
+       ((unsigned int *)ctx->in)[15] = ctx->bits[1];
+
+       _md5_transform(ctx->buf, (const long unsigned int *)ctx->in);
+       if (ctx->doByteReverse)
+               _byte_reverse((unsigned char *)ctx->buf, 4);
+       memcpy(digest, ctx->buf, 16);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/security-assistant/md5.h b/src/framework/security-assistant/md5.h
new file mode 100755 (executable)
index 0000000..6b2d778
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MD5_H_
+#define MD5_H_
+
+#include <glib.h>
+
+/**
+ * @file md5.h
+ * @brief Provides md5 operation
+ */
+
+/** @addtogroup security_assistant
+ *     @{
+ */
+
+/**
+ * @brief      md5 context structure
+ */
+typedef struct sa_md5context {
+       unsigned long int buf[4];               /**< buffer */
+       unsigned long int bits[2];              /**< bits */
+       unsigned char in[64];                   /**< in */
+       int doByteReverse;                              /**< do byte reverse */
+} sa_md5_context_s;
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define SA_F1(x, y, z) (z ^ (x & (y ^ z)))
+#define SA_F2(x, y, z) SA_F1(z, x, y)
+#define SA_F3(x, y, z) (x ^ y ^ z)
+#define SA_F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define SA_MD5_STEP(f, w, x, y, z, data, s) (w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x)
+
+/**
+ * @brief api to get digest
+ * @param[in] buffer                   buffer
+ * @param[in] buffer_size                      buffer size
+ * @param[out] digest                  digest
+ */
+void sa_md5_get_digest(const char *buffer, int buffer_size, unsigned char *digest);
+
+/**
+ * @brief api to initialize
+ * @param[in] ctx                      sa_md5_context_s
+ */
+void sa_md5_init(sa_md5_context_s * ctx);
+
+/**
+ * @brief api to update
+ * @param[in] ctx                      sa_md5_context_s
+ * @param[in] buf                      buf
+ * @param[in] len                      len
+ */
+void sa_md5_update(sa_md5_context_s * ctx, const char *buf, unsigned long int len);
+
+/**
+ * @brief api to finalize
+ * @param[in] ctx                      sa_md5_context_s
+ * @param[in] digest                   digest
+ */
+void sa_md5_final(sa_md5_context_s * ctx, unsigned char *digest);
+
+/**
+ *     @}
+ */
+
+#endif                         /* MD5_H_ */
diff --git a/src/framework/sync-agent.pc.in b/src/framework/sync-agent.pc.in
new file mode 100644 (file)
index 0000000..e29f491
--- /dev/null
@@ -0,0 +1,13 @@
+
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: sync-agent
+Description: Sync Agent Library Package
+Requires:
+Version: @VERSION@
+Libs: -L${libdir} -lsync-agent
+Cflags: -I${includedir} -I${includedir}/sync-agent
+
diff --git a/src/framework/test/include/suites/unit_test_fw_alloc_suite.h b/src/framework/test/include/suites/unit_test_fw_alloc_suite.h
new file mode 100755 (executable)
index 0000000..0d0e2af
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_FW_ALLOC_SUITE_H_
+#define UNIT_TEST_FW_ALLOC_SUITE_H_
+
+#include "unit_test_common.h"
+
+Suite *fw_alloc_suite(void);
+
+#endif                         /* UNIT_TEST_FW_ALLOC_SUITE_H_ */
diff --git a/src/framework/test/include/suites/unit_test_fw_log_suite.h b/src/framework/test/include/suites/unit_test_fw_log_suite.h
new file mode 100755 (executable)
index 0000000..d7ab84a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_FW_LOG_SUITE_H_
+#define UNIT_TEST_FW_LOG_SUITE_H_
+
+#include "unit_test_common.h"
+
+Suite *fw_log_suite(void);
+
+#endif                         /* UNIT_TEST_FW_LOG_SUITE_H_ */
diff --git a/src/framework/test/include/suites/unit_test_fw_sequential_id_provider_suite.h b/src/framework/test/include/suites/unit_test_fw_sequential_id_provider_suite.h
new file mode 100755 (executable)
index 0000000..c809f75
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_FW_SEQUENTIAL_ID_PROVIDER_SUITE_H_
+#define UNIT_TEST_FW_SEQUENTIAL_ID_PROVIDER_SUITE_H_
+
+#include "unit_test_common.h"
+
+Suite *fw_sequential_id_provider_suite(void);
+
+#endif                         /* UNIT_TEST_FW_SEQUENTIAL_ID_PROVIDER_SUITE_H_ */
diff --git a/src/framework/test/include/suites/unit_test_protocol_binder_suite.h b/src/framework/test/include/suites/unit_test_protocol_binder_suite.h
new file mode 100755 (executable)
index 0000000..5877cba
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_PROTOCOL_BINDER_SUITE_H_
+#define UNIT_TEST_PROTOCOL_BINDER_SUITE_H_
+
+#include "unit_test_common.h"
+
+Suite *protocol_binder_suite(void);
+
+#endif                         /* UNIT_TEST_PROTOCOL_BINDER_SUITE_H_ */
diff --git a/src/framework/test/include/suites/unit_test_sample_suite.h b/src/framework/test/include/suites/unit_test_sample_suite.h
new file mode 100755 (executable)
index 0000000..597cd52
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_SUITE_H_
+#define UNIT_TEST_SUITE_H_
+
+#include "unit_test_common.h"
+
+Suite *sample_suite(void);
+
+#endif                         /* UNIT_TEST_SUITE_H_ */
diff --git a/src/framework/test/include/unit_test_common.h b/src/framework/test/include/unit_test_common.h
new file mode 100755 (executable)
index 0000000..4ecdeff
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_COMMON_H_
+#define UNIT_TEST_COMMON_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <check.h>
+
+#endif                         /* UNIT_TEST_COMMON_H_ */
diff --git a/src/framework/test/include/unit_test_run.h b/src/framework/test/include/unit_test_run.h
new file mode 100755 (executable)
index 0000000..96284fb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_H_
+#define UNIT_TEST_H_
+
+#include "unit_test_common.h"
+
+typedef enum run_unit_test_mode run_unit_test_mode_t;
+enum run_unit_test_mode {
+       FUNCTION_MODE,          /* unit test runs just like function */
+       /* good for debugging */
+       FORK_MODE
+};
+
+int unit_test_run(run_unit_test_mode_t mode);
+
+#endif                         /* UNIT_TEST_H_ */
diff --git a/src/framework/test/include/unit_test_suites.h b/src/framework/test/include/unit_test_suites.h
new file mode 100755 (executable)
index 0000000..c0b2a81
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TEST_SUITES_H_
+#define UNIT_TEST_SUITES_H_
+
+#include "unit_test_common.h"
+#include "suites/unit_test_sample_suite.h"
+#include "suites/unit_test_fw_alloc_suite.h"
+#include "suites/unit_test_fw_log_suite.h"
+#include "suites/unit_test_protocol_binder_suite.h"
+#include "suites/unit_test_fw_sequential_id_provider_suite.h"
+
+/* define here suites to be tested */
+typedef Suite *(*SUITE_FUNCTION) (void);
+static SUITE_FUNCTION suiteFunctions[] = {
+       sample_suite,
+       fw_alloc_suite,
+       fw_log_suite,
+       protocol_binder_suite,
+       fw_sequential_id_provider_suite
+};
+
+#endif                         /* UNIT_TEST_SUITES_H_ */
diff --git a/src/framework/test/src/fw_test_main.c b/src/framework/test/src/fw_test_main.c
new file mode 100755 (executable)
index 0000000..e27f768
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "unit_test_run.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TEST"
+#endif
+
+int main(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int test_success = unit_test_run(FUNCTION_MODE);
+
+       _EXTERN_FUNC_EXIT;
+
+       return test_success;
+}
diff --git a/src/framework/test/src/suites/unit_test_fw_alloc_suite.c b/src/framework/test/src/suites/unit_test_fw_alloc_suite.c
new file mode 100755 (executable)
index 0000000..74ea9b1
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "unit_test_common.h"
+#include "suites/unit_test_fw_alloc_suite.h"
+#include "utility/fw_alloc_internal.h"
+#include "utility/fw_alloc.h"
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TEST"
+#endif
+
+#include <string.h>
+
+/* test internal interfaces */
+#ifndef        NDEBUG
+START_TEST(_alloc_init_realbytes_test)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = false;
+
+       unsigned int bytes = 10;
+       const char *file = "main.c";
+       int line = 10;
+
+       /* allocation */
+       void *pRealbytes = util_alloc_init_real_bytes(bytes, file, line);
+       if (pRealbytes == NULL) {
+               fail();
+       }
+
+       /* test */
+       /* check redzone */
+       success = util_check_red_zone(pRealbytes);
+       fail_unless(success);
+
+       /* check debug info */
+       util_alloc_debug_info_s *pAlloc_debug_info = util_get_debug_info(pRealbytes);
+       fail_unless(!strcmp(pAlloc_debug_info->file, file));
+       fail_unless(pAlloc_debug_info->line == line);
+       fail_unless(pAlloc_debug_info->size == bytes);
+
+       /* free allocated */
+       util_free_real_bytes(pRealbytes);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST
+/* test external interfaces */
+START_TEST(_fw_malloc_and_fw_free_test)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int bytes = 100;
+       void *ptr = NULL;
+
+       /* allocation */
+       ptr = util_malloc(bytes, __FILE__, __LINE__);
+       fail_unless(ptr != NULL);
+
+       /* free */
+       util_free(ptr);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(_fw_calloc_and_fw_free_test)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int bytes = 100;
+       void *ptr = NULL;
+
+       /* allocation */
+       ptr = util_calloc(bytes, __FILE__, __LINE__);
+       fail_unless(ptr != NULL);
+
+       /* free */
+       util_free(ptr);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST
+#endif                         /* NDEBUG */
+    Suite * fw_alloc_suite(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* create test suite */
+       Suite *s = suite_create("fw_allocation");
+
+#ifndef        NDEBUG
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("_fw_malloc");
+
+               tcase_add_test(tcase, _alloc_init_realbytes_test);
+               tcase_add_test(tcase, _fw_malloc_and_fw_free_test);
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("_fw_calloc");
+
+               tcase_add_test(tcase, _fw_calloc_and_fw_free_test);
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+#endif                         /* NDEBUG */
+
+       _EXTERN_FUNC_EXIT;
+
+       return s;
+}
diff --git a/src/framework/test/src/suites/unit_test_fw_log_suite.c b/src/framework/test/src/suites/unit_test_fw_log_suite.c
new file mode 100755 (executable)
index 0000000..1c05cc0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "unit_test_common.h"
+#include "suites/unit_test_fw_log_suite.h"
+#include "utility/sync_util.h"
+
+/* test external interfaces */
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "UNIT_TEST_FW_LOG"
+#endif
+
+START_TEST(_color_logging_test)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* first example : logging with default option */
+       _DEBUG_INFO("print with default option !");
+
+       /* second example : logging with background color & word color */
+       /* note that in below code, SYNC_AGENT_UTIL_TM_OPT_RED_WORD & SYNC_AGENT_UTIL_TM_OPT_WHITE_BACKGROUND is separated by space operator */
+       /* and the order is not important */
+       _DEBUG_INFO_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_TM_OPT_RED_WORD SYNC_AGENT_UTIL_TM_OPT_WHITE_BACKGROUND, "print red word in white background !");
+
+       /* third example : setting only word color */
+       _DEBUG_INFO_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_TM_OPT_GREEN_WORD, "print green word in default background !");
+
+       /* second example : setting only background color */
+       _DEBUG_INFO_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_TM_OPT_BLUE_BACKGROUND, "print default color word in blue background !");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST Suite *fw_log_suite(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* create test suite */
+       Suite *s = suite_create("fw_logging");
+
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("color logging test");
+
+               tcase_add_test(tcase, _color_logging_test);
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return s;
+}
diff --git a/src/framework/test/src/suites/unit_test_fw_sequential_id_provider_suite.c b/src/framework/test/src/suites/unit_test_fw_sequential_id_provider_suite.c
new file mode 100755 (executable)
index 0000000..0a3a7d1
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include "utility/sync_util.h"
+#include "unit_test_common.h"
+#include "utility/fw_sequential_id_provider.h"
+#include "utility/fw_sequential_id_provider_internal.h"
+#include "suites/unit_test_fw_sequential_id_provider_suite.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TEST"
+#endif
+
+START_TEST(provide_id_without_delete_id_test1)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int max_id = 100;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       unsigned int i = 0;
+       unsigned int id = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+
+       for (i = 0; i <= max_id; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+       }
+
+       error = util_provide_id(pId_provider, &id);
+       fail_unless(error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID);
+       fail_unless(pId_provider->total_free_cnt == 0);
+
+       util_destroy_id_provider(pId_provider);
+       fprintf(stderr, "%s\n", "provide_id_without_delete_id_test1 done");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_without_delete_id_test2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int max_id = (1024 * 4) * 8;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       unsigned int i = 0;
+       unsigned int id = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       for (i = 0; i <= max_id; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+       }
+
+       error = util_provide_id(pId_provider, &id);
+       fail_unless(error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID);
+       fail_unless(pId_provider->total_free_cnt == 0);
+
+       util_destroy_id_provider(pId_provider);
+
+       fprintf(stderr, "%s\n", "provide_id_without_delete_id_test2 done");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_without_delete_id_test3)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int max_id = (1024 * 4) * 8 * 2;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       unsigned int i = 0;
+       unsigned int id = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       for (i = 0; i <= max_id; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+       }
+
+       error = util_provide_id(pId_provider, &id);
+       fail_unless(error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID);
+       fail_unless(pId_provider->total_free_cnt == 0);
+
+       util_destroy_id_provider(pId_provider);
+       fprintf(stderr, "%s\n", "provide_id_without_delete_id_test3 done");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_with_delete_id_test1)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int max_id = 100;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       unsigned int i = 0;
+       unsigned int j = 0;
+       unsigned int id = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+
+       for (i = 0; i <= max_id / 10; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+       }
+
+       for (j = 0; j <= max_id / 20; j++) {
+               fail_unless(UTIL_ID_PROVIDER_OK == util_delete_id(pId_provider, j));
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (max_id / 10 + 1)) + j + 1);
+       }
+
+       for (i = max_id / 10 + 1; i <= max_id; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)) + max_id / 20 + 1);
+       }
+
+       for (j = 0; j <= max_id / 20; j++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(j == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id / 20 - j));
+       }
+
+       error = util_provide_id(pId_provider, &id);
+       fail_unless(error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID);
+       fail_unless(pId_provider->total_free_cnt == 0);
+
+       fail_unless(UTIL_ID_PROVIDER_OK == util_delete_id(pId_provider, 50));
+       fail_unless(pId_provider->total_free_cnt == 1);
+
+       fail_unless(UTIL_ID_PROVIDER_NOT_EXIST_ID == util_delete_id(pId_provider, 50));
+       fail_unless(pId_provider->total_free_cnt == 1);
+
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, 101));
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, 102));
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, 2000));
+
+       util_destroy_id_provider(pId_provider);
+       fprintf(stderr, "%s\n", "provide_id_with_delete_id_test1 done");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_with_delete_id_test2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int max_id = (1024 * 4) * 8;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       unsigned int i = 0;
+       unsigned int j = 0;
+       unsigned int id = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+
+       for (i = 0; i <= max_id / 10; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+       }
+
+       for (j = 0; j <= max_id / 20; j++) {
+               fail_unless(UTIL_ID_PROVIDER_OK == util_delete_id(pId_provider, j));
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (max_id / 10 + 1)) + j + 1);
+       }
+
+       for (i = max_id / 10 + 1; i <= max_id; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)) + max_id / 20 + 1);
+       }
+
+       for (j = max_id / 2; j <= max_id; j++) {
+               fail_unless(UTIL_ID_PROVIDER_OK == util_delete_id(pId_provider, j));
+               fail_unless(pId_provider->total_free_cnt == max_id / 20 + 1 + (j - max_id / 2) + 1);
+       }
+
+       for (j = 0; j <= max_id / 20; j++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(j == id);
+
+               fail_unless(pId_provider->total_free_cnt == max_id / 20 + 1 + (max_id - max_id / 2) + 1 - (j + 1));
+       }
+
+       for (j = max_id / 2; j <= max_id; j++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(j == id);
+
+               fail_unless(pId_provider->total_free_cnt == max_id / 20 + 1 + (max_id - max_id / 2) + 1 - (max_id / 20 + 1) - (j - max_id / 2 + 1));
+       }
+
+       error = util_provide_id(pId_provider, &id);
+       fail_unless(error == UTIL_ID_PROVIDER_NOT_ENOUGH_ID);
+       fail_unless(pId_provider->total_free_cnt == 0);
+
+       fail_unless(UTIL_ID_PROVIDER_OK == util_delete_id(pId_provider, 50));
+       fail_unless(pId_provider->total_free_cnt == 1);
+
+       fail_unless(UTIL_ID_PROVIDER_NOT_EXIST_ID == util_delete_id(pId_provider, 50));
+       fail_unless(pId_provider->total_free_cnt == 1);
+
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, max_id + 1));
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, max_id + 2));
+       fail_unless(UTIL_ID_PROVIDER_OUT_OF_ID_RANGE == util_delete_id(pId_provider, max_id + 1000));
+
+       util_destroy_id_provider(pId_provider);
+       fprintf(stderr, "%s\n", "provide_id_with_delete_id_test2 done");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_without_unchanged_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int page_bit_cnt = (1024 * 4) * 8;
+       unsigned int max_id = 3 * page_bit_cnt - 1;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       unsigned int i = 0;
+       unsigned int id = 0;
+
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       for (i = 0; i < page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 1);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       for (i = page_bit_cnt; i < 2 * page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 2);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       for (i = 2 * page_bit_cnt; i < 3 * page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 3);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       for (i = 0; i < page_bit_cnt - 1; i++) {
+               error = util_delete_id(pId_provider, i);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(pId_provider->total_free_cnt == (i + 1));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 3);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       error = util_delete_id(pId_provider, page_bit_cnt - 1);
+       fail_unless(error == UTIL_ID_PROVIDER_OK);
+       fail_unless(pId_provider->total_free_cnt == page_bit_cnt);
+
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 2);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+
+       util_destroy_id_provider(pId_provider);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(provide_id_with_unchanged_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int page_bit_cnt = (1024 * 4) * 8;
+       unsigned int max_id = 4 * page_bit_cnt - 1;
+       util_id_provider_s *pId_provider = util_create_id_provider(max_id, 12, true);
+
+       unsigned int i = 0;
+       unsigned int id = 0;
+
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       fail_unless(pId_provider->total_free_cnt == max_id + 1);
+
+       /* prepare test */
+       for (i = 0; i < page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 1);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       for (i = page_bit_cnt; i < 2 * page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 2);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       for (i = 2 * page_bit_cnt; i < 3 * page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (max_id + 1 - (i + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 3);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 0);
+       }
+
+       /* move all add list to unchaged list for test */
+       util_id_provider_move_id_page(pId_provider, pId_provider->id_page_array[0], UTIL_ID_PAGE_FLAG_UNCHANGED);
+       util_id_provider_move_id_page(pId_provider, pId_provider->id_page_array[1], UTIL_ID_PAGE_FLAG_UNCHANGED);
+       util_id_provider_move_id_page(pId_provider, pId_provider->id_page_array[2], UTIL_ID_PAGE_FLAG_UNCHANGED);
+
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 3);
+
+       /* test started from here */
+       for (i = 0; i < page_bit_cnt - 1; i++) {
+               error = util_delete_id(pId_provider, i);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(pId_provider->total_free_cnt == page_bit_cnt + (i + 1));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 1);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 2);
+       }
+
+       error = util_delete_id(pId_provider, page_bit_cnt - 1);
+       fail_unless(error == UTIL_ID_PROVIDER_OK);
+       fail_unless(pId_provider->total_free_cnt == 2 * page_bit_cnt);
+
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 1);
+       fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 2);
+
+       for (i = 3 * page_bit_cnt; i < 4 * page_bit_cnt; i++) {
+               error = util_provide_id(pId_provider, &id);
+               fail_unless(error == UTIL_ID_PROVIDER_OK);
+               fail_unless(i == id);
+               fail_unless(pId_provider->total_free_cnt == (2 * page_bit_cnt - (i - 3 * page_bit_cnt + 1)));
+
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_add_list_head)) == 1);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_update_list_head)) == 0);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_delete_list_head)) == 1);
+               fail_unless(list_count(&(pId_provider->pTracking->id_page_unchanged_list_head)) == 2);
+       }
+
+       util_destroy_id_provider(pId_provider);
+
+       _EXTERN_FUNC_EXIT;
+s}
+
+END_TEST Suite *fw_sequential_id_provider_suite(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* create test suite */
+       Suite *s = suite_create("fw_sequential_id_provider_suite");
+
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("provide_id_without_delete_id");
+
+               tcase_add_test(tcase, provide_id_without_delete_id_test1);
+               tcase_add_test(tcase, provide_id_without_delete_id_test2);
+               tcase_add_test(tcase, provide_id_without_delete_id_test3);
+
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+
+       /* create another test case and add to test suite just like above code */
+       {
+               TCase *tcase = tcase_create("provide_id_with_delete_id");
+               tcase_add_test(tcase, provide_id_with_delete_id_test1);
+               tcase_add_test(tcase, provide_id_with_delete_id_test2);
+               tcase_set_timeout(tcase, 1);
+               suite_add_tcase(s, tcase);
+       }
+
+       /* create another test case and add to test suite just like above code */
+       {
+               TCase *tcase = tcase_create("provide_id_tracking_mode");
+               tcase_add_test(tcase, provide_id_without_unchanged_list);
+               tcase_add_test(tcase, provide_id_with_unchanged_list);
+               tcase_set_timeout(tcase, 1);
+               suite_add_tcase(s, tcase);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return s;
+}
diff --git a/src/framework/test/src/suites/unit_test_protocol_binder.c b/src/framework/test/src/suites/unit_test_protocol_binder.c
new file mode 100755 (executable)
index 0000000..067e477
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "unit_test_common.h"
+#include "suites/unit_test_protocol_binder_suite.h"
+#include "interface.h"
+#include "util_internal.h"
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "TEST_FW_PROTOCOL_BINDER"
+#endif
+
+typedef enum {
+       PE_UNDEF = 0,
+       PE_ADD,
+       PE_ALERT,
+       PE_ATOMIC_START,
+       PE_ATOMIC_END,
+       PE_COPY,
+       PE_DELETE,
+       PE_EXEC,
+       PE_GET,
+       PE_MAP,
+       PE_PUT_START,
+       PE_PUT_END,
+       PE_RESULTS_START,
+       PE_RESULTS_END,
+       PE_SEARCH,
+       PE_SEQUENCE_START,
+       PE_SEQUENCE_END,
+       PE_STATUS,
+       PE_SYNC_START,
+       PE_SYNC_END,
+       PE_REPLACE,
+       PE_HEADER,
+       PE_PUT_GET,
+       PE_CMD_GROUP,
+       PE_GENERIC,
+       PE_FINAL,
+       PE_DEVINF,
+       PE_SYNCML_START,
+       PE_SYNCML_END,
+       PE_BODY_START,
+       PE_BODY_END
+} OMA_DS_Protocol_Element;
+
+static sync_agent_pb_error_e oma_ds_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+       WBXMLTreeNode *syncml_node = sync_agent_create_node(pBinder, "SyncML");
+       if (syncml_node == NULL)
+               return SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+
+       switch (syncml_node->type) {
+       case WBXML_TREE_ELEMENT_NODE:
+               fprintf(stderr, "[%s] element node\n", __func__);
+               if (syncml_node->name->type == WBXML_VALUE_TOKEN) {
+                       fprintf(stderr, "[%s] tag type value token", __func__);
+               } else if (syncml_node->name->type == WBXML_VALUE_LITERAL) {
+                       fprintf(stderr, "[%s] tag type literal token", __func__);
+               } else {
+                       fprintf(stderr, "[%s] tag type error", __func__);
+               }
+               break;
+       case WBXML_TREE_TEXT_NODE:
+               fprintf(stderr, "[%s] text node\n", __func__);
+               break;
+       case WBXML_TREE_CDATA_NODE:
+               fprintf(stderr, "[%s] cdata node\n", __func__);
+               break;
+       case WBXML_TREE_PI_NODE:
+               fprintf(stderr, "[%s] pi node\n", __func__);
+               break;
+       case WBXML_TREE_TREE_NODE:
+               fprintf(stderr, "[%s] tree node\n", __func__);
+               break;
+       }
+
+       *ppWbxml_dom_node = syncml_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_pb_error_e oma_ds_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       /* add SyncHdr, VerDTD, VerProto node */
+       WBXMLTreeNode *synchdr_node = sync_agent_create_node(pBinder, "SyncHdr");
+
+       char *verDTD = "VerDTD";
+       char *verProto = "VerProto";
+
+       char *verDTD_data = "1.2";
+       char *verProto_data = "SyncML/1.2";
+
+       sync_agent_add_child_text_node(pBinder, synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
+       sync_agent_add_child_text_node(pBinder, synchdr_node, verProto, verProto_data, strlen(verProto_data));
+
+       /* session ID */
+       char *sessionId = "12345";
+       sync_agent_add_child_text_node(pBinder, synchdr_node, "SessionID", sessionId, strlen(sessionId));
+
+       /* msgID */
+       char *msgID_data = "1";
+       sync_agent_add_child_text_node(pBinder, synchdr_node, "MsgID", msgID_data, strlen(msgID_data));
+
+       sync_agent_add_child_node(pBinder, synchdr_node, "Target");
+       sync_agent_add_child_node(pBinder, synchdr_node, "Source");
+
+       *ppWbxml_dom_node = synchdr_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_pb_error_e oma_ds_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WBXMLTreeNode *syncbody_node = sync_agent_create_node(pBinder, "SyncBody");
+
+       *ppWbxml_dom_node = syncbody_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_pb_error_e oma_ds_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WBXMLTreeNode *final_node = sync_agent_create_node(pBinder, "Final");
+
+       *ppWbxml_dom_node = final_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+static sync_agent_pb_error_e oma_ds_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+       WBXMLTreeNode *results_node = sync_agent_create_node(pBinder, "Results");
+
+       char *str_cmdID = "1";
+       sync_agent_add_child_text_node(pBinder, results_node, "CmdID", str_cmdID, strlen(str_cmdID));
+
+       char *str_msgRef = "2";
+       sync_agent_add_child_text_node(pBinder, results_node, "MsgRef", str_msgRef, strlen(str_msgRef));
+
+       char *str_cmdRef = "3";
+       sync_agent_add_child_text_node(pBinder, results_node, "CmdRef", str_cmdRef, strlen(str_cmdRef));
+
+       char *content_type = "application/vnd.syncml-devinf+xml";
+       WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, results_node, "Meta");
+       sync_agent_add_child_text_node(pBinder, meta_node, "Type", content_type, strlen(content_type));
+
+       char *target_ref_locUri = "./devinf12";
+       sync_agent_add_child_text_node(pBinder, results_node, "TargetRef", target_ref_locUri, strlen(target_ref_locUri));
+
+       *ppWbxml_dom_node = results_node;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+const sync_agent_pb_function_info_s oma_ds_binder_function_info[8] = {
+       {PE_SYNCML_START, "SyncML", oma_ds_binder_syncml_start_converter_function, NULL, false},
+       {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
+       {PE_HEADER, "SyncHdr", oma_ds_binder_header_converter_function, NULL, true},
+       {PE_BODY_START, "SyncBody", oma_ds_binder_body_start_converter_function, NULL, false},
+       {PE_BODY_END, "/SyncBody", NULL, NULL, false},
+       {PE_FINAL, "Final", oma_ds_binder_final_converter_function, NULL, true},
+       {PE_RESULTS_START, "Results", oma_ds_binder_results_command_converter_function, NULL, false},
+       {PE_RESULTS_END, "/Results", NULL, NULL, false}
+};
+
+START_TEST(_protocol_binder_flow_mode_xml_output1)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pb_protocol_binder_function_set_s *pFunction_set = NULL;
+       char *xml_output = NULL;
+       unsigned int xml_size = 0;
+       sync_agent_pb_error_e err = sync_agent_init_binder_function_set(8, oma_ds_binder_function_info,
+                                                                       &pFunction_set);
+       fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_init_binder_function_set failed");
+       fail_unless(pFunction_set != NULL, "pFunction_set != NULL" "after sync_agent_init_binder_function_set function successfully done");
+
+       sync_agent_pb_protocol_binder_info_s *pBinder = sync_agent_init_protocol_binder(NULL,
+                                                                                       SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL,
+                                                                                       SYNC_AGENT_PB_ENCODING_WBXML_12, false, false, false, true, false,
+                                                                                       NULL, NULL,
+                                                                                       pFunction_set);
+       fail_unless(pBinder != NULL, "pBinder != NULL failed");
+
+       err = sync_agent_append_element(pBinder, PE_SYNCML_START, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_SYNCML_START failed"); */
+       err = sync_agent_append_element(pBinder, PE_HEADER, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_HEADER failed"); */
+       err = sync_agent_append_element(pBinder, PE_BODY_START, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_BODY_START failed"); */
+       err = sync_agent_append_element(pBinder, PE_RESULTS_START, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_RESULTS_START failed"); */
+       err = sync_agent_append_element(pBinder, PE_RESULTS_END, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_RESULTS_END failed"); */
+       err = sync_agent_append_element(pBinder, PE_BODY_END, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_BODY_END failed"); */
+       err = sync_agent_append_element(pBinder, PE_SYNCML_END, NULL);
+/* fail_unless(err == SYNC_AGENT_PB_RETURN_OK, "sync_agent_append_element PE_SYNCML_END failed"); */
+
+       err = sync_agent_get_stream_from_protocol_binder(pBinder, &xml_output, &xml_size);
+       /*
+          fail_unless(err != SYNC_AGENT_PB_RETURN_OK, "sync_agent_get_stream_from_protocol_binder failed");
+
+          fail_unless(xml_output != NULL, "xml_output != NULL failed");
+          fail_unless(xml_size != 0, "xml_size != 0 failed");
+        */
+       fprintf(stderr, "xml = %s\n", xml_output);
+
+       if (xml_output)
+               free(xml_output);
+       if (pBinder)
+               sync_agent_destroy_protocol_binder(pBinder);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST Suite *protocol_binder_suite(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* create test suite */
+       Suite *s = suite_create("protocol binder");
+
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("binder flow mode xml test cases");
+
+               tcase_add_test(tcase, _protocol_binder_flow_mode_xml_output1);
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return s;
+}
diff --git a/src/framework/test/src/suites/unit_test_sample_suite.c b/src/framework/test/src/suites/unit_test_sample_suite.c
new file mode 100755 (executable)
index 0000000..a92966b
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "unit_test_common.h"
+#include "suites/unit_test_sample_suite.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TEST"
+#endif
+
+START_TEST(sample_test1)
+{
+       _EXTERN_FUNC_ENTER;
+
+       fail_unless(2 != 1, "2 != 1 failed");
+       fail_unless(3 != 1, "3 != 1 failed");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST START_TEST(sample_test2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* unit test code */
+       fail_unless(10 != 5, "10 != 5 failed");
+
+       _EXTERN_FUNC_EXIT;
+}
+
+END_TEST Suite *sample_suite(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* create test suite */
+       Suite *s = suite_create("Sample");
+
+       /* test case create and add in suite */
+       {
+               TCase *tcase = tcase_create("SampleTestCase");
+               /* TODO : explain following lines */
+               /*
+                  tcase_add_unchecked_fixture (tcase, setup, teardown);
+                  tcase_add_checked_fixture (tcase, setup, teardown);
+                */
+
+               tcase_add_test(tcase, sample_test1);
+               tcase_add_test(tcase, sample_test2);
+               /* TODO : explain following lines */
+               tcase_set_timeout(tcase, 1);
+
+               suite_add_tcase(s, tcase);
+       }
+
+       /* create another test case and add to test suite just like above code */
+       {
+               TCase *tc_core2 = tcase_create("Sample2");
+               tcase_add_test(tc_core2, sample_test1);
+               tcase_add_test(tc_core2, sample_test2);
+               tcase_set_timeout(tc_core2, 1);
+               suite_add_tcase(s, tc_core2);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return s;
+}
diff --git a/src/framework/test/src/unit_test_run.c b/src/framework/test/src/unit_test_run.c
new file mode 100755 (executable)
index 0000000..a59b727
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "unit_test_common.h"
+#include "unit_test_run.h"
+#include "unit_test_suites.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TEST"
+#endif
+
+/* introduction to unit test using check by yangsuh
+  * SRunner : runner of all test which belong to added suites
+  *    Suite : container of test cases(TCase)
+  *            TCase : container of tests
+  *                    test : container of many asserts
+  *
+  * SRunner has fork_status option. I will set this option to CK_FORK which means
+  * not stopping until all test finished.
+  * (Of course, when error like SIGSEGV occurs or test failed, current test will be stopped
+  * and goes to next test)
+  */
+
+typedef enum fork_status fork_status_t;
+int unit_test_main(fork_status_t fork_status)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SRunner *sr = NULL;
+
+       /* srunner build up by defined test suites */
+       int suite_count = sizeof(suiteFunctions) / sizeof(SUITE_FUNCTION);
+       fprintf(stderr, "total test suites number = %d\n", suite_count);
+
+       if (suite_count == 0) {
+               return 0;       /* nothing to do */
+       } else {                /* suite_count > 0 */
+               SUITE_FUNCTION suite_func = NULL;
+
+               int i = 0;
+               for (i = 0; i < suite_count; i++) {
+                       suite_func = suiteFunctions[i];
+                       Suite *s = suite_func();
+                       if (s != NULL) {
+                               if (i == 0) {
+                                       sr = srunner_create(s);
+                               } else {
+                                       srunner_add_suite(sr, s);
+                               }
+                       } else {
+                               fprintf(stderr, "%s\n", "invalid suite function");
+                       }
+               }
+       }
+
+       /* srunner setting */
+       srunner_set_log(sr, "/tmp/test.log");   /* set log file */
+       srunner_set_fork_status(sr, fork_status);       /* set fork status of Runner */
+
+       srunner_run_all(sr, CK_VERBOSE);        /* set print mode to verbose */
+       srunner_free(sr);
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+/* TODO : return handling */
+static inline int unit_test_run_fork_mode()
+{
+       _EXTERN_FUNC_ENTER;
+
+       pid_t pid_w;
+       pid_t pid;
+       int status = 0;
+
+       pid = fork();
+       if (pid == -1)
+               fprintf(stderr, "%s\n", "Error in call to fork");
+       if (pid == 0) {
+               /* child process : run unit_test_main */
+               unit_test_main(CK_FORK);
+               exit(EXIT_SUCCESS);
+       } else {
+               /* parent process */
+               fprintf(stderr, "test process pid = %d", pid);
+               pid_w = waitpid(pid, &status, 0);
+
+               if (pid_w == pid) {
+                       fprintf(stderr, "%s\n", "test finished successfully");
+                       return 1;       /* test finished */
+               } else {
+                       fprintf(stderr, "%s\n", "test failed");
+                       return 0;       /* test error */
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return status;
+}
+
+/* running as main function will be need during debugging */
+/* TODO : return handling */
+static inline int unit_test_run_function_mode()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return unit_test_main(CK_NOFORK);
+}
+
+int unit_test_run(run_unit_test_mode_t mode)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int success = 1;        /* success */
+
+       switch (mode) {
+       case FORK_MODE:
+               success = unit_test_run_fork_mode();
+               break;
+       case FUNCTION_MODE:
+               success = unit_test_run_function_mode();
+               break;
+       default:
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
diff --git a/src/framework/utility/fw_alloc.c b/src/framework/utility/fw_alloc.c
new file mode 100755 (executable)
index 0000000..3a084cb
--- /dev/null
@@ -0,0 +1,433 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NDEBUG
+
+#include <time.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include "utility/fw_thread.h"
+#include "utility/fw_alloc.h"
+#include "utility/fw_alloc_internal.h"
+#include "utility/fw_list.h"
+
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_ALLOC"
+#endif
+
+/* internal variable */
+static util_list_node_s alloc_list_head = { &alloc_list_head, &alloc_list_head };
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+UTIL_STATIC UTIL_INLINE void *util_get_real_bytes(void *bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *real_bytes = NULL;
+       real_bytes = bytes - UTIL_ALLOC_FRONT_RED_ZONE_SIZE - UTIL_ALIGN64(sizeof(util_alloc_debug_info_s)) - sizeof(util_list_node_s);
+
+       _EXTERN_FUNC_EXIT;
+
+       return real_bytes;
+}
+
+UTIL_STATIC UTIL_INLINE util_alloc_debug_info_s *util_get_debug_info(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_alloc_debug_info_s *debug_info = NULL;
+       debug_info = real_bytes + sizeof(util_list_node_s);
+
+       _EXTERN_FUNC_EXIT;
+
+       return debug_info;
+}
+
+UTIL_STATIC UTIL_INLINE void *util_get_front_red_zone(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *front_red_zone = NULL;
+       front_red_zone = real_bytes + sizeof(util_list_node_s) + UTIL_ALIGN64(sizeof(util_alloc_debug_info_s));
+
+       _EXTERN_FUNC_EXIT;
+
+       return front_red_zone;
+}
+
+UTIL_STATIC UTIL_INLINE void *util_get_bytes(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *bytes = NULL;
+       bytes = real_bytes + sizeof(util_list_node_s) + UTIL_ALIGN64(sizeof(util_alloc_debug_info_s)) + UTIL_ALLOC_FRONT_RED_ZONE_SIZE;
+
+       _EXTERN_FUNC_EXIT;
+
+       return bytes;
+}
+
+UTIL_STATIC UTIL_INLINE void *util_get_rear_red_zone(void *real_bytes, unsigned int bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *rear_red_zone = NULL;
+       rear_red_zone = real_bytes + sizeof(util_list_node_s) + UTIL_ALIGN64(sizeof(util_alloc_debug_info_s)) + UTIL_ALLOC_FRONT_RED_ZONE_SIZE + bytes;
+
+       _EXTERN_FUNC_EXIT;
+
+       return rear_red_zone;
+}
+
+UTIL_STATIC UTIL_INLINE util_list_node_s *util_get_my_list_node(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_list_node_s *my_list_node = NULL;
+       my_list_node = (util_list_node_s *) real_bytes;
+
+       _EXTERN_FUNC_EXIT;
+
+       return my_list_node;
+}
+
+UTIL_STATIC UTIL_INLINE bool util_check_red_zone(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool pass = true;
+       pass = util_check_front_red_zone(real_bytes);
+       if (!pass)
+               goto return_part;
+
+       pass = util_check_rear_red_zone(real_bytes);
+ return_part:
+       _DEBUG_INFO("finished with pass = %d\n", pass);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pass;
+}
+
+UTIL_STATIC UTIL_INLINE bool util_check_red_zone_with_pattern(char *red_zone, char pattern, unsigned int pattern_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool different = false;
+       int i;
+       for (i = 0; i < pattern_size; i++) {
+               different |= (red_zone[i] ^ pattern);
+               if (different) {
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return (!different);
+}
+
+UTIL_STATIC UTIL_INLINE bool util_check_front_red_zone(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *front_red_zone = util_get_front_red_zone(real_bytes);
+       bool pass = util_check_red_zone_with_pattern(front_red_zone,
+                                                    UTIL_ALLOC_FRONT_RED_ZONE_PATTERN, UTIL_ALLOC_FRONT_RED_ZONE_SIZE);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pass;
+}
+
+UTIL_STATIC UTIL_INLINE bool util_check_rear_red_zone(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_alloc_debug_info_s *pAlloc_debug_info = util_get_debug_info(real_bytes);
+
+       void *rear_red_zone = util_get_rear_red_zone(real_bytes, pAlloc_debug_info->size);
+       bool pass = util_check_red_zone_with_pattern(rear_red_zone,
+                                                    UTIL_ALLOC_REAR_RED_ZONE_PATTERN, UTIL_ALLOC_REAR_RED_ZONE_SIZE);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pass;
+}
+
+/*
+ *@brief               init already allocated debug info
+ *@param[in]           debug_info : already allocated debug info structure
+ *@param[in]           byte_size
+ *@param[in]           file                    : file must be allocated already
+ *@param[in]           line
+ */
+UTIL_STATIC UTIL_INLINE void util_init_debug_info(util_alloc_debug_info_s * debug_info, unsigned int byte_size, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO : assert debug_info != NULL */
+       debug_info->file = file;
+       debug_info->line = line;
+       debug_info->size = byte_size;
+       debug_info->time = time(NULL);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+UTIL_STATIC bool util_init_real_bytes(void *real_bytes, unsigned int bytes, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = true;
+       void *front_red_zone = NULL;
+       void *rear_red_zone = NULL;
+       util_alloc_debug_info_s *debug_info_ptr = NULL;
+       util_list_node_s *list_link = NULL;
+
+       char *dup_file = NULL;
+       dup_file = strdup(file);
+       if (dup_file == NULL) {
+               success = false;
+               goto return_part;
+       }
+
+       /* init list_link */
+       list_link = util_get_my_list_node(real_bytes);
+       list_link->next = NULL;
+       list_link->prev = NULL;
+
+       /* init_debug_info */
+       debug_info_ptr = util_get_debug_info(real_bytes);
+       util_init_debug_info(debug_info_ptr, bytes, dup_file, line);
+
+       /* init front redzone */
+       front_red_zone = util_get_front_red_zone(real_bytes);
+       memset(front_red_zone, UTIL_ALLOC_FRONT_RED_ZONE_PATTERN, UTIL_ALLOC_FRONT_RED_ZONE_SIZE);
+
+       /* init rear redzone */
+       rear_red_zone = util_get_rear_red_zone(real_bytes, bytes);
+       memset(rear_red_zone, UTIL_ALLOC_REAR_RED_ZONE_PATTERN, UTIL_ALLOC_REAR_RED_ZONE_SIZE);
+
+ return_part:
+       if (dup_file != NULL) {
+               free(dup_file);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+/*
+ *@brief               alloc realbytes then init debug info, front and rear redzone
+ *@param[in]           byte_size
+ *@param[in]           file
+ *@param[in]           line
+ */
+UTIL_STATIC void *util_alloc_init_real_bytes(unsigned int bytes, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *real_bytes = NULL;
+
+       unsigned int real_bytes_len = 0;
+       bool success = true;
+
+       /* get real byte size */
+       real_bytes_len = sizeof(util_list_node_s) + UTIL_ALIGN64(sizeof(util_alloc_debug_info_s)) + bytes + UTIL_ALLOC_FRONT_RED_ZONE_SIZE + UTIL_ALLOC_REAR_RED_ZONE_SIZE;
+
+       /* memory allocation : real byte memory & duplicate file */
+       real_bytes = malloc(real_bytes_len);
+       if (real_bytes == NULL) {
+               success = false;
+               goto return_part;
+       }
+
+       success = util_init_real_bytes(real_bytes, bytes, file, line);
+
+ return_part:
+       if (!success) {
+               if (real_bytes != NULL) {
+                       free(real_bytes);
+                       real_bytes = NULL;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return real_bytes;
+}
+
+UTIL_STATIC void util_free_real_bytes(void *real_bytes)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (real_bytes != NULL) {
+               util_alloc_debug_info_s *debug_info_ptr = NULL;
+
+               debug_info_ptr = util_get_debug_info(real_bytes);
+               if (debug_info_ptr->file != NULL) {
+                       free((void *)(debug_info_ptr->file));
+               }
+               free(real_bytes);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* external interface */
+
+void *util_malloc(unsigned int bytes, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *real_bytes = NULL;
+       void *ret_ptr = NULL;
+       util_list_node_s *pList_link = NULL;
+
+       real_bytes = util_alloc_init_real_bytes(bytes, file, line);
+       if (real_bytes == NULL) {
+               goto return_part;
+       }
+
+       /* put in list */
+       pList_link = util_get_my_list_node(real_bytes);
+
+       pthread_mutex_lock(&mutex);
+       {
+               util_list_add_node(pList_link, &alloc_list_head);
+       }
+       pthread_mutex_unlock(&mutex);
+
+       ret_ptr = util_get_bytes(real_bytes);
+
+ return_part:
+       _DEBUG_INFO("[%s] allocation done! return ptr = %p\n", __func__, ret_ptr);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret_ptr;
+}
+
+void *util_calloc(unsigned int bytes, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *out_bytes = NULL;
+       out_bytes = util_malloc(bytes, file, line);
+       memset(out_bytes, 0x00, bytes);
+
+       _EXTERN_FUNC_EXIT;
+
+       return out_bytes;
+}
+
+void *util_realloc(void *ptr, unsigned int bytes, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+void util_free(void *ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *real_bytes = util_get_real_bytes(ptr);
+       util_list_node_s *pList_link = util_get_my_list_node(real_bytes);
+       bool pass_redzone = false;
+
+       /* remove in list */
+       pthread_mutex_lock(&mutex);
+       {
+               util_list_delete_node(pList_link);
+       }
+       pthread_mutex_unlock(&mutex);
+
+       pass_redzone = util_check_red_zone(real_bytes);
+       if (!pass_redzone) {
+               util_alloc_debug_info_s *debug_info_ptr = NULL;
+               debug_info_ptr = util_get_debug_info(real_bytes);
+
+               char time_str[26];
+               ctime_r(&(debug_info_ptr->time), (char *)(&time_str));
+
+               _DEBUG_ERROR("REDZONE CHECK ERROR. \n" "\tmalloc from:" "filename = %s, line = %d, size = %d\n at time = %s", debug_info_ptr->file, debug_info_ptr->line, debug_info_ptr->size, time_str);
+
+               _DEBUG_ERROR("[%s] checking redzone failed in ptr = %p\n", __func__, ptr);
+               /* TODO : abort */
+       } else {
+               _DEBUG_INFO("[%s] checking redzone success in ptr = %p\n", __func__, ptr);
+       }
+
+       util_free_real_bytes(real_bytes);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+char *util_strdup(const char *src, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (src == NULL) {
+               goto error_part;
+       }
+
+       unsigned int str_len = strlen(src);
+       char *out_string = util_malloc(str_len + 1, file, line);
+       if (out_string == NULL) {
+               goto error_part;
+       }
+
+       memcpy(out_string, src, str_len);
+       out_string[str_len] = '\0';
+
+       _EXTERN_FUNC_EXIT;
+
+       return out_string;
+
+ error_part:
+       return NULL;
+}
+
+char *util_strndup(const char *src, unsigned int n, const char *file, int line)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+#endif
diff --git a/src/framework/utility/fw_alloc.h b/src/framework/utility/fw_alloc.h
new file mode 100755 (executable)
index 0000000..42bff6d
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_ALLOC_H_
+#define FW_ALLOC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_alloc.h
+ * @brief provides allocate operation
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/* data structure alignment */
+#define UTIL_ALIGN(n, m)               (((n) + ((m) - 1)) & ~((m) - 1))                /**< align*/
+
+#define UTIL_ALIGN16(n)                UTIL_ALIGN(n, 2)                                                /**< align16*/
+#define UTIL_ALIGN32(n)                UTIL_ALIGN(n, 4)                                                /**< align32*/
+#define UTIL_ALIGN64(n)                UTIL_ALIGN(n, 8)                                                /**< align64*/
+
+/* memory allocation */
+#ifdef NDEBUG
+#include <string.h>
+#include <stdlib.h>
+
+/* release version */
+       static inline void *UTIL_MALLOC(size_t bytes) {
+               return malloc(bytes);
+       }
+       static inline void *UTIL_CALLOC(size_t nmemb, size_t size) {
+               return calloc(nmemb, size);
+       }
+
+       static inline void *UTIL_REALLOC(void *ptr, size_t bytes) {
+               return realloc(ptr, bytes);
+       }
+
+       static inline char *UTIL_STRDUP(const char *src) {
+               return strdup(src);
+       }
+
+       static inline char *UTIL_STRNDUP(const char *src, unsigned int n) {
+               return strndup(src, n);
+       }
+
+#define UTIL_FREE                free
+
+#else
+/* debug version */
+#define UTIL_MALLOC(bytes)                                                      \
+               util_malloc(bytes, __FILE__, __LINE__)
+#define UTIL_CALLOC(nmemb, size)                                                \
+               util_calloc((nmemb) * (size), __FILE__, __LINE__)
+#define UTIL_REALLOC(ptr, bytes)                                                \
+               util_realloc(ptr, bytes, __FILE__, __LINE__)
+#define UTIL_FREE(ptr)                                                          \
+               util_free(ptr)
+#define UTIL_FREE_NO_INFO                                                       \
+               util_free_no_info
+
+#define UTIL_STRDUP(src)                                                        \
+               util_strdup(src, __FILE__, __LINE__)
+#define UTIL_STRNDUP(src, n)                                                    \
+               util_strndup(src, n, __FILE__, __LINE__)
+
+/**
+ * @brief      malloc
+ * @param[in]  bytes           bytes
+ * @param[in]  file            file
+ * @param[in]  line            line
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+       void *util_malloc(unsigned int bytes, const char *file, int line);
+
+/**
+ * @brief      calloc
+ * @param[in]  bytes           bytes
+ * @param[in]  file            file
+ * @param[in]  line            line
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+       void *util_calloc(unsigned int bytes, const char *file, int line);
+
+/**
+ * @brief      realloc
+ * @param[in]  ptr             ptr
+ * @param[in]  bytes           bytes
+ * @param[in]  file            file
+ * @param[in]  line            line
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+       void *util_realloc(void *ptr, unsigned int bytes, const char *file, int line);
+
+/**
+ * @brief      free
+ * @param[in]  ptr                     ptr
+ */
+       void util_free(void *ptr);
+
+/* TODO */
+
+/**
+ * @brief      string copy
+ * @param[in]  src             source
+ * @param[in]  file            file
+ * @param[in]  line            line
+ * @return             string
+ * @retval             string  success
+ * @retval             NULL            fail
+ */
+       char *util_strdup(const char *src, const char *file, int line);
+
+/**
+ * @brief      string copy at most n characters
+ * @param[in]  src             source
+ * @param[in]  n               n characters
+ * @param[in]  file            file
+ * @param[in]  line            line
+ * @return             string
+ * @retval             string  success
+ * @retval             NULL            fail
+ */
+       char *util_strndup(const char *src, unsigned int n, const char *file, int line);
+
+#endif                         /* no DEBUG_ALLOC */
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_ALLOC_H_ */
diff --git a/src/framework/utility/fw_alloc_internal.h b/src/framework/utility/fw_alloc_internal.h
new file mode 100755 (executable)
index 0000000..1df5393
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_ALLOC_INTERNAL_H_
+#define FW_ALLOC_INTERNAL_H_
+
+#include <pthread.h>
+#include <glib.h>
+#include <stdbool.h>
+#include "utility/fw_list.h"
+
+/**
+ * @file fw_alloc_internal.h
+ * @brief provides allocate operation
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define UTIL_ALLOC_FRONT_RED_ZONE_SIZE                 8                       /**< front red zone size */
+#define UTIL_ALLOC_REAR_RED_ZONE_SIZE                  8                       /**< rear red zone size */
+#define UTIL_ALLOC_FRONT_RED_ZONE_PATTERN              0xa7            /**< front red zone pattern */
+#define UTIL_ALLOC_REAR_RED_ZONE_PATTERN                       0x9d    /**< rear red zone pattern */
+
+/**
+ * @brief      debug info structure
+ */
+typedef struct util_alloc_debug_info util_alloc_debug_info_s;
+struct util_alloc_debug_info {
+       const char *file;                       /**< file */
+       time_t time;                            /**< time */
+       unsigned int line;                      /**< line */
+       unsigned int size;                      /**< size */
+};
+
+#ifdef NDEBUG
+#define UTIL_STATIC static
+#define UTIL_INLINE inline
+#else
+#define UTIL_STATIC
+#define UTIL_INLINE
+#endif
+
+/**
+ * @brief      get real bytes
+ * @param[in]  bytes           bytes
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE void *util_get_real_bytes(void *bytes);
+
+/**
+ * @brief      get debug info
+ * @param[in]  real_bytes              real bytes
+ * @return             util_alloc_debug_info_s on success, NULL on fail
+ * @retval             util_alloc_debug_info_s success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE util_alloc_debug_info_s *util_get_debug_info(void *real_bytes);
+
+/**
+ * @brief      get front red zone
+ * @param[in]  real_bytes              real bytes
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE void *util_get_front_red_zone(void *real_bytes);
+
+/**
+ * @brief      get bytes
+ * @param[in]  real_bytes              real bytes
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE void *util_get_bytes(void *real_bytes);
+
+/**
+ * @brief      get bytes
+ * @param[in]  real_bytes              real bytes
+ * @param[in]  bytes           bytes
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE void *util_get_rear_red_zone(void *real_bytes, unsigned int bytes);
+
+/**
+ * @brief      get my list node
+ * @param[in]  real_bytes              real bytes
+ * @return             util_list_node_s on success, NULL on fail
+ * @retval             util_list_node_s        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC UTIL_INLINE util_list_node_s *util_get_my_list_node(void *real_bytes);
+
+/**
+ * @brief      check red zone
+ * @param[in]  real_bytes              real bytes
+ * @return             true on yes, false on no
+ * @retval             true    yes
+ * @retval             false           no
+ */
+UTIL_STATIC UTIL_INLINE bool util_check_red_zone(void *real_bytes);
+
+/**
+ * @brief      check front red zone
+ * @param[in]  real_bytes              real bytes
+ * @return             true on yes, false on no
+ * @retval             true    yes
+ * @retval             false           no
+ */
+UTIL_STATIC UTIL_INLINE bool util_check_front_red_zone(void *real_bytes);
+
+/**
+ * @brief      check rear red zone
+ * @param[in]  real_bytes              real bytes
+ * @return             true on yes, false on no
+ * @retval             true    yes
+ * @retval             false           no
+ */
+UTIL_STATIC UTIL_INLINE bool util_check_rear_red_zone(void *real_bytes);
+
+/**
+ * @brief      check rear red zone with pattern
+ * @param[in]  red_zone                red zone
+ * @param[in]  pattern                 pattern
+ * @param[in]  pattern_size                    pattern size
+ * @return             true on yes, false on no
+ * @retval             true    yes
+ * @retval             false           no
+ */
+UTIL_STATIC UTIL_INLINE bool util_check_red_zone_with_pattern(char *red_zone, char pattern, unsigned int pattern_size);
+
+/**
+ * @brief      initialize debug info
+ * @param[in]  debug_info                      red zone
+ * @param[in]  byte_size                       pattern
+ * @param[in]  file                            file
+ * @param[in]  line                            line
+ */
+UTIL_STATIC UTIL_INLINE void util_init_debug_info(util_alloc_debug_info_s * debug_info, unsigned int byte_size, const char *file, int line);
+
+/**
+ * @brief      initialize real bytes
+ * @param[in]  real_bytes                      real bytes
+ * @param[in]  bytes                   bytes
+ * @param[in]  file                            file
+ * @param[in]  line                            line
+ * @return             true on yes, false on no
+ * @retval             true    yes
+ * @retval             false           no
+ */
+UTIL_STATIC bool util_init_real_bytes(void *real_bytes, unsigned int bytes, const char *file, int line);
+
+/**
+ * @brief      allocate init real bytes
+ * @param[in]  bytes                   bytes
+ * @param[in]  file                            file
+ * @param[in]  line                            line
+ * @return             void ptr
+ * @retval             void ptr        success
+ * @retval             NULL            fail
+ */
+UTIL_STATIC void *util_alloc_init_real_bytes(unsigned int bytes, const char *file, int line);
+
+/**
+ * @brief      free real bytes
+ * @param[in]  real_bytes                      real bytes
+ */
+UTIL_STATIC void util_free_real_bytes(void *real_bytes);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_ALLOC_INTERNAL_H_ */
diff --git a/src/framework/utility/fw_async_queue.c b/src/framework/utility/fw_async_queue.c
new file mode 100755 (executable)
index 0000000..99192ad
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "utility/fw_async_queue.h"
+#include "utility/fw_async_queue_internal.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_UTIL_FW_AYNC_QUEUE"
+#endif
+
+EXPORT_API sync_agent_util_async_queue_s *sync_agent_alloc_async_queue()
+{
+       _EXTERN_FUNC_ENTER;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+#endif
+
+       sync_agent_util_async_queue_s *queue = (sync_agent_util_async_queue_s *) calloc(1, sizeof(sync_agent_util_async_queue_s));
+       if (queue == NULL) {
+               goto return_part;
+       }
+
+       queue->pQueue = g_async_queue_new();
+       if (queue->pQueue == NULL) {
+               goto error_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return queue;
+
+ error_part:
+       util_destroy_async_queue(queue);
+       return NULL;
+}
+
+void util_destroy_async_queue(sync_agent_util_async_queue_s * queue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(queue == NULL, "queue parameter is NULL !!");
+
+       if (queue != NULL) {
+               if (queue->pQueue != NULL) {
+                       g_async_queue_unref(queue->pQueue);
+                       queue->pQueue = NULL;
+               }
+               free(queue);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_lock_async_queue(sync_agent_util_async_queue_s * queue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(queue == NULL, "queue parameter is NULL !!");
+
+       if (queue != NULL && queue->pQueue != NULL) {
+               g_async_queue_lock(queue->pQueue);
+       } else {
+               _DEBUG_INFO("Invalid fw_async_queue\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_unlock_async_queue(sync_agent_util_async_queue_s * queue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(queue == NULL, "queue parameter is NULL !!");
+
+       if (queue != NULL && queue->pQueue != NULL) {
+               g_async_queue_unlock(queue->pQueue);
+       } else {
+               _DEBUG_INFO("Invalid fw_async_queue\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void *sync_agent_receive_msg_async_queue(sync_agent_util_async_queue_s * queue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(queue == NULL, NULL, "queue parameter is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_async_queue_pop(queue->pQueue);
+}
+
+EXPORT_API void sync_agent_send_msg_async_queue(sync_agent_util_async_queue_s * queue, void *msg)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(queue == NULL, "queue parameter is NULL !!");
+
+       g_async_queue_push(queue->pQueue, msg);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_send_msg_async_queue_with_compare_priority(sync_agent_util_async_queue_s * queue, void *msg, sync_agent_compare_priority_cb cpf, void *user_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(queue == NULL, "queue parameter is NULL !!");
+
+       if (cpf == NULL) {
+               g_async_queue_push(queue->pQueue, msg);
+       } else {
+               g_async_queue_push_sorted(queue->pQueue, msg, cpf, user_data);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_async_queue_length(sync_agent_util_async_queue_s * queue)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(queue == NULL, -1, "queue parameter is NULL !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return g_async_queue_length(queue->pQueue);
+}
diff --git a/src/framework/utility/fw_async_queue_internal.h b/src/framework/utility/fw_async_queue_internal.h
new file mode 100755 (executable)
index 0000000..aeba285
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_ASYNC_QUEUE_INTERNAL_H_
+#define FW_ASYNC_QUEUE_INTERNAL_H_
+
+#include "utility/fw_async_queue.h"
+
+/**
+ * @file fw_async_queue_internal.h
+ * @brief      provides DataStructure - asynchronous Queue
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * @brief      destroy asynchronous Queue
+ * @param[in]  queue           asynchronous Queue
+ */
+void util_destroy_async_queue(sync_agent_util_async_queue_s * queue);
+
+/**
+ * @brief      lock asynchronous Queue
+ * @param[in]  queue           asynchronous Queue
+ */
+void util_lock_async_queue(sync_agent_util_async_queue_s * queue);
+
+/**
+ * @brief      unlock asynchronous Queue
+ * @param[in]  queue           asynchronous Queue
+ */
+void util_unlock_async_queue(sync_agent_util_async_queue_s * queue);
+
+/**
+ * @brief      send item to asynchronous Queue with priority
+ * @param[in]  queue           asynchronous Queue
+ * @param[in]  msg             item
+ * @param[in]  cpf              priority for callback function
+ * @param[in]  user_data               user_data
+ */
+void util_send_msg_async_queue_with_compare_priority(sync_agent_util_async_queue_s * queue, void *msg, sync_agent_compare_priority_cb cpf, void *user_data);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_ASYNC_QUEUE_INTERNAL_H_ */
diff --git a/src/framework/utility/fw_cache.c b/src/framework/utility/fw_cache.c
new file mode 100755 (executable)
index 0000000..1a042fc
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <glib.h>
+
+#include "utility/fw_cache.h"
+#include "utility/fw_common.h"
+#include "utility/fw_thread.h"
+
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_CACHE"
+#endif
+
+/**
+ * @brief      cache structure
+ */
+typedef struct {
+       UTIL_THREAD_MUTEX_T mutex;      /**< Mutex to protect access to the structure */
+       char *cache_name;       /**< cache name */
+       void *value;            /**< object pointer in this cache */
+       int ref_count;          /**< reference count for value */
+} util_cache_s;
+
+/**
+ * @brief      cache manager structure
+ */
+typedef struct {
+       util_cache_constructor_cb *constructor; /**< constructor to allocate memory for cache value */
+       util_cache_destructor_cb *destructor;   /**< destructor to free memory for cache value */
+       util_cache_reloader_cb *reloader;       /**< reloader to reload memory for cache value */
+       UTIL_HASH_TABLE *cache_hash_table;      /**< hash table */
+       UTIL_THREAD_MUTEX_T hash_mutex;         /**< hash mutex */
+} util_cache_manager_s;
+
+static util_cache_manager_s *cache_manager = NULL;
+
+static util_cache_s *_alloc_cache(const char *cache_name);
+static void _free_cache(util_cache_s * cache);
+
+int util_create_cache(util_cache_constructor_cb * constructor, util_cache_destructor_cb * destructor, util_cache_reloader_cb * reloader)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cache_manager != NULL) {
+               _DEBUG_ERROR("cache_manager exist already !!");
+               return 0;
+       }
+
+       cache_manager = (util_cache_manager_s *) calloc(1, sizeof(util_cache_manager_s));
+       if (cache_manager == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       pthread_mutex_init(&cache_manager->hash_mutex, 0);
+       cache_manager->constructor = constructor;
+       cache_manager->reloader = reloader;
+       cache_manager->destructor = destructor;
+       cache_manager->cache_hash_table = g_hash_table_new(g_int_hash, 0);
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int util_destroy_cache(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (cache_manager == NULL) {
+               _DEBUG_ERROR("cache_manage is NULL. cache cannot free !!");
+               return 0;
+       }
+
+       g_hash_table_destroy(cache_manager->cache_hash_table);
+       pthread_mutex_destroy(&cache_manager->hash_mutex);
+       free(cache_manager);
+       cache_manager = NULL;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+void *util_use_cache_info(const char *cache_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *object = NULL;
+       if (cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL) {
+               _DEBUG_ERROR("cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL");
+               goto return_part;
+       }
+
+       util_cache_s *cache = NULL;
+       UTIL_THREAD_MUTEX_LOCK(&cache_manager->hash_mutex);
+       cache = g_hash_table_lookup(cache_manager->cache_hash_table, cache_name);
+       if (cache == NULL) {
+               _DEBUG_INFO("Cache Search Fail and add Cache Hash Table !!");
+               cache = _alloc_cache(cache_name);
+               if (cache == NULL) {
+                       _DEBUG_ERROR("Failed to __alloc_cache()");
+                       UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+                       return NULL;
+               }
+               g_hash_table_insert(cache_manager->cache_hash_table, (void *)cache_name, cache);
+               object = cache->value;
+               UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+               goto return_part;
+       }
+       UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+
+       _DEBUG_INFO("Cache Search Success !!");
+       UTIL_THREAD_MUTEX_LOCK(&cache->mutex);
+       cache->ref_count++;
+       object = cache->value;
+       UTIL_THREAD_MUTEX_UNLOCK(&cache->mutex);
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+
+       return object;
+}
+
+int util_return_cache_info(const char *cache_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 1;
+
+       if (cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL) {
+               _DEBUG_ERROR("cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL");
+               ret = 0;
+               goto return_part;
+       }
+
+       util_cache_s *cache = NULL;
+       UTIL_THREAD_MUTEX_LOCK(&cache_manager->hash_mutex);
+       cache = g_hash_table_lookup(cache_manager->cache_hash_table, cache_name);
+       if (cache == NULL) {
+               _DEBUG_ERROR("Cache Search Fail");
+               ret = 0;
+               goto mutex_unlock;
+       }
+
+       _DEBUG_INFO("Cache Search Success");
+       UTIL_THREAD_MUTEX_LOCK(&cache->mutex);
+       (cache->ref_count)--;
+       UTIL_THREAD_MUTEX_UNLOCK(&cache->mutex);
+
+       if (cache->ref_count <= 0) {
+               g_hash_table_remove(cache_manager->cache_hash_table, cache_name);
+               _free_cache(cache);
+       }
+
+ mutex_unlock:
+       UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+ return_part:
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+void *util_reload_cache_info(const char *cache_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       void *object = NULL;
+       if (cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL) {
+               _DEBUG_ERROR("cache_name == NULL || cache_manager == NULL || cache_manager->cache_hash_table == NULL");
+               goto return_part;
+       }
+
+       util_cache_s *cache = NULL;
+       UTIL_THREAD_MUTEX_LOCK(&cache_manager->hash_mutex);
+       cache = g_hash_table_lookup(cache_manager->cache_hash_table, cache_name);
+       if (cache == NULL) {
+               /* insert cache */
+               _DEBUG_INFO("Cache Search Fail and add Cache Hash Table !!");
+               cache = _alloc_cache(cache_name);
+               if (cache == NULL) {
+                       _DEBUG_ERROR("Failed to __alloc_cache()");
+                       UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+                       return NULL;
+               }
+               g_hash_table_insert(cache_manager->cache_hash_table, (void *)cache_name, cache);
+               object = cache->value;
+               UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+               goto return_part;
+       }
+       UTIL_THREAD_MUTEX_UNLOCK(&cache_manager->hash_mutex);
+
+       _DEBUG_INFO("Cache Search Success");
+       UTIL_THREAD_MUTEX_LOCK(&cache->mutex);
+
+       if (cache_manager->destructor != NULL)
+               cache_manager->destructor(cache_name, cache->value);
+       if (cache_manager->reloader != NULL)
+               cache->value = cache_manager->reloader(cache_name);
+       object = cache->value;
+       UTIL_THREAD_MUTEX_UNLOCK(&cache->mutex);
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+
+       return object;
+}
+
+static util_cache_s *_alloc_cache(const char *cache_name)
+{
+       _INNER_FUNC_ENTER;
+
+       util_cache_s *cache = (util_cache_s *) calloc(1, sizeof(util_cache_s));
+       if (cache == NULL)
+               return NULL;
+
+       pthread_mutex_init(&cache->mutex, 0);
+       cache->cache_name = strdup(cache_name);
+       cache->ref_count = 1;
+
+       if (cache_manager->constructor != NULL)
+               cache->value = cache_manager->constructor(cache_name);
+
+       _INNER_FUNC_EXIT;
+
+       return cache;
+}
+
+static void _free_cache(util_cache_s * cache)
+{
+       _INNER_FUNC_ENTER;
+
+       if (cache != NULL) {
+
+               if (cache->cache_name != 0 && cache->value) {
+                       if (cache_manager->destructor != NULL)
+                               cache_manager->destructor(cache->cache_name, cache->value);
+                       free(cache->cache_name);
+               }
+
+               pthread_mutex_destroy(&cache->mutex);
+               free(cache);
+       }
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/framework/utility/fw_cache.h b/src/framework/utility/fw_cache.h
new file mode 100755 (executable)
index 0000000..2d5872e
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_CACHE_H_
+#define FW_CACHE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_cache.h
+ * @brief Provides cache service such as create, destroy, reload and etc
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * @brief              Constructor used to initialize allocated objects
+ * @param[in]  key                                                                     key to allocate
+ * @return                     operation result
+ * @retval                     object pointer to cache         success
+ * @retval                     0                                                                               fail
+ */
+       typedef void *util_cache_constructor_cb(const char *key);
+
+/**
+ * @brief              Destructor used to clean up allocated objects before they are
+ * @param[in]          key                                                                     key to allocate
+ * @param[in]          obj                                                                     object pointer
+ */
+       typedef void util_cache_destructor_cb(const char *key, void *obj);
+
+/**
+ * @brief                      Reloader used to reload allocated objects
+ * @param[in]  key                                                                     key to allocate
+ * @return                     operation result
+ * @retval                     object pointer to cache         success
+ * @retval                     0                                                                               fail
+ */
+       typedef void *util_cache_reloader_cb(const char *key);
+
+/**
+ * @brief                      Create a cache.
+ *
+ * you should register only once per process
+ *
+ * @param[in]          constructor             the function to be called to initialize memory when we need to allocate more memory from the os.
+ * @param[in]          destructor              destructor the function to be called before we release the memory back  to the os.
+ * @param[in]          reloader                        reloader the function to be called when we need to reload from the os.
+ * @return                     operation result
+ * @retval                     1               success
+ * @retval                     0               fail
+ */
+       int util_create_cache(util_cache_constructor_cb * constructor, util_cache_destructor_cb * destructor, util_cache_reloader_cb * reloader);
+
+/**
+ * @brief                      Destroy a cache.
+ *
+ * you should register only once per process
+ *
+ * @return                     operation result
+ * @retval                     1               success
+ * @retval                     0               fail
+ */
+       int util_destroy_cache(void);
+
+/**
+ * @brief                      Allocate a cache object and register has table
+ *
+ * That corresponds to the cache_name of the constructor callback function should be written.
+ *
+ * @param[in]          cache_name      cache name (is used hash table key)
+ * @return                     operation result
+ * @retval                     1               success
+ * @retval                     0               fail
+ */
+       void *util_use_cache_info(const char *cache_name);
+
+/**
+ * @brief                      Return an object back to the cache.
+ *
+ *  That corresponds to the cache_name of the destructor callback function should be written.
+ *
+ * @param[in]          cache_name              cache name (is used hash table key)
+ * @return                     operation result
+ * @retval                     1               success
+ * @retval                     0               fail
+ */
+       int util_return_cache_info(const char *cache_name);
+
+/**
+ * @brief                      Reload an object to the cache
+ *
+ *  That corresponds to the cache_name of the reloader callback function should be written.
+ *
+ * @param[in]          cache_name              cache name (is used hash table key)
+ * @retval                     1               success
+ * @retval                     0               fail
+ */
+       void *util_reload_cache_info(const char *cache_name);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_CACHE_H_ */
diff --git a/src/framework/utility/fw_common.h b/src/framework/utility/fw_common.h
new file mode 100755 (executable)
index 0000000..b1ee428
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_COMMON_H_
+#define FW_COMMON_H_
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <glib.h>
+
+/**
+ * @file fw_common.h
+ * @brief Provides list and hash table
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define UTIL_SLIST             GSList
+
+#define UTIL_SLIST_SORT(list, compare_func)    g_slist_sort(list, compare_func)
+#define UTIL_SLIST_FIND(list, data)                            g_slist_find(list, data)
+#define UTIL_SLIST_PREPEND(list, data)                 g_slist_prepend(list, data)
+#define UTIL_SLIST_APPEND(list, data)                  g_slist_append(list, data)
+#define UTIL_SLIST_REMOVE(list, data)                  g_slist_remove(list, data)
+#define UTIL_SLIST_FIND_CUSTOM(list, data, func)       g_slist_find_custom(list, data, func)
+#define UTIL_SLIST_INSERT_SORTED(list, data, func)     g_slist_insert_sorted(list, data, func)
+#define UTIL_SLIST_FOREACH(list, func, user_data)      g_slist_foreach(list, func, user_data)
+#define UTIL_SLIST_FREE(list)                                                          g_slist_free(list)
+#define UTIL_SLIST_REMOVE_LINK(list, link)                             g_slist_remove_link(list, link)
+#define UTIL_SLIST_NEXT(list)                                                          g_slist_next(iist)
+
+#define UTIL_HASH_TABLE        GHashTable
+
+#define UTIL_HASH_TABLE_NEW(hash_func, equal_func)     g_hash_table_new(hash_func, equal_func)
+#define UTIL_HASH_TABLE_DESTORY(hash_table)                    g_hash_table_destroy(hash_table)
+#define UTIL_HASH_TABLE_LOOKUP(hasn_table, key)        g_hash_table_lookup(hasn_table, key)
+#define UTIL_HASH_TABLE_INSERT(hash_table, key, valaue)        g_hash_table_insert(hash_table, key, value)
+#define UTIL_HASH_TABLE_REMOVE(hash_table, key)        g_hash_table_remove(hash_table, key)
+
+#include <stdbool.h>
+#define UTIL_BOOL      bool
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_COMMON_H_ */
diff --git a/src/framework/utility/fw_compress.c b/src/framework/utility/fw_compress.c
new file mode 100755 (executable)
index 0000000..e5d8db3
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <errno.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_compress.h"
+#include "fsapi/operation.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_COMPRESS"
+#endif
+
+EXPORT_API sync_agent_util_compress_result_e sync_agent_compress(sync_agent_util_compress_type_e type, const char *input_directory_path, const char *output_file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (input_directory_path == NULL || output_file_path == NULL) {
+               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+       }
+
+       if (!sync_agent_is_existing_fs(input_directory_path)) {
+               _DEBUG_ERROR("tar input file not existing !!");
+               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+       }
+
+       char *command = NULL;
+
+       switch (type) {
+       case SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR:
+               {
+                       int command_len = strlen("tar cvzpf ") + strlen(output_file_path) + strlen(" ") + strlen(input_directory_path) + 1;
+                       int len = 0;
+                       command = (char *)calloc(command_len, sizeof(char));
+                       if (command == NULL)
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+
+                       len = g_strlcat(command, "tar cvzpf ", command_len);
+                       len = g_strlcat(command, output_file_path, command_len);
+                       len = g_strlcat(command, " ", command_len);
+                       len = g_strlcat(command, input_directory_path, command_len);
+
+                       if (len >= command_len) {
+                               _DEBUG_ERROR("command buffer overflow !!");
+                               free(command);
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                       }
+
+                       int pid = fork();
+                       if (pid == -1) {
+                               _DEBUG_ERROR("Fork failed to create a process");
+                               free(command);
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                       } else if (pid == 0) {
+                               char *argv[4];
+
+                               argv[0] = "sh";
+                               argv[1] = "-c";
+                               argv[2] = command;
+                               argv[3] = 0;
+
+                               execv("/bin/sh", argv);
+
+                               abort();
+                       }
+
+                       int status = 0;
+                       do {
+                               if (waitpid(pid, &status, 0) == -1) {
+                                       if (errno != EINTR) {
+                                               free(command);
+                                               _EXTERN_FUNC_EXIT;
+                                               return SYNC_AGENT_UTIL_COMPRESS_SUCCESS;
+                                       } else {
+                                               free(command);
+                                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                                       }
+                               }
+                       } while (1);
+               }
+               break;
+       case SYNC_AGENT_UTIL_COMPRESS_TYPE_ZIP:
+               {
+                       /*
+                        * Not yet support
+                        */
+               }
+               break;
+       default:
+               _DEBUG_ERROR("Not support compress type!!");
+               break;
+       }
+
+       return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+}
+
+EXPORT_API sync_agent_util_compress_result_e sync_agent_uncompress(sync_agent_util_compress_type_e type, const char *input_file_path, const char *output_direcory_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (input_file_path == NULL || output_direcory_path == NULL) {
+               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+       }
+
+       if (!sync_agent_is_existing_fs(input_file_path)) {
+               _DEBUG_ERROR("tar input file not existing !!");
+               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+       }
+
+       char *command = NULL;
+
+       switch (type) {
+       case SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR:
+               {
+                       int command_len = strlen("tar xvf ") + strlen(input_file_path) + strlen(" -C ") + strlen(output_direcory_path) + 1;
+                       int len = 0;
+                       command = (char *)calloc(command_len, sizeof(char));
+                       if (command == NULL)
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+
+                       len = g_strlcat(command, "tar xvf ", command_len);
+                       len = g_strlcat(command, input_file_path, command_len);
+                       len = g_strlcat(command, " -C ", command_len);
+                       len = g_strlcat(command, output_direcory_path, command_len);
+
+                       if (len >= command_len) {
+                               _DEBUG_ERROR("command buffer overflow !!");
+                               free(command);
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                       }
+
+                       int pid = fork();
+                       if (pid == -1) {
+                               _DEBUG_ERROR("Fork failed to create a process");
+                               free(command);
+                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                       } else if (pid == 0) {
+                               char *argv[4];
+
+                               argv[0] = "sh";
+                               argv[1] = "-c";
+                               argv[2] = command;
+                               argv[3] = 0;
+
+                               execv("/bin/sh", argv);
+
+                               abort();
+                       }
+
+                       int status = 0;
+                       do {
+                               if (waitpid(pid, &status, 0) == -1) {
+                                       if (errno != EINTR) {
+                                               free(command);
+                                               _EXTERN_FUNC_EXIT;
+                                               return SYNC_AGENT_UTIL_COMPRESS_SUCCESS;
+                                       } else {
+                                               free(command);
+                                               return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+                                       }
+                               }
+                       } while (1);
+               }
+               break;
+       case SYNC_AGENT_UTIL_COMPRESS_TYPE_ZIP:
+               {
+                       /*
+                        * Not yet support
+                        */
+               }
+               break;
+       default:
+               _DEBUG_ERROR("Not support compress type!!");
+               break;
+       }
+
+       return SYNC_AGENT_UTIL_COMPRESS_FAIL;
+}
diff --git a/src/framework/utility/fw_file.c b/src/framework/utility/fw_file.c
new file mode 100755 (executable)
index 0000000..66e4c23
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utility/sync_util.h"
+#include "utility/fw_file.h"
+
+#include "fsapi/operation.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_UTIL_FILE"
+#endif
+
+#define UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER "/opt/data/sync-agent/db"
+
+EXPORT_API int sync_agent_set_int_into_file(char *file_path, int value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, 0, "file_path parameter is NULL !!");
+
+       char path[128];
+       char *temp_value = NULL;
+
+       if (!sync_agent_is_existing_fs(UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER)) {
+               if (!sync_agent_create_directory(UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER)) {
+                       _DEBUG_ERROR("Failed to create default folder");
+                       _EXTERN_FUNC_EXIT;
+                       return 0;
+               }
+       }
+
+       snprintf(path, sizeof(path), "%s/%s", UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER, file_path);
+       temp_value = g_strdup_printf("%d", value);
+
+       if (temp_value != NULL) {
+               _DEBUG_INFO("path = %s", path);
+               _DEBUG_INFO("value = %s", temp_value);
+
+               if (!sync_agent_write_whole_file(path, temp_value, strlen(temp_value), true)) {
+                       _DEBUG_ERROR("Failed write data");
+                       _EXTERN_FUNC_EXIT;
+                       return 0;
+               }
+
+               free(temp_value);
+       } else {
+               _DEBUG_ERROR("strdup() FAIL !!!");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+EXPORT_API int sync_agent_get_int_from_file(char *file_path, int *value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, 0, "file_path parameter is NULL !!");
+       retvm_if(value == NULL, 0, "value parameter is NULL !!");
+
+       char path[128];
+       char *temp_value = NULL;
+       unsigned long size;
+
+       snprintf(path, sizeof(path), "%s/%s", UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER, file_path);
+
+       _DEBUG_INFO("path = %s", path);
+       if (!sync_agent_read_whole_file(path, &temp_value, &size)) {
+               _DEBUG_ERROR("Failed to read file");
+               *value = 0;
+               return 0;
+       }
+
+       *value = atoi(temp_value);
+
+       _DEBUG_INFO("value = %d", *value);
+
+//      if (temp_value != NULL)
+       free(temp_value);
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+EXPORT_API int sync_agent_unset_file(char *file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, 0, "file_path parameter is NULL !!");
+
+       char path[128];
+
+       snprintf(path, sizeof(path), "%s/%s", UTIL_DEFAULT_ACCOUNT_PLUGIN_FOLDER, file_path);
+       _DEBUG_INFO("path = %s", path);
+
+       _EXTERN_FUNC_EXIT;
+
+       return sync_agent_delete_file(path);
+}
diff --git a/src/framework/utility/fw_list.c b/src/framework/utility/fw_list.c
new file mode 100755 (executable)
index 0000000..abb1f31
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "utility/fw_list.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_UTIL_LIST"
+#endif
+
+void util_list_add_node(util_list_node_s * new_node, util_list_node_s * head_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       *(volatile util_list_node_s **)&new_node->next = head_ptr->next;
+       new_node->prev = head_ptr;
+       head_ptr->next->prev = new_node;
+       head_ptr->next = new_node;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_list_delete_node(util_list_node_s * target_node)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_list_node_s *prev = target_node->prev;
+       util_list_node_s *next = target_node->next;
+
+       next->prev = prev;
+       *(volatile util_list_node_s **)&prev->next = next;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_list_move_node(util_list_node_s * list, util_list_node_s * head_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_list_delete_node(list);
+       util_list_add_node(list, head_ptr);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+int util_list_node_count(const util_list_node_s * head_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int volatile count = 0;
+
+       util_list_node_s *cursor_ptr = head_ptr->next;
+       while (cursor_ptr != head_ptr) {
+               count++;
+               cursor_ptr = cursor_ptr->next;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return count;
+}
+
+void util_list_init(util_list_node_s * node_ptr)
+{
+       _EXTERN_FUNC_ENTER;
+
+       node_ptr->next = node_ptr;
+       node_ptr->prev = node_ptr;
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/utility/fw_list.h b/src/framework/utility/fw_list.h
new file mode 100755 (executable)
index 0000000..1e7692c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_LIST_H_
+#define FW_LIST_H_
+
+/**
+ * @file               fw_list.h
+ * @brief      provide DataStructure - Linked List
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define UTIL_PREFETCH(link)
+
+#define UTIL_LIST_ITER(iter, head_ptr)                                               \
+for (iter = (head_ptr)->next; (UTIL_PREFETCH(iter->next) iter != (head_ptr));              \
+        iter = iter->next)
+
+/**
+ * @brief      Node structure of Double Linked List
+ */
+typedef struct util_list_node util_list_node_s;
+struct util_list_node {
+       util_list_node_s *next;                 /**< next */
+       util_list_node_s *prev;                 /**< prev */
+};
+
+/**
+ * @brief      add node
+ * @param[in] new_node                 util_list_node_s
+ * @param[in] head_ptr                 util_list_node_s
+ */
+void util_list_add_node(util_list_node_s * new_node, util_list_node_s * head_ptr);
+
+/**
+ * @brief      delete node
+ * @param[in] target_node                      util_list_node_s
+ */
+void util_list_delete_node(util_list_node_s * target_node);
+
+/**
+ * @brief      move node
+ * @param[in] list                             util_list_node_s
+ * @param[in] head_ptr                 util_list_node_s
+ */
+void util_list_move_node(util_list_node_s * list, util_list_node_s * head_ptr);
+
+/**
+ * @brief      get list node count
+ * @param[in] head_ptr                 util_list_node_s
+ */
+int util_list_node_count(const util_list_node_s * head_ptr);
+
+/**
+ * @brief      initialize list
+ * @param[in] node_ptr                 util_list_node_s
+ */
+void util_list_init(util_list_node_s * node_ptr);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_LIST_H_ */
diff --git a/src/framework/utility/fw_log.c b/src/framework/utility/fw_log.c
new file mode 100755 (executable)
index 0000000..eedea7c
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <glib.h>
+#include "utility/fw_log.h"
+#include "utility/sync_util.h"
+
+#define UTIL_LOG_FORMAT_MAX_SIZE               1024
+#define UTIL_BASE_NAME(file_path)              (strrchr((file_path), '/') ? strrchr(file_path, '/') + 1 : (file_path))
+
+#define SLP_PLATFORM
+
+#ifdef SLP_PLATFORM
+#include <dlog.h>
+#endif                         /* SLP_PLATFORM */
+
+#ifdef LINUX_PLATFORM
+#endif                         /* LINUX_PLATFORM */
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_LOG"
+#endif
+
+static const char *default_terminal_option = "\033[0m";
+
+void util_log(int prio, const char *log_tag, const char *terminal_option, const char *file_path, const char *func_name, const unsigned int line, const char *format, ...)
+{
+       _EXTERN_FUNC_ENTER;
+
+       va_list ap;
+       va_start(ap, format);
+
+       /* get new log format */
+       /* new log format to be saved here */
+       char new_log_format[UTIL_LOG_FORMAT_MAX_SIZE];
+       int new_log_format_len = 0;
+       if (terminal_option == NULL) {
+               new_log_format_len = snprintf(new_log_format, UTIL_LOG_FORMAT_MAX_SIZE, "[File = %.60s, Func = %.60s, Line = %u] %s", UTIL_BASE_NAME(file_path), func_name, line, format);
+       } else {
+               new_log_format_len = snprintf(new_log_format, UTIL_LOG_FORMAT_MAX_SIZE, "[File = %.60s, Func = %.60s, Line = %u] %s%s%s", UTIL_BASE_NAME(file_path), func_name, line, terminal_option, format, default_terminal_option);
+       }
+
+       if (new_log_format_len <= UTIL_LOG_FORMAT_MAX_SIZE) {
+               /* get right new log format case */
+#ifdef SLP_PLATFORM
+               switch (prio) {
+               case SYNC_AGENT_UTIL_FW_LOG_UNKNOWN:
+               case SYNC_AGENT_UTIL_FW_LOG_DEFAULT:
+               case SYNC_AGENT_UTIL_FW_LOG_VERBOSE:
+                       LOG_VA(LOG_VERBOSE, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_DEBUG:
+                       LOG_VA(LOG_DEBUG, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_INFO:
+                       LOG_VA(LOG_INFO, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_WARN:
+                       LOG_VA(LOG_WARN, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_ERROR:
+                       LOG_VA(LOG_ERROR, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_FATAL:
+                       LOG_VA(LOG_FATAL, log_tag, new_log_format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_SILENT:
+                       LOG_VA(LOG_SILENT, log_tag, new_log_format, ap);
+                       break;
+               default:
+                       assert(false);
+               }
+#endif                         /* SLP_PLATFORM */
+
+#ifdef LINUX_PLATFORM
+               /* TODO */
+               vfprintf(stderr, new_log_format, ap);
+#endif                         /* LINUX_PLATFORM */
+
+       } else {
+               /* may be new log format is greater than SYNC_AGENT_UTIL_FW_LOG_FORMAT_MAX_SIZE case */
+#ifdef SLP_PLATFORM
+               switch (prio) {
+               case SYNC_AGENT_UTIL_FW_LOG_UNKNOWN:
+               case SYNC_AGENT_UTIL_FW_LOG_DEFAULT:
+               case SYNC_AGENT_UTIL_FW_LOG_VERBOSE:
+                       LOG_VA(LOG_VERBOSE, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_DEBUG:
+                       LOG_VA(LOG_DEBUG, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_INFO:
+                       LOG_VA(LOG_INFO, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_WARN:
+                       LOG_VA(LOG_WARN, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_ERROR:
+                       LOG_VA(LOG_ERROR, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_FATAL:
+                       LOG_VA(LOG_FATAL, log_tag, format, ap);
+                       break;
+               case SYNC_AGENT_UTIL_FW_LOG_SILENT:
+                       LOG_VA(LOG_SILENT, log_tag, format, ap);
+                       break;
+               default:
+                       assert(false);
+               }
+#endif                         /* SLP_PLATFORM */
+
+#ifdef LINUX_PLATFORM
+               /* TODO */
+               vfprintf(stderr, format, ap);
+#endif                         /* LINUX_PLATFORM */
+       }
+
+       va_end(ap);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/utility/fw_log.h b/src/framework/utility/fw_log.h
new file mode 100755 (executable)
index 0000000..c848fce
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_LOG_H_
+#define FW_LOG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file fw_log.h
+ * @brief Provides various of DLOG wrappers
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * Enumeration of log priority level
+ */
+       typedef enum utility_log_priority {
+               SYNC_AGENT_UTIL_FW_LOG_UNKNOWN = 0,
+                                               /**< Unknown level */
+               SYNC_AGENT_UTIL_FW_LOG_DEFAULT,
+                                       /**< Default level */
+               SYNC_AGENT_UTIL_FW_LOG_VERBOSE,
+                                       /**< Verbose level */
+               SYNC_AGENT_UTIL_FW_LOG_DEBUG,   /**< Debug level */
+               SYNC_AGENT_UTIL_FW_LOG_INFO,    /**< Info level */
+               SYNC_AGENT_UTIL_FW_LOG_WARN,    /**< Warn level */
+               SYNC_AGENT_UTIL_FW_LOG_ERROR,   /**< Error level */
+               SYNC_AGENT_UTIL_FW_LOG_FATAL,   /**< Fatal level */
+               SYNC_AGENT_UTIL_FW_LOG_SILENT   /**< Silent level */
+       } sync_agent_util_log_priority_e;
+
+/**
+ * Terminal option for character coloring
+ */
+#define SYNC_AGENT_UTIL_TM_OPT_RED_WORD                "\033[31m"                              /**< Red word */
+#define SYNC_AGENT_UTIL_TM_OPT_GREEN_WORD      "\033[32m"                              /**< Green word */
+#define SYNC_AGENT_UTIL_TM_OPT_YELLOW_WORD     "\033[33m"                              /**< Yellow word */
+#define SYNC_AGENT_UTIL_TM_OPT_BLUE_WORD               "\033[34m"                      /**< Blue word */
+#define SYNC_AGENT_UTIL_TM_OPT_PURPLE_WORD     "\033[35m"                              /**< Purple word */
+#define SYNC_AGENT_UTIL_TM_OPT_WHITE_WORD              "\033[37m"                      /**< White word */
+
+/**
+ * Terminal option for background coloring
+ */
+#define SYNC_AGENT_UTIL_TM_OPT_RED_BACKGROUND          "\033[41m"              /**< Red background */
+#define SYNC_AGENT_UTIL_TM_OPT_GREEN_BACKGROUND        "\033[42m"                      /**< Green background */
+#define SYNC_AGENT_UTIL_TM_OPT_YELLOW_BACKGROUND       "\033[43m"              /**< Yellow background */
+#define SYNC_AGENT_UTIL_TM_OPT_BLUE_BACKGROUND         "\033[44m"              /**< Blue background */
+#define SYNC_AGENT_UTIL_TM_OPT_PURPLE_BACKGROUND       "\033[45m"              /**< Purple background */
+#define SYNC_AGENT_UTIL_TM_OPT_WHITE_BACKGROUND                "\033[47m"              /**< White background */
+
+/* common interface */
+#ifndef NDEBUG
+
+/**
+ * Macro with pre-defined priority level
+ */
+#define UTILITY_LOGV(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)               /**< Verbose */
+#define UTILITY_LOGD(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_DEBUG, LOG_TAG, __VA_ARGS__)                 /**< Debug */
+#define UTILITY_LOGI(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_INFO, LOG_TAG, __VA_ARGS__)                  /**< Info */
+
+#else
+
+/**
+ * Macro with pre-defined priority level
+ */
+#define UTILITY_LOGV(...)
+#define UTILITY_LOGD(...)
+#define UTILITY_LOGI(...)
+
+#endif                         /* NDEBUG */
+
+/**
+ * Macro with pre-defined priority level
+ */
+#define UTILITY_LOGW(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_WARN, LOG_TAG, __VA_ARGS__)          /**< Warn */
+#define UTILITY_LOGE(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_ERROR, LOG_TAG, __VA_ARGS__)         /**< Error */
+#define UTILITY_LOGF(...)                                                                      UTILITY_LOG(SYNC_AGENT_UTIL_FW_LOG_FATAL, LOG_TAG, __VA_ARGS__)         /**< Fatal */
+
+/**
+ * Macro with pre-defined priority level and terminal option
+ */
+#ifndef NDEBUG
+#define UTILITY_LOGV_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_VERBOSE, LOG_TAG, TM_OPT, __VA_ARGS__)  /**< Verbose with terminal option */
+#else
+#define UTILITY_LOGV_WITH_TERMINAL_OPTION(TM_OPT, ...)
+#endif
+#define UTILITY_LOGD_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_DEBUG, LOG_TAG, TM_OPT, __VA_ARGS__)    /**< Debug with terminal option */
+#define UTILITY_LOGI_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_INFO, LOG_TAG, TM_OPT, __VA_ARGS__)             /**< Info with terminal option */
+#define UTILITY_LOGW_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_WARN, LOG_TAG, TM_OPT, __VA_ARGS__)             /**< Warn with terminal option */
+#define UTILITY_LOGE_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_ERROR, LOG_TAG, TM_OPT, __VA_ARGS__)    /**< Error with terminal option */
+#define UTILITY_LOGF_WITH_TERMINAL_OPTION(TM_OPT, ...)                 UTILITY_LOG_WITH_TERMINAL_OPTION(SYNC_AGENT_UTIL_FW_LOG_FATAL, LOG_TAG, TM_OPT, __VA_ARGS__)    /**< Fatal with terminal option */
+
+/**
+ * Macro with no concern about file/funn name and line number
+ */
+#define UTILITY_LOG(LOG_PRIORITY, TAG, FORMAT...) \
+               util_log(LOG_PRIORITY, TAG, 0, __FILE__, __func__, __LINE__, FORMAT)                            /**< log */
+#define UTILITY_LOG_WITH_TERMINAL_OPTION(LOG_PRIORITY, TAG, TM_OPT, FORMAT...) \
+               util_log(LOG_PRIORITY, TAG, TM_OPT, __FILE__, __func__, __LINE__, FORMAT)                       /**< log with terminal option */
+
+/* internal function */
+
+/**
+ * API to decreases reference count of parameter spec
+ * @param[in] prio Priority in sync_agent_util_log_priority_e type
+ * @param[in] log_tag Log tag to be displayed under
+ * @param[in] terminal_option Terminal option such as character color or background color
+ * @param[in] file_path Source file path
+ * @param[in] func_name Func name
+ * @param[in] line Line number
+ * @param[in] format Printf format
+ * @param[in] ... VA_LIST
+ */
+       void util_log(int prio, const char *log_tag, const char *terminal_option, const char *file_path, const char *func_name, const unsigned int line, const char *format, ...);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_LOG_H_ */
diff --git a/src/framework/utility/fw_mainloop.c b/src/framework/utility/fw_mainloop.c
new file mode 100755 (executable)
index 0000000..4072888
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <pthread.h>
+
+#include "utility/fw_mainloop.h"
+#include "utility/fw_mainloop_internal.h"
+#include "utility/sync_util.h"
+
+#define UTIL_MAX_CALLBACK      10
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "AF_UTIL_FW_MAINLOOP"
+#endif
+
+static pthread_t main_loop_thread_id;
+static int callback_count = 0;
+
+static pthread_mutex_t loop_mutex;
+static pthread_cond_t loop_cond;
+static GMainLoop *loop = NULL;
+static util_callback_rutine_cb callback_list[UTIL_MAX_CALLBACK] = { 0 };
+static void *callback_data_list[UTIL_MAX_CALLBACK] = { 0 };
+
+static void *_main_loop_rutine(void *data);
+
+/*
+ * non thread safe function !!
+ */
+void util_register_callback_to_main_loop(util_callback_rutine_cb callback, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_list[callback_count] = callback;
+       callback_data_list[callback_count] = data;
+
+       callback_count++;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_run_main_loop(int use_thread)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int is_running = util_is_running_main_loop();
+       /*
+        * when main loop is not running !!
+        */
+       if (is_running != 1) {
+               if (use_thread) {
+                       pthread_mutex_init(&loop_mutex, NULL);  /* TODO : error handling if return value is not 0, fail logic */
+
+                       pthread_cond_init(&loop_cond, NULL);    /* TODO : error handling  if return value is not 0, fail logic */
+
+                       pthread_mutex_lock(&loop_mutex);
+                       pthread_create(&main_loop_thread_id, 0, _main_loop_rutine, 0);
+                       do {
+                               pthread_cond_wait(&loop_cond, &loop_mutex);
+                       } while (loop == NULL);
+
+                       pthread_mutex_unlock(&loop_mutex);
+               } else {
+                       int i;
+                       for (i = 0; i < callback_count; i++) {
+                               if (callback_list[i] != 0) {
+                                       callback_list[i] (callback_data_list[i]);
+                               }
+                       }
+
+                       pthread_mutex_lock(&loop_mutex);
+                       loop = g_main_loop_new(NULL, FALSE);
+                       pthread_mutex_unlock(&loop_mutex);
+
+                       g_main_loop_run(loop);
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_stop_main_loop(int use_thread)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int is_running = util_is_running_main_loop();
+
+       if (is_running) {
+               if (use_thread) {
+                       pthread_mutex_destroy(&loop_mutex);     /* TODO : error handling if return value is not 0, fail logic */
+
+                       pthread_cond_destroy(&loop_cond);       /* TODO : error handling if return value is not 0, fail logic */
+                       g_main_loop_quit(loop);
+                       g_main_loop_unref(loop);
+                       pthread_cancel(main_loop_thread_id);
+               } else {
+                       g_main_loop_quit(loop);
+                       g_main_loop_unref(loop);
+               }
+       }
+
+       pthread_mutex_lock(&loop_mutex);
+       loop = NULL;
+       pthread_mutex_unlock(&loop_mutex);
+
+       //loop = NULL;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void *sync_agent_get_main_loop()
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (loop != NULL) {
+               _EXTERN_FUNC_EXIT;
+               return (void *)loop;
+       } else {
+               _DEBUG_ERROR("fw mainloop is NULL !!");
+               return NULL;
+       }
+}
+
+int util_is_running_main_loop(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       gboolean result = 0;
+       if (loop == NULL) {
+               return result;
+       }
+       result = g_main_loop_is_running(loop);
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
+
+static void *_main_loop_rutine(void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int i;
+       for (i = 0; i < callback_count; i++) {
+               if (callback_list[i] != 0) {
+                       callback_list[i] (callback_data_list[i]);
+               }
+       }
+
+       pthread_mutex_lock(&loop_mutex);
+
+       loop = g_main_loop_new(NULL, FALSE);
+
+       pthread_cond_signal(&loop_cond);
+       pthread_mutex_unlock(&loop_mutex);
+
+       g_main_loop_run(loop);
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
diff --git a/src/framework/utility/fw_mainloop_internal.h b/src/framework/utility/fw_mainloop_internal.h
new file mode 100755 (executable)
index 0000000..0bfdda9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_MAINLOOP_INTERNAL_H_
+#define FW_MAINLOOP_INTERNAL_H_
+
+/**
+ * @file fw_mainloop_internal.h
+ * @brief Provides main-loop manipulation functionality
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * Function which is registerd to main loop
+ */
+typedef void (*util_callback_rutine_cb) (void *data);
+
+/**
+ * @brief      register callback to main loop
+ * @param[in] callback                 util_callback_rutine_cb
+ * @param[in] data                                             uesr data
+ */
+void util_register_callback_to_main_loop(util_callback_rutine_cb callback, void *data);
+
+/**
+ * @brief      run main loop
+ */
+int util_is_running_main_loop(void);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_MAINLOOP_INTERNAL_H_ */
diff --git a/src/framework/utility/fw_ref.c b/src/framework/utility/fw_ref.c
new file mode 100755 (executable)
index 0000000..e4ee267
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "utility/fw_ref.h"
+#include <stdlib.h>
+#include <glib.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_REF"
+#endif
+
+EXPORT_API sync_agent_util_ref_object_s *sync_agent_create_referenced_object(void *data, sync_agent_free_cb data_free_func)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(data == NULL, NULL, "data parameter is NULL !!!");
+//      retvm_if(data_free_func == NULL, NULL, "data_free_func parameter is 0 !!!");
+
+       sync_agent_util_ref_object_s *ref = (sync_agent_util_ref_object_s *) malloc(sizeof(sync_agent_util_ref_object_s));
+       if (ref == NULL) {
+               goto error_part;
+       }
+
+       ref->refcount = 1;
+       ref->data = data;
+       ref->free_func = data_free_func;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ref;
+
+ error_part:
+       return NULL;
+}
+
+EXPORT_API sync_agent_util_ref_object_s *sync_agent_get_referenced_object(sync_agent_util_ref_object_s * object)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(object == NULL, NULL, "object parameter is NULL !!!");
+
+       g_atomic_int_inc(&(object->refcount));
+
+       _EXTERN_FUNC_EXIT;
+
+       return object;
+}
+
+EXPORT_API void *sync_agent_get_original_object(sync_agent_util_ref_object_s * object)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(object == NULL, NULL, "object parameter is NULL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return object->data;
+}
+
+EXPORT_API bool sync_agent_compare_object(sync_agent_util_ref_object_s * object1, sync_agent_util_ref_object_s * object2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(object1 == NULL, false, "object1 parameter is NULL !!!");
+       retvm_if(object2 == NULL, false, "object2 parameter is NULL !!!");
+
+       if ((object1->data) == (object2->data)) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       } else {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+}
+
+EXPORT_API void sync_agent_unref_referenced_object(sync_agent_util_ref_object_s * ref)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(ref == NULL, "ref parameter is NULL !!!");
+
+       if (g_atomic_int_dec_and_test(&(ref->refcount))) {
+               if (ref->free_func != NULL)
+                       ref->free_func(ref->data);
+
+               free(ref);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/utility/fw_sequential_id_provider.c b/src/framework/utility/fw_sequential_id_provider.c
new file mode 100755 (executable)
index 0000000..86753e5
--- /dev/null
@@ -0,0 +1,1375 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "utility/fw_list.h"
+#include "utility/sync_util.h"
+#include "utility/fw_sequential_id_provider_internal.h"
+#include "data-adapter/agent_handler_manager.h"
+#include "data-adapter/agent_handler_manager_internal.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "FW_UTIL_ID"
+#endif
+
+unsigned int _calculate_free_bit_cnt(char *bits, unsigned int bit_cnt);
+inline bool _is_bit_on(unsigned int offset, char *bits);
+inline bool _is_bit_off(unsigned int offset, char *bits);
+inline void _set_bit_on(unsigned int offset, char *bits);
+inline void _set_bit_off(unsigned int offset, char *bits);
+
+/* internal interfaces */
+unsigned int _calculate_free_bit_cnt(char *bits, unsigned int bit_cnt)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int cnt = 0;
+
+       unsigned int i = 0;
+       for (i = 0; i < bit_cnt; i++) {
+               if (_is_bit_off(i, bits)) {
+                       cnt++;
+               }
+       }
+
+       _DEBUG_TRACE("end with free_bit_cnt = %u", cnt);
+
+       _INNER_FUNC_EXIT;
+
+       return cnt;
+}
+
+inline bool _is_bit_on(unsigned int offset, char *bits)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int q = offset / 8;
+       unsigned int r = offset % 8;
+       char mask = 1 << (7 - r);
+
+       _INNER_FUNC_EXIT;
+
+       return (bits[q] & mask);
+}
+
+inline bool _is_bit_off(unsigned int offset, char *bits)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return !_is_bit_on(offset, bits);
+}
+
+inline void _set_bit_on(unsigned int offset, char *bits)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int q = offset / 8;
+       unsigned int r = offset % 8;
+       char mask = 1 << (7 - r);
+       bits[q] |= mask;
+
+       _INNER_FUNC_EXIT;
+}
+
+inline void _set_bit_off(unsigned int offset, char *bits)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int q = offset / 8;
+       unsigned int r = offset % 8;
+       char mask = 1 << (7 - r);
+       bits[q] &= (~mask);
+
+       _INNER_FUNC_EXIT;
+}
+
+util_id_page_s *util_id_page_alloc(util_id_page_flag flag, unsigned int page_index, unsigned int free_bit_cnt, unsigned int page_bit_cnt, char *bits)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_page_s *id_page = (util_id_page_s *) malloc(sizeof(util_id_page_s));
+       if (id_page == NULL) {
+               goto return_part;
+       }
+
+       id_page->link.next = 0;
+       id_page->link.prev = 0;
+       id_page->flag = flag;
+       id_page->page_index = page_index;
+       id_page->free_bit_cnt = free_bit_cnt;
+       id_page->page_bit_cnt = page_bit_cnt;
+       id_page->bits = bits;
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return id_page;
+}
+
+util_id_page_s *util_id_page_alloc_new_page(unsigned int page_index, unsigned int page_bit_cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int size = UTIL_DIVIDE_INT_ROUND_UP(page_bit_cnt, 8);
+       char *bits = (char *)calloc(size, sizeof(char));
+
+       if (bits == NULL) {
+               return NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_alloc(UTIL_ID_PAGE_FLAG_UNKNOWN, page_index, page_bit_cnt, page_bit_cnt, bits);
+}
+
+util_id_page_s *util_id_page_load(unsigned int code, unsigned int page_index, unsigned int page_bit_cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_page_s *id_page = NULL;
+
+       /* get bits from db */
+       char *page_bit = NULL;
+       sync_agent_da_return_e ret = da_get_id_page_wrapper(code, page_index, &page_bit);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("Failed sync_agent_get_id_page()\n");
+               assert(false);
+       } else {
+               _DEBUG_INFO("Success sync_agent_get_id_page()\n");
+       }
+
+       if (page_bit != NULL) {
+               /* calculate free bit count */
+               unsigned int free_bit_cnt = _calculate_free_bit_cnt(page_bit, page_bit_cnt);
+
+               /* create page with bits from db */
+               id_page = util_id_page_alloc(UTIL_ID_PAGE_FLAG_UNKNOWN, page_index, free_bit_cnt, page_bit_cnt, page_bit);
+               _DEBUG_INFO("(page_index = %u, free_bit_cnt = %u, page_bit_cnt = %u", page_index, free_bit_cnt, page_bit_cnt);
+
+               assert(id_page != NULL);        /* TODO : remove this part by change interface */
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_page;
+}
+
+void util_id_page_free(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_page != NULL) {
+               if (id_page->bits != NULL) {
+                       free(id_page->bits);
+               }
+               free(id_page);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline bool util_id_page_is_empty(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_page->free_bit_cnt == id_page->page_bit_cnt) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+inline void util_id_page_set_flag(util_id_page_s * id_page, util_id_page_flag flag)
+{
+       _EXTERN_FUNC_ENTER;
+
+       id_page->flag = flag;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline util_id_page_flag util_id_page_get_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_page->flag;
+}
+
+inline bool util_id_page_has_same_flag(util_id_page_s * id_page, util_id_page_flag flag)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (util_id_page_get_flag(id_page) == flag) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+inline bool util_id_page_is_unknown_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_has_same_flag(id_page, UTIL_ID_PAGE_FLAG_UNKNOWN);
+}
+
+inline bool util_id_page_is_add_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_has_same_flag(id_page, UTIL_ID_PAGE_FLAG_ADD);
+}
+
+inline bool util_id_page_is_delete_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_has_same_flag(id_page, UTIL_ID_PAGE_FLAG_DELETE);
+}
+
+inline bool util_id_page_is_update_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_has_same_flag(id_page, UTIL_ID_PAGE_FLAG_UPDATE);
+}
+
+inline bool util_id_page_is_unchanged_flag(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_page_has_same_flag(id_page, UTIL_ID_PAGE_FLAG_UNCHANGED);
+}
+
+inline unsigned int util_id_page_get_page_index(util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_page->page_index;
+}
+
+inline void util_id_page_set_page_index(util_id_page_s * id_page, unsigned int index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       id_page->page_index = index;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline bool util_id_page_is_bit_on(util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_bit_on(offset, id_page->bits);
+}
+
+inline bool util_id_page_is_bit_off(util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return _is_bit_off(offset, id_page->bits);
+}
+
+inline bool util_id_page_set_bit_on(util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = false;
+       if (util_id_page_is_bit_off(id_page, offset)) {
+               success = true;
+               _set_bit_on(offset, id_page->bits);
+               (id_page->free_bit_cnt)--;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+inline bool util_id_page_set_bit_off(util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool success = false;
+       if (util_id_page_is_bit_on(id_page, offset)) {
+               success = true;
+               _set_bit_off(offset, id_page->bits);
+               (id_page->free_bit_cnt)++;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return success;
+}
+
+bool util_id_page_find_next_free_offset(util_id_page_s * id_page, unsigned int search_start_offset, unsigned int *next_free_offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool found = false;
+
+       unsigned int i = 0;
+       unsigned int end_offset = id_page->page_bit_cnt;
+       for (i = search_start_offset; i < end_offset; i++) {
+               if (util_id_page_is_bit_off(id_page, i)) {
+                       found = true;
+                       *next_free_offset = i;
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return found;
+}
+
+util_id_provider_change_tracking_s *util_id_provider_change_tracking_alloc(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_change_tracking_s *pTracking = (util_id_provider_change_tracking_s *) malloc(sizeof(util_id_provider_change_tracking_s));
+
+       if (pTracking == NULL) {
+               goto error_part;
+       }
+
+       util_list_init(&(pTracking->id_page_add_list_head));
+       util_list_init(&(pTracking->id_page_update_list_head));
+       util_list_init(&(pTracking->id_page_delete_list_head));
+       util_list_init(&(pTracking->id_page_unchanged_list_head));
+
+       _EXTERN_FUNC_EXIT;
+
+       return pTracking;
+
+ error_part:
+       return NULL;
+}
+
+void util_id_provider_change_tracking_free(util_id_provider_change_tracking_s * tracking)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (tracking != NULL) {
+               /* Do not free pages linked with list. */
+               free(tracking);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline util_list_node_s *util_id_provider_change_tracking_get_list(util_id_provider_change_tracking_s * tracking, util_id_page_flag flag)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_list_node_s *pHead = NULL;
+
+       switch (flag) {
+       case UTIL_ID_PAGE_FLAG_UNCHANGED:
+               pHead = &(tracking->id_page_unchanged_list_head);
+               break;
+       case UTIL_ID_PAGE_FLAG_ADD:
+               pHead = &(tracking->id_page_add_list_head);
+               break;
+       case UTIL_ID_PAGE_FLAG_DELETE:
+               pHead = &(tracking->id_page_delete_list_head);
+               break;
+       case UTIL_ID_PAGE_FLAG_UPDATE:
+               pHead = &(tracking->id_page_update_list_head);
+               break;
+       default:
+               pHead = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pHead;
+}
+
+util_id_provider_s *util_id_provider_create_internal(bool persistent_mode, unsigned int code, unsigned int total_free_bit_cnt, unsigned int id_max, unsigned int log2_page_size, bool support_thread_safety)
+{
+       _EXTERN_FUNC_ENTER;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+#endif
+
+       util_id_provider_s *pProvider = (util_id_provider_s *) calloc(1, sizeof(util_id_provider_s));
+       if (pProvider == NULL) {
+               goto error_part;
+       }
+
+       /* TODO : validation of input */
+       pProvider->persistent_mode = persistent_mode;
+       pProvider->code = code;
+
+       pProvider->tracking = false;
+
+       pProvider->support_thread_safety = support_thread_safety;
+
+       if (support_thread_safety) {
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+               pProvider->mutex = g_mutex_new();
+               if (pProvider->mutex == NULL) {
+                       goto error_part;
+               }
+#else
+               g_mutex_init(&(pProvider->mutex));
+//              if (&(pProvider->mutex) == NULL) {
+//                      goto error_part;
+//              }
+#endif
+       }
+
+       pProvider->id_max = id_max;
+
+       pProvider->log2_page_size = log2_page_size;
+       pProvider->page_size = (1 << log2_page_size);
+       pProvider->bits_per_page = UTIL_BITS_PER_PAGE(pProvider->page_size);
+
+       pProvider->total_free_cnt = total_free_bit_cnt;
+       pProvider->last_id = id_max;    /* To provide 0 for first id */
+
+       pProvider->id_page_cnt = UTIL_ID_PAGE_CNT(id_max, pProvider->bits_per_page);
+       pProvider->id_page_array = (util_id_page_s **) calloc(pProvider->id_page_cnt, sizeof(util_id_page_s *));
+       if (pProvider->id_page_array == NULL) {
+               goto error_part;
+       }
+
+       pProvider->pTracking = util_id_provider_change_tracking_alloc();
+       if (pProvider->pTracking == NULL) {
+               goto error_part;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return pProvider;
+
+ error_part:
+       util_destroy_id_provider(pProvider);
+       return NULL;
+}
+
+inline void util_id_provider_init_routine(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       if (!g_thread_supported()) {
+               g_thread_init(NULL);
+       }
+#endif
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline void util_id_provider_lock(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_provider->support_thread_safety) {
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+               g_mutex_lock(id_provider->mutex);
+#else
+               g_mutex_lock(&(id_provider->mutex));
+#endif
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline void util_id_provider_unlock(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_provider->support_thread_safety) {
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+               g_mutex_unlock(id_provider->mutex);
+#else
+               g_mutex_unlock(&(id_provider->mutex));
+#endif
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+inline bool util_id_provider_is_valid_id_range(util_id_provider_s * id_provider, unsigned int id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id > id_provider->id_max) {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+       _EXTERN_FUNC_EXIT;
+       return true;
+}
+
+inline bool util_id_provider_is_valid_page_index(util_id_provider_s * id_provider, unsigned int id_page_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_page_index >= id_provider->id_page_cnt) {
+               _EXTERN_FUNC_EXIT;
+               return false;
+       }
+       _EXTERN_FUNC_EXIT;
+       return true;
+}
+
+inline bool util_id_provider_is_last_page_index(util_id_provider_s * id_provider, unsigned int id_page_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_page_index == id_provider->id_page_cnt - 1) {
+               _EXTERN_FUNC_EXIT;
+               return true;
+       }
+       _EXTERN_FUNC_EXIT;
+       return false;
+}
+
+inline unsigned int util_id_provider_calculate_offset_in_page(unsigned int id, unsigned int bits_per_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (id & UTIL_BITS_PER_PAGE_MASK(bits_per_page));
+}
+
+inline unsigned int util_id_provider_calculate_id(util_id_provider_s * provider, unsigned int id_page_index, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_page_index * provider->bits_per_page + offset;
+}
+
+inline unsigned int util_id_provider_calculate_id_page_array_index(util_id_provider_s * id_provider, unsigned int id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return id / id_provider->bits_per_page;
+}
+
+inline util_id_provider_error_e util_id_provider_calculate_page_cnt_for_id_page(util_id_provider_s * id_provider, unsigned int id_page_index, unsigned int *page_cnt)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       unsigned int out_page_cnt = 0;
+
+       if (!util_id_provider_is_valid_page_index(id_provider, id_page_index)) {
+               error = UTIL_ID_PROVIDER_NOT_EXIST_PAGE;
+               goto return_part;
+       }
+
+       if (util_id_provider_is_last_page_index(id_provider, id_page_index)) {
+               out_page_cnt = (id_provider->id_max + 1) - ((id_provider->id_page_cnt - 1) * (id_provider->bits_per_page));
+       } else {
+               out_page_cnt = id_provider->bits_per_page;
+       }
+
+ return_part:
+       if (error == UTIL_ID_PROVIDER_OK) {
+               *page_cnt = out_page_cnt;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return error;
+}
+
+inline util_id_provider_error_e util_id_provider_fetch_id_page_by_index(util_id_provider_s * id_provider, unsigned int index, util_id_page_s ** id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start with index = %u", index);
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       util_id_page_s *temp_id_page = NULL;
+
+       if (!util_id_provider_is_valid_page_index(id_provider, index)) {
+               error = UTIL_ID_PROVIDER_NOT_EXIST_PAGE;
+               goto return_part;
+       }
+
+       temp_id_page = id_provider->id_page_array[index];
+       if (temp_id_page == NULL) {
+               if (id_provider->persistent_mode) {
+                       /* load db page */
+                       util_id_provider_error_e load_error = util_id_provider_load_id_page(id_provider, index, &temp_id_page);
+                       if (load_error == UTIL_ID_PROVIDER_OK) {
+                               goto return_part;
+                       }
+
+                       /* if db page does not exist, then add new page by below lines */
+                       assert(load_error == UTIL_ID_PROVIDER_PERSISTENT_NOT_EXIST_PAGE);
+               }
+
+               /* add new page */
+               temp_id_page = util_id_provider_add_id_page(id_provider, index);
+               if (temp_id_page == NULL) {
+                       error = UTIL_ID_PROVIDER_NOT_ENOUGH_MEMORY;
+                       goto return_part;
+               }
+       }
+
+ return_part:
+       if (error == UTIL_ID_PROVIDER_OK) {
+               *id_page = temp_id_page;
+       }
+
+       _DEBUG_INFO("end with error = %d", error);
+
+       _EXTERN_FUNC_EXIT;
+
+       return error;
+}
+
+inline util_id_provider_error_e util_id_provider_fetch_id_page(util_id_provider_s * id_provider, unsigned int id, util_id_page_s ** id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start with id = %u", id);
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+
+       unsigned int id_page_array_index = 0;
+       util_id_page_s *temp_id_page = NULL;
+
+       if (!util_id_provider_is_valid_id_range(id_provider, id)) {
+               error = UTIL_ID_PROVIDER_OUT_OF_ID_RANGE;
+               goto return_part;
+       }
+
+       id_page_array_index = util_id_provider_calculate_id_page_array_index(id_provider, id);
+       error = util_id_provider_fetch_id_page_by_index(id_provider, id_page_array_index, &temp_id_page);
+
+ return_part:
+       if (error == UTIL_ID_PROVIDER_OK) {
+               *id_page = temp_id_page;
+       }
+
+       _DEBUG_INFO("end with error = %d", error);
+
+       _EXTERN_FUNC_EXIT;
+
+       return error;
+}
+
+inline util_id_provider_error_e util_id_provider_set_id_page_index(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       bool valid_page_index = util_id_provider_is_valid_page_index(id_provider, index);
+
+       if (valid_page_index) {
+               util_id_page_set_page_index(id_page, index);
+               id_provider->id_page_array[index] = id_page;
+       } else {
+               id_error = UTIL_ID_PROVIDER_NOT_EXIST_PAGE;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+void util_id_provider_move_id_page(util_id_provider_s * id_provider, util_id_page_s * id_page, util_id_page_flag next)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_page_flag prev = util_id_page_get_flag(id_page);
+       if (prev == next) {
+               return;
+       }
+
+       util_list_node_s *pNextHead = util_id_provider_change_tracking_get_list(id_provider->pTracking, next);
+
+       /* move from previous list to next list */
+
+       if ((id_page->link.prev == NULL) && (id_page->link.next == NULL)) {
+               util_list_add_node(&(id_page->link), pNextHead);
+       } else {
+               util_list_move_node(&(id_page->link), pNextHead);
+       }
+
+       /* set id_page_flag */
+       util_id_page_set_flag(id_page, next);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_id_provider_remove_id_page(util_id_provider_s * id_provider, util_id_page_s * id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       unsigned int id_page_index = 0;
+
+       /* remove from list */
+       if (!util_id_page_is_unknown_flag(id_page)) {
+               if ((id_page->link.prev == NULL) || (id_page->link.next == NULL)) {
+                       /* DO NOTHING */
+               } else {
+                       util_list_delete_node(&(id_page->link));
+               }
+       }
+
+       /* set id_page_array NULL */
+       id_page_index = util_id_page_get_page_index(id_page);
+       id_provider->id_page_array[id_page_index] = NULL;
+
+       /* free id page */
+       util_id_page_free(id_page);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+util_id_page_s *util_id_provider_add_id_page(util_id_provider_s * id_provider, unsigned int page_index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start with page_index = %u", page_index);
+       util_id_page_s *id_page = NULL;
+       unsigned int page_cnt_for_new_id_page = 0;
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+       error = util_id_provider_calculate_page_cnt_for_id_page(id_provider, page_index, &page_cnt_for_new_id_page);
+       assert(error == UTIL_ID_PROVIDER_OK);
+
+       /* validation */
+       if (id_provider->id_page_array[page_index] != NULL) {
+               goto return_part;
+       }
+
+       /* get page */
+       id_page = util_id_page_alloc_new_page(page_index, page_cnt_for_new_id_page);
+       if (id_page == NULL) {
+               goto return_part;
+       }
+
+       /* set page at array */
+       id_provider->id_page_array[page_index] = id_page;
+
+       /* assign page to add list */
+       util_id_provider_move_id_page(id_provider, id_page, UTIL_ID_PAGE_FLAG_ADD);
+
+ return_part:
+       _DEBUG_INFO("end with pId_page = %x", id_page);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_page;
+}
+
+util_id_provider_error_e util_id_provider_load_id_page(util_id_provider_s * id_provider, unsigned int page_index, util_id_page_s ** id_page)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("start with page_index = %u", page_index);
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       util_id_page_s *temp_id_page = NULL;
+
+       /* get page bit cnt */
+       unsigned int page_bit_cnt = 0;
+       id_error = util_id_provider_calculate_page_cnt_for_id_page(id_provider, page_index, &page_bit_cnt);
+       assert(id_error == UTIL_ID_PROVIDER_OK);
+
+       /* load page */
+       temp_id_page = util_id_page_load(id_provider->code, page_index, page_bit_cnt);
+
+       if (temp_id_page != NULL) {
+               /* set page at array */
+               id_provider->id_page_array[page_index] = temp_id_page;
+
+               /* assign page to unchanged list */
+               util_id_provider_move_id_page(id_provider, temp_id_page, UTIL_ID_PAGE_FLAG_UNCHANGED);
+       } else {
+               id_error = UTIL_ID_PROVIDER_PERSISTENT_NOT_EXIST_PAGE;
+       }
+
+       if (id_error == UTIL_ID_PROVIDER_OK) {
+               *id_page = temp_id_page;
+       }
+
+       _DEBUG_INFO("end with id_error = %d", id_error);
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+bool util_id_provider_set_id_page_bit_on(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool bit_on_success = util_id_page_set_bit_on(id_page, offset);
+
+       if (bit_on_success) {
+               assert(!util_id_page_is_unknown_flag(id_page));
+
+               /* If page is in add or update list, then DO NOTHING */
+
+               /* If page is in unchanged or delete list, then move page to update list */
+               if (util_id_page_is_unchanged_flag(id_page) || util_id_page_is_delete_flag(id_page)) {
+                       util_id_provider_move_id_page(id_provider, id_page, UTIL_ID_PAGE_FLAG_UPDATE);
+               }
+
+               (id_provider->total_free_cnt)--;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return bit_on_success;
+}
+
+bool util_id_provider_set_id_page_bit_off(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int offset)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool bit_off_success = util_id_page_set_bit_off(id_page, offset);
+       bool is_empty_page = false;
+
+       if (bit_off_success) {
+               assert(!util_id_page_is_unknown_flag(id_page));
+               assert(!util_id_page_is_delete_flag(id_page));
+
+               is_empty_page = util_id_page_is_empty(id_page);
+               if (is_empty_page) {
+                       /* If page is in update or unchanged list, then move to delete list */
+                       if (util_id_page_is_update_flag(id_page) || util_id_page_is_unchanged_flag(id_page)) {
+                               util_id_provider_move_id_page(id_provider, id_page, UTIL_ID_PAGE_FLAG_DELETE);
+                       }
+
+                       /* If page is in add list, then remove in list & free page */
+                       if (util_id_page_is_add_flag(id_page)) {
+                               util_id_provider_remove_id_page(id_provider, id_page);
+                       }
+               } else {
+                       /* If page is in unchaged list, then move to update list */
+                       if (util_id_page_is_unchanged_flag(id_page)) {
+                               util_id_provider_move_id_page(id_provider, id_page, UTIL_ID_PAGE_FLAG_UPDATE);
+                       }
+               }
+
+               (id_provider->total_free_cnt)++;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return bit_off_success;
+}
+
+void util_id_provider_reset_tracking_info(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_change_tracking_s *pTracking = id_provider->pTracking;
+       util_id_page_s *page = NULL;
+       util_list_node_s *iter = NULL;
+       util_list_node_s *add_page_list = &(pTracking->id_page_add_list_head);
+       util_list_node_s *update_page_list = &(pTracking->id_page_update_list_head);
+       util_list_node_s *delete_page_list = &(pTracking->id_page_delete_list_head);
+
+       /* add list handling : move to unchaged list */
+       for (iter = add_page_list; iter != add_page_list;) {
+               page = (util_id_page_s *) iter;
+               iter = iter->next;
+               util_id_provider_move_id_page(id_provider, page, UTIL_ID_PAGE_FLAG_UNCHANGED);
+       }
+
+       /* update list handling : move to unchaged list */
+       for (iter = update_page_list; iter != update_page_list;) {
+               page = (util_id_page_s *) iter;
+               iter = iter->next;
+               util_id_provider_move_id_page(id_provider, page, UTIL_ID_PAGE_FLAG_UNCHANGED);
+       }
+
+       /* delete list handling : remove id page */
+       for (iter = delete_page_list; iter != delete_page_list;) {
+               page = (util_id_page_s *) iter;
+               iter = iter->next;
+               util_id_provider_remove_id_page(id_provider, page);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+void util_id_provider_destroy_id_page_array(unsigned int id_page_cnt, util_id_page_s ** id_page_array)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (id_page_array != NULL) {
+               unsigned int i = 0;
+               util_id_page_s *id_page = NULL;
+
+               for (i = 0; i < id_page_cnt; i++) {
+                       id_page = id_page_array[i];
+                       if (id_page != NULL) {
+                               util_id_page_free(id_page);
+                       }
+               }
+               free(id_page_array);
+               id_page_array = NULL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/* external interfaces */
+util_id_provider_error_e util_create_id_persistent_provider(unsigned int code, unsigned int id_max, unsigned int log2_page_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+
+       sync_agent_da_id_provider_s id_provider;
+       id_provider.id_provider_code = code;
+       id_provider.id_capacity = id_max;
+       id_provider.bit_per_page = UTIL_BITS_PER_PAGE(1 << log2_page_size);
+       id_provider.last_id = id_max;
+       id_provider.free_bit_cnt = id_max + 1;
+
+       sync_agent_da_return_e ret = da_add_id_provider_wrapper(&id_provider);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("Failed sync_agent_add_id_provider()\n");
+               id_error = UTIL_ID_PROVIDER_PERSISTENT_CREATE_ERROR;
+       } else {
+               _DEBUG_INFO("Success sync_agent_add_id_provider()\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+util_id_provider_s *util_load_id_persistent_provider(unsigned int code, bool support_thread_safety)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_s *provider = NULL;
+       sync_agent_da_id_provider_s *got_id_provider = NULL;
+
+       /* get information from id provider DB */
+       sync_agent_da_return_e ret = da_get_id_provider_wrapper(code, &got_id_provider);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("Failed sync_agent_get_id_provider()\n");
+               /* TODO : error handling */
+
+               goto return_part;
+       } else {
+               _DEBUG_INFO("Success sync_agent_get_id_provider()\n");
+       }
+
+       _DEBUG_INFO("id_capacity : %d\n", got_id_provider->id_capacity);
+       _DEBUG_INFO("bit_per_page : %d\n", got_id_provider->bit_per_page);
+       _DEBUG_INFO("last_id : %d\n", got_id_provider->last_id);
+       _DEBUG_INFO("free_bit_cnt : %d\n", got_id_provider->free_bit_cnt);
+
+       unsigned int log2_page_size = (unsigned int)log2((got_id_provider->bit_per_page) / 8);
+
+       provider = util_id_provider_create_internal(true, code, got_id_provider->free_bit_cnt, got_id_provider->id_capacity, log2_page_size, support_thread_safety);
+
+ return_part:
+       if (got_id_provider != NULL) {
+               free(got_id_provider);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return provider;
+}
+
+util_id_provider_error_e util_update_id_persistent_provider(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+
+       /* id_provider_tbl update */
+       sync_agent_da_id_provider_s da_id_provider;
+       da_id_provider.id_provider_code = id_provider->code;
+       da_id_provider.last_id = id_provider->last_id;
+       da_id_provider.free_bit_cnt = id_provider->total_free_cnt;
+
+       sync_agent_da_return_e ret = da_update_id_provider_wrapper(&da_id_provider);
+       if (ret != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_INFO("Failed sync_agent_update_id_provider() = %d", ret);
+               assert(false);
+       } else {
+               _DEBUG_INFO("Success sync_agent_update_id_provider()");
+       }
+
+       /* id_page_tbl update */
+       util_id_provider_change_tracking_s *pTracking = id_provider->pTracking;
+       util_id_page_s *page = NULL;
+       util_list_node_s *iter = NULL;
+       util_list_node_s *add_page_list = &(pTracking->id_page_add_list_head);
+       util_list_node_s *update_page_list = &(pTracking->id_page_update_list_head);
+       util_list_node_s *delete_page_list = &(pTracking->id_page_delete_list_head);
+       unsigned int page_byte_size = 0;
+
+       sync_agent_da_id_page_s id_page;
+       id_page.id_provider_code = id_provider->code;
+
+       /* add list handling */
+/*     for (iter = add_page_list->next; iter != add_page_list; iter = iter->next) { */
+       UTIL_LIST_ITER(iter, add_page_list) {
+               page = (util_id_page_s *) iter;
+               id_page.page_index = page->page_index;
+               id_page.page_bit = page->bits;
+
+               page_byte_size = UTIL_DIVIDE_INT_ROUND_UP(page->page_bit_cnt, 8);
+
+               /* add page to db */
+               ret = da_add_id_page_wrapper(&id_page, page_byte_size);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_INFO("Failed sync_agent_add_id_page() = %d\n", ret);
+                       assert(false);
+               } else {
+                       _DEBUG_INFO("Success sync_agent_add_id_page()\n");
+               }
+       }
+
+       /* update list handling */
+/* for (iter = add_page_list->next; iter != update_page_list; iter = iter->next) { */
+       UTIL_LIST_ITER(iter, update_page_list) {
+               page = (util_id_page_s *) iter;
+               id_page.page_index = page->page_index;
+               id_page.page_bit = page->bits;
+
+               page_byte_size = UTIL_DIVIDE_INT_ROUND_UP(page->page_bit_cnt, 8);
+
+               /* update page to db */
+               ret = da_update_id_page_wrapper(&id_page, page_byte_size);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_INFO("Failed sync_agent_update_id_page() = %d\n", ret);
+                       assert(false);
+               } else {
+                       _DEBUG_INFO("Success sync_agent_update_id_page()\n");
+               }
+       }
+
+       /* delete list handling */
+/*for (iter = add_page_list->next; iter != delete_page_list; iter = iter->next) {      */
+       UTIL_LIST_ITER(iter, delete_page_list) {
+               page = (util_id_page_s *) iter;
+
+               /* delete page in db */
+               ret = da_delete_id_page_wrapper(id_provider->code, page->page_index);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_INFO("Failed sync_agent_delete_id_page() = %d\n", ret);
+                       assert(false);
+               } else {
+                       _DEBUG_INFO("Success sync_agent_delete_id_page()\n");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+util_id_provider_s *util_create_id_provider(unsigned int id_max, unsigned int log2_page_size, bool support_thread_safety)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_init_routine();
+       unsigned int total_free_bit_cnt = id_max + 1;   /* Since 0, 1, ..., id_max */
+
+       _EXTERN_FUNC_EXIT;
+
+       return util_id_provider_create_internal(false, 0, total_free_bit_cnt, id_max, log2_page_size, support_thread_safety);
+}
+
+void util_destroy_id_provider(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_init_routine();
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       if (id_provider != NULL) {
+               if (id_provider->support_thread_safety && id_provider->mutex != NULL) {
+                       g_mutex_free(id_provider->mutex);
+                       id_provider->mutex = NULL;
+               }
+#else
+       if (id_provider != NULL) {
+               if (id_provider->support_thread_safety) {
+                       g_mutex_clear(&(id_provider->mutex));
+               }
+#endif
+               util_id_provider_destroy_id_page_array(id_provider->id_page_cnt, id_provider->id_page_array);
+
+               if (id_provider->pTracking != NULL) {
+                       util_id_provider_change_tracking_free(id_provider->pTracking);
+                       id_provider->pTracking = NULL;
+               }
+               free(id_provider);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+util_id_provider_error_e util_tracking_mode_on(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       util_id_provider_init_routine();
+
+       if (id_provider == NULL) {
+               _DEBUG_INFO("Error. pId_provider == NULL\n");
+               return UTIL_ID_PROVIDER_NOT_EXIST_ID;
+       }
+
+       if (id_provider->support_thread_safety) {
+               util_id_provider_lock(id_provider);
+       }
+
+       if (id_provider->tracking) {
+               id_error = UTIL_ID_PROVIDER_ALREADY_TRACKING_MODE_ON;
+       } else {
+               id_provider->tracking = true;
+       }
+
+       if (id_provider->support_thread_safety) {
+               util_id_provider_unlock(id_provider);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+util_id_provider_error_e util_tracking_mode_off(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_error_e id_error = UTIL_ID_PROVIDER_OK;
+       util_id_provider_init_routine();
+
+       if (id_provider == NULL) {
+               _DEBUG_INFO("Error. pId_provider == NULL\n");
+               return UTIL_ID_PROVIDER_NOT_EXIST_ID;
+       }
+
+       if (id_provider->support_thread_safety) {
+               util_id_provider_lock(id_provider);
+       }
+
+       if (!(id_provider->tracking)) {
+               id_error = UTIL_ID_PROVIDER_ALREADY_TRACKING_MODE_OFF;
+       } else {
+               id_provider->tracking = false;
+               util_id_provider_reset_tracking_info(id_provider);
+       }
+
+       if (id_provider->support_thread_safety) {
+               util_id_provider_unlock(id_provider);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_error;
+}
+
+util_id_provider_error_e util_provide_id(util_id_provider_s * id_provider, unsigned int *new_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_init_routine();
+
+       util_id_provider_error_e error = UTIL_ID_PROVIDER_OK;
+
+       unsigned int out_new_id = 0;
+
+       unsigned int max_id = id_provider->id_max;
+       unsigned int bits_per_page = id_provider->bits_per_page;
+
+       unsigned int offset = 0;
+       util_id_page_s *id_page = NULL;
+       unsigned int id_page_index = 0;
+
+       util_id_provider_lock(id_provider);
+
+       if (id_provider->total_free_cnt == 0) {
+               error = UTIL_ID_PROVIDER_NOT_ENOUGH_ID;
+               goto error_part;
+       }
+
+       /* find new id to provide */
+       {
+               /* set first candidate as last id + 1 */
+               out_new_id = (id_provider->last_id + 1) % (max_id + 1);
+
+               /* find id_page of first candidate */
+               error = util_id_provider_fetch_id_page(id_provider, out_new_id, &id_page);
+               if (error != UTIL_ID_PROVIDER_OK) {
+                       goto error_part;
+               }
+               assert(id_page != NULL);
+               assert(id_page->bits != NULL);
+
+               /* calculate page_index & offset in id_page of first candidate */
+               id_page_index = util_id_page_get_page_index(id_page);
+               offset = util_id_provider_calculate_offset_in_page(out_new_id, bits_per_page);
+
+               /* note that below loop will be finished in the end, since pId_provider->total_free_cnt > 0, we must have one free id */
+               while (true) {
+
+                       /* we have to look other page, since this page is full */
+                       if (id_page->free_bit_cnt == 0) {
+                               if (util_id_provider_is_last_page_index(id_provider, id_page_index)) {
+                                       id_page_index = 0;
+                               } else {
+                                       id_page_index++;
+                               }
+
+                               offset = 0;
+                               error = util_id_provider_fetch_id_page_by_index(id_provider, id_page_index, &id_page);
+                               if (error != UTIL_ID_PROVIDER_OK) {
+                                       goto error_part;
+                               }
+
+                               continue;
+                       }
+
+                       /* we can provide not reserved id in this page */
+                       if (util_id_page_is_bit_off(id_page, offset)) {
+                               _DEBUG_INFO("page_bit off at id_page = %u, offset = %u", id_page_index, offset);
+                               /* DO NOTHING */
+                       } else {
+                               _DEBUG_INFO("page_bit on at id_page = %u, offset = %u", id_page_index, offset);
+                               /* encounter already used id since we have once reached max id */
+                               /* in this case, find next free id */
+                               unsigned int next_offset = 0;
+
+                               bool find_next_free_offset_success = util_id_page_find_next_free_offset(id_page, offset, &next_offset);
+                               assert(find_next_free_offset_success);
+
+                               offset = next_offset;
+                       }
+                       out_new_id = util_id_provider_calculate_id(id_provider, id_page_index, offset);
+                       break;
+               }
+
+               bool set_bit_on_success = util_id_provider_set_id_page_bit_on(id_provider, id_page, offset);
+               assert(set_bit_on_success);
+
+               id_provider->last_id = out_new_id;
+               *new_id = out_new_id;
+       }
+
+ error_part:
+       if (error == UTIL_ID_PROVIDER_OK && !(id_provider->tracking)) {
+               util_id_provider_reset_tracking_info(id_provider);
+       }
+
+       util_id_provider_unlock(id_provider);
+       _DEBUG_INFO("end with error = %d, provided id = %u (page index = %u, offset = %u)", error, out_new_id, id_page_index, offset);
+
+       _EXTERN_FUNC_EXIT;
+
+       return error;
+}
+
+util_id_provider_error_e util_delete_id(util_id_provider_s * id_provider, unsigned int id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_id_provider_init_routine();
+
+       util_id_provider_error_e err = UTIL_ID_PROVIDER_OK;
+
+       unsigned int bits_per_page = id_provider->bits_per_page;
+       util_id_page_s *id_page = NULL;
+       unsigned int offset = 0;
+
+       util_id_provider_lock(id_provider);
+
+       if (!util_id_provider_is_valid_id_range(id_provider, id)) {
+               err = UTIL_ID_PROVIDER_OUT_OF_ID_RANGE;
+               goto error_part;
+       }
+
+       offset = util_id_provider_calculate_offset_in_page(id, bits_per_page);
+       err = util_id_provider_fetch_id_page(id_provider, id, &id_page);
+       if (err != UTIL_ID_PROVIDER_OK) {
+               goto error_part;
+       }
+
+       if (!util_id_provider_set_id_page_bit_off(id_provider, id_page, offset)) {
+               /* bit already off case */
+               err = UTIL_ID_PROVIDER_NOT_EXIST_ID;
+       }
+
+ error_part:
+       if (err == UTIL_ID_PROVIDER_OK && !(id_provider->tracking)) {
+               util_id_provider_reset_tracking_info(id_provider);
+       }
+       util_id_provider_unlock(id_provider);
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+unsigned int util_get_total_free_count(util_id_provider_s * id_provider)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_provider->total_free_cnt;
+}
diff --git a/src/framework/utility/fw_sequential_id_provider.h b/src/framework/utility/fw_sequential_id_provider.h
new file mode 100755 (executable)
index 0000000..61752bb
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_SEQUENTIAL_ID_PROVIDER_H_
+#define FW_SEQUENTIAL_ID_PROVIDER_H_
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif                         /* __cplusplus */
+
+/**
+ * @file               fw_sequential_id_provider.h
+ * @brief      Support to generate unique ID
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/**
+ * @brief      Enumerations of error codes for Id provider
+ */
+       typedef enum util_id_provider_error util_id_provider_error_e;
+
+/**
+ * @brief      Enumerations of error codes for Id provider
+ */
+       enum util_id_provider_error {
+               UTIL_ID_PROVIDER_OK = 0,        /**< successful */
+
+               UTIL_ID_PROVIDER_NOT_EXIST_ID,  /**< not exist id */
+               UTIL_ID_PROVIDER_OUT_OF_ID_RANGE,       /**< out of id range */
+               UTIL_ID_PROVIDER_NOT_ENOUGH_ID, /**< full assigned */
+               UTIL_ID_PROVIDER_NOT_EXIST_PAGE,        /**< already exist page */
+               UTIL_ID_PROVIDER_NOT_ENOUGH_MEMORY,     /**< not enough memory */
+               UTIL_ID_PROVIDER_ALREADY_TRACKING_MODE_ON,      /**< already tracking mode on status */
+               UTIL_ID_PROVIDER_ALREADY_TRACKING_MODE_OFF,     /**< already tracking mode off status */
+               UTIL_ID_PROVIDER_PERSISTENT_CREATE_ERROR,       /**< storage create fail */
+               UTIL_ID_PROVIDER_PERSISTENT_NOT_EXIST_PAGE      /**< not exist page in storage */
+       };
+
+/**
+ * @brief      Structure of ID Provider
+ */
+       typedef struct util_id_provider util_id_provider_s;
+
+/**
+ * @brief       create new id provider and register to F/W storage
+ * @param[in] code     ID of id provider - this described in F/W configuration file
+ * @param[in] id_max   max ID count possible id provider generate - this described in F/W configuration file
+ * @param[in] log2_page_size
+ * @return     SYNC_AGENT_UTIL_ID_PROVIDER_OK on success, otherwise a error code.
+ * @see sync_agent_create_id_provider()
+ */
+       util_id_provider_error_e util_create_id_persistent_provider(unsigned int code, unsigned int id_max, unsigned int log2_page_size);
+
+/**
+ * @brief      load id provider from F/W id_provider_tbl
+ * @param[in] code     ID of id provider - this described in F/W configuration file
+ * @param[in] support_thread_safety    whether thread safety or not
+ * @return     util_id_provider_s * on success, otherwise a null pointer.
+ */
+       util_id_provider_s *util_load_id_persistent_provider(unsigned int code, bool support_thread_safety);
+
+/**
+ * @brief      register updated id provider to F/W id_provider_tbl
+ * @param[in] id_provider      updated ID provider structure
+ * @return     SYNC_AGENT_UTIL_ID_PROVIDER_OK on success, otherwise a error code.
+ */
+       util_id_provider_error_e util_update_id_persistent_provider(util_id_provider_s * id_provider);
+
+/**
+ * @brief       create new id provider
+ * @remarks             very similar to @ref util_create_id_persistent_provider(). this function use only memory but F/W storage.
+ * @param[in] id_max   max ID count possible id provider generate - this described in F/W configuration file
+ * @param[in] log2_page_size
+ * @param[in] support_thread_safety    whether thread safety or not
+ * @return     util_id_provider_s * on success, otherwise a null pointer.
+ * @see util_create_id_persistent_provider()
+ */
+       util_id_provider_s *util_create_id_provider(unsigned int id_max, unsigned int log2_page_size, bool support_thread_safety);
+
+/**
+ * @brief       destroy id provider
+ * @remarks            common interface for both persistence mode and memory mode
+ * @param[in] id_provider              expected to destroyed id provider
+ */
+       void util_destroy_id_provider(util_id_provider_s * id_provider);
+
+/**
+ * @brief       tracking bit of id provider -> ON
+ * @param[in] id_provider              id provider
+ * @return     SYNC_AGENT_UTIL_ID_PROVIDER_OK on success, otherwise a error code.
+ */
+       util_id_provider_error_e util_tracking_mode_on(util_id_provider_s * id_provider);
+
+/**
+ * @brief       tracking bit of id provider -> OFF
+ * @param[in] id_provider              id provider
+ * @return     SYNC_AGENT_UTIL_ID_PROVIDER_OK on success, otherwise a error code.
+ */
+       util_id_provider_error_e util_tracking_mode_off(util_id_provider_s * id_provider);
+
+/**
+ * @brief              generate new unique ID
+ * @param[in]  id_provider     id provider
+ * @param[out] new_id          generated unique ID
+ * @return     id_provider_t * on success, otherwise a null pointer.
+ */
+       util_id_provider_error_e util_provide_id(util_id_provider_s * id_provider, unsigned int *new_id);
+
+/**
+ * @brief              delete unique ID
+ * @param[in]  id_provider     id provider
+ * @param[in]  id              expected to deleted ID
+ * @return     id_provider_t * on success, otherwise a null pointer.
+ */
+       util_id_provider_error_e util_delete_id(util_id_provider_s * id_provider, unsigned int id);
+
+/**
+ * @brief              get number of IDs that can be issued
+ * @param[in]  id_provider     id provider
+ * @return     number of IDs
+ */
+       unsigned int util_get_total_free_count(util_id_provider_s * id_provider);
+
+/**
+ *     @}
+ */
+
+#ifdef __cplusplus
+}
+#endif                         /* __cplusplus */
+#endif                         /* FW_SEQUENTIAL_ID_PROVIDER_H_ */
diff --git a/src/framework/utility/fw_sequential_id_provider_internal.h b/src/framework/utility/fw_sequential_id_provider_internal.h
new file mode 100755 (executable)
index 0000000..f7eaad5
--- /dev/null
@@ -0,0 +1,519 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_SEQUENTIAL_ID_PROVIDER_INTERNAL_H_
+#define FW_SEQUENTIAL_ID_PROVIDER_INTERNAL_H_
+
+#include <glib.h>
+#include "utility/fw_list.h"
+#include "utility/fw_sequential_id_provider.h"
+
+/**
+ * @file fw_sequential_id_provider_internal.h
+ * @brief Support to generate unique ID
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define UTIL_ID_PAGE_CNT(ID_MAX_LIMIT, UTIL_BITS_PER_PAGE)             (((ID_MAX_LIMIT) + 1 + (UTIL_BITS_PER_PAGE) - 1))/(UTIL_BITS_PER_PAGE)  /**< id page count(since 0, 1, ... ID_MAX_LIMIT)  */
+#define UTIL_BITS_PER_PAGE(PAGE_SIZE)                                                          ((PAGE_SIZE) * 8)                       /**< bits per page */
+#define UTIL_BITS_PER_PAGE_MASK(UTIL_BITS_PER_PAGE)                            ((UTIL_BITS_PER_PAGE) - 1)              /**< bits per page mask*/
+#define UTIL_DIVIDE_INT_ROUND_UP(NUM1, NUM2)                                   (((NUM1) + (NUM2) - 1)/(NUM2))          /**< divide int round up */
+
+typedef unsigned int util_id_page_flag;                                                /**< id page flag */
+#define UTIL_ID_PAGE_FLAG_UNKNOWN              0x00                            /**< unknown */
+#define UTIL_ID_PAGE_FLAG_UNCHANGED    0x01                                    /**< unchanged */
+#define UTIL_ID_PAGE_FLAG_ADD                          0x02                    /**< add */
+#define        UTIL_ID_PAGE_FLAG_DELETE                        0x04                    /**< delete */
+#define        UTIL_ID_PAGE_FLAG_UPDATE                        0x08                    /**< update */
+
+/**
+ * @brief      Structure of id page instance
+ */
+typedef struct util_id_page util_id_page_s;
+struct util_id_page {
+       util_list_node_s link;                  /**< Link */
+       util_id_page_flag flag;                 /**< Flag */
+       unsigned int page_index;                /**< Page index */
+       unsigned int free_bit_cnt;              /**< Free bit count */
+       unsigned int page_bit_cnt;              /**< Page bit count */
+       char *bits;                                             /**< Bits */
+};
+
+/**
+ * @brief       allocate id page structure
+ * @param[in] flag                             Id page flag(UTIL_ID_PAGE_FLAG_UNKNOWN, UTIL_ID_PAGE_FLAG_UNCHANGED, UTIL_ID_PAGE_FLAG_ADD, UTIL_ID_PAGE_FLAG_DELETE, UTIL_ID_PAGE_FLAG_UPDATE)
+ * @param[in] page_index               Page index
+ * @param[in] free_bit_cnt             Free bit count
+ * @param[in] page_bit_cnt             page bit count
+ * @param[in] bits                             Bits
+ * @return     util_id_page_s on success, NULL on fail
+ * @retval             util_id_page_s          Successful
+ * @retval             NULL            Fail
+ */
+util_id_page_s *util_id_page_alloc(util_id_page_flag flag, unsigned int page_index, unsigned int free_bit_cnt, unsigned int page_bit_cnt, char *bits);
+
+/**
+ * @brief       allocate new id page structure
+ * @param[in] page_index               Page index
+ * @param[in] page_bit_cnt             page bit count
+ * @return     util_id_page_s on success, NULL on fail
+ * @retval             util_id_page_s          Successful
+ * @retval             NULL            Fail
+ */
+util_id_page_s *util_id_page_alloc_new_page(unsigned int page_index, unsigned int page_bit_cnt);
+
+/**
+ * @brief       Load id page structure
+ * @param[in] code                             Code
+ * @param[in] page_index               Id page index
+ * @param[in] page_bit_cnt             Id page bit count
+ * @return     util_id_page_s on success, NULL on fail
+ * @retval             util_id_page_s          Successful
+ * @retval             NULL            Fail
+ */
+util_id_page_s *util_id_page_load(unsigned int code, unsigned int page_index, unsigned int page_bit_cnt);
+
+/**
+ * @brief       Free id page structure
+ * @param[in] id_page                  util_id_page_s
+ */
+void util_id_page_free(util_id_page_s * id_page);
+
+/**
+ * @brief       check that id page is empty
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            Successful
+ * @retval             false           Fail
+ */
+inline bool util_id_page_is_empty(util_id_page_s * id_page);
+
+/**
+ * @brief       check that id page is empty
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] flag                             Id page flag(UTIL_ID_PAGE_FLAG_UNKNOWN, UTIL_ID_PAGE_FLAG_UNCHANGED, UTIL_ID_PAGE_FLAG_ADD, UTIL_ID_PAGE_FLAG_DELETE, UTIL_ID_PAGE_FLAG_UPDATE)
+ */
+inline void util_id_page_set_flag(util_id_page_s * id_page, util_id_page_flag flag);
+
+/**
+ * @brief       get id page flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     util_id_page_flag
+ * @retval             util_id_page_flag(UTIL_ID_PAGE_FLAG_UNKNOWN, UTIL_ID_PAGE_FLAG_UNCHANGED, UTIL_ID_PAGE_FLAG_ADD, UTIL_ID_PAGE_FLAG_DELETE, UTIL_ID_PAGE_FLAG_UPDATE)
+ */
+inline util_id_page_flag util_id_page_get_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      check that id page has same flag
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] flag                     util_id_page_flag
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_has_same_flag(util_id_page_s * id_page, util_id_page_flag flag);
+
+/**
+ * @brief      check that id page is unknown flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_unknown_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      check that id page is add flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_add_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      check that id page is delete flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_delete_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      check that id page is update flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_update_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      check that id page is unchanged flag
+ * @param[in] id_page                  util_id_page_s
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_unchanged_flag(util_id_page_s * id_page);
+
+/**
+ * @brief      get page index
+ * @param[in] id_page                  util_id_page_s
+ * @return     page index
+ */
+inline unsigned int util_id_page_get_page_index(util_id_page_s * id_page);
+
+/**
+ * @brief      set page index
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] index                    page index
+ */
+inline void util_id_page_set_page_index(util_id_page_s * id_page, unsigned int index);
+
+/**
+ * @brief      bit on
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_bit_on(util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      bit off
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success, false on fail
+ * @retval             true            YES
+ * @retval             false           NO
+ */
+inline bool util_id_page_is_bit_off(util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      set bit on
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success, false on fail
+ * @retval             true            Successful
+ * @retval             false           Fail
+ */
+inline bool util_id_page_set_bit_on(util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      set bit off
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success, false on fail
+ * @retval             true            Successful
+ * @retval             false           Fail
+ */
+inline bool util_id_page_set_bit_off(util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      find next free offset
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] search_start_offset                      search start offset
+ * @param[out] next_free_offset                        next free offset
+ * @return     true on success, false on fail
+ * @retval             true            Successful
+ * @retval             false           Fail
+ */
+bool util_id_page_find_next_free_offset(util_id_page_s * id_page, unsigned int search_start_offset, unsigned int *next_free_offset);
+
+/**
+ * @brief      Structure of id provider change tracing instance
+ */
+typedef struct util_id_provider_change_tracking util_id_provider_change_tracking_s;
+struct util_id_provider_change_tracking {
+       util_list_node_s id_page_add_list_head;                         /**< Add list head */
+       util_list_node_s id_page_update_list_head;                      /**< Update list head */
+       util_list_node_s id_page_delete_list_head;                      /**< delete list head */
+       util_list_node_s id_page_unchanged_list_head;           /**< unchanged list head */
+};
+
+/**
+ * @brief      allocate id provider change tracking structure
+ * @return     true on success, false on fail
+ * @retval             util_id_provider_change_tracking_s              Successful
+ * @retval             NULL                                                                    Fail
+ */
+util_id_provider_change_tracking_s *util_id_provider_change_tracking_alloc(void);
+
+/**
+ * @brief      free id provider change tracking structure
+ * @param[in] tracking                 util_id_provider_change_tracking_s                                                                      Fail
+ */
+void util_id_provider_change_tracking_free(util_id_provider_change_tracking_s * tracking);
+
+/**
+ * @brief      Get id provider change tracking list
+ * @param[in] tracking                 util_id_provider_change_tracking_s
+ * @param[in] flag                     util_id_page_flag
+ * @return     util_list_node_s on success,  NULL on fail
+ * @retval             util_list_node_s                Successful
+ * @retval             NULL                    Fail
+ */
+inline util_list_node_s *util_id_provider_change_tracking_get_list(util_id_provider_change_tracking_s * tracking, util_id_page_flag flag);
+
+/**
+ * @brief      Structure of id provider instance
+ */
+struct util_id_provider {
+       bool persistent_mode;   /**< whether persistent mode or not*/
+       unsigned int code;      /**< only used in persistent mode */
+
+       bool tracking;  /**< whether tracking or not*/
+
+       bool support_thread_safety;             /**< support thread safety*/
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       GMutex *mutex;                                  /**< mutex */
+#else
+       GMutex mutex;
+#endif
+       unsigned int id_max;                    /**< max */
+
+       unsigned int log2_page_size;            /**< log2 page size */
+       unsigned int page_size;                         /**< page size */
+       unsigned int bits_per_page;                     /**< bits per page */
+
+       unsigned int last_id;                   /**< last id */
+
+       unsigned int total_free_cnt;            /**< total free count */
+
+       unsigned int id_page_cnt;                       /**< id page count */
+       util_id_page_s **id_page_array;         /**< id page array */
+
+       util_id_provider_change_tracking_s *pTracking;          /**< change tracking */
+};
+
+/**
+ * @brief      create id provider internal
+ * @param[in] persistent_mode                  persistent mode
+ * @param[in] code                                             code
+ * @param[in] total_free_bit_cnt                       total free bit count
+ * @param[in] id_max                                   max
+ * @param[in] log2_page_size                   log2 page size
+ * @param[in] support_thread_safety                    support thread safety
+ * @return     util_id_provider_s on success,  NULL on fail
+ * @retval             util_id_provider_s              Successful
+ * @retval             NULL                    Fail
+ */
+util_id_provider_s *util_id_provider_create_internal(bool persistent_mode, unsigned int code, unsigned int total_free_bit_cnt, unsigned int id_max, unsigned int log2_page_size, bool support_thread_safety);
+
+/**
+ * @brief      initialize routine
+ */
+inline void util_id_provider_init_routine(void);
+
+/**
+ * @brief      id provider lock
+ * @param[in] id_provider                      util_id_provider_s
+ */
+inline void util_id_provider_lock(util_id_provider_s * id_provider);
+
+/**
+ * @brief      id provider unlock
+ * @param[in] id_provider                      util_id_provider_s
+ */
+inline void util_id_provider_unlock(util_id_provider_s * id_provider);
+
+/**
+ * @brief      check valid id range
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id                                               id
+ * @return     true on success,  false on fail
+ * @retval             true                    Yes
+ * @retval             false                   No
+ */
+inline bool util_id_provider_is_valid_id_range(util_id_provider_s * id_provider, unsigned int id);
+
+/**
+ * @brief      check valid page index
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page_index                                            id page index
+ * @return     true on success,  false on fail
+ * @retval             true                    Yes
+ * @retval             false                   No
+ */
+inline bool util_id_provider_is_valid_page_index(util_id_provider_s * id_provider, unsigned int id_page_index);
+
+/**
+ * @brief      check last page index
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page_index                                            id page index
+ * @return     true on success,  false on fail
+ * @retval             true                    Yes
+ * @retval             false                   No
+ */
+inline bool util_id_provider_is_last_page_index(util_id_provider_s * id_provider, unsigned int id_page_index);
+
+/**
+ * @brief      calculate id page array index
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id                                               id
+ * @return     id page array index
+ */
+inline unsigned int util_id_provider_calculate_id_page_array_index(util_id_provider_s * id_provider, unsigned int id);
+
+/**
+ * @brief      calculate page count for id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page_index                    id page index
+ * @param[in] page_cnt                 page count
+ * @return     UTIL_ID_PROVIDER_OK on success, otherwise a error value.
+ * @retval             UTIL_ID_PROVIDER_OK                     Successful
+ * @retval             UTIL_ID_PROVIDER_NOT_EXIST_PAGE                 when page is not exist
+ */
+inline util_id_provider_error_e util_id_provider_calculate_page_cnt_for_id_page(util_id_provider_s * id_provider, unsigned int id_page_index, unsigned int *page_cnt);
+
+/**
+ * @brief      calculate offset
+ * @param[in] id                       id
+ * @param[in] bits_per_page                    bits per page
+ * @return     offset in page
+ */
+inline unsigned int util_id_provider_calculate_offset_in_page(unsigned int id, unsigned int bits_per_page);
+
+/**
+ * @brief      calculate id
+ * @param[in] provider                 util_id_provider_s
+ * @param[in] id_page_index                    id page index
+ * @param[in] offset                   offset
+ * @return     id
+ */
+inline unsigned int util_id_provider_calculate_id(util_id_provider_s * provider, unsigned int id_page_index, unsigned int offset);
+
+/**
+ * @brief      fetch id page by index
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] index                    index
+ * @param[out] id_page                 util_id_page_s
+ * @return     UTIL_ID_PROVIDER_OK on success, otherwise a error value.
+ * @retval             UTIL_ID_PROVIDER_OK                     Successful
+ * @retval             UTIL_ID_PROVIDER_NOT_EXIST_PAGE                 when page is not exist
+ * @retval             UTIL_ID_PROVIDER_NOT_ENOUGH_MEMORY              when memory is not enough
+ */
+inline util_id_provider_error_e util_id_provider_fetch_id_page_by_index(util_id_provider_s * id_provider, unsigned int index, util_id_page_s ** id_page);
+
+/**
+ * @brief      fetch id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id                       id
+ * @param[out] id_page                 util_id_page_s
+ * @return     UTIL_ID_PROVIDER_OK on success, otherwise a error value.
+ * @retval             UTIL_ID_PROVIDER_OK                     Successful
+ * @retval             UTIL_ID_PROVIDER_OUT_OF_ID_RANGE                when out of id range
+ * @retval             UTIL_ID_PROVIDER_NOT_EXIST_PAGE                 when page is not exist
+ * @retval             UTIL_ID_PROVIDER_NOT_ENOUGH_MEMORY              when memory is not enough
+ */
+inline util_id_provider_error_e util_id_provider_fetch_id_page(util_id_provider_s * id_provider, unsigned int id, util_id_page_s ** id_page);
+
+/**
+ * @brief      fetch id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] index                    index
+ * @return     UTIL_ID_PROVIDER_OK on success, otherwise a error value.
+ * @retval             UTIL_ID_PROVIDER_OK                     Successful
+ * @retval             UTIL_ID_PROVIDER_OUT_OF_ID_RANGE                when out of id range
+ * @retval             UTIL_ID_PROVIDER_NOT_EXIST_PAGE                 when page is not exist
+ * @retval             UTIL_ID_PROVIDER_NOT_ENOUGH_MEMORY              when memory is not enough
+ */
+inline util_id_provider_error_e util_id_provider_set_id_page_index(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int index);
+
+/**
+ * @brief      move id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page                  util_id_page_s
+ * @param[in] next                     util_id_page_flag
+ */
+void util_id_provider_move_id_page(util_id_provider_s * id_provider, util_id_page_s * id_page, util_id_page_flag next);
+
+/**
+ * @brief      remove id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page                  util_id_page_s
+ */
+void util_id_provider_remove_id_page(util_id_provider_s * id_provider, util_id_page_s * id_page);
+
+/**
+ * @brief      add id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] page_index                       page index
+ * @return     util_id_page_s on success, NULL on fail
+ * @retval             util_id_page_s                  Successful
+ * @retval             NULL            Fail
+ */
+util_id_page_s *util_id_provider_add_id_page(util_id_provider_s * id_provider, unsigned int page_index);
+
+/**
+ * @brief      load id page
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] page_index                       page index
+ * @param[out] id_page                 util_id_page_s
+ * @return     UTIL_ID_PROVIDER_OK on success, otherwise a error value.
+ * @retval             UTIL_ID_PROVIDER_OK                     Successful
+ * @retval             UTIL_ID_PROVIDER_NOT_EXIST_PAGE                 when page is not exist
+ */
+util_id_provider_error_e util_id_provider_load_id_page(util_id_provider_s * id_provider, unsigned int page_index, util_id_page_s ** id_page);
+
+/**
+ * @brief      set id page bit on
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page                  page util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success,  false on fail
+ * @retval             true                    Yes
+ * @retval             false                   No
+ */
+bool util_id_provider_set_id_page_bit_on(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      set id page bit off
+ * @param[in] id_provider                      util_id_provider_s
+ * @param[in] id_page                  page util_id_page_s
+ * @param[in] offset                   offset
+ * @return     true on success,  false on fail
+ * @retval             true                    Yes
+ * @retval             false                   No
+ */
+bool util_id_provider_set_id_page_bit_off(util_id_provider_s * id_provider, util_id_page_s * id_page, unsigned int offset);
+
+/**
+ * @brief      reset tracking info
+ * @param[in] id_provider                      util_id_provider_s
+ */
+void util_id_provider_reset_tracking_info(util_id_provider_s * id_provider);
+
+/**
+ * @brief      destory id page array
+ * @param[in] id_page_cnt                      id page count
+ * @param[in] id_page_array                    util_id_page_s
+ */
+void util_id_provider_destroy_id_page_array(unsigned int id_page_cnt, util_id_page_s ** id_page_array);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_SEQUENTIAL_ID_PROVIDER_INTERNAL_H_ */
diff --git a/src/framework/utility/fw_thread.c b/src/framework/utility/fw_thread.c
new file mode 100755 (executable)
index 0000000..5257059
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "utility/fw_thread.h"
+#include <stdlib.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_THREAD"
+#endif
+
+pthread_mutex_t *util_alloc_init_mutex(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+       if (mutex == NULL) {
+               goto return_part;
+       }
+       if (0 != pthread_mutex_init(mutex, NULL)) {
+               free(mutex);
+               mutex = NULL;
+               goto return_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return mutex;
+}
+
+void util_free_mutex(pthread_mutex_t * mutex)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (mutex != NULL) {
+               pthread_mutex_destroy(mutex);
+               free(mutex);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+pthread_cond_t *util_alloc_init_thread_cond(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       pthread_cond_t *thread_cond = (pthread_cond_t *) malloc(sizeof(pthread_cond_t));
+       if (thread_cond == NULL) {
+               goto return_part;
+       }
+
+       if (0 != pthread_cond_init(thread_cond, 0)) {
+               free(thread_cond);
+               thread_cond = NULL;
+               goto return_part;
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return thread_cond;
+}
+
+void util_free_thread_cond(pthread_cond_t * thread_cond)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (thread_cond != NULL) {
+               pthread_cond_destroy(thread_cond);
+               free(thread_cond);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/src/framework/utility/fw_thread.h b/src/framework/utility/fw_thread.h
new file mode 100755 (executable)
index 0000000..1560331
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_THREAD_H_
+#define FW_THREAD_H_
+
+#include <pthread.h>
+#include <signal.h>
+
+/**
+ * @file               fw_thread.h
+ * @brief      Provides thread operation
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+/* for pthread.h */
+#define UTIL_THREAD_T                                          pthread_t
+#define UTIL_THREAD_MUTEX_T                    pthread_mutex_t
+#define UTIL_THREAD_COND_T                             pthread_cond_t
+#define UTIL_THREAD_KET_T                              pthread_key_t
+
+#define UTIL_THREAD_MUTEX_LOCK(mutex)                                                                  pthread_mutex_lock(mutex)
+#define UTIL_THREAD_MUTEX_UNLOCK(mutex)                                                                pthread_mutex_unlock(mutex)
+#define UTIL_THREAD_CREATE(thread_id, attr, start_function, arg)       pthread_create(thread_id, attr, start_function, arg)
+#define UTIL_THREAD_DETACH(thread_id)                                                                  pthread_detach(thread_id)
+#define UTIL_THREAD_COND_SIGNAL(cond)                                                                  pthread_cond_signal(cond)
+#define UTIL_THREAD_COND_WAIT(cond, mutex)                                                     pthread_cond_wait(cond, mutex)
+#define UTIL_THREAD_KILL(thread_id, signo)                                                             pthread_kill(thread_id, signo)
+#define UTIL_THREAD_SELF()                                                                                                             pthread_self()
+#define UTIL_THREAD_EXIT(retval)                                                                                               pthread_exit(retval)
+#define UTIL_THREAD_SETSPECIFIC(key, value)                                                            pthread_setspecific(key, value)
+#define UTIL_THREAD_SIGMASK(how, new_mask, signo)                              pthread_sigmask(how, new_mask, signo)
+
+/**
+ * @brief              Initialize mutex
+ * @return             pthread_mutex_t on success, NULL on fail
+ * @retval             pthread_mutex_t         Successful
+ * @retval             NULL                            Fail
+ */
+pthread_mutex_t *util_alloc_init_mutex(void);
+
+/**
+ * @brief              Free mutex
+ * @param[in]  mutex           pthread_mutex_t
+ */
+void util_free_mutex(pthread_mutex_t * mutex);
+
+/**
+ * @brief              Initialize thread cond
+ * @return             pthread_cond_t on success, NULL on fail
+ * @retval             pthread_cond_t          Successful
+ * @retval             NULL                            Fail
+ */
+pthread_cond_t *util_alloc_init_thread_cond(void);
+
+/**
+ * @brief              Free thread cond
+ * @param[in]  thread_cond             pthread_cond_t
+ */
+void util_free_thread_cond(pthread_cond_t * thread_cond);
+
+/* for signal.h */
+#define UTIL_SIGSET_T                  sigset_t
+#define UTIL_SIGACTION_T       struct sigaction
+
+#define UTIL_SIGACTION(signum, act, oldact)            sigaction(signum, act, oldact)
+#define UTIL_SIGEMPTYSET(set)                                          sigemptyset(set)
+#define UTIL_SIGADDSET(set, signum)                            sigaddset(set, signum)
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_THREAD_H_ */
diff --git a/src/framework/utility/fw_time.c b/src/framework/utility/fw_time.c
new file mode 100755 (executable)
index 0000000..f2f1eb0
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/fw_time.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TIME"
+#endif
+
+static int _get_time_zone_second(void);
+static int _get_daylight_second(void);
+
+EXPORT_API int sync_agent_convert_seconds_to_utc(int seconds)
+{
+       _EXTERN_FUNC_ENTER;
+
+       seconds += _get_time_zone_second();
+       seconds += _get_daylight_second();
+
+       _EXTERN_FUNC_EXIT;
+
+       return seconds;
+}
+
+static int _get_time_zone_second(void)
+{
+       _INNER_FUNC_ENTER;
+
+       int time_zone;
+       tzset();
+       time_zone = timezone;
+       _DEBUG_TRACE("time zone : %d", time_zone);
+       time_zone = time_zone * -1;
+
+       _INNER_FUNC_EXIT;
+
+       return time_zone;
+}
+
+static int _get_daylight_second(void)
+{
+       _INNER_FUNC_ENTER;
+
+       int day_light;
+       tzset();
+       day_light = daylight;
+       _DEBUG_TRACE("daylight = %d", day_light);
+       if (day_light == 0) {
+               return 0;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 3600;
+}
diff --git a/src/framework/utility/fw_timer.c b/src/framework/utility/fw_timer.c
new file mode 100755 (executable)
index 0000000..747eaca
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/fw_list.h"
+#include "utility/fw_timer.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_TIMER"
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+
+static util_timer_element_s *_timer_element_alloc(char *label);
+static void _timer_element_free(util_timer_element_s * element);
+static double _calculate_diff_time(util_timer_element_s * element);
+
+static util_timer_element_s *_timer_element_alloc(char *label)
+{
+       _INNER_FUNC_ENTER;
+
+       util_timer_element_s *element = NULL;
+       char *dest_label = NULL;
+       if (label == NULL) {
+               goto return_part;
+       }
+
+       element = (util_timer_element_s *) calloc(1, sizeof(util_timer_element_s));
+       if (element == NULL) {
+               _DEBUG_ERROR("fw_timer_element alloc failed because of out of memory");
+               goto return_part;
+       }
+       dest_label = element->label;
+
+       /* set label */
+       strncpy(dest_label, label, UTIL_TIMER_MAX_LABEL_LEN);
+
+ return_part:
+       _INNER_FUNC_EXIT;
+       return element;
+}
+
+static void _timer_element_free(util_timer_element_s * element)
+{
+       _INNER_FUNC_ENTER;
+
+       if (element != NULL) {
+               free(element);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+util_timer_s *util_timer_alloc()
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_timer_s *timer = (util_timer_s *) malloc(sizeof(util_timer_s));
+
+       if (timer != NULL) {
+               util_list_init(&(timer->element_head));
+       } else {
+               _DEBUG_ERROR("fw_timer_alloc failed because of out of memory");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return timer;
+}
+
+static double _calculate_diff_time(util_timer_element_s * element)
+{
+       _INNER_FUNC_ENTER;
+
+       double diff_time = 0.0;
+       double sTime = element->start_time.tv_sec + (element->start_time.tv_usec / 1000000.0);
+       double fTime = element->finish_time.tv_sec + (element->finish_time.tv_usec / 1000000.0);
+       diff_time = fTime - sTime;
+
+       _INNER_FUNC_EXIT;
+
+       return diff_time;
+}
+
+util_timer_error_e util_timer_start(util_timer_s * timer, char *label)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_timer_error_e err = UTIL_TIMER_OK;
+       if (timer == NULL) {
+               err = UTIL_TIMER_INVALID_TIMER;
+               goto return_part;
+       }
+
+       util_timer_element_s *element = _timer_element_alloc(label);
+       if (element == NULL) {
+               err = UTIL_TIMER_OUT_OF_MEMORY;
+               goto return_part;
+       }
+
+       /* set timer start time */
+       if (-1 == gettimeofday(&(element->start_time), NULL)) {
+               err = UTIL_TIMER_GETTIME_ERROR;
+               _timer_element_free(element);
+               goto return_part;
+       }
+
+       /* add list */
+       util_list_add_node((util_list_node_s *) element, &(timer->element_head));
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+util_timer_error_e util_timer_finish(util_timer_s * timer, char *label, double *passed_sec)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_timer_error_e err = UTIL_TIMER_OK;
+       util_list_node_s *iter = NULL;
+       util_list_node_s *head = &(timer->element_head);
+       util_timer_element_s *element = NULL;
+
+       /* find list node */
+       UTIL_LIST_ITER(iter, head) {
+               element = (util_timer_element_s *) iter;
+
+               if (strncmp(label, element->label, UTIL_TIMER_MAX_LABEL_LEN) != 0) {
+                       continue;
+               }
+
+               if (-1 == gettimeofday(&(element->finish_time), NULL)) {
+                       err = UTIL_TIMER_GETTIME_ERROR;
+                       goto return_part;
+               } else {
+                       /* calcuate passed_sec */
+                       if (passed_sec != NULL) {
+                               *passed_sec = _calculate_diff_time(element);
+                       }
+
+                       break;
+               }
+       }
+
+ return_part:
+       _EXTERN_FUNC_EXIT;
+       return err;
+}
+
+/* TODO */
+util_timer_error_e util_timer_print(util_timer_s * timer)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_timer_error_e err = UTIL_TIMER_OK;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
+
+/* TODO */
+util_timer_error_e util_timer_free(util_timer_s * timer)
+{
+       _EXTERN_FUNC_ENTER;
+
+       util_timer_error_e err = UTIL_TIMER_OK;
+
+       _EXTERN_FUNC_EXIT;
+
+       return err;
+}
diff --git a/src/framework/utility/fw_timer.h b/src/framework/utility/fw_timer.h
new file mode 100755 (executable)
index 0000000..8171517
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_TIMER_H_
+#define FW_TIMER_H_
+
+#include <sys/time.h>
+#include "utility/fw_list.h"
+
+/**
+ * @file               fw_thread.h
+ * @brief      Provides timer operation
+ */
+
+/** @addtogroup utility
+ *     @{
+ */
+
+#define UTIL_TIMER_MAX_LABEL_LEN       512                             /**< max labe length */
+
+typedef struct util_timer_element util_timer_element_s;
+typedef struct util_timer util_timer_s;
+
+/**
+ * @brief      Enumerations of error codes for util timer
+ */
+typedef enum {
+       UTIL_TIMER_OK = 0,                                      /**< OK */
+       UTIL_TIMER_OUT_OF_MEMORY,                       /**< Out of memory */
+       UTIL_TIMER_INVALID_TIMER,                       /**< Invalid timer */
+       UTIL_TIMER_GETTIME_ERROR                        /**< Error */
+} util_timer_error_e;
+
+/**
+ * @brief      Structure of timer element instance
+ */
+struct util_timer_element {
+       util_list_node_s link;                                          /**< Link */
+       struct timeval start_time;                                      /**< Start time */
+       struct timeval finish_time;                                     /**< Finish time */
+       char label[UTIL_TIMER_MAX_LABEL_LEN + 1];       /**< Label */
+};
+
+/**
+ * @brief      Structure of timer instance
+ */
+struct util_timer {
+       util_list_node_s element_head;                          /**< Element head */
+};
+
+/**
+ * @brief      Allocate util_timer_s structure
+ * @return     util_timer_s on success, otherwise NULL
+ * @retval             util_timer_s                    Successful
+ * @retval             NULL                                    When memory allocation is failed
+ */
+util_timer_s *util_timer_alloc();
+
+/**
+ * @brief              start timer
+ * @param[in]  timer           util_timer_s structure
+ * @param[in]  label           label
+ * @return             UTIL_TIMER_OK           on success, otherwise a error value.
+ * @retval             UTIL_TIMER_OK           Successful
+ * @retval             UTIL_TIMER_INVALID_TIMER                when timer is NULL
+ * @retval             UTIL_TIMER_OUT_OF_MEMORY                When memory allocation is failed
+ * @retval             UTIL_TIMER_GETTIME_ERROR                when get start time is failed
+ */
+util_timer_error_e util_timer_start(util_timer_s * timer, char *label);
+
+/**
+ * @brief              finish timer
+ * @param[in]  timer           util_timer_s structure
+ * @param[in]  label           label
+ * @param[in]  passed_sec              passed_sec
+ * @return             UTIL_TIMER_OK           on success, otherwise a error value.
+ * @retval             UTIL_TIMER_OK           Successful
+ * @retval             UTIL_TIMER_GETTIME_ERROR                when get start time is failed
+ */
+util_timer_error_e util_timer_finish(util_timer_s * timer, char *label, double *passed_sec);
+
+/**
+ * @brief              print timer
+ * @param[in]  timer           util_timer_s structure
+ * @return             UTIL_TIMER_OK           on success
+ * @retval             UTIL_TIMER_OK           Successful
+ */
+util_timer_error_e util_timer_print(util_timer_s * timer);
+
+/**
+ * @brief              free timer
+ * @param[in]  timer           util_timer_s structure
+ * @return             UTIL_TIMER_OK           on success
+ * @retval             UTIL_TIMER_OK           Successful
+ */
+util_timer_error_e util_timer_free(util_timer_s * timer);
+
+/**
+ *     @}
+ */
+
+#endif                         /* FW_TIMER_H_ */
diff --git a/src/framework/utility/sync_util.c b/src/framework/utility/sync_util.c
new file mode 100755 (executable)
index 0000000..c348dc7
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "AF_SYNC_UTIL"
+#endif
+
+EXPORT_API int sync_agent_daemonize(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       pid_t pid, sid;
+
+       /* 1. if already a daemon running, return */
+       if (getppid() == 1) {
+               _DEBUG_WARNING("daemon is already running");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       /* 2. Fork off the parent process */
+       pid = fork();
+
+       if (pid < 0) {          // if error
+               _DEBUG_ERROR("fork() error");
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+       /* If we got a good PID, then we can exit the parent process,
+        * so that PPID can be the one of init process(1).
+        */
+       if (pid > 0) {          // if parent process
+               exit(0);
+       }
+
+       /* At this point we are executing as the child process */
+
+       /* 3. Change the file mode mask (022 : permission = 644) */
+       umask(022);
+
+       /* 4. Create a new SID for the child process,
+        * so that PGID can be the one of PID of child process.
+        */
+       sid = setsid();
+       if (sid < 0) {
+               _DEBUG_ERROR("setsid() error");
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+
+       /* 5. Change the current working directory.
+        * This prevents the current directory from being locked; hence not being able to remove it.
+        */
+       if ((chdir("/")) < 0) {
+               _DEBUG_ERROR("chdir() error");
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+
+       /* 6. Redirect standard files to /dev/null */
+       FILE *fp;
+       fp = freopen("/dev/null", "r", stdin);
+       if (fp == NULL) {
+               _DEBUG_ERROR("freopen() error");
+       }
+       fp = freopen("/dev/null", "w", stdout);
+       if (fp == NULL) {
+               _DEBUG_ERROR("freopen() error");
+       }
+       fp = freopen("/dev/null", "w", stderr);
+       if (fp == NULL) {
+               _DEBUG_ERROR("freopen() error");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
diff --git a/src/fw-plugins/CMakeLists.sub b/src/fw-plugins/CMakeLists.sub
new file mode 100644 (file)
index 0000000..8040b54
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set lib name
+SET(LIBNAME "lib${PROJECT_NAME}")
+#SET(LIBDIR "${PREFIX}/lib")
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${PLUGIN_CFLAGS}")
+
+# add include directories to the build.
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../include)
+
+# find all source files in a directory.
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# add a library to the project using the specified source files.
+ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
+
+# link a target to given libraries from pkg-config.
+TARGET_LINK_LIBRARIES(${LIBNAME} ${PLUGIN_LDFLAGS})
+
+# sets additional compiler flags used to build sources within the target.
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+# override the default target name prefix (such as "lib")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+
+# specify the build version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
+
+# specify the api version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+# install library files
+INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIBDIR})
+
diff --git a/src/fw-plugins/CMakeLists.txt b/src/fw-plugins/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..04ce3d0
--- /dev/null
@@ -0,0 +1,3 @@
+
+#ADD_SUBDIRECTORY(common-private)
+ADD_SUBDIRECTORY(common-public)
diff --git a/src/fw-plugins/common-private/CMakeLists.txt b/src/fw-plugins/common-private/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..46d6ce9
--- /dev/null
@@ -0,0 +1,9 @@
+
+# set plguin name
+SET(PLUGIN_CATEGORY_NAME "common-private")
+
+# set plugin install path
+SET(LIBDIR "${PREFIX}/lib/sync-agent/${PLUGIN_CATEGORY_NAME}")
+
+ADD_SUBDIRECTORY(slp-mdm)
+
diff --git a/src/fw-plugins/common-public/CMakeLists.txt b/src/fw-plugins/common-public/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..6102f10
--- /dev/null
@@ -0,0 +1,20 @@
+
+# set plguin name
+SET(PLUGIN_CATEGORY_NAME "common-public")
+
+# set plugin install path
+SET(LIBDIR "${PREFIX}/lib/sync-agent/${PLUGIN_CATEGORY_NAME}")
+
+ADD_SUBDIRECTORY(account)
+ADD_SUBDIRECTORY(calendar)
+ADD_SUBDIRECTORY(call-log)
+ADD_SUBDIRECTORY(contact)
+ADD_SUBDIRECTORY(http)
+ADD_SUBDIRECTORY(memo)
+ADD_SUBDIRECTORY(slp-device)
+ADD_SUBDIRECTORY(slp-sysnoti-alarm)
+ADD_SUBDIRECTORY(slp-sysnoti-network-connection)
+ADD_SUBDIRECTORY(slp-sysnoti-wap-push)
+ADD_SUBDIRECTORY(vcalendar)
+ADD_SUBDIRECTORY(vobject-tizen)
+
diff --git a/src/fw-plugins/common-public/account/CMakeLists.txt b/src/fw-plugins/common-public/account/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..933a2d8
--- /dev/null
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "account")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       accounts-svc
+                                       glib-2.0
+                                       vconf
+                                       dlog)
+
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${account_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${account_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/account/src/plugin_interface.c b/src/fw-plugins/common-public/account/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..c170dde
--- /dev/null
@@ -0,0 +1,569 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>             /*for debugging */
+#include <string.h>
+
+#include <account.h>
+
+#include "account/service.h"
+
+/* for log */
+#include "utility/sync_util.h"
+#include "utility/fw_file.h"
+
+#include "plugin/account_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_ACCOUNT"
+#endif
+
+/*
+ * Key         : DEFAULT_ACCOUNT_PLUGIN_FOLDER/.[Agent Name]_Service_[Service_Type]_[FW AccountID]
+ * Value       : Service Account ID
+ */
+#define ACCOUNT_ID_SERVICE_ACCOUNT_ID  ".%s_service_%d_%d"
+
+/*
+ * KEY : DEFAULT_ACCOUNT_PLUGIN_FOLDER/.[Agent Name]_FW_[Service_Type]_[Service AccountID]_[Index]
+ * Value : FW Account ID
+ */
+#define ACCOUNT_ID_FW_ACCOUNT_ID       ".%s_fw_%d_%d_%d"
+
+/*
+ * Key         : DEFAULT_ACCOUNT_PLUGIN_FOLDER/.[Agent Name]_FW_Count_[Service_Type]_[Service AccountID]
+ * Value       : FW Account Count Included in one service Account
+ */
+#define ACCOUNT_ID_FW_ACCOUNT_COUNT            ".%s_fw_count_%d_%d"
+
+#define        FW_CONTACT              0
+#define FW_CALENDAR    1
+#define FW_MEMO                        2
+#define FW_CONTENT_COUNT       3
+
+#define MAX_ACCOUNT_COUNT      20
+
+static const char *agent_name = 0;
+
+static void _set_account_id_service(int service_type, int fw_account_id, int service_account_id);
+
+static void _arrange_account_id_fw(int service_type, int service_account_id, int index, int fw_account_id);
+
+static void _set_account_id_fw(int service_type, int service_account_id, int count, int fw_account_id);
+
+static int _increase_account_count_fw(int service_type, int service_account_id);
+
+static int _get_account_count_fw(int service_type, int service_account_id);
+
+static void _unset_account_id_service(int service_type, int fw_account_id);
+
+static void _unset_account_id_fw(int service_type, int service_account_id, int index);
+
+static int _decrease_account_count_fw(int service_type, int service_account_id);
+
+static int _get_account_info(int service_account_id, sync_agent_service_account_info_s ** account_info);
+
+EXPORT_API void sync_agent_plugin_set_account_repository_name(const char *input_agent_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       agent_name = input_agent_name;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_add_platform_account(int fw_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int slp_id = -1;
+
+       int slp_contact_id = sync_agent_plugin_get_service_account_id(FW_CONTACT, fw_account_id);
+       int slp_calendar_id = sync_agent_plugin_get_service_account_id(FW_CALENDAR, fw_account_id);
+       int slp_memo_id = sync_agent_plugin_get_service_account_id(FW_MEMO, fw_account_id);
+
+       /*
+        * if not existed ?
+        */
+       if (slp_contact_id == -100) {
+               _set_account_id_service(FW_CONTACT, fw_account_id, slp_id);
+               int contact_index = _increase_account_count_fw(FW_CONTACT, slp_id);
+               if (contact_index < 1 || contact_index > MAX_ACCOUNT_COUNT) {
+                       _DEBUG_ERROR("[account_plugIn] _increase_account_count_fw() returned OUT OF BOUND int !!!");
+                       return;
+               }
+               _set_account_id_fw(FW_CONTACT, slp_id, contact_index, fw_account_id);
+       }
+
+       if (slp_calendar_id == -100) {
+               _set_account_id_service(FW_CALENDAR, fw_account_id, slp_id);
+               int calendar_index = _increase_account_count_fw(FW_CALENDAR, slp_id);
+               if (calendar_index < 1 || calendar_index > MAX_ACCOUNT_COUNT) {
+                       _DEBUG_ERROR("[account_plugIn] _increase_account_count_fw() returned OUT OF BOUND int !!!");
+                       return;
+               }
+               _set_account_id_fw(FW_CALENDAR, slp_id, calendar_index, fw_account_id);
+       }
+
+       if (slp_memo_id == -100) {
+               _set_account_id_service(FW_MEMO, fw_account_id, slp_id);
+               int memo_index = _increase_account_count_fw(FW_MEMO, slp_id);
+               if (memo_index < 1 || memo_index > MAX_ACCOUNT_COUNT) {
+                       _DEBUG_ERROR("[account_plugIn] _increase_account_count_fw() returned OUT OF BOUND int !!!");
+                       return;
+               }
+               _set_account_id_fw(FW_MEMO, slp_id, memo_index, fw_account_id);
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_platform_account_service(int fw_account_id, int service_type, int service_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _set_account_id_service(service_type, fw_account_id, service_account_id);
+
+       int service_index = _increase_account_count_fw(service_type, service_account_id);
+       if (service_index < 1 || service_index > MAX_ACCOUNT_COUNT) {
+               _DEBUG_ERROR("[account_plugIn] _increase_account_count_fw() returned OUT OF BOUND int !!!");
+               return;
+       }
+       _set_account_id_fw(service_type, service_account_id, service_index, fw_account_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_delete_platform_account(int fw_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("fw_account_id = %d", fw_account_id);
+       int deleted = 0;
+
+       int i = 0;
+       for (; i < FW_CONTENT_COUNT; i++) {
+
+               deleted = 0;
+               int service_account_id = sync_agent_plugin_get_service_account_id(i, fw_account_id);
+               _DEBUG_INFO("service_account_id =%d", service_account_id);
+
+               _unset_account_id_service(i, fw_account_id);
+
+               int count = _get_account_count_fw(i, service_account_id);
+               if (count < 0 || count > MAX_ACCOUNT_COUNT) {
+                       _DEBUG_ERROR("[account_plugIn] _get_account_count_fw() returned OUT OF BOUND int !!!");
+                       return;
+               }
+
+               _DEBUG_INFO("count =%d", count);
+               int k = 0;
+               for (; k < count; k++) {
+                       int target_fw_account_id = sync_agent_plugin_get_fw_account_id(i, service_account_id, k);
+                       _DEBUG_INFO("target_fw_account_id =%d", target_fw_account_id);
+                       if (target_fw_account_id == fw_account_id) {
+                               _unset_account_id_fw(i, service_account_id, k);
+                               _decrease_account_count_fw(i, service_account_id);
+                               _DEBUG_INFO("deleted !!!");
+                               deleted = 1;
+                       } else {
+                               if (deleted == 1)
+                                       _arrange_account_id_fw(i, service_account_id, k, target_fw_account_id);
+                       }
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_delete_platform_account_service(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _unset_account_id_service(service_type, fw_account_id);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_has_platform_account_service(int fw_account_id, int service_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int result = sync_agent_plugin_get_service_account_id(service_type, fw_account_id);
+       if (result == -100) {
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 1;
+}
+
+EXPORT_API int sync_agent_plugin_get_service_account_id(int service_type, int fw_account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int service_account_id;
+       _DEBUG_INFO("[account_plugIn] service_type : %d\n", service_type);
+       _DEBUG_INFO("[account_plugIn] fw_account_id : %d\n", fw_account_id);
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_SERVICE_ACCOUNT_ID, agent_name, service_type, fw_account_id);
+
+       if (!sync_agent_get_int_from_file(path, &service_account_id)) {
+               _DEBUG_ERROR("[account_plugIn] __get_int_from_file FAIL\n");
+               return -100;
+       }
+
+       _DEBUG_INFO("[account_plugIn] path : %s\n", path);
+       _DEBUG_INFO("[account_plugIn] service_account_id : %d\n", service_account_id);
+
+       _EXTERN_FUNC_EXIT;
+
+       return service_account_id;
+}
+
+EXPORT_API int sync_agent_plugin_get_fw_account_id(int service_type, int service_account_id, int index)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_ID, agent_name, service_type, service_account_id, index);
+
+       int fw_account_id;
+       if (!sync_agent_get_int_from_file(path, &fw_account_id)) {
+               _DEBUG_ERROR("[account_plugIn] __get_int_from_file FAIL\n");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return fw_account_id;
+}
+
+EXPORT_API int sync_agent_plugin_get_service_account_info(int fw_account_id, int service_type, sync_agent_service_account_info_s ** account_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(*account_info == NULL, 0, "*account_info is NULL. FAIL !!!");
+
+       int service_account_id = sync_agent_plugin_get_service_account_id(service_type, fw_account_id);
+       _DEBUG_INFO("[account_plugIn] service_account_id : %d\n", service_account_id);
+       if (service_account_id == -100) {
+               return 0;
+       }
+
+       int result = _get_account_info(service_account_id, account_info);
+
+       if (result == 1) {
+               _DEBUG_INFO("[account_plugIn] account_info->type : %d\n", (*account_info)->type);
+               _DEBUG_INFO("[account_plugIn] account_info->email : %s\n", (*account_info)->email);
+       } else {
+               _DEBUG_ERROR("[account_plugIn] account_info is empty\n");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 1;
+}
+
+/******************************************* Impl static function ********************************************/
+
+static void _set_account_id_service(int service_type, int fw_account_id, int service_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_SERVICE_ACCOUNT_ID, agent_name, service_type, fw_account_id);
+
+       if (!sync_agent_set_int_into_file(path, service_account_id))
+               _DEBUG_ERROR("[account_plugIn] __set_int_into_file FAIL\n");
+
+       _DEBUG_TRACE("\n[account_plugIn] Sucess __set_int_into_file\n");
+       _DEBUG_TRACE("[account_plugIn] service_type : %d, fw_account_id : %d, service_account_id : %d\n\n", service_type, fw_account_id, service_account_id);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _arrange_account_id_fw(int service_type, int service_account_id, int index, int fw_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(index < 0, "index = %d", index);
+       _DEBUG_INFO("service_type = %d", service_type);
+       _DEBUG_INFO("service_account_id = %d", service_account_id);
+       _DEBUG_INFO("index = %d", index);
+       _DEBUG_INFO("fw_account_id = %d", fw_account_id);
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_ID, agent_name, service_type, service_account_id, index - 1);
+
+       if (!sync_agent_set_int_into_file(path, fw_account_id)) {
+               _DEBUG_ERROR("[account_plugIn] __set_int_into_file FAIL\n");
+               return;
+       }
+
+       _unset_account_id_fw(service_type, service_account_id, index);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _set_account_id_fw(int service_type, int service_account_id, int count, int fw_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("count : %d", count);
+
+       char path[100] = { 0 };
+
+       int index = 0;
+       for (; index < count; index++) {
+               int i = 0;
+               for (; i < 100; i++) {
+                       path[i] = 0;
+               }
+
+               int data;
+               snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_ID, agent_name, service_type, service_account_id, index);
+               _DEBUG_TRACE("================== 01 [%s]\n", path);
+               if (!sync_agent_get_int_from_file(path, &data)) {
+                       _DEBUG_TRACE("================== 02\n");
+                       break;
+               }
+       }
+
+       if (!sync_agent_set_int_into_file(path, fw_account_id)) {
+               _DEBUG_ERROR("[account_plugIn] __set_int_into_file FAIL\n");
+               return;
+       }
+
+       _DEBUG_TRACE("\n[account_plugIn] Sucess __set_int_into_file\n");
+       _DEBUG_TRACE("[account_plugIn] service_type : %d, service_account_id : %d, fw_account_id[%d] : %d\n\n", service_type, service_account_id, index, fw_account_id);
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _increase_account_count_fw(int service_type, int service_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_COUNT, agent_name, service_type, service_account_id);
+
+       int fw_account_count;
+       if (!sync_agent_get_int_from_file(path, &fw_account_count)) {
+               _DEBUG_TRACE("[account_plugIn] first added\n");
+               if (!sync_agent_set_int_into_file(path, 1))
+                       _DEBUG_ERROR("[account_plugIn] __set_int_into_file FAIL\n");
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       }
+
+       if (fw_account_count < 1 || fw_account_count > MAX_ACCOUNT_COUNT) {
+               _DEBUG_ERROR("[account_plugIn] Out of MAX_ACCOUNT_COUNT range !!!");
+               return -1;
+       }
+
+       if (!sync_agent_set_int_into_file(path, fw_account_count + 1))
+               _DEBUG_ERROR("[account_plugIn] __set_int_into_file FAIL\n");
+
+       _INNER_FUNC_EXIT;
+
+       return fw_account_count + 1;
+
+}
+
+static int _get_account_count_fw(int service_type, int service_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_COUNT, agent_name, service_type, service_account_id);
+
+       int fw_account_count;
+       if (!sync_agent_get_int_from_file(path, &fw_account_count)) {
+               _DEBUG_ERROR("[account_plugIn] empty\n");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return fw_account_count;
+}
+
+static void _unset_account_id_service(int service_type, int fw_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_SERVICE_ACCOUNT_ID, agent_name, service_type, fw_account_id);
+
+       if (!sync_agent_unset_file(path))
+               _DEBUG_ERROR("[account_plugIn] __unset_file FAIL\n");
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _unset_account_id_fw(int service_type, int service_account_id, int index)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_ID, agent_name, service_type, service_account_id, index);
+
+       if (!sync_agent_unset_file(path)) {
+               _DEBUG_ERROR("[account_plugIn] __unset_file FAIL : %s\n", path);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _decrease_account_count_fw(int service_type, int service_account_id)
+{
+       _INNER_FUNC_ENTER;
+
+       char path[100];
+       snprintf(path, sizeof(path), ACCOUNT_ID_FW_ACCOUNT_COUNT, agent_name, service_type, service_account_id);
+
+       int fw_account_count = 0;
+       if (!sync_agent_get_int_from_file(path, &fw_account_count)) {
+               _DEBUG_ERROR("[account_plugIn] attempt delete when empty\n");
+               return 0;
+       }
+
+       if (fw_account_count < 1 || fw_account_count > MAX_ACCOUNT_COUNT) {
+               _DEBUG_ERROR("[account_plugIn] Out of MAX_ACCOUNT_COUNT range !!!");
+               return -1;
+       }
+
+       fw_account_count = fw_account_count - 1;
+
+       if (fw_account_count == 0) {
+               if (!sync_agent_unset_file(path)) {
+                       _DEBUG_ERROR("[account_plugIn] __unset_file FAIL : %s\n", path);
+               }
+               return 0;
+       }
+
+       if (!sync_agent_set_int_into_file(path, fw_account_count))
+               _DEBUG_ERROR("[account_plugIn] vconf_set_id FAIL\n");
+
+       _INNER_FUNC_EXIT;
+
+       return fw_account_count;
+}
+
+static int _get_account_info(int service_account_id, sync_agent_service_account_info_s ** account_info)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(*account_info == NULL, 0, "*account_info is NULL. FAIL !!!");
+
+       if (service_account_id == -1) {
+               (*account_info)->email = 0;
+               (*account_info)->type = SYNC_AGENT_ACC_TYPE_LOCAL;
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       }
+
+       char *domain_name = 0;
+       char *email = 0;
+       account_h account_handle = 0;
+
+       int error_code = account_connect();
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_connect()");
+               goto error_part2;
+       }
+
+       account_create(&account_handle);
+       error_code = account_query_account_by_account_id(service_account_id, &account_handle);
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_query_account_by_account_id()");
+               goto error_part1;
+       }
+
+       error_code = account_get_domain_name(account_handle, &domain_name);
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_get_domain_name()");
+               goto error_part1;
+       }
+
+       if (!strcmp(domain_name, "Gmail")) {
+               (*account_info)->type = SYNC_AGENT_ACC_TYPE_GOOGLE;
+       } else if (!strcmp(domain_name, "exchange")) {
+               (*account_info)->type = SYNC_AGENT_ACC_TYPE_EAS;
+       } else {
+               (*account_info)->type = SYNC_AGENT_ACC_TYPE_NONE;
+       }
+
+       error_code = account_get_email_address(account_handle, &email);
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_get_email_address()");
+               goto error_part1;
+       }
+
+       if (email != NULL) {
+               (*account_info)->email = strdup(email);
+       }
+
+       error_code = account_destroy(account_handle);
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_destroy() = %d", error_code);
+       }
+       error_code = account_disconnect();
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_disconnect() = %d", error_code);
+               goto error_part2;
+       }
+//      if (domain_name != NULL)
+       free(domain_name);
+       if (email != NULL)
+               free(email);
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+
+ error_part1:
+
+       error_code = account_destroy(account_handle);
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_destroy() = %d", error_code);
+       }
+       error_code = account_disconnect();
+       if (error_code != ACCOUNT_ERROR_NONE) {
+               _DEBUG_ERROR("Failed to call account_disconnect() = %d", error_code);
+       }
+
+ error_part2:
+
+       if (domain_name != NULL)
+               free(domain_name);
+       if (email != NULL)
+               free(email);
+
+       _DEBUG_ERROR("Returning through ERROR_PART");
+       return 0;
+}
diff --git a/src/fw-plugins/common-public/calendar/CMakeLists.txt b/src/fw-plugins/common-public/calendar/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..5ea00f6
--- /dev/null
@@ -0,0 +1,42 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-calendar")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       calendar-service2
+                                       glib-2.0
+                                       accounts-svc
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-calendar_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-calendar_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/calendar/include/ext_datastore_info_calendar.h b/src/fw-plugins/common-public/calendar/include/ext_datastore_info_calendar.h
new file mode 100755 (executable)
index 0000000..621db33
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXT_DATASTORE_INFO_CALENDAR_H_
+#define EXT_DATASTORE_INFO_CALENDAR_H_
+
+typedef enum {
+       CALENDAR_FIELD_DB_INDEX = 1,
+       CALENDAR_FIELD_SUMMARY,
+       CALENDAR_FIELD_DESCRIPTION,
+       CALENDAR_FIELD_LOCATOIN,
+       CALENDAR_FIELD_YEAR,
+       CALENDAR_FIELD_MODEL,
+       CALENDAR_FIELD_MEMO,
+       CALENDAR_FIELD_TIMEZONE,
+       CALENDAR_FIELD_TYPE_MODEL
+} calenadr_field_e;
+
+typedef enum {
+       CALENDAR_CHILD_FIELD_BIAS = 1,
+       CALENDAR_CHILD_FIELD_DAYLIGHT,
+       CALENDAR_CHILD_FIELD_DAYLIGHT_BIAS,
+       CALENDAR_CHILD_FIELD_DAYLIGHT_BEGIN,
+       CALENDAR_CHILD_FIELD_DAYLIGHT_END,
+       CALENDAR_CHILD_FIELD_STANDARD_TIMENAME,
+       CALENDAR_CHILD_FIELD_DAYLIGHT_TIMENAME
+} calendar_child_field_e;
+
+typedef enum {
+       CALENDAR_FEATURE_APPOINTMENT = 1,
+       CALENDAR_FEATURE_ANNIVERSARY,
+       CALENDAR_FEATURE_HOLIDAY,
+       CALENDAR_FEATURE_IMPORTANT,
+       CALENDAR_FEATURE_PRIVATE,
+       CALENDAR_FEATURE_MISCELLANEOUS,
+       CALENDAR_FEATURE_TASK,
+       CALENDAR_FEATURE_MEMO
+} calendar_feature_e;
+
+#endif                         /* EXT_DATASTORE_INFO_CALENDAR_H_ */
diff --git a/src/fw-plugins/common-public/calendar/include/extern_info.h b/src/fw-plugins/common-public/calendar/include/extern_info.h
new file mode 100755 (executable)
index 0000000..4a4a486
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTERN_INFO_H_
+#define EXTERN_INFO_H_
+
+typedef enum {
+       DEFAULT_CALENDAR_FOLDER = 0,
+       USER_DEFINED_FOLDER
+} calendar_folder_type_e;
+
+#endif                         /* EXTERN_INFO_H_ */
diff --git a/src/fw-plugins/common-public/calendar/include/in_datastore_info_calendar.h b/src/fw-plugins/common-public/calendar/include/in_datastore_info_calendar.h
new file mode 100755 (executable)
index 0000000..587d3f5
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_DATASTORE_INFO_CALENDAR_H_
+#define IN_DATASTORE_INFO_CALENDAR_H_
+
+/* ITEM COUNT */
+#define MAX_ITEM_COUNT_CALENDAR                65535
+
+/* TIMEZONE FIELD */
+#define VAL_TZ_BIAS                                    NULL
+#define VAL_TZ_DAYLIGHT                                NULL
+#define VAL_TZ_DAYLIGHT_BIAS           NULL
+#define VAL_TZ_DAYLIGHT_BEGIN          NULL
+#define VAL_TZ_DAYLIGHT_END                    NULL
+#define VAL_TZ_STANDARD_TIMENAME       NULL
+#define VAL_TZ_DAYLIGHT_TIMENAME       NULL
+
+/* CALENDAR INFO */
+#define MAX_LEN_SUMMARY                                65535
+#define MAX_LEN_DESCRIPTION                    65535
+#define MAX_LEN_LOCATION                       65535
+#define MIN_PERIOD_YEAR                                1902
+#define MAX_PERIOD_YEAR                                2037
+#define MAX_LEN_MEMO                           FALSE
+#define VAL_TYPE_MODEL                         "A"
+
+/* FEATURE */
+#define IF_SUPPORT_APPOINTMENT         TRUE
+#define IF_SUPPORT_ANNIVERSARY         FALSE
+#define IF_SUPPORT_HOLIDAY                     FALSE
+#define IF_SUPPORT_IMPORTANT           FALSE
+#define IF_SUPPORT_PRIVATE                     FALSE
+#define IF_SUPPORT_MISCELLANEOUS       FALSE
+#define IF_SUPPORT_TASK                                FALSE
+#define IF_SUPPORT_MEMO                                TRUE
+
+/* FEATURE FIELD */
+#define VAL_DB_INDEX_APPOINTMENT       1
+#define VAL_DB_INDEX_ANNIVERSARY       2
+#define VAL_DB_INDEX_HOLIDAY           3
+#define VAL_DB_INDEX_IMPORTANT         4
+#define VAL_DB_INDEX_PRIVATE           5
+#define VAL_DB_INDEX_MISCELLANEOUS     6
+#define VAL_DB_INDEX_TASK                      7
+#define VAL_DB_INDEX_MEMO                      8
+
+#endif                         /* IN_DATASTORE_INFO_CALENDAR_H_ */
diff --git a/src/fw-plugins/common-public/calendar/include/item_change_info.h b/src/fw-plugins/common-public/calendar/include/item_change_info.h
new file mode 100755 (executable)
index 0000000..3b33952
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ITEM_CHANGE_INFO_H_
+#define ITEM_CHANGE_INFO_H_
+
+int get_calendar_time_stamp(void);
+
+int set_calendar_time_stamp(int setting_time);
+
+#endif                         /* ITEM_CHANGE_INFO_H_ */
diff --git a/src/fw-plugins/common-public/calendar/src/item_change_info.c b/src/fw-plugins/common-public/calendar/src/item_change_info.c
new file mode 100755 (executable)
index 0000000..19c8c6a
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <time.h>
+
+#include "utility/sync_util.h"
+#include "item_change_info.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DA_CALENDAR"
+#endif
+
+static int calendar_time_stamp = 0;
+
+int get_calendar_time_stamp(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ((int)time(0) - 3);
+}
+
+int set_calendar_time_stamp(int setting_time)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* Critical Sectioin Start */
+       calendar_time_stamp = setting_time;
+       /* Critical Section End */
+
+       _EXTERN_FUNC_EXIT;
+
+       return setting_time;
+}
diff --git a/src/fw-plugins/common-public/calendar/src/plugin_interface.c b/src/fw-plugins/common-public/calendar/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..3ad1065
--- /dev/null
@@ -0,0 +1,1871 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <glib.h>
+#include <pthread.h>
+#include <calendar2.h>
+#include <account.h>
+
+#include "extern_info.h"
+#include "item_change_info.h"
+#include "ext_datastore_info_calendar.h"
+#include "in_datastore_info_calendar.h"
+
+/* for log */
+#include "utility/sync_util.h"
+#include "utility/fw_async_queue.h"
+#include "plugin/data_connector_interface.h"
+#include "data-adapter/agent_handler_manager.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DA_CALENDAR"
+#endif
+
+#define FW_CALENDAR    1       /* plugIn-Id */
+
+static sync_agent_util_async_queue_s *queue;
+
+static int latest_calendar_version = 0;
+
+static pthread_mutex_t lockx;
+
+static int is_noti_from_me = 0;
+
+static int is_storage_changed = 0;
+
+static sync_agent_add_item_cb_plugin callback_add_item;
+
+static sync_agent_del_item_cb_plugin callback_del_item;
+
+static sync_agent_update_item_cb_plugin callback_update_item;
+
+static sync_agent_get_account_id_list_cb_plugin callback_get_account_id_list;
+
+static void _set_is_noti_from_me(int set_flag);
+
+static int __get_is_noti_from_me(void);
+
+static void _process_calendar_change(const char *view_uri, void *user_data);
+
+static void *_rutine_calendar_change(void *);
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err);
+
+static bool _get_account_id(account_h account, void *user_data);
+
+static bool __is_calendar_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data);
+
+static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count);
+
+static sync_agent_da_return_e _get_service_event_list_by_folder_id(int folder_id, calendar_list_h * item_list, int *count);
+
+//static void _calendar_db_result_cb(int error, void *user_data);
+
+typedef struct account_id {
+       int account_id;
+       struct account_id *next;
+} account_id_s;
+
+//static void _calendar_db_result_cb(int error, void *user_data)
+//{
+//      _INNER_FUNC_ENTER;
+//      _DEBUG_TRACE("error = %d", error);
+//      _INNER_FUNC_EXIT;
+//}
+
+static sync_agent_da_return_e _get_service_event_list_by_folder_id(int folder_id, calendar_list_h * item_list, int *count)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = 0;
+
+       unsigned int ids[1];
+       calendar_query_h query = NULL;
+       calendar_filter_h filter = NULL;
+       calendar_list_h list = NULL;
+
+       // start pre condition
+       service_ret = calendar_query_create(_calendar_event._uri, &query);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_create Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_filter_create(_calendar_event._uri, &filter);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_create Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, folder_id);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_add_int Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       // end pre condition
+
+       service_ret = calendar_query_set_filter(query, filter);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_filter Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       ids[0] = _calendar_event.id;
+       service_ret = calendar_query_set_projection(query, ids, 1);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_projection Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_db_get_records_with_query Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_list_get_count(list, count);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       _DEBUG_INFO("count(%d)", *count);
+
+       service_ret = calendar_list_first(list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+       calendar_filter_destroy(filter);
+       calendar_query_destroy(query);
+
+       *item_list = list;
+       return ret;
+       _INNER_FUNC_EXIT;
+}
+
+static sync_agent_da_return_e _get_service_folder_list_by_account_id(int account_id, calendar_list_h * item_list, int *count)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = 0;
+
+       unsigned int ids[1];
+       calendar_query_h query = NULL;
+       calendar_filter_h filter = NULL;
+       calendar_list_h list = NULL;
+
+       // start pre condition
+       service_ret = calendar_query_create(_calendar_book._uri, &query);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_create Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_filter_create(_calendar_book._uri, &filter);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_create Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_filter_add_int(filter, _calendar_book.account_id, CALENDAR_MATCH_EQUAL, account_id);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_filter_add_int Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       // end pre condition
+
+       service_ret = calendar_query_set_filter(query, filter);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_filter Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       ids[0] = _calendar_book.id;
+       service_ret = calendar_query_set_projection(query, ids, 1);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_query_set_projection Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       service_ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_db_get_records_with_query Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       service_ret = calendar_list_get_count(list, count);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+       _DEBUG_INFO("count(%d)", *count);
+
+       service_ret = calendar_list_first(list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+ DACI_FINISH:
+       calendar_filter_destroy(filter);
+       calendar_query_destroy(query);
+
+       *item_list = list;
+       return ret;
+       _INNER_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = calendar_connect_on_thread();
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = calendar_disconnect_on_thread();
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_begin_transaction(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       _DEBUG_INFO("[da_calendar_plugIn] not anymore need to transaction");
+
+       _set_is_noti_from_me(1);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_end_transaction(int is_success)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calendar_plugIn] SLP Calendar Service is not supported Rollback Operation!\n");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_INFO("[da_calendar_plugIn] in calendar Success!\n");
+       if (is_storage_changed == 0) {
+               _DEBUG_INFO("calendar storaged was not Changed!!");
+               _set_is_noti_from_me(0);
+       }
+       is_storage_changed = 0;
+       _DEBUG_INFO("[da_calendar_plugIn] not anymore need to transaction, is_success : [%d]", is_success);
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = 0;
+
+       calendar_record_h item = (calendar_record_h) data;
+
+       int un_type = 0;
+       memcpy(&un_type, item, 4);
+       int int_folder_id = atoi(folder_id);
+       _DEBUG_INFO("[da_calendar_plugIn] calendar type %d, in %d, folder id [%d]", un_type, item, int_folder_id);
+
+       /* setting folder id */
+       service_ret = calendar_record_set_int(item, _calendar_event.calendar_book_id, int_folder_id);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_record_set_int() Fail! : err = %d", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_struct_set_int(folder %d) return [%d]!\n", atoi(folder_id), service_ret);
+
+       /* add item */
+       int slp_cal_info_id = 0;
+       service_ret = calendar_db_insert_record(item, &slp_cal_info_id);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_db_insert_record() Fail! : err = %d", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               *item_id = 0;
+               goto DACI_FINISH;
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_insert() Success!");
+               _DEBUG_INFO("calendar_svc_insert() Success!: id = %d", slp_cal_info_id);
+               *item_id = g_strdup_printf("%d", slp_cal_info_id);
+               is_storage_changed = 1;
+       }
+ DACI_FINISH:
+       /*  memory free */
+//      if (item != NULL){
+       service_ret = calendar_record_destroy(item, false);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", service_ret);
+       }
+       item = NULL;
+//      }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       calendar_record_h item = (calendar_record_h) data;
+       int int_folder_id = atoi(folder_id);
+
+       /* setting folder id */
+       int service_ret = calendar_record_set_int(item, _calendar_event.calendar_book_id, int_folder_id);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_record_set_int() Fail! : err = %d", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+
+       /*  update item */
+       err = calendar_db_update_record(item);
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] calendar_svc_update() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_update() Success!");
+               is_storage_changed = 1;
+       }
+
+       /*  memory free */
+ DACI_FINISH:
+       /*  memory free */
+       if (item != NULL) {
+               calendar_record_destroy(item, false);
+               if (err != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+               }
+               item = NULL;
+       }
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       /*  delete item  */
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = calendar_db_delete_record(_calendar_event._uri, atoi(item_id));
+
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Fail!");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Success!");
+               is_storage_changed = 1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 1;
+
+       int folder_id_list_cnt = 0;
+       int *folder_type_list;
+       char **folder_id_list = 0;
+       int service_ret = 0;
+
+       int item_id = 0;
+       int *calendar_id_list = 0;
+       calendar_list_h event_list = NULL;
+
+       /* get folder id list for account id */
+       folder_id_list = sync_agent_plugin_get_folder_id_list(account_id, &folder_id_list_cnt, &folder_type_list);
+       if (folder_id_list == NULL || folder_id_list_cnt == 0) {
+               _DEBUG_INFO("[da_calendar_plugIn] folder id list cnt : %d", folder_id_list_cnt);
+               return SYNC_AGENT_DA_ERR_NO_DATA;
+       }
+
+       int folder_iter = 0;
+       for (; folder_iter < folder_id_list_cnt; folder_iter++) {
+               int int_folder_id = atoi(folder_id_list[folder_iter]);
+               _DEBUG_INFO("[da_calendar_plugIn] folder id : %d\n", int_folder_id);
+               int event_count = 0;
+               ret = _get_service_event_list_by_folder_id(int_folder_id, &event_list, &event_count);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("_get_service_folder_list_by_account_id failed !!!");
+                       continue;
+               } else if (event_count == 0) {
+                       _DEBUG_INFO("_get_service_folder_list_by_account_id no list");
+                       continue;
+               }
+
+               int event_list_count = 0;
+               service_ret = calendar_list_get_count(event_list, &event_list_count);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+                       continue;
+               }
+               _DEBUG_TRACE("recode list count = %d", event_list_count);
+               if (event_list_count == 0) {
+                       continue;
+               }
+               calendar_id_list = (int *)calloc(event_list_count, sizeof(int));
+//              int count = 0;
+               do {
+                       calendar_record_h event = NULL;
+
+                       item_id = -1;
+                       event = NULL;
+                       service_ret = calendar_list_get_current_record_p(event_list, &event);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_current_record_p Fail!\n");
+                               ret = _convert_service_error_to_common_error(service_ret);
+                               continue;
+                       }
+                       service_ret = calendar_record_get_int(event, _calendar_event.id, &item_id);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_record_get_int Fail!\n");
+                               ret = _convert_service_error_to_common_error(service_ret);
+                               continue;
+                       }
+                       _DEBUG_INFO("[da_calendar_plugIn] item id : %d\n", item_id);
+
+//                      calendar_id_list[count] = item_id;
+//                      ++count;
+
+                       err = calendar_db_delete_record(_calendar_event._uri, item_id);
+                       if (err != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_calendar_plugIn] calendar_svc_delete(%d) Fail!\n", item_id);
+                               ret = _convert_service_error_to_common_error(err);
+                               goto DACI_FINISH;
+                       } else {
+                               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete(%d) Success!\n", item_id);
+                               is_storage_changed = 1;
+                       }
+
+               } while (calendar_list_next(event_list) != CALENDAR_ERROR_NO_DATA);
+
+//              int i = 0;
+//              for( ; i < count; i++) {
+//                      _DEBUG_INFO("%d = %d", i, calendar_id_list[i]);
+//              }
+//              /* delete items */
+//              service_ret = calendar_db_delete_records(_calendar_event._uri, calendar_id_list, event_list_count, _calendar_db_result_cb, NULL);
+//              if (service_ret != CALENDAR_ERROR_NONE) {
+//                      _DEBUG_ERROR("[da_calendar_plugIn] calendar_db_delete_records Fail!\n");
+//                      ret = _convert_service_error_to_common_error(service_ret);
+//                      goto DACI_FINISH;
+//              } else {
+//                      _DEBUG_INFO("[da_calendar_plugIn] calendar_db_delete_records Success!\n");
+//                      is_storage_changed = 1;
+//              }
+//              if(calendar_id_list != NULL){
+//                      free(calendar_id_list);
+//                      calendar_id_list = NULL;
+//              }
+
+               if (event_list != NULL) {
+                       err = calendar_list_destroy(event_list, true);
+                       if (err != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+                       }
+                       event_list = NULL;
+               }
+       }
+
+ DACI_FINISH:
+       /* memory free */
+       if (calendar_id_list != NULL) {
+               free(calendar_id_list);
+               calendar_id_list = NULL;
+       }
+
+       if (event_list != NULL) {
+               err = calendar_list_destroy(event_list, true);
+               if (err != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+               }
+               event_list = NULL;
+       }
+
+       if (folder_id_list != NULL) {
+               int cnt = 0;
+               for (cnt = 0; cnt < folder_id_list_cnt; cnt++) {
+                       if (folder_id_list[cnt] != NULL) {
+                               free(folder_id_list[cnt]);
+                               _DEBUG_INFO("[da_calendar_plugIn] folder id free !! \n");
+                       }
+               }
+               cfree(folder_id_list);
+               _DEBUG_INFO("[da_calendar_plugIn] folder id list free !! \n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       calendar_record_h item = 0;
+
+       /* get item */
+       err = calendar_db_get_record(_calendar_event._uri, atoi(item_id), &item);
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *data = 0;
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_get() Success!\n");
+               *data = (void *)item;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_name is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       calendar_record_h folder = 0;
+
+       /* new service struct */
+       int calendar_ret = CALENDAR_ERROR_NONE;
+       calendar_ret = calendar_record_create(_calendar_book._uri, &folder);
+       if(calendar_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_record_create() = %d Fail!\n", calendar_ret);
+               *folder_id = 0;
+               return SYNC_AGENT_DA_ERRORS;
+       }
+       if (folder == NULL) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_struct_new() Fail!\n");
+               *folder_id = 0;
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /* setting folder data */
+       int cal_ret = calendar_record_set_int(folder, _calendar_book.account_id, account_id);
+       if (cal_ret != CALENDAR_ERROR_NONE) {
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+       cal_ret = calendar_record_set_int(folder, _calendar_book.visibility, 1);
+       if (cal_ret != CALENDAR_ERROR_NONE) {
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+       cal_ret = calendar_record_set_str(folder, _calendar_book.name, folder_name);
+       if (cal_ret != CALENDAR_ERROR_NONE) {
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+
+       /* add folder */
+       int service_folder_item_id = 0;
+       cal_ret = calendar_db_insert_record(folder, &service_folder_item_id);
+       if (cal_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_insert() Fail!\n");
+               ret = _convert_service_error_to_common_error(cal_ret);
+               *folder_id = 0;
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_insert() Success!");
+               *folder_id = g_strdup_printf("%d", service_folder_item_id);
+               is_storage_changed = 1;
+       }
+ DACI_FINISH:
+       /*  memory free */
+       if (folder != NULL) {
+               calendar_record_destroy(folder, false);
+               if (err != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+               }
+               folder = NULL;
+       }
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+
+       /* delete folder */
+       err = calendar_db_delete_record(_calendar_book._uri, atoi(folder_id));
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_db_delete_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_delete() Success!\n");
+               calendar_db_clean_after_sync(atoi(folder_id));
+               is_storage_changed = 1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       calendar_record_h folder = 0;
+
+       /* get item */
+       int calendar_folder_id = atoi(folder_id);
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_folder_id : %d\n", calendar_folder_id);
+       err = calendar_db_get_record(_calendar_book._uri, calendar_folder_id, &folder);
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *out_folder_name = 0;
+               *out_folder_type = -1;
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Success!\n");
+               *out_folder_name = 0;
+               calendar_record_get_str(folder, _calendar_book.name, out_folder_name);
+               *out_folder_type = DEFAULT_CALENDAR_FOLDER;
+       }
+
+       /*  memory free */
+       if (folder != NULL) {
+               calendar_record_destroy(folder, false);
+               if (err != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+               }
+               folder = NULL;
+       }
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_execute(int account_ID, const char *execute_key, void *execute_values, void **result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calendar_plugIn] service is not supported execute. \n");
+       *result = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 0;
+       int used_cnt = 0;
+       int err = calendar_db_get_count(_calendar_event._uri, &used_cnt);
+       if (err != CALENDAR_ERROR_NONE) {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_count() Fail\n");
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_count() Success\n");
+               _DEBUG_INFO("[da_calendar_plugIn] used_count = %d\n", used_cnt);
+               ret = used_cnt;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+       int ret = 0;
+
+       calendar_filter_h filter = NULL;
+       calendar_query_h query = NULL;
+       ret = calendar_query_create(_calendar_event._uri, &query);
+       // end pre condition
+       ret = calendar_filter_create(_calendar_event._uri, &filter);
+       ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id, CALENDAR_MATCH_EQUAL, atoi(folder_id));
+       // end pre condition
+
+       ret = calendar_query_set_filter(query, filter);
+
+       int used_cnt = 0;
+       ret = calendar_db_get_count_with_query(query, &used_cnt);
+       if (ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] calendar_db_get_count() Fail\n");
+       } else {
+               _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_count() Success\n");
+               _DEBUG_INFO("[da_calendar_plugIn] used_count = %d\n", used_cnt);
+       }
+
+       if (filter != NULL)
+               calendar_filter_destroy(filter);
+       if (query != NULL)
+               calendar_query_destroy(query);
+
+       _EXTERN_FUNC_EXIT;
+
+       return used_cnt;
+}
+
+EXPORT_API char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char **folder_id_list = 0;
+       int count = 0;
+       calendar_list_h service_folder_list = 0;
+       calendar_record_h folder = NULL;
+       int err = 0;
+       int i = 0;
+       *folder_count = 0;
+
+       _DEBUG_INFO("account_id [%d]", account_id);
+
+       err = _get_service_folder_list_by_account_id(account_id, &service_folder_list, &count);
+       if (err != SYNC_AGENT_DA_SUCCESS || count == 0) {
+               _DEBUG_ERROR("_get_service_folder_list_by_account_id failed !!!");
+               return NULL;
+       }
+       if (count > 0) {
+               folder_id_list = (char **)calloc(count, sizeof(char *));
+               if (folder_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               *folder_type_list = (int *)calloc(count, sizeof(int));
+               if (*folder_type_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+
+               /* find */
+               do {
+                       /* get */
+                       err = calendar_list_get_current_record_p(service_folder_list, &folder);
+                       if ((err != CALENDAR_ERROR_NONE) && (folder == NULL)) {
+                               _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", err);
+                               break;
+                       }
+
+                       /* check */
+                       int int_folder_id = 0;
+                       err = calendar_record_get_int(folder, _calendar_book.id, &int_folder_id);
+                       folder_id_list[i] = g_strdup_printf("%d", int_folder_id);
+                       (*folder_type_list)[i] = DEFAULT_CALENDAR_FOLDER;
+                       i++;
+                       *folder_count = i;
+
+//                      if (folder != NULL){
+//                              calendar_record_destroy(folder, false);
+//                              if (err != CALENDAR_ERROR_NONE) {
+//                                      _DEBUG_ERROR("calendar_record_destroy() Fail! : err = %d", err);
+//                              }
+//                              folder = NULL;
+//                      }
+
+               } while (calendar_list_next(service_folder_list) != CALENDAR_ERROR_NO_DATA);
+       }
+       /* memory free */
+       if (service_folder_list != NULL) {
+               err = calendar_list_destroy(service_folder_list, true);
+               if (err != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", err);
+               }
+               service_folder_list = NULL;
+       }
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id_list;
+}
+
+EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calendar_plugIn] start!!\n");
+
+       int error_code = account_connect();
+
+       account_id_s *account_info_list = (account_id_s *) calloc(1, sizeof(account_id_s));
+       if (account_info_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+       account_info_list->account_id = -1;
+       account_info_list->next = 0;
+
+       account_foreach_account_from_db(_get_account_id, account_info_list);
+
+       *count = 0;
+       account_id_s *cursor_ptr = account_info_list;
+       while (cursor_ptr != 0) {
+               cursor_ptr = cursor_ptr->next;
+               (*count)++;
+       }
+
+       int *id_list = 0;
+
+       if ((*count) > 0) {
+               id_list = (int *)calloc(*count, sizeof(int));
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       free(account_info_list);
+                       _EXTERN_FUNC_EXIT;
+                       return NULL;
+               }
+               cursor_ptr = account_info_list;
+               int i = 0;
+               while (cursor_ptr != 0) {
+                       id_list[i] = cursor_ptr->account_id;
+                       cursor_ptr = cursor_ptr->next;
+                       i++;
+               }
+       }
+
+       free(account_info_list);
+
+       error_code = account_disconnect();
+
+       _DEBUG_INFO("[da_calendar_plugIn] end!!\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int changepoint, int *changeCount)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calendar_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", changepoint);
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int calendarTimeStamp = changepoint;
+       int current_change_point = 0;
+       int temp_folder_id = atoi(folder_id);
+       int service_ret = 0;
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+
+       calendar_list_h service_changed_list = 0;
+       calendar_record_h changed_event = NULL;
+
+       service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendarTimeStamp, &service_changed_list, &current_change_point);
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+       if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+               _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       int list_count = 0;
+       service_ret = calendar_list_get_count(service_changed_list, &list_count);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+       if (list_count <= 0) {
+//              ret =SYNC_AGENT_DA_ERR_NO_DATA;
+               goto DACI_FINISH;
+       }
+//      service_ret = calendar_svc_iter_next(iter);
+       service_ret = calendar_list_first(service_changed_list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_svc_iter_next service_ret : %d\n", service_ret);
+
+       do {
+               _DEBUG_INFO("while start");
+
+               service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_event);
+               if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
+                       _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+                       ret = SYNC_AGENT_DA_ERRORS;
+                       goto DACI_FINISH;
+               }
+               int type = 0;
+               service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                       break;
+               }
+
+               _DEBUG_INFO("[da_calendar_plugIn] type is [%d]", type);
+               if (type == CALENDAR_EVENT_MODIFIED_STATUS_INSERTED) {
+                       int calendar_id = 0;
+                       service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.id, &calendar_id);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                               break;
+                       }
+                       _DEBUG_INFO("[da_calendar_plugIn] calendar id is [%d]", calendar_id);
+                       char *calendar_id_str = g_strdup_printf("%d", calendar_id);
+                       _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_INSERTED : [%s]\n", calendar_id_str);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               root_ptr->item_id = calendar_id_str;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               cursor_ptr->next->item_id = calendar_id_str;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+
+               }
+
+               /*if list can successfully free child than dont need this free */
+//              if (changed_event != NULL)
+//                      calendar_record_destroy(changed_event, true);
+       } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+       if (service_changed_list != NULL) {
+               calendar_list_destroy(service_changed_list, true);
+               service_changed_list = NULL;
+       }
+
+       *changeCount = chagned_count;
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calendar_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", change_point);
+       int current_change_point = 0;
+       int calendar_time_stamp = change_point;
+       int temp_folder_id = atoi(folder_id);
+       int service_ret = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+
+       calendar_list_h service_changed_list = 0;
+       calendar_record_h changed_event = NULL;
+
+       service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendar_time_stamp, &service_changed_list, &current_change_point);
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+       if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+               _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       int list_count = 0;
+       service_ret = calendar_list_get_count(service_changed_list, &list_count);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+       if (list_count <= 0) {
+               goto DACI_FINISH;
+       }
+
+       service_ret = calendar_list_first(service_changed_list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+       _DEBUG_INFO("[da_calendar_plugIn] service_ret : %d\n", service_ret);
+
+       do {
+
+               service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_event);
+               if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
+                       _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+                       ret = SYNC_AGENT_DA_ERRORS;
+                       goto DACI_FINISH;
+               }
+
+               int type = 0;
+               service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                       break;
+               }
+               if (type == CALENDAR_EVENT_MODIFIED_STATUS_DELETED) {
+                       int calendar_id = 0;
+                       service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.id, &calendar_id);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                               break;
+                       }
+                       char *calendar_id_str = g_strdup_printf("%d", calendar_id);
+                       _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_DELETED : [%s]\n", calendar_id_str);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               root_ptr->item_id = calendar_id_str;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               cursor_ptr->next->item_id = calendar_id_str;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+
+               /*if list can successfully free child than dont need this free */
+//              if (changed_event != NULL)
+//                      calendar_record_destroy(changed_event, true);
+       } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+       if (service_changed_list != NULL) {
+               calendar_list_destroy(service_changed_list, true);
+               service_changed_list = NULL;
+       }
+
+       *change_count = chagned_count;
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("\n[da_calendar_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_calendar_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_calendar_plugIn] changepoint : %d\n", change_point);
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int calendar_time_stamp = change_point;
+       int temp_folder_id = atoi(folder_id);
+       int service_ret = 0;
+
+       calendar_list_h service_changed_list = 0;
+       calendar_record_h changed_event = NULL;
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+       int current_change_point = 0;
+       service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, temp_folder_id, calendar_time_stamp, &service_changed_list, &current_change_point);
+       _DEBUG_INFO("[da_calendar_plugIn] calendar_db_get_changes_by_version service_ret : %d, input folder id [%d], current change point [%d]", service_ret, temp_folder_id, current_change_point);
+       if ((service_ret != CALENDAR_ERROR_NONE) && (service_changed_list == NULL)) {
+               _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail! : err = %d", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       int list_count = 0;
+       service_ret = calendar_list_get_count(service_changed_list, &list_count);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calendar_plugIn] in calendar_list_get_count Fail!\n");
+               ret = _convert_service_error_to_common_error(service_ret);
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_calendar_plugIn] in calendar_list_get_count [%d]!", list_count);
+       if (list_count <= 0) {
+               goto DACI_FINISH;
+       }
+
+       service_ret = calendar_list_first(service_changed_list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_calendar_plugIn] service_ret : %d\n", service_ret);
+
+       do {
+               service_ret = calendar_list_get_current_record_p(service_changed_list, &changed_event);
+               if ((service_ret != CALENDAR_ERROR_NONE) && (changed_event == NULL)) {
+                       _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+                       ret = SYNC_AGENT_DA_ERRORS;
+                       goto DACI_FINISH;
+               }
+               int type = 0;
+               service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.modified_status, &type);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                       break;
+               }
+
+               if (type == CALENDAR_EVENT_MODIFIED_STATUS_UPDATED) {
+                       int calendar_id = 0;
+                       service_ret = calendar_record_get_int(changed_event, _calendar_updated_info.id, &calendar_id);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                               break;
+                       }
+                       char *calendar_id_str = g_strdup_printf("%d", calendar_id);
+                       _DEBUG_INFO("[da_calendar_plugIn] CALS_UPDATED_TYPE_MODIFIED : [%s]\n", calendar_id_str);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               root_ptr->item_id = calendar_id_str;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               cursor_ptr->next->item_id = calendar_id_str;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+
+               /*if list can successfully free child than dont need this free */
+//              if (changed_event != NULL)
+//                      calendar_record_destroy(changed_event, true);
+       } while (calendar_list_next(service_changed_list) != CALENDAR_ERROR_NO_DATA);
+
+ DACI_FINISH:
+
+       if (service_changed_list != NULL) {
+               calendar_list_destroy(service_changed_list, true);
+               service_changed_list = NULL;
+       }
+
+       *change_count = chagned_count;
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API int sync_agent_plugin_get_last_change_point(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int calendar_db_version = 0;
+       int service_ret = calendar_db_get_current_version(&calendar_db_version);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+       }
+       _EXTERN_FUNC_EXIT;
+
+       return calendar_db_version;
+}
+
+EXPORT_API void sync_agent_plugin_start_listening_change_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int service_ret = calendar_db_add_changed_cb(_calendar_event._uri, _process_calendar_change, NULL);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_db_add_changed_cb() Fail!: err = %d", service_ret);
+       }
+
+       latest_calendar_version = sync_agent_plugin_get_last_change_point();
+       _DEBUG_INFO("Current Latest Contact Version : %d", latest_calendar_version);
+
+       pthread_t thread_process_change_id;
+       if (pthread_create(&thread_process_change_id, 0, _rutine_calendar_change, 0) < 0) {
+               _DEBUG_ERROR("Calendar Change Noti Handling Thread Create Error");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_add_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_del_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_update_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_get_account_id_list = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return MAX_ITEM_COUNT_CALENDAR;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_length(int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (field_name) {
+       case CALENDAR_FIELD_SUMMARY:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_SUMMARY;
+       case CALENDAR_FIELD_DESCRIPTION:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_DESCRIPTION;
+       case CALENDAR_FIELD_LOCATOIN:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_LOCATION;
+       case CALENDAR_FIELD_MEMO:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_MEMO;
+       default:
+               _EXTERN_FUNC_EXIT;
+               return -1;
+       }
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_count(int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return -1;
+}
+
+EXPORT_API int sync_agent_plugin_get_field_value(int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (field_name) {
+       case CALENDAR_FIELD_YEAR:
+               *num_val1 = MIN_PERIOD_YEAR;
+               *num_val2 = MAX_PERIOD_YEAR;
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       case CALENDAR_FIELD_TYPE_MODEL:
+               *str_val = VAL_TYPE_MODEL;
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       case CALENDAR_FIELD_DB_INDEX:
+               switch (child_field_name) {
+               case CALENDAR_FEATURE_APPOINTMENT:
+                       *num_val1 = VAL_DB_INDEX_APPOINTMENT;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_ANNIVERSARY:
+                       *num_val1 = VAL_DB_INDEX_ANNIVERSARY;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_HOLIDAY:
+                       *num_val1 = VAL_DB_INDEX_HOLIDAY;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_IMPORTANT:
+                       *num_val1 = VAL_DB_INDEX_IMPORTANT;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_PRIVATE:
+                       *num_val1 = VAL_DB_INDEX_PRIVATE;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_MISCELLANEOUS:
+                       *num_val1 = VAL_DB_INDEX_MISCELLANEOUS;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_TASK:
+                       *num_val1 = VAL_DB_INDEX_TASK;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_FEATURE_MEMO:
+                       *num_val1 = VAL_DB_INDEX_MEMO;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               default:
+                       return -1;
+               }
+       case CALENDAR_FIELD_TIMEZONE:
+               switch (child_field_name) {
+               case CALENDAR_CHILD_FIELD_BIAS:
+                       *num_val1 = (int)VAL_TZ_BIAS;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_DAYLIGHT:
+                       *num_val1 = (int)VAL_TZ_DAYLIGHT;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_DAYLIGHT_BIAS:
+                       *num_val1 = (int)VAL_TZ_DAYLIGHT_BIAS;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_DAYLIGHT_BEGIN:
+                       *str_val = VAL_TZ_DAYLIGHT_BEGIN;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_DAYLIGHT_END:
+                       *str_val = VAL_TZ_DAYLIGHT_END;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_STANDARD_TIMENAME:
+                       *str_val = VAL_TZ_STANDARD_TIMENAME;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               case CALENDAR_CHILD_FIELD_DAYLIGHT_TIMENAME:
+                       *str_val = VAL_TZ_DAYLIGHT_TIMENAME;
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               default:
+                       return -1;
+               }
+       default:
+               return -1;
+       }
+}
+
+EXPORT_API int sync_agent_plugin_get_is_support_feature(int feature)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (feature) {
+       case CALENDAR_FEATURE_APPOINTMENT:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_APPOINTMENT;
+       case CALENDAR_FEATURE_ANNIVERSARY:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_ANNIVERSARY;
+       case CALENDAR_FEATURE_HOLIDAY:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_HOLIDAY;
+       case CALENDAR_FEATURE_IMPORTANT:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_IMPORTANT;
+       case CALENDAR_FEATURE_PRIVATE:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_PRIVATE;
+       case CALENDAR_FEATURE_MISCELLANEOUS:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_MISCELLANEOUS;
+       case CALENDAR_FEATURE_TASK:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_TASK;
+       case CALENDAR_FEATURE_MEMO:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_MEMO;
+       default:
+               return -1;
+       }
+}
+
+/********************************** static function *******************************************/
+
+static void _set_is_noti_from_me(int set_flag)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pthread_mutex_lock(&lockx)) {
+               _DEBUG_ERROR("[da_calendar_plugIn] pthread_mutex_lock error");
+       }
+
+       is_noti_from_me = set_flag;
+
+       if (pthread_mutex_unlock(&lockx)) {
+               _DEBUG_ERROR("[da_calendar_plugIn] pthread_mutex_unlock error");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int __get_is_noti_from_me(void)
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return is_noti_from_me;
+}
+
+void _process_calendar_change(const char *view_uri, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("[da_calendar_plugIn] detected calendar storage changed\n");
+
+       int from_Me = __get_is_noti_from_me();
+       if (from_Me == 1) {
+               _set_is_noti_from_me(0);
+               _DEBUG_TRACE("[da_calendar_plugIn] This noti is from Me!! so will be ignored!!\n");
+               return;
+       }
+
+       int *calendarVersion = (int *)calloc(1, sizeof(int));
+       if (calendarVersion == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return;
+       }
+       *calendarVersion = latest_calendar_version;
+       latest_calendar_version++;
+
+       _DEBUG_INFO("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+       if (sync_agent_async_queue_length(queue) < 1) {
+               sync_agent_send_msg_async_queue(queue, (void *)calendarVersion);
+               _DEBUG_INFO("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void *_rutine_calendar_change(void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("[da_calendar_plugIn] Start __rutine_Calendar_Change (create thread)\n");
+
+       /*
+        * Create Queue
+        */
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               _DEBUG_ERROR("Failed to call fw_async_queue_alloc()");
+               return 0;
+       }
+
+       calendar_list_h folder_list = NULL;
+       calendar_list_h record_list = NULL;
+       int service_ret = 0;
+
+       // open calendar service
+       sync_agent_plugin_open_service();
+
+       while (1) {
+               _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+               int *temp_calendar_version = sync_agent_receive_msg_async_queue(queue);
+               int calendar_version = *temp_calendar_version;
+               free(temp_calendar_version);
+
+               _DEBUG_TRACE("Detected Change calendarVersion : %d", calendar_version);
+
+               int account_list_count;
+               int *account_list = callback_get_account_id_list(FW_CALENDAR, &account_list_count);
+               if (account_list == NULL)
+                       return 0;
+
+               int i = 0;
+               for (; i < account_list_count; i++) {
+                       int calendar_account_id = account_list[i];
+                       _DEBUG_TRACE("[da_calendar_plugIn] calendar_account_id : %d, count : %d\n", calendar_account_id, account_list_count);
+                       _DEBUG_TRACE("[da_calendar_plugIn] Before calendar_svc_event_get_changes : %d\n", calendar_version);
+
+                       /*get folder id */
+                       int folder_list_count = 0;
+                       service_ret = _get_service_folder_list_by_account_id(calendar_account_id, &folder_list, &folder_list_count);
+                       if (service_ret != SYNC_AGENT_DA_SUCCESS || folder_list == NULL) {
+                               _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+                               break;
+                       }
+                       _DEBUG_TRACE("[da_calendar_plugIn] folder_list_count : %d", folder_list_count);
+
+                       do {
+
+                               calendar_record_h folder = NULL;
+                               service_ret = calendar_list_get_current_record_p(folder_list, &folder);
+                               if ((service_ret != CALENDAR_ERROR_NONE) && (folder == NULL)) {
+                                       _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+                                       break;
+                               }
+
+                               int calendar_folder_id = 0;
+                               service_ret = calendar_record_get_int(folder, _calendar_book.id, &calendar_folder_id);
+                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                       _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                                       break;
+                               }
+
+                               int current_cal_db_ver = 0;
+                               service_ret = calendar_db_get_changes_by_version(_calendar_event._uri, calendar_folder_id, calendar_version, &record_list, &current_cal_db_ver);
+                               if (service_ret != CALENDAR_ERROR_NONE || record_list == NULL) {
+                                       _DEBUG_ERROR("calendar_db_get_changes_by_version() Fail!: calendar_folder_id = %d, err = %d", calendar_folder_id, service_ret);
+                                       continue;
+                               }
+                               _DEBUG_TRACE("calendar_db_get_changes_by_version() Success, calendar_folderId = %d", calendar_folder_id);
+
+                               service_ret = calendar_list_first(record_list);
+                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                       _DEBUG_ERROR("calendar_list_first() Fail! : err = %d", service_ret);
+                                       break;
+                               }
+                               int recode_count = 0;
+                               service_ret = calendar_list_get_count(record_list, &recode_count);
+                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                       _DEBUG_ERROR("calendar_list_get_count() Fail! : err = %d", service_ret);
+                                       break;
+                               }
+                               _DEBUG_TRACE("recode list count = %d", recode_count);
+                               if (recode_count == 0) {
+                                       continue;
+                               }
+
+                               do {
+                                       calendar_record_h row_event = NULL;
+                                       service_ret = calendar_list_get_current_record_p(record_list, &row_event);
+                                       if ((service_ret != CALENDAR_ERROR_NONE) && (row_event == NULL)) {
+                                               _DEBUG_ERROR("calendar_list_get_current_record_p() Fail! : err = %d", service_ret);
+                                               break;
+                                       }
+
+                                       int calendar_id = 0;
+                                       service_ret = calendar_record_get_int(row_event, _calendar_updated_info.id, &calendar_id);
+                                       if (service_ret != CALENDAR_ERROR_NONE) {
+                                               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                                               break;
+                                       }
+
+                                       _DEBUG_TRACE("recode list count = %d", recode_count);
+                                       char calendar_id_str[12];
+                                       snprintf(calendar_id_str, sizeof(calendar_id_str), "%d", calendar_id);
+
+                                       int type = 0;
+                                       service_ret = calendar_record_get_int(row_event, _calendar_updated_info.modified_status, &type);
+                                       if (service_ret != CALENDAR_ERROR_NONE) {
+                                               _DEBUG_ERROR("calendar_record_get_int() Fail!: err = %d", service_ret);
+                                               break;
+                                       }
+                                       switch (type) {
+                                       case CALENDAR_EVENT_MODIFIED_STATUS_INSERTED:
+                                               {
+                                                       char calendar_folder_id_str[12];
+                                                       snprintf(calendar_folder_id_str, sizeof(calendar_folder_id_str), "%d", calendar_folder_id);
+
+                                                       _DEBUG_TRACE("[da_calendar_plugIn] Calendar Inserted!\n");
+                                                       _DEBUG_TRACE("[da_calendar_plugIn] calendar folder id : %s\n", calendar_folder_id_str);
+                                                       int result = callback_add_item(account_list[i], i, calendar_id_str, FW_CALENDAR, calendar_folder_id_str, 0);
+                                                       if (!result)
+                                                               _DEBUG_TRACE("[da_calendar_plugIn] Failed to call SA_EH_Add_Item() \n");
+                                                       else
+                                                               _DEBUG_TRACE("[da_calendar_plugIn] Success to call SA_EH_Add_Item() \n");
+
+                                               }
+                                               break;
+                                       case CALENDAR_EVENT_MODIFIED_STATUS_UPDATED:
+                                               {
+                                                       _DEBUG_TRACE("[da_calendar_plugIn] Calendar Updated!\n");
+                                                       int result = callback_update_item(account_list[i], i, calendar_id_str, FW_CALENDAR);
+                                                       if (!result)
+                                                               _DEBUG_TRACE("[da_calendar_plugIn] Failed to call callback_del_item() \n");
+                                               }
+                                               break;
+                                       case CALENDAR_EVENT_MODIFIED_STATUS_DELETED:
+                                               {
+                                                       _DEBUG_TRACE("[da_calendar_plugIn] Calendar Deleted!\n");
+                                                       int result = callback_del_item(account_list[i], i, calendar_id_str, FW_CALENDAR);
+                                                       if (!result)
+                                                               _DEBUG_TRACE("[da_calendar_plugIn] Failed to call callback_del_item() \n");
+                                               }
+                                               break;
+                                       default:
+                                               _DEBUG_TRACE("[da_calendar_plugIn] cached Another Calendar Change Noti!\n");
+                                               break;
+                                       }
+
+                                       /*if list can successfully free child than dont need this free */
+//                                      if (row_event != NULL){
+//                                              calendar_record_destroy(row_event, true);
+//                                              row_event = NULL;
+//                                      }
+
+                               } while (calendar_list_next(record_list) != CALENDAR_ERROR_NO_DATA);
+
+                               if (record_list != NULL) {
+                                       service_ret = calendar_list_destroy(record_list, true);
+                                       if (service_ret != CALENDAR_ERROR_NONE) {
+                                               _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+                                       }
+                                       record_list = NULL;
+                               }
+                               /*if list can successfully free child than dont need this free */
+//                              if (folder != NULL){
+//                                      calendar_record_destroy(folder, true);
+//                                      folder = NULL;
+//                              }
+
+                       } while (calendar_list_next(folder_list) != CALENDAR_ERROR_NO_DATA);    /*folder iter list */
+
+                       _DEBUG_TRACE("folder list free");
+                       if (folder_list != NULL) {
+                               service_ret = calendar_list_destroy(folder_list, true);
+                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                       _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+                               }
+                               folder_list = NULL;
+                       }
+
+               }               /*account loop for */
+               _DEBUG_TRACE("account list free");
+               if (account_list != NULL) {
+                       free(account_list);
+               }
+
+       }                       /*while (1) */
+
+       //  close calendar service
+       sync_agent_plugin_close_service();
+
+       _DEBUG_TRACE("[da_calendar_plugIn] End __rutine_Calendar_Change (create thread)\n");
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       case CALENDAR_ERROR_INVALID_PARAMETER:  /* -4 */
+               ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
+               break;
+
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+static bool _get_account_id(account_h account, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       account_id_s *account_info_list = user_data;
+
+       bool has_contact = FALSE;
+
+       account_get_capability_all(account, __is_calendar_id, &has_contact);
+
+       if (has_contact == FALSE) {
+               /* DO Nothing */
+               _DEBUG_INFO("has_contact is false");
+       } else {
+               char *domain_name = NULL;
+               account_error_e error_code = account_get_domain_name(account, &domain_name);
+               if (error_code != ACCOUNT_ERROR_NONE) {
+                       _DEBUG_ERROR("Failed to call account_get_domain_name()");
+                       return has_contact;
+               }
+
+               /*local service id already in id list so pass */
+               _DEBUG_INFO("domain_name = %s", domain_name);
+               if (strcmp(domain_name, "Gmail") && strcmp(domain_name, "exchange")) {
+                       _DEBUG_TRACE("domain is [%s] is not gmail&exchange");
+                       return has_contact;
+               }
+
+               account_id_s *account_info = (account_id_s *) calloc(1, sizeof(account_id_s));
+               if (account_info == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return FALSE;
+               }
+               account_get_account_id(account, &(account_info->account_id));
+               _DEBUG_TRACE("Getted accont id : %d", account_info->account_id);
+               account_info->next = 0;
+
+               account_id_s *cursor_ptr = account_info_list;
+               while (cursor_ptr->next != 0) {
+                       cursor_ptr = cursor_ptr->next;
+               }
+
+               cursor_ptr->next = account_info;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return has_contact;
+}
+
+static bool __is_calendar_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+       retvm_if(capability_type == NULL, FALSE, "capability_type is NULL !!");
+
+       bool *has_contact = user_data;
+       //if (capability_type == ACCOUNT_CAPABILITY_CALENDAR) {
+       if (strncmp(capability_type, ACCOUNT_SUPPORTS_CAPABILITY_CALENDAR, strlen(capability_type)) == 0) {
+               *has_contact = TRUE;
+               _INNER_FUNC_EXIT;
+               return FALSE;
+       }
+       _INNER_FUNC_EXIT;
+       return TRUE;
+}
diff --git a/src/fw-plugins/common-public/call-log/CMakeLists.txt b/src/fw-plugins/common-public/call-log/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..e586bd2
--- /dev/null
@@ -0,0 +1,40 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-call-log")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       contacts-service2
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-call-log_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-call-log_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/call-log/src/plugin_interface.c b/src/fw-plugins/common-public/call-log/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..4e9a0e4
--- /dev/null
@@ -0,0 +1,788 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <contacts.h>
+#include <time.h>
+
+/* for log */
+#include "utility/sync_util.h"
+
+#include "plugin/data_connector_interface.h"
+
+#define BACKUP_PATH "/opt/media/Downloads/Kies/.BnR/CallLog.bk"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DA_CALL_LOG"
+#endif
+
+#define CALLOG_SYNC_PERIODIC 60*60*24*8        /*8days */
+
+/* call log Internal Struct */
+typedef struct {
+       int v_type:16;
+       bool embedded;
+       bool img_loaded;
+       int id;
+       int num_type;
+       char *first;
+       char *last;
+       char *display;
+       const char *number;
+       char *img_path;
+       int log_time;
+       int log_type;
+       int extra_data1;        /* duration, message_id */
+       const char *extra_data2;        /*short message */
+       int related_id;         /* contact id */
+} dc_plog_list_s;
+
+static void _del_all_calllogs(void);
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err);
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = contacts_connect2();
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calllog_plugIn] in calllog Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calllog_plugIn] in calllog Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = contacts_disconnect2();
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_calllog_plugIn] in calllog Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_calllog_plugIn] in calllog Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_calllog_plugIn] calllog Start !!");
+       int *account_id_list = (int *)calloc(1, sizeof(int));
+       if (account_id_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+       account_id_list[0] = -1;
+       *count = 1;
+
+       _DEBUG_INFO("[da_calllog_plugIn] calllog End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return account_id_list;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_backup_service_items_to_file(int account_ID, char **file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      FILE *file = 0;
+//      int cur_size = 0;
+//      CTSiter *iter = 0;
+//      CTSvalue *plog = 0;     /*plog_list */
+//
+//      file = fopen(BACKUP_PATH, "w");
+//      if (file == NULL) {
+//              _DEBUG_INFO("[da_call_log_plugIn] fopen fail\n");
+//              return SYNC_AGENT_DA_ERRORS;
+//      }
+//
+//      contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
+//      while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+//              dc_plog_list_s plog_list;
+//
+//              /* get call log */
+//              plog = contacts_svc_iter_get_info(iter);
+//              if (plog == NULL)
+//                      continue;
+//
+//              plog_list.number = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_NUMBER_STR);
+//              plog_list.log_time = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT);
+//              plog_list.log_type = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TYPE_INT);
+//              plog_list.extra_data1 = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_DURATION_INT);
+//              plog_list.extra_data2 = contacts_svc_value_get_str(plog, CTS_LIST_PLOG_SHORTMSG_STR);
+//              plog_list.related_id = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_RELATED_ID_INT);
+//
+//              _DEBUG_INFO("plog_list.number : %s\n", plog_list.number);
+//              _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
+//              _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
+//              _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
+//              _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
+//              _DEBUG_INFO("plog_list.extra_data2 : %s\n", plog_list.extra_data2);
+//
+//              /* save call log : to file text */
+//              cur_size = fprintf(file, "%s %d %d %d %d %s ", plog_list.number, plog_list.related_id, plog_list.log_time, plog_list.log_type, plog_list.extra_data1, plog_list.extra_data2);
+//
+//              if (cur_size == -1) {
+//                      _DEBUG_INFO("[da_call_log_plugIn] fprintf fail\n");
+//                      ret = SYNC_AGENT_DA_ERRORS;
+//                      goto DACI_FINISH;
+//              }
+//
+//              /* memory free */
+//              if (plog != NULL) {
+//                      contacts_svc_value_free(plog);
+//                      plog = 0;
+//              }
+//      }
+//
+//DACI_FINISH:
+//
+//      if (file != NULL) {
+//              fclose(file);
+//              file = 0;
+//      }
+//
+//      /* memory free */
+//      if (plog != NULL) {
+//              contacts_svc_value_free(plog);
+//              plog = 0;
+//      }
+//
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//      }
+//
+//      *file_path = strdup(BACKUP_PATH);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       FILE *file = 0;
+       int cur_size = 0;
+
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_list_h list = NULL;
+
+       char *number = NULL;
+       int related_id;
+       int log_time;
+       int log_type;
+       int duration;
+       char *short_msg = NULL;
+
+       file = fopen(BACKUP_PATH, "w");
+       if (file == NULL) {
+               _DEBUG_ERROR("[da_call_log_plugIn] fopen fail\n");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_list_first(list);
+       while (err == CONTACTS_ERROR_NONE) {
+               contacts_record_h record = NULL;
+
+               /* get call log */
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] contacts_list_get_current_record_p fail\n");
+                       continue;
+               }
+
+               contacts_record_get_str_p(record, _contacts_phone_log.address, &number);
+               contacts_record_get_int(record, _contacts_phone_log.person_id, &related_id);
+               contacts_record_get_int(record, _contacts_phone_log.log_time, &log_time);
+               contacts_record_get_int(record, _contacts_phone_log.log_type, &log_type);
+               contacts_record_get_int(record, _contacts_phone_log.extra_data1, &duration);
+               contacts_record_get_str_p(record, _contacts_phone_log.extra_data2, &short_msg);
+
+               _DEBUG_INFO("plog_list.number : %s\n", number);
+               _DEBUG_INFO("plog_list.related_id : %d\n", related_id);
+               _DEBUG_INFO("plog_list.log_time : %d\n", log_time);
+               _DEBUG_INFO("plog_list.log_type : %d\n", log_type);
+               _DEBUG_INFO("plog_list.extra_data1 : %d\n", duration);
+               _DEBUG_INFO("plog_list.extra_data2 : %s\n", short_msg);
+
+               /* save call log : to file text */
+               cur_size = fprintf(file, "%s %d %d %d %d %s ", number, related_id, log_time, log_type, duration, short_msg);
+               if (cur_size == -1) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] fprintf fail\n");
+                       ret = SYNC_AGENT_DA_ERRORS;
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_list_next(list);
+       }
+
+ DACI_FINISH:
+
+       if (file != NULL) {
+               fclose(file);
+               file = 0;
+       }
+
+       contacts_list_destroy(list, true);
+
+       *file_path = strdup(BACKUP_PATH);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_restore_service_items_from_file(int account_ID, const char *file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(file_path == NULL, SYNC_AGENT_DA_ERRORS, "file_path is NULL. FAIL !!!");
+//
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      FILE *file = 0;
+//      int cur_size = 0;
+//      CTSvalue *plog = 0;     /* plog */
+//
+//      /* open call log : from file text */
+//      file = fopen(BACKUP_PATH, "r");
+//      if (file == NULL) {
+//              _DEBUG_INFO("[da_call_log_plugIn] fopen fail\n");
+//              return SYNC_AGENT_DA_ERRORS;
+//      }
+//
+//      /* delete call log from contact service database */
+//      _del_all_calllogs();
+//
+//      while (1) {
+//              dc_plog_list_s plog_list;
+//              char temp_number[100] = { 0 };
+//              char temp_extra_data2[1024] = { 0 };
+//
+//              /* read call log : from file text */
+//              cur_size = fscanf(file, "%100s %d %d %d %d %1024s ", temp_number, &(plog_list.related_id), &(plog_list.log_time), &(plog_list.log_type), &(plog_list.extra_data1), temp_extra_data2);
+//
+//              if (cur_size == -1) {
+//                      _DEBUG_INFO("[da_call_log_plugIn] fscanf fail\n");
+//                      ret = SYNC_AGENT_DA_ERRORS;
+//                      goto DACI_FINISH;
+//              }
+//
+//              plog = contacts_svc_value_new(CTS_VALUE_PHONELOG);
+//              if (plog == NULL) {
+//                      _DEBUG_INFO("[da_call_log_plugIn] memory allocation fail\n");
+//                      ret = SYNC_AGENT_DA_ERRORS;
+//                      goto DACI_FINISH;
+//              }
+//
+//              /* add call log to contact service database */
+//              contacts_svc_value_set_str(plog, CTS_PLOG_VAL_NUMBER_STR, temp_number);
+//              contacts_svc_value_set_int(plog, CTS_PLOG_VAL_RELATED_ID_INT, plog_list.related_id);
+//              contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TIME_INT, plog_list.log_time);
+//              contacts_svc_value_set_int(plog, CTS_PLOG_VAL_LOG_TYPE_INT, plog_list.log_type);
+//              contacts_svc_value_set_int(plog, CTS_PLOG_VAL_DURATION_INT, plog_list.extra_data1);
+//              contacts_svc_value_set_str(plog, CTS_PLOG_VAL_SHORTMSG_STR, temp_extra_data2);
+//
+//              _DEBUG_INFO("plog_list.number : %s\n", temp_number);
+//              _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
+//              _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
+//              _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
+//              _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
+//              _DEBUG_INFO("plog_list.extra_data2 : %s\n", temp_extra_data2);
+//
+//              err = contacts_svc_insert_phonelog(plog);
+//              if (err < CTS_SUCCESS) {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_phonelog() Fail!\n");
+//                      ret = SYNC_AGENT_DA_ERRORS;
+//                      goto DACI_FINISH;
+//              } else {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_phonelog() Success!\n");
+//
+//                      /* memory free */
+//                      if (plog != NULL) {
+//                              contacts_svc_value_free(plog);
+//                              plog = 0;
+//                      }
+//              }
+//      }
+//
+//DACI_FINISH:
+//
+//      if (file != NULL) {
+//              fclose(file);
+//              file = 0;
+//      }
+//
+//      /* memory free */
+//      if (plog != NULL) {
+//              contacts_svc_value_free(plog);
+//              plog = 0;
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       FILE *file = 0;
+       int cur_size = 0;
+       contacts_record_h record = NULL;
+       int contact_id = 0;
+
+       /* open call log : from file text */
+       file = fopen(BACKUP_PATH, "r");
+       if (file == NULL) {
+               _DEBUG_ERROR("[da_call_log_plugIn] fopen fail\n");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /* delete call log from contact service database */
+       _del_all_calllogs();
+
+       while (1) {
+               dc_plog_list_s plog_list;
+               char temp_number[100] = { 0 };
+               char temp_extra_data2[1024] = { 0 };
+
+               /* read call log : from file text */
+               cur_size = fscanf(file, "%100s %d %d %d %d %1024s ", temp_number, &(plog_list.related_id), &(plog_list.log_time), &(plog_list.log_type), &(plog_list.extra_data1), temp_extra_data2);
+
+               if (cur_size == -1) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] fscanf fail\n");
+                       ret = SYNC_AGENT_DA_ERRORS;
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_record_create(_contacts_phone_log._uri, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] contacts_record_create Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               /* add call log to contact service database */
+               contacts_record_set_str(record, _contacts_phone_log.address, temp_number);
+               contacts_record_set_int(record, _contacts_phone_log.person_id, plog_list.related_id);
+               contacts_record_set_int(record, _contacts_phone_log.log_time, plog_list.log_time);
+               contacts_record_set_int(record, _contacts_phone_log.log_type, plog_list.log_type);
+               contacts_record_set_int(record, _contacts_phone_log.extra_data1, plog_list.extra_data1);
+               contacts_record_set_str(record, _contacts_phone_log.extra_data2, temp_extra_data2);
+
+               _DEBUG_INFO("plog_list.number : %s\n", temp_number);
+               _DEBUG_INFO("plog_list.related_id : %d\n", plog_list.related_id);
+               _DEBUG_INFO("plog_list.log_time : %d\n", plog_list.log_time);
+               _DEBUG_INFO("plog_list.log_type : %d\n", plog_list.log_type);
+               _DEBUG_INFO("plog_list.extra_data1 : %d\n", plog_list.extra_data1);
+               _DEBUG_INFO("plog_list.extra_data2 : %s\n", temp_extra_data2);
+
+               err = contacts_db_insert_record(record, &contact_id);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail!\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               } else {
+                       _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success!\n");
+                       _DEBUG_INFO("[da_contact_plugIn] contact_id = %d", contact_id);
+               }
+       }
+
+ DACI_FINISH:
+
+       contacts_record_destroy(record, true);
+
+       if (file != NULL) {
+               fclose(file);
+               file = 0;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      cts_error err = 0;
+//      CTSvalue *item = 0;
+//
+//      /* get item */
+//      int colllog_id = atoi(item_id);
+//      _DEBUG_INFO("[da_call-log_plugIn] colllog_id : %d\n", colllog_id);
+//      err = contacts_svc_get_phonelog(colllog_id, &item);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_call-log_plugIn] contacts_svc_get_phonelog() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//              *data = 0;
+//      } else {
+//              _DEBUG_INFO("[da_call-log_plugIn] contacts_svc_get_phonelog() Success!\n");
+//              *data = (void *)item;
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       contacts_record_h record = NULL;
+
+       /* get item */
+       int colllog_id = atoi(item_id);
+       _DEBUG_INFO("[da_call-log_plugIn] colllog_id : %d\n", colllog_id);
+       err = contacts_db_get_record(_contacts_phone_log._uri, colllog_id, &record);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_call-log_plugIn] contacts_db_get_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *data = 0;
+       } else {
+               _DEBUG_INFO("[da_call-log_plugIn] contacts_db_get_record() Success!\n");
+               *data = (void *)record;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+static void _del_all_calllogs(void)
+{
+       _INNER_FUNC_ENTER;
+
+//      CTSiter *iter = 0;
+//      CTSvalue *plog = 0;     /*plog_list */
+//
+//      contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
+//      while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+//
+//              /* get call log */
+//              plog = contacts_svc_iter_get_info(iter);
+//              if (plog == NULL)
+//                      continue;
+//
+//              int id = contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT);
+//
+//              /* delete call log */
+//              contacts_svc_delete_phonelog(CTS_PLOG_DEL_BY_ID, id);
+//              _DEBUG_TRACE("[da_call_log_plugIn] id : %d\n", id);
+//
+//              /* memory free */
+//              if (plog != NULL) {
+//                      contacts_svc_value_free(plog);
+//                      plog = 0;
+//              }
+//      }
+//
+//      /* memory free */
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//      }
+
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_list_h list = NULL;
+
+       err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+               return;
+       }
+
+       err = contacts_list_first(list);
+       while (err == CONTACTS_ERROR_NONE) {
+               contacts_record_h record = NULL;
+
+               /* get call log */
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+                       continue;
+               }
+
+               int id;
+               err = contacts_record_get_int(record, _contacts_phone_log.id, &id);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+                       continue;
+               }
+
+               _DEBUG_TRACE("[da_call_log_plugIn] id : %d\n", id);
+
+               /* delete call log */
+               contacts_db_delete_record(_contacts_phone_log._uri, id);
+
+               err = contacts_list_next(list);
+       }
+
+       /* memory free */
+       contacts_list_destroy(list, true);
+
+       _INNER_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int changepoint, int *changeCount)
+{
+       _EXTERN_FUNC_ENTER;
+//
+//      _DEBUG_INFO("[da_call-log_plugIn] account_id : %d\n", account_id);
+//      _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
+//      _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", changepoint);
+//
+//      sync_agent_plugin_item_node_s *root_ptr = 0;
+//      sync_agent_plugin_item_node_s *cursor_ptr = 0;
+//      int chagned_count = 0;
+//      int current_time = time(NULL);
+//
+//      CTSiter *iter = NULL;
+//      CTSvalue *plog = NULL;  /*plog_list */
+//
+//      char *calllog_id_str = NULL;
+//
+//      int result = contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter);
+//      _DEBUG_INFO("result = %d", result);
+//      while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+//
+//              /* get call log */
+//              plog = contacts_svc_iter_get_info(iter);
+//              if (plog == NULL)
+//                      continue;
+//
+//              /*check that item is within 7 days before since at the time */
+//              if (current_time - CALLOG_SYNC_PERIODIC <= contacts_svc_value_get_int(plog, CTS_LIST_PLOG_LOG_TIME_INT)) {
+//                      calllog_id_str = g_strdup_printf("%d", contacts_svc_value_get_int(plog, CTS_LIST_PLOG_ID_INT));
+//                      _DEBUG_INFO("calllog_id_str = %s", calllog_id_str);
+//
+//                      if (root_ptr == NULL) {
+//                              root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                              if( root_ptr == NULL ) {
+//                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                      return NULL;
+//                              }
+//                              root_ptr->item_id = calllog_id_str;
+//                              root_ptr->next = 0;
+//                              cursor_ptr = root_ptr;
+//                      } else {
+//                              cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                              if( cursor_ptr->next == NULL ) {
+//                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                      return NULL;
+//                              }
+//                              cursor_ptr->next->item_id = calllog_id_str;
+//                              cursor_ptr->next->next = 0;
+//                              cursor_ptr = cursor_ptr->next;
+//                      }
+//
+//                      chagned_count++;
+//
+//                      /* memory free */
+//                      if (plog != NULL) {
+//                              contacts_svc_value_free(plog);
+//                              plog = NULL;
+//                      }
+//              }
+//      }
+//
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+//
+//      *changeCount = chagned_count;
+
+       _DEBUG_INFO("[da_call-log_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", changepoint);
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+       int current_time = time(NULL);
+
+       char *calllog_id_str = NULL;
+
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_list_h list = NULL;
+
+       err = contacts_db_get_all_records(_contacts_phone_log._uri, 0, 0, &list);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+               return NULL;
+       }
+
+       err = contacts_list_first(list);
+       while (err == CONTACTS_ERROR_NONE) {
+
+               contacts_record_h record = NULL;
+
+               /* get call log */
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_call_log_plugIn] contacts_db_get_all_records fail\n");
+                       continue;
+               }
+
+               /*check that item is within 7 days before since at the time */
+               int log_time;
+               contacts_record_get_int(record, _contacts_phone_log.log_time, &log_time);
+
+               if (current_time - CALLOG_SYNC_PERIODIC <= log_time) {
+                       int calllog_id;
+                       contacts_record_get_int(record, _contacts_phone_log.id, &calllog_id);
+
+                       calllog_id_str = g_strdup_printf("%d", calllog_id);
+                       _DEBUG_INFO("calllog_id_str = %s", calllog_id_str);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               root_ptr->item_id = calllog_id_str;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+                               cursor_ptr->next->item_id = calllog_id_str;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+
+               err = contacts_list_next(list);
+       }
+
+       contacts_list_destroy(list, true);
+
+       *changeCount = chagned_count;
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_call-log_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_call-log_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_call-log_plugIn] changepoint : %d\n", change_point);
+
+       *change_count = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return NULL;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+
+       *change_count = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return NULL;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_contact_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       case CONTACTS_ERROR_NONE:
+               ret = SYNC_AGENT_DA_SUCCESS;
+               break;
+       case CONTACTS_ERROR_OUT_OF_MEMORY:
+               ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               break;
+       case CONTACTS_ERROR_INVALID_PARAMETER:
+               ret = SYNC_AGENT_DA_ERR_INVALID_PARAMETER;
+               break;
+       case CONTACTS_ERROR_NO_DATA:
+               ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               break;
+       case CONTACTS_ERROR_DB:
+               ret = SYNC_AGENT_DA_ERR_SERVICE_DB;
+               break;
+       case CONTACTS_ERROR_IPC:
+               ret = SYNC_AGENT_DA_ERR_SERVICE_IPC;
+               break;
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_last_change_point(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      contacts_svc_begin_trans();
+//      int contact_version = contacts_svc_end_trans(1);
+
+       int contact_version;
+       contacts_db_get_current_version(&contact_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return contact_version;
+}
diff --git a/src/fw-plugins/common-public/contact/CMakeLists.txt b/src/fw-plugins/common-public/contact/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..d611c11
--- /dev/null
@@ -0,0 +1,41 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-contact")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       contacts-service2
+                                       accounts-svc
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-contact_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-contact_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/contact/include/ext_datastore_info_contact.h b/src/fw-plugins/common-public/contact/include/ext_datastore_info_contact.h
new file mode 100755 (executable)
index 0000000..d9450fd
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXT_DATASTORE_INFO_CONTACT_H_
+#define EXT_DATASTORE_INFO_CONTACT_H_
+
+typedef enum {
+       CONTACT_FIELD_NAME = 1,
+       CONTACT_FIELD_TEL,
+       CONTACT_FIELD_EMAIL,
+       CONTACT_FIELD_URL,
+       CONTACT_FIELD_ADDR,
+       CONTACT_FIELD_NOTE,
+       CONTACT_FIELD_COMPANY,
+       CONTACT_FIELD_DEPARTMENT,
+       CONTACT_FIELD_TITLE,
+       CONTACT_FIELD_HOBBY,
+       CONTACT_FIELD_PHOTO,
+       CONTACT_FIELD_YEAR
+} contact_field_e;
+
+typedef enum {
+       CONTACT_CHILD_FIELD_FAMILY = 1,
+       CONTACT_CHILD_FIELD_GIVEN,
+       CONTACT_CHILD_FIELD_MIDDLE,
+       CONTACT_CHILD_FIELD_PREFIX,
+       CONTACT_CHILD_FIELD_SUFFIX,
+       CONTACT_CHILD_FIELD_FORMATTED,
+       CONTACT_CHILD_FIELD_NICKNAME,
+       CONTACT_CHILD_FIELD_READING_NAME,
+       CONTACT_CHILD_FIELD_READING_LAST_NAME,
+       CONTACT_CHILD_FIELD_TEL,
+       CONTACT_CHILD_FIELD_EMAIL,
+       CONTACT_CHILD_FIELD_URL,
+       CONTACT_CHILD_FIELD_POBOX,
+       CONTACT_CHILD_FIELD_EXT_ADDR,
+       CONTACT_CHILD_FIELD_STREET,
+       CONTACT_CHILD_FIELD_LOCALITY,
+       CONTACT_CHILD_FIELD_REGION,
+       CONTACT_CHILD_FIELD_POSTAL_CODE,
+       CONTACT_CHILD_FIELD_COUNTRY
+} contact_child_field_e;
+
+typedef enum {
+       CONTACT_FEATURE_GENDER = 1
+} contact_feature_e;
+
+#endif                         /* EXT_DATASTORE_INFO_CONTACT_H_ */
diff --git a/src/fw-plugins/common-public/contact/include/extern_info.h b/src/fw-plugins/common-public/contact/include/extern_info.h
new file mode 100755 (executable)
index 0000000..354bd76
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTERN_INFO_H_
+#define EXTERN_INFO_H_
+
+typedef enum {
+       DEFAULT_CONTACT_FOLDER = 0,
+       USER_DEFINED_FOLDER
+} contact_folder_type_e;
+
+#endif                         /* EXTERN_INFO_H_ */
diff --git a/src/fw-plugins/common-public/contact/include/in_datastore_info_contact.h b/src/fw-plugins/common-public/contact/include/in_datastore_info_contact.h
new file mode 100755 (executable)
index 0000000..95f6008
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_DATASTORE_INFO_CONTACT_H_
+#define IN_DATASTORE_INFO_CONTACT_H_
+
+/* ITEM COUNT */
+#define MAX_ITEM_COUNT_CONTACT         65535
+
+/* FIELD COUNT */
+#define MAX_FIELD_COUNT_TEL                    3
+#define MAX_FIELD_COUNT_EMAIL          2
+#define MAX_FIELD_COUNT_URL                    1
+#define MAX_FIELD_COUNT_ADDR           2
+
+/* NAME FIELD */
+#define MAX_LEN_FAMILY                         2000
+#define MAX_LEN_GIVEN                          2000
+#define MAX_LEN_MIDDLE                         2000
+#define MAX_LEN_PREFIX                         FALSE
+#define MAX_LEN_SUFFIX                         2000
+#define MAX_LEN_FORMATTED                      FALSE
+#define MAX_LEN_NICKNAME                       2000
+#define MAX_LEN_READING_NAME                   FALSE
+#define MAX_LEN_READING_LAST_NAME              FALSE
+
+/* TEL FIELD */
+#define        MAX_LEN_TEL                                     100
+
+/* EMAIL FIELD */
+#define MAX_LEN_EMAIL                          100
+
+/* URL FIELD */
+#define MAX_LEN_URL                                    100
+
+/* ADDR FIELD */
+#define MAX_LEN_POBOX                          FALSE
+#define MAX_LEN_EXT_ADDR                       FALSE
+#define MAX_LEN_STREET                         50
+#define MAX_LEN_LOCALITY                       50
+#define MAX_LEN_REGION                         50
+#define MAX_LEN_POSTAL_CODE                    50
+#define MAX_LEN_COUNTRY                                20
+
+/* DEVICE CONTACT */
+#define MAX_LEN_NOTE                           100
+#define MAX_LEN_COMPANY                                50
+#define MAX_LEN_DEPARTMENT                     FALSE
+#define MAX_LEN_TITLE                          FALSE
+#define MAX_LEN_HOBBY                          FALSE
+#define MIN_PERIOD_YEAR                                1970
+#define MAX_PERIOD_YEAR                                2037
+#define MAX_LEN_PHOTO                          46
+
+/* FEATURE */
+#define IF_SUPPORT_GENDER                      FALSE
+
+/* SIM CONTACT */
+#define TYPE_SIM
+#define MAX_LEN_NAME
+#define MAX_LEN_NUMBER
+#define MAX_COUNT_ANR
+#define MAX_LEN_ANR
+#define MAX_LEN_SNE
+#define IF_USING_SIM
+
+#endif                         /* IN_DATASTORE_INFO_CONTACT_H_ */
diff --git a/src/fw-plugins/common-public/contact/include/item_change_info.h b/src/fw-plugins/common-public/contact/include/item_change_info.h
new file mode 100755 (executable)
index 0000000..6aaef4c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ITEM_CHANGE_INFO_H_
+#define ITEM_CHANGE_INFO_H_
+
+int get_contact_version(int mode);
+
+int set_contact_version(int setting_time);
+
+#endif                         /* ITEM_CHANGE_INFO_H_ */
diff --git a/src/fw-plugins/common-public/contact/src/item_change_info.c b/src/fw-plugins/common-public/contact/src/item_change_info.c
new file mode 100755 (executable)
index 0000000..4cb35ef
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#include <contacts-svc.h>
+#include <contacts.h>
+
+#include "utility/sync_util.h"
+#include "item_change_info.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DA_CONTACT"
+#endif
+
+static int contact_version = 0;
+
+int get_contact_version(int mode)
+{
+       _EXTERN_FUNC_ENTER;
+
+/*     if (contactTimeStamp > 0)
+               return contactTimeStamp;
+
+       return ((int)time(0) - 1);*/
+
+       if (mode == 0) {
+               return contact_version;
+       }
+
+/*     if (contactVersion > 0)
+               return contactVersion;*/
+
+//      contacts_svc_begin_trans();
+//      contact_version = contacts_svc_end_trans(1);
+
+       contacts_error_e err = contacts_db_get_current_version(&contact_version);
+       if (err != CONTACTS_ERROR_NONE)
+               _DEBUG_ERROR("contacts_db_get_current_version is failed");
+
+       _EXTERN_FUNC_EXIT;
+
+       return contact_version;
+}
+
+int set_contact_version(int setting_time)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* Critical Sectioin Start */
+       contact_version = setting_time;
+       /* Critical Section End */
+
+       _EXTERN_FUNC_EXIT;
+
+       return setting_time;
+}
diff --git a/src/fw-plugins/common-public/contact/src/plugin_interface.c b/src/fw-plugins/common-public/contact/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..8084975
--- /dev/null
@@ -0,0 +1,2533 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <pthread.h>
+
+#include <contacts.h>
+#include <account.h>
+
+#include "extern_info.h"
+#include "item_change_info.h"
+#include "ext_datastore_info_contact.h"
+#include "in_datastore_info_contact.h"
+
+/* for log */
+#include "utility/sync_util.h"
+#include "utility/fw_async_queue.h"
+
+#include "plugin/data_connector_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DA_CONTACT"
+#endif
+
+#define FW_CONTACT             0       /* plugIn-Id */
+
+static int latest_contact_version;
+
+static sync_agent_util_async_queue_s *queue;
+
+static pthread_mutex_t lockx;
+
+static int is_noti_from_me = 0;
+
+static int is_storage_changed = 0;
+
+static sync_agent_add_item_cb_plugin callback_add_item;
+
+static sync_agent_del_item_cb_plugin callback_del_item;
+
+static sync_agent_update_item_cb_plugin callback_update_item;
+
+static sync_agent_get_account_id_list_cb_plugin callback_get_account_id_list;
+
+static void _set_is_noti_from_me(int set_flag);
+
+static int _get_is_noti_from_me(void);
+
+//static void _process_contact_change(void *);
+static void _process_contact_change(const char *view_uri, void *user_data);
+
+static void *_rutine_contact_change(void *);
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err);
+
+static bool _get_account_id(account_h account, void *user_data);
+
+static bool __is_contact_id(/*account_capability_type_e*/const char* capability_type, account_capability_state_e capability_value, void *user_data);
+
+static void _contacts_db_result_cb(int error, void *user_data);
+
+typedef struct account_id {
+       int account_id;
+       struct account_id *next;
+} account_id_s;
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = contacts_svc_connect();
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = contacts_connect2();
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] in contact Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = contacts_svc_disconnect();
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = contacts_disconnect2();
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] in contact Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_begin_transaction(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_contact_plugIn] Start Begin_Transaction\n");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = contacts_svc_begin_trans();
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_ERROR("[da_contact_plugIn] in contact Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Success!\n");
+       _set_is_noti_from_me(1);
+//      }
+
+       _DEBUG_INFO("[da_contact_plugIn] End Begin_Transaction\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_end_transaction(int is_success)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_contact_plugIn] Start End_Transaction\n");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = contacts_svc_end_trans(is_success);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_ERROR("[da_contact_plugIn] in contact Fail!");
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] in contact Success!");
+       if (is_storage_changed == 0) {
+               _DEBUG_INFO("contact storaged was not Changed!!");
+               _set_is_noti_from_me(0);
+       }
+       is_storage_changed = 0;
+//      }
+
+       _DEBUG_INFO("[da_contact_plugIn] End End_Transaction\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+//
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      CTSstruct *item = (CTSstruct *)data;
+//
+//      /*  add item */
+//      err = contacts_svc_insert_contact(atoi(folder_id), (CTSstruct *)item);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_contact() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//              *item_id = 0;
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_contact() Success!\n");
+//              *item_id = g_strdup_printf("%d", err);
+//              is_storage_changed = 1;
+//      }
+//
+//      /*  memory free */
+//      if (item != NULL)
+//              contacts_svc_struct_free(item);
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_record_h record = (contacts_record_h) data;
+
+       int contact_id = 0;
+
+       int int_folder_id = atoi(folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] folder id [%s][%d]", folder_id, int_folder_id);
+
+       /*set folder id */
+       err = contacts_record_set_int(record, _contacts_contact.address_book_id, int_folder_id);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_set_int Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       _DEBUG_INFO("[da_contact_plugIn] insert");
+
+       /*  add item */
+       err = contacts_db_insert_record(record, &contact_id);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *item_id = 0;
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success!\n");
+               _DEBUG_INFO("contact_id = %d", contact_id);
+               *item_id = g_strdup_printf("%d", contact_id);
+               is_storage_changed = 1;
+       }
+
+ DACI_FINISH:
+
+       contacts_record_destroy(record, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+//      retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+//
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      CTSstruct *item = (CTSstruct *)data;
+//
+//      /*  update item */
+//      err = contacts_svc_update_contact((CTSstruct *)item);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Success!\n");
+//              is_storage_changed = 1;
+//      }
+//
+//      /*  memory free */
+//      if (item != NULL)
+//              contacts_svc_struct_free(item);
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_record_h record = (contacts_record_h) data;
+
+       /*  update item */
+       err = contacts_db_update_record(record);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_update_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_update_record() Success!\n");
+               is_storage_changed = 1;
+       }
+
+       contacts_record_destroy(record, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+
+/*sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       CTSstruct *item = (CTSstruct *)data;
+
+       err = contacts_svc_update_contact(item);
+       if (err < CTS_SUCCESS) {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_svc_update_contact() Success!\n");
+       }
+
+       //  memory free
+       if (item != NULL)
+               contacts_svc_struct_free(item);
+
+       return ret;*/
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+//
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//
+//      /* delete item */
+//      err = contacts_svc_delete_contact(atoi(item_id));
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%s) Fail!\n", item_id);
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%s) Success!\n", item_id);
+//              is_storage_changed = 1;
+//      }
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+
+       /* delete item */
+       err = contacts_db_delete_record(_contacts_contact._uri, atoi(item_id));
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_record(%s) Fail!\n", item_id);
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_delete_record(%s) Success!\n", item_id);
+               is_storage_changed = 1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      int folder_id_list_cnt = 0;
+//      int *folder_type_list = 0;
+//      char **folder_id_list = 0;
+//      CTSiter *iter = 0;
+//      CTSvalue *item = 0;
+//      int item_id = 0;
+//
+//      /* get folder id list for account id */
+//      folder_id_list = sync_agent_plugin_get_folder_id_list(account_id, &folder_id_list_cnt, &folder_type_list);
+//      if (folder_id_list == NULL) {
+//              _DEBUG_INFO("[da_contact_plugIn] folder id list cnt : %d\n", folder_id_list_cnt);
+//              return SYNC_AGENT_DA_ERR_NO_DATA;
+//      }
+//
+//      int cnt = 0;
+//      for (; cnt < folder_id_list_cnt; cnt++) {
+//              /* get item id list (iter) for each folder id */
+//              err = contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_ADDRESSBOOK_ID, atoi(folder_id_list[cnt]), &iter);
+//
+//              if (err == CTS_SUCCESS) {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_list_with_int Success!! \n");
+//
+//                      while (contacts_svc_iter_next(iter) == CTS_SUCCESS) {
+//                              /* get item */
+//                              item = contacts_svc_iter_get_info(iter);
+//                              if (item != NULL) {
+//                                      item_id = contacts_svc_value_get_int(item, CTS_LIST_CONTACT_ID_INT);
+//                                      _DEBUG_INFO("[da_contact_plugIn] item id : %d\n", item_id);
+//
+//                                      /* delete item */
+//                                      err = contacts_svc_delete_contact(item_id);
+//                                      if (err != CTS_SUCCESS) {
+//                                              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%d) Fail!\n", item_id);
+//                                              ret = _convert_service_error_to_common_error(err);
+//                                              goto DACI_FINISH;
+//                                      } else {
+//                                              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_contact(%d) Success!\n", item_id);
+//                                              is_storage_changed = 1;
+//                                      }
+//
+//                                      /* memory free */
+//                                      contacts_svc_value_free(item);
+//                                      item = 0;
+//                                      item_id = 0;
+//                              }
+//                      }       /* end while */
+//
+//                      /* memory free */
+//                      if (iter != NULL) {
+//                              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//                              contacts_svc_iter_remove(iter);
+//                              iter = 0;
+//                      }
+//
+//              } else {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_list_with_int Fail !! \n");
+//                      ret = _convert_service_error_to_common_error(err);
+//                      goto DACI_FINISH;
+//              }
+//      }
+//
+//DACI_FINISH:
+//
+//      /* memory free */
+//      if (item != NULL)
+//              contacts_svc_value_free(item);
+//
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+//      if (folder_id_list != NULL) {
+//              /*
+//                 for (cnt = 0; cnt < folder_id_list_cnt; cnt++) {
+//                 if (folder_id_list[cnt] != NULL) {
+//                 _DEBUG_INFO("folder_id_list[%d] : %s\n", cnt, folder_id_list[cnt]);
+//                 free(folder_id_list[cnt]);
+//                 _DEBUG_INFO("[da_calendar_plugIn] folder id free !! \n");
+//                 }
+//                 }
+//               */
+//              free(folder_id_list);
+//              _DEBUG_INFO("[da_contact_plugIn] folder id list free !! \n");
+//      }
+//      if (folder_type_list != NULL) {
+//              free(folder_type_list);
+//              _DEBUG_INFO("[da_contact_plugIn] folder type list free !! \n");
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int folder_id_list_cnt = 0;
+       int *folder_type_list = 0;
+       char **folder_id_list = 0;
+       int item_id = 0;
+
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_query_h query = NULL;
+       contacts_filter_h filter = NULL;
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+
+       int count = 0;
+       int index = 0;
+       int *contact_id_list = NULL;
+
+       /* get folder id list for account id */
+       folder_id_list = sync_agent_plugin_get_folder_id_list(account_id, &folder_id_list_cnt, &folder_type_list);
+       if (folder_id_list == NULL) {
+               _DEBUG_ERROR("[da_contact_plugIn] folder id list cnt : %d\n", folder_id_list_cnt);
+               return SYNC_AGENT_DA_ERR_NO_DATA;
+       }
+
+       int cnt = 0;
+       for (; cnt < folder_id_list_cnt; cnt++) {
+               err = contacts_query_create(_contacts_contact_grouprel._uri, &query);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_query_create Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_filter_create(_contacts_contact_grouprel._uri, &filter);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_create Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_filter_add_int(filter, _contacts_contact_grouprel.address_book_id, CONTACTS_MATCH_EQUAL, atoi(folder_id_list[cnt]));
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_set_int Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_query_set_filter(query, filter);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_filter Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               err = contacts_db_get_count_with_query(query, &count);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_count_with_query Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+               _DEBUG_INFO("count = %d", count);
+
+               if (count > 0) {
+
+                       err = contacts_db_get_records_with_query(query, 0, 0, &list);
+                       if (err == CONTACTS_ERROR_NONE) {
+                               _DEBUG_INFO("[da_contact_plugIn] contacts_db_get_records_with_query Success!! \n");
+
+                               index = 0;
+                               contact_id_list = (int *)calloc(count, sizeof(int));
+
+                               err = contacts_list_first(list);
+                               while (err == CONTACTS_ERROR_NONE) {
+
+                                       err = contacts_list_get_current_record_p(list, &record);
+                                       if (err != CONTACTS_ERROR_NONE) {
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+                                               ret = _convert_service_error_to_common_error(err);
+                                               goto DACI_FINISH;
+                                       }
+
+                                       err = contacts_record_get_int(record, _contacts_contact_grouprel.contact_id, &item_id);
+                                       if (err != CONTACTS_ERROR_NONE) {
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+                                               ret = _convert_service_error_to_common_error(err);
+                                               goto DACI_FINISH;
+                                       }
+
+                                       contact_id_list[index] = item_id;
+                                       _DEBUG_INFO("[da_contact_plugIn] contact_id_list[%d]: %d\n", index, contact_id_list[index]);
+
+                                       index++;
+                                       item_id = 0;
+
+                                       err = contacts_list_next(list);
+                               }       /* end while */
+
+                               int i = 0;
+                               for (; i < count; i++) {
+                                       _DEBUG_INFO("%d = %d", i, contact_id_list[i]);
+                               }
+
+                               /* delete items */
+                               err = contacts_db_delete_records_async(_contacts_contact._uri, contact_id_list, count, _contacts_db_result_cb, NULL);
+                               if (err != CONTACTS_ERROR_NONE) {
+                                       _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_records Fail!\n");
+                                       ret = _convert_service_error_to_common_error(err);
+                                       goto DACI_FINISH;
+                               } else {
+                                       _DEBUG_INFO("[da_contact_plugIn] contacts_db_delete_records Success!\n");
+                                       is_storage_changed = 1;
+                               }
+
+                               if (contact_id_list != NULL) {
+                                       free(contact_id_list);
+                                       contact_id_list = NULL;
+                               }
+
+                       } else {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_records_with_query Fail !! \n");
+                               ret = _convert_service_error_to_common_error(err);
+                               goto DACI_FINISH;
+                       }
+
+                       count = 0;
+                       contacts_list_destroy(list, true);
+                       list = NULL;
+               }
+
+               contacts_filter_destroy(filter);
+               filter = NULL;
+
+               contacts_query_destroy(query);
+               query = NULL;
+       }
+
+ DACI_FINISH:
+
+       contacts_filter_destroy(filter);
+       contacts_query_destroy(query);
+       contacts_list_destroy(list, true);
+
+       if (folder_id_list != NULL) {
+               free(folder_id_list);
+               _DEBUG_INFO("[da_contact_plugIn] folder id list free !! \n");
+       }
+       if (folder_type_list != NULL) {
+               free(folder_type_list);
+               _DEBUG_INFO("[da_contact_plugIn] folder type list free !! \n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+//
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      CTSstruct *item = 0;
+//
+//      /* get item */
+//      int contact_id = atoi(item_id);
+//      _DEBUG_INFO("[da_contact_plugIn] contact_id : %d\n", contact_id);
+//      err = contacts_svc_get_contact(contact_id, &item);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_contact() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//              *data = 0;
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_contact() Success!\n");
+//              *data = (void *)item;
+//      }
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_record_h record = NULL;
+
+       /* get item */
+       int contact_id = atoi(item_id);
+       _DEBUG_INFO("[da_contact_plugIn] contact_id : %d\n", contact_id);
+       err = contacts_db_get_record(_contacts_contact._uri, contact_id, &record);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *data = 0;
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_get_record() Success!\n");
+               *data = (void *)record;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_name == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_name is NULL. FAIL !!!");
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      CTSvalue *folder = 0;
+//
+//      /* new service struct */
+//      folder = contacts_svc_value_new(CTS_VALUE_ADDRESSBOOK);
+//
+//      /* setting folder data */
+//      contacts_svc_value_set_int(folder, CTS_ADDRESSBOOK_VAL_ACC_ID_INT, account_id);
+//      /*              change value in contacts service :   CTS_ADDRESSBOOK_TYPE_NONE --> CTS_ADDRESSBOOK_TYPE_OTHER
+//       *
+//       contacts_svc_value_set_int(folder, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT, CTS_ADDRESSBOOK_TYPE_NONE);
+//       */
+//      //contacts_svc_value_set_int(folder, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT, CTS_ADDRESSBOOK_TYPE_OTHER);
+//      contacts_svc_value_set_int(folder, CTS_ADDRESSBOOK_VAL_MODE_INT, CTS_ADDRESSBOOK_MODE_NONE);
+//      contacts_svc_value_set_str(folder, CTS_ADDRESSBOOK_VAL_NAME_STR, folder_name);
+//
+//      /* add folder */
+//      err = contacts_svc_insert_addressbook(folder);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_addressbook() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//              *folder_id = 0;
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_insert_addressbook() Success!\n");
+//              *folder_id = g_strdup_printf("%d", err);
+//              is_storage_changed = 1;
+//      }
+//
+//      /*  memory free */
+//      if (folder != NULL)
+//              contacts_svc_value_free(folder);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_record_h record = NULL;
+       int contact_id = 0;
+
+       err = contacts_record_create(_contacts_address_book._uri, &record);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_create Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               folder_id = 0;
+               return ret;
+       }
+
+       err = contacts_record_set_int(record, _contacts_address_book.account_id, account_id);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_set_int Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_record_set_int(record, _contacts_address_book.mode, CONTACTS_ADDRESS_BOOK_MODE_NONE);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_set_int Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_record_set_str(record, _contacts_address_book.name, folder_name);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_set_str Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_db_insert_record(record, &contact_id);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_insert_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *folder_id = 0;
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_insert_record() Success!\n");
+               _DEBUG_INFO("[da_contact_plugIn] contact_id = %d", contact_id);
+               int folder = 0;
+               err = contacts_record_get_int(record, _contacts_address_book.id, &folder);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               *folder_id = g_strdup_printf("%d", folder);
+               is_storage_changed = 1;
+       }
+
+ DACI_FINISH:
+
+       contacts_record_destroy(record, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//
+//      /* delete folder */
+//      err = contacts_svc_delete_addressbook(atoi(folder_id));
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_addressbook(%s) Fail!\n", folder_id);
+//              ret = _convert_service_error_to_common_error(err);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_delete_addressbook(%s) Success!\n", folder_id);
+//              is_storage_changed = 1;
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+
+       /* delete folder */
+       err = contacts_db_delete_record(_contacts_address_book._uri, atoi(folder_id));
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_delete_record(%s) Fail!\n", folder_id);
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_delete_record(%s) Success!\n", folder_id);
+               is_storage_changed = 1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+//      sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+//      int err = 0;
+//      CTSvalue *folder = 0;
+//
+//      /* get item */
+//      int contact_folder_id = atoi(folder_id);
+//      _DEBUG_INFO("[da_contact_plugIn] contact_folder_id : %d\n", contact_folder_id);
+//      err = contacts_svc_get_addressbook(contact_folder_id, &folder);
+//      if (err < CTS_SUCCESS) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Fail!\n");
+//              ret = _convert_service_error_to_common_error(err);
+//              *out_folder_name = 0;
+//              *out_folder_type = -1;
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_get_addressbook() Success!\n");
+//              const char *folder_name = contacts_svc_value_get_str(folder, CTS_ADDRESSBOOK_VAL_NAME_STR);
+//              _DEBUG_INFO("out_folder_name : %s", folder_name);
+//              *out_folder_name = strdup(folder_name);
+//              *out_folder_type = DEFAULT_CONTACT_FOLDER;
+//      }
+//
+//      /*  memory free */
+//      if (folder != NULL)
+//              contacts_svc_value_free(folder);
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       contacts_record_h record = NULL;
+
+       /* get item */
+       int contact_folder_id = atoi(folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] contact_folder_id : %d\n", contact_folder_id);
+       err = contacts_db_get_record(_contacts_address_book._uri, contact_folder_id, &record);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_record() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *out_folder_name = 0;
+               *out_folder_type = -1;
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_get_record() Success!\n");
+               char *folder_name = NULL;
+               err = contacts_record_get_str(record, _contacts_address_book.name, &folder_name);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_str Fail\n");
+                       ret = _convert_service_error_to_common_error(err);
+                       goto DACI_FINISH;
+               }
+
+               _DEBUG_INFO("out_folder_name : %s", folder_name);
+               *out_folder_name = folder_name;
+               *out_folder_type = DEFAULT_CONTACT_FOLDER;
+       }
+
+ DACI_FINISH:
+
+       contacts_record_destroy(record, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_execute(int account_ID, const char *execute_key, void *execute_values, void **result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_contact_plugIn] service is not supported execute. \n");
+       *result = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_contact_plugIn] Start\n");
+
+//      int ret = SYNC_AGENT_DA_SUCCESS;
+//      int used_cnt = contacts_svc_count(CTS_GET_ALL_CONTACT);
+//      if (used_cnt < 0) {
+//              _DEBUG_INFO("[da_contact_plugIn] contact_svc_count() Fail\n");
+//              ret = _convert_service_error_to_common_error(used_cnt);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contact_svc_count() Success\n");
+//              _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
+//              ret = used_cnt;
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       int used_cnt = 0;
+
+       err = contacts_db_get_count(_contacts_contact._uri, &used_cnt);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_count() Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_get_count() Success\n");
+               _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return used_cnt;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(folder_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "folder_id is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[da_contact_plugIn] Start\n");
+
+//      int ret = SYNC_AGENT_DA_SUCCESS;
+//      int used_cnt = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK, atoi(folder_id));
+//      if (used_cnt < 0) {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_count_with_int(%s) Fail\n", folder_id);
+//              ret = _convert_service_error_to_common_error(used_cnt);
+//      } else {
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_count_with_int(%s) Success\n", folder_id);
+//              _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
+//              ret = used_cnt;
+//      }
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       int used_cnt = 0;
+
+       contacts_query_h query = NULL;
+       contacts_filter_h filter = NULL;
+
+       err = contacts_query_create(_contacts_contact._uri, &query);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_create Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_filter_create(_contacts_address_book._uri, &filter);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_create Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_filter_add_int(filter, _contacts_address_book.id, CONTACTS_MATCH_EQUAL, atoi(folder_id));
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_add_int Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_query_set_filter(query, filter);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_filter Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_db_get_count_with_query(query, &used_cnt);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_svc_count_with_int(%s) Fail\n", folder_id);
+               ret = _convert_service_error_to_common_error(used_cnt);
+       } else {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_svc_count_with_int(%s) Success\n", folder_id);
+               _DEBUG_INFO("[da_contact_plugIn] used_count = %d\n", used_cnt);
+       }
+
+ DACI_FINISH:
+
+       contacts_filter_destroy(filter);
+       contacts_query_destroy(query);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      char **folder_id_list = 0;
+//      *folder_count = 0;
+//      CTSiter *iter_addressbook = 0;
+//      CTSvalue *addressbook = 0;
+//
+//      if (account_id == -1) {
+//              folder_id_list = (char **)calloc(1, sizeof(char *));
+//              if( folder_id_list == NULL ) {
+//                      _DEBUG_ERROR("CALLOC failed !!!");
+//                      return NULL;
+//              }
+//              *folder_type_list = (int *)calloc(1, sizeof(int));
+//              if( *folder_type_list == NULL ) {
+//                      _DEBUG_ERROR("CALLOC failed !!!");
+//                      return NULL;
+//              }
+//
+//              folder_id_list[0] = "0";
+//              *folder_count = 1;
+//              (*folder_type_list)[0] = DEFAULT_CONTACT_FOLDER;
+//
+//              return folder_id_list;
+//      }
+//
+//      folder_id_list = (char **)calloc(50, sizeof(char *));
+//      if( folder_id_list == NULL ) {
+//              _DEBUG_ERROR("CALLOC failed !!!");
+//              return NULL;
+//      }
+//      *folder_type_list = (int *)calloc(50, sizeof(int));
+//      if( *folder_type_list == NULL ) {
+//              _DEBUG_ERROR("CALLOC failed !!!");
+//              return NULL;
+//      }
+//
+//      int err = contacts_svc_get_list_with_int(CTS_LIST_ADDRESSBOOKS_OF_ACCOUNT_ID, account_id, &iter_addressbook);
+//      err = contacts_svc_iter_next(iter_addressbook);
+//      while (err == CTS_SUCCESS) {
+//              addressbook = contacts_svc_iter_get_info(iter_addressbook);
+//              if (addressbook != NULL) {
+//                      int addressbook_id = 0;
+//                      addressbook_id = contacts_svc_value_get_int(addressbook, CTS_LIST_ADDRESSBOOK_ID_INT);
+//                      char *str_addressbook_id = g_strdup_printf("%d", addressbook_id);
+//                      _DEBUG_INFO("[da_contact_plugIn] addressbook_id : %d\n", addressbook_id);
+//
+//                      folder_id_list[*folder_count] = str_addressbook_id;
+//                      (*folder_type_list)[*folder_count] = DEFAULT_CONTACT_FOLDER;
+//                      *folder_count = *folder_count + 1;
+//
+//                      if (addressbook != NULL)
+//                              contacts_svc_value_free(addressbook);
+//
+//                      err = contacts_svc_iter_next(iter_addressbook);
+//              } else {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() Fail!\n");
+//                      break;
+//              }
+//      }
+//
+//      /* memory free */
+//      if (iter_addressbook != NULL) {
+//              contacts_svc_iter_remove(iter_addressbook);
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+
+       char **folder_id_list = 0;
+       *folder_count = 0;
+
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       contacts_query_h query = NULL;
+       contacts_filter_h filter = NULL;
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+
+       if (account_id == -1) {
+               folder_id_list = (char **)calloc(1, sizeof(char *));
+               if (folder_id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+               *folder_type_list = (int *)calloc(1, sizeof(int));
+               if (*folder_type_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return NULL;
+               }
+
+               folder_id_list[0] = "0";
+               *folder_count = 1;
+               (*folder_type_list)[0] = DEFAULT_CONTACT_FOLDER;
+
+               return folder_id_list;
+       }
+
+       folder_id_list = (char **)calloc(50, sizeof(char *));
+       if (folder_id_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+       *folder_type_list = (int *)calloc(50, sizeof(int));
+       if (*folder_type_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+
+               if (folder_id_list != NULL)
+                       free(folder_id_list);
+
+               return NULL;
+       }
+
+       err = contacts_query_create(_contacts_address_book._uri, &query);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_create Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_filter_create(_contacts_address_book._uri, &filter);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_create Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_filter_add_int(filter, _contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, account_id);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_set_int Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_query_set_filter(query, filter);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_filter Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+               goto DACI_FINISH;
+       }
+
+       err = contacts_db_get_records_with_query(query, 0, 0, &list);
+       if (err == CONTACTS_ERROR_NONE) {
+               _DEBUG_INFO("[da_contact_plugIn] contacts_db_get_records_with_query Success!! \n");
+
+               err = contacts_list_first(list);
+               while (err == CONTACTS_ERROR_NONE) {
+                       int addressbook_id = 0;
+
+                       err = contacts_list_get_current_record_p(list, &record);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+                               ret = _convert_service_error_to_common_error(err);
+                               goto DACI_FINISH;
+                       }
+
+                       err = contacts_record_get_int(record, _contacts_address_book.id, &addressbook_id);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+                               ret = _convert_service_error_to_common_error(err);
+                               goto DACI_FINISH;
+                       }
+
+                       char *str_addressbook_id = g_strdup_printf("%d", addressbook_id);
+                       _DEBUG_INFO("[da_contact_plugIn] addressbook_id : %d\n", addressbook_id);
+
+                       folder_id_list[*folder_count] = str_addressbook_id;
+                       (*folder_type_list)[*folder_count] = DEFAULT_CONTACT_FOLDER;
+                       *folder_count = *folder_count + 1;
+
+                       err = contacts_list_next(list);
+               }
+       }
+
+ DACI_FINISH:
+
+       contacts_filter_destroy(filter);
+       contacts_query_destroy(query);
+
+       contacts_list_destroy(list, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id_list;
+}
+
+EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_contact_plugIn] start!!\n");
+
+       int error_code = account_connect();
+
+       account_id_s *account_info_list = (account_id_s *) calloc(1, sizeof(account_id_s));
+       if (account_info_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+       account_info_list->account_id = -1;
+       account_info_list->next = 0;
+
+       account_foreach_account_from_db(_get_account_id, account_info_list);
+
+       *count = 0;
+       account_id_s *cursor_ptr = account_info_list;
+       while (cursor_ptr != 0) {
+               cursor_ptr = cursor_ptr->next;
+               (*count)++;
+       }
+
+       int *id_list = 0;
+       if ((*count) > 0) {
+               id_list = (int *)calloc(*count, sizeof(int));
+               if (id_list == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+         free(account_info_list);
+                       return NULL;
+               }
+               cursor_ptr = account_info_list;
+               int i = 0;
+               while (cursor_ptr != 0) {
+                       id_list[i] = cursor_ptr->account_id;
+                       cursor_ptr = cursor_ptr->next;
+                       i++;
+               }
+       }
+
+       free(account_info_list);
+
+       error_code = account_disconnect();
+
+       _DEBUG_INFO("[da_contact_plugIn] end!!\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return id_list;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+//      _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+//      _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+//
+//      sync_agent_plugin_item_node_s *root_ptr = 0;
+//      sync_agent_plugin_item_node_s *cursor_ptr = 0;
+//      int chagned_count = 0;
+//
+//      int contact_version = change_point;
+//
+//      int addressbook_id = atoi(folder_id);
+//      CTSiter *iter = 0;
+//      contacts_svc_get_updated_contacts(addressbook_id, contact_version, &iter);
+//
+//      int contact_ret = contacts_svc_iter_next(iter);
+//      while (CTS_SUCCESS == contact_ret) {
+//              CTSvalue *row_info = 0;
+//
+//              if ((row_info = contacts_svc_iter_get_info(iter)) == CTS_SUCCESS) {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() failed.\n");
+//              } else {
+//                      int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+//
+//                      switch (type) {
+//                      case CTS_OPERATION_INSERTED:
+//                              {
+//                                      int contact_id = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+//                                      char *contact_id_str = g_strdup_printf("%d", contact_id);
+//                                      _DEBUG_INFO("[da_contact_plugIn]  CTS_OPERATION_INSERTED : [%s]\n", contact_id_str);
+//
+//                                      if (root_ptr == NULL) {
+//                                              root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( root_ptr == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              root_ptr->item_id = contact_id_str;
+//                                              root_ptr->next = 0;
+//                                              cursor_ptr = root_ptr;
+//                                      } else {
+//                                              cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( cursor_ptr->next == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              cursor_ptr->next->item_id = contact_id_str;
+//                                              cursor_ptr->next->next = 0;
+//                                              cursor_ptr = cursor_ptr->next;
+//                                      }
+//
+//                                      chagned_count++;
+//                              }
+//                              break;
+//                      default:
+///*                            _DEBUG_INFO("[da_contact_plugIn] Another Contact Change Noti");*/
+//                              break;
+//                      }
+//              }
+//
+//              contacts_svc_value_free(row_info);      /* next changing */
+//              row_info = 0;
+//              contact_ret = contacts_svc_iter_next(iter);
+//      }
+//
+//      /* memory free */
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+//      *change_count = chagned_count;
+
+       _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+       int contact_version = change_point;
+       int addressbook_id = atoi(folder_id);
+
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       int current_contact_version;
+
+       err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &list, &current_contact_version);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version Fail\n");
+               goto DACI_FINISH;
+       }
+
+       err = contacts_list_first(list);
+       while (CONTACTS_ERROR_NONE == err) {
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+               } else {
+                       int type;
+                       err = contacts_record_get_int(record, _contacts_contact_updated_info.type, &type);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                               goto DACI_FINISH;
+                       }
+
+                       switch (type) {
+                       case CONTACTS_CHANGE_INSERTED:
+                               {
+                                       int contact_id;
+                                       err = contacts_record_get_int(record, _contacts_contact_updated_info.contact_id, &contact_id);
+                                       if (err != CONTACTS_ERROR_NONE) {
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                                               goto DACI_FINISH;
+                                       }
+
+                                       char *contact_id_str = g_strdup_printf("%d", contact_id);
+                                       _DEBUG_INFO("[da_contact_plugIn]  CTS_OPERATION_INSERTED : [%s]\n", contact_id_str);
+
+                                       if (root_ptr == NULL) {
+                                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (root_ptr == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               root_ptr->item_id = contact_id_str;
+                                               root_ptr->next = 0;
+                                               cursor_ptr = root_ptr;
+                                       } else {
+                                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (cursor_ptr->next == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               cursor_ptr->next->item_id = contact_id_str;
+                                               cursor_ptr->next->next = 0;
+                                               cursor_ptr = cursor_ptr->next;
+                                       }
+
+                                       chagned_count++;
+                               }
+                               break;
+                       default:
+                               /*_DEBUG_INFO("[da_contact_plugIn] Another Contact Change Noti");*/
+                               break;
+                       }
+                       err = contacts_list_next(list);
+               }
+       }
+
+ DACI_FINISH:
+
+       *change_count = chagned_count;
+
+       contacts_list_destroy(list, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+//      _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+//      _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+//
+//      sync_agent_plugin_item_node_s *root_ptr = 0;
+//      sync_agent_plugin_item_node_s *cursor_ptr = 0;
+//      int chagned_count = 0;
+//
+//      int contact_version = change_point;
+//
+//      int addressbook_id = atoi(folder_id);
+//      CTSiter *iter = 0;
+//      contacts_svc_get_updated_contacts(addressbook_id, contact_version, &iter);
+//
+//      int contact_ret = contacts_svc_iter_next(iter);
+//      while (CTS_SUCCESS == contact_ret) {
+//              CTSvalue *row_info = 0;
+//
+//              if ((row_info = contacts_svc_iter_get_info(iter)) == CTS_SUCCESS) {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() failed.\n");
+//              } else {
+//                      int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+//
+//                      switch (type) {
+//                      case CTS_OPERATION_DELETED:
+//                              {
+//                                      int contact_id = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+//                                      char *contact_id_str = g_strdup_printf("%d", contact_id);
+//                                      _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_DELETED : [%s]\n", contact_id_str);
+//
+//                                      if (root_ptr == NULL) {
+//                                              root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( root_ptr == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              root_ptr->item_id = contact_id_str;
+//                                              root_ptr->next = 0;
+//                                              cursor_ptr = root_ptr;
+//                                      } else {
+//                                              cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( cursor_ptr->next == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              cursor_ptr->next->item_id = contact_id_str;
+//                                              cursor_ptr->next->next = 0;
+//                                              cursor_ptr = cursor_ptr->next;
+//                                      }
+//
+//                                      chagned_count++;
+//                              }
+//                              break;
+//                      default:
+//                              break;
+//                      }
+//              }
+//
+//              contacts_svc_value_free(row_info);      /* next changing */
+//              row_info = 0;
+//              contact_ret = contacts_svc_iter_next(iter);
+//      }
+//
+//      /* memory free */
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+//
+//      *change_count = chagned_count;
+
+       _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+
+       int chagned_count = 0;
+       int contact_version = change_point;
+       int addressbook_id = atoi(folder_id);
+
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       int current_contact_version;
+
+       err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &list, &current_contact_version);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+               goto DACI_FINISH;
+       }
+
+       err = contacts_list_first(list);
+       while (err == CONTACTS_ERROR_NONE) {
+
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+               } else {
+                       int type;
+                       err = contacts_record_get_int(record, _contacts_contact_updated_info.type, &type);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                               goto DACI_FINISH;
+                       }
+
+                       switch (type) {
+                       case CONTACTS_CHANGE_DELETED:
+                               {
+                                       int contact_id;
+                                       err = contacts_record_get_int(record, _contacts_contact_updated_info.contact_id, &contact_id);
+                                       if (err != CONTACTS_ERROR_NONE) {
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                                               goto DACI_FINISH;
+                                       }
+
+                                       char *contact_id_str = g_strdup_printf("%d", contact_id);
+                                       _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_DELETED : [%s]\n", contact_id_str);
+
+                                       if (root_ptr == NULL) {
+                                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (root_ptr == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               root_ptr->item_id = contact_id_str;
+                                               root_ptr->next = 0;
+                                               cursor_ptr = root_ptr;
+                                       } else {
+                                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (cursor_ptr->next == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               cursor_ptr->next->item_id = contact_id_str;
+                                               cursor_ptr->next->next = 0;
+                                               cursor_ptr = cursor_ptr->next;
+                                       }
+
+                                       chagned_count++;
+                               }
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               err = contacts_list_next(list);
+       }
+
+ DACI_FINISH:
+
+       *change_count = chagned_count;
+
+       contacts_list_destroy(list, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int change_point, int *change_count)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+//      _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+//      _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+//
+//      sync_agent_plugin_item_node_s *root_ptr = 0;
+//      sync_agent_plugin_item_node_s *cursor_ptr = 0;
+//      int chagned_count = 0;
+//
+//      int contact_version = change_point;
+//
+//      int addressbook_id = atoi(folder_id);
+//      CTSiter *iter = 0;
+//      contacts_svc_get_updated_contacts(addressbook_id, contact_version, &iter);
+//
+//      int contact_ret = contacts_svc_iter_next(iter);
+//      while (CTS_SUCCESS == contact_ret) {
+//              CTSvalue *row_info = 0;
+//
+//              if ((row_info = contacts_svc_iter_get_info(iter)) == CTS_SUCCESS) {
+//                      _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_get_info() failed.\n");
+//              } else {
+//                      int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+//
+//                      switch (type) {
+//                      case CTS_OPERATION_UPDATED:
+//                              {
+//                                      int contact_id = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+//                                      char *contact_id_str = g_strdup_printf("%d", contact_id);
+//                                      _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_UPDATED : [%s]\n", contact_id_str);
+//
+//                                      if (root_ptr == NULL) {
+//                                              root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( root_ptr == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              root_ptr->item_id = contact_id_str;
+//                                              root_ptr->next = 0;
+//                                              cursor_ptr = root_ptr;
+//                                      } else {
+//                                              cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+//                                              if( cursor_ptr->next == NULL ) {
+//                                                      _DEBUG_ERROR("CALLOC failed !!!");
+//                                                      return NULL;
+//                                              }
+//                                              cursor_ptr->next->item_id = contact_id_str;
+//                                              cursor_ptr->next->next = 0;
+//                                              cursor_ptr = cursor_ptr->next;
+//                                      }
+//
+//                                      chagned_count++;
+//                              }
+//                              break;
+//                      default:
+//                              break;
+//                      }
+//              }
+//
+//              contacts_svc_value_free(row_info);      /* next changing */
+//              row_info = 0;
+//              contact_ret = contacts_svc_iter_next(iter);
+//      }
+//
+//      /* memory free */
+//      if (iter != NULL) {
+//              contacts_svc_iter_remove(iter);
+//              iter = 0;
+//              _DEBUG_INFO("[da_contact_plugIn] contacts_svc_iter_remove !! \n");
+//      }
+//
+//      *change_count = chagned_count;
+
+       _DEBUG_INFO("\n[da_contact_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_contact_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_contact_plugIn] changepoint : %d\n", change_point);
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+
+       int chagned_count = 0;
+       int contact_version = change_point;
+       int addressbook_id = atoi(folder_id);
+
+       contacts_list_h list = NULL;
+       contacts_record_h record = NULL;
+       contacts_error_e err = CONTACTS_ERROR_NONE;
+       int current_contact_version;
+
+       err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &list, &current_contact_version);
+       if (err != CONTACTS_ERROR_NONE) {
+               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version Fail\n");
+               goto DACI_FINISH;
+       }
+
+       err = contacts_list_first(list);
+       while (err == CONTACTS_ERROR_NONE) {
+
+               err = contacts_list_get_current_record_p(list, &record);
+               if (err != CONTACTS_ERROR_NONE) {
+                       _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+               } else {
+                       int type;
+                       err = contacts_record_get_int(record, _contacts_contact_updated_info.type, &type);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                               goto DACI_FINISH;
+                       }
+
+                       switch (type) {
+                       case CONTACTS_CHANGE_UPDATED:
+                               {
+                                       int contact_id;
+                                       err = contacts_record_get_int(record, _contacts_contact_updated_info.contact_id, &contact_id);
+                                       if (err != CONTACTS_ERROR_NONE) {
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+                                               goto DACI_FINISH;
+                                       }
+
+                                       char *contact_id_str = g_strdup_printf("%d", contact_id);
+                                       _DEBUG_INFO("[da_contact_plugIn] CTS_OPERATION_UPDATED : [%s]\n", contact_id_str);
+
+                                       if (root_ptr == NULL) {
+                                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (root_ptr == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               root_ptr->item_id = contact_id_str;
+                                               root_ptr->next = 0;
+                                               cursor_ptr = root_ptr;
+                                       } else {
+                                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                                               if (cursor_ptr->next == NULL) {
+                                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                                       return NULL;
+                                               }
+                                               cursor_ptr->next->item_id = contact_id_str;
+                                               cursor_ptr->next->next = 0;
+                                               cursor_ptr = cursor_ptr->next;
+                                       }
+
+                                       chagned_count++;
+                               }
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               err = contacts_list_next(list);
+       }
+
+ DACI_FINISH:
+
+       *change_count = chagned_count;
+
+       contacts_list_destroy(list, true);
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API int sync_agent_plugin_get_last_change_point(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      contacts_svc_begin_trans();
+//      int contactVersion = contacts_svc_end_trans(1);
+
+       int contactVersion;
+       contacts_db_get_current_version(&contactVersion);
+
+       _EXTERN_FUNC_EXIT;
+
+       return contactVersion;
+}
+
+EXPORT_API void sync_agent_plugin_start_listening_change_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+//      contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, _process_contact_change, 0);
+//
+//      latest_contact_version = get_contact_version(1);
+//      _DEBUG_INFO("Current Latest Contact Version : %d", latest_contact_version);
+//
+//      pthread_t thread_process_change_id;
+//      if (pthread_create(&thread_process_change_id, 0, _rutine_contact_change, 0) < 0) {
+//              _DEBUG_ERROR("Contact Change Noti Handling Thread Create Error");
+//      }
+
+       contacts_error_e err = contacts_db_add_changed_cb(_contacts_contact._uri, _process_contact_change, 0);
+       sync_agent_da_return_e ret = _convert_service_error_to_common_error(err);
+       _DEBUG_INFO("ret = %d", ret);
+
+       latest_contact_version = get_contact_version(1);
+       _DEBUG_INFO("Current Latest Contact Version : %d", latest_contact_version);
+
+       pthread_t thread_process_change_id;
+       if (pthread_create(&thread_process_change_id, 0, _rutine_contact_change, 0) < 0) {
+               _DEBUG_ERROR("Contact Change Noti Handling Thread Create Error");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_add_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_del_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_update_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_get_account_id_list = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_item_count(int folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return MAX_ITEM_COUNT_CONTACT;
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_length(int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (field_name) {
+       case CONTACT_FIELD_NAME:
+               switch (child_field_name) {
+               case CONTACT_CHILD_FIELD_FAMILY:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_FAMILY;
+               case CONTACT_CHILD_FIELD_GIVEN:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_GIVEN;
+               case CONTACT_CHILD_FIELD_MIDDLE:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_MIDDLE;
+               case CONTACT_CHILD_FIELD_PREFIX:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_PREFIX;
+               case CONTACT_CHILD_FIELD_SUFFIX:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_SUFFIX;
+               case CONTACT_CHILD_FIELD_FORMATTED:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_FORMATTED;
+               case CONTACT_CHILD_FIELD_NICKNAME:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_NICKNAME;
+               case CONTACT_CHILD_FIELD_READING_NAME:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_READING_NAME;
+               case CONTACT_CHILD_FIELD_READING_LAST_NAME:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_READING_LAST_NAME;
+               default:
+                       return -1;
+               }
+       case CONTACT_FIELD_TEL:
+               switch (child_field_name) {
+               case CONTACT_CHILD_FIELD_TEL:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_TEL;
+               default:
+                       return -1;
+               }
+       case CONTACT_FIELD_EMAIL:
+               switch (child_field_name) {
+               case CONTACT_CHILD_FIELD_EMAIL:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_EMAIL;
+               default:
+                       return -1;
+               }
+       case CONTACT_FIELD_URL:
+               switch (child_field_name) {
+               case CONTACT_CHILD_FIELD_URL:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_URL;
+               default:
+                       return -1;
+               }
+       case CONTACT_FIELD_ADDR:
+               switch (child_field_name) {
+               case CONTACT_CHILD_FIELD_POBOX:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_POBOX;
+               case CONTACT_CHILD_FIELD_EXT_ADDR:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_EXT_ADDR;
+               case CONTACT_CHILD_FIELD_STREET:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_STREET;
+               case CONTACT_CHILD_FIELD_LOCALITY:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_LOCALITY;
+               case CONTACT_CHILD_FIELD_REGION:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_REGION;
+               case CONTACT_CHILD_FIELD_POSTAL_CODE:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_POSTAL_CODE;
+               case CONTACT_CHILD_FIELD_COUNTRY:
+                       _EXTERN_FUNC_EXIT;
+                       return MAX_LEN_COUNTRY;
+               default:
+                       return -1;
+               }
+       case CONTACT_FIELD_NOTE:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_NOTE;
+       case CONTACT_FIELD_COMPANY:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_COMPANY;
+       case CONTACT_FIELD_DEPARTMENT:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_DEPARTMENT;
+       case CONTACT_FIELD_TITLE:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_TITLE;
+       case CONTACT_FIELD_HOBBY:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_HOBBY;
+       case CONTACT_FIELD_PHOTO:
+               _EXTERN_FUNC_EXIT;
+               return MAX_LEN_PHOTO;
+       default:
+               return -1;
+       }
+}
+
+EXPORT_API int sync_agent_plugin_get_max_field_count(int field_name, int child_field_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (field_name) {
+       case CONTACT_FIELD_TEL:
+               _EXTERN_FUNC_EXIT;
+               return MAX_FIELD_COUNT_TEL;
+       case CONTACT_FIELD_EMAIL:
+               _EXTERN_FUNC_EXIT;
+               return MAX_FIELD_COUNT_EMAIL;
+       case CONTACT_FIELD_URL:
+               _EXTERN_FUNC_EXIT;
+               return MAX_FIELD_COUNT_URL;
+       case CONTACT_FIELD_ADDR:
+               _EXTERN_FUNC_EXIT;
+               return MAX_FIELD_COUNT_ADDR;
+       default:
+               return -1;
+       }
+}
+
+EXPORT_API int sync_agent_plugin_get_field_value(int field_name, int child_field_name, char **str_val, int *num_val1, int *num_val2)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (field_name) {
+       case CONTACT_FIELD_YEAR:
+               *num_val1 = MIN_PERIOD_YEAR;
+               *num_val2 = MAX_PERIOD_YEAR;
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       default:
+               return -1;
+       }
+}
+
+EXPORT_API int sync_agent_plugin_get_is_support_feature(int feature)
+{
+       _EXTERN_FUNC_ENTER;
+
+       switch (feature) {
+       case CONTACT_FEATURE_GENDER:
+               _EXTERN_FUNC_EXIT;
+               return IF_SUPPORT_GENDER;
+       default:
+               return -1;
+       }
+}
+
+/********************************** static function *******************************************/
+
+static void _set_is_noti_from_me(int set_flag)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pthread_mutex_lock(&lockx)) {
+               _DEBUG_TRACE("[da_contact_plugIn] pthread_mutex_lock error\n");
+       }
+
+       is_noti_from_me = set_flag;
+       _DEBUG_TRACE("[da_contact_plugIn] is_noti_from_me set [%d]", set_flag);
+
+       if (pthread_mutex_unlock(&lockx)) {
+               _DEBUG_TRACE("[da_contact_plugIn] pthread_mutex_unlock error\n");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int _get_is_noti_from_me(void)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("[da_contact_plugIn] is_noti_from_me get [%d]", is_noti_from_me);
+
+       _INNER_FUNC_EXIT;
+
+       return is_noti_from_me;
+}
+
+//static void _process_contact_change(void *data)
+//{
+//      _INNER_FUNC_ENTER;
+//
+//      _DEBUG_TRACE("[da_contact_plugIn] detected contact storage changed!!\n");
+//
+//      int from_Me = _get_is_noti_from_me();
+//
+//      if (from_Me == 1) {
+//              _DEBUG_TRACE("[da_contact_plugIn] This noti has been sended from Me!! so will be ignored!!\n");
+//              _set_is_noti_from_me(0);
+//              latest_contact_version++;
+//              return;
+//      }
+//
+//      int *contactVersion = (int *)calloc(1, sizeof(int));
+//      if( contactVersion == NULL ) {
+//              _DEBUG_ERROR("CALLOC failed !!!");
+//              return;
+//      }
+//      *contactVersion = latest_contact_version;
+//      latest_contact_version++;
+//
+//
+//      _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+//      if( sync_agent_async_queue_length(queue) < 1 ) {
+//              sync_agent_send_msg_async_queue(queue, (void *)contactVersion);
+//              _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+//      }
+//
+//      _INNER_FUNC_EXIT;
+//}
+
+static void _process_contact_change(const char *view_uri, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("[da_contact_plugIn] detected contact storage changed!!\n");
+
+       int from_Me = _get_is_noti_from_me();
+
+       if (from_Me == 1) {
+               _DEBUG_TRACE("[da_contact_plugIn] This noti has been sended from Me!! so will be ignored!!\n");
+               _set_is_noti_from_me(0);
+               latest_contact_version++;
+               return;
+       }
+
+       int *contactVersion = (int *)calloc(1, sizeof(int));
+       if (contactVersion == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return;
+       }
+       *contactVersion = latest_contact_version;
+       latest_contact_version++;
+
+       _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+       if (sync_agent_async_queue_length(queue) < 1) {
+               sync_agent_send_msg_async_queue(queue, (void *)contactVersion);
+               _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void *_rutine_contact_change(void *data)
+{
+       _INNER_FUNC_ENTER;
+
+//      _DEBUG_TRACE("[da_contact_plugIn] Start __rutine_Contact_Change (create thread)\n");
+//
+//      /*
+//       * Create Queue
+//       */
+//      queue = sync_agent_alloc_async_queue();
+//      if (queue == NULL) {
+//              _DEBUG_ERROR("Failed to call fw_async_quecontacts_svc_get_updated_contactsue_alloc()");
+//              return 0;
+//      }
+//
+//      while (1) {
+//              _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+//              int *temp_contact_version = sync_agent_receive_msg_async_queue(queue);
+//              _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+//              int contact_version = *temp_contact_version;
+//              free(temp_contact_version);
+//
+//              _DEBUG_TRACE("Detected Change ContactVersion : %d", contact_version);
+//
+//              int count;
+//              int *accountList = callback_get_account_id_list(FW_CONTACT, &count);
+//              if (accountList == NULL)
+//                      continue;
+//
+//              int i = 0;
+//              for (; i < count; i++) {
+//                      int contact_account_id = accountList[i];
+//
+//                      _DEBUG_TRACE("[da_contact_plugIn] contact_account_id : %d, count : %d\n", contact_account_id, count);
+//                      _DEBUG_TRACE("[da_contact_plugIn] Before contacts_svc_get_updated_contacts : %d\n", contact_version);
+//
+//                      CTSiter *iter_addressbook = 0;
+//                      CTSvalue *addressbook = 0;
+//
+//                      int err = contacts_svc_get_list_with_int(CTS_LIST_ADDRESSBOOKS_OF_ACCOUNT_ID, contact_account_id, &iter_addressbook);
+//                      err = contacts_svc_iter_next(iter_addressbook);
+//                      _DEBUG_TRACE("[da_contact_plugIn] err : %d\n", err);
+//
+//                      if (err != CTS_SUCCESS && contact_account_id == -1) {
+//                              err = CTS_SUCCESS;
+//                      }
+//
+//                      while (err == CTS_SUCCESS) {
+//                              if (contact_account_id != -1)
+//                                      addressbook = contacts_svc_iter_get_info(iter_addressbook);
+//
+//                              if (addressbook != NULL || contact_account_id == -1) {
+//                                      int addressbook_id = 0;
+//                                      if (contact_account_id != -1)
+//                                              addressbook_id = contacts_svc_value_get_int(addressbook, CTS_LIST_ADDRESSBOOK_ID_INT);
+//
+//                                      char *str_addressbook_id = g_strdup_printf("%d", addressbook_id);
+//                                      _DEBUG_TRACE("[da_contact_plugIn] addressbook_id : %d\n", addressbook_id);
+//
+//                                      CTSiter *iter = 0;
+//                                      int temp_err = contacts_svc_get_updated_contacts(addressbook_id, contact_version, &iter);
+//                                      _DEBUG_TRACE("temp_err =%d", temp_err);
+//
+//                                      int contact_ret = contacts_svc_iter_next(iter);
+//                                      while (CTS_SUCCESS == contact_ret) {
+//                                              CTSvalue *row_info = 0;
+//
+//                                              if ((row_info = contacts_svc_iter_get_info(iter)) == CTS_SUCCESS) {
+//                                                      _DEBUG_TRACE("[da_contact_plugIn] contacts_svc_iter_get_info() failed.\n");
+//                                              } else {
+//                                                      int contact_id = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_ID_INT);
+//                                                      char contact_id_str[12];
+//                                                      snprintf(contact_id_str, sizeof(contact_id_str), "%d", contact_id);
+//                                                      int type = contacts_svc_value_get_int(row_info, CTS_LIST_CHANGE_TYPE_INT);
+//                                                      _DEBUG_TRACE("[da_contact_plugIn] $$$$$$$ contact_id :%d\n", contact_id);
+//
+//                                                      switch (type) {
+//                                                      case CTS_OPERATION_INSERTED:
+//                                                              {
+//                                                                      _DEBUG_TRACE("[da_contact_plugIn]  CTS_OPERATION_INSERTED\n");
+//
+//                                                                      int result = callback_add_item(accountList[i], i, contact_id_str, FW_CONTACT, str_addressbook_id, 0);
+//                                                                      _DEBUG_TRACE("[da_contact_plugIn] ===1\n");
+//                                                                      if (!result)
+//                                                                              _DEBUG_TRACE("[da_contact_plugIn] Failed to call callback_add_item() \n");
+//                                                              }
+//                                                              break;
+//                                                      case CTS_OPERATION_UPDATED:
+//                                                              {
+//                                                                      _DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_UPDATED\n");
+//                                                                      _DEBUG_TRACE("[da_contact_plugIn] contact_id : %s\n", contact_id_str);
+//
+//                                                                      int result = callback_update_item(accountList[i], i, contact_id_str, FW_CONTACT);
+//                                                                      if (!result)
+//                                                                              _DEBUG_TRACE("[da_contact_plugIn] Failed to call callback_update_item() \n");
+//                                                              }
+//                                                              break;
+//                                                      case CTS_OPERATION_DELETED:
+//                                                              {
+//                                                                      _DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_DELETED\n");
+//                                                                      int result = callback_del_item(accountList[i], i, contact_id_str, FW_CONTACT);
+//                                                                      if (!result)
+//                                                                              _DEBUG_TRACE("[da_contact_plugIn] Failed to call callback_del_item() \n");
+//                                                              }
+//                                                              break;
+//                                                      default:
+//                                                              _DEBUG_TRACE("[da_contact_plugIn] Another Contact Change Noti\n");
+//                                                              break;
+//                                                      }
+//                                              }
+//
+//                                              contacts_svc_value_free(row_info);      /* next changing */
+//                                              row_info = NULL;
+//                                              contact_ret = contacts_svc_iter_next(iter);
+//                                      }
+//
+//                                      if (contact_account_id == -1)
+//                                              err = CTS_ERR_FINISH_ITER;
+//                                      else
+//                                              err = contacts_svc_iter_next(iter_addressbook);
+//
+//                                      if (addressbook != NULL)
+//                                              contacts_svc_value_free(addressbook);
+//
+//                                      if (iter != NULL)
+//                                              contacts_svc_iter_remove(iter);
+//
+//                                      if (str_addressbook_id != NULL) {
+//                                              free(str_addressbook_id);
+//                                      }
+//
+//                              } else {
+//                                      _DEBUG_TRACE("[da_contact_plugIn] account : %d, contact folder does not exist \n", contact_account_id);
+//                                      break;
+//                              }
+//                      }
+//
+//                      if (contact_account_id != -1) {
+//                              contacts_svc_iter_remove(iter_addressbook);
+//                      }
+//              }
+//
+//              /* memory free */
+//              if (accountList != NULL)
+//                      free(accountList);
+//      }
+//
+//      _DEBUG_TRACE("[da_contact_plugIn] End __rutine_Contact_Change (create thread)\n");
+
+       _DEBUG_TRACE("[da_contact_plugIn] Start __rutine_Contact_Change (create thread)\n");
+
+       /*
+        * Create Queue
+        */
+       queue = sync_agent_alloc_async_queue();
+       if (queue == NULL) {
+               _DEBUG_ERROR("Failed to call sync_agent_alloc_async_queue()");
+               return 0;
+       }
+       // open contact service
+       sync_agent_plugin_open_service();
+
+       while (1) {
+               _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+               int *temp_contact_version = sync_agent_receive_msg_async_queue(queue);
+               _DEBUG_TRACE("fw_async_queue_length = %d", sync_agent_async_queue_length(queue));
+               int contact_version = *temp_contact_version;
+               free(temp_contact_version);
+
+               _DEBUG_TRACE("Detected Change ContactVersion : %d", contact_version);
+
+               int count;
+               int *accountList = callback_get_account_id_list(FW_CONTACT, &count);
+               if (accountList == NULL)
+                       continue;
+
+               int i = 0;
+               for (; i < count; i++) {
+                       int contact_account_id = accountList[i];
+
+                       _DEBUG_TRACE("[da_contact_plugIn] contact_account_id : %d, count : %d\n", contact_account_id, count);
+                       _DEBUG_TRACE("[da_contact_plugIn] Before contacts_db_get_changes_by_version : %d\n", contact_version);
+
+                       contacts_error_e err = CONTACTS_ERROR_NONE;
+                       contacts_query_h query = NULL;
+                       contacts_filter_h filter = NULL;
+                       contacts_list_h address_book_list = NULL;
+                       contacts_list_h contact_list = NULL;
+                       contacts_record_h address_book_record = NULL;
+                       contacts_record_h contact_record = NULL;
+
+                       unsigned int projections[] = {
+                               _contacts_address_book.id
+                       };
+
+                       err = contacts_query_create(_contacts_address_book._uri, &query);
+                       if (err != CONTACTS_ERROR_NONE)
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_create Fail\n");
+
+                       err = contacts_filter_create(_contacts_address_book._uri, &filter);
+                       if (err != CONTACTS_ERROR_NONE)
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_create Fail\n");
+
+                       err = contacts_filter_add_int(filter, _contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, contact_account_id);
+                       if (err != CONTACTS_ERROR_NONE)
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_filter_set_int Fail\n");
+
+                       err = contacts_query_set_filter(query, filter);
+                       if (err != CONTACTS_ERROR_NONE)
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_filter Fail\n");
+
+                       err = contacts_query_set_projection(query, projections, 1);
+                       if (err != CONTACTS_ERROR_NONE)
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_query_set_projection Fail\n");
+
+                       err = contacts_db_get_records_with_query(query, 0, 0, &address_book_list);
+                       if (err != CONTACTS_ERROR_NONE) {
+                               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_records_with_query Fail\n");
+                               _DEBUG_ERROR("err = %d", err);
+                       }
+//                      err = contacts_list_first(address_book_list);
+//                      _DEBUG_TRACE("[da_contact_plugIn] err : %d\n", err);
+//                      if (err != CONTACTS_ERROR_NONE && contact_account_id == -1)
+//                              err = CONTACTS_ERROR_NONE;
+
+                       while (err == CONTACTS_ERROR_NONE) {
+                               if (contact_account_id != -1) {
+                                       err = contacts_list_get_current_record_p(address_book_list, &address_book_record);
+                                       if (err != CONTACTS_ERROR_NONE)
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+                               }
+
+                               if (address_book_record != NULL || contact_account_id == -1) {
+                                       int addressbook_id = 0;
+                                       if (contact_account_id != -1) {
+                                               err = contacts_record_get_int(address_book_record, _contacts_address_book.id, &addressbook_id);
+                                               if (err != CONTACTS_ERROR_NONE)
+                                                       _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+                                       }
+
+                                       char *str_addressbook_id = g_strdup_printf("%d", addressbook_id);
+                                       _DEBUG_TRACE("[da_contact_plugIn] addressbook_id : %d\n", addressbook_id);
+
+                                       int current_contact_version;
+                                       err = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, addressbook_id, contact_version, &contact_list, &current_contact_version);
+                                       if (err != CONTACTS_ERROR_NONE)
+                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_db_get_changes_by_version Fail\n");
+
+                                       err = contacts_list_first(contact_list);
+                                       _DEBUG_TRACE("err = %d", err);
+                                       while (err == CONTACTS_ERROR_NONE) {
+
+                                               err = contacts_list_get_current_record_p(contact_list, &contact_record);
+                                               if (err != CONTACTS_ERROR_NONE) {
+                                                       _DEBUG_ERROR("[da_contact_plugIn] contacts_list_get_current_record_p Fail\n");
+                                               } else {
+                                                       int contact_id;
+                                                       char contact_id_str[12];
+                                                       int type;
+
+                                                       err = contacts_record_get_int(contact_record, _contacts_contact_updated_info.contact_id, &contact_id);
+                                                       if (err != CONTACTS_ERROR_NONE)
+                                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+
+                                                       snprintf(contact_id_str, sizeof(contact_id_str), "%d", contact_id);
+
+                                                       err = contacts_record_get_int(contact_record, _contacts_contact_updated_info.type, &type);
+                                                       if (err != CONTACTS_ERROR_NONE)
+                                                               _DEBUG_ERROR("[da_contact_plugIn] contacts_record_get_int Fail\n");
+
+                                                       _DEBUG_TRACE("[da_contact_plugIn] $$$$$$$ contact_id :%d\n", contact_id);
+
+                                                       switch (type) {
+                                                       case CONTACTS_CHANGE_INSERTED:
+                                                               {
+                                                                       _DEBUG_TRACE("[da_contact_plugIn]  CTS_OPERATION_INSERTED\n");
+
+                                                                       int result = callback_add_item(accountList[i], i, contact_id_str, FW_CONTACT, str_addressbook_id, 0);
+                                                                       _DEBUG_TRACE("[da_contact_plugIn] ===1\n");
+                                                                       if (!result)
+                                                                               _DEBUG_ERROR("[da_contact_plugIn] Failed to call callback_add_item() \n");
+                                                               }
+                                                               break;
+                                                       case CONTACTS_CHANGE_UPDATED:
+                                                               {
+                                                                       _DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_UPDATED\n");
+                                                                       _DEBUG_TRACE("[da_contact_plugIn] contact_id : %s\n", contact_id_str);
+
+                                                                       int result = callback_update_item(accountList[i], i, contact_id_str, FW_CONTACT);
+                                                                       if (!result)
+                                                                               _DEBUG_ERROR("[da_contact_plugIn] Failed to call callback_update_item() \n");
+                                                               }
+                                                               break;
+                                                       case CONTACTS_CHANGE_DELETED:
+                                                               {
+                                                                       _DEBUG_TRACE("[da_contact_plugIn] CTS_OPERATION_DELETED\n");
+                                                                       int result = callback_del_item(accountList[i], i, contact_id_str, FW_CONTACT);
+                                                                       if (!result)
+                                                                               _DEBUG_ERROR("[da_contact_plugIn] Failed to call callback_del_item() \n");
+                                                               }
+                                                               break;
+                                                       default:
+                                                               _DEBUG_TRACE("[da_contact_plugIn] Another Contact Change Noti\n");
+                                                               break;
+                                                       }
+
+                                               }
+
+                                               err = contacts_list_next(contact_list);
+                                       }
+
+                                       if (str_addressbook_id != NULL) {
+                                               free(str_addressbook_id);
+                                       }
+
+                                       contacts_list_destroy(contact_list, true);
+                               } else {
+                                       _DEBUG_TRACE("[da_contact_plugIn] account : %d, contact folder does not exist \n", contact_account_id);
+                                       break;
+                               }
+
+                               err = contacts_list_next(address_book_list);
+                               _DEBUG_TRACE("contacts_list_next = %d", err);
+                       }
+
+                       contacts_query_destroy(query);
+                       contacts_filter_destroy(filter);
+                       contacts_list_destroy(address_book_list, true);
+               }
+
+               /* memory free */
+               if (accountList != NULL)
+                       free(accountList);
+
+       }
+
+       //  close contact service
+       sync_agent_plugin_close_service();
+
+       _DEBUG_TRACE("[da_contact_plugIn] End __rutine_Contact_Change (create thread)\n");
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(contacts_error_e err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_contact_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       case CONTACTS_ERROR_NONE:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_NONE");
+               ret = SYNC_AGENT_DA_SUCCESS;
+               break;
+       case CONTACTS_ERROR_OUT_OF_MEMORY:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_OUT_OF_MEMORY");
+               ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               break;
+       case CONTACTS_ERROR_INVALID_PARAMETER:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_INVALID_PARAMETER");
+               ret = SYNC_AGENT_DA_ERR_INVALID_PARAMETER;
+               break;
+       case CONTACTS_ERROR_NO_DATA:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_NO_DATA");
+               ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               break;
+       case CONTACTS_ERROR_DB:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_DB");
+               ret = SYNC_AGENT_DA_ERR_SERVICE_DB;
+               break;
+       case CONTACTS_ERROR_IPC:
+               _DEBUG_TRACE("[da_contact_plugIn] Error Code CONTACTS_ERROR_IPC");
+               ret = SYNC_AGENT_DA_ERR_SERVICE_IPC;
+               break;
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+static bool _get_account_id(account_h account, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       account_id_s *account_info_list = user_data;
+
+       bool has_contact = FALSE;
+
+       account_get_capability_all(account, __is_contact_id, &has_contact);
+
+       if (has_contact == FALSE) {
+               /* DO Nothing */
+       } else {
+               char *domain_name = NULL;
+               account_error_e error_code = account_get_domain_name(account, &domain_name);
+               if (error_code != ACCOUNT_ERROR_NONE) {
+                       _DEBUG_ERROR("Failed to call account_get_domain_name()");
+                       return has_contact;
+               }
+
+               /*local service id already in id list so pass */
+               if (strcmp(domain_name, "Gmail") && strcmp(domain_name, "exchange")) {
+                       _DEBUG_TRACE("domain is [%s] is not gmail&exchange");
+                       return has_contact;
+               }
+
+               account_id_s *account_info = (account_id_s *) calloc(1, sizeof(account_id_s));
+               if (account_info == NULL) {
+                       _DEBUG_ERROR("CALLOC failed !!!");
+                       return FALSE;
+               }
+               account_get_account_id(account, &(account_info->account_id));
+               _DEBUG_TRACE("Getted accont id : %d", account_info->account_id);
+               account_info->next = 0;
+
+               account_id_s *cursor_ptr = account_info_list;
+               while (cursor_ptr->next != 0) {
+                       cursor_ptr = cursor_ptr->next;
+               }
+
+               cursor_ptr->next = account_info;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return has_contact;
+}
+
+static bool __is_contact_id(/*account_capability_type_e*/ const char* capability_type, account_capability_state_e capability_value, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+       retvm_if(capability_type == NULL, FALSE, "capability_type is NULL !!");
+
+       bool *has_contact = user_data;
+       //if (capability_type == ACCOUNT_CAPABILITY_CONTACT) {
+       if (strncmp(capability_type, ACCOUNT_SUPPORTS_CAPABILITY_CONTACT, strlen(capability_type)) ==0) {
+               *has_contact = TRUE;
+               _INNER_FUNC_EXIT;
+               return FALSE;
+       }
+       _INNER_FUNC_EXIT;
+       return TRUE;
+}
+
+static void _contacts_db_result_cb(int error, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+       _DEBUG_TRACE("error = %d", error);
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/fw-plugins/common-public/http/CMakeLists.txt b/src/fw-plugins/common-public/http/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..f14ca06
--- /dev/null
@@ -0,0 +1,41 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "na-http")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       libsoup-2.4
+                                       libcurl
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${na-http_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${na-http_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/http/include/http_status.h b/src/fw-plugins/common-public/http/include/http_status.h
new file mode 100755 (executable)
index 0000000..6720fc9
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HTTP_STATUS_H_
+#define HTTP_STATUS_H_
+
+typedef enum {
+       /*
+        *      Transport Error
+        */
+       SOUP_CANCELED = 1,
+       SOUP_CANT_RESOLVE,
+       SOUP_CANT_RESOLVE_PROXY,
+       SOUP_CANT_CONNECT,
+       SOUP_CANT_CONNECT_PROXY,
+       SOUP_SSL_FAILED,
+       SOUP_MALFORMED,
+       SOUP_TRY_AGAIN,
+       SOUP_TOO_MANY_REDIRECTS,
+
+       /*
+        *      Informational
+        */
+       CONTINUE = 100,
+       SWITCHING_PROTOCOLS = 101,
+       PROCESSING = 102,       /* WebDAV */
+       CHECKPOINT = 103,
+
+       /*
+        *      Successful
+        */
+       OK = 200,
+       CREATED = 201,
+       ACCEPTED = 202,
+       NON_AUTHORITATIVE_INFORMATION = 203,
+       NO_CONTENT = 204,
+       RESET_CONTENT = 205,
+       PARTIAL_CONTENT = 206,
+       MULTI_STATUS = 207,     /* WebDAV */
+       IM_USED = 208,
+
+       /*
+        *      Redirection
+        */
+       MULTIPLE_CHOICES = 300,
+       MOVED_PERMANENTLY = 301,
+       FOUND = 302,
+       SEE_OTHER = 303,
+       NOT_MODIFIED = 304,
+       USE_PROXY = 305,
+       /* SWITCH_PROXY = 306, *//* Unused */
+       TEMPORARY_REDIRECT = 307,
+       RESUME_INCOMPLETE = 308,
+
+       /*
+        *      Client Error
+        */
+       BAD_REQUEST = 400,
+       UNAUTHORIZED = 401,
+       PAYMENT_REQUIRED = 402,
+       FORBIDDEN = 403,
+       NOT_FOUND = 404,
+       METHOD_NOT_ALLOWED = 405,
+       NOT_ACCEPTABLE = 406,
+       PROXY_AUTHENTICATION_REQUIRED = 407,
+       REQUEST_TIMEOUT = 408,
+       CONFLICT = 409,
+       GONE = 410,
+       LENGTH_REQUIRED = 411,
+       PRECONDITION_FAILED = 412,
+       REQUEST_ENTITY_TOO_LARGE = 413,
+       REQUEST_URI_TOO_LONG = 414,
+       UNSUPPORTED_MEDIA_TYPE = 415,
+       REQUESTED_RANGE_NOT_SATISFIABLE = 416,
+       EXPECTATION_FAILED = 417,
+       IM_A_TEAPOT = 418,
+       UNPROCESSABLE_ENTITY = 422,     /* WebDAV */
+       LOCKED = 423,           /* WebDAV */
+       FAILED_DEPENDENCY = 424,        /* WebDAV */
+       UNORDERED_COLLECTION = 425,
+       UPGRADE_REQUIRED = 426,
+       NO_RESPONSE = 444,
+       RETRY_WITH = 449,
+       BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450,
+       CLIENT_CLOSED_REQUEST = 499,
+
+       /*
+        *      Server Error
+        */
+       INTERNAL_SERVER_ERROR = 500,
+       NOT_IMPLEMENTED = 501,
+       BAD_GATEWAY = 502,
+       SERVICE_UNAVAILABLE = 503,
+       GATEWAY_TIMEOUT = 504,
+       HTTP_VERSION_NOT_SUPPORTED = 505,
+       VARIANT_ALSO_NEGOTIATES = 506,
+       INSUFFICIENT_STORAGE = 507,     /* WebDAV */
+       BANDWIDTH_LIMIT_EXCEEDED = 509, /* Apache bw / timited extension */
+       NOT_EXTENDED = 510,
+
+} http_status_e;
+
+#endif                         /* HTTP_STATUS_H_ */
diff --git a/src/fw-plugins/common-public/http/include/na_external.h b/src/fw-plugins/common-public/http/include/na_external.h
new file mode 100755 (executable)
index 0000000..7464a03
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NA_EXTERNALL_H_
+#define NA_EXTERNAL_H_
+
+typedef struct {
+       char *key;
+       char *value;
+} common_header_info_s;
+
+#endif                         /* NA_EXTERNAL_H_ */
diff --git a/src/fw-plugins/common-public/http/src/plugin_interface.c b/src/fw-plugins/common-public/http/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..ffedd2d
--- /dev/null
@@ -0,0 +1,1927 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+//#define USING_LIBSOUP
+/* #define time_check */
+//#define CBA
+
+#ifdef USING_LIBSOUP
+#include <libsoup/soup-uri.h>
+#include <libsoup/soup.h>
+#else
+#include <curl/curl.h>
+#include <ctype.h>
+#endif
+
+#include <time.h>
+
+//#include <dlog.h>
+
+#include "na_external.h"
+#include "http_status.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#include "plugin/network_access_interface.h"
+
+#ifdef CBA
+#include <openssl/ssl.h>
+#include <errno.h>
+#endif
+
+#define SEMI_COLON_LEN                 1
+#define NULL_LEN                                               1
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_NA_HTTP"
+#endif
+
+#ifdef USING_LIBSOUP
+typedef struct {
+       SoupSession *session;
+       CURL *session;
+       char *id;
+       char *password;
+} auth_info_s;
+
+static int _add_auth_info(SoupSession * session, char *user_id, char *user_pw);
+                                                                                                                                                                    /*static int remove_auth_info(SoupSession *session); *//*      not used        */
+static int _find_auth_info(SoupSession * session, auth_info_s ** auth_info);
+static void authenticate_cb(SoupSession * session, SoupMessage * msg, SoupAuth * auth, gboolean retrying, gpointer user_data);
+
+static GList *auth_info_list = NULL;
+#else
+typedef enum {
+       LIBCURL_HTTP_GET = 0,
+       LIBCURL_HTTP_PUT,
+       LIBCURL_HTTP_POST,
+       LIBCURL_HTTP_TRACE,
+       LIBCURL_HTTP_CONNECT,
+       LIBCURL_HTTP_HEAD,
+       LIBCURL_HTTP_DELETE,
+       LIBCURL_HTTP_OPTIONS
+} libcurl_http_method_e;
+
+typedef struct {
+       char *buff;
+       int length;
+       int block_size;
+} http_buffer_s;
+
+#ifdef CBA
+typedef struct {
+       int accept_all_certs;
+       char *privatekey_password;
+       char *certificate_path;
+       unsigned char *privatekey;
+} certificate_info_s;
+#endif
+
+typedef struct {
+       libcurl_http_method_e method;
+       char *uri;
+       char *accept_encoding;
+       struct curl_slist *send_header;
+       http_buffer_s *response_header;
+       http_buffer_s *response_body;
+       int http_status;
+       int abort;
+       void *session;
+#ifdef CBA
+       certificate_info_s *cert_info;
+#endif
+} http_message_s;
+
+typedef struct {
+       CURL *session;
+       http_message_s *msg;
+} curl_session_s;
+
+#define HEADER_BLOCK_SIZE              (1024)
+#define CONTENT_BLOCK_SIZE             (16*1024)
+
+static int curl_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
+
+static int _curl_session_abort(curl_session_s * session);
+
+static http_buffer_s *__create_http_buffer(int block_size);
+static int __delete_http_buffer(http_buffer_s * buff);
+static size_t write_http_buffer_cb(void *ptr, size_t size, size_t nmemb, void *userdata);
+
+#ifdef CBA
+static http_message_s *_create_http_message(libcurl_http_method_e method, char *uri, char *accept_encoding, int is_cert);
+#else
+static http_message_s *_create_http_message(libcurl_http_method_e method, char *uri, char *accept_encoding);
+#endif
+
+static int _add_http_header(http_message_s * msg, char *key, char *value);
+static int _delete_http_message(http_message_s * msg);
+
+static int _parse_http_header(http_buffer_s * header, GList ** header_list);
+
+static common_header_info_s *__create_header_info(char *key, char *value);
+
+#ifdef CBA
+static void _add_certificate_option(CURL * curl, http_message_s * msg);
+static CURLcode ssl_context_cb(CURL * curl, SSL_CTX * sslctx, void *param);
+static int verify_peer_cb(int preverify_ok, X509_STORE_CTX * x509_ctx);
+#endif
+
+#endif
+
+#ifdef USING_LIBSOUP
+EXPORT_API int sync_agent_plugin_open_connection(void **session, char *proxy, int timeout)
+{
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+
+       /*
+        *      create session
+        */
+       SoupSession *ss = (SoupSession *) (*session);
+       SoupURI *proxy_uri = NULL;
+
+       _DEBUG_INFO("proxy : %s", proxy);
+
+       /*
+        *      proxy setting
+        */
+       if (proxy != NULL) {
+               proxy_uri = soup_uri_new(proxy);
+               ss = soup_session_sync_new_with_options(SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
+       } else {
+               ss = soup_session_sync_new();
+       }
+
+       g_object_set(ss, SOUP_SESSION_TIMEOUT, timeout, NULL);
+       _DEBUG_INFO("[na_http_plugIn] set timeout : %d", timeout);
+
+       _DEBUG_INFO("[na_http_plugIn] session : %d\n", ss);
+
+       if (ss != NULL) {
+               _DEBUG_INFO("[na_http_plugIn] success !! \n");
+       } else {
+               _DEBUG_ERROR("[na_http_plugIn] fail !! \n");
+               res = 0;
+       }
+
+       *session = ss;
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       return res;
+}
+#else
+EXPORT_API int sync_agent_plugin_open_connection(void **session, char *proxy, int timeout)
+{
+       _EXTERN_FUNC_ENTER;
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+
+       /*
+        *      create session
+        */
+
+       curl_session_s *curl_session = (curl_session_s *) calloc(1, sizeof(curl_session_s));
+       if (curl_session == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       CURL *curl;
+       CURLcode ret;
+
+       _DEBUG_INFO("proxy : %s", proxy);
+
+       /*
+        *      proxy setting
+        */
+       curl = curl_easy_init();
+       if (proxy != NULL) {
+               ret = curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
+       }
+
+       ret = curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
+       _DEBUG_INFO("[na_http_plugIn] set timeout : %d", timeout);
+
+       _DEBUG_INFO("[na_http_plugIn] session : %d\n", curl);
+
+       if (curl != NULL) {
+               _DEBUG_INFO("[na_http_plugIn] success !! \n");
+       } else {
+               _DEBUG_ERROR("[na_http_plugIn] fail !! \n");
+               res = 0;
+       }
+
+       curl_session->session = curl;
+
+       *session = curl_session;
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+#endif
+
+EXPORT_API int sync_agent_plugin_header_binding(GList * header_info, void **header_binding)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(header_info == NULL, 0, "header_info is NULL. FAIL !!!");
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+#ifdef USING_LIBSOUP
+       int res = 1;
+       GList *iter = NULL;
+       char *method = NULL;
+       char *uri = NULL;
+       common_header_info_s *iter_data = NULL;
+
+       if (header_info == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Error !! ( not exist header information )\n");
+               res = 0;
+               return res;
+       }
+
+       SoupMessage *msg = (SoupMessage *) (*header_binding);
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", msg);
+
+#else
+       char *method = NULL;
+       char *uri = NULL;
+#ifdef CBA
+       char *is_certificate = NULL;
+#endif
+       char *accept_encoding = "gzip,deflate";
+
+       int res = 1;
+       GList *iter = NULL;
+       http_message_s *msg = NULL;
+       libcurl_http_method_e libcurl_method = LIBCURL_HTTP_GET;
+
+       /*
+        *      add message body to message header
+        */
+       _DEBUG_INFO("[na_http_plugIn] create whole msg (header + body)\n");
+
+       common_header_info_s *iter_data = NULL;
+
+       if (header_info == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Error !! ( not exist header information )\n");
+               res = 0;
+               return res;
+       }
+#endif
+
+       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "method")) {
+                               method = ((common_header_info_s *) (iter->data))->value;
+                               break;
+                       }
+               }
+       }
+
+       if (iter == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Iteration is NULL\n");
+               res = 0;
+               return res;
+       }
+
+       iter_data = (common_header_info_s *) iter->data;
+       header_info = g_list_remove(header_info, iter_data);
+       free((common_header_info_s *) iter_data);
+       _DEBUG_INFO("[na_http_plugIn] method : %s\n", method);
+
+       iter = NULL;
+       iter_data = NULL;
+       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "uri")) {
+                               uri = ((common_header_info_s *) (iter->data))->value;
+                               break;
+                       }
+               }
+       }
+
+       if (iter == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Iteration is NULL\n");
+               res = 0;
+               return res;
+       }
+
+       iter_data = (common_header_info_s *) iter->data;
+       header_info = g_list_remove(header_info, iter_data);
+       free((common_header_info_s *) iter_data);
+       _DEBUG_INFO("[na_http_plugIn] uri : %s\n", uri);
+
+#ifdef CBA
+       iter = NULL;
+       iter_data = NULL;
+       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "certificate")) {
+                               is_certificate = ((common_header_info_s *) (iter->data))->value;
+                               break;
+                       }
+               }
+       }
+
+       if (iter == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] 'Certificate' is not existed !!");
+       } else {
+               iter_data = (common_header_info_s *) iter->data;
+               header_info = g_list_remove(header_info, iter_data);
+               free((common_header_info_s *) iter_data);
+               _DEBUG_INFO("[na_http_plugIn] certificate : %s\n", is_certificate);
+       }
+#endif
+
+#ifdef USING_LIBSOUP
+       if (!strcmp(method, "options")) {
+               msg = soup_message_new(SOUP_METHOD_OPTIONS, uri);
+       } else if (!strcmp(method, "get")) {
+               msg = soup_message_new(SOUP_METHOD_GET, uri);
+       } else if (!strcmp(method, "head")) {
+               msg = soup_message_new(SOUP_METHOD_HEAD, uri);
+       } else if (!strcmp(method, "post")) {
+               msg = soup_message_new(SOUP_METHOD_POST, uri);
+       } else if (!strcmp(method, "put")) {
+               msg = soup_message_new(SOUP_METHOD_PUT, uri);
+       } else if (!strcmp(method, "delete")) {
+               msg = soup_message_new(SOUP_METHOD_DELETE, uri);
+       } else if (!strcmp(method, "trace")) {
+               msg = soup_message_new(SOUP_METHOD_TRACE, uri);
+       } else if (!strcmp(method, "connect")) {
+               msg = soup_message_new(SOUP_METHOD_CONNECT, uri);
+       }
+
+       if (msg == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Error !! ( wrong uri : %s )\n", uri);
+               res = 0;
+               return res;
+       }
+#else
+       iter = NULL;
+       iter_data = NULL;
+       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "Accept-Encoding")) {
+                               accept_encoding = ((common_header_info_s *) (iter->data))->value;
+                               break;
+                       }
+               }
+       }
+
+       if (iter != NULL) {
+               iter_data = (common_header_info_s *) iter->data;
+               header_info = g_list_remove(header_info, iter_data);
+               free((common_header_info_s *) iter_data);
+               _DEBUG_INFO("[na_http_plugIn] accept_encoding : %s\n", accept_encoding);
+       }
+
+       if (method != NULL) {
+               if (!strcmp(method, "options")) {
+                       libcurl_method = LIBCURL_HTTP_OPTIONS;
+               } else if (!strcmp(method, "get")) {
+                       libcurl_method = LIBCURL_HTTP_GET;
+               } else if (!strcmp(method, "head")) {
+                       libcurl_method = LIBCURL_HTTP_HEAD;
+               } else if (!strcmp(method, "post")) {
+                       libcurl_method = LIBCURL_HTTP_POST;
+               } else if (!strcmp(method, "put")) {
+                       libcurl_method = LIBCURL_HTTP_PUT;
+               } else if (!strcmp(method, "delete")) {
+                       libcurl_method = LIBCURL_HTTP_DELETE;
+               } else if (!strcmp(method, "trace")) {
+                       libcurl_method = LIBCURL_HTTP_TRACE;
+               } else if (!strcmp(method, "connect")) {
+                       libcurl_method = LIBCURL_HTTP_CONNECT;
+               }
+               //free(method);
+       }
+       if (uri != NULL) {
+#ifdef CBA
+               if (is_certificate != NULL)
+                       msg = _create_http_message(libcurl_method, uri, accept_encoding, atoi(is_certificate));
+               else
+#else
+               msg = _create_http_message(libcurl_method, uri, accept_encoding);
+#endif
+               _DEBUG_INFO("[na_http_plugIn] create_http_message(%s)\n", uri);
+
+#ifdef CBA
+               if (msg->cert_info != NULL) {
+                       _DEBUG_INFO("[na_http_plugIn] certificate info is existed !!");
+
+                       iter = NULL;
+                       iter_data = NULL;
+                       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+                               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "accept_all_certs")) {
+                                               msg->cert_info->accept_all_certs = strdup(((common_header_info_s *) (iter->data))->value);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (iter != NULL) {
+                               iter_data = (common_header_info_s *) iter->data;
+                               header_info = g_list_remove(header_info, iter_data);
+                               free((common_header_info_s *) iter_data);
+                               _DEBUG_INFO("[na_http_plugIn] privatekey password : %s", msg->cert_info->accept_all_certs);
+                       }
+
+                       iter = NULL;
+                       iter_data = NULL;
+                       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+                               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "privatekey_password")) {
+                                               msg->cert_info->privatekey_password = strdup(((common_header_info_s *) (iter->data))->value);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (iter != NULL) {
+                               iter_data = (common_header_info_s *) iter->data;
+                               header_info = g_list_remove(header_info, iter_data);
+                               free((common_header_info_s *) iter_data);
+                               _DEBUG_INFO("[na_http_plugIn] privatekey password : %s", msg->cert_info->privatekey_password);
+                       }
+
+                       iter = NULL;
+                       iter_data = NULL;
+                       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+                               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "certificate_path")) {
+                                               msg->cert_info->certificate_path = strdup(((common_header_info_s *) (iter->data))->value);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (iter != NULL) {
+                               iter_data = (common_header_info_s *) iter->data;
+                               header_info = g_list_remove(header_info, iter_data);
+                               free((common_header_info_s *) iter_data);
+                               _DEBUG_INFO("[na_http_plugIn] certificate path : %s", msg->cert_info->certificate_path);
+                       }
+
+                       iter = NULL;
+                       iter_data = NULL;
+                       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+                               if (((common_header_info_s *) (iter->data))->key != NULL) {
+                                       if (!strcmp(((common_header_info_s *) (iter->data))->key, "privatekey")) {
+                                               msg->cert_info->privatekey = strdup(((common_header_info_s *) (iter->data))->value);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (iter != NULL) {
+                               iter_data = (common_header_info_s *) iter->data;
+                               header_info = g_list_remove(header_info, iter_data);
+                               free((common_header_info_s *) iter_data);
+                               _DEBUG_INFO("[na_http_plugIn] privatekey : %s", msg->cert_info->privatekey);
+                       }
+               }
+#endif
+               //free(uri);
+       }
+
+       if (msg == NULL) {
+               _DEBUG_INFO("[na_http_plugIn] create_http_message(%s) Failed\n", uri);
+               res = 0;
+               return res;
+       }
+#endif
+       /*
+        *      perform soup_message_headers_append() using key-value in header_info
+        */
+       iter = NULL;
+       iter_data = NULL;
+       for (iter = header_info; iter != NULL;) {
+               iter_data = ((common_header_info_s *) (iter->data));
+               if (iter_data->key != NULL) {
+#ifdef USING_LIBSOUP
+                       soup_message_headers_append(msg->request_headers, iter_data->key, iter_data->value);
+#else
+                       _add_http_header(msg, iter_data->key, iter_data->value);
+#endif
+                       _DEBUG_INFO("[na_http_plugIn] header append\n\t key : %s, value : %s\n", iter_data->key, iter_data->value);
+                       iter = g_list_next(iter);
+                       header_info = g_list_remove(header_info, iter_data);
+                       free((common_header_info_s *) (iter_data));
+               }
+       }
+
+       *header_binding = msg;
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", msg);
+
+       if (header_info != NULL)
+               g_list_free(header_info);
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_send_message(void *session, void **header_binding, char *send_msg, unsigned int send_msg_length, unsigned int *recv_msg_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(*header_binding == NULL, 0, "*header_binding is NULL. FAIL !!!");
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+
+#ifdef USING_LIBSOUP
+       SoupSession *ss = (SoupSession *) session;
+       _DEBUG_INFO("[na_http_plugIn] session : %d\n", ss);
+       SoupMessage *msg = (SoupMessage *) (*header_binding);
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", msg);
+
+/*     for test
+       SoupMessageHeadersIter iter;
+       const char *name, *value;
+
+       soup_message_headers_iter_init (&iter, msg->request_headers);
+       _DEBUG_INFO(stdout, "1\n");
+       while (soup_message_headers_iter_next (&iter, &name, &value)) {
+               _DEBUG_INFO(stdout, "header - name : %s   value : %s", name, value);
+               _DEBUG_INFO(stdout, "2\n");
+       }
+       */
+
+       /*
+        *      add message body to message header
+        */
+       _DEBUG_INFO("[na_http_plugIn] create whole msg (header + body)\n");
+       soup_message_body_append(msg->request_body, SOUP_MEMORY_TEMPORARY, send_msg, send_msg_length);
+
+       /*
+        *      send & receive message
+        */
+       _DEBUG_INFO("[na_http_plugIn] send message & receive message to server \n");
+       int http_status = soup_session_send_message(ss, msg);
+
+       switch (http_status) {  /* todo : Send Message return type must be defined */
+       case REQUEST_TIMEOUT:
+               res = -408;
+               break;
+       case OK:
+               res = 1;
+               break;
+       case SOUP_CANCELED:
+               res = -1;
+               break;
+       case SOUP_TRY_AGAIN:
+               res = -8;
+               break;
+       default:
+               res = 0;
+               break;
+       }
+
+       _DEBUG_INFO("[na_http_plugIn] http status : %d\n", http_status);
+#else
+       curl_session_s *curl_session = (curl_session_s *) session;
+       if (curl_session == NULL) {
+               _DEBUG_ERROR("curl_session is NULL");
+               res = 0;
+               return res;
+       }
+
+       CURL *curl = curl_session->session;
+       http_message_s *msg = (http_message_s *) * header_binding;
+
+       _DEBUG_INFO("[na_http_plugIn] session : %d\n", session);
+
+       if (curl_session->msg != NULL) {
+               _delete_http_message(curl_session->msg);
+               curl_session->msg = NULL;
+       }
+       msg->session = curl_session;
+       curl_session->msg = msg;
+
+       /*
+        *      add message body to message header
+        */
+       _DEBUG_INFO("[na_http_plugIn] create whole msg (header + body)\n");
+
+       curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
+       curl_easy_setopt(curl, CURLOPT_POST, 0L);
+       curl_easy_setopt(curl, CURLOPT_PUT, 0L);
+       curl_easy_setopt(curl, CURLOPT_HTTPGET, 0L);
+
+       curl_easy_setopt(curl, CURLOPT_ENCODING, msg->accept_encoding);
+
+       curl_easy_setopt(curl, CURLOPT_HTTPHEADER, msg->send_header);
+       switch (msg->method) {
+       case LIBCURL_HTTP_GET:
+               curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
+               break;
+       case LIBCURL_HTTP_HEAD:
+               curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD");
+               break;
+       case LIBCURL_HTTP_POST:
+               curl_easy_setopt(curl, CURLOPT_POST, 1L);
+               curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, send_msg_length);
+               curl_easy_setopt(curl, CURLOPT_POSTFIELDS, send_msg);
+               break;
+       case LIBCURL_HTTP_PUT:
+               curl_easy_setopt(curl, CURLOPT_PUT, 1L);
+               break;
+       case LIBCURL_HTTP_DELETE:
+               curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
+               break;
+       case LIBCURL_HTTP_TRACE:
+               curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "TRACE");
+               break;
+       case LIBCURL_HTTP_OPTIONS:
+               curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
+               break;
+       case LIBCURL_HTTP_CONNECT:
+               break;
+       }
+       curl_easy_setopt(curl, CURLOPT_URL, msg->uri);
+
+       curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
+       curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress_cb);
+       curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, msg->session);
+       curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_http_buffer_cb);
+       curl_easy_setopt(curl, CURLOPT_WRITEDATA, msg->response_body);
+       curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_http_buffer_cb);
+       curl_easy_setopt(curl, CURLOPT_WRITEHEADER, msg->response_header);
+
+#ifdef CBA
+       if (msg->cert_info == NULL) {
+               curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+               curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+       } else {
+               _add_certificate_option(curl, msg);
+       }
+#else
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+#endif
+
+       /*
+        *      send & receive message
+        */
+       _DEBUG_INFO("[na_http_plugIn] send message & receive message to server \n");
+       int http_status = 0;
+       long response_code;
+       http_status = curl_easy_perform(curl);
+
+       switch (http_status) {  /* todo : Send Message return type must be defined */
+       case CURLE_OPERATION_TIMEDOUT:
+               res = -408;
+               break;
+       case CURLE_OK:
+               curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
+               http_status = response_code;
+               _DEBUG_INFO("[na_http_plugIn] response_code : %d\n", response_code);
+               if (response_code >= 200 && response_code <= 299) {
+                       res = 1;
+               } else {
+                       res = 0;
+               }
+               break;
+       case CURLE_ABORTED_BY_CALLBACK:
+               res = -1;
+               break;
+       case CURLE_AGAIN:
+       case CURLE_GOT_NOTHING:
+               res = -8;
+               break;
+#ifdef CBA
+       case CURLE_SSL_CACERT:
+       case CURLE_PEER_FAILED_VERIFICATION:
+               if (msg->cert_info->accept_all_certs != 1) {
+                       res = -10;
+               } else {
+                       res = 1;
+               }
+               break;
+#endif
+       default:
+               res = 0;
+               break;
+       }
+       msg->http_status = http_status;
+       _DEBUG_INFO("[na_http_plugIn] http status : %d\n", http_status);
+#endif
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_header_unbinding(void *msg, unsigned int msg_size, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length)
+{
+       _EXTERN_FUNC_ENTER;
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+#ifdef USING_LIBSOUP
+       SoupMessage *whole_msg = (SoupMessage *) msg;
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", whole_msg);
+
+       SoupMessageHeadersIter iter;
+       const char *name, *value;
+
+       *recv_header = NULL;
+
+       /*
+        *      separate header
+        */
+       soup_message_headers_iter_init(&iter, whole_msg->response_headers);
+       common_header_info_s *header_info = NULL;
+       while (soup_message_headers_iter_next(&iter, &name, &value)) {
+               header_info = (common_header_info_s *) malloc(sizeof(common_header_info_s));
+               if (header_info == NULL) {
+                       _DEBUG_ERROR("[na_http_plugIn] header_info malloc fail !!");
+
+                       if (*recv_header != NULL)
+                               g_list_free(*recv_header);
+
+                       res = 0;
+                       return res;
+               }
+               memset(header_info, 0x00, sizeof(common_header_info_s));
+
+               header_info->key = strdup(name);
+               header_info->value = strdup(value);
+
+               *recv_header = g_list_append(*recv_header, header_info);
+       }
+#else
+       http_message_s *http_message = (http_message_s *) msg;
+       //char *http_status = g_strdup_printf("%d", http_message->http_status);
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", msg);
+       *recv_header = NULL;
+       if (_parse_http_header(http_message->response_header, recv_header) == 0) {
+               res = 0;
+               return res;
+       }
+
+       /*
+          if (http_status) {
+          *recv_header = g_list_append(*recv_header, create_header_info("Http-Status", http_status));
+          free(http_status);
+          } */
+#endif
+       /* for test */
+       GList *g_iter = NULL;
+       for (g_iter = *recv_header; g_iter != NULL; g_iter = g_list_next(g_iter)) {
+               _DEBUG_INFO("[na_http_plugIn] key : %s, value : %s", ((common_header_info_s *) (g_iter->data))->key, ((common_header_info_s *) (g_iter->data))->value);
+       }
+
+       /*
+        *      separate body
+        */
+#ifdef USING_LIBSOUP
+       if (whole_msg->response_body != NULL) {
+               if ((whole_msg->response_body->length > 0) && (whole_msg->response_body->data != NULL)) {
+                       _DEBUG_INFO("[na_http_plugIn] recv body length : %d\n", whole_msg->response_body->length);
+                       *recv_msg = (unsigned char *)malloc(whole_msg->response_body->length + 1);
+                       if (*recv_msg == NULL) {
+                               res = 0;
+                               return res;
+                       }
+                       memset(*recv_msg, 0x00, whole_msg->response_body->length + 1);
+                       memcpy(*recv_msg, whole_msg->response_body->data, whole_msg->response_body->length);
+
+                       *recv_msg_length = whole_msg->response_body->length;
+                       _DEBUG_INFO("[na_http_plugIn] recv_body : %s\n", *recv_msg);
+               }
+               /* else {
+                  _DEBUG_INFO("[na_http_plugIn] recv msg is not exist !!\n");
+
+                  if (*recv_header != NULL)
+                  g_list_free(recv_header);
+
+                  res = 0;
+                  return res;
+                  } */
+       }
+#else
+       if ((recv_msg_length != NULL) && (recv_msg != NULL)) {
+               if ((http_message->response_body->length > 0)) {
+                       if (http_message->response_body->buff != NULL) {
+                               *recv_msg = malloc(http_message->response_body->length + 1);
+                               if (*recv_msg == NULL) {
+                                       _DEBUG_ERROR("MALLOC failed !!!");
+                                       res = 0;
+                                       return res;
+                               }
+                               memcpy(*recv_msg, http_message->response_body->buff, http_message->response_body->length);
+                               (*recv_msg)[http_message->response_body->length] = 0;
+                               *recv_msg_length = http_message->response_body->length;
+                       }
+               } else {
+                       *recv_msg_length = 0;
+                       *recv_msg = NULL;
+               }
+       }
+#endif
+
+       _DEBUG_INFO("[na_http_plugIn] msg : %d\n", msg);
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+#ifdef USING_LIBSOUP
+       g_object_unref(G_OBJECT(msg));
+#else
+       curl_session_s *session;
+       session = (curl_session_s *) http_message->session;
+       _delete_http_message(http_message);
+       if (session->msg != NULL)
+               session->msg = NULL;
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_close_connection(void *session)
+{
+       _EXTERN_FUNC_ENTER;
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+
+#ifdef USING_LIBSOUP
+       SoupSession *ss = (SoupSession *) session;
+
+       _DEBUG_INFO("[na_http_plugIn] session : %d", session);
+
+       auth_info_s *auth_info = NULL;
+       res = _find_auth_info(ss, &auth_info);
+       if (res == 0) {
+               _DEBUG_INFO("[na_http_plugIn] auth_info is NULL !!");
+
+               /* soup_session_cleanup_connections(ss, TRUE); */
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session cleanup connections !!");
+
+               res = 1;
+       } else if (res == 1) {
+               _DEBUG_INFO("[na_http_plugIn] fine_auth_info() is success !!");
+
+               /* soup_session_cleanup_connections(ss, TRUE); */
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session cleanup connections !!");
+
+               if (auth_info != NULL) {
+                       auth_info_list = g_list_remove(auth_info_list, auth_info);
+
+                       if (auth_info->id != NULL)
+                               free(auth_info->id);
+                       if (auth_info->password != NULL)
+                               free(auth_info->password);
+                       free(auth_info);
+
+                       _DEBUG_INFO("[na_http_plugIn] remove auth_info success !!");
+               }
+       } else {                /* res  == -1 */
+               _DEBUG_INFO("[na_http_plugIn] auth_info_list is NULL !!");
+
+               /* soup_session_cleanup_connections(ss, TRUE); */
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session cleanup connections !!");
+
+               res = 1;
+       }
+#else
+       curl_session_s *curl_session = (curl_session_s *) session;
+       CURL *curl = curl_session->session;
+       curl_easy_cleanup(curl);
+
+       if (curl_session->msg != NULL) {
+               _delete_http_message(curl_session->msg);
+               curl_session->msg = NULL;
+       }
+       free(curl_session);
+
+#endif
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_cancel_message(void *session)
+{
+       _EXTERN_FUNC_ENTER;
+
+#ifdef time_check
+       /* function Start Time */
+       clock_t start_t, end_t;
+       double proc_t = 0.0;
+       start_t = clock();
+#endif
+
+       int res = 1;
+
+#ifdef USING_LIBSOUP
+       SoupSession *ss = (SoupSession *) session;
+       _DEBUG_INFO("[na_http_plugIn] session : %d", session);
+
+       auth_info_s *auth_info = NULL;
+       /* SoupMessage *cancel_msg = (SoupMessage*)msg; */
+
+       /* if ((ss != NULL) && (cancel_msg != NULL) && (cancel_msg->status_code != SOUP_STATUS_OK && cancel_msg->status_code != SOUP_STATUS_CANCELLED)) {
+          soup_session_cancel_message(ss, cancel_msg, SOUP_STATUS_CANCELLED);
+          _DEBUG_INFO("[na_http_plugIn] cancel message !!\n");
+          } */
+
+       res = _find_auth_info(ss, &auth_info);
+       if (res == 0) {
+               _DEBUG_INFO("[na_http_plugIn] auth_info is NULL !!");
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session abort !! \n");
+
+               res = 1;
+       } else if (res == 1) {
+               _DEBUG_INFO("[na_http_plugIn] fine_auth_info() is success !!");
+
+               /* cancel all pending requests & disconnect connection */
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session abort !! \n");
+
+               if (auth_info != NULL) {
+                       auth_info_list = g_list_remove(auth_info_list, auth_info);
+
+                       if (auth_info->id != NULL)
+                               free(auth_info->id);
+                       if (auth_info->password != NULL)
+                               free(auth_info->password);
+                       free(auth_info);
+
+                       _DEBUG_INFO("[na_http_plugIn] remove auth_info success !!");
+               }
+       } else {                /* res  == -1 */
+               _DEBUG_INFO("[na_http_plugIn] auth_info_list is NULL !!");
+
+               /* cancel all pending requests & disconnect connection */
+               soup_session_abort(ss);
+               _DEBUG_INFO("[na_http_plugIn] session abort !! \n");
+
+               res = 1;
+       }
+#else
+       curl_session_s *curl_session = (curl_session_s *) session;
+       _curl_session_abort(curl_session);
+#endif
+
+#ifdef time_check
+       /* function End Time */
+       end_t = clock();
+       proc_t = ((double)(end_t - start_t)) / CLOCKS_PER_SEC;
+       _DEBUG_INFO("[na_http_plugIn] execute time : %0.2f\n", proc_t);
+#endif
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_get_header_info(GList * header_info, char *key, char **value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(header_info == NULL, 0, "header_info is NULL. FAIL !!!");
+       retvm_if(key == NULL, 0, "key is NULL. FAIL !!!");
+
+       int res = 1;
+
+       GList *iter = NULL;
+       common_header_info_s *iter_data;
+       *value = NULL;
+       int value_len = 0;
+
+       if (header_info == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] Error !! ( not exist header information )\n");
+               res = 0;
+               return res;
+       }
+
+       for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               iter_data = (common_header_info_s *) (iter->data);
+               if (iter_data->key != NULL) {
+                       if (!strcmp(iter_data->key, key)) {
+                               if (iter_data->value != NULL) {
+                                       /* if (*value == NULL) { *//* first 'key - value' pair */
+                                       if (value_len == 0) {   /* first 'key - value' pair */
+                                               *value = (char *)malloc(strlen(iter_data->value) + NULL_LEN + SEMI_COLON_LEN);
+                                               if (*value == NULL) {
+                                                       _DEBUG_ERROR("[na_http_plugIn] malloc error !!");
+                                                       res = 0;
+                                                       return res;
+                                               }
+
+                                               memset(*value, 0x00, strlen(iter_data->value) + NULL_LEN + SEMI_COLON_LEN);
+                                               memcpy(*value, iter_data->value, strlen(iter_data->value));
+                                               _DEBUG_INFO("[na_http_plugIn] key : %s, value : %s ( %d )", iter_data->key, *value, strlen(*value));
+
+                                               value_len += strlen(*value);
+                                       } else {        /* after first 'key - value' pair */
+                                               int len = strlen(iter_data->value);
+                                               _DEBUG_INFO("value = %s, len = %d", iter_data->value, len);
+                                               if (len != 0) {
+                                                       value_len += (len + NULL_LEN + SEMI_COLON_LEN);
+                                                       *value = (char *)realloc(*value, value_len);
+                                                       if (*value == NULL) {
+                                                               _DEBUG_ERROR("[na_http_plugIn] realloc error !!");
+                                                               res = 0;
+                                                               return res;
+                                                       }
+                                                       int strcat_check_len = 0;
+
+                                                       strcat_check_len = g_strlcat(*value, ";", value_len);
+                                                       strcat_check_len = g_strlcat(*value, iter_data->value, value_len);
+
+                                                       if (strcat_check_len >= value_len) {
+                                                               _DEBUG_ERROR("[na_http_plugIn] *value buffer overflow !!");
+                                                               res = 0;
+                                                               return res;
+                                                       }
+                                                       _DEBUG_INFO("[na_http_plugIn] key : %s, value : %s ( %d )", iter_data->key, *value, strlen(*value));
+                                               } else {
+                                                       /*do nothing */
+                                               }
+                                       }
+                               } else {
+                                       _DEBUG_ERROR("[na_http_plugIn] value is NULL !! \n");
+                                       res = 0;
+                                       return res;
+                               }
+                       }
+               } else {
+                       _DEBUG_ERROR("[na_http_plugIn] key is NULL !! \n");
+                       res = 0;
+                       return res;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_set_data_download_info(void *http_info, char *current_download_range)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(http_info == NULL, 0, "http_info is NULL. FAIL !!!");
+       retvm_if(current_download_range == NULL, 0, "current_download_range is NULL. FAIL !!!");
+
+       int ret = 1;
+
+       GList *iter = 0;
+       for (iter = (GList *) http_info; iter != NULL; iter = g_list_next(iter)) {
+
+               if (((common_header_info_s *) (iter->data))->key != NULL && !strcmp(((common_header_info_s *) (iter->data))->key, "Range")) {
+
+                       char *value = ((common_header_info_s *) (iter->data))->value;
+                       if (value != NULL) {
+                               free(value);
+
+                               ((common_header_info_s *) (iter->data))->value = g_strdup_printf("bytes=%s", current_download_range);
+                               _DEBUG_INFO("[After] key : %s, value : %s\n", ((common_header_info_s *) (iter->data))->key, ((common_header_info_s *) (iter->data))->value);
+                               break;
+                       } else {
+                               _DEBUG_ERROR("[na_http_plugIn] value is NULL !! \n");
+                               ret = 0;
+                               return ret;
+                       }
+               }
+       }
+
+       _DEBUG_INFO("[na_http_plugIn] end");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_data_download_info(void *http_req_info, void *http_info, int *total_doanload_size, char **current_download_range, char **download_file_name)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(http_req_info == NULL, 0, "http_req_info is NULL. FAIL !!!");
+       retvm_if(http_info == NULL, 0, "http_info is NULL. FAIL !!!");
+
+       int ret = 1;
+
+       /* Get_Header_Info(http_info, "Content-Disposition", download_file_name);
+          if (*download_file_name == NULL) {
+          _DEBUG_INFO("[na_http_plugIn] download_file_name == 0");
+          return 0;
+          } else {
+          _DEBUG_INFO("[na_http_plugIn]  download_file_name = %s\n", *download_file_name);
+          }
+
+          char *content_range_value = 0;
+          Get_Header_Info(http_info, "Content-Range", &content_range_value);
+          if (content_range_value == NULL) {
+          _DEBUG_INFO("[na_http_plugIn] content_range_value == 0");
+          return 0;
+          } else {
+          _DEBUG_INFO("[na_http_plugIn] content range value = %s\n", content_range_value);
+          } */
+
+       /* pasing file name */
+       char *temp_file_name = 0;       /* strdup("attachment; fileName=\"FW-20110901-13121.bin\""); */
+       sync_agent_plugin_get_header_info((GList *) http_info, "Content-Disposition", &temp_file_name);
+       _DEBUG_INFO("temp_file_name = %s\n", temp_file_name);
+       if (temp_file_name != NULL) {
+               char *ptr1 = strstr(temp_file_name, "attachment;");
+               if (ptr1 != NULL) {
+                       ptr1 = strstr(ptr1, "fileName=");
+                       if (ptr1 != NULL) {
+
+                               char *temp = strdup(ptr1);
+
+                               char *del = "\"";
+                               char *temp_ptr = strtok(temp, del);
+                               _DEBUG_INFO("1st token = %s\n", temp_ptr);
+
+                               temp_ptr = strtok(NULL, del);
+                               _DEBUG_INFO("2nd token = %s\n", temp_ptr);
+
+                               *download_file_name = strdup(temp_ptr);
+                               _DEBUG_INFO("*download_file_name = %s\n", *download_file_name);
+
+                               if (temp != NULL)
+                                       free(temp);
+                       }
+               }
+       } else {
+               char *result_name = NULL;
+
+               sync_agent_plugin_get_header_info((GList *) http_req_info, "uri", &temp_file_name);
+               _DEBUG_INFO("temp_file_name = %s\n", temp_file_name);
+
+               result_name = strrchr(temp_file_name, '/');
+               _DEBUG_INFO("result_file name : %s", result_name);
+
+               if (result_name != NULL) {
+                       ++result_name;
+                       _DEBUG_INFO("remove '/' result_file name : %s", result_name);
+               }
+
+               *download_file_name = strdup(result_name);
+               _DEBUG_INFO("*download_file_name = %s\n", *download_file_name);
+
+       }
+       /* parsing data range info */
+       char *temp_range_value = 0;     /* strdup("bytes 0-66303/3192624"); */
+       sync_agent_plugin_get_header_info((GList *) http_info, "Content-Range", &temp_range_value);
+       char *temp = strdup(temp_range_value + strlen("bytes "));
+       _DEBUG_INFO("temp_range = %s\n", temp);
+
+       char *del2 = "/";
+       char *ptr2 = strtok(temp, del2);
+       if (ptr2 != NULL) {
+               _DEBUG_INFO("[na_http_plugIn] range = %s\n", ptr2);
+               *current_download_range = strdup(ptr2);
+
+               ptr2 = strtok(NULL, del2);
+               _DEBUG_INFO("[na_http_plugIn] total = %s\n", ptr2);
+               *total_doanload_size = atoi(ptr2);
+       }
+//      if (temp_file_name != NULL)
+       free(temp_file_name);
+       if (temp_range_value != NULL)
+               free(temp_range_value);
+       if (temp != NULL)
+               free(temp);
+
+       _DEBUG_INFO("[na_http_plugIn] end");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_add_authentication_info(void *session, char *id, char *password)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(id == NULL, 0, "id is NULL. FAIL !!!");
+       retvm_if(password == NULL, 0, "password is NULL. FAIL !!!");
+
+       int res = 1;
+
+#ifdef USING_LIBSOUP
+       SoupSession *ss = (SoupSession *) session;
+
+       res = _add_auth_info(ss, id, password);
+#else
+       CURL *curl = ((curl_session_s *) session)->session;
+
+       char *userpwd;
+       int id_len, pw_len, userpwd_len;
+
+       id_len = strlen(id);
+       pw_len = strlen(password);
+
+       userpwd_len = id_len + pw_len + 2;
+       userpwd = (char *)malloc(userpwd_len);
+       if (userpwd != NULL) {
+               snprintf(userpwd, userpwd_len, "%s:%s", id, password);
+       } else {
+               _DEBUG_ERROR("[na_http_plugIn] userpwd malloc failed !!");
+               res = 0;
+               return res;
+       }
+
+       curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd);
+
+       if (userpwd != NULL)
+               free(userpwd);
+#endif
+       if (res != 1) {
+               _DEBUG_ERROR("[na_http_plugIn] _add_auth_info() is fail !!");
+               return res;
+       } else {
+               _DEBUG_INFO("[na_http_plugIn] _add_auth_info() is success !!");
+               /* register user authentication callback (for EAS) */
+#ifdef USING_LIBSOUP
+               g_signal_connect(ss, "authenticate", G_CALLBACK(authenticate_cb), NULL);
+#endif
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_set_property(void *session, sync_agent_na_property_e property, va_list va)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 1;
+       CURL *curl = ((curl_session_s *) session)->session;
+       if (curl == NULL)
+               return 0;
+
+       switch (property) {
+       case SYNC_AGENT_NA_PROP_TIMEOUT:{
+                       int timeout = va_arg(va, long);
+                       curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
+               }
+               break;
+       default:
+               ret = 0;
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_status(void *session, sync_agent_na_status_e status, va_list va)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = 1;
+       CURL *curl = ((curl_session_s *) session)->session;
+       if (curl == NULL)
+               return 0;
+
+       switch (status) {
+       case SYNC_AGENT_NA_STATUS_ELAPSED_TIME:{
+                       double *arg = va_arg(va, double *);
+                       curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, arg);
+               }
+               break;
+       case SYNC_AGENT_NA_STATUS_RESPONSE_CODE:{
+                       long *arg = va_arg(va, long *);
+                       curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, arg);
+               }
+               break;
+       default:
+               ret = 0;
+               break;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+#ifdef USING_LIBSOUP
+static int _add_auth_info(SoupSession * session, char *user_id, char *user_pw)
+{
+       int res = 1;
+
+       auth_info_s *auth_info;
+
+       /* memory alloc - auth_info  */
+       auth_info = (auth_info_s *) calloc(1, sizeof(auth_info_s));
+       if (auth_info == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] auth_info calloc fail !!");
+               return 0;
+       }
+       _DEBUG_TRACE("[na_http_plugIn] auth_info calloc success !!");
+
+       auth_info->session = (void *)calloc(1, sizeof(auth_info->session));
+       if (auth_info->session == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       auth_info->session = session;
+       _DEBUG_TRACE("[na_http_plugIn] auth_info : sessoin ( %d )", auth_info->session);
+       auth_info->id = strdup(user_id);
+       _DEBUG_TRACE("[na_http_plugIn] auth_info : id ( %s )", auth_info->id);
+       auth_info->password = strdup(user_pw);
+       _DEBUG_TRACE("[na_http_plugIn] auth_info : password ( %s )", auth_info->password);
+
+       /* append auth_info to auth_info_list */
+       auth_info_list = g_list_append(auth_info_list, auth_info);
+       _DEBUG_TRACE("[na_http_plugIn] append auth_info");
+
+       return res;
+}
+
+/*static int remove_auth_info(SoupSession *session)
+{
+       int res = 1;
+       auth_info_s *auth_info = NULL;
+
+       res = _find_auth_info(session, &auth_info);
+       if (res == 0) {
+               _DEBUG_ERROR("[na_http_plugIn] _find_auth_info() is fail !!");
+               res = 0;
+               return res;
+       } else if (res == 1) {
+               _DEBUG_INFO("[na_http_plugIn] fine_auth_info() is success !!");
+
+               if (auth_info->id != NULL)
+                       free(auth_info->id);
+
+               if (auth_info->password != NULL)
+                       free(auth_info->password);
+
+               if (auth_info != NULL)
+                       free(auth_info);
+       }
+
+       return res;
+}*/
+
+static int _find_auth_info(SoupSession * session, auth_info_s ** auth_info)
+{
+       GList *iter = NULL;
+       auth_info_s *iter_data;
+
+       int res = 1;
+
+       if (auth_info_list != NULL) {
+               /* find auth_info for session */
+               for (iter = auth_info_list; iter != NULL; iter = g_list_next(iter)) {
+                       iter_data = NULL;
+                       if (((auth_info_s *) (iter->data))->session != NULL) {
+                               if (((auth_info_s *) (iter->data))->session == session) {
+                                       iter_data = (auth_info_s *) (iter->data);
+                                       _DEBUG_TRACE("[na_http_plugIn] find session : %d", session);
+                                       break;
+                               }
+                       }
+               }
+       } else {
+               _DEBUG_ERROR("[na_http_plugIn] auth_info_list is NULL !!");
+               res = -1;
+               return res;
+       }
+
+       if (iter_data != NULL) {
+               *auth_info = (auth_info_s *) iter_data;
+       } else {
+               _DEBUG_ERROR("[na_http_plugIn] iter_data is NULL !!");
+               res = 0;
+               return res;
+       }
+
+       return res;
+}
+
+static void authenticate_cb(SoupSession * session, SoupMessage * msg, SoupAuth * auth, gboolean retrying, gpointer user_data)
+{
+       int err = 1;
+       auth_info_s *auth_info = NULL;
+
+       if (!retrying) {
+               err = _find_auth_info(session, &auth_info);
+               if (err == 0) {
+                       _DEBUG_ERROR("[na_http_plugIn] _find_auth_info() is fail !!");
+                       /* todo : error handling */
+               } else if (err == 1) {
+                       _DEBUG_INFO("[na_http_plugIn] _find_auth_info() is success !!");
+                       /* first authentication */
+                       if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) {
+                               if ((auth_info->id != NULL) && (auth_info->password != NULL))
+                                       soup_auth_authenticate(auth, auth_info->id, auth_info->password);
+                       }
+                       /* not implement - proxy authentication */
+                       /* else if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
+                          if (((auth_info_s*)(iter->data))->proxy_id && ((auth_info_s*)(iter->data))->proxy_password)
+                          soup_auth_authenticate(auth, ((auth_info_s*)(iter->data))->proxy_id, ((auth_info_s*)(iter->data))->proxy_password);
+                          } */
+               } else {        /* err == -1 */
+                       _DEBUG_INFO("[na_http_plugIn] auth_info_list is NULL !!");
+               }
+       } else {
+               /* retry */
+               _DEBUG_INFO("[na_http_plugIn] authentication Retry !!");
+       }
+
+}
+#else
+
+static http_buffer_s *__create_http_buffer(int block_size)
+{
+       _INNER_FUNC_ENTER;
+
+       http_buffer_s *buff = (http_buffer_s *) calloc(1, sizeof(http_buffer_s));
+       if (buff == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+       buff->block_size = block_size;
+
+       _INNER_FUNC_EXIT;
+
+       return buff;
+}
+
+static int __delete_http_buffer(http_buffer_s * buff)
+{
+       _INNER_FUNC_ENTER;
+
+       if (buff->buff != NULL) {
+               free(buff->buff);
+       }
+       free(buff);
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static size_t write_http_buffer_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+       _EXTERN_FUNC_ENTER;
+
+       http_buffer_s *buff = (http_buffer_s *) userdata;
+       int len = size * nmemb;
+       int written_len = buff->length;
+       int block_size = buff->block_size;
+       int allocated_block = (written_len + (block_size - 1)) / block_size;
+
+       if (written_len + len > allocated_block * block_size) {
+               allocated_block = (written_len + len + (block_size - 1)) / block_size;
+               buff->buff = realloc(buff->buff, allocated_block * block_size);
+               if (buff->buff == NULL) {
+                       return 0;
+               }
+       }
+       memcpy(&buff->buff[written_len], ptr, len);
+       buff->length += len;
+
+       _EXTERN_FUNC_EXIT;
+
+       return len;
+}
+
+#ifdef CBA
+static http_message_s *_create_http_message(libcurl_http_method_e method, char *uri, char *accept_encoding, int is_cert)
+#else
+static http_message_s *_create_http_message(libcurl_http_method_e method, char *uri, char *accept_encoding)
+#endif
+{
+       _INNER_FUNC_ENTER;
+
+       http_message_s *msg = (http_message_s *) calloc(1, sizeof(http_message_s));
+       if (msg == NULL)
+               return NULL;
+
+       msg->method = method;
+       msg->uri = uri ? strdup(uri) : NULL;
+       msg->accept_encoding = accept_encoding ? strdup(accept_encoding) : NULL;
+       msg->response_header = __create_http_buffer(HEADER_BLOCK_SIZE);
+       msg->response_body = __create_http_buffer(CONTENT_BLOCK_SIZE);
+#ifdef CBA
+       if (is_cert != 0)
+               msg->cert_info = (certificate_info_s *) calloc(1, sizeof(certificate_info_s));
+       if (msg->cert_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+#endif
+
+       _INNER_FUNC_EXIT;
+
+       return msg;
+}
+
+static int _add_http_header(http_message_s * msg, char *key, char *value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(key == NULL, 0, "key is NULL. FAIL !!!");
+       retvm_if(value == NULL, 0, "value is NULL. FAIL !!!");
+
+       char *key_pair;
+       int key_len, val_len, key_pair_len;
+
+       key_len = strlen(key);
+       val_len = strlen(value);
+
+       key_pair_len = key_len + val_len + 2;
+       key_pair = (char *)malloc(key_pair_len);
+       if (key_pair == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] authentication Retry !!");
+               return 0;
+       }
+
+       snprintf(key_pair, key_pair_len, "%s:%s", key, value);
+
+       msg->send_header = curl_slist_append(msg->send_header, key_pair);
+       free(key_pair);
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+static int _delete_http_message(http_message_s * msg)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(msg == NULL, 0, "msg is NULL. FAIL !!!");
+
+       if (msg->uri != NULL) {
+               free(msg->uri);
+       }
+       if (msg->accept_encoding != NULL) {
+               free(msg->accept_encoding);
+       }
+       if (msg->send_header != NULL) {
+               curl_slist_free_all(msg->send_header);
+       }
+       if (msg->response_header != NULL) {
+               __delete_http_buffer(msg->response_header);
+               msg->response_header = 0;
+       }
+       if (msg->response_body != NULL) {
+               __delete_http_buffer(msg->response_body);
+               msg->response_body = 0;
+       }
+       free(msg);
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+static int curl_progress_cb(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(clientp == NULL, 0, "clientp is NULL. FAIL !!!");
+
+       curl_session_s *session = (curl_session_s *) clientp;
+       if (session->msg != NULL) {
+               if (session->msg->abort != 0) {
+                       _EXTERN_FUNC_EXIT;
+                       return 1;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int _curl_session_abort(curl_session_s * session)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(session == NULL, 0, "session is NULL. FAIL !!!");
+
+       if (session->msg != NULL) {
+               session->msg->abort = 1;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+static common_header_info_s *__create_header_info(char *key, char *value)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(key == NULL, NULL, "key is NULL. FAIL !!!");
+       retvm_if(value == NULL, NULL, "value is NULL. FAIL !!!");
+
+       common_header_info_s *header_info = NULL;
+       header_info = (common_header_info_s *) calloc(1, sizeof(common_header_info_s));
+       if (header_info == NULL) {
+               return NULL;
+       }
+       header_info->key = strdup(key);
+       header_info->value = strdup(value);
+
+       _INNER_FUNC_EXIT;
+
+       return header_info;
+}
+
+static int _parse_http_header(http_buffer_s * header, GList ** header_list)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(header == NULL, 0, "header is NULL. FAIL !!!");
+
+       common_header_info_s *header_info = NULL;
+
+       int state = 0;
+       int ret = 1;
+       char *value = NULL;
+       char *buff = malloc(header->length + 1);
+       if (buff == NULL) {
+               _DEBUG_ERROR("MALLOC failed !!!");
+               return 0;
+       }
+       char *tmp = buff;
+       char ch;
+
+       char *key = NULL;
+       *header_list = NULL;
+
+       memcpy(buff, header->buff, header->length);
+       buff[header->length] = 0;
+
+       while (*tmp) {
+               ch = *tmp;
+               if (ch == '\r' || ch == '\n') {
+                       *tmp = 0;
+                       if ((key != NULL) && (state == 100)) {
+                               header_info = __create_header_info(key, value ? value : "");
+                               *header_list = g_list_append(*header_list, header_info);
+                       }
+                       state = 0;
+                       key = NULL;
+                       value = NULL;
+                       tmp++;
+                       continue;
+               }
+               switch (state) {
+               case 0:
+                       if (isspace(ch) && (key == NULL)) {
+                               *tmp = 0;
+                       } else {
+                               if (key == NULL) {
+                                       key = tmp;
+                               }
+                               if (ch == ':') {
+                                       *tmp = 0;
+                                       state = 100;
+                               }
+                       }
+
+                       break;
+               case 100:
+                       if (isspace(ch) && (value == NULL)) {
+                               *tmp = 0;
+                       } else {
+                               if (value == NULL) {
+                                       value = tmp;
+                               }
+                               if (ch == ';') {
+                                       *tmp = 0;
+                                       if (key != NULL) {
+                                               header_info = __create_header_info(key, value);
+                                               *header_list = g_list_append(*header_list, header_info);
+                                               value = NULL;
+                                       }
+                               }
+                       }
+                       break;
+               }
+               tmp++;
+       }
+
+       free(buff);
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+#ifdef CBA
+static void _add_certificate_option(CURL * curl, http_message_s * msg)
+{
+       _INNER_FUNC_ENTER;
+
+       retm_if(msg == NULL, "msg is NULL. FAIL !!!");
+
+       if (msg->cert_info->accept_all_certs != 1)
+               curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, ssl_context_cb);
+
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
+       curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
+
+       curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
+       curl_easy_setopt(curl, CURLOPT_SSLCERT, msg->cert_info->certificate_path);
+       curl_easy_setopt(curl, CURLOPT_KEYPASSWD, msg->cert_info->privatekey_password);
+
+       curl_easy_setopt(curl, CURLOPT_SSLKEYTYPE, "PEM");
+       curl_easy_setopt(curl, CURLOPT_SSLKEY, msg->cert_info->privatekey);
+
+       /* set the file with the certs vaildating the server */
+       //curl_easy_setopt(session->curl,CURLOPT_CAINFO,pServerCert);
+       curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);
+
+       _INNER_FUNC_EXIT;
+}
+
+static CURLcode ssl_context_cb(CURL * curl, SSL_CTX * sslctx, void *param)
+{
+       _EXTERN_FUNC_ENTER;
+
+       SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_peer_cb);
+
+       _EXTERN_FUNC_EXIT;
+       return CURLE_OK;
+}
+
+static int verify_peer_cb(int preverify_ok, X509_STORE_CTX * x509_ctx)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int retVal = 1;
+
+       _DEBUG_INFO("[na_http_plugIn] Read Peer certificates from SSL context !!");
+       X509 *cert = X509_STORE_CTX_get_current_cert(x509_ctx);
+       if (cert == NULL) {
+               _DEBUG_ERROR("[na_http_plugIn] No cert info available in the Context !!");
+               retVal = 0;
+               goto return_part;
+       }
+
+       int err = X509_STORE_CTX_get_error(x509_ctx);
+//    char cert_file_path[1024] = {0, };
+//    snprintf(cert_file_path, sizeof(cert_file_path), "%s/PeerCertificate_%u", "aaa",(int)g_thread_self());
+//    _DEBUG_INFO("[na_http_plugIn] Certificate Path : %s",cert_file_path);
+//
+//    FILE *fp = fopen(cert_file_path, "a");
+//    errno = 0;
+//    if (!fp) {
+//        _DEBUG_ERROR("[na_http_plugIn] Failed to open file : %s", strerror(errno));
+//        retVal = 0;
+//        goto return_part;
+//    }
+
+       if (preverify_ok) {
+//        fprintf(fp,"Certificate is OK\n");
+               _DEBUG_INFO("[na_http_plugIn] Certificate is OK !!");
+       } else {
+//        fprintf(fp,"Certificate verification failed.Reason::%d\n",err);
+               _DEBUG_ERROR("[na_http_plugIn] Certificate verification failed ( err : %d ) !!", err);
+               retVal = 0;
+       }
+//    X509_print_fp(fp,cert);
+//    fprintf(fp,"===========================================\n");
+//    if (fp != NULL) {
+//        fclose(fp);
+//        fp = NULL;
+//    }
+
+ return_part:
+
+       _EXTERN_FUNC_EXIT;
+
+       return retVal;
+}
+#endif
+
+#endif
+
+EXPORT_API void sync_agent_plugin_register_fw_main_loop_network_access(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return;
+}
diff --git a/src/fw-plugins/common-public/memo/CMakeLists.txt b/src/fw-plugins/common-public/memo/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..da8a8a5
--- /dev/null
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-memo")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       memo
+                                       glib-2.0
+                                       accounts-svc
+                                       dlog)
+
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-memo_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-memo_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/memo/include/extern_info.h b/src/fw-plugins/common-public/memo/include/extern_info.h
new file mode 100755 (executable)
index 0000000..ccf3ec3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXTERN_INFO_H_
+#define EXTERN_INFO_H_
+
+typedef enum {
+       DEFAULT_MEMO_FOLDER = 0,
+       USER_DEFINED_FOLDER
+} memo_folder_type_e;
+
+#endif                         /* EXTERN_INFO_H_ */
diff --git a/src/fw-plugins/common-public/memo/include/item_change_info.h b/src/fw-plugins/common-public/memo/include/item_change_info.h
new file mode 100755 (executable)
index 0000000..24f594c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ITEM_CHANGE_INFO_H_
+#define ITEM_CHANGE_INFO_H_
+
+int get_memo_time_stamp();
+
+int set_memo_time_stamp(int setting_time);
+
+#endif                         /* ITEM_CHANGE_INFO_H_ */
diff --git a/src/fw-plugins/common-public/memo/src/item_change_info.c b/src/fw-plugins/common-public/memo/src/item_change_info.c
new file mode 100755 (executable)
index 0000000..32ceb27
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <time.h>
+
+#include "utility/sync_util.h"
+#include "item_change_info.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DA_MEMO"
+#endif
+
+static int memo_time_stamp = 0;
+
+int get_memo_time_stamp()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ((int)time(0) - 3);
+}
+
+int set_memo_time_stamp(int setting_time)
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* Critical Sectioin Start */
+       memo_time_stamp = setting_time;
+       /* Critical Section End */
+
+       _EXTERN_FUNC_EXIT;
+
+       return setting_time;
+}
diff --git a/src/fw-plugins/common-public/memo/src/plugin_interface.c b/src/fw-plugins/common-public/memo/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..13643b4
--- /dev/null
@@ -0,0 +1,943 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+#include <pthread.h>
+#include <string.h>
+#include <malloc.h>
+
+#include <memo-db.h>
+
+#include "extern_info.h"
+#include "item_change_info.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#include "plugin/data_connector_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DA_MEMO"
+#endif
+
+#define FW_MEMO                2       /* plugIn-Id */
+
+static pthread_mutex_t lockx;
+
+static int is_noti_from_me = 0;
+
+static int is_storage_changed = 0;
+
+static sync_agent_add_item_cb_plugin callback_add_item;
+
+static sync_agent_del_item_cb_plugin callback_del_item;
+
+static sync_agent_update_item_cb_plugin callback_update_item;
+
+static sync_agent_get_account_id_list_cb_plugin callback_get_accountidlist;
+
+static void _free_item_node(sync_agent_plugin_item_node_s * node);
+
+static void _set_is_noti_from_me(int set_flag);
+
+static int __get_is_noti_from_me();
+
+static void _process_memo_change(void *);
+
+static void *__rutine_memo_change(void *);
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err);
+
+static int _get_digit(int new_id);
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_open_service()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = memo_init(0);
+       if (err < 0) {
+               _DEBUG_INFO("[da_memo_plugIn] in memo Fail!\n");
+               ret = SYNC_AGENT_DA_ERR_OPEN_FAILED;
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] in memo Success!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_close_service()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /* memo service api does not return value */
+       memo_fini();
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_begin_transaction()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /* memo service api does not return value */
+       /* real transaction is not for event notification */
+       memo_begin_trans();
+       _set_is_noti_from_me(1);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_end_transaction(int is_success)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /* memo service api does not return value */
+       /* real transaction is not for event notification */
+       /* memo service is not supported rollback operation */
+       memo_end_trans();
+/*     _set_is_noti_from_me(1);*/
+
+       if (is_storage_changed == 0) {
+               _DEBUG_INFO("memo storaged was not Changed!!");
+               _set_is_noti_from_me(0);
+       }
+       is_storage_changed = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_item(int account_id, char *folder_id, void *data, char **item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "data is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       struct memo_data *item = (struct memo_data *)data;
+
+       /* configuration item */
+       item->id = -1;
+       item->modi_time = time((time_t *) 0);
+       item->font_size = 32;
+       item->font_color = 0xff000000;
+
+       /*  add item */
+       err = memo_add_data(item);
+       if (err < 0) {
+               _DEBUG_INFO("[da_memo_plugIn] memo_add_data() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *item_id = 0;
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] memo_add_data() Success!\n");
+               *item_id = g_strdup_printf("%d", err);
+               is_storage_changed = 1;
+       }
+
+       /* memory free */
+       if (item != NULL)
+               memo_free_data(item);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_update_item(int account_id, char *folder_id, char *item_id, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "data is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       struct memo_data *item = (struct memo_data *)data;
+
+       /* update item */
+       err = memo_mod_data(item);
+       if (err < 0) {
+               _DEBUG_INFO("[da_memo_plugIn] memo_mod_data() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] memo_mod_data() Success!\n");
+               is_storage_changed = 1;
+       }
+
+       /*  memory free */
+       if (item != NULL)
+               memo_free_data(item);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_item(int account_id, char *folder_id, char *item_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+
+       /* delete item */
+       err = memo_del_data(atoi(item_id));
+       if (err < 0) {
+               _DEBUG_INFO("[da_memo_plugIn] memo_del_data(%s) Fail!\n", item_id);
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] memo_del_data(%s) Success!\n", item_id);
+               is_storage_changed = 1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_all_items(int account_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 1;
+       struct memo_data_list *item_list = NULL;
+       struct memo_data_list *first_item_list = NULL;
+
+       /* get all data in memo db */
+       item_list = memo_get_all_data_list();
+       first_item_list = item_list;
+
+       while (item_list != NULL) {
+               err = memo_del_data(item_list->md.id);
+               if (err < 0) {
+                       _DEBUG_INFO("[da_memo_plugIn] memo_del_data(%d) Fail!\n", item_list->md.id);
+                       ret = _convert_service_error_to_common_error(err);
+                       break;
+               } else {
+                       _DEBUG_INFO("[da_memo_plugIn] memo_del_data(%d) Success!\n", item_list->md.id);
+                       is_storage_changed = 1;
+               }
+
+               /* memory free */
+               if (item_list->md.comment != NULL) {
+                       free(item_list->md.comment);
+                       item_list->md.comment = 0;
+               }
+
+               if (item_list->md.doodle_path != NULL) {
+                       free(item_list->md.doodle_path);
+                       item_list->md.doodle_path = 0;
+               }
+
+               item_list = item_list->next;
+       }
+
+       /* memory free */
+       if (first_item_list != NULL) {
+               memo_free_data_list(first_item_list);
+               _DEBUG_INFO("[da_memo_plugIn] memo_free_data_list \n");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_item(int account_id, char *folder_id, char *item_id, void **data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(item_id == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "item_id is NULL. FAIL !!!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       struct memo_data *item = 0;
+
+       /* get item */
+       item = memo_get_data(atoi(item_id));
+       if (item == NULL) {
+               _DEBUG_INFO("[da_memo_plugIn] memo_get_data() Fail!\n");
+               ret = SYNC_AGENT_DA_ERRORS;
+               *data = 0;
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] memo_get_data() Success!");
+               *data = (void *)item;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_add_folder(int account_id, char *folder_name, int folder_type, char **folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] memo service is not supported folder\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_delete_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] memo service is not supported folder\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_get_folder(int account_id, char *folder_id, char **out_folder_name, int *out_folder_type)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] memo service is not supported folder\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_execute(int account_ID, const char *execute_key, void *execute_values, void **result)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] memo service is not supported execute. \n");
+       *result = 0;
+
+       _EXTERN_FUNC_EXIT;
+
+       return SYNC_AGENT_DA_SUCCESS;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int ret = SYNC_AGENT_DA_SUCCESS;
+       int used_cnt = 0;
+       int err = memo_get_count(&used_cnt);
+       if (err == -1) {
+               _DEBUG_INFO("[da_memo_plugIn] memo_get_count() Fail\n");
+               ret = _convert_service_error_to_common_error(err);
+       } else {
+               _DEBUG_INFO("[da_memo_plugIn] memo_get_count() Success\n");
+               _DEBUG_INFO("[da_memo_plugIn] used_count = %d\n", used_cnt);
+               ret = used_cnt;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count_for_folder(int account_id, char *folder_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] Memo plugIn is not supported this function\n");
+       _DEBUG_INFO("[da_memo_plugIn] Return all memo count \n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return sync_agent_plugin_get_used_item_count();
+}
+
+EXPORT_API char **sync_agent_plugin_get_folder_id_list(int account_id, int *folder_count, int **folder_type_list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char **folder_id_list = (char **)calloc(1, sizeof(char *));
+       if (folder_id_list == NULL)
+               return 0;
+
+       *folder_type_list = (int *)calloc(1, sizeof(int));
+       if (*folder_type_list == NULL) {
+               free(folder_id_list);
+               return 0;
+       }
+
+       folder_id_list[0] = "0";
+       *folder_count = 1;
+       (*folder_type_list)[0] = DEFAULT_MEMO_FOLDER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return folder_id_list;
+}
+
+EXPORT_API int *sync_agent_plugin_get_account_id_list(int *count)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[da_memo_plugIn] start!!\n");
+
+       int *account_id_list = (int *)calloc(1, sizeof(int));
+       if (account_id_list == NULL)
+               return 0;
+
+       *count = 1;
+       account_id_list[0] = -1;
+
+       _EXTERN_FUNC_EXIT;
+
+       return account_id_list;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_add(int account_id, const char *folder_id, int changepoint, int *changeCount)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("\n[da_memo_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_memo_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_memo_plugIn] changepoint : %d\n", changepoint);
+
+       bool success = true;
+
+       int memo_time_stamp = changepoint;
+       struct memo_operation_list *item_list = 0;
+       struct memo_operation_list *item_list_origin = 0;
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+
+       item_list = memo_get_operation_list(memo_time_stamp);
+       if (item_list == NULL)
+               goto DACI_FINISH;
+
+       item_list_origin = item_list;
+
+       while ((item_list != 0) && (item_list->id > -1)) {
+               if (item_list->operation == MEMO_OPERATION_ADD) {
+                       int digit = _get_digit(item_list->id);
+                       char *str_item_id = (char *)calloc(digit + 1, sizeof(char));
+                       if (str_item_id == NULL) {
+                               _DEBUG_ERROR("str_item_id is null");
+                               goto DACI_FINISH;
+                       }
+
+                       snprintf(str_item_id, digit + 1, "%d", item_list->id);
+                       _DEBUG_INFO("[da_memo_plugIn] MEMO_OPERATION_ADD : [%s]\n", str_item_id);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("root_ptr is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       goto DACI_FINISH;
+                               }
+
+                               root_ptr->item_id = str_item_id;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("cursor_ptr->next is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       success = false;
+                                       goto DACI_FINISH;
+                               }
+
+                               cursor_ptr->next->item_id = str_item_id;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+               item_list = item_list->next;
+       }
+
+ DACI_FINISH:
+
+       /*  memory free */
+       if (item_list_origin != NULL) {
+               memo_free_operation_list(item_list_origin);
+               item_list_origin = 0;
+       }
+
+       if (success != true) {
+               _free_item_node(root_ptr);
+               root_ptr = NULL;
+               *changeCount = 0;
+       } else {
+               *changeCount = chagned_count;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_delete(int account_id, const char *folder_id, int changepoint, int *changeCount)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("\n[da_memo_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_memo_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_memo_plugIn] changepoint : %d\n", changepoint);
+
+       bool success = true;
+
+       int memo_time_stamp = changepoint;
+       struct memo_operation_list *item_list = 0;
+       struct memo_operation_list *item_list_origin = 0;
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+
+       item_list = memo_get_operation_list(memo_time_stamp);
+       if (item_list == NULL)
+               goto DACI_FINISH;
+
+       item_list_origin = item_list;
+
+       while ((item_list != 0) && (item_list->id > -1)) {
+               if (item_list->operation == MEMO_OPERATION_DELETE) {
+                       int digit = _get_digit(item_list->id);
+                       char *str_item_id = (char *)calloc(digit + 1, sizeof(char));
+                       if (str_item_id == NULL) {
+                               _DEBUG_ERROR("str_item_id is null");
+                               goto DACI_FINISH;
+                       }
+
+                       snprintf(str_item_id, digit + 1, "%d", item_list->id);
+                       _DEBUG_INFO("[da_memo_plugIn] MEMO_OPERATION_DELETE : [%s]\n", str_item_id);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("root_ptr is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       goto DACI_FINISH;
+                               }
+
+                               root_ptr->item_id = str_item_id;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("cursor_ptr->next is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       success = false;
+                                       goto DACI_FINISH;
+                               }
+
+                               cursor_ptr->next->item_id = str_item_id;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+               item_list = item_list->next;
+       }
+
+ DACI_FINISH:
+
+       /*  memory free */
+       if (item_list_origin != NULL) {
+               memo_free_operation_list(item_list_origin);
+               item_list_origin = 0;
+       }
+
+       if (success != true) {
+               _free_item_node(root_ptr);
+               root_ptr = NULL;
+               *changeCount = 0;
+       } else {
+               *changeCount = chagned_count;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API sync_agent_plugin_item_node_s *sync_agent_plugin_get_changed_item_for_folder_update(int account_id, const char *folder_id, int changepoint, int *changeCount)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("\n[da_memo_plugIn] account_id : %d\n", account_id);
+       _DEBUG_INFO("[da_memo_plugIn] folder_id : %s\n", folder_id);
+       _DEBUG_INFO("[da_memo_plugIn] changepoint : %d\n", changepoint);
+
+       bool success = true;
+
+       int memo_time_stamp = changepoint;
+       struct memo_operation_list *item_list = 0;
+       struct memo_operation_list *item_list_origin = 0;
+
+       sync_agent_plugin_item_node_s *root_ptr = 0;
+       sync_agent_plugin_item_node_s *cursor_ptr = 0;
+       int chagned_count = 0;
+
+       item_list = memo_get_operation_list(memo_time_stamp);
+       if (item_list == NULL)
+               goto DACI_FINISH;
+
+       item_list_origin = item_list;
+
+       while ((item_list != 0) && (item_list->id > -1)) {
+               if (item_list->operation == MEMO_OPERATION_UPDATE) {
+                       int digit = _get_digit(item_list->id);
+                       char *str_item_id = (char *)calloc(digit + 1, sizeof(char));
+                       if (str_item_id == NULL) {
+                               _DEBUG_ERROR("str_item_id is null");
+                               goto DACI_FINISH;
+                       }
+
+                       snprintf(str_item_id, digit + 1, "%d", item_list->id);
+                       _DEBUG_INFO("[da_memo_plugIn] MEMO_OPERATION_UPDATE : [%s]\n", str_item_id);
+
+                       if (root_ptr == NULL) {
+                               root_ptr = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (root_ptr == NULL) {
+                                       _DEBUG_ERROR("root_ptr is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       goto DACI_FINISH;
+                               }
+
+                               root_ptr->item_id = str_item_id;
+                               root_ptr->next = 0;
+                               cursor_ptr = root_ptr;
+                       } else {
+                               cursor_ptr->next = (sync_agent_plugin_item_node_s *) calloc(1, sizeof(sync_agent_plugin_item_node_s));
+                               if (cursor_ptr->next == NULL) {
+                                       _DEBUG_ERROR("cursor_ptr->next is null, calloc() FAIL !!!");
+                                       free(str_item_id);
+                                       success = false;
+                                       goto DACI_FINISH;
+                               }
+
+                               cursor_ptr->next->item_id = str_item_id;
+                               cursor_ptr->next->next = 0;
+                               cursor_ptr = cursor_ptr->next;
+                       }
+
+                       chagned_count++;
+               }
+               item_list = item_list->next;
+       }
+
+ DACI_FINISH:
+
+       /*  memory free */
+       if (item_list_origin != NULL) {
+               memo_free_operation_list(item_list_origin);
+               item_list_origin = 0;
+       }
+
+       if (success != true) {
+               _free_item_node(root_ptr);
+               root_ptr = NULL;
+               *changeCount = 0;
+       } else {
+               *changeCount = chagned_count;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return root_ptr;
+}
+
+EXPORT_API int sync_agent_plugin_get_last_change_point()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return (int)time(0);
+}
+
+EXPORT_API void sync_agent_plugin_start_listening_change_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       memo_subscribe_change(_process_memo_change, 0);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_add_item(sync_agent_add_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_add_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_delete_item(sync_agent_del_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_del_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_update_item(sync_agent_update_item_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_update_item = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API void sync_agent_plugin_set_callback_get_account_id_list(sync_agent_get_account_id_list_cb_plugin callback)
+{
+       _EXTERN_FUNC_ENTER;
+
+       callback_get_accountidlist = callback;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+/********************************** static function *******************************************/
+
+static void _free_item_node(sync_agent_plugin_item_node_s * node)
+{
+       if (node != NULL) {
+               if (node->item_id != NULL) {
+                       free(node->item_id);
+                       node->item_id = NULL;
+               }
+               if (node->next != NULL) {
+                       _free_item_node(node->next);
+                       node->next = NULL;
+               }
+
+               free(node);
+       }
+}
+
+static void _set_is_noti_from_me(int set_flag)
+{
+       _INNER_FUNC_ENTER;
+
+       if (pthread_mutex_lock(&lockx)) {
+               _DEBUG_TRACE("[da_memo_plugIn] pthread_mutex_lock error");
+       }
+
+       is_noti_from_me = set_flag;
+
+       if (pthread_mutex_unlock(&lockx)) {
+               _DEBUG_TRACE("[da_memo_plugIn] pthread_mutex_unlock error");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static int __get_is_noti_from_me()
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return is_noti_from_me;
+}
+
+void _process_memo_change(void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("[da_memo_plugIn] detected memo storage changed!!\n");
+
+       int from_Me = __get_is_noti_from_me();
+       if (from_Me == 1) {
+               _set_is_noti_from_me(0);
+               _DEBUG_TRACE("[da_memo_plugIn] This noti is from Me!! so will be ignored!!\n");
+               return;
+       }
+
+       pthread_t thread_process_change_id;
+       pthread_create(&thread_process_change_id, 0, __rutine_memo_change, 0);
+
+       _INNER_FUNC_EXIT;
+}
+
+static void *__rutine_memo_change(void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_VERBOSE("[da_memo_plugIn] Start __rutine_memo_change (create thread)\n");
+
+       int memo_time_stamp = get_memo_time_stamp();
+
+       int i = 0;
+       int count = 0;
+       int result = 0;
+       char *str_item_id = 0;
+       int *accountList = 0;
+       struct memo_operation_list *item_list = 0;
+       struct memo_operation_list *item_list_origin = 0;
+
+       accountList = callback_get_accountidlist(FW_MEMO, &count);
+       if (accountList == NULL)
+               goto DACI_FINISH;
+
+       item_list = memo_get_operation_list(memo_time_stamp);
+       if (item_list == NULL)
+               goto DACI_FINISH;
+
+       item_list_origin = item_list;
+
+       while ((item_list != 0) && (item_list->id > -1)) {
+               str_item_id = g_strdup_printf("%d", item_list->id);
+
+               for (i = 0; i < count; i++) {
+                       _DEBUG_VERBOSE("[da_memo_plugIn] memo_account_id : %d, count : %d\n", accountList[i], count);
+                       _DEBUG_VERBOSE("[da_memo_plugIn] memo_get_operation_list : %d\n", memo_time_stamp);
+
+                       switch (item_list->operation) {
+                       case MEMO_OPERATION_ADD:
+                               {
+                                       /* memo service is not supported folder */
+                                       _DEBUG_VERBOSE("[da_memo_plugIn]  MEMO_OPERATION_ADD\n");
+                                       result = callback_add_item(accountList[i], i, str_item_id, FW_MEMO, "0", 0);
+                                       if (!result) {
+                                               _DEBUG_ERROR("[da_memo_plugIn] Failed to call callback_add_item() \n");
+                                               goto DACI_FINISH;
+                                       }
+                               }
+                               break;
+                       case MEMO_OPERATION_UPDATE:
+                               {
+                                       _DEBUG_VERBOSE("[da_memo_plugIn] MEMO_OPERATION_UPDATE\n");
+                                       result = callback_update_item(accountList[i], i, str_item_id, FW_MEMO);
+                                       if (!result) {
+                                               _DEBUG_ERROR("[da_memo_plugIn] Failed to call callback_update_item() \n");
+                                               goto DACI_FINISH;
+                                       }
+                               }
+                               break;
+                       case MEMO_OPERATION_DELETE:
+                               {
+                                       _DEBUG_VERBOSE("[da_memo_plugIn] MEMO_OPERATION_DELETE\n");
+                                       result = callback_del_item(accountList[i], i, str_item_id, FW_MEMO);
+                                       if (!result) {
+                                               _DEBUG_ERROR("[da_memo_plugIn] Failed to call callback_del_item() \n");
+                                               goto DACI_FINISH;
+                                       }
+                               }
+                               break;
+                       default:
+                               _DEBUG_VERBOSE("[da_memo_plugIn] Another Memo Change Noti\n");
+                               break;
+                       }
+               }
+               item_list = item_list->next;
+               free(str_item_id);
+               str_item_id = 0;
+       }
+
+ DACI_FINISH:
+
+       /*  memory free */
+       if (item_list_origin != NULL) {
+               memo_free_operation_list(item_list_origin);
+               item_list_origin = 0;
+       }
+
+       if (accountList != NULL) {
+               free(accountList);
+               accountList = 0;
+       }
+
+       if (str_item_id != NULL) {
+               free(str_item_id);
+               str_item_id = 0;
+       }
+
+       _DEBUG_VERBOSE("[da_memo_plugIn] End __rutine_memo_change (create thread)\n");
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+static sync_agent_da_return_e _convert_service_error_to_common_error(int err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_memo_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+
+static int _get_digit(int new_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int temp_id = 0;
+       int count = 1;
+
+       temp_id = new_id;
+
+       while (1) {
+               if (temp_id >= 10) {
+                       temp_id /= 10;
+                       count++;
+               } else
+                       break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return count;
+}
diff --git a/src/fw-plugins/common-public/slp-device/CMakeLists.txt b/src/fw-plugins/common-public/slp-device/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a215561
--- /dev/null
@@ -0,0 +1,46 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "di-slp-device")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       glib-2.0
+                                       vconf
+                                       tapi
+                                       pmapi
+                                       capi-system-info
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${di-slp-device_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${di-slp-device_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/plugin_slp_device.h DESTINATION include/sync-agent/plugin/)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
diff --git a/src/fw-plugins/common-public/slp-device/include/plugin_slp_device.h b/src/fw-plugins/common-public/slp-device/include/plugin_slp_device.h
new file mode 100755 (executable)
index 0000000..aceb4e6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_SLP_DEVICE_H_
+#define PLUGIN_SLP_DEVICE_H_
+
+/*
+ *     list of device information on SLP
+ */
+
+/*
+ *             < OMA DS >
+ *  - DevID : device id
+ *  - Man : manufacture
+ *  - Mod : model id or model number
+ *  - SwV : software version
+ *  - HwV : hardware version
+ *  - FwV : firmware version
+ *  - ModemV : modem version
+ *  - PDAV : PDA version
+ *  - OEM : original equipment manufacturer
+ *  - DevType : device type
+ */
+
+/**
+ * @brief Enumerations for state of power manager
+ */
+typedef enum {
+       LCD_NORMAL = 0,
+       LCD_DIM,
+       LCD_OFF,
+       SUSPEND,
+       POWER_OFF,
+       SETALL
+} pm_state_e;
+
+/**
+ * @brief Enumerations for lock state of power manager
+ */
+typedef enum {
+       GOTO_STATE_NOW = 0,
+       STAY_CUR_STATE
+} pm_lock_state_flag_e;
+
+/**
+ * @brief Enumerations for unlock state of power manager
+ */
+typedef enum {
+       SLEEP_MARGIN = 0,
+       RESET_TIMER,
+       KEEP_TIMER
+} pm_unlock_state_flag_e;
+
+#endif                         /* PLUGIN_SLP_DEVICE_H_ */
diff --git a/src/fw-plugins/common-public/slp-device/include/slp_device_info.h b/src/fw-plugins/common-public/slp-device/include/slp_device_info.h
new file mode 100755 (executable)
index 0000000..c092e0d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SAMSUNG_DEVICE_INFO_H_
+#define SAMSUNG_DEVICE_INFO_H_
+
+char *slp_device_info_get_software_version();
+char *slp_device_info_get_hardware_version();
+char *slp_device_info_get_modem_version();
+char *slp_device_info_get_pda_version();
+char *slp_device_info_get_csc_version();
+char *slp_device_info_get_firmware_version();
+
+char *slp_device_info_get_device_id();
+char *slp_device_info_get_device_type();
+char *slp_device_info_get_manufacturer_info();
+char *slp_device_info_get_model_info();
+char *slp_device_info_get_oem_info();
+
+char *slp_device_info_get_battery_level();
+
+#endif                         /* SAMSUNG_DEVICE_INFO_H_ */
diff --git a/src/fw-plugins/common-public/slp-device/src/plugin_interface_devexe.c b/src/fw-plugins/common-public/slp-device/src/plugin_interface_devexe.c
new file mode 100755 (executable)
index 0000000..b439ba0
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+#include "plugin_slp_device.h"
+
+#include "utility/sync_util.h"
+#include "device/information.h"
+#include "plugin/device_info_interface.h"
+
+#include "pmapi.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DEVINFO_SLP"
+#endif
+
+static unsigned int _convert_pm_state(int state);
+static unsigned int _convert_pm_lock_flag(int flag);
+static unsigned int _convert_pm_unlock_flag(int flag);
+
+EXPORT_API int sync_agent_plugin_execute_dev_function(char *function_name, int args_cnt, va_list ap)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(function_name == NULL, 0, "function_name is NULL. FAIL !!!");
+
+       if (!strncmp(function_name, "pm_lock", strlen("pm_lock"))) {
+
+               pm_state_e state = va_arg(ap, pm_state_e);
+               pm_lock_state_flag_e flag = va_arg(ap, pm_lock_state_flag_e);
+               unsigned int timeout = va_arg(ap, unsigned int);
+
+               _DEBUG_INFO(" Received %s request !!!", function_name);
+               return pm_lock_state(_convert_pm_state(state), _convert_pm_lock_flag(flag), timeout);
+
+       } else if (!strncmp(function_name, "pm_unlock", strlen("pm_unlock"))) {
+
+               pm_state_e state = va_arg(ap, pm_state_e);
+               pm_unlock_state_flag_e flag = va_arg(ap, pm_unlock_state_flag_e);
+
+               _DEBUG_INFO(" Received %s request !!!", function_name);
+               return pm_unlock_state(_convert_pm_state(state), _convert_pm_unlock_flag(flag));
+
+       } else if (!strncmp(function_name, "pm_change", strlen("pm_change"))) {
+
+               pm_state_e state = va_arg(ap, pm_state_e);
+
+               _DEBUG_INFO(" Received %s request !!!", function_name);
+               return pm_change_state(_convert_pm_state(state));
+
+       } else {
+               _DEBUG_INFO("Device function requested not defined in plug-in !!!");
+               goto error_part;
+       }
+
+ error_part:
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static unsigned int _convert_pm_state(int state)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int pm_state = -1;
+
+       switch (state) {
+       case 0:
+               pm_state = LCD_NORMAL;
+               break;
+       case 1:
+               pm_state = LCD_DIM;
+               break;
+       case 2:
+               pm_state = LCD_OFF;
+               break;
+       case 3:
+               pm_state = SUSPEND;
+               break;
+       case 4:
+               pm_state = POWER_OFF;
+               break;
+       case 5:
+               pm_state = LCD_DIM | LCD_OFF | LCD_NORMAL;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pm_state;
+}
+
+static unsigned int _convert_pm_lock_flag(int flag)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int pm_flag = -1;
+
+       switch (flag) {
+       case 0:
+               pm_flag = GOTO_STATE_NOW;
+               break;
+       case 1:
+               pm_flag = STAY_CUR_STATE;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pm_flag;
+}
+
+static unsigned int _convert_pm_unlock_flag(int flag)
+{
+       _INNER_FUNC_ENTER;
+
+       unsigned int pm_flag = -1;
+
+       switch (flag) {
+       case 0:
+               pm_flag = PM_SLEEP_MARGIN;
+               break;
+       case 1:
+               pm_flag = PM_RESET_TIMER;
+               break;
+       case 2:
+               pm_flag = PM_KEEP_TIMER;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return pm_flag;
+}
diff --git a/src/fw-plugins/common-public/slp-device/src/plugin_interface_devinfo.c b/src/fw-plugins/common-public/slp-device/src/plugin_interface_devinfo.c
new file mode 100755 (executable)
index 0000000..ebd849d
--- /dev/null
@@ -0,0 +1,361 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "slp_device_info.h"
+
+#include "utility/sync_util.h"
+#include "plugin/device_info_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DEVINFO_SLP"
+#endif
+
+#define IMEI_LEN                                       5
+#define FW_VERSION_LEN         20
+#define BUFF_SIZE                                      1000
+
+/* todo : temporary definition */
+#define HW_VERSION                             "1.0"
+
+typedef struct {
+       char *info_name;
+       char *vconf_key;
+} dici_name_key_map_s;
+
+dici_name_key_map_s dev_key_map[] = {
+       {"SwV", VCONFKEY_TELEPHONY_SWVERSION},
+       {"HwV", VCONFKEY_TELEPHONY_HWVERSION},
+       /*{"Lang", "db/menu_widget/language"}, */
+       {"Lang", VCONFKEY_LANGSET},
+       {NULL, NULL},
+};
+
+static GList *dev_info;
+static void _free_device_info(sync_agent_plugin_device_info_s * devinfo);
+
+/*static int find_key(const char *info_name, char *key);*/
+
+EXPORT_API int sync_agent_plugin_load_devinfo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       g_type_init();
+
+       int res = 1;
+
+       dev_info = NULL;
+       int idx = 0;
+
+       sync_agent_plugin_device_info_s *dev_id = NULL;
+       sync_agent_plugin_device_info_s *man = NULL;
+       sync_agent_plugin_device_info_s *mod = NULL;
+       sync_agent_plugin_device_info_s *fw = NULL;
+       sync_agent_plugin_device_info_s *oem = NULL;
+       sync_agent_plugin_device_info_s *dev_type = NULL;
+       sync_agent_plugin_device_info_s *modem_version = NULL;
+       sync_agent_plugin_device_info_s *pda_version = NULL;
+       sync_agent_plugin_device_info_s *csc_version = NULL;
+
+       dev_id = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (dev_id == NULL) {
+               _DEBUG_ERROR("malloc() dev_id FAIL !!!");
+               goto error_part;
+       }
+       memset(dev_id, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       man = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (man == NULL) {
+               _DEBUG_ERROR("malloc() man FAIL !!!");
+               goto error_part;
+       }
+       memset(man, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       mod = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (mod == NULL) {
+               _DEBUG_ERROR("malloc() mod FAIL !!!");
+               goto error_part;
+       }
+       memset(mod, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       fw = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (fw == NULL) {
+               _DEBUG_ERROR("malloc() fw FAIL !!!");
+               goto error_part;
+       }
+       memset(fw, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       oem = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (oem == NULL) {
+               _DEBUG_ERROR("malloc() oem FAIL !!!");
+               goto error_part;
+       }
+       memset(oem, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       dev_type = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (dev_type == NULL) {
+               _DEBUG_ERROR("malloc() dev_type FAIL !!!");
+               goto error_part;
+       }
+       memset(dev_type, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       modem_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (modem_version == NULL) {
+               _DEBUG_ERROR("malloc() modem_version FAIL !!!");
+               goto error_part;
+       }
+       memset(modem_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       pda_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (pda_version == NULL) {
+               _DEBUG_ERROR("malloc() pda_version FAIL !!!");
+               goto error_part;
+       }
+       memset(pda_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+       csc_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+       if (csc_version == NULL) {
+               _DEBUG_ERROR("malloc() csc_version FAIL !!!");
+               goto error_part;
+       }
+       memset(csc_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+
+       /* get SwV, HwV, Lang */
+       sync_agent_plugin_device_info_s *info = NULL;
+       while (dev_key_map[idx].info_name != NULL) {
+
+               info = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+               if (info == NULL) {
+                       _DEBUG_ERROR("malloc() info FAIL !!!");
+                       goto error_part;
+               }
+               memset(info, 0x00, sizeof(sync_agent_plugin_device_info_s));
+
+               info->info_name = strdup(dev_key_map[idx].info_name);
+               info->value = strdup(vconf_get_str(dev_key_map[idx].vconf_key));
+               _DEBUG_INFO("[devInfo_slp_plugIn] info_name : %s\n", info->info_name);
+               _DEBUG_INFO("[devInfo_slp_plugIn] value : %s\n", info->value);
+
+               if (!strcmp(info->info_name, "HwV")) {
+                       if ((info->value == NULL) || (!strcmp(info->value, "")) || (!strcmp(info->value, "REV__"))) {
+                               free(info->value);
+                               info->value = strdup(HW_VERSION);
+                       }
+               }
+
+               _DEBUG_INFO("[devInfo_slp_plugIn] value : %s\n", info->value);
+               dev_info = g_list_append(dev_info, info);
+               ++idx;
+       }
+
+       /* get DevID */
+       dev_id->info_name = strdup("DevID");
+       dev_id->value = slp_device_info_get_device_id();
+       dev_info = g_list_append(dev_info, dev_id);
+       _DEBUG_INFO("mdi ============= \n");
+
+       /* get Manufacture */
+       man->info_name = strdup("Man");
+       man->value = slp_device_info_get_manufacturer_info();
+       dev_info = g_list_append(dev_info, man);
+
+       /* get Model info */
+       mod->info_name = strdup("Mod");
+       mod->value = slp_device_info_get_model_info();
+       dev_info = g_list_append(dev_info, mod);
+
+       /* get FwV */
+       fw->info_name = strdup("FwV");
+       fw->value = slp_device_info_get_firmware_version();
+       dev_info = g_list_append(dev_info, fw);
+
+       /* get OEM */
+       oem->info_name = strdup("OEM");
+       oem->value = slp_device_info_get_oem_info();
+       dev_info = g_list_append(dev_info, oem);
+
+       /* get DevTyp */
+       dev_type->info_name = strdup("DevTyp");
+       dev_type->value = slp_device_info_get_device_type();
+       dev_info = g_list_append(dev_info, dev_type);
+
+       /* get Modem version */
+       modem_version->info_name = strdup("ModemV");
+       modem_version->value = slp_device_info_get_modem_version();
+       dev_info = g_list_append(dev_info, modem_version);
+
+       /* get PDA version */
+       pda_version->info_name = strdup("PDAV");
+       pda_version->value = slp_device_info_get_pda_version();
+       dev_info = g_list_append(dev_info, pda_version);
+
+       /* get CSC version */
+       csc_version->info_name = strdup("CSCV");
+       csc_version->value = slp_device_info_get_csc_version();
+       dev_info = g_list_append(dev_info, csc_version);
+
+       /* for test */
+       int cnt = 0;
+       GList *iter = NULL;
+       for (iter = dev_info; iter != NULL; iter = g_list_next(iter)) {
+               _DEBUG_INFO("[devInfo_slp_plugIn] cnt : %d,  info_name : %s, value : %s\n", cnt, ((sync_agent_plugin_device_info_s *) (iter->data))->info_name, ((sync_agent_plugin_device_info_s *) (iter->data))->value);
+               cnt++;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+
+ error_part:
+
+       _free_device_info(dev_id);
+       _free_device_info(man);
+       _free_device_info(mod);
+       _free_device_info(fw);
+       _free_device_info(oem);
+       _free_device_info(dev_type);
+       _free_device_info(modem_version);
+       _free_device_info(pda_version);
+       _free_device_info(csc_version);
+
+       res = sync_agent_plugin_clear_devinfo();
+
+       _DEBUG_ERROR("Returning with error.. means FAIL !!!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+EXPORT_API int sync_agent_plugin_get_devinfo(char *info_name, char **value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(info_name == NULL, 0, "info_name is NULL. FAIL !!!");
+
+       int res = 1;
+       int is_exist = 0;
+       GList *iter = NULL;
+       sync_agent_plugin_device_info_s *iter_data;
+
+       for (iter = dev_info; iter != NULL; iter = g_list_next(iter)) {
+               iter_data = NULL;
+               iter_data = (sync_agent_plugin_device_info_s *) (iter->data);
+               if (iter_data->info_name != NULL) {
+                       if (!strcmp(iter_data->info_name, info_name)) {
+                               if (iter_data->value != NULL) {
+
+                                       *value = strdup(iter_data->value);
+
+                                       is_exist = 1;
+                                       break;
+                               } else {
+                                       _DEBUG_INFO("[devInfo_slp_plugIn] %s  value is NULL !!\n", info_name);
+                                       res = 0;
+                                       return res;
+                               }
+                       }
+               }
+       }
+
+       if (strcmp("Battery", info_name) == 0) {
+               *value = slp_device_info_get_battery_level();
+               if (*value != NULL)
+                       is_exist = 1;
+       }
+
+       if (is_exist != 1) {
+               _DEBUG_INFO("[devInfo_slp_plugIn] not exist  %s  information !!\n", info_name);
+               res = -1;
+               return res;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_clear_devinfo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       GList *iter = NULL;
+       sync_agent_plugin_device_info_s *iter_data;
+
+       if (dev_info != NULL) {
+               for (iter = dev_info; iter != NULL;) {
+                       iter_data = NULL;
+                       iter_data = ((sync_agent_plugin_device_info_s *) (iter->data));
+                       iter = g_list_next(iter);
+                       dev_info = g_list_remove(dev_info, iter_data);
+
+                       _free_device_info((sync_agent_plugin_device_info_s *) (iter_data));
+               }
+
+               g_list_free(dev_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+static void _free_device_info(sync_agent_plugin_device_info_s * devinfo)
+{
+       if (devinfo != NULL) {
+               if (devinfo->info_name != NULL) {
+                       free(devinfo->info_name);
+                       devinfo->info_name = NULL;
+               }
+               if (devinfo->value != NULL) {
+                       free(devinfo->value);
+                       devinfo->value = NULL;
+               }
+
+               free(devinfo);
+       }
+}
+
+/*static int find_key(const char *info_name, char *key)
+{
+       int res = 1;
+       int idx = 0;
+
+       while (dev_key_map[idx].info_name != NULL) {
+               if (!strcmp(dev_key_map[idx].info_name, info_name)) {
+                       if (dev_key_map[idx].vconf_key != NULL) {
+                               key = dev_key_map[idx].vconf_key;
+                               break;
+                       } else {
+                               _DEBUG_INFO("[devInfo_slp_plugIn] vconf_key is NULL ( %s )\n", info_name);
+                               res = 0;
+                               return res;
+                       }
+               }
+
+               ++idx;
+       }
+
+       _DEBUG_INFO("[devInfo_slp_plugIn] vconf_key : %s\n", key);
+
+       return res;
+}*/
diff --git a/src/fw-plugins/common-public/slp-device/src/slp_device_info.c b/src/fw-plugins/common-public/slp-device/src/slp_device_info.c
new file mode 100755 (executable)
index 0000000..7d16144
--- /dev/null
@@ -0,0 +1,769 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "slp_device_info.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <tapi_common.h>
+#include <ITapiModem.h>
+#include <ITapiSim.h>
+#include <system_info.h>
+
+#include "fsapi/operation.h"
+#include "plugin/device_info_interface.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "SLP_DEVICE_INFO"
+#endif
+
+#define _D_MSC_FIRMWARE_MAXSTRING_      40
+#define _D_SIZE_64_                     64
+#define _D_SIZE_128_                    128
+
+/* todo : temporary definition */
+#define SW_VERSION            "SLP-v1.0"
+#define HW_VERSION                             "GT-I9500-v1.0"
+#define FW_VERSION                             "1.0"
+#define MODEM_VERSION          "M.I9500XXUI"
+#define PDA_VERSION                    "P.I9500XXJI-"
+#define PDA_BIN_VERSION                                   "/usr/etc/info.ini"
+#define PDA_VERSION_INFO_FILE  "/etc/info.ini"
+#define CSC_DB_VERSION                                         "/mnt/csc/info.ini"
+#define _D_PDA_BUILD_INFO_MAJOR_              "Major="
+#define _D_PDA_BUILD_INFO_BUILD_               "Build="
+
+#define MANUFACTURE                    "Samsung electronics"
+#define MODEL                                          "GT-I9500"
+#define OEM                                                    "Samsung Electronics"
+#define DEV_TYPE                                       "phone"
+
+#define BATTERY_LEVEL                                  "/sys/class/power_supply/battery/capacity"
+
+/* ========================================*/
+/* version information
+ *     software version
+ *     hardware version
+ *     modem version
+ *     PDA version
+ *     CSC version
+ *     firmware version
+ */
+/* ========================================*/
+char *slp_device_info_get_software_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+       char *sw_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (sw_version == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       /*snprintf(sw_version, _D_SIZE_128_ - 1, SW_VERSION, strlen(SW_VERSION)); */
+       snprintf(sw_version, _D_SIZE_128_ - 1, "%s", SW_VERSION);
+       _DEBUG_INFO("SW version = %s\n", sw_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return sw_version;
+}
+
+char *slp_device_info_get_hardware_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+       /* TODO */
+       char *HW_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (HW_version == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       /*snprintf(HW_version, _D_SIZE_128_ - 1, HW_VERSION, strlen(HW_VERSION)); */
+       snprintf(HW_version, _D_SIZE_128_ - 1, "%s", HW_VERSION);
+       _DEBUG_INFO("HW version = %s\n", HW_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return HW_version;
+}
+
+char *slp_device_info_get_modem_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+/*
+       char *get_str;
+       char str_key_name[_D_SIZE_128_ * 2] = { 0, };
+       snprintf(str_key_name, _D_SIZE_128_ * 2, "%s", VCONFKEY_TELEPHONY_SWVERSION);
+       get_str = vconf_get_str(str_key_name);
+       _DEBUG_INFO("Modem version = %s\n", get_str);
+       return get_str;
+*/
+       char *get_str = NULL;
+       TapiHandle *handle = tel_init(NULL);
+       if (!handle)
+               _DEBUG_INFO("tapi handle is null\n");
+
+       TelMiscVersionInformation *info = tel_get_misc_me_version_sync(handle);
+       if (!info) {
+               _DEBUG_INFO("tet_get_misc_me_version_sync -> return Fail\n");
+               get_str = strdup("I8800XXKI1");
+       } else {
+               _DEBUG_INFO("szSwVersion [%s], szHwVersion [%s], szRfCalDate [%s], szProductCode [%s]\n", info->szSwVersion, info->szHwVersion, info->szRfCalDate, info->szProductCode);
+               get_str = strdup((char *)(info->szSwVersion));  // I9200XXKI2
+               free(info);
+       }
+
+       if (!handle)
+               tel_deinit(handle);
+
+       _DEBUG_INFO("Modem version = %s\n", get_str);
+
+       _EXTERN_FUNC_EXIT;
+
+       return get_str;
+}
+
+/* pre source */
+/*char *slp_device_info_get_pda_version()
+{
+      FILE *file_des;
+    //file_des =fopen("/usr/etc/info.ini","rb");
+
+    file_des =fopen(PDA_VERSION_INFO_FILE,"rb");
+    int i = 0 ;
+      if(file_des==NULL)
+      {
+                       _DEBUG_INFO("fopen fail - info.ini \n");
+                       return g_strdup_printf("%s", PDA_VERSION);
+      }
+
+      char *pda_version = 0;
+    while( ! feof(file_des) )
+    {
+               char info_temp[20] = {0,} ;
+               int result = 1 ;
+               fseek(file_des,i,SEEK_SET);
+               i++ ;
+
+               fread(info_temp, sizeof(char) , strlen("Major=") , file_des );
+               result = memcmp( info_temp , "Major=" , strlen("Major=") ) ;
+               if( !result )
+               {
+                       if (pda_version == NULL)
+                               pda_version = (char*) calloc(20, sizeof(char));
+                               if( pda_version == NULL ) {
+                                       _DEBUG_ERROR("CALLOC failed !!!");
+                                       return NULL;
+                               }
+
+                       memcpy(pda_version, "P." , strlen("P.") );
+                       fread(pda_version+strlen("P."), sizeof(char) , strlen(PDA_VERSION) , file_des );
+                       _DEBUG_INFO("fread pda_version - %s\n" , pda_version);
+                       break;
+               }
+       }
+
+    if( file_des != NULL )
+               fclose(file_des);
+
+}*/
+
+char *slp_device_info_get_pda_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+/*
+       char *pda_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if( pda_version == NULL ) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       FILE *file_des;
+       file_des = fopen(PDA_BIN_VERSION, "rb");
+       int i = 0;
+
+       if (file_des == NULL) {
+               _DEBUG_INFO("fopen fail - info.ini \n");
+               snprintf(pda_version, _D_SIZE_128_ / 2, "%s", PDA_VERSION);
+               return 0;
+       }
+
+       while (!feof(file_des)) {
+               char info_temp[20] = { 0, };
+               int result = 1;
+               fseek(file_des, i, SEEK_SET);
+               i++;
+
+               fread(info_temp, sizeof(char), strlen(_D_PDA_BUILD_INFO_BUILD_), file_des);     // 2011/10/05 SCM request  _D_PDA_BUILD_INFO_MAJOR_ -> _D_PDA_BUILD_INFO_BUILD_
+               result = memcmp(info_temp, _D_PDA_BUILD_INFO_BUILD_, strlen(_D_PDA_BUILD_INFO_BUILD_));
+               if (!result) {
+                       char pda_version_check[64] = { 0 };
+                       int read_pos = 0;
+                       //memcpy(pda_version_check, "P." , strlen("P.") );
+                       //   read_pos = strlen(pda_version_check);
+                       while (!feof(file_des)) {
+                               fread(pda_version_check + read_pos, sizeof(char), 1, file_des);
+                               if (pda_version_check[read_pos] == '_')
+                                       pda_version_check[read_pos] = '-';
+                               else if (pda_version_check[read_pos] == '\n')
+                                       break;
+                               else if (pda_version_check[read_pos] == ';') {
+                                       //pda_version_check[read_pos] = NULL;
+                                       pda_version_check[read_pos] = 0;
+                                       break;
+                               }
+                               read_pos++;
+                       }
+
+                       snprintf(pda_version, _D_SIZE_128_ / 2, "%s", pda_version_check);
+                       _DEBUG_INFO("fread pda_version - [%s]\n", pda_version);
+                       break;
+               }
+       }
+
+       if (file_des != NULL)
+               fclose(file_des);
+
+       return pda_version;
+*/
+       char *pda_version = NULL;
+       int sys_result = SYSTEM_INFO_ERROR_NONE;
+       sys_result = system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &pda_version);  /* GT-I8800_c210_2012_09_10_1 */
+       if (sys_result == SYSTEM_INFO_ERROR_NONE) {
+               if (pda_version != NULL) {
+                       _DEBUG_INFO("system_info_get_value_string [%s]\n", pda_version);
+                       //free(pda_version);
+               } else {
+                       pda_version = strdup("GT-I8800_c210_2012_09_10_1");
+               }
+       } else {
+               _DEBUG_INFO("system_info_get_value_string error [%d]\n", sys_result);
+               pda_version = strdup("GT-I8800_c210_2012_09_10_2");
+       }
+
+       _DEBUG_INFO("pda_version [%s]\n", pda_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return pda_version;
+}
+
+char *slp_device_info_get_csc_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+/*
+       char *csc_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if( csc_version == NULL ) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+
+       FILE *file_des;
+       file_des = fopen(CSC_DB_VERSION, "rb");
+       int i = 0;
+       if (file_des == NULL) {
+               _DEBUG_INFO("fopen fail - info.ini \n");
+               snprintf(csc_version, _D_SIZE_128_ / 2, "%s", "C.");
+               return 0;
+       }
+       while (!feof(file_des)) {
+               char info_temp[20] = { 0, };
+               int result = 1;
+               fseek(file_des, i, SEEK_SET);
+               i++;
+
+               fread(info_temp, sizeof(char), strlen(_D_PDA_BUILD_INFO_BUILD_), file_des);     // 2011/10/05 SCM request  _D_PDA_BUILD_INFO_MAJOR_ -> _D_PDA_BUILD_INFO_BUILD_
+               result = memcmp(info_temp, _D_PDA_BUILD_INFO_BUILD_, strlen(_D_PDA_BUILD_INFO_BUILD_));
+               if (!result) {
+                       char csc_version_check[64] = { 0 };
+                       int read_pos = 0;
+                       // memcpy(csc_version_check, "C." , strlen("C.") );
+                       //   read_pos = strlen(csc_version_check);
+                       while (!feof(file_des)) {
+                               fread(csc_version_check + read_pos, sizeof(char), 1, file_des);
+                               if (csc_version_check[read_pos] == '_')
+                                       csc_version_check[read_pos] = '-';
+                               else if (csc_version_check[read_pos] == '\n')
+                                       break;
+                               else if (csc_version_check[read_pos] == ';') {
+                                       //csc_version_check[read_pos] = NULL;
+                                       csc_version_check[read_pos] = 0;
+                                       break;
+                               }
+                               read_pos++;
+                       }
+
+                       snprintf(csc_version, _D_SIZE_128_ / 2, "%s", csc_version_check);
+                       _DEBUG_INFO("fread csc_version - [%s]\n", csc_version);
+                       break;
+               }
+       }
+
+       if (file_des != NULL)
+               fclose(file_des);
+
+       return csc_version;
+*/
+       char *csc_version = NULL;
+       TapiHandle *handle = tel_init(NULL);
+       if (!handle)
+               _DEBUG_INFO("tapi handle is null\n");
+
+       TelMiscVersionInformation *info = tel_get_misc_me_version_sync(handle);
+       if (!info) {
+               _DEBUG_INFO("tet_get_misc_me_version_sync -> return Fail\n");
+               csc_version = strdup("XXX");
+       } else {
+               _DEBUG_INFO("szSwVersion [%s], szHwVersion [%s], szRfCalDate [%s], szProductCode [%s]\n", info->szSwVersion, info->szHwVersion, info->szRfCalDate, info->szProductCode);
+               csc_version = strdup((char *)(info->szProductCode));
+               free(info);
+       }
+
+       if (!handle)
+               tel_deinit(handle);
+
+       _DEBUG_INFO("Modem version = %s\n", csc_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return csc_version;
+}
+
+char *slp_device_info_get_firmware_version()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int index = 0;
+       char *firmware_version = (char *)calloc(_D_SIZE_64_, sizeof(char));
+       if (firmware_version == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       char *firmware_ver = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (firmware_ver == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               free(firmware_version);
+               return 0;
+       }
+
+       char *modem_version = slp_device_info_get_modem_version();
+       _DEBUG_INFO("firmware_ver modem - [%s]\n", modem_version);
+       if (modem_version != NULL) {
+               /*if( strncmp(modem_version,"I9500", sizeof(char)*strlen("I9500") ) == 0 ) */
+               snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", modem_version + sizeof(char) * (strlen("I8800")));
+               /*else
+                  snprintf(firmware_ver + index, _D_SIZE_128_/3 , "%s-", modem_version); */
+       } else {
+               snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", "XXKI1");
+       }
+
+       if (firmware_ver != NULL) {
+               index = strlen(firmware_ver);
+       } else {
+               _DEBUG_ERROR("firmware_ver is NULL !!");
+               /* todo : exception handling */
+               free(firmware_version);
+               return 0;
+       }
+       _DEBUG_INFO("index = %d\n", index);
+       _DEBUG_INFO("firmware Ver1 = %s\n", firmware_ver);
+
+       char *pda_version = slp_device_info_get_pda_version();  // GT-I8800_c210_2012_09_10_2
+       _DEBUG_INFO("firmware_ver modem-pda-[%s]\n", pda_version);
+       if (pda_version != NULL) {
+               /*
+                  if (strncmp(pda_version, "I9500-c210-2012", (sizeof(char)) * (strlen("I9500-c210-2012"))) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version + sizeof(char) * (strlen("I9500-c210-2012")));
+                  else if (strncmp(pda_version, "I9500-2012", sizeof(char) * (strlen("I9500-2012"))) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version + sizeof(char) * (strlen("I9500-2012")));
+                  else
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version);
+                */
+               snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s-", pda_version);
+       }
+
+       if (firmware_ver != NULL) {
+               index = strlen(firmware_ver);
+               _DEBUG_INFO("index = %d\n", index);
+               _DEBUG_INFO("firmware Ver2 = %s\n", firmware_ver);
+       } else {
+               _DEBUG_ERROR("firmware_ver is NULL !!");
+               /* todo : exception handling */
+               return 0;
+       }
+
+       char *csc_version = slp_device_info_get_csc_version();
+       _DEBUG_INFO("firmware_ver modem-pda-csc - [%s]\n", csc_version);
+       if (csc_version != NULL) {
+               /*
+                  if (strncmp(csc_version, "I9500OXA-c210-2012", sizeof(char) * (strlen("I9500OXA-c210-2012"))) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500OXA-c210-2012")));
+                  else if (strncmp(csc_version, "I9500OXA-2012", sizeof(char) * strlen("I9500OXA-2012")) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500OXA-c210-2012")));
+                  else if (strncmp(csc_version, "I9500-c210-2012", sizeof(char) * strlen("I9500-c210-2012")) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500-c210-2012")));
+                  else if (strncmp(csc_version, "I9500-2012", sizeof(char) * (strlen("I9500-2012"))) == 0)
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version + sizeof(char) * (strlen("I9500-2012")));
+                  else
+                  snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version);
+                */
+               snprintf(firmware_ver + index, _D_SIZE_128_ / 3, "%s", csc_version);
+       }
+
+       if (modem_version != NULL) {
+               free(modem_version);
+               modem_version = NULL;
+       }
+       if (pda_version != NULL) {
+               free(pda_version);
+               pda_version = NULL;
+       }
+       if (csc_version != NULL) {
+               free(csc_version);
+               csc_version = NULL;
+       }
+
+       _DEBUG_INFO("firmware_ver [%s]\n", firmware_ver);
+       snprintf(firmware_version, _D_MSC_FIRMWARE_MAXSTRING_, "%s", firmware_ver);
+       if (firmware_ver != NULL)
+               free(firmware_ver);
+       _DEBUG_INFO("firmware_version [%s]\n", firmware_version);
+
+       _EXTERN_FUNC_EXIT;
+
+       return firmware_version;
+}
+
+/* ====================================
+ * device etc information
+ * =====================================*/
+char *slp_device_info_get_device_type()
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *dev_type = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (dev_type == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       snprintf(dev_type, _D_SIZE_128_ - 1, "%s", DEV_TYPE);
+       _DEBUG_INFO("Device Type = %s\n", DEV_TYPE);
+
+       _EXTERN_FUNC_EXIT;
+
+       return dev_type;
+}
+
+char *slp_device_info_get_device_id()
+{
+       _EXTERN_FUNC_ENTER;
+
+//      char *DeviceID = (char *)calloc(_D_SIZE_128_, sizeof(char));
+//      if( DeviceID == NULL ) {
+//              _DEBUG_ERROR("CALLOC failed !!!");
+//              return 0;
+//      }
+//      if (vconf_get_str(VCONFKEY_TELEPHONY_IMEI) != NULL)
+//              snprintf(DeviceID, _D_SIZE_128_ - 1, "IMEI:%s", vconf_get_str(VCONFKEY_TELEPHONY_IMEI));
+//      else
+//              snprintf(DeviceID, _D_SIZE_128_ - 1, "IMEI:%s", "355310046608752");
+//
+//      /*snprintf(DeviceID, _D_SIZE_128_-1, "%s", vconf_get_str(VCONFKEY_TELEPHONY_IMEI)); */
+//      return DeviceID;
+
+       TapiHandle *handle;
+       handle = tel_init(NULL);
+       char *imei = 0;
+       char imei_value[30] = { 0, };
+       if (handle == NULL) {
+               _DEBUG_INFO("handle is NULL !!");
+       } else {
+               _DEBUG_INFO("handle : %d", handle);
+               imei = tel_get_misc_me_imei_sync(handle);
+               _DEBUG_INFO("imei : %s", imei);
+       }
+
+       tel_deinit(handle);
+
+       if (imei != NULL) {
+               snprintf(imei_value, sizeof(imei_value), "%s:%s", "IMEI", imei);
+               _EXTERN_FUNC_EXIT;
+               return strdup(imei_value);
+       } else {
+               return 0;
+       }
+
+}
+
+char *slp_device_info_get_model_info()
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *model_info = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (model_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       snprintf(model_info, _D_SIZE_128_ - 1, "%s", MODEL);
+       _DEBUG_INFO("Model info = %s\n", model_info);
+
+       _EXTERN_FUNC_EXIT;
+
+       return model_info;      /* prevent */
+}
+
+char *slp_device_info_get_manufacturer_info()
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *ManufacturerInfo = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (ManufacturerInfo == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       snprintf(ManufacturerInfo, _D_SIZE_128_ - 1, "%s", MANUFACTURE);        /* prevent */
+
+       _DEBUG_INFO("Manufacturer = %s\n", MANUFACTURE);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ManufacturerInfo;
+}
+
+char *slp_device_info_get_oem_info()
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *oem_info = (char *)calloc(_D_SIZE_128_, sizeof(char));
+       if (oem_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+       snprintf(oem_info, _D_SIZE_128_ - 1, "%s", OEM);
+
+       _DEBUG_INFO("OEM = %s\n", OEM);
+
+       _EXTERN_FUNC_EXIT;
+
+       return oem_info;
+}
+
+char *slp_device_info_get_battery_level()
+{
+       _EXTERN_FUNC_ENTER;
+
+       FILE *file = 0;
+       unsigned char read_buf[10] = { 0, };
+       char *battery_level = 0;
+       int read_size = 0;
+
+       _DEBUG_INFO("path:%s", BATTERY_LEVEL);
+       file = fopen(BATTERY_LEVEL, "rb");
+       if (file != NULL) {
+               read_size = fread(read_buf, 10, sizeof(unsigned char), file);
+               battery_level = strdup((char *)read_buf);
+
+               _DEBUG_INFO("read size:%d, read_buf:%s, battery:%s", read_size, read_buf, battery_level);
+
+       } else {
+               _DEBUG_INFO("ERROR: cannot read %s", BATTERY_LEVEL);
+       }
+
+       if (file != NULL)
+               fclose(file);
+
+       _EXTERN_FUNC_EXIT;
+
+       return battery_level;
+}
+
+/*static char *__slp_device_info_get_modem_version_for_fw()
+{
+      char *ModemVersion = (char*)calloc(_D_SIZE_128_, sizeof(char));
+         if( ModemVersion == NULL ) {
+                 _DEBUG_ERROR("CALLOC failed !!!");
+                 return NULL;
+         }
+
+      char * get_str = slp_device_info_get_modem_version();
+      _DEBUG_INFO("vconf telephony swversion  = %s\n", get_str);
+      if( get_str != NULL )
+      {
+                       if( strncmp(get_str,"I9200", sizeof(char)*strlen("I9200") ) == 0 )
+                               snprintf(ModemVersion, _D_SIZE_128_/2 , "%s-", get_str + sizeof(char)*strlen("I9200") );
+                       else
+                               snprintf(ModemVersion, _D_SIZE_128_/2 , "%s-", get_str);
+       } else {
+                       snprintf(ModemVersion, _D_SIZE_128_/2 , "%s-", "XXKH2");
+       }
+
+      _DEBUG_INFO("Modem version for FirmV = %s\n", ModemVersion);
+      return ModemVersion;
+}*/
+
+/*char *__slp_device_info_get_CSC_version_for_fw()
+{
+      char *csc_version = (char*)calloc(_D_SIZE_128_, sizeof(char));
+         if( csc_version == NULL ) {
+                 _DEBUG_ERROR("CALLOC failed !!!");
+                 return NULL;
+         }
+
+      FILE *file_des;
+   file_des =fopen(CSC_DB_VERSION,"rb");
+   int i = 0 ;
+      if(file_des==NULL)
+      {
+               _DEBUG_INFO("fopen fail - info.ini \n");
+               snprintf(csc_version,_D_SIZE_128_/2, "%s" , "C." );
+               return 0;
+      }
+    while( ! feof(file_des) )
+    {
+               char info_temp[20] = {0,} ;
+               int result = 1 ;
+               fseek(file_des,i,SEEK_SET);
+               i++ ;
+
+               fread(info_temp, sizeof(char) , strlen(_D_PDA_BUILD_INFO_BUILD_) , file_des ); // 2011/10/05 SCM request  _D_PDA_BUILD_INFO_MAJOR_ -> _D_PDA_BUILD_INFO_BUILD_
+               result = memcmp( info_temp , _D_PDA_BUILD_INFO_BUILD_ , strlen(_D_PDA_BUILD_INFO_BUILD_) ) ;
+               if( !result )
+               {
+                       char csc_version_check[64] = {0};
+                       int read_pos = 0 ;
+                       //memcpy(csc_version_check, "C." , strlen("C.") );
+                       //read_pos = strlen(csc_version_check);
+                       while( !feof(file_des) )
+                       {
+                               fread(csc_version_check+read_pos,sizeof(char), 1, file_des);
+                               if( csc_version_check[read_pos] == '_' )
+                                       csc_version_check[read_pos] = '-' ;
+                               else if( csc_version_check[read_pos] == '\n' )
+                                       break;
+                               else if( csc_version_check[read_pos] == ';' )
+                               {
+                                       csc_version_check[read_pos] = NULL;
+                                       break;
+                               }
+
+                               read_pos++;
+                       }
+
+                       if( strncmp(csc_version_check,"I9200OXA-c210-2011", sizeof(char)*strlen("I9200OXA-c210-2011") ) == 0 )
+                               snprintf(csc_version,_D_SIZE_128_/2,"%s", csc_version_check + sizeof(char)*strlen("I9200OXA-c210-2011"));
+                       else if( strncmp(csc_version_check,"I9200OXA-2011", sizeof(char)*strlen("I9200OXA-2011") ) == 0 )
+                               snprintf(csc_version,_D_SIZE_128_/2,"%s", csc_version_check + sizeof(char)*strlen("I9200OXA-c210-2011"));
+
+                       else if( strncmp(csc_version_check,"I9200-c210-2011", sizeof(char)*strlen("I9200-c210-2011") ) == 0 )
+                               snprintf(csc_version,_D_SIZE_128_/2,"%s", csc_version_check + sizeof(char)*strlen("I9200-c210-2011"));
+                       else if( strncmp(csc_version_check,"I9200-2011", sizeof(char)*strlen("I9200-2011") ) == 0 )
+                               snprintf(csc_version,_D_SIZE_128_/2,"%s", csc_version_check + sizeof(char)*strlen("I9200-2011"));
+                       else
+                               snprintf(csc_version,_D_SIZE_128_/2,"%s", csc_version_check );
+
+                               _DEBUG_INFO("fread csc_version - [%s]\n" , csc_version);
+                               break;
+                       }
+               }
+
+               if( file_des != NULL )
+                       fclose(file_des);
+
+               return csc_version;
+}*/
+
+/*
+char *__slp_device_info_get_PDA_version_for_fw()
+{
+      char *pda_version = (char*)calloc(_D_SIZE_128_, sizeof(char));
+         if( pda_version == NULL ) {
+                 _DEBUG_ERROR("CALLOC failed !!!");
+                 return NULL;
+         }
+      FILE *file_des;
+      file_des =fopen(PDA_BIN_VERSION,"rb");
+      int i = 0 ;
+
+      if(file_des==NULL)
+      {
+                       _DEBUG_INFO("fopen fail - info.ini \n");
+                       snprintf(pda_version,_D_SIZE_128_/2, "%s" , "P.I9200XXJI-" );
+                       return 0;
+      }
+
+    while( ! feof(file_des) )
+    {
+               char info_temp[20] = {0,} ;
+               int result = 1 ;
+               fseek(file_des,i,SEEK_SET);
+               i++ ;
+
+               fread(info_temp, sizeof(char) , strlen(_D_PDA_BUILD_INFO_BUILD_) , file_des ); // 2011/10/05 SCM request  _D_PDA_BUILD_INFO_MAJOR_ -> _D_PDA_BUILD_INFO_BUILD_
+               result = memcmp( info_temp , _D_PDA_BUILD_INFO_BUILD_ , strlen(_D_PDA_BUILD_INFO_BUILD_) ) ;
+               If( !result )
+               {
+                       char pda_version_check[64] = {0};
+                       int read_pos = 0 ;
+                       //memcpy(pda_version_check, "P." , strlen("P.") );
+                       //read_pos = strlen(pda_version_check);
+                       while( !feof(file_des) )
+                       {
+                               fread(pda_version_check+read_pos,sizeof(char), 1, file_des);
+                               if( pda_version_check[read_pos] == '_' )
+                                       pda_version_check[read_pos] = '-' ;
+                               else if( pda_version_check[read_pos] == '\n' )
+                                       break;
+                               else if( pda_version_check[read_pos] == ';' )
+                               {
+                                       pda_version_check[read_pos] = NULL;
+                                       break;
+                               }
+
+                               read_pos++;
+                       }
+                       pda_version_check[read_pos] = '-';
+                       _DEBUG_INFO( "pda_version_check = %s\n", pda_version_check);
+
+                       if( strncmp(pda_version_check,"I9200-c210-2011", sizeof(char)*strlen("I9200-c210-2011") ) == 0 )
+                               snprintf(pda_version,_D_SIZE_128_/2,"%s", pda_version_check + sizeof(char)*strlen("I9200-c210-2011"));
+                       else if( strncmp(pda_version_check,"I9200-2011", sizeof(char)*strlen("I9200-2011") ) == 0 )
+                               snprintf(pda_version,_D_SIZE_128_/2,"%s", pda_version_check + sizeof(char)*strlen("I9200-2011"));
+                       else
+                               snprintf(pda_version,_D_SIZE_128_/2,"%s", pda_version_check );
+
+                       _DEBUG_INFO("fread pda_version - [%s]\n" , pda_version);
+                       break;
+               }
+       }
+
+       if( file_des != NULL )
+               fclose(file_des);
+
+       return pda_version;
+}
+*/
diff --git a/src/fw-plugins/common-public/slp-sysnoti-alarm/CMakeLists.txt b/src/fw-plugins/common-public/slp-sysnoti-alarm/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..ee64db8
--- /dev/null
@@ -0,0 +1,45 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "pm-slp-sysnoti-alarm")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       glib-2.0
+                                       vconf
+                                       alarm-service
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${pm-slp-sysnoti-alarm_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${pm-slp-sysnoti-alarm_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/plugin_slp_sysnoti_alarm.h DESTINATION include/sync-agent/plugin/)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
+
diff --git a/src/fw-plugins/common-public/slp-sysnoti-alarm/include/plugin_slp_sysnoti_alarm.h b/src/fw-plugins/common-public/slp-sysnoti-alarm/include/plugin_slp_sysnoti_alarm.h
new file mode 100755 (executable)
index 0000000..b2414cc
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_SLP_SYSNOTI_ALARM_H_
+#define PLUGIN_SLP_SYSNOTI_ALARM_H_
+
+#include <time.h>
+
+#define DAY_CNT        7
+
+/**
+ * @brief Enumerations for the day type
+ */
+typedef enum {
+       DAY_NO_TYPE = 0x00,
+       DAY_SUN = 0x01,
+       DAY_MON = 0x02,
+       DAY_TUE = 0x04,
+       DAY_WED = 0x08,
+       DAY_THU = 0x10,
+       DAY_FRI = 0x20,
+       DAY_SAT = 0x40
+} pmci_day_type_e;
+
+/**
+ * @brief Enumerations for the repeat type
+ */
+typedef enum {
+       REPEAT_NO_TYPE = 0,
+       ONCE = 1,
+       REPEAT,
+       REPEAT_WEEKLY,
+       REPEAT_MONTHLY,
+       REPEAT_ANNUALLY,
+} pmci_repeat_type_e;
+
+/**
+ * sync-agent
+ * @see PMCI_Add_Item_To_Specific_Type(), SPECIFIC_TYPE_CALLBACK
+ */
+typedef struct {
+       /* start alarm time : time to start alarm at first.
+        *  format: 2011-01-02T15:13:02Z
+        */
+       char *start_alarm_time;
+
+       /* repeat type */
+       pmci_repeat_type_e repeat_type;
+
+       /* repeat value
+        * 1) repeat_type: ONCE => repeat_value: do not mean
+        * 1) repeat_type: REPEAT => repeat_value: interval time (second)
+        * 2) repeat_type: etc  => repeat_value: pmci_day_type_e
+        */
+       int repeat_value;
+
+       int is_disposable;
+} pmci_alarm_s;
+
+#endif                         /* PLUGIN_SLP_SYSNOTI_ALARM_H_ */
diff --git a/src/fw-plugins/common-public/slp-sysnoti-alarm/src/plugin_interface.c b/src/fw-plugins/common-public/slp-sysnoti-alarm/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..5467682
--- /dev/null
@@ -0,0 +1,535 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <vconf-keys.h>
+#include <vconf.h>
+
+#include <alarm.h>
+
+#include "plugin/platform_monitor_interface.h"
+
+//#include "slp_callback.h"
+
+/* for alarm service */
+//#include "slp_alarm.h"
+#include "plugin_slp_sysnoti_alarm.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_PM_SYSNOTI_ALARM"
+#endif
+
+static int _convert_service_time(char *temp_time, alarm_date_t * out_time);
+static int _convert_fw_time(alarm_date_t * temp_time, char **out_time);
+
+EXPORT_API void sync_agent_plugin_init_service_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(data == NULL, "data is NULL. FAIL !!!");
+
+       sync_agent_pm_register_data_s *reg_data = (sync_agent_pm_register_data_s *) data;
+       if (reg_data == NULL) {
+               _DEBUG_ERROR("data is NULL !!");
+               goto free_part;
+       }
+
+       _DEBUG_INFO("pkg_name : %s", reg_data->pkg_name);
+
+       int ret = alarmmgr_init(reg_data->pkg_name);
+       if (ret != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_init() failed ( err_code : %d ) !!", ret);
+       } else {
+               _DEBUG_INFO("alarmmgr_init() success !!");
+       }
+
+ free_part:
+       if (reg_data != NULL) {
+               if (reg_data->pkg_name != NULL)
+                       free(reg_data->pkg_name);
+
+               free(reg_data);
+
+               _DEBUG_INFO("free sync_agent_pm_register_data_s !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_unregister_service_noti(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       /* not support destroy alarm api */
+       _DEBUG_INFO("not support destroy alarm api !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_add_service_data(void *add_data, int *added_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(add_data == NULL, SYNC_AGENT_PM_FAIL, "add_data is NULL. FAIL !!!");
+
+       int err = 0;
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       pmci_alarm_s *temp_add_data = (pmci_alarm_s *) add_data;
+
+       /* allocate service alarm struct */
+       alarm_entry_t *service_add_data = NULL;
+       service_add_data = alarmmgr_create_alarm();
+       if (service_add_data == NULL)
+               goto return_part;
+
+       /* convert fw struct to service struct  */
+
+       /* setting start alarm time */
+       if (temp_add_data->start_alarm_time != NULL) {
+               alarm_date_t expire_time;
+               memset(&expire_time, 0x00, sizeof(alarm_date_t));
+               err = _convert_service_time(temp_add_data->start_alarm_time, &expire_time);
+               if (err != 1)
+                       _DEBUG_ERROR("__convert_alarm_time() failed (err_code : %d ) !!", err);
+
+               err = alarmmgr_set_time(service_add_data, expire_time);
+               if (err != ALARMMGR_RESULT_SUCCESS)
+                       _DEBUG_ERROR("alarmmgr_set_time() failed ( err_code : %d ) !!", err);
+       }
+
+       /* setting repeat mode and repeat value */
+       alarm_repeat_mode_t repeat_mode = 0;
+       if (temp_add_data->repeat_type != REPEAT_NO_TYPE) {
+               switch (temp_add_data->repeat_type) {
+               case ONCE:
+                       repeat_mode = ALARM_REPEAT_MODE_ONCE;
+                       break;
+               case REPEAT:
+                       repeat_mode = ALARM_REPEAT_MODE_REPEAT;
+                       break;
+               case REPEAT_WEEKLY:
+                       repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
+                       break;
+               case REPEAT_MONTHLY:
+                       repeat_mode = ALARM_REPEAT_MODE_MONTHLY;
+                       break;
+               case REPEAT_ANNUALLY:
+                       repeat_mode = ALARM_REPEAT_MODE_ANNUALLY;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       alarm_day_of_week_t repeat_value = 0;
+       if (temp_add_data->repeat_value != DAY_NO_TYPE) {
+               switch (temp_add_data->repeat_type) {
+               case ONCE:
+               case REPEAT:
+                       {
+                               repeat_value = temp_add_data->repeat_value;
+                       }
+                       break;
+               case REPEAT_ANNUALLY:
+               case REPEAT_MONTHLY:
+               case REPEAT_WEEKLY:
+                       {
+                               int tmp;
+                               int num = 1;
+
+                               int i;
+                               for (i = 1; i <= DAY_CNT; i++) {
+                                       tmp = (temp_add_data->repeat_value >> i);
+                                       switch (tmp) {
+                                       case DAY_SUN:
+                                               repeat_value |= ALARM_WDAY_SUNDAY;
+                                               break;
+                                       case DAY_MON:
+                                               repeat_value |= ALARM_WDAY_MONDAY;
+                                               break;
+                                       case DAY_TUE:
+                                               repeat_value |= ALARM_WDAY_TUESDAY;
+                                               break;
+                                       case DAY_WED:
+                                               repeat_value |= ALARM_WDAY_WEDNESDAY;
+                                               break;
+                                       case DAY_THU:
+                                               repeat_value |= ALARM_WDAY_THURSDAY;
+                                               break;
+                                       case DAY_FRI:
+                                               repeat_value |= ALARM_WDAY_FRIDAY;
+                                               break;
+                                       case DAY_SAT:
+                                               repeat_value |= ALARM_WDAY_SATURDAY;
+                                               break;
+                                       default:
+                                               break;
+                                       }
+
+                                       num *= 2;
+                               }
+                       }
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       err = alarmmgr_set_repeat_mode(service_add_data, repeat_mode, repeat_value);
+       if (err != ALARMMGR_RESULT_SUCCESS)
+               _DEBUG_ERROR("alarmmgr_set_repeat_mode() failed ( err_code : %d ) !!", err);
+
+       /* set alarm type */
+       int alarm_type = 0;
+       if (temp_add_data->is_disposable != 0) {
+               alarm_type = ALARM_TYPE_VOLATILE;
+       } else {
+               alarm_type = ALARM_TYPE_DEFAULT;
+       }
+
+       err = alarmmgr_set_type(service_add_data, alarm_type);
+       if (err != ALARMMGR_RESULT_SUCCESS)
+               _DEBUG_ERROR("alarmmgr_set_type() failed ( err_code : %d ) !!", err);
+
+       /* insert add alarm item */
+       int alarm_id = 0;
+       int result = alarmmgr_add_alarm_with_localtime(service_add_data, 0, &alarm_id);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_add_alarm() failed ( err_code : %d ) !!", result);
+               err = 0;
+       } else {
+               _DEBUG_INFO("alarmmgr_add_alarm() success ( alarm_id : %d ) !!", alarm_id);
+               *added_data_id = alarm_id;
+               err = 1;
+       }
+
+       if (service_add_data != NULL)
+               alarmmgr_free_alarm(service_add_data);
+
+ return_part:
+       if (err != 1) {
+               ret = SYNC_AGENT_PM_FAIL;
+       } else {
+               ret = SYNC_AGENT_PM_SUCCESS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       int result = alarmmgr_remove_alarm(remove_data_id);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_remove_alarm() failed ( err_code : %d ) !!", result);
+               ret = SYNC_AGENT_PM_FAIL;
+       } else {
+               _DEBUG_INFO("alarmmgr_remove_alarm() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       alarm_entry_t *alarm = alarmmgr_create_alarm();
+       int result = alarmmgr_get_info(get_data_id, alarm);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_get_info() failed ( err_code : %d ) !!", result);
+               result = alarmmgr_free_alarm(alarm);
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       /* converting */
+       pmci_alarm_s *agent_alarm_info = (pmci_alarm_s *) calloc(1, sizeof(pmci_alarm_s));
+       if (agent_alarm_info == NULL) {
+               _DEBUG_ERROR("calloc failed !!!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       int alarm_type = 0;
+       result = alarmmgr_get_type(alarm, &alarm_type);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_get_type() failed ( err_code : %d ) !!", result);
+               return SYNC_AGENT_PM_FAIL;
+       }
+       _DEBUG_INFO("alarm_type : %d", alarm_type);
+
+       if (alarm_type == ALARM_TYPE_DEFAULT) {
+               agent_alarm_info->is_disposable = false;
+       } else {
+               agent_alarm_info->is_disposable = true;
+       }
+
+       alarm_repeat_mode_t repeat_mode;
+       alarm_day_of_week_t repeat_value;
+       result = alarmmgr_get_repeat_mode(alarm, &repeat_mode, (int *)(&repeat_value));
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_get_repeat_mode() failed ( err_code : %d ) !!", result);
+               return SYNC_AGENT_PM_FAIL;
+       }
+       _DEBUG_INFO("repeat_mode : %d, repeat_value : %d", repeat_mode, repeat_value);
+
+       switch (repeat_mode) {
+       case ALARM_REPEAT_MODE_ONCE:
+               {
+                       _DEBUG_INFO("ALARM_REPEAT_ONCE");
+                       agent_alarm_info->repeat_type = ONCE;
+                       agent_alarm_info->repeat_value = repeat_value;
+               }
+               break;
+       case ALARM_REPEAT_MODE_REPEAT:
+               {
+                       _DEBUG_INFO("ALARM_REPEAT_MODE_REPEAT");
+                       agent_alarm_info->repeat_type = REPEAT;
+                       agent_alarm_info->repeat_value = repeat_value;
+               }
+               break;
+       case ALARM_REPEAT_MODE_WEEKLY:
+       case ALARM_REPEAT_MODE_MONTHLY:
+       case ALARM_REPEAT_MODE_ANNUALLY:
+               {
+                       _DEBUG_INFO("ALARM_REPEAT_MODE_WEEKLY, MONTHLY, ANNUALLY");
+                       int tmp;
+                       int num = 1;
+
+                       int i;
+                       for (i = 1; i <= DAY_CNT; i++) {
+                               tmp = (repeat_value >> i);
+                               switch (tmp) {
+                               case DAY_SUN:
+                                       agent_alarm_info->repeat_value |= DAY_SUN;
+                                       break;
+                               case DAY_MON:
+                                       agent_alarm_info->repeat_value |= DAY_MON;
+                                       break;
+                               case DAY_TUE:
+                                       agent_alarm_info->repeat_value |= DAY_TUE;
+                                       break;
+                               case DAY_WED:
+                                       agent_alarm_info->repeat_value |= DAY_WED;
+                                       break;
+                               case DAY_THU:
+                                       agent_alarm_info->repeat_value |= DAY_THU;
+                                       break;
+                               case DAY_FRI:
+                                       agent_alarm_info->repeat_value |= DAY_FRI;
+                                       break;
+                               case DAY_SAT:
+                                       agent_alarm_info->repeat_value |= DAY_SAT;
+                                       break;
+                               default:
+                                       break;
+                               }
+                               num *= 2;
+                       }
+               }
+               break;
+       default:
+               break;
+       }
+
+       alarm_date_t alarm_time;
+       result = alarmmgr_get_time(alarm, &alarm_time);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               _DEBUG_ERROR("alarmmgr_get_info() failed ( err_code : %d ) !!", result);
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       char *alarm_time_s = NULL;
+       _convert_fw_time(&alarm_time, &alarm_time_s);
+       _DEBUG_INFO("alarm_time_s : %s", alarm_time_s);
+       agent_alarm_info->start_alarm_time = alarm_time_s;
+
+       *service_data = agent_alarm_info;
+
+       if (alarm != NULL)
+               alarmmgr_free_alarm(alarm);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API void sync_agent_plugin_set_user_callback(int callback_counts, va_list list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int result = ALARMMGR_RESULT_SUCCESS;
+       int i = 0;
+
+       for (; i < callback_counts; i++) {
+               result = alarmmgr_set_cb(va_arg(list, sync_agent_user_callback_cb_plugin), 0);
+               if (result != ALARMMGR_RESULT_SUCCESS) {
+                       _DEBUG_ERROR("alarmmgr_set_cb() failed ( err_code : %d ) !!", result);
+               } else {
+                       _DEBUG_INFO("alarmmgr_set_cb() success !!");
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static int _convert_service_time(char *temp_time, alarm_date_t * out_time)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(temp_time == NULL, 0, "temp_time is NULL. FAIL !!!");
+
+       _DEBUG_TRACE("temp_time = %s", temp_time);
+
+       char *delimiter = "-";
+
+       char *day_ptr = strstr(temp_time, "T");
+       if(day_ptr == NULL) {
+               _DEBUG_TRACE("day_ptr is NULL!!");
+               return 0;
+       }
+       _DEBUG_TRACE("Day_ptr = %s", day_ptr);
+
+       int length1 = strlen(day_ptr);
+       _DEBUG_TRACE("length1 = %d", length1);
+
+       char *day = (char *)calloc(length1 + 1, sizeof(char));
+       if (day == NULL) {
+               _DEBUG_ERROR("calloc fail !!");
+               return 0;
+       }
+       strncpy(day, temp_time, length1);
+       _DEBUG_TRACE("Day = %s", day);
+
+       /* get year */
+       char *ptr = strtok(day, delimiter);
+       if (ptr == NULL) {
+               free(day);
+               return 0;
+       }
+       _DEBUG_TRACE("Year = %s\n", ptr);
+       (out_time)->year = atoi(ptr);
+
+       /* get month */
+       ptr = strtok(0, delimiter);
+       if (ptr == NULL) {
+               free(day);
+               return 0;
+       }
+       _DEBUG_TRACE("Month = %s\n", ptr);
+       (out_time)->month = atoi(ptr);
+
+       /* get day */
+       ptr = strtok(0, delimiter);
+       if (ptr == NULL) {
+               free(day);
+               return 0;
+       }
+       _DEBUG_TRACE("Day = %s\n", ptr);
+       (out_time)->day = atoi(ptr);
+
+       if (day != NULL)
+               free(day);
+
+       char *time_ptr = strstr(day_ptr, "Z");
+       _DEBUG_TRACE("time_ptr = %s", time_ptr);
+
+       int length2 = strlen(temp_time) - strlen(day_ptr) - 2;
+       _DEBUG_TRACE("length2 = %d", length2);
+
+       char *time = (char *)calloc(length2, sizeof(char));
+       if (time == NULL) {
+               _DEBUG_ERROR("calloc fail !!");
+               return 0;
+       }
+       strncpy(time, day_ptr + 1, length2);
+       _DEBUG_TRACE("Time = %s", time);
+       delimiter = ":";
+
+       /* get hour */
+       ptr = strtok(time, delimiter);
+       if (ptr == NULL) {
+               free(time);
+               return 0;
+       }
+       _DEBUG_TRACE("hour = %s\n", ptr);
+       (out_time)->hour = atoi(ptr);
+
+       /* get min */
+       ptr = strtok(0, delimiter);
+       if (ptr == NULL) {
+               free(time);
+               return 0;
+       }
+       _DEBUG_TRACE("min = %s\n", ptr);
+       (out_time)->min = atoi(ptr);
+
+       /* get sec */
+       ptr = strtok(0, delimiter);
+       if (ptr == NULL) {
+               free(time);
+               return 0;
+       }
+       _DEBUG_TRACE("sec = %s\n", ptr);
+       (out_time)->sec = atoi(ptr);
+
+       if (time != NULL)
+               free(time);
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+static int _convert_fw_time(alarm_date_t * temp_time, char **out_time)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(temp_time == NULL, 0, "temp_time is NULL. FAIL !!!");
+
+       *out_time = g_strdup_printf("%.2d-%.2d-%.2dT%.2d:%.2d:%.2dZ", temp_time->year, temp_time->month, temp_time->day, temp_time->hour, temp_time->min, temp_time->sec);
+       _DEBUG_TRACE("out_time = %s\n", *out_time);
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
diff --git a/src/fw-plugins/common-public/slp-sysnoti-network-connection/CMakeLists.txt b/src/fw-plugins/common-public/slp-sysnoti-network-connection/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..10a2463
--- /dev/null
@@ -0,0 +1,45 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "pm-slp-sysnoti-network-connection")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       glib-2.0
+                                       vconf
+                                       capi-network-connection
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${pm-slp-sysnoti-network-connection_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${pm-slp-sysnoti-network-connection_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/plugin_slp_sysnoti_network_connection.h DESTINATION include/sync-agent/plugin/)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
+
diff --git a/src/fw-plugins/common-public/slp-sysnoti-network-connection/include/plugin_slp_sysnoti_network_connection.h b/src/fw-plugins/common-public/slp-sysnoti-network-connection/include/plugin_slp_sysnoti_network_connection.h
new file mode 100755 (executable)
index 0000000..37b89d3
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_SLP_SYSNOTI_NETWORK_CONNECTION_H_
+#define PLUGIN_SLP_SYSNOTI_NETWORK_CONNECTION_H_
+
+/**
+ * sync-agent
+ */
+typedef struct {
+//      int protocol_type;
+       int fw_network_status;
+       int fw_connection_type;
+       int fw_connection_state;
+       char *proxy;
+       char *ip;
+} pmci_network_connection_s;
+
+#endif                         /* PLUGIN_SLP_SYSNOTI_NETWORK_CONNECTION_H_ */
diff --git a/src/fw-plugins/common-public/slp-sysnoti-network-connection/src/plugin_interface.c b/src/fw-plugins/common-public/slp-sysnoti-network-connection/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..d3c653c
--- /dev/null
@@ -0,0 +1,1055 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <vconf-keys.h>
+#include <vconf.h>
+
+#include <net_connection.h>
+#include <connection_profile.h>
+
+#include "plugin_slp_sysnoti_network_connection.h"
+#include "network-access/network_status.h"
+#include "plugin/platform_monitor_interface.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_PM_SYSNOTI_NET_CONN"
+#endif
+
+static connection_h connection = NULL;
+static sync_agent_na_network_status_e network_status;
+static sync_agent_na_network_connection_type_e connection_type;
+static sync_agent_na_network_connection_state_e connection_state;
+
+/* internal callback function for framework */
+static int (*registered_network_status_cb) (int data_id, void *user_data);
+static int (*registered_network_cancel_cb) (int data_id, void *user_data);
+
+/* external callback function for user */
+static int (*registered_network_on_cb) (int data_id, void *user_data);
+static int (*registered_network_off_cb) (int data_id, void *user_data);
+static int (*registered_network_change_cb) (int data_id, void *user_data);
+
+static void _type_changed_callback(connection_type_e type, void *user_data);
+static void _ip_changed_callback(const char *ipv4_address, const char *ipv6_address, void *user_data);
+static void _proxy_changed_callback(const char *ipv4_address, const char *ipv6_address, void *user_data);
+
+int __check_connection();
+char *__get_connection_proxy();
+char *_get_connection_ip();
+int _get_net_status();
+int _get_conn_type();
+int _get_conn_state();
+
+static void __log_for_network_status(sync_agent_na_network_status_e status);
+static void __log_for_connection_type(sync_agent_na_network_connection_type_e type);
+static void __log_for_connection_state(sync_agent_na_network_connection_state_e state);
+
+static void _network_status_callback_fn(int protocol_type);
+static void __network_cancel_callback_fn(int protocol_type);
+
+EXPORT_API void sync_agent_plugin_init_service_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retm_if(data == NULL, "data is NULL. FAIL !!!");
+
+       g_type_init();
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+       g_thread_init(NULL);
+#endif
+
+       network_status = SYNC_AGENT_NA_NETWORK_UNKNOWN;
+       connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN;
+       connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+
+       int res = connection_create(&connection);
+       if (res == CONNECTION_ERROR_NONE) {
+               _DEBUG_INFO("connection_create() success !!");
+               _DEBUG_INFO("connection_set_changed_cb() start !!");
+               connection_set_type_changed_cb(connection, _type_changed_callback, NULL);
+               connection_set_ip_address_changed_cb(connection, _ip_changed_callback, NULL);
+               connection_set_proxy_address_changed_cb(connection, _proxy_changed_callback, NULL);
+               _DEBUG_INFO("connection_set_changed_cb() end !!");
+       } else {
+               _DEBUG_ERROR("connection_create() failed !! ( err_code : %d )", res);
+       }
+
+       if (data != NULL) {
+               sync_agent_pm_register_data_s *reg_data = (sync_agent_pm_register_data_s *) data;
+               sync_agent_user_callback_cb_plugin *temp = reg_data->user_data;
+               if (temp != NULL) {
+                       registered_network_status_cb = temp[0];
+                       registered_network_cancel_cb = temp[1];
+
+                       free(temp);
+                       free(reg_data);
+               }
+       }
+
+       _network_status_callback_fn(1);
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_unregister_service_noti(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 0;
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       if (connection != NULL) {
+               res = connection_unset_type_changed_cb(connection);
+               if (res != CONNECTION_ERROR_NONE) {
+                       _DEBUG_ERROR("connection_unset_type_changed_cb() failed !! ( err_code : %d )", res);
+                       return SYNC_AGENT_PM_FAIL;
+               } else {
+                       _DEBUG_INFO("connection_unset_type_changed_cb() success !!");
+               }
+
+               res = connection_unset_ip_address_changed_cb(connection);
+               if (res != CONNECTION_ERROR_NONE) {
+                       _DEBUG_ERROR("connection_unset_ip_address_changed_cb() failed !! ( err_code : %d )", res);
+                       return SYNC_AGENT_PM_FAIL;
+               } else {
+                       _DEBUG_INFO("connection_unset_ip_address_changed_cb() success !!");
+               }
+
+               res = connection_unset_proxy_address_changed_cb(connection);
+               if (res != CONNECTION_ERROR_NONE) {
+                       _DEBUG_ERROR("connection_unset_proxy_address_changed_cb() fail !! ( err_code : %d )", res);
+                       return SYNC_AGENT_PM_FAIL;
+               } else {
+                       _DEBUG_INFO("connection_unset_proxy_address_changed_cb() success !!");
+               }
+
+               res = connection_destroy(connection);
+               if (res != CONNECTION_ERROR_NONE) {
+                       _DEBUG_ERROR("connection_destroy() failed !! ( err_code : %d )", res);
+                       return SYNC_AGENT_PM_FAIL;
+               } else {
+                       _DEBUG_INFO("connection_destroy() success !!");
+               }
+       } else {
+               _DEBUG_ERROR("cannot deregister : Handle is NULL !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_add_service_data(void *add_data, int *added_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       _DEBUG_INFO("not support this feature !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       _DEBUG_INFO("not support this feature !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       pmci_network_connection_s *network_status = (pmci_network_connection_s *) calloc(1, sizeof(pmci_network_connection_s));
+       if (network_status == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return SYNC_AGENT_PM_FAIL;
+       }
+//      network_status->protocol_type = get_data_id;
+       network_status->fw_network_status = _get_net_status();
+       network_status->fw_connection_type = _get_conn_type();
+       network_status->fw_connection_state = _get_conn_state();
+
+       char *proxy = NULL;
+       char *ip = NULL;
+
+       proxy = _get_connection_ip();
+       if (proxy != NULL)
+               network_status->proxy = strdup(proxy);
+
+       ip = _get_connection_ip();
+       if (ip != NULL)
+               network_status->ip = strdup(ip);
+
+       *service_data = network_status;
+
+       if (proxy != NULL)
+               g_free(proxy);
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API void sync_agent_plugin_set_user_callback(int callback_counts, va_list list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i = 0;
+
+       _DEBUG_INFO("callback_counts : %d", callback_counts);
+       for (; i < callback_counts; i++) {
+               switch (i) {
+               case 0:
+                       registered_network_on_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+                       _DEBUG_INFO("set user callback ( for Network ON ) !!");
+                       break;
+               case 1:
+                       registered_network_off_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+                       _DEBUG_INFO("set user callback ( for Network OFF ) !!");
+                       break;
+               case 2:
+                       registered_network_change_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+                       _DEBUG_INFO("set user callback ( for Network Change ) !!");
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static void _type_changed_callback(connection_type_e type, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       if (registered_network_change_cb != NULL) {
+               registered_network_change_cb(0, NULL);
+       } else {
+               _DEBUG_TRACE("not registered registered_network_change_cb !!");
+       }
+
+       int err = 0;
+       sync_agent_na_network_status_e prev_network_status = network_status;
+       sync_agent_na_network_connection_type_e prev_connection_type = connection_type;
+       sync_agent_na_network_connection_state_e prev_connection_state = connection_state;
+       _DEBUG_TRACE("=======================================");
+       _DEBUG_TRACE("previous network status");
+       __log_for_network_status(prev_network_status);
+       _DEBUG_TRACE("previous connection type");
+       __log_for_connection_type(prev_connection_type);
+       _DEBUG_TRACE("previous connection state");
+       __log_for_connection_state(prev_connection_state);
+       _DEBUG_TRACE("=======================================");
+
+       switch (type) {
+       case CONNECTION_TYPE_DISCONNECTED:
+               {
+                       _DEBUG_TRACE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED !!");
+
+//                      _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                      __network_cancel_callback_fn(1);
+//                      _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+
+//                      if (prev_network_status == SYNC_AGENT_NA_NETWORK_ON)
+////                            network_off_callback_fn(0, NULL);
+//                              registered_network_off_cb(0, NULL);
+
+//                      network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                      connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+//                      connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+
+                       if (prev_network_status == SYNC_AGENT_NA_NETWORK_CHANGE) {
+                               if (prev_connection_type != SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED) {
+                                       return;
+                               }
+                       } else if (prev_network_status == SYNC_AGENT_NA_NETWORK_ON) {
+                               network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                               connection_state = prev_connection_state;
+
+                               /* network-off process */
+                               _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+                               __network_cancel_callback_fn(1);
+                               _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+
+                               goto return_part;
+                       }
+               }
+               break;
+       case CONNECTION_TYPE_WIFI:
+               {
+                       _DEBUG_TRACE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI !!");
+
+//                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+                       connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI;
+
+                       connection_wifi_state_e w_state;
+                       err = connection_get_wifi_state(connection, &w_state);
+                       if (err != CONNECTION_ERROR_NONE) {
+                               _DEBUG_ERROR("connection_get_wifi_state() failed !!");
+                               /*
+                                *      for exception handling
+                                */
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                              __network_cancel_callback_fn(1);
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+//
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+//                              connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED;
+                               goto return_part;
+                       } else {
+                               _DEBUG_TRACE("connection_get_wifi_state() : %d", w_state);
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI + w_state;
+                               __log_for_connection_state(connection_state);
+
+                               if (w_state != CONNECTION_WIFI_STATE_CONNECTED) {
+                                       if ((prev_network_status == SYNC_AGENT_NA_NETWORK_ON)
+                                           && (prev_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI)
+                                           && (prev_connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED)) {
+                                               network_status = SYNC_AGENT_NA_NETWORK_CHANGE;
+//                                              log_for_network_status(network_status);
+                                               /* hold on current network status */
+//                                              _DEBUG_TRACE("hold on current network status !!");
+//                                              return;
+                                       } else {
+                                               /* Meaningless case */
+                                       }
+                               } else {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                               }
+                       }
+
+                       /*
+                        *      exception handling
+                        */
+//                      if (w_state == CONNECTION_WIFI_STATE_CONNECTED) {
+//                              _DEBUG_TRACE("WIFI state : WIFI_STATE_CONNECTED !!");
+//                      } else {
+//                              _DEBUG_ERROR("Exception case occurred !!");
+//
+//                              if (w_state == CONNECTION_WIFI_STATE_DEACTIVATED) {
+//                                      _DEBUG_TRACE("WIFI state : WIFI_STATE_DEACTIVATED !!");
+//                              } else if (w_state == CONNECTION_WIFI_STATE_DISCONNECTED) {
+//                                      _DEBUG_TRACE("WIFI state : WIFI_STATE_DISCONNECTED !!");
+//                              }
+//
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                              __network_cancel_callback_fn(1);
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+//
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                      }
+               }
+               break;
+       case CONNECTION_TYPE_CELLULAR:
+               {
+                       _DEBUG_TRACE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR !!");
+
+//                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+                       connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR;
+
+                       connection_cellular_state_e c_state;
+                       err = connection_get_cellular_state(connection, &c_state);
+                       if (err != CONNECTION_ERROR_NONE) {
+                               _DEBUG_ERROR("connection_get_cellular_state() failed !!");
+                               /*
+                                *      for exception handling
+                                */
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                              __network_cancel_callback_fn(1);
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+//
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+//                              connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE;
+//                              goto return_part;
+                       } else {
+                               _DEBUG_TRACE("connection_get_cellular_state() : %d", c_state);
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR + c_state;
+                               __log_for_connection_state(connection_state);
+
+                               if (c_state != CONNECTION_CELLULAR_STATE_CONNECTED) {
+                                       if ((prev_network_status == SYNC_AGENT_NA_NETWORK_ON)
+                                           && (prev_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR)
+                                           && (prev_connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CONNECTED)) {
+                                               network_status = SYNC_AGENT_NA_NETWORK_CHANGE;
+//                                              log_for_network_status(network_status);
+                                               /* hold on current network status */
+//                                              _DEBUG_TRACE("hold on current network status !!");
+//                                              return;
+                                       } else {
+                                               /* Meaningless case */
+                                       }
+                               } else {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                               }
+                       }
+
+                       /*
+                        *      exception handling
+                        */
+//                      if (c_state == CONNECTION_CELLULAR_STATE_AVAILABLE) {
+//                              _DEBUG_TRACE("Cellular state : CELLULAR_STATE_AVAILABLE !!");
+//                      }
+//                      /*else if (c_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_ROAMING_OFF) {
+//                              _DEBUG_TRACE("Cellular state : CELLULAR_STATE_ROAMING_OFF !!");
+//                      }*/
+//                      else {
+//                              _DEBUG_ERROR("Exception case occurred !!");
+//
+//                              if (c_state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) {
+//                                      _DEBUG_TRACE("Cellular state : CELLULAR_STATE_OUT_OF_SERVICE !!");
+//                              } else if (c_state == CONNECTION_CELLULAR_STATE_FLIGHT_MODE) {
+//                                      _DEBUG_TRACE("Cellular state : CELLULAR_STATE_FLIGHT_MODE !!");
+//                              } else if (c_state == CONNECTION_CELLULAR_STATE_ROAMING_OFF) {
+//                                      _DEBUG_TRACE("Cellular state : CELLULAR_STATE_ROAMING_OFF !!");
+//                              } else if (c_state == CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE) {
+//                                      _DEBUG_TRACE("Cellular state : CELLULAR_STATE_CALL_ONLY_AVAILABLE !!");
+//                              }
+//
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                              __network_cancel_callback_fn(1);
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+//
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                      }
+               }
+               break;
+       case CONNECTION_TYPE_ETHERNET:
+               {
+                       _DEBUG_TRACE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET !!");
+
+//                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+                       connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET;
+
+                       connection_ethernet_state_e e_state;
+                       err = connection_get_ethernet_state(connection, &e_state);
+                       if (err != CONNECTION_ERROR_NONE) {
+                               _DEBUG_ERROR("connection_get_ethernet_state() failed !!");
+                               /*
+                                *      for exception handling
+                                */
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+//                              connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED;
+//                              goto return_part;
+                       } else {
+                               _DEBUG_TRACE("connection_get_ethernet_state() : %d", e_state);
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET + e_state;
+                               __log_for_connection_state(connection_state);
+
+                               if (e_state != CONNECTION_ETHERNET_STATE_CONNECTED) {
+                                       if ((prev_network_status == SYNC_AGENT_NA_NETWORK_ON)
+                                           && (prev_connection_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET)
+                                           && (prev_connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED)) {
+                                               network_status = SYNC_AGENT_NA_NETWORK_CHANGE;
+//                                              log_for_network_status(network_status);
+                                               /* hold on current network status */
+//                                              _DEBUG_TRACE("hold on current network status !!");
+//                                              return;
+                                       } else {
+                                               /* Meaningless case */
+                                       }
+                               } else {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                               }
+                       }
+
+                       /*
+                        *      exception handling
+                        */
+//                      if (e_state == CONNECTION_ETHERNET_STATE_CONNECTED) {
+//                              _DEBUG_TRACE("Ethernet state : WIFI_STATE_CONNECTED !!");
+//                      } else {
+//                              _DEBUG_ERROR("Exception case occurred !!");
+//
+//                              if (e_state == CONNECTION_ETHERNET_STATE_DEACTIVATED) {
+//                                      _DEBUG_TRACE("Ethernet state : ETHERNET_STATE_DEACTIVATED !!");
+//                              } else if (e_state == CONNECTION_ETHERNET_STATE_DISCONNECTED) {
+//                                      _DEBUG_TRACE("Ethernet state : ETHERNET_STATE_DISCONNECTED !!");
+//                              }
+//
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//                              __network_cancel_callback_fn(1);
+//                              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+//
+//                              network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                      }
+               }
+               break;
+       default:
+               break;
+       }
+
+ return_part:
+       __log_for_network_status(network_status);
+       __log_for_connection_type(connection_type);
+       __log_for_connection_state(connection_state);
+
+       _DEBUG_TRACE("_network_status_callback_fn() : Start !!");
+       _network_status_callback_fn(1);
+       _DEBUG_TRACE("_network_status_callback_fn() : End !!");
+
+       if (prev_network_status == SYNC_AGENT_NA_NETWORK_OFF) {
+               if (network_status == SYNC_AGENT_NA_NETWORK_ON) {
+//                      network_on_callback_fn(0, NULL);
+                       if (registered_network_on_cb != NULL) {
+                               registered_network_on_cb(0, NULL);
+                       } else {
+                               _DEBUG_TRACE("not registered registered_network_on_cb !!");
+                       }
+               }
+       } else {
+               if (network_status == SYNC_AGENT_NA_NETWORK_OFF) {
+//                      network_off_callback_fn(0, NULL);
+                       if (registered_network_off_cb != NULL) {
+                               registered_network_off_cb(0, NULL);
+                       } else {
+                               _DEBUG_TRACE("not registered registered_network_off_cb !!");
+                       }
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _ip_changed_callback(const char *ipv4_address, const char *ipv6_address, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("changed IP - IPv4 address : %s,  IPv6 address : %s", ipv4_address, (ipv6_address ? ipv6_address : 0));
+
+       int res = 0;
+       connection_type_e type;
+       res = connection_get_type(connection, &type);
+       if (res != CONNECTION_ERROR_NONE) {
+               _DEBUG_ERROR("connection_get_type() failed !!");
+               res = 0;
+       } else {
+               _DEBUG_TRACE("connection type : %d", type);
+       }
+
+       if (type != CONNECTION_TYPE_DISCONNECTED) {
+               _DEBUG_TRACE("connection type : not CONNECTION_TYPE_DISCONNECTED !!");
+//              _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+//              __network_cancel_callback_fn(1);
+//              _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+
+               _DEBUG_TRACE("_network_status_callback_fn() : Start !!");
+               _network_status_callback_fn(1);
+               _DEBUG_TRACE("_network_status_callback_fn() : End !!");
+       } else {
+               _DEBUG_TRACE("connection type : CONNECTION_TYPE_DISCONNECTED !!");
+               _DEBUG_TRACE("ip address is changed but do nothing !!");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _proxy_changed_callback(const char *ipv4_address, const char *ipv6_address, void *user_data)
+{
+       _INNER_FUNC_ENTER;
+
+       _DEBUG_TRACE("changed Proxy - IPv4 address : %s,  IPv6 address : %s", ipv4_address, (ipv6_address ? ipv6_address : 0));
+
+       int res = 0;
+       connection_type_e type;
+       res = connection_get_type(connection, &type);
+       if (res != CONNECTION_ERROR_NONE) {
+               _DEBUG_ERROR("connection_get_type() failed !!");
+               res = 0;
+       } else {
+               _DEBUG_TRACE("connection type : %d", type);
+       }
+
+       if (type != CONNECTION_TYPE_DISCONNECTED) {
+               _DEBUG_TRACE("__network_cancel_callback_fn() Start !!");
+               __network_cancel_callback_fn(1);
+               _DEBUG_TRACE("__network_cancel_callback_fn() End !!");
+
+               _DEBUG_TRACE("_network_status_callback_fn() : Start !!");
+               _network_status_callback_fn(1);
+               _DEBUG_TRACE("_network_status_callback_fn() : End !!");
+       } else {
+               _DEBUG_TRACE("connection type : CONNECTION_TYPE_DISCONNECTED !!");
+               _DEBUG_TRACE("proxy is changed but do nothing !!");
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+int __check_connection()
+{
+       _INNER_FUNC_ENTER;
+
+       /*
+        *      network off : -1
+        *      network change : 0
+        *      network on : 1
+        */
+       int res = -1;
+       int err = 0;
+
+       if (network_status == SYNC_AGENT_NA_NETWORK_CHANGE || network_status == SYNC_AGENT_NA_NETWORK_UNKNOWN) {
+               connection_type_e type;
+               res = connection_get_type(connection, &type);
+               if (res != CONNECTION_ERROR_NONE) {
+                       _DEBUG_ERROR("connection_get_type() failed !!");
+
+                       /* error case - default setting */
+                       connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+                       __log_for_connection_type(connection_type);
+                       connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+                       __log_for_connection_state(connection_state);
+                       network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                       __log_for_network_status(network_status);
+
+                       res = -1;
+               } else {
+                       _DEBUG_VERBOSE("connection type : %d", type);
+               }
+
+               switch (type) {
+               case CONNECTION_TYPE_DISCONNECTED:
+                       {
+                               connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED;
+                               __log_for_connection_type(connection_type);
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+                               __log_for_connection_state(connection_state);
+                               network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                               __log_for_network_status(network_status);
+                       }
+                       break;
+               case CONNECTION_TYPE_WIFI:
+                       {
+                               connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI;
+                               __log_for_connection_type(connection_type);
+
+                               connection_wifi_state_e w_state;
+                               err = connection_get_wifi_state(connection, &w_state);
+                               if (err != CONNECTION_ERROR_NONE) {
+                                       _DEBUG_ERROR("connection_get_wifi_state() failed !!");
+                                       goto return_part;
+                               } else {
+                                       _DEBUG_VERBOSE("connection_get_wifi_state() : %d", w_state);
+                               }
+
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI + w_state;
+                               __log_for_connection_state(connection_state);
+//                              if (connection_state != SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED) {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              } else {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+//                                      res = 1;
+//                              }
+
+                               if (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                                       res = 1;
+                               } else if (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                                       res = -1;
+                               } else {
+                                       res = 0;
+                               }
+                               __log_for_network_status(network_status);
+                       }
+                       break;
+               case CONNECTION_TYPE_CELLULAR:
+                       {
+                               connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR;
+                               __log_for_connection_type(connection_type);
+
+                               connection_cellular_state_e c_state;
+                               err = connection_get_cellular_state(connection, &c_state);
+                               if (err != CONNECTION_ERROR_NONE) {
+                                       _DEBUG_ERROR("connection_get_cellular_state() failed !!");
+                                       goto return_part;
+                               } else {
+                                       _DEBUG_VERBOSE("connection_get_cellular_state() : %d", c_state);
+                               }
+
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR + c_state;
+                               __log_for_connection_state(connection_state);
+//                              if ((connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) ||
+//                                              (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE)) {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              } else {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+//                                      res = 1;
+//                              }
+                               if (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CONNECTED) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                                       res = 1;
+                               } else if ((connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE) || (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE)) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                                       res = -1;
+                               } else {
+                                       res = 0;
+                               }
+                               __log_for_network_status(network_status);
+                       }
+                       break;
+               case CONNECTION_TYPE_ETHERNET:
+                       {
+                               connection_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET;
+                               __log_for_connection_type(connection_type);
+
+                               connection_ethernet_state_e e_state;
+                               err = connection_get_ethernet_state(connection, &e_state);
+                               if (err != CONNECTION_ERROR_NONE) {
+                                       _DEBUG_ERROR("connection_get_ethernet_state() failed !!");
+                                       goto return_part;
+                               } else {
+                                       _DEBUG_VERBOSE("connection_get_ethernet_state() : %d", e_state);
+                               }
+
+                               connection_state = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET + e_state;
+                               __log_for_connection_state(connection_state);
+//                              if (connection_state != SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED) {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_OFF;
+//                              } else {
+//                                      network_status = SYNC_AGENT_NA_NETWORK_ON;
+//                                      res = 1;
+//                              }
+
+                               if (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_ON;
+                                       res = 1;
+                               } else if (connection_state == SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED) {
+                                       network_status = SYNC_AGENT_NA_NETWORK_OFF;
+                                       res = -1;
+                               } else {
+                                       res = 0;
+                               }
+
+                               __log_for_network_status(network_status);
+                       }
+                       break;
+               default:
+                       break;
+               }
+       } else if (network_status == SYNC_AGENT_NA_NETWORK_ON) {
+               res = 1;
+       }
+
+ return_part:
+       _INNER_FUNC_EXIT;
+       return res;
+}
+
+char *__get_connection_proxy()
+{
+       _INNER_FUNC_ENTER;
+
+       char *proxy_addr = NULL;
+
+       connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
+
+       if (proxy_addr == NULL) {
+               _DEBUG_ERROR("Proxy address does not exist !!");
+       } else {
+               _DEBUG_VERBOSE("Current proxy : %s", proxy_addr);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return proxy_addr;
+}
+
+char *_get_connection_ip()
+{
+       _INNER_FUNC_ENTER;
+
+       char *ip_addr = NULL;
+
+       connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+
+       if (ip_addr == NULL) {
+               _DEBUG_ERROR("IP address does not exist !!");
+       } else {
+               _DEBUG_TRACE("IPv4 address : %s", ip_addr);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ip_addr;
+}
+
+int _get_net_status()
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return network_status;
+}
+
+int _get_conn_type()
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return connection_type;
+}
+
+int _get_conn_state()
+{
+       _INNER_FUNC_ENTER;
+
+       _INNER_FUNC_EXIT;
+
+       return connection_state;
+}
+
+static void __log_for_network_status(sync_agent_na_network_status_e status)
+{
+       _INNER_FUNC_ENTER;
+
+       switch (status) {
+       case SYNC_AGENT_NA_NETWORK_UNKNOWN:
+               _DEBUG_VERBOSE("network status : SYNC_AGENT_NA_NETWORK_UNKNOWN !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_ON:
+               _DEBUG_VERBOSE("network status : SYNC_AGENT_NA_NETWORK_ON !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_OFF:
+               _DEBUG_VERBOSE("network status : SYNC_AGENT_NA_NETWORK_OFF !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CHANGE:
+               _DEBUG_VERBOSE("network status : SYNC_AGENT_NA_NETWORK_CHANGE !!");
+               break;
+       default:
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __log_for_connection_type(sync_agent_na_network_connection_type_e type)
+{
+       _INNER_FUNC_ENTER;
+
+       switch (type) {
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN:
+               _DEBUG_VERBOSE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED:
+               _DEBUG_ERROR("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_DISCONNECTED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI:
+               _DEBUG_VERBOSE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR:
+               _DEBUG_VERBOSE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_CELLULAR !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET:
+               _DEBUG_VERBOSE("connection type : SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_ETHERNET !!");
+               break;
+       default:
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __log_for_connection_state(sync_agent_na_network_connection_state_e state)
+{
+       _INNER_FUNC_ENTER;
+
+       switch (state) {
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED:
+               _DEBUG_ERROR("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DEACTIVATED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED:
+               _DEBUG_ERROR("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_DISCONNECTED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE:
+               _DEBUG_ERROR("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_OUT_OF_SERVICE !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_FLIGHT_MODE:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_FLIGHT_MODE !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_ROAMING_OFF:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_ROAMING_OFF !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CALL_ONLY_AVAILABLE !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_AVAILABLE !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CONNECTED:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_CELLULAR_CONNECTED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED:
+               _DEBUG_ERROR("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DEACTIVATED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED:
+               _DEBUG_ERROR("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_DISCONNECTED !!");
+               break;
+       case SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED:
+               _DEBUG_VERBOSE("connection state : SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_ETHERNET_CONNECTED !!");
+               break;
+       default:
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _network_status_callback_fn(int protocol_type)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 0;
+
+       pmci_network_connection_s *net_status = (pmci_network_connection_s *) calloc(1, sizeof(pmci_network_connection_s));
+       if (net_status == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return;
+       }
+
+       char *proxy = NULL;
+       char *ip = NULL;
+
+//      if (check_connection() == 1) {
+//              _DEBUG_TRACE("network is ON !!");
+//
+//              proxy = __get_connection_proxy();
+//              if (proxy != NULL)
+//                      network_status->proxy = strdup(proxy);
+//
+//              ip = _get_connection_ip();
+//              if (ip != NULL)
+//                      network_status->ip = strdup(ip);
+//      } else {
+//              _DEBUG_TRACE("network is OFF !!");
+//      }
+
+       int ch_con = __check_connection();
+       if (ch_con == -1) {
+               _DEBUG_TRACE("network is OFF !!");
+       } else {
+               if (ch_con == 0) {
+                       _DEBUG_TRACE("network is Changing !!");
+               } else if (ch_con == 1) {
+                       _DEBUG_TRACE("network is ON !!");
+               }
+               proxy = __get_connection_proxy();
+               if (proxy != NULL)
+                       net_status->proxy = strdup(proxy);
+
+               ip = _get_connection_ip();
+               if (ip != NULL)
+                       net_status->ip = strdup(ip);
+       }
+
+       //      network_status->protocol_type = protocol_type;
+       net_status->fw_network_status = _get_net_status();
+       net_status->fw_connection_type = _get_conn_type();
+       net_status->fw_connection_state = _get_conn_state();
+
+       _DEBUG_TRACE("protocol_type : %d, network status : %d,  connection type : %d, connection state : %d,  proxy : %s,  ip : %s !!",
+//                                              network_status->protocol_type,
+                    protocol_type, net_status->fw_network_status, net_status->fw_connection_type, net_status->fw_connection_state, proxy, ip);
+
+       _DEBUG_TRACE("registered_network_status_cb() Start !!");
+       if (registered_network_status_cb != NULL) {
+//              res = registered_network_status_cb(protocol_type, net_status, conn_type, conn_state, proxy, ip);
+               res = registered_network_status_cb(protocol_type, (void *)net_status);
+       } else {
+               _DEBUG_ERROR("registered_network_status_cb() is NULL !!");
+       }
+       _DEBUG_TRACE("callback_network_status() End !!");
+
+       if (res != 1) {
+               _DEBUG_ERROR("registered_network_status_cb() failed !!");
+       } else {
+               _DEBUG_TRACE("registered_network_status_cb() success !!");
+       }
+
+       if (proxy != NULL)
+               g_free(proxy);
+
+       if (net_status != NULL) {
+               if (net_status->proxy != NULL)
+                       free(net_status->proxy);
+               if (net_status->ip != NULL)
+                       free(net_status->ip);
+
+               free(net_status);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void __network_cancel_callback_fn(int protocol_type)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+
+       if (registered_network_cancel_cb != NULL) {
+               _DEBUG_VERBOSE("call registered_network_cancel_cb() !!");
+
+               res = registered_network_cancel_cb(protocol_type, NULL);
+               if (res != 1) {
+                       _DEBUG_ERROR("registered_network_cancel_cb() failed !!");
+               } else {
+                       _DEBUG_VERBOSE("registered_network_cancel_cb() success !!");
+               }
+       } else {
+               _DEBUG_ERROR("registered_network_cancel_cb is NULL !! (not registered registered_network_cancel_cb())");
+       }
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/fw-plugins/common-public/slp-sysnoti-wap-push/CMakeLists.txt b/src/fw-plugins/common-public/slp-sysnoti-wap-push/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cccece0
--- /dev/null
@@ -0,0 +1,45 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "pm-slp-sysnoti-wap-push")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       glib-2.0
+                                       vconf
+                                       msg-service
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${pm-slp-sysnoti-wap-push_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${pm-slp-sysnoti-wap-push_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/plugin_slp_sysnoti_wap_push.h DESTINATION include/sync-agent/plugin/)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
+
diff --git a/src/fw-plugins/common-public/slp-sysnoti-wap-push/include/plugin_slp_sysnoti_wap_push.h b/src/fw-plugins/common-public/slp-sysnoti-wap-push/include/plugin_slp_sysnoti_wap_push.h
new file mode 100755 (executable)
index 0000000..525961d
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_SLP_SYSNOTI_WAP_PUSH_H_
+#define PLUGIN_SLP_SYSNOTI_WAP_PUSH_H_
+
+typedef enum {
+       SAN_VERSION_11 = 11,
+       SAN_VERSION_12 = 12,
+       SAN_DM_XML = 13,
+       SAN_DM_WBXML = 14,
+       SAN_DM_NOTI = 15,
+       SAN_CP_XML = 16,
+       SAN_CP_WBXML = 17
+} pm_san_version_e;
+
+/**
+ * sync-agent
+ * @remarks Notification data for 'SAN Incoming' operation
+ * @see SPECIFIC_TYPE_CALLBACK
+ */
+typedef struct {
+       const char *msg_body;
+       unsigned int msg_size;
+       int version;
+} pmci_san_incoming_s;
+
+/**
+ * sync-agent
+ * @remarks Notification data for 'SAN Operation' operation
+ * @see SPECIFIC_TYPE_CALLBACK
+ */
+typedef struct {
+       int msg_id;
+       int ext_id;
+       void *user_param;
+} pmci_san_operation_s;
+
+/**
+ * sync-agent
+ * @see PMCI_Add_Item_To_Specific_Type()
+ */
+typedef struct {
+       int ext_id;
+       int pin_code;
+       char *msg_data;
+} pmci_san_message_s;
+
+#endif                         /* PLUGIN_SLP_SYSNOTI_WAP_PUSH_H_ */
diff --git a/src/fw-plugins/common-public/slp-sysnoti-wap-push/src/plugin_interface.c b/src/fw-plugins/common-public/slp-sysnoti-wap-push/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..e95a981
--- /dev/null
@@ -0,0 +1,635 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <time.h>
+#include <vconf-keys.h>
+#include <vconf.h>
+
+#include <msg.h>
+#include <msg_storage.h>
+#include <msg_transport.h>
+
+#include "plugin_slp_sysnoti_wap_push.h"
+#include "plugin/platform_monitor_interface.h"
+
+/* for data logging */
+#include "fsapi/operation.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_PM_SYSNOTI_WAP_PUSH"
+#endif
+
+#define CP_HEADER_DATA_PATH "/opt/data/header_log.wbxml"
+#define CP_BODY_DATA_PATH "/opt/data/body_log.wbxml"
+
+static msg_handle_t msg_handle = NULL;
+
+static int (*registered_wap_push_incoming_cb) (int data_id, void *user_data);
+static int (*registered_wap_push_operation_cb) (int data_id, void *user_data);
+
+static int _start_wap_push();
+static int _end_wap_push();
+static int _add_message(void *add_data, int *added_data_id);
+static int _remove_message(int remove_data_id);
+
+static int __register_msg_callback();
+static void __check_msg_server_cb(keynode_t * node, void *data);
+static void ___incomming_syncml_msg_cb(msg_handle_t msg_handle, msg_syncml_message_type_t msg_type, const char *push_body, int push_body_len, const char *wsp_header, int wsp_header_len, void *user_param);
+void ___operation_syncml_msg_cb(msg_handle_t handle, int msg_id, int ext_id, void *user_param);
+
+EXPORT_API void sync_agent_plugin_init_service_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 0;
+
+       res = _start_wap_push();
+
+       if (res != 1) {
+               _DEBUG_ERROR("_start_wap_push() failed !!");
+       } else {
+               _DEBUG_INFO("_start_wap_push() success !!");
+       }
+
+       if (data != NULL) {
+               if (((sync_agent_pm_register_data_s *) data)->pkg_name != NULL)
+                       free(((sync_agent_pm_register_data_s *) data)->pkg_name);
+
+               if (((sync_agent_pm_register_data_s *) data)->additional_data != NULL)
+                       free(((sync_agent_pm_register_data_s *) data)->additional_data);
+
+               free(data);
+
+               _DEBUG_INFO("free sync_agent_pm_register_data_s !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_unregister_service_noti(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       int res = 0;
+
+       res = _end_wap_push();
+
+       if (res != 1) {
+               _DEBUG_ERROR("_end_wap_push() failed !!");
+               return res;
+       } else {
+               _DEBUG_INFO("_end_wap_push() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_add_service_data(void *add_data, int *added_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(add_data == NULL, SYNC_AGENT_PM_FAIL, "add_data is NULL. FAIL !!!");
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       int res = 0;
+
+       res = _add_message(add_data, added_data_id);
+
+       if (res != 1) {
+               _DEBUG_ERROR("_add_message() failed !!");
+               return SYNC_AGENT_PM_FAIL;
+       } else {
+               _DEBUG_INFO("_add_message() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       int res = 0;
+
+       res = _remove_message(remove_data_id);
+
+       if (res != 1) {
+               _DEBUG_ERROR("_remove_message() failed !!");
+               return res;
+       } else {
+               _DEBUG_INFO("_remove_message() success !!");
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       _DEBUG_INFO("not support this feature !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API void sync_agent_plugin_set_user_callback(int callback_counts, va_list list)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int i = 0;
+
+       _DEBUG_INFO("callback_counts : %d", callback_counts);
+       for (; i < callback_counts; i++) {
+               switch (i) {
+               case 0:
+                       registered_wap_push_incoming_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+                       _DEBUG_INFO("set user callback ( for WAP Push Incoming ) !!");
+                       break;
+               case 1:
+                       registered_wap_push_operation_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+                       _DEBUG_INFO("set user callback ( for WAP Push Operation End ) !!");
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       _EXTERN_FUNC_EXIT;
+}
+
+static int _start_wap_push()
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       int msg_key = 0;
+
+       msg_error_t err = MSG_SUCCESS;
+
+       if (vconf_get_bool(VCONFKEY_MSG_SERVER_READY, &msg_key) == 0) {
+               if (msg_key == 1) {
+                       _DEBUG_TRACE("msg server is ready !!");
+
+                       err = msg_open_msg_handle(&msg_handle);
+                       if (err != MSG_SUCCESS) {
+                               _DEBUG_ERROR("msg_open_msg_handle() failed ( err_code : %d ) !!", err);
+                               res = -1;
+                               goto return_part;
+                       } else {
+                               _DEBUG_TRACE("msg_open_msg_handle() success !!");
+
+                               res = __register_msg_callback();
+                               if (res != 1) {
+                                       _DEBUG_ERROR("register_syncml_msg_callback() failed ( err_code : %d ) !!", res);
+
+                                       err = msg_close_msg_handle(&msg_handle);
+                                       if (err != MSG_SUCCESS) {
+                                               _DEBUG_ERROR("msg_close_msg_handle() failed ( err_code : %d ) !!", err);
+                                               res = -1;
+                                               goto return_part;
+                                       } else {
+                                               _DEBUG_TRACE("msg_close_msg_handle() success !!");
+                                               msg_handle = NULL;
+                                               res = -1;
+                                               goto return_part;
+                                       }
+                               } else {
+                                       _DEBUG_TRACE("register_syncml_msg_callback() success !!");
+                               }
+                       }
+               } else {
+                       _DEBUG_ERROR("msg server is not ready !!");
+
+                       if (vconf_notify_key_changed((char *)VCONFKEY_MSG_SERVER_READY, __check_msg_server_cb, NULL) != 0) {
+                               _DEBUG_ERROR("vconf_notify_key_changed( VCONFKEY_MSG_SERVER_READY ) failed !!");
+                               res = -1;
+                               goto return_part;
+                       } else {
+                               _DEBUG_TRACE("vconf_notify_key_changed() success !!");
+                       }
+               }
+       } else {
+               _DEBUG_ERROR("vconf_get_bool ( VCONFKEY_MSG_SERVER_READY ) failed !!");
+               res = -1;
+               goto return_part;
+       }
+
+ return_part:
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static int _end_wap_push()
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       msg_error_t err = MSG_SUCCESS;
+
+       err = msg_close_msg_handle(&msg_handle);
+       if (err != MSG_SUCCESS) {
+               _DEBUG_ERROR("msg_close_msg_handle() failed ( err_code : %d ) !!", err);
+               res = -1;
+               goto return_part;
+       } else {
+               _DEBUG_TRACE("msg_close_msg_handle() success !!");
+               msg_handle = NULL;
+       }
+
+ return_part:
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static int _add_message(void *add_data, int *added_data_id)
+{
+       _INNER_FUNC_ENTER;
+
+       retvm_if(add_data == NULL, 0, "add_data is NULL. FAIL !!!");
+
+       int res = 1;
+       msg_error_t err = MSG_SUCCESS;
+
+       msg_struct_t syncml_msg = msg_create_struct(MSG_STRUCT_SYNCML_INFO);
+       pmci_san_message_s *add_msg = (pmci_san_message_s *) add_data;
+
+       *added_data_id = add_msg->ext_id;
+       msg_set_int_value(syncml_msg, MSG_SYNCML_INFO_EXTID_INT, add_msg->ext_id);
+       msg_set_int_value(syncml_msg, MSG_SYNCML_INFO_PINCODE_INT, add_msg->pin_code);
+
+       msg_struct_t msg = NULL;
+       msg_get_struct_handle(syncml_msg, MSG_SYNCML_INFO_MESSAGE_HND, &msg);
+       msg_set_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, MSG_INBOX_ID);
+       msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS_SYNCML);
+       msg_set_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, MSG_NETWORK_RECEIVED);
+       msg_set_int_value(msg, MSG_MESSAGE_DIRECTION_INT, MSG_DIRECTION_TYPE_MT);
+
+       msg_struct_list_s *addr_list = NULL;
+       msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
+       addr_list->nCount = 1;
+
+       msg_struct_t addr_info = NULL;
+       addr_info = addr_list->msg_struct_info[0];
+       msg_set_int_value(addr_info, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
+       char addr_value[MAX_ADDRESS_VAL_LEN] = "+1004";
+       msg_set_str_value(addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr_value, MAX_ADDRESS_VAL_LEN);
+
+       time_t t = time(NULL);
+       time_t utfTime = time(&t);
+       msg_set_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, utfTime);
+
+       msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, add_msg->msg_data, strlen(add_msg->msg_data));
+
+       err = msg_add_syncml_message(msg_handle, syncml_msg);
+       if (err != MSG_SUCCESS) {
+               _DEBUG_ERROR("msg_add_syncml_message() failed ( err_code : %d ) !!", err);
+               res = -1;
+               goto return_part;
+       } else {
+               _DEBUG_TRACE("msg_add_syncml_message() success !!");
+       }
+
+ return_part:
+       msg_release_struct(&syncml_msg);
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static int _remove_message(int remove_data_id)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       msg_error_t err = MSG_SUCCESS;
+
+       if (msg_handle == NULL) {
+               _DEBUG_ERROR("msg_handle is NULL !!");
+               res = -1;
+               goto return_part;
+       }
+
+       err = msg_delete_message(msg_handle, remove_data_id);
+       if (err != MSG_SUCCESS) {
+               _DEBUG_ERROR("msg_delete_message() fail !!");
+               res = -1;
+       } else {
+               _DEBUG_INFO("msg_delete_message() success !!");
+       }
+
+ return_part:
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static int __register_msg_callback()
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       msg_error_t err = MSG_SUCCESS;
+
+       if (msg_handle == NULL) {
+               _DEBUG_ERROR("msg_handle is NULL !!");
+               res = -1;
+               goto return_part;
+       }
+//    err = msg_reg_syncml_message_callback(msg_handle, &___incomming_syncml_msg_cb, NULL);
+       err = msg_reg_syncml_message_callback(msg_handle, ___incomming_syncml_msg_cb, NULL);
+       if (err != MSG_SUCCESS) {
+               _DEBUG_ERROR("Register SyncML Incoming Callback fail [%d] !!", err);
+               res = -1;
+               goto return_part;
+       } else {
+               _DEBUG_VERBOSE("Register SyncML Incoming Callback success !!");
+       }
+
+//      err = msg_reg_syncml_message_operation_callback(msg_handle, &___operation_syncml_msg_cb, NULL);
+       err = msg_reg_syncml_message_operation_callback(msg_handle, ___operation_syncml_msg_cb, NULL);
+       if (err != MSG_SUCCESS) {
+               _DEBUG_ERROR("Register SyncML Operation Callback fail [%d] !!", err);
+               res = -1;
+               goto return_part;
+       } else {
+               _DEBUG_VERBOSE("Register SyncML Operation Callback success !!");
+       }
+
+ return_part:
+
+       _INNER_FUNC_EXIT;
+
+       return res;
+}
+
+static void __check_msg_server_cb(keynode_t * node, void *data)
+{
+       _INNER_FUNC_ENTER;
+
+       int res = 1;
+       int msg_key = 0;
+       msg_error_t err = MSG_SUCCESS;
+
+       if (vconf_get_bool(VCONFKEY_MSG_SERVER_READY, &msg_key) == 0) {
+               if (msg_key == 1) {
+                       _DEBUG_VERBOSE("msg server is ready !!");
+
+                       if (msg_handle == NULL) {
+                               err = msg_open_msg_handle(&msg_handle);
+                               if (err != MSG_SUCCESS) {
+                                       _DEBUG_ERROR("msg_open_msg_handle() fail [%d] !!", err);
+                                       goto return_part;
+                               } else {
+                                       _DEBUG_VERBOSE("msg_open_msg_handle() success !!");
+
+                                       res = __register_msg_callback();
+                                       if (res != 1) {
+                                               _DEBUG_ERROR("register_syncml_msg_callback() fail !!");
+                                               goto return_part;
+                                       } else {
+                                               _DEBUG_VERBOSE("register_syncml_msg_callback() success !!");
+                                       }
+                               }
+                       } else {
+                               _DEBUG_VERBOSE("callback is already registered !!");
+                       }
+               } else {
+                       _DEBUG_VERBOSE("msg server is not ready !!");
+               }
+       } else {
+               _DEBUG_ERROR("vconf_get_bool ( VCONFKEY_MSG_SERVER_READY ) fail !!");
+               goto return_part;
+       }
+
+ return_part:
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void ___incomming_syncml_msg_cb(msg_handle_t msg_handle, msg_syncml_message_type_t msg_type, const char *push_body, int push_body_len, const char *wsp_header, int wsp_header_len, void *user_param)
+{
+       _INNER_FUNC_ENTER;
+
+       pmci_san_incoming_s *san_incoming = (pmci_san_incoming_s *) calloc(1, sizeof(pmci_san_incoming_s));
+       if (san_incoming == NULL) {
+               _DEBUG_ERROR("pmci_san_incomming_t calloc error !!");
+               /* todo : exception handling */
+               return;
+       }
+       _DEBUG_VERBOSE("push body : %s,   push body len : %d", push_body, push_body_len);
+       _DEBUG_VERBOSE("wsp header : %s,   wsp header len : %d", wsp_header, wsp_header_len);
+
+       /* FIXME : for recoding log data - Start */
+       _DEBUG_VERBOSE("logging wsp_header >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+
+       int file_ret = sync_agent_write_whole_file(CP_HEADER_DATA_PATH, wsp_header, wsp_header_len, 1);
+       if (file_ret != 1) {
+               _DEBUG_ERROR("sync_agent_write_whole_file() - CP header data failed !!");
+       } else {
+               _DEBUG_VERBOSE("sync_agent_write_whole_file() - CP header data success !!");
+       }
+
+       _DEBUG_VERBOSE("logging PushBody >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+       file_ret = sync_agent_write_whole_file(CP_BODY_DATA_PATH, push_body, push_body_len, 1);
+
+       if (file_ret != 1) {
+               _DEBUG_ERROR("sync_agent_write_whole_file() - CP body data failed !!");
+       } else {
+               _DEBUG_VERBOSE("sync_agent_write_whole_file() - CP body data success !!");
+       }
+
+       /* FIXME : for recoding log data - End */
+
+       if ((msg_type == CP_WBXML) || (msg_type == CP_XML)) {   /* CP case : merging header & body messages */
+               if ((push_body_len > 0) && (wsp_header_len > 0)) {
+                       int msg_len = push_body_len + wsp_header_len + 1;
+
+                       san_incoming->msg_body = (char *)calloc(msg_len, sizeof(char));
+                       if (san_incoming->msg_body == NULL) {
+                               _DEBUG_ERROR("san_incoming->msg_body calloc error !!");
+                               goto free_part;
+                       } else {
+                               if (wsp_header != NULL) {
+                                       _DEBUG_VERBOSE("CP : add wsp_header data !!");
+                                       memcpy((void *)(san_incoming->msg_body), wsp_header, wsp_header_len + 1);
+                               } else {
+                                       _DEBUG_ERROR("wrong message - wapHeader is NULL !!");
+                                       goto free_part;
+                               }
+
+                               if (push_body != NULL) {
+                                       _DEBUG_VERBOSE("CP : add push_body data !!");
+                                       memcpy((void *)((san_incoming->msg_body) + wsp_header_len), push_body, push_body_len + 1);
+                               } else {
+                                       _DEBUG_ERROR("wrong message - push_body is NULL !!");
+                                       goto free_part;
+                               }
+
+                               san_incoming->msg_size = msg_len - 1;
+                       }
+               } else {
+                       _DEBUG_ERROR("wrong message format !!");
+                       goto free_part;
+               }
+       } else {
+               if ((push_body_len > 0) && (push_body != NULL)) {
+                       san_incoming->msg_body = (char *)calloc(push_body_len + 1, sizeof(char));
+                       if (san_incoming->msg_body == NULL) {
+                               _DEBUG_ERROR("san_incoming->msg_body calloc error !!");
+                               goto free_part;
+                       } else {
+                               _DEBUG_VERBOSE("OTHERS : set push_body data !!");
+                               memcpy((void *)(san_incoming->msg_body), push_body, push_body_len + 1);
+                               san_incoming->msg_size = push_body_len;
+                       }
+               } else {
+                       _DEBUG_VERBOSE("PushBody message is NULL !!");
+                       san_incoming->msg_body = NULL;
+                       san_incoming->msg_size = 0;
+               }
+       }
+
+       switch (msg_type) {
+       case DM_WBXML:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 0, DM_WBXML ) detected.\n");
+                       san_incoming->version = SAN_DM_WBXML;
+               }
+               break;
+       case DM_XML:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 1, DM_XML ) detected.\n");
+                       san_incoming->version = SAN_DM_XML;
+               }
+               break;
+       case DM_NOTIFICATION:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 2, DM_NOTIFICATION ) detected.\n");
+                       san_incoming->version = SAN_DM_NOTI;
+               }
+               break;
+       case DS_NOTIFICATION:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 3, DS_NOTIFICATION ) detected.\n");
+                       san_incoming->version = SAN_VERSION_12;
+               }
+               break;
+       case DS_WBXML:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 4, DS_WBXML ) detected.\n");
+                       san_incoming->version = SAN_VERSION_11;
+               }
+               break;
+       case CP_XML:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 5, CP_XML ) detected.\n");
+                       san_incoming->version = SAN_CP_XML;
+               }
+               break;
+       case CP_WBXML:
+               {
+                       _DEBUG_VERBOSE("MsgNoti ( msg_type = 6, CP_WBXML ) detected.\n");
+                       san_incoming->version = SAN_CP_WBXML;
+               }
+               break;
+       case OTHERS:
+       default:
+               _DEBUG_VERBOSE("Unknown MsgNoti ( %d ) detected.\n", msg_type);
+               break;
+       }
+
+       if (registered_wap_push_incoming_cb != NULL) {
+               registered_wap_push_incoming_cb(0, (void *)san_incoming);
+       } else {
+               _DEBUG_ERROR("not registered registered_wap_push_incoming_cb !!");
+       }
+
+ free_part:
+       if (san_incoming != NULL) {
+               if (san_incoming->msg_body != NULL)
+                       free((void *)(san_incoming->msg_body));
+
+               free(san_incoming);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+void ___operation_syncml_msg_cb(msg_handle_t handle, int msg_id, int ext_id, void *user_param)
+{
+       _INNER_FUNC_ENTER;
+
+       pmci_san_operation_s *san_operation = (pmci_san_operation_s *) calloc(1, sizeof(pmci_san_operation_s));
+       if (san_operation == NULL) {
+               _DEBUG_ERROR("pmci_san_operation_s calloc error !!");
+               /* todo : exception handling */
+               return;
+       }
+
+       san_operation->msg_id = msg_id;
+       _DEBUG_VERBOSE("msg_id : %d", msg_id);
+
+       san_operation->ext_id = ext_id;
+       _DEBUG_VERBOSE("ext_id : %d", ext_id);
+
+       san_operation->user_param = user_param;
+       /*memcpy(san_operation->user_param, user_param, sizeof(user_param)); */
+
+       if (registered_wap_push_operation_cb != NULL) {
+               registered_wap_push_operation_cb(0, (void *)san_operation);
+       } else {
+               _DEBUG_ERROR("not registered registered_wap_push_operation_cb !!");
+       }
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/fw-plugins/common-public/vcalendar/CMakeLists.txt b/src/fw-plugins/common-public/vcalendar/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a209af3
--- /dev/null
@@ -0,0 +1,42 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "dc-vcalendar")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+#                                      calendar
+                                       calendar-service2
+                                       glib-2.0
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${dc-vcalendar_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${dc-vcalendar_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/vcalendar/include/encoding_util.h b/src/fw-plugins/common-public/vcalendar/include/encoding_util.h
new file mode 100755 (executable)
index 0000000..5ed2c86
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ENCODING_UTIL_H_
+#define ENCODING_UTIL_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define QP_SIZE                        76
+#define BASE64_SIZE                    76
+
+typedef enum {
+       EN_TYPE_NONE = 0,
+       EN_TYPE_QUOTED_PRINTABLE,
+       EN_TYPE_BASE64
+} encoding_type_e;
+
+/*             Quoted-Printable
+ *
+ *     @example code
+int main()
+{
+       char *src = "안녕하세요";
+       char *encode_src;
+       int encode_src_len = 0;
+       char *decode_src;
+       int decode_src_len = 0;
+
+       int res = encode_qp(src, strlen(src), &encode_src, &encode_src_len);
+       if (res != 0)
+               fprintf(stdout, "encode src : %s ( %d ) \n", encode_src, encode_src_len);
+       else
+               fprintf(stdout, "%s\n", "encode error !!");
+
+       res = decode_qp(encode_src, encode_src_len, &decode_src, &decode_src_len);
+       if (res != 0)
+               fprintf(stdout, "decode src : %s ( %d ) \n", decode_src, decode_src_len);
+       else
+               fprintf(stdout, "%s\n", "decode error !!");
+
+       return 0;
+}
+
+ */
+
+/*
+ * @brief                      encode original source ( encoding type : quoted-printable )
+ *     @param[in]      src                             original source
+ *     @param[in]      src_len                 length of original source
+ *     @param[out]     en_src                  encoded source
+ *     @param[out]     en_src_len              length of encoded source
+ *     @return                 operation result
+ *     @retval                 1                                       success
+ *     @retval                 0                                       fail
+ */
+int encode_qp(char *src, int src_len, char **en_src, int *en_src_len);
+
+/*
+ * @brief                      decode encoded source ( decoding type : quoted-printable )
+ * @param[in]  src                             encoded source
+ * @param[in]  src_len                 length of encoded source
+ * @param[out] de_src                  decoded source ( original source )
+ * @param[out] de_src_len              length of decoded source
+ * @return                     operation result
+ * @retval                     1                                       success
+ * @retval                     0                                       fail
+ */
+int decode_qp(char *src, int src_len, char **de_src, int *de_src_len);
+
+/*             Base64
+ *
+ *     @example code
+
+ int main()
+{
+       char *src = "Hello";
+       char *encode_src;
+       int encode_src_len = 0;
+       char *decode_src;
+       int decode_src_len = 0;
+
+       int res = encode_base64(src, strlen(src), &encode_src, &encode_src_len);
+       if (res != 0)
+               fprintf(stdout, "encode src : %s ( %d ) \n", encode_src, encode_src_len);
+       else
+               fprintf(stdout, "%s\n", "encode error !!");
+
+       res = decode_base64(encode_src, encode_src_len, &decode_src, &decode_src_len);
+       if (res != 0)
+               fprintf(stdout, "decode src : %s ( %d ) \n", decode_src, decode_src_len);
+       else
+               fprintf(stdout, "%s\n", "decode error !!");
+
+       return 0;
+}
+
+ */
+
+/*
+ * @brief                      encode original source ( encoding type : base64 )
+ *     @param[in]      src                             original source
+ *     @param[in]      src_len                 length of original source
+ *     @param[out]     en_src                  encoded source
+ *     @param[out]     en_src_len              length of encoded source
+ *     @return                 operation result
+ *     @retval                 1                                       success
+ *     @retval                 0                                       fail
+ */
+int encode_base64(char *src, int src_len, char **en_src, int *en_src_len);
+
+/*
+ * @brief                      decode encoded source ( decoding type : base64 )
+ * @param[in]  src                             encoded source
+ * @param[in]  src_len                 length of encoded source
+ * @param[out] de_src                  decoded source ( original source )
+ * @param[out] de_src_len              length of decoded source
+ * @return                     operation result
+ * @retval                     1                                       success
+ * @retval                     0                                       fail
+ */
+int decode_base64(char *src, int src_len, char **de_src, int *de_src_len);
+
+/*
+ * @brief                      make the decoding process
+ * @param[in]  src                             encoded source
+ * @param[in]  src_len                 length of encoded source
+ * @param[out] de_src                  decoded source ( original source )
+ * @param[out] de_src_len              length of decoded source
+ * @return                     operation result
+ * @retval                     1                                       success
+ * @retval                     0                                       fail
+ *
+ * @example code
+
+int main()
+{
+       char *src = "...";                      // decoded data
+       int src_len = strlen(src);
+       char *decode_src;
+       int decode_src_len = 0;
+
+       int res = proc_decoding(src, src_len, &decode_src, &decode_src_len);
+
+       if (res != 0)
+               fprintf(stdout, "decode src : \n%s\n", decode_src);
+       else
+               fprintf(stdout, "%s\n", "decode error !!");
+
+       if (decode_src != NULL)
+               free(decode_src);
+
+       return 0;
+}
+ */
+int proc_decoding(const char *src, int src_len, char **de_src, int *de_src_len);
+
+/*
+ * @brief                      encoded value is changed to the decoded value
+ * @param[in]  type                                    encoding type
+ * @param[in]  value                                   encoded value (end of string must be '\0' !!)
+ *                                                                                     ex) =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+ * @param[in]  value_size                      length of encoded value
+ * @param[out] decode_str                      decoded string
+ * @param[out] decode_str_len  length of decoded string
+ * @return                     operation result
+ * @ratval                     1                                               success
+ * @retval                     0                                               fail
+ *
+ * @example code
+
+ int main()
+ {
+        char *data = "...";                                            // ex) ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8
+        encoding_type_e type = find_encoding_type((const char *)data);
+
+        char *value = "...";                                   // ex) =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+        int value_size = strlen(value);
+
+        int decode_str_len = 0;
+        char *decode_str = (char*)malloc(sizeof(char)*BUF_SIZE);                       // BUF_SIZE : user define
+        if (decode_str == NULL) {
+                // error process
+        }
+        memset(decode_str, 0x00, sizeof(char)*BUF_SIZE);
+
+        int res = decode_value(type, value, data_size, &decode_str, &decode_str_len);
+
+        if (res == 1) {
+                // success process
+                if (decode_str != NULL)
+                        free(decode_str);
+        } else {
+                // error process
+                if (decode_str != NULL)
+                        free(decode_str);
+        }
+
+        return 0;
+ }
+ */
+int decode_value(encoding_type_e type, const char *value, int value_size, char **decode_str, int *decode_str_len);
+
+/*
+ * @brief                      get encoding type for data
+ * @param[in]  data                                    vobject data
+ * @return                     encoding type
+ * @ratval                     >= 1                                    success
+ * @retval                     0                                               fail
+ */
+encoding_type_e find_encoding_type(const char *data);
+
+/*
+ * @brief                      check whether to exist this string, "ENCODING=" in the data
+ * @param[in]  data                            vobject data
+ * @return                     operation result
+ * @retval                     1                                       exist
+ * @retval                     0                                       not exist
+ */
+int check_encoding_data(const char *data);
+
+#endif                         /* ENCODING_UTIL_H_ */
diff --git a/src/fw-plugins/common-public/vcalendar/include/in_datastore_info_vcalendar.h b/src/fw-plugins/common-public/vcalendar/include/in_datastore_info_vcalendar.h
new file mode 100755 (executable)
index 0000000..3277ecf
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IN_DATASTORE_INFO_VCALENDAR_H_
+#define IN_DATASTORE_INFO_VCALENDAR_H_
+
+#define VCALENDAR_TYPE                                         "text/x-vcalendar"
+#define VCALENDAR_VERSION                                      "1.0"
+
+typedef enum {
+       VCALENDAR_FIELD_BEGIN = 10,
+       VCALENDAR_FIELD_END,
+       VCALENDAR_FIELD_VERSION,
+       VCALENDAR_FIELD_AALARM,
+       VCALENDAR_FIELD_ACTION,
+       VCALENDAR_FIELD_ATTACH,
+       VCALENDAR_FIELD_ATTENDEE,
+       VCALENDAR_FIELD_CALSCALE,
+       VCALENDAR_FIELD_CATEGORIES,
+       VCALENDAR_FIELD_CLASS,
+       VCALENDAR_FIELD_COMMENT,
+       VCALENDAR_FIELD_COMPLETED,
+       VCALENDAR_FIELD_CONTACT,
+       VCALENDAR_FIELD_CREATED,
+       VCALENDAR_FIELD_DALARM,
+       VCALENDAR_FIELD_DAYLIGHT,
+       VCALENDAR_FIELD_DCREATED,
+       VCALENDAR_FIELD_DESCRIPTION,
+       VCALENDAR_FIELD_DTEND,
+       VCALENDAR_FIELD_DTSTAMP,
+       VCALENDAR_FIELD_DTSTART,
+       VCALENDAR_FIELD_DUE,
+       VCALENDAR_FIELD_DURATION,
+       VCALENDAR_FIELD_EXDATE,
+       VCALENDAR_FIELD_EXRULE,
+       VCALENDAR_FIELD_FREEBUSY,
+       VCALENDAR_FIELD_GEO,
+       VCALENDAR_FIELD_LAST_MODIFIED,
+       VCALENDAR_FIELD_LOCATION,
+       VCALENDAR_FIELD_MALARM,
+       VCALENDAR_FIELD_METHOD,
+       VCALENDAR_FIELD_ORGANIZER,
+       VCALENDAR_FIELD_PALARM,
+       VCALENDAR_FIELD_PERCENT_COMPLETE,
+       VCALENDAR_FIELD_PRIORITY,
+       VCALENDAR_FIELD_PRODID,
+       VCALENDAR_FIELD_RDATE,
+       VCALENDAR_FIELD_RECURRENCE_ID,
+       VCALENDAR_FIELD_RELATED_TO,
+       VCALENDAR_FIELD_REPEAT,
+       VCALENDAR_FIELD_REQUEST_STATUS,
+       VCALENDAR_FIELD_RESOURCES,
+       VCALENDAR_FIELD_RNUM,
+       VCALENDAR_FIELD_RRULE,
+       VCALENDAR_FIELD_SEQUENCE,
+       VCALENDAR_FIELD_STANDARD,
+       VCALENDAR_FIELD_STATUS,
+       VCALENDAR_FIELD_SUMMARY,
+       VCALENDAR_FIELD_TRANSP,
+       VCALENDAR_FIELD_TRIGGER,
+       VCALENDAR_FIELD_TZ,
+       VCALENDAR_FIELD_TZID,
+       VCALENDAR_FIELD_TZNAME,
+       VCALENDAR_FIELD_TZOFFSETFROM,
+       VCALENDAR_FIELD_TZOFFSETTO,
+       VCALENDAR_FIELD_TZURL,
+       VCALENDAR_FIELD_URL,
+       VCALENDAR_FIELD_UID,
+       VCALENDAR_FIELD_VALARM,
+       VCALENDAR_FIELD_VCALENDAR,
+       VCALENDAR_FIELD_VEVENT,
+       VCALENDAR_FIELD_VFREEBUSY,
+       VCALENDAR_FIELD_VJOURNAL,
+       VCALENDAR_FIELD_VTIMEZONE,
+       VCALENDAR_FIELD_VTODO,
+       VCALENDAR_FIELD_X_FUNAMBOL_ALLDAY,
+
+} vcalendadr_field_e;
+
+typedef enum {
+       VCALENDAR_FIELD_BEGIN_END_VCALENDAR = 100,
+       VCALENDAR_FIELD_BEGIN_END_VEVENT,
+       VCALENDAR_FIELD_BEGIN_END_VTODO,
+       VCALENDAR_FIELD_BEGIN_END_VJOURNAL,
+       VCALENDAR_FIELD_BEGIN_END_VFREEBUSY,
+       VCALENDAR_FIELD_BEGIN_END_VTIMEZONE,
+       VCALENDAR_FIELD_BEGIN_END_VALARM,
+       VCALENDAR_FIELD_BEGIN_END_STANDARD,
+       VCALENDAR_FIELD_BEGIN_END_DAYLIGHT,
+
+} vcalendar_field_begin_end_sub_e;
+
+typedef enum {
+       VCALENDAR_FIELD_CATEGORIES_APPOINTMENT = 200,
+       VCALENDAR_FIELD_CATEGORIES_HOLIDAY,
+       VCALENDAR_FIELD_CATEGORIES_BUSINESS,
+       VCALENDAR_FIELD_CATEGORIES_SPECIAL_OCCASION,
+       VCALENDAR_FIELD_CATEGORIES_IMPORTANT,
+       VCALENDAR_FIELD_CATEGORIES_BIRTHDAY,
+       VCALENDAR_FIELD_CATEGORIES_MISSCELLANEOUS,
+
+} vcalendadr_field_categories_sub_e;
+
+typedef enum {
+       VCALENDAR_FIELD_STATUS_NEEDS_ACTION = 300,
+       VCALENDAR_FIELD_STATUS_COMPLETED,
+
+} VCALENDAR_FIELD_STATUS_SUB;
+
+typedef struct vcalendar_field_list vcalendar_field_list_s;
+struct vcalendar_field_list {
+       int field_enum;
+       char *field_name;
+};
+
+static vcalendar_field_list_s vcalendar_field_list[] = {
+       {VCALENDAR_FIELD_BEGIN, "BEGIN"},
+       {VCALENDAR_FIELD_END, "END"},
+       {VCALENDAR_FIELD_VERSION, "VERSION"},
+       {VCALENDAR_FIELD_AALARM, "AALARM"},
+       {VCALENDAR_FIELD_ACTION, "ACTION"},
+       {VCALENDAR_FIELD_ATTACH, "ATTACH"},
+       {VCALENDAR_FIELD_ATTENDEE, "ATTENDEE"},
+       {VCALENDAR_FIELD_CALSCALE, "CALSCALE"},
+       {VCALENDAR_FIELD_CATEGORIES, "CATEGORIES"},
+       {VCALENDAR_FIELD_CLASS, "CLASS"},
+       {VCALENDAR_FIELD_COMMENT, "COMMENT"},
+       {VCALENDAR_FIELD_COMPLETED, "COMPLETED"},
+       {VCALENDAR_FIELD_CONTACT, "CONTACT"},
+       {VCALENDAR_FIELD_CREATED, "CREATED"},
+       {VCALENDAR_FIELD_DALARM, "DALARM"},
+       {VCALENDAR_FIELD_DAYLIGHT, "DAYLIGHT"},
+       {VCALENDAR_FIELD_DCREATED, "DCREATED"},
+       {VCALENDAR_FIELD_DESCRIPTION, "DESCRIPTION"},
+       {VCALENDAR_FIELD_DTEND, "DTEND"},
+       {VCALENDAR_FIELD_DTSTAMP, "DTSTAMP"},
+       {VCALENDAR_FIELD_DTSTART, "DTSTART"},
+       {VCALENDAR_FIELD_DUE, "DUE"},
+       {VCALENDAR_FIELD_DURATION, "DURATION"},
+       {VCALENDAR_FIELD_EXDATE, "EXDATE"},
+       {VCALENDAR_FIELD_EXRULE, "EXRULE"},
+       {VCALENDAR_FIELD_FREEBUSY, "FREEBUSY"},
+       {VCALENDAR_FIELD_GEO, "GEO"},
+       {VCALENDAR_FIELD_LAST_MODIFIED, "LAST-MODIFIED"},
+       {VCALENDAR_FIELD_LOCATION, "LOCATION"},
+       {VCALENDAR_FIELD_MALARM, "MALARM"},
+       {VCALENDAR_FIELD_METHOD, "METHOD"},
+       {VCALENDAR_FIELD_ORGANIZER, "ORGANIZER"},
+       {VCALENDAR_FIELD_PALARM, "PALARM"},
+       {VCALENDAR_FIELD_PERCENT_COMPLETE, "PERCENT-COMPLETE"},
+       {VCALENDAR_FIELD_PRIORITY, "PRIORITY"},
+       {VCALENDAR_FIELD_PRODID, "PRODID"},
+       {VCALENDAR_FIELD_RDATE, "RDATE"},
+       {VCALENDAR_FIELD_RECURRENCE_ID, "RECURRENCE-ID"},
+       {VCALENDAR_FIELD_RELATED_TO, "RELATED-TO"},
+       {VCALENDAR_FIELD_REPEAT, "REPEAT"},
+       {VCALENDAR_FIELD_REQUEST_STATUS, "REQUEST-STATUS"},
+       {VCALENDAR_FIELD_RESOURCES, "RESOURCES"},
+       {VCALENDAR_FIELD_RNUM, "RNUM"},
+       {VCALENDAR_FIELD_RRULE, "RRULE"},
+       {VCALENDAR_FIELD_SEQUENCE, "SEQUENCE"},
+       {VCALENDAR_FIELD_STANDARD, "STANDARD"},
+       {VCALENDAR_FIELD_STATUS, "STATUS"},
+       {VCALENDAR_FIELD_SUMMARY, "SUMMARY"},
+       {VCALENDAR_FIELD_TRANSP, "TRANSP"},
+       {VCALENDAR_FIELD_TRIGGER, "TRIGGER"},
+       {VCALENDAR_FIELD_TZ, "TZ"},
+       {VCALENDAR_FIELD_TZID, "TZID"},
+       {VCALENDAR_FIELD_TZNAME, "TZNAME"},
+       {VCALENDAR_FIELD_TZOFFSETFROM, "TZOFFSETFROM"},
+       {VCALENDAR_FIELD_TZOFFSETTO, "TZOFFSETTO"},
+       {VCALENDAR_FIELD_TZURL, "TZURL"},
+       {VCALENDAR_FIELD_URL, "URL"},
+       {VCALENDAR_FIELD_UID, "UID"},
+       {VCALENDAR_FIELD_VALARM, "VALARM"},
+       {VCALENDAR_FIELD_VCALENDAR, "VCALENDAR"},
+       {VCALENDAR_FIELD_VEVENT, "VEVENT"},
+       {VCALENDAR_FIELD_VFREEBUSY, "VFREEBUSY"},
+       {VCALENDAR_FIELD_VJOURNAL, "VJOURNAL"},
+       {VCALENDAR_FIELD_VTIMEZONE, "VTIMEZONE"},
+       {VCALENDAR_FIELD_VTODO, "VTODO"},
+       {VCALENDAR_FIELD_X_FUNAMBOL_ALLDAY, "X-FUNAMBOL-ALLDAY"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_begin_end[] = {
+       {VCALENDAR_FIELD_BEGIN_END_VCALENDAR, "VCALENDAR"},
+       {VCALENDAR_FIELD_BEGIN_END_VEVENT, "VEVENT"},
+       {VCALENDAR_FIELD_BEGIN_END_VTODO, "VTODO"},
+       {VCALENDAR_FIELD_BEGIN_END_VJOURNAL, "VJOURNAL"},
+       {VCALENDAR_FIELD_BEGIN_END_VFREEBUSY, "VFREEBUSY"},
+       {VCALENDAR_FIELD_BEGIN_END_VTIMEZONE, "VTIMEZONE"},
+       {VCALENDAR_FIELD_BEGIN_END_VALARM, "VALARM"},
+       {VCALENDAR_FIELD_BEGIN_END_STANDARD, "STANDARD"},
+       {VCALENDAR_FIELD_BEGIN_END_DAYLIGHT, "DAYLIGHT"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_version[] = {
+       {-1, VCALENDAR_VERSION}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_categories[] = {
+       {VCALENDAR_FIELD_CATEGORIES_APPOINTMENT, "APPOINTMENT"},
+       {VCALENDAR_FIELD_CATEGORIES_HOLIDAY, "HOLIDAY"},
+       {VCALENDAR_FIELD_CATEGORIES_BUSINESS, "BUSINESS"},
+       {VCALENDAR_FIELD_CATEGORIES_SPECIAL_OCCASION, "SPECIAL OCCASION"},
+       {VCALENDAR_FIELD_CATEGORIES_IMPORTANT, "IMPORTANT"},
+       {VCALENDAR_FIELD_CATEGORIES_BIRTHDAY, "BIRTHDAY"},
+       {VCALENDAR_FIELD_CATEGORIES_MISSCELLANEOUS, "MISSCELLANEOUS"}
+};
+
+static vcalendar_field_list_s vcalendar_field_list_status[] = {
+       {VCALENDAR_FIELD_STATUS_NEEDS_ACTION, "NEEDS ACTION"},
+       {VCALENDAR_FIELD_STATUS_COMPLETED, "COMPLETED"}
+};
+
+#endif                         /* IN_DATASTORE_INFO_VCALENDAR_H_ */
diff --git a/src/fw-plugins/common-public/vcalendar/src/encoding_util.c b/src/fw-plugins/common-public/vcalendar/src/encoding_util.c
new file mode 100755 (executable)
index 0000000..429041e
--- /dev/null
@@ -0,0 +1,892 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "encoding_util.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "ENCODING_UTIL"
+#endif
+
+#define TYPE_CHECK_BUF_SIZE                    100     /* temporary definition */
+#define TEMP_BUFFER_SIZE                               1024    /* temporary definition */
+
+/* BASE64 TABLE */
+static char base64_table[65] = {
+       'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
+       'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
+       'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a',
+       'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+       'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
+       't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1',
+       '2', '3', '4', '5', '6', '7', '8', '9', '+',
+       '/', '='
+};
+
+/* Quoted-Printable */
+static char *_dec_to_hex(int dec);
+static int _hex_to_dec(char *hex);
+
+/* Base64 */
+static int _find_base(char ch);
+
+/*
+ *     Quoted-Printable
+ */
+int encode_qp(char *src, int src_len, char **en_src, int *en_src_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+       char *en_hex;
+       int i = 0;
+       int j = 0;
+       int size_cnt = 0;
+
+       if (src == NULL) {
+               _DEBUG_ERROR("[encoding_util] src is NULL\n");
+               return 0;
+       }
+
+       /*encoded string length is three times longer than existing maximum string length */
+       int full_lenth = src_len * 3 + 1 + (int)(src_len * 3 / 76) * 3;
+       *en_src = (char *)malloc(sizeof(char) * full_lenth);
+       if (*en_src == NULL) {
+               _DEBUG_ERROR("[encoding_util] malloc fail !!\n");
+               return 0;
+       }
+       memset(*en_src, 0x00, src_len * 3 + 1);
+
+       _DEBUG_INFO("[encoding_util] src_len : %d\n", src_len);
+       for (i = 0; i < src_len; i++) {
+               /* _DEBUG_INFO("[encoding_util] i : %d\n", i); */
+               if (size_cnt >= QP_SIZE - 3) {
+                       size_cnt = 0;
+                       (*en_src)[j++] = 0x3D;
+                       (*en_src)[j++] = 0x0D;
+                       (*en_src)[j++] = 0x0A;
+               }
+
+               if ((src[i] >= 33 && src[i] <= 126) || (src[i] == 0x0A) || (src[i] == 0x0D)) {
+                       if (src[i] == 61 || src[i] == 0x0A || src[i] == 0x0D) {
+                               en_hex = _dec_to_hex(src[i]);
+                               (*en_src)[j++] = 0x3D;  /* '=' */
+                               (*en_src)[j++] = en_hex[0];
+                               (*en_src)[j++] = en_hex[1];
+                               size_cnt += 3;
+                       } else {
+                               size_cnt++;
+                               (*en_src)[j++] = src[i];
+                       }
+               } else if (src[i] == 9 || src[i] == 32) {
+                       if (src[i + 1] == 0x0A || src[i + 1] == '\0') { /* TAB or WhiteSpace */
+                               en_hex = _dec_to_hex(src[i]);
+                               (*en_src)[j++] = 0x3D;  /* '=' */
+                               (*en_src)[j++] = en_hex[0];
+                               (*en_src)[j++] = en_hex[1];
+                               size_cnt += 3;
+                       } else {
+                               size_cnt++;
+                               (*en_src)[j++] = src[i];
+                       }
+               } else {
+                       en_hex = _dec_to_hex(src[i]);
+                       (*en_src)[j++] = 0x3D;  /* '=' */
+                       (*en_src)[j++] = en_hex[0];
+                       (*en_src)[j++] = en_hex[1];
+                       _DEBUG_INFO("[encoding_util] en_src : %s\n", *en_src);
+                       size_cnt += 3;
+               }
+       }
+
+       (*en_src)[j] = 0x00;
+       *en_src_len = size_cnt;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int decode_qp(char *src, int src_len, char **de_src, int *de_src_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+       char hex[3];
+       char ch;
+       int dec = 0;
+       int i = 0;
+       int j = 0;
+       int is_space = 0;
+       int is_equal = 0;
+
+       if (src == NULL) {
+               _DEBUG_ERROR("[encoding_util] src is NULL\n");
+               return 0;
+       }
+
+       *de_src = (char *)malloc(sizeof(char) * (src_len + 1));
+       if (*de_src == NULL) {
+               _DEBUG_ERROR("[encoding_util] malloc is fail !!\n");
+               return 0;
+       }
+       memset(*de_src, 0x00, sizeof(char) * (src_len + 1));
+
+       while (src[i] != '\0') {
+               if (src[i] == 0x3D) {   /* '=' */
+                       /* check whiteSpace */
+                       ch = src[++i];
+
+                       /* '=' skip if next character is a TAB or WhiteSpace */
+                       while (ch == 0x09 || ch == 0x20) {
+                               is_space = 1;
+                               ch = src[++i];
+                               break;
+                       }
+
+                       if (is_space == 1) {
+                               is_space = 0;
+                               continue;
+                       }
+
+                       /* '=' skip if next character is 3D which means '=' (encoding error case ??) */
+                       while (ch == '3') {
+                               ch = src[++i];
+
+                               if (ch == 'D') {
+                                       is_equal = 1;
+                                       ch = src[++i];
+                                       break;
+                               }
+                       }
+
+                       if (is_equal == 1) {
+                               is_equal = 0;
+                               goto insert_equal;
+                       }
+
+                       /* if next character is LF after '=' do doft line break
+                        * encoded QP string on one line 76 character is allowed
+                        */
+                       if (ch == 0x0D) {       /* LF */
+                               ch = src[++i];
+                               if (ch == 0x0A) {
+                                       ch = src[++i];
+                                       continue;
+                               }
+                       }
+
+                       hex[0] = src[i++];
+                       hex[1] = src[i++];
+                       hex[2] = '\0';
+
+                       dec = _hex_to_dec(hex);
+
+                       /* decoding error */
+                       if (dec < 0) {
+                               /* when error occur, restore the previous encoding message */
+                               (*de_src)[j++] = 0x3D;  /* '=' */
+                               (*de_src)[j++] = hex[0];
+                               (*de_src)[j++] = hex[1];
+                       } else {
+                               (*de_src)[j++] = dec;
+                       }
+                       continue;
+               } else if (src[i] > 0x7E) {     /* encoding error */
+                       i++;    /* ignore that character */
+                       continue;
+               } else {
+                       (*de_src)[j++] = src[i++];
+                       continue;
+               }
+
+ insert_equal:
+               (*de_src)[j++] = 0x3D;
+       }
+
+       (*de_src)[j] = '\0';
+       *de_src_len = j;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+static char *_dec_to_hex(int dec)
+{
+       _INNER_FUNC_ENTER;
+
+       static char hex[3];
+       int i;
+       int ch;
+
+       for (i = 0; i < 2; i++) {
+               if (i == 0) {
+                       ch = (dec & 0xF0) >> 4;
+               } else if (i == 1) {
+                       ch = (dec & 0x0F);
+               }
+
+               if (ch >= 10) {
+                       hex[i] = 'A' + ch - 10;
+               } else {
+                       hex[i] = '0' + ch;
+               }
+       }
+
+       hex[i] = 0x00;
+
+       _DEBUG_TRACE("[encoding_util] hex : %s\n", hex);
+
+       _INNER_FUNC_EXIT;
+
+       return &hex[0];
+}
+
+static int _hex_to_dec(char *hex)
+{
+       _INNER_FUNC_ENTER;
+
+       int dec = 0;
+       int byte;
+       int i = 0;
+
+       for (i = 0; i < 2; i++) {
+               if (hex[i] >= '0' && hex[i] <= '9') {
+                       byte = hex[i] - '0';
+               } else if (hex[i] >= 'A' && hex[i] <= 'F') {
+                       byte = hex[i] - 'A' + 10;
+               } else if (hex[i] >= 'a' && hex[i] <= 'f') {
+                       byte = hex[i] - 'a' + 10;
+               } else {
+                       byte = -1;
+               }
+
+               if (byte < 0)
+                       return -1;
+
+               dec += (i == 0) ? byte << 4 : byte;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return dec;
+}
+
+/*
+ *     Base64
+ */
+int encode_base64(char *src, int src_len, char **en_src, int *en_src_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+       int i = 0;
+       int j = 0;
+       int cnt = 0;
+       int ch = 0;
+       int size_cnt = 0;
+
+       if (src == NULL) {
+               _DEBUG_ERROR("[encoding_util] src is NULL\n");
+               return 0;
+       }
+
+       *en_src = (char *)malloc(sizeof(char) * (src_len * 2));
+
+       if (*en_src == NULL) {
+               _DEBUG_ERROR("[encoding_util] malloc fail !!\n");
+               return 0;
+       }
+       memset(*en_src, 0x00, src_len * 2);
+
+       while (1) {
+               switch (cnt++) {
+               case 0:
+                       {
+                               if (i < src_len) {
+                                       ch = (src[i] & 0xFC) >> 2;
+                               } else {
+                                       ch = -1;
+                               }
+                       }
+                       break;
+
+               case 1:
+                       {
+                               if (i < src_len) {
+                                       if (i + 1 < src_len) {
+                                               ch = ((src[i] & 0x03) << 4) | ((src[i + 1] & 0xF0) >> 4);
+                                       } else {
+                                               ch = ((src[i] & 0x03) << 4);
+                                       }
+                               } else {
+                                       ch = -1;
+                               }
+                               i++;
+                               break;
+                       }
+
+               case 2:
+                       {
+                               if (i < src_len) {
+                                       if (i + 1 < src_len) {
+                                               ch = ((src[i] & 0x0F) << 2) | ((src[i] & 0xC0) >> 6);
+                                       } else {
+                                               ch = ((src[i] & 0x0F) << 2);
+                                       }
+                               } else {
+                                       ch = -1;
+                               }
+                               i++;
+                       }
+                       break;
+
+               case 3:
+                       {
+                               if (i < src_len) {
+                                       ch = (src[i] & 0x3F);
+                               } else {
+                                       ch = -1;
+                               }
+                               i++;
+                               cnt = 0;
+                       }
+                       break;
+               }
+
+               /*
+                  if (ch >= 0 && ch <= 25) {           // Upper Case Alphabet
+                  (*en_src)[j++] = 'A' + ch;
+                  } else if (ch >= 26 && ch <= 51) {           // Lower Case Alphabet
+                  (*en_src)[j++] = 'a' + ch - 26;
+                  } else if (ch >= 52 && ch <= 61) {           // Digit
+                  (*en_src)[j++] = '0' + ch - 52;
+                  } else if (ch == 62) {
+                  (*en_src)[j++] = '+';
+                  } else if (ch == 63) {
+                  (*en_src)[j++] = '/';
+                  } else if (ch == -1) {
+                  (*en_src)[j++] = '=';                // padding
+                  }
+                */
+
+               if ((ch != -1) && (ch >= 0 && ch <= 64)) {
+                       (*en_src)[j++] = base64_table[ch];
+               } else {
+                       (*en_src)[j++] = base64_table[64];      /* padding */
+               }
+
+               size_cnt++;
+
+               if (j % 4 == 0) {
+                       if (size_cnt == BASE64_SIZE) {
+                               size_cnt = 0;
+                               (*en_src)[j++] = 0x0A;  /* soft line break */
+                       }
+
+                       if (i >= src_len)
+                               break;
+               }
+       }
+
+       (*en_src)[j] = 0x00;
+       *en_src_len = j;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int decode_base64(char *src, int src_len, char **de_src, int *de_src_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+       long tmp = 0;           /* 4byte (using decoding) */
+       int i = 0;
+       int j = 0;
+       int cnt = 0;
+       int pad_cnt = 0;
+
+       if (src == NULL) {
+               _DEBUG_ERROR("[encoding_util] src is NULL\n");
+               return 0;
+       }
+
+       /* de_src is enough for the src_len 3/4 size */
+       *de_src = (char *)malloc(sizeof(char) * (src_len));
+       if (*de_src == NULL) {
+               _DEBUG_ERROR("malloc error !!");
+               return 0;
+       }
+       memset(*de_src, 0x00, src_len);
+
+       if (*de_src == NULL) {
+               _DEBUG_ERROR("[encoding_util] malloc is fail !!\n");
+               return 0;
+       }
+
+       while (src[i] != '\0') {
+               /*
+                  if (isupper(src[i])) {
+                  tmp = (tmp << 6) | (src[i] - 'A');           // Upper case : 0 ~ 25
+                  } else if (islower(src[i])) {
+                  tmp = (tmp << 6) | (src[i] - 'a' + 0x1A);            // Lower case : 26(0x1A) ~ 51
+                  } else if (isdigit(src[i])) {
+                  tmp = (tmp << 6) | (src[i] - '0' + 0x34);    // Number : 52(0x34) ~ 61
+                  } else if (src[i] == '+') {
+                  tmp = (tmp << 6) | 0x3E;             // '+' : 62(0x3E)
+                  } else if (src[i] == '/') {
+                  tmp = (tmp << 6) | 0x3F;                     // '/' : 63(0x3F)
+                  } else if (src[i] == '=') {
+                  pad_cnt++;
+                  tmp = (tmp << 6);                                    // '=' : padding
+                  } else {
+                  tmp = (tmp << 6);                                    // encoding error
+                  f_DEBUG_INFO(stdout, "encoding error !! \n");
+                  }
+                */
+
+               tmp = (tmp << 6) | (_find_base(src[i]));
+               if (tmp == 64) {
+                       pad_cnt++;
+               } else if (tmp == -1) {
+                       _DEBUG_ERROR("[encoding_util] encoding error \n");
+               }
+
+               if (++cnt >= 4) {
+                       (*de_src)[j++] = (char)((tmp & 0x00FF0000) >> 16);
+                       (*de_src)[j++] = (char)((tmp & 0x0000FF00) >> 8);
+                       (*de_src)[j++] = (char)(tmp & 0x000000FF);
+
+                       cnt = 0;
+                       tmp = 0;
+
+                       if (src[i + 1] == 0x0A) {       /* soft line break */
+                               i++;
+                       }
+               }
+
+               i++;
+       }
+
+       (*de_src)[j - pad_cnt] = '\0';
+       *de_src_len = j - pad_cnt;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int proc_decoding(const char *src, int src_len, char **de_src, int *de_src_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(src == NULL, 0, "[encoding_util] src is NULL\n");
+
+       const char *reg_src = NULL;
+       reg_src = src;
+
+       _DEBUG_INFO("[encoding_util] << src >> \n%s\n", src);
+
+       *de_src = (char *)malloc(sizeof(char) * (src_len + 1));
+       if (*de_src == NULL) {
+               _DEBUG_INFO("[encoding_util] malloc error !! \n");
+
+               return 0;
+       }
+       memset(*de_src, 0x00, sizeof(char) * (src_len + 1));
+
+       char colon[] = ":";
+       char line_breaker[] = "\r\n";
+       char *start_decoding = NULL;
+       int data_size = 0;
+       int res = 0;
+       int de_temp_len = 0;
+       int len = 0;
+
+       char *de_temp = (char *)malloc(sizeof(char) * TEMP_BUFFER_SIZE);        /* todo : temporary */
+       if (de_temp == NULL) {
+               _DEBUG_ERROR("[encoding_util] malloc error !!\n");
+
+               if (*de_src != NULL)
+                       free(*de_src);
+
+               return 0;
+       }
+
+       while ((start_decoding = strstr(src, "ENCODING="))) {
+               char *charset_loc = strstr(src, "CHARSET=");
+               char *colon_loc = strstr(start_decoding, colon);        /* find ':''s location */
+               char *line_breaker_loc = 0;
+
+               /*edited code for line beaker */
+               char *colon_loc_temp = colon_loc;
+               while (line_breaker_loc == NULL) {
+                       if(colon_loc_temp == NULL) {
+                               _DEBUG_ERROR("[encoding_util] colon_loc_temp is NULL !!\n");
+                               if(de_temp != NULL)
+                                       free(de_temp);
+                               if (*de_src != NULL)
+                                       free(*de_src);
+                               return 0;
+                       }
+                       line_breaker_loc = strstr(colon_loc_temp, line_breaker);        /* find "\r\n"'s location */
+                       if (line_breaker_loc > colon_loc_temp && !strncmp(line_breaker_loc - 1, "=", 1)) {
+                               colon_loc_temp = line_breaker_loc + 1;
+                               line_breaker_loc = 0;
+                       }
+               }
+
+               /*
+                *      if find "ENCODING=" do strcat data until ":" to de_src
+                */
+               if (charset_loc != NULL) {
+                       if (start_decoding > charset_loc) {     /* CHARSET=UTF-8;ENCODING=abcxx: */
+                               data_size = (charset_loc - 1) - src;
+                       } else {        /* ENCODING=abcxxx;CHARSET=UTF-8:       */
+                               data_size = (start_decoding - 1) - src;
+                       }
+               } else {
+                       data_size = (start_decoding - 1) - src;
+               }
+
+               char *temp = (char *)malloc(sizeof(char) * (data_size + 1));
+               if (temp == NULL) {
+                       _DEBUG_ERROR("[encoding_util] malloc error !!");
+
+                       if (*de_src != NULL)
+                               free(*de_src);
+
+                       if (de_temp != NULL)
+                               free(de_temp);
+
+                       return 0;
+               }
+               memset(temp, 0x00, sizeof(char) * (data_size + 1));
+               memcpy(temp, src, data_size);
+
+               len = g_strlcat(*de_src, temp, (src_len + 1));
+               if (len >= (src_len + 1)) {
+                       _DEBUG_ERROR("*de_src buffer overflow !!");
+
+                       if (*de_src != NULL)
+                               free(*de_src);
+
+                       if (de_temp != NULL)
+                               free(de_temp);
+
+                       if (temp != NULL)
+                               free(temp);
+
+                       return 0;
+               }
+
+               (*de_src)[strlen(*de_src)] = ':';
+               if (temp != NULL)
+                       free(temp);
+
+               _DEBUG_INFO("[encoding_util] << *de_src >> \n %s\n", *de_src);
+
+               /*
+                *              copy data from ":" until "\r\n"(actual encoding stream)
+                */
+               data_size = line_breaker_loc - colon_loc;       /* from ':' until "\r\n" + '\0' */
+               char *value = (char *)malloc(sizeof(char) * (data_size + 1));
+               if (value == NULL) {
+                       _DEBUG_ERROR("[encoding_util] malloc error !!\n");
+
+                       if (*de_src != NULL)
+                               free(*de_src);
+
+                       if (de_temp != NULL)
+                               free(de_temp);
+
+                       return 0;
+               }
+               memset(value, 0x00, sizeof(char) * (data_size + 1));
+               memcpy(value, ++colon_loc, data_size);  /* from ':' until "\r\n" */
+               value[data_size] = '\0';
+               _DEBUG_INFO("[encoding_util] data len is [%d] and value is [%s]\n\n", data_size, value);
+               /*
+                *      Get encoding type using data from "ENCODING=" to ":"
+                */
+               char type_check[TYPE_CHECK_BUF_SIZE] = { 0, };
+               int type_check_size = colon_loc - start_decoding;
+               strncpy(type_check, start_decoding, type_check_size);
+               _DEBUG_INFO("[encoding_util] type check : %s\n", type_check);
+               encoding_type_e type = find_encoding_type((const char *)type_check);
+
+               /*
+                *              Process decoding by passing the actual value and encoding type to decode_value()
+                */
+               de_temp_len = 0;
+               memset(de_temp, 0x00, sizeof(char) * TEMP_BUFFER_SIZE); /* todo : temporary */
+
+               res = decode_value(type, value, data_size, &de_temp, &de_temp_len);
+
+               if (res != 1) {
+                       _DEBUG_ERROR("[encoding_util] decode_value error !!\n");
+
+                       if (*de_src != NULL)
+                               free(*de_src);
+
+                       if (de_temp != NULL)
+                               free(de_temp);
+
+                       if (value != NULL)
+                               free(value);
+
+                       return 0;
+               }
+
+               /*
+                *      Append decoded data to de_src
+                */
+               _DEBUG_INFO("[encoding_util] de_temp : %s\n", de_temp);
+               len = 0;
+               len = g_strlcat(*de_src, de_temp, (src_len + 1));
+               if (len >= (src_len + 1)) {
+                       _DEBUG_ERROR("*de_src buffer overflow !!");
+
+                       if (*de_src != NULL)
+                               free(*de_src);
+
+                       if (de_temp != NULL)
+                               free(de_temp);
+
+                       if (value != NULL)
+                               free(value);
+
+                       return 0;
+               }
+
+               /*
+                *      find "ENCODING=" since "\r\n" agina
+                */
+               src = line_breaker_loc;
+
+               if (value != NULL)
+                       free(value);
+       }
+
+       len = 0;
+       len = g_strlcat(*de_src, src, (src_len + 1));
+       if (len >= (src_len + 1)) {
+               _DEBUG_ERROR("*de_src buffer overflow !!");
+
+               if (*de_src != NULL)
+                       free(*de_src);
+
+               if (de_temp != NULL)
+                       free(de_temp);
+
+               return 0;
+       }
+
+       *de_src_len = strlen(*de_src);
+       _DEBUG_INFO("[encoding_util] changed src : \n%s ( %d ) \n", *de_src, *de_src_len);
+
+       if (de_temp != NULL)
+               free(de_temp);
+
+       _DEBUG_INFO("[encoding_util] End \n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+int check_encoding_data(const char *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (strstr(data, "ENCODING=") != NULL) {
+               _DEBUG_INFO("[encoding_util] exist encoding data !! \n");
+               _EXTERN_FUNC_EXIT;
+               return 1;
+       } else {
+               _DEBUG_INFO("[encoding_util] not exist encoding data !! \n");
+               _EXTERN_FUNC_EXIT;
+               return 0;
+       }
+}
+
+encoding_type_e find_encoding_type(const char *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[encoding_util] Start !! \n");
+
+       encoding_type_e type = EN_TYPE_NONE;
+       if (strstr(data, "QUOTED-PRINTABLE") != NULL) {
+               _DEBUG_INFO("[encoding_util] type : QP\n");
+               type = EN_TYPE_QUOTED_PRINTABLE;
+       } else if (strstr(data, "BASE64") != NULL) {
+               _DEBUG_INFO("[encoding_util] type : BASE64\n");
+               type = EN_TYPE_BASE64;
+       } else {
+               _DEBUG_INFO("[encoding_util] not supported type !! \n");
+       }
+
+       _DEBUG_INFO("[encoding_util] End !! \n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return type;
+}
+
+int decode_value(encoding_type_e type, const char *value, int value_size, char **decode_str, int *decode_str_len)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(value == NULL, 0, "[encoding_util] value is NULL\n");
+
+       int res = 1;
+       const char *start_pos = NULL;
+       const char *cursor = NULL;
+       int semi_cnt = 0;
+       int len = 0;
+
+       /*
+        *      ex> value - =EA=B9=80;=EC=B2=A0=EC=88=98;;;\0
+        */
+       cursor = value;
+       start_pos = value;
+
+       while (*cursor != '\0') {
+               if ((*cursor != ';') && (*(cursor + 1) != '\0')) {
+                       cursor++;
+                       continue;
+               } else if (*cursor == ';') {
+                       semi_cnt++;
+               }
+
+               int data_size = 0;
+               if (*cursor == ';')
+                       data_size = cursor - start_pos;
+               else            /* case of [*(cursor+1)=='\0'] */
+                       data_size = cursor + 1 - start_pos;
+
+               if (data_size == 0) {
+                       cursor++;
+                       start_pos++;
+               } else {
+                       char *temp = (char *)malloc(sizeof(char) * (value_size + 1));
+                       if (temp == NULL) {
+                               _DEBUG_ERROR("[encoding_util] malloc error !!");
+                               return 0;
+                       }
+                       memset(temp, 0x00, sizeof(char) * (value_size + 1));
+                       memcpy(temp, start_pos, data_size);
+
+                       _DEBUG_INFO("[encoding_util] temp : %s \n", temp);
+
+                       char *decoding = 0;
+                       int decoding_len = 0;
+
+                       switch (type) {
+                       case EN_TYPE_QUOTED_PRINTABLE:
+                               res = decode_qp(temp, data_size, &decoding, &decoding_len);
+                               break;
+                       case EN_TYPE_BASE64:
+                               res = decode_base64(temp, data_size, &decoding, &decoding_len);
+                               break;
+                       default:
+                               break;
+                       }
+
+                       if (temp != NULL)
+                               free(temp);
+
+                       _DEBUG_INFO("[encoding_util] decoding : %s ( %d )\n", decoding, decoding_len);
+
+                       if (res != 1) {
+                               _DEBUG_ERROR("[encoding_util] decoding error !! \n");
+
+                               if (decoding != NULL)
+                                       free(decoding);
+
+                               res = 0;
+                               return res;
+                       }
+
+                       len = g_strlcat(*decode_str, decoding, TEMP_BUFFER_SIZE);
+                       if (len >= TEMP_BUFFER_SIZE) {
+                               _DEBUG_ERROR("*decode_str buffer overflow !!");
+
+                               if (decoding != NULL)
+                                       free(decoding);
+
+                               res = 0;
+                               return res;
+                       }
+
+                       _DEBUG_INFO("[encoding_util] *decode_str : %s\n", *decode_str);
+
+                       if (decoding != NULL)
+                               free(decoding);
+
+                       cursor++;
+                       start_pos = cursor;
+               }
+
+               if (semi_cnt > 0) {
+                       int len = strlen(*decode_str);
+                       (*decode_str)[len] = ';';
+                       _DEBUG_INFO("[encoding_util] *decode_str : %s ( %d )\n", *decode_str, strlen(*decode_str));
+                       semi_cnt--;
+               }
+       }
+
+       *decode_str_len = strlen(*decode_str);
+
+       _DEBUG_INFO("[encoding_util] *decode_str : %s ( %d )\n", *decode_str, *decode_str_len);
+
+       _DEBUG_INFO("[encoding_util] End !! \n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
+
+static int _find_base(char ch)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+       for (i = 0; i < 65; i++) {
+               if (base64_table[i] == ch) {
+                       _DEBUG_TRACE("[encoding_util] End !! \n");
+                       _INNER_FUNC_EXIT;
+                       return i;
+               }
+       }
+
+       return -1;
+}
diff --git a/src/fw-plugins/common-public/vcalendar/src/plugin_interface.c b/src/fw-plugins/common-public/vcalendar/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..afc2b4b
--- /dev/null
@@ -0,0 +1,1116 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib/gprintf.h>
+
+#include "encoding_util.h"
+#ifdef old_api
+#include "calendar-svc-provider.h"
+#else
+#include <calendar2.h>
+#include <calendar_types2.h>
+#endif
+
+#include "in_datastore_info_vcalendar.h"
+
+/* for log */
+#include "utility/sync_util.h"
+
+#include "plugin/data_converter_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DC_VCALENDAR"
+#endif
+
+static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count);
+static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list);
+#ifdef old_api
+static sync_agent_da_return_e _convert_service_error_to_common_error(cal_error err);
+#else
+static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err);
+#endif
+
+#ifdef old_api
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       cal_struct *temp_service_data = 0;
+       const char *temp_agent_data = (const char *)agent_data;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+       int allday = 0;
+       if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
+               allday = 1;
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+       if (temp_agent_data == NULL) {
+               _DEBUG_ERROR("inputed temp_agent_data is null");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+       /*using new interface */
+       GList *l, *schedules = NULL;
+       err = calendar_svc_read_schedules(temp_agent_data, &schedules);
+       if (err < CAL_SUCCESS) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Fail! err[%d]\n", err);
+               ret = _convert_service_error_to_common_error(err);
+               *service_data = NULL;
+       } else {
+               if (schedules == NULL) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_read_schedules() -> temp_service_data is null, err[%d] !!", err);
+                       return SYNC_AGENT_DA_ERRORS;
+               }
+               temp_service_data = schedules->data;
+
+               err = calendar_svc_struct_set_str(temp_service_data, CALS_VALUE_TXT_DTSTART_TZID, "Asia/Seoul");
+               if (err != CAL_SUCCESS) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
+                       /*i think when set return fail then going throw input schesule */
+               }
+
+               err = calendar_svc_struct_set_str(temp_service_data, CALS_VALUE_TXT_DTEND_TZID, "Asia/Seoul");
+               if (err != CAL_SUCCESS) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
+                       /*i think when set return fail then going throw input schesule */
+               }
+
+               /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+//              if (allday) {
+//                      cal_struct *item = (cal_struct *) temp_service_data;
+//
+//                      _DEBUG_INFO(" CAL_VALUE_INT_ALL_DAY_EVENT = %d ", calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT));
+//
+//                      if (!calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT)) {
+//                              _DEBUG_INFO("[Debug] X-ALLDAY flag set in vCalendar, but not in calendar service structure after conversion !!!");
+//                              calendar_svc_struct_set_int(item, CAL_VALUE_INT_ALL_DAY_EVENT, 1);
+//                      }
+//              }
+               /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+               *service_data = (void *)temp_service_data;
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Success!\n");
+
+               /*remove another calendar */
+               l = schedules;
+               l = g_list_next(l);
+               while (l) {
+                       cal_struct *item = l->data;
+                       if (item == NULL) {
+                               l = g_list_next(l);
+                               continue;
+                       }
+                       l = g_list_next(l);
+
+                       calendar_svc_struct_free(&item);
+               }
+       }
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#else
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_converter(const void *agent_data, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "agent_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = CALENDAR_ERROR_NONE;
+       calendar_record_h temp_service_data = NULL;
+       const char *temp_agent_data = (const char *)agent_data;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+       int allday = 0;
+       if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
+               allday = 1;
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+       if (temp_agent_data == NULL) {
+               _DEBUG_ERROR("inputed temp_agent_data is null");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+       /*using new interface */
+       calendar_list_h schedules = NULL;
+
+       service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &schedules);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               *service_data = NULL;
+       } else {
+               if (schedules == NULL) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() -> temp_service_data is null, err[%d] !!", service_ret);
+                       return SYNC_AGENT_DA_ERRORS;
+               }
+
+               service_ret = calendar_list_first(schedules);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+               }
+
+               service_ret = calendar_list_get_current_record_p(schedules, &temp_service_data);
+               if ((service_ret != CALENDAR_ERROR_NONE) && (temp_service_data == NULL)) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+               }
+
+               service_ret = calendar_record_set_str(temp_service_data, _calendar_event.start_tzid, "Asia/Seoul");
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+                       /*i think when set return fail then going throw input schedule */
+               }
+
+               service_ret = calendar_record_set_str(temp_service_data, _calendar_event.end_tzid, "Asia/Seoul");
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+                       /*i think when set return fail then going throw input schedule */
+               }
+
+               *service_data = (void *)temp_service_data;
+
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Success!\n");
+               if (schedules != NULL) {
+                       service_ret = calendar_list_destroy(schedules, false);
+                       if (service_ret != CALENDAR_ERROR_NONE) {
+                               _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+                       }
+                       schedules = NULL;
+               }
+       }
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#endif
+
+#ifdef old_api
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+       retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       cal_struct *temp_new_service_data = 0;
+       cal_struct *temp_old_service_data = (cal_struct *) old_service_data;
+       const char *temp_agent_data = (const char *)agent_data;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+       int allday = 0;
+
+       if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
+               allday = 1;
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+       if (temp_agent_data == NULL) {
+               _DEBUG_ERROR("inputed temp_agent_data is null");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /* convert */
+       _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules !!");
+
+       /*using new interface */
+       GList *l, *schedules = NULL;
+       err = calendar_svc_read_schedules(temp_agent_data, &schedules);
+       if (err < CAL_SUCCESS) {
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *new_service_data = 0;
+       } else {
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() success!\n");
+               temp_new_service_data = schedules->data;
+
+               /*index moving */
+               int n_cal_struct_index = calendar_svc_struct_get_int(temp_old_service_data, CAL_VALUE_INT_INDEX);
+               err = calendar_svc_struct_set_int(temp_new_service_data, CAL_VALUE_INT_INDEX, n_cal_struct_index);
+               if (err != CAL_SUCCESS) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_int() Fail! err[%d]\n", err);
+                       return SYNC_AGENT_DA_ERRORS;
+               }
+
+               err = calendar_svc_struct_set_str(temp_new_service_data, CALS_VALUE_TXT_DTSTART_TZID, "Asia/Seoul");
+               if (err != CAL_SUCCESS) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_svc_struct_set_str() Fail! err[%d]\n", err);
+                       /*i think when set return fail then going throw input schesule */
+               }
+               /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+//              if (allday) {
+//                      cal_struct *item = (cal_struct *) temp_new_service_data;
+//
+//                      _DEBUG_INFO(" CAL_VALUE_INT_ALL_DAY_EVENT = %d ", calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT));
+//
+//                      if (!calendar_svc_struct_get_int(item, CAL_VALUE_INT_ALL_DAY_EVENT)) {
+//                              _DEBUG_INFO("[Debug] X-ALLDAY flag set in vCalendar, but not in calendar service structure after conversion !!!");
+//                              calendar_svc_struct_set_int(item, CAL_VALUE_INT_ALL_DAY_EVENT, 1);
+//                      }
+//              }
+               /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+               /*remove another calendar */
+               l = schedules;
+               l = g_list_next(l);
+               while (l) {
+                       cal_struct *item = l->data;
+                       if (item == NULL) {
+                               l = g_list_next(l);
+                               continue;
+                       }
+                       l = g_list_next(l);
+
+                       calendar_svc_struct_free(&item);
+               }
+
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules() Success!\n");
+               *new_service_data = (void *)temp_new_service_data;
+       }
+
+       /*  memory free */
+       if (temp_old_service_data != NULL)
+               calendar_svc_struct_free(&temp_old_service_data);
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#else
+
+sync_agent_da_return_e _temp_merge_record_new_to_old(calendar_record_h old_service_data, calendar_record_h new_service_data)
+{
+       _EXTERN_FUNC_ENTER;
+       retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+       retvm_if(new_service_data == NULL, SYNC_AGENT_DA_ERRORS, "new_service_data is NULL. FAIL !!!");
+
+       int service_ret = 0;
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       /*description */
+       char *description = 0;
+       service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.description, &description);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       service_ret = calendar_record_set_str(old_service_data, _calendar_event.description, description);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /*st time */
+       calendar_time_s cal_time_st = { 0, };
+       service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.start_time, &cal_time_st);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.start_time, cal_time_st);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /*end time */
+       calendar_time_s cal_time_ed = { 0, };
+       service_ret = calendar_record_get_caltime(new_service_data, _calendar_event.end_time, &cal_time_ed);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       service_ret = calendar_record_set_caltime(old_service_data, _calendar_event.end_time, cal_time_ed);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /*summary time */
+       char *summary = 0;
+       service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.summary, &summary);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       service_ret = calendar_record_set_str(old_service_data, _calendar_event.summary, summary);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /*location time */
+       char *location = 0;
+       service_ret = calendar_record_get_str_p(new_service_data, _calendar_event.location, &location);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       service_ret = calendar_record_set_str(old_service_data, _calendar_event.location, location);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set() Fail! err[%d]\n", service_ret);
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return ret;
+}
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_replace_converter(void *old_service_data, const void *agent_data, void **new_service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(old_service_data == NULL, SYNC_AGENT_DA_ERRORS, "old_service_data is NULL. FAIL !!!");
+       retvm_if(agent_data == NULL, SYNC_AGENT_DA_ERRORS, "agent_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = CALENDAR_ERROR_NONE;
+       calendar_record_h temp_new_service_data = NULL;
+       calendar_record_h temp_old_service_data = (calendar_record_h) old_service_data;
+       const char *temp_agent_data = (const char *)agent_data;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : START */
+       int allday = 0;
+
+       if (strstr((char *)agent_data, "\r\nX-ALLDAY:SET") != NULL)
+               allday = 1;
+       /* Temporary fix for KIES vCalendar X-ALLDAY tag : END */
+
+       if (temp_agent_data == NULL) {
+               _DEBUG_ERROR("inputed temp_agent_data is null");
+               return SYNC_AGENT_DA_ERRORS;
+       }
+
+       /* convert */
+       _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_read_schedules !!");
+
+       /*using new interface */
+       calendar_list_h schedules = NULL;
+       service_ret = calendar_vcalendar_parse_to_calendar(temp_agent_data, &schedules);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Fail! err[%d]\n", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               *new_service_data = NULL;
+       } else {
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() success!\n");
+
+               service_ret = calendar_list_first(schedules);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_first() Fail! : err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+               }
+
+               service_ret = calendar_list_get_current_record_p(schedules, &temp_new_service_data);
+               if ((service_ret != CALENDAR_ERROR_NONE) && (temp_new_service_data == NULL)) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_list_get_current_record_p() Fail! : err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+               }
+
+               /*index moving */
+//              int n_cal_struct_index = 0;
+//              service_ret = calendar_record_get_int(temp_old_service_data, _calendar_event.id, &n_cal_struct_index);
+//              if (service_ret != CALENDAR_ERROR_NONE) {
+//                      _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_get_int() Fail! err[%d]\n", service_ret);
+//              }
+//
+//              service_ret = calendar_record_set_int(temp_new_service_data, _calendar_event.id, n_cal_struct_index);
+//              if (service_ret != CALENDAR_ERROR_NONE) {
+//                      _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int() Fail! err[%d]\n", service_ret);
+//                      return SYNC_AGENT_DA_ERRORS;
+//              }
+
+               ret = _temp_merge_record_new_to_old(temp_old_service_data, temp_new_service_data);
+               if (ret != SYNC_AGENT_DA_SUCCESS) {
+                       _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_int() Fail! err[%d]\n", ret);
+                       /*i think when set return fail then going throw input schedule */
+               }
+//              service_ret = calendar_record_set_str(temp_new_service_data, _calendar_event.start_tzid, "Asia/Seoul");
+//              if (service_ret != CALENDAR_ERROR_NONE) {
+//                      _DEBUG_ERROR("[dc_vcalendar_plugIn] calendar_record_set_str() Fail! err[%d]\n", service_ret);
+//                      /*i think when set return fail then going throw input schedule*/
+//              }
+
+               *new_service_data = temp_old_service_data;
+       }
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_vcalendar_parse_to_calendar() Success!\n");
+       if (schedules != NULL) {
+               service_ret = calendar_list_destroy(schedules, false);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_list_destroy() Fail! : err = %d", service_ret);
+               }
+               schedules = NULL;
+       }
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#endif
+
+#ifdef old_api
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int err = 0;
+       char *temp_agent_data = 0;
+       cal_struct *temp_service_data = (cal_struct *) service_data;
+       int len = 0;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE/LAST MODIFIED tag : START */
+       int allday = 0;
+       char rrule[30];
+       memset(rrule, 0, 30);
+
+       cal_struct *item = (cal_struct *) temp_service_data;
+
+       _DEBUG_INFO("before calendar_svc_write_schedules");
+       if (CALS_TIME_LOCALTIME == calendar_svc_struct_get_int(item, CALS_VALUE_INT_DTSTART_TYPE)) {
+               _DEBUG_INFO("[Debug] Found X-ALLDAY flag set in calendar service structure before conversion !!!");
+               allday = 1;
+       }
+
+       /*      calendar service say it is supported */
+//      if (calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_TERM) != CAL_REPEAT_NONE) {
+//
+//              char repeat_end_date[16 + 1] = { 0 };
+//              char week_day_string[16 + 1] = { 0 };
+//
+//              struct tm *tm = calendar_svc_struct_get_tm(item, CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL);
+//
+//              memset(repeat_end_date, 0, 17);
+//
+//              snprintf(repeat_end_date, sizeof(repeat_end_date), "%04ld%02d%02dT%02d%02d%02dZ", tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+//
+//              _DEBUG_INFO(" repeat_end_date = %s ", repeat_end_date);
+//
+//              char str[50];
+//              memset(str, 0, 50);
+//
+//              switch (calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_TERM)) {
+//              case CAL_REPEAT_EVERY_DAY:
+//                      snprintf(str, sizeof(str), "D%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
+//                      break;
+//
+//              case CAL_REPEAT_EVERY_WEEK:
+//              case CAL_REPEAT_EVERY_WEEKDAYS:{
+//                              struct tm *tm_start = calendar_svc_struct_get_tm(item, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL);
+//
+//                              char *date_string[7] = { "SU", "MO", "TU", "WE", "TH", "FR", "SA" };
+//
+//                              struct tm temp;
+//                              time_t t = timegm(tm_start);
+//                              gmtime_r(&t, &temp);
+//
+//                              if (temp.tm_wday < 0 || temp.tm_wday > 6) {
+//                              } else {
+//                                      snprintf(week_day_string, 3, date_string[temp.tm_wday]);
+//                              }
+//
+//                              snprintf(str, sizeof(str), "W%d %s %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), week_day_string, repeat_end_date);
+//                      }
+//                      break;
+//
+//              case CAL_REPEAT_EVERY_MONTH:
+//              case CAL_REPEAT_EVERY_MONTH_DAY:
+//                      snprintf(str, sizeof(str), "MD%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
+//                      break;
+//
+//              case CAL_REPEAT_EVERY_YEAR:
+//              case CAL_REPEAT_EVERY_YEAR_DAY:
+//                      snprintf(str, sizeof(str), "YM%d %s", calendar_svc_struct_get_int(item, CAL_VALUE_INT_REPEAT_INTERVAL), repeat_end_date);
+//                      break;
+//
+//              default:
+//                      break;
+//              }
+//
+//              len = g_strlcat(rrule, "\r\nRRULE:", sizeof(rrule));
+//              len = g_strlcat(rrule, str, sizeof(rrule));
+//
+//              if (len >= sizeof(rrule)) {
+//                      _DEBUG_ERROR("rrule buffer overflow !!");
+//                      /* todo : exception handling */
+//              }
+//
+//              _DEBUG_INFO(" rrule = %s ", rrule);
+//      }
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
+
+       /* Reverse_Converter */
+       /*new */
+       _DEBUG_INFO("before calendar_svc_write_schedules");
+       GList *list = g_list_append(NULL, temp_service_data);
+       err = calendar_svc_write_schedules(list, &temp_agent_data);
+       _DEBUG_INFO("after calendar_svc_write_schedules");
+//      free(list);
+       /*old */
+//      err = calendar_svc_util_convert_event_to_vcs(temp_service_data, &temp_agent_data, &size);
+       if (err < CAL_SUCCESS) {
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Fail!\n");
+               ret = _convert_service_error_to_common_error(err);
+               *agent_data = 0;
+       } else {
+               /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : START */
+               if (strstr(temp_agent_data, "\r\nX-ALLDAY:SET") == NULL && allday) {
+                       char *vevent_loc = strstr(temp_agent_data, "\r\nEND:VEVENT");
+                       if (vevent_loc != NULL) {
+                               len = 0;
+                               int mod_data_len = strlen(temp_agent_data) + strlen("\r\nX-ALLDAY:SET") + 1;
+                               char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
+                               if (mod_data == NULL) {
+                                       _DEBUG_ERROR("mod_data is null");
+                                       ret = SYNC_AGENT_DA_ERRORS;
+                                       *agent_data = 0;
+                                       return ret;
+                               }
+
+                               strncpy(mod_data, temp_agent_data, vevent_loc - temp_agent_data);
+
+                               len = g_strlcat(mod_data, "\r\nX-ALLDAY:SET", mod_data_len);
+                               len = g_strlcat(mod_data, vevent_loc, mod_data_len);
+
+                               if (len >= mod_data_len) {
+                                       _DEBUG_ERROR("mod_data buffer overflow !!");
+                                       /* todo : exception handling */
+                               }
+
+                               free(temp_agent_data);
+                               temp_agent_data = mod_data;
+                       }
+                       char *dtstart_loc = strstr(temp_agent_data, "\r\nDTSTART:");
+                       if (dtstart_loc != NULL) {
+                               char *dtstart_z_loc = dtstart_loc + 25;
+                               if (!strncmp(dtstart_z_loc, "Z", 1))
+                                       strncpy(dtstart_z_loc, "\r\r\n", 4);
+                       }
+                       char *dtend_loc = strstr(temp_agent_data, "\r\nDTEND:");
+                       if (dtend_loc != NULL) {
+                               char *dtend_z_loc = dtend_loc + 23;
+                               if (!strncmp(dtend_z_loc, "Z", 1))
+                                       strncpy(dtend_z_loc, "\r\r\n", 4);
+                       }
+               }
+
+               if (strstr(temp_agent_data, "\r\nRRULE:") == NULL) {
+                       char *category_loc = strstr(temp_agent_data, "\r\nCATEGORIES:");
+                       if (category_loc != NULL) {
+                               len = 0;
+                               int mod_data_len = strlen(temp_agent_data) + strlen(rrule) + 1;
+                               char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
+                               if (mod_data == NULL) {
+                                       _DEBUG_ERROR("mod_data is null");
+                                       ret = SYNC_AGENT_DA_ERRORS;
+                                       *agent_data = 0;
+                                       return ret;
+                               }
+
+                               strncpy(mod_data, temp_agent_data, category_loc - temp_agent_data);
+
+                               len = g_strlcat(mod_data, rrule, mod_data_len);
+                               len = g_strlcat(mod_data, category_loc, mod_data_len);
+
+                               if (len >= mod_data_len) {
+                                       _DEBUG_ERROR("mod_data buffer overflow !!");
+                                       /* todo : exception handling */
+                               }
+
+                               free(temp_agent_data);
+                               temp_agent_data = mod_data;
+                       }
+               }
+
+               /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
+               _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Success!\n");
+               *agent_data = (void *)temp_agent_data;
+       }
+
+       /*  memory free */
+       _DEBUG_INFO("temp service data free");
+       if (temp_service_data != NULL)
+               calendar_svc_struct_free(&temp_service_data);
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#else
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_reverse_converter(void *service_data, void **agent_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(service_data == NULL, SYNC_AGENT_DA_ERR_INVALID_CONTENT, "service_data is NULL. FAIL !!!");
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] Start !!");
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       int service_ret = CALENDAR_ERROR_NONE;
+       char *temp_agent_data = NULL;
+       calendar_record_h temp_service_data = (calendar_record_h) service_data;
+       int len = 0;
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE/LAST MODIFIED tag : START */
+       int allday = 0;
+       char rrule[30];
+       memset(rrule, 0, 30);
+
+       calendar_record_h item = (calendar_record_h) temp_service_data;
+       calendar_list_h list = NULL;
+       calendar_time_s cal_start_time = { 0, };
+
+       _DEBUG_INFO("before calendar_svc_write_schedules");
+
+       service_ret = calendar_record_get_caltime(item, _calendar_event.start_time, &cal_start_time);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_record_get_caltime() Fail: err[%d]", service_ret);
+               ret = SYNC_AGENT_DA_ERRORS;
+               *agent_data = NULL;
+       } else {
+               if (cal_start_time.type == CALENDAR_TIME_LOCALTIME) {
+                       _DEBUG_INFO("[Debug] Found X-ALLDAY flag set in calendar service structure before conversion !!!");
+                       allday = 1;
+               }
+       }
+
+       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
+
+       /* Reverse_Converter */
+       /*new */
+       service_ret = calendar_list_create(&list);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_list_create() Fail!: err[%d]", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               *agent_data = NULL;
+       }
+
+       _DEBUG_INFO("before calendar_svc_write_schedules");
+       service_ret = calendar_list_add(list, temp_service_data);
+       if (service_ret != CALENDAR_ERROR_NONE) {
+               _DEBUG_ERROR("calendar_list_add() Fail!: err[%d]", service_ret);
+               ret = _convert_service_error_to_common_error(service_ret);
+               *agent_data = NULL;
+       }
+
+       if (list != NULL) {
+               service_ret = calendar_vcalendar_make_from_records(list, &temp_agent_data);
+               _DEBUG_INFO("after calendar_vcalendar_make_from_records");
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_vcalendar_make_from_records() Fail!: err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+                       *agent_data = NULL;
+               } else {
+                       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : START */
+                       if (strstr(temp_agent_data, "\r\nX-ALLDAY:SET") == NULL && allday) {
+                               char *vevent_loc = strstr(temp_agent_data, "\r\nEND:VEVENT");
+                               if (vevent_loc != NULL) {
+                                       len = 0;
+                                       int mod_data_len = strlen(temp_agent_data) + strlen("\r\nX-ALLDAY:SET") + 1;
+                                       char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
+                                       if (mod_data == NULL) {
+                                               _DEBUG_ERROR("mod_data is null");
+                                               ret = SYNC_AGENT_DA_ERRORS;
+                                               *agent_data = NULL;
+
+                                               service_ret = calendar_list_destroy(list, true);
+                                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                                       _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
+                                                       ret = _convert_service_error_to_common_error(service_ret);
+                                               }
+
+                                               return ret;
+                                       }
+
+                                       strncpy(mod_data, temp_agent_data, vevent_loc - temp_agent_data);
+
+                                       len = g_strlcat(mod_data, "\r\nX-ALLDAY:SET", mod_data_len);
+                                       len = g_strlcat(mod_data, vevent_loc, mod_data_len);
+
+                                       if (len >= mod_data_len) {
+                                               _DEBUG_ERROR("mod_data buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+
+                                       free(temp_agent_data);
+                                       temp_agent_data = mod_data;
+                               }
+                               char *dtstart_loc = strstr(temp_agent_data, "\r\nDTSTART:");
+                               if (dtstart_loc != NULL) {
+                                       char *dtstart_z_loc = dtstart_loc + 25;
+                                       if (!strncmp(dtstart_z_loc, "Z", 1))
+                                               strncpy(dtstart_z_loc, "\r\r\n", 3);
+                               }
+                               char *dtend_loc = strstr(temp_agent_data, "\r\nDTEND:");
+                               if (dtend_loc != NULL) {
+                                       char *dtend_z_loc = dtend_loc + 23;
+                                       if (!strncmp(dtend_z_loc, "Z", 1))
+                                               strncpy(dtend_z_loc, "\r\r\n", 3);
+                               }
+                       }
+
+                       if (strstr(temp_agent_data, "\r\nRRULE:") == NULL) {
+                               char *category_loc = strstr(temp_agent_data, "\r\nCATEGORIES:");
+                               if (category_loc != NULL) {
+                                       len = 0;
+                                       int mod_data_len = strlen(temp_agent_data) + strlen(rrule) + 1;
+                                       char *mod_data = (char *)calloc(mod_data_len, sizeof(char));
+                                       if (mod_data == NULL) {
+                                               _DEBUG_ERROR("mod_data is null");
+                                               ret = SYNC_AGENT_DA_ERRORS;
+                                               *agent_data = 0;
+
+                                               service_ret = calendar_list_destroy(list, true);
+                                               if (service_ret != CALENDAR_ERROR_NONE) {
+                                                       _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
+                                                       ret = _convert_service_error_to_common_error(service_ret);
+                                               }
+
+                                               return ret;
+                                       }
+
+                                       strncpy(mod_data, temp_agent_data, category_loc - temp_agent_data);
+
+                                       len = g_strlcat(mod_data, rrule, mod_data_len);
+                                       len = g_strlcat(mod_data, category_loc, mod_data_len);
+
+                                       if (len >= mod_data_len) {
+                                               _DEBUG_ERROR("mod_data buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+
+                                       free(temp_agent_data);
+                                       temp_agent_data = mod_data;
+                               }
+                       }
+                       /* Temporary fix for KIES vCalendar X-ALLDAY/RRULE tag : END */
+                       _DEBUG_INFO("[dc_vcalendar_plugIn] calendar_svc_util_convert_event_to_vcs() Success!\n");
+                       *agent_data = (void *)temp_agent_data;
+               }
+
+               service_ret = calendar_list_destroy(list, true);
+               if (service_ret != CALENDAR_ERROR_NONE) {
+                       _DEBUG_ERROR("calendar_list_destroy() Fail!: err[%d]", service_ret);
+                       ret = _convert_service_error_to_common_error(service_ret);
+               }
+       }
+
+       _DEBUG_INFO("[dc_vcalendar_plugIn] End !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+#endif
+
+EXPORT_API void *sync_agent_plugin_alloc_object()
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+EXPORT_API int sync_agent_plugin_free_object(void *in_object)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+EXPORT_API void *sync_agent_plugin_set_value(void *in_object, int key, char *extension_key, void *value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+EXPORT_API void *sync_agent_plugin_get_value(void *in_object, int key, char *extension_key)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _DEBUG_INFO("[dc_vcard_plugIn] not implement !!");
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+EXPORT_API sync_agent_plugin_object_info_s *sync_agent_plugin_get_obj_info()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_plugin_object_info_s *obj_info = (sync_agent_plugin_object_info_s *) calloc(1, sizeof(sync_agent_plugin_object_info_s));
+       if (obj_info == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return NULL;
+       }
+
+       obj_info->type = VCALENDAR_TYPE;
+       obj_info->version = VCALENDAR_VERSION;
+       obj_info->field_cnt = sizeof(vcalendar_field_list) / sizeof(vcalendar_field_list_s);
+
+       if (obj_info->field_cnt > 0)
+               if (_set_obj_field_info(&(obj_info->field_list), obj_info->field_cnt, vcalendar_field_list) == 0) {
+
+                       if (obj_info != NULL)
+                               free(obj_info);
+
+                       return NULL;
+               }
+
+       _EXTERN_FUNC_EXIT;
+
+       return obj_info;
+}
+
+EXPORT_API int sync_agent_plugin_free_obj_info(sync_agent_plugin_object_info_s * obj_info)
+{
+       _EXTERN_FUNC_ENTER;
+
+       if (obj_info != NULL) {
+               if (obj_info->field_cnt > 0)
+                       if (_free_obj_field_info(obj_info->field_list, obj_info->field_cnt) == 0)
+                               return 0;
+
+               free(obj_info);
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 1;
+}
+
+static int _free_obj_field_info(sync_agent_plugin_field_info_s * field_list, int count)
+{
+       _INNER_FUNC_ENTER;
+
+       int field_count = 0;
+       sync_agent_plugin_field_info_s *child = NULL;
+
+       if (field_list != NULL) {
+               for (field_count = 0; field_count < count; field_count++) {
+                       child = field_list + field_count;
+                       if (child->field_child_cnt > 0)
+                               if (_free_obj_field_info(child->field_child_list, child->field_child_cnt) == 0)
+                                       return 0;
+               }
+               free(field_list);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+static int _set_obj_field_info(sync_agent_plugin_field_info_s ** field_list, int count, vcalendar_field_list_s * input_list)
+{
+       _INNER_FUNC_ENTER;
+
+       int field_count = 0;
+       sync_agent_plugin_field_info_s *child = NULL;
+
+       *field_list = (sync_agent_plugin_field_info_s *) calloc(count, sizeof(sync_agent_plugin_field_info_s));
+       if (*field_list == NULL) {
+               _DEBUG_ERROR("CALLOC failed !!!");
+               return 0;
+       }
+
+       for (field_count = 0; field_count < count; field_count++) {
+               child = (*field_list) + field_count;
+               child->field_name = input_list[field_count].field_name;
+               _DEBUG_TRACE("[%s]", child->field_name);
+
+               if (input_list[field_count].field_enum == VCALENDAR_FIELD_BEGIN || input_list[field_count].field_enum == VCALENDAR_FIELD_END) {
+                       child->field_child_cnt = sizeof(vcalendar_field_list_begin_end) / sizeof(vcalendar_field_list_s);
+                       _DEBUG_TRACE("----------");
+                       _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_begin_end);
+                       _DEBUG_TRACE("==========");
+               } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_VERSION) {
+                       child->field_child_cnt = sizeof(vcalendar_field_list_version) / sizeof(vcalendar_field_list_s);
+                       _DEBUG_TRACE("----------");
+                       _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_version);
+                       _DEBUG_TRACE("==========");
+               } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_CATEGORIES) {
+                       child->field_child_cnt = sizeof(vcalendar_field_list_categories) / sizeof(vcalendar_field_list_s);
+                       _DEBUG_TRACE("----------");
+                       _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_categories);
+                       _DEBUG_TRACE("==========");
+               } else if (input_list[field_count].field_enum == VCALENDAR_FIELD_STATUS) {
+                       child->field_child_cnt = sizeof(vcalendar_field_list_status) / sizeof(vcalendar_field_list_s);
+                       _DEBUG_TRACE("----------");
+                       _set_obj_field_info(&(child->field_child_list), child->field_child_cnt, vcalendar_field_list_status);
+                       _DEBUG_TRACE("==========");
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return 1;
+}
+
+#ifdef old_api
+static sync_agent_da_return_e _convert_service_error_to_common_error(cal_error err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       case CAL_ERR_DB_LOCK:   /* -204 */
+               ret = SYNC_AGENT_DA_ERR_LOCKED;
+               break;
+       case CAL_ERR_DB_RECORD_NOT_FOUND:       /* -203 */
+       case CAL_ERR_NO_DATA:   /* -3 */
+               ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               break;
+       case CAL_ERR_DB_NOT_OPENED:     /* -201 */
+               ret = SYNC_AGENT_DA_ERR_OPEN_FAILED;
+               break;
+       case CAL_ERR_OUT_OF_MEMORY:     /* -8 */
+               ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               break;
+       case CAL_ERR_ALREADY_EXIST:     /* -7 */
+               ret = SYNC_AGENT_DA_ERR_ALREADY_EXIST;
+               break;
+       case CAL_ERR_EVENT_START_DATE:  /* -405 */
+       case CAL_ERR_EVENT_END_DATE:    /* -404 */
+       case CAL_ERR_EVENT_REPEAT_END_DATE:     /* -403 */
+       case CAL_ERR_EVENT_DURATION:    /* -402 */
+       case CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT:   /* -401 */
+       case CAL_ERR_INVALID_DATA_TYPE: /* -301 */
+       case CAL_ERR_ARG_NULL:  /* -5 */
+       case CAL_ERR_ARG_INVALID:       /* -4 */
+               ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
+               break;
+       case CAL_ERR_FINISH_ITER:       /* -2 */
+       case CAL_SUCCESS:       /* 0 */
+       case CAL_TRUE:          /* 1 */
+               ret = SYNC_AGENT_DA_SUCCESS;
+               break;
+               /*
+                * CAL_ERR_DB_FAILED: -202,
+                *  CAL_ERR_VCONF_FAILED: -102,
+                * CAL_ERR_VOBJECT_FAILED:  -101,
+                * CAL_ERR_EXCEEDED_LIMIT: -9,
+                *  CAL_ERR_ENV_INVALID: -6, CAL_ERR_FAIL:  -1,
+                */
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+#else
+static sync_agent_da_return_e _convert_service_error_to_common_error(calendar_error_e err)
+{
+       _INNER_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+       _DEBUG_TRACE("[da_calendar_plugIn] Error Code : %d\n", err);
+
+       switch (err) {
+       case CALENDAR_ERROR_DB_RECORD_NOT_FOUND:
+       case CALENDAR_ERROR_NO_DATA:
+               ret = SYNC_AGENT_DA_ERR_NO_DATA;
+               break;
+       case CALENDAR_ERROR_OUT_OF_MEMORY:
+               ret = SYNC_AGENT_DA_ERR_MEMORY_FULL;
+               break;
+       case CALENDAR_ERROR_INVALID_PARAMETER:
+               ret = SYNC_AGENT_DA_ERR_INVALID_CONTENT;
+               break;
+       case CALENDAR_ERROR_ITERATOR_END:
+       case CALENDAR_ERROR_NONE:
+               ret = SYNC_AGENT_DA_SUCCESS;
+               break;
+               /*
+                * CALENDAR_ERROR_DB_FAILED
+                * CALENDAR_ERROR_NOW_IN_PROGRESS
+                * CALENDAR_ERROR_ALREADY_IN_PROGRESS
+                * CALENDAR_ERROR_NOT_PERMITTED
+                */
+       default:
+               ret = SYNC_AGENT_DA_ERRORS;
+               break;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return ret;
+}
+#endif
diff --git a/src/fw-plugins/common-public/vobject-tizen/CMakeLists.txt b/src/fw-plugins/common-public/vobject-tizen/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..ca2e7c3
--- /dev/null
@@ -0,0 +1,44 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "dc-vobject-tizen")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       glib-2.0
+                                       sqlite3
+                                       vconf
+                                       dlog
+                                       db-util
+                                       alarm-service)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${dc-vobject-tizen_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${dc-vobject-tizen_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-errors.h b/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-errors.h
new file mode 100755 (executable)
index 0000000..e8ea578
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @defgroup return_value return_value
+ * @ingroup CALENDAR_SVC
+ * @brief
+ *             return value with api call
+ */
+
+#ifndef __CALENDAR_SVC_ERRORS_H__
+#define __CALENDAR_SVC_ERRORS_H__
+
+typedef enum {
+       CAL_ERR_EVENT_START_DATE = -405,
+       CAL_ERR_EVENT_END_DATE = -404,
+       CAL_ERR_EVENT_REPEAT_END_DATE = -403,
+       CAL_ERR_EVENT_DURATION = -402,
+       CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT = -401,
+
+       CAL_ERR_INVALID_DATA_TYPE = -301,
+
+       CAL_ERR_DB_LOCK = -204,
+       CAL_ERR_DB_RECORD_NOT_FOUND = -203,
+       CAL_ERR_DB_FAILED = -202,
+       CAL_ERR_DB_NOT_OPENED = -201,
+
+       CAL_ERR_ALARMMGR_FAILED = -105,
+       CAL_ERR_TIME_FAILED = -104,
+       CAL_ERR_INOTIFY_FAILED = -103,
+       CAL_ERR_VCONF_FAILED = -102,
+       CAL_ERR_VOBJECT_FAILED = -101,
+
+       CAL_ERR_NO_SPACE = -11,
+       CAL_ERR_IO_ERR = -10,
+       CAL_ERR_EXCEEDED_LIMIT = -9,
+       CAL_ERR_OUT_OF_MEMORY = -8,
+       CAL_ERR_ALREADY_EXIST = -7,
+       CAL_ERR_ENV_INVALID = -6,
+       CAL_ERR_ARG_NULL = -5,
+       CAL_ERR_ARG_INVALID = -4,
+       CAL_ERR_NO_DATA = -3,
+       CAL_ERR_FINISH_ITER = -2,
+       CAL_ERR_FAIL = -1,
+       CAL_SUCCESS = 0,
+       CAL_FALSE = 0,
+       CAL_TRUE
+} cal_error;
+
+#endif                         /* __CALENDAR_SVC_ERRORS_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-provider.h b/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-provider.h
new file mode 100755 (executable)
index 0000000..3c6aa6c
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_H__
+#define __CALENDAR_SVC_H__
+
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__ ((deprecated))
+#endif
+
+#include <glib.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <calendar-svc-errors.h>
+#include <calendar-svc-struct.h>
+
+/**
+ * @addtogroup common
+ * @{
+ */
+
+/**
+ * This enumeration date type, sun or lunar.
+ */
+       typedef enum {
+               CAL_DATE_SUN = 0,  /**< date is sun type*/
+               CAL_DATE_LUNAR, /**< date is lunar type */
+       } cal_date_type_t;
+
+/**
+ * This enumeration defines Remind Tick Unit for schedule.
+ * Ex. remindTick = 1, remindTickUnit = CAL_SCH_TIME_UNIT_MIN, Organizer alarms
+ * 1 minute before schedule starting time.
+ */
+       typedef enum {
+               CAL_SCH_TIME_UNIT_OFF = -1,
+                                   /**< off */
+               CAL_SCH_TIME_UNIT_MIN = 0,
+                                       /**< Minute */
+               CAL_SCH_TIME_UNIT_HOUR, /**< Hour */
+               CAL_SCH_TIME_UNIT_DAY,  /**< Day */
+               CAL_SCH_TIME_UNIT_WEEK, /**< Week */
+               CAL_SCH_TIME_UNIT_MONTH,/**< Month - will be removed*/
+               CAL_SCH_TIME_UNIT_SPECIFIC
+                                   /**< using alarm time */
+       } cal_sch_remind_tick_unit_t;
+
+/**
+ * This enumeration defines Repeat term.
+ */
+       typedef enum {
+               CAL_REPEAT_NONE = 0,     /**< never Repeat */
+               CAL_REPEAT_EVERY_DAY, /**< Repeats every day */
+               CAL_REPEAT_EVERY_WEEK,/**< Repeats every week */
+               CAL_REPEAT_EVERY_MONTH,
+                                     /**< Repeats every month */
+               CAL_REPEAT_EVERY_YEAR,/**< Repeats every year */
+               CAL_REPEAT_EVERY_WEEKDAYS,      /**< Repeats every weekdays *//* same with CAL_REPEAT_EVERY_WEEK, but week_flag="0111110", day_date=1, sun_moon=0, week_start=0 */
+               CAL_REPEAT_EVERY_MONTH_DAY,     /**< Repeats every month's week days *//* same with CAL_REPEAT_EVERY_MONTH, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
+               CAL_REPEAT_EVERY_YEAR_DAY,      /**< Repeats every year's month week days *//* same with CAL_REPEAT_EVERY_YEAR, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
+       } cal_repeat_term_t;
+
+/**
+ * This enumeration defines sync status.
+ */
+       typedef enum {
+               CAL_SYNC_STATUS_NEW = 0,/**< newly added. */
+               CAL_SYNC_STATUS_UPDATED,/**< updated. */
+               CAL_SYNC_STATUS_DELETED,/**< deleted. */
+               CAL_SYNC_STATUS_SYNCED, /**< synced */
+       } cal_sync_status_t;
+
+/**
+ * This enumeration defines lart type.
+ */
+       typedef enum {
+               CAL_ALERT_MELODY = 0,                     /**< alarm type is melody */
+               CAL_ALERT_MUTE,                                   /**< alarm type is mute */
+               CAL_ALERT_INCREASING_MELODY,      /**< alarm type is increasing melody */
+               CAL_ALERT_VIBRATION,                       /**< alarm type is vibrate */
+               CAL_ALERT_VIBRATION_THEN_MELODY,  /**< alarm type is vibrate then melody */
+               CAL_ALERT_VIBMELODY,                       /**< alarm type is melody with vibrate */
+               CAL_ALERT_VIB_INCREASING_MELODY /**< alarm type is increasing melody */
+       } cal_alert_type_t;
+
+/**
+ * This enumeration defines status.
+ * (related with CAL_VALUE_INT_TASK_STATUS)
+ */
+       typedef enum {
+               CALS_STATUS_NONE = 0,
+               CALS_EVENT_STATUS_TENTATIVE,
+               CALS_EVENT_STATUS_CONFIRMED,
+               CALS_EVENT_STATUS_CANCELLED,
+               CALS_TODO_STATUS_NEEDS_ACTION,
+               CALS_TODO_STATUS_COMPLETED,
+               CALS_TODO_STATUS_IN_PROCESS,
+               CALS_TODO_STATUS_CANCELLED,
+       } cals_status_t;
+
+/**
+ * @fn int vobject_calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
+ * This function converts data (cal_struct(event) to raw_data(vcal format)),it is convenient for user to convert.
+ *
+ * @ingroup utilities
+ * @param[in] record      original record type
+ * @param[out] raw_data            vcalendar event raw data
+ * @param[out] data_size          raw_data buf size
+ * @return      This function returns CAL_SUCCESS or error code on failure.
+ * @remarks none
+ * @pre none.
+ * @post none
+ * @code
+       #include <calendar_svc_provider.h>
+       void sample_code()
+       {
+               char raw_data = NULL;
+               int data_size = 0;
+
+               //connect to database
+               calendar_svc_connect();
+
+               cal_struct* event = NULL;
+
+               //get the record
+               calendar_svc_get("schedule",1,NULL,&event);
+
+               //convert
+               vobject_calendar_svc_util_convert_event_to_vcs (event,&raw_data,&data_size);
+
+               calendar_svc_struct_free(&event);
+
+               //close to database
+               calendar_svc_close();
+       }
+ * @endcode
+ * @see calendar_svc_util_convert_vcs_to_event().
+ */
+       int vobject_calendar_svc_util_convert_event_to_vcs(cal_struct * record, char **raw_data, int *data_size);
+
+#endif                         /* __CALENDAR_SVC_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-struct.h b/src/fw-plugins/common-public/vobject-tizen/include/calendar-svc-struct.h
new file mode 100755 (executable)
index 0000000..636f13a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_STRUCT_H__
+#define __CALENDAR_SVC_STRUCT_H__
+
+/**
+ * @defgroup CALENDAR_SVC Calendar Service
+ * @section intro 2.0 calendar engine
+ * - this document maded for calendar service
+ * - this document contain api signature & usage
+ *
+ * @section CREATEINFO author infomation
+ * - author      :   heungjae jeong(hj98.jeong@samsung.com)
+ * - date                 :   2010/09/06
+ *
+ * @section DEPENDENCY DEPENDENCY
+ * - GLIB
+ *
+ * @section MODIFYINFO Revision history
+ * - maximus/2010-09-06          : make api signature
+ * - maximus/2010-09-16       : add calendar type & exception date, change api name(remove _event)
+ * - maximus/2010-09-16       : add utility function(for vcalendar)
+ *
+ *
+ */
+
+/**
+ *cal_struct is an opaque type, it must be used via accessor functions.
+ *@ingroup common
+ *@see also:
+ * calendar_svc_struct_new(), calendar_svc_struct_free()
+ * calendar_svc_struct_get_value(), calendar_svc_struct_get_list(),
+ * calendar_svc_struct_store_value(), calendar_svc_struct_store_list()
+ */
+typedef struct _cal_struct cal_struct;
+
+/**
+ * cal_value is an opaque type, it must be
+ * used via accessor functions.
+ * @ingroup common
+ * @see calendar_svc_struct_new(), calendar_svc_struct_free()
+ */
+typedef struct _cal_value cal_value;
+
+#endif                         /* __CALENDAR_SVC_STRUCT_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/include/cals-internal.h b/src/fw-plugins/common-public/vobject-tizen/include/cals-internal.h
new file mode 100755 (executable)
index 0000000..70c135a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_INTERNAL_H__
+#define __CALENDAR_SVC_INTERNAL_H__
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <dlog.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define _E(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
+
+#define CAL_FREE(ptr) \
+        do { \
+         free(ptr); \
+         ptr = NULL; \
+        }while(0);
+
+#endif                         /* __CALENDAR_SVC_INTERNAL_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.c b/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.c
new file mode 100755 (executable)
index 0000000..d63c2cb
--- /dev/null
@@ -0,0 +1,1916 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <ctype.h>
+#include <assert.h>
+#include <time.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "cals-typedef.h"
+#include "cals-ical.h"
+#include "cals-ical-codec.h"
+#include "cals-internal.h"
+#include "cals-utils.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "VOBJECT_TIZEN"
+#endif
+
+/****************************************************************************************************/
+/*                                               GLOBAL VARIABLE DECLARATION AND INITIALIZATION                                                        */
+/****************************************************************************************************/
+
+/* Type */
+const char *pszCalTypeList[] = {
+       "AALARM",
+       "ACTION",
+       "ATTACH",
+       "ATTENDEE",
+       "BEGIN",
+       "CALSCALE",
+       "CATEGORIES",
+       "CLASS",
+       "COMMENT",
+       "COMPLETED",
+       "CONTACT",
+       "CREATED",
+       "DALARM",
+       "DAYLIGHT",
+       "DCREATED",
+       "DESCRIPTION",
+       "DTEND",
+       "DTSTAMP",
+       "DTSTART",
+       "DUE",
+       "DURATION",
+       "END",
+       "EXDATE",
+       "EXRULE",
+       "FREEBUSY",
+       "GEO",
+       "LAST-MODIFIED",
+       "LOCATION",
+       "MALARM",
+       "METHOD",
+       "ORGANIZER",
+       "PALARM",
+       "PERCENT-COMPLETE",
+       "PRIORITY",
+       "PRODID",
+       "RDATE",
+       "RECURRENCE-ID",
+       "RELATED-TO",
+       "REPEAT",
+       "REQUEST-STATUS",
+       "RESOURCES",
+       "RNUM",
+       "RRULE",
+       "SEQUENCE",
+       "STANDARD",
+       "STATUS",
+       "SUMMARY",
+       "TRANSP",
+       "TRIGGER",
+       "TZ",
+       "TZID",
+       "TZNAME",
+       "TZOFFSETFROM",
+       "TZOFFSETTO",
+       "TZURL",
+       "URL",
+       "UID",
+       "VALARM",
+       "VCALENDAR",
+       "VERSION",
+       "VEVENT",
+       "VFREEBUSY",
+       "VJOURNAL",
+       "VTIMEZONE",
+       "VTODO",
+       "X-FUNAMBOL-ALLDAY"
+};
+
+/* Parameter */
+static const char *pszCalParamList[] = {
+       "ALTREP",
+       "CHARSET",
+       "CN",
+       "CONTEXT",
+       "CUTYPE",
+       "DELEGATED-FROM",
+       "DELEGATED-TO",
+       "DIR",
+       "ENCODING",
+       "EXPECT",
+       "FBTYPE",
+       "FMTYPE",
+       "LANGUAGE",
+       "MEMBER",
+       "PARTSTAT",
+       "RANGE",
+       "RELATED",
+       "RELTYPE",
+       "ROLE",
+       "RSVP",
+       "SENT_BY",
+       "STATUS",
+       "TYPE",
+       "TZID",
+       "VALUE"
+};
+
+/* Cu type value */
+static const ValueObj pCalCutypeValList[] = {
+       {"GROUP", 0x00000001},
+       {"INDIVIDUAL", 0x00000002},
+       {"RESOURCE", 0x00000004},
+       {"ROOM", 0x00000008},
+       {"UNKNOWN", 0x00000010}
+};
+
+/* Character set value */
+static const ValueObj pCalCharsetValList[] = {
+       {"UTF-8", 0x00000001},
+       {"UTF-16", 0x00000002}
+};
+
+/* Encoding value */
+static const ValueObj pCalEncValList[] = {
+       {"B", 0x00000001},
+       {"BASE64", 0x00000002},
+       {"QUOTED-PRINTABLE", 0x00000004},
+       {"7BIT", 0x00000008},
+       {"8BIT", 0x00000010}
+};
+
+/* Fb type value */
+static const ValueObj pCalFbtypeValList[] = {
+       {"BUSY", 0x00000001},
+       {"BUSY_TENTATIVE", 0x00000002},
+       {"BUSY_UNAVAILABLE", 0x00000004},
+       {"FREE", 0x00000008}
+};
+
+/* Partstat value */
+static const ValueObj pCalPartstatValList[] = {
+       {"ACCEPTED", 0x00000001},
+       {"COMPLETED", 0x00000002},
+       {"DELEGATED", 0x00000004},
+       {"DECLINED", 0x00000008},
+       {"IN_PROCESS", 0x00000010},
+       {"NEED_ACTION", 0x00000020},
+       {"TENTATIVE", 0x00000040}
+};
+
+/* Range value */
+static const ValueObj pCalRangeValList[] = {
+       {"THISANDFUTURE", 0x00000001},
+       {"THISANDPRIOR", 0x00000002}
+};
+
+/* Related value */
+static const ValueObj pCalRelatedValList[] = {
+       {"END", 0x00000001},
+       {"START", 0x00000002}
+};
+
+/* Rel type value */
+static const ValueObj pCalReltypeValList[] = {
+       {"CHILD", 0x00000001},
+       {"PARENT", 0x00000002},
+       {"SIBLING", 0x00000004}
+};
+
+/* Value value */
+static const ValueObj pCalValValList[] = {
+       {"BINARY", 0x00000001},
+       {"BOOLEAN", 0x00000002},
+       {"CAL-ADDRESS", 0x00000004},
+       {"CID", 0x00000008},
+       {"CONTENT-ID", 0x00000010},
+       {"DATE", 0x00000020},
+       {"DATE-TIME", 0x00000040},
+       {"DURATION", 0x00000080},
+       {"FLOAT", 0x00000100},
+       {"INTEGER", 0x00000200},
+       {"PERIOD", 0x00000400},
+       {"PHONE-NUMBER", 0x00000800},
+       {"RECUR", 0X00001000},
+       {"TEXT", 0x00002000},
+       {"TIME", 0x00004000},
+       {"URI", 0x00008000},
+       {"URL", 0x00010000},
+       {"UTC-OFFSET", 0x00020000},
+       {"VCALENDAR", 0x00040000},
+       {"VEVENT", 0x00080000},
+       {"VTODO", 0x00100000}
+};
+
+/* Type value */
+static const ValueObj pCalTypeValList[] = {
+       {"AIFF", 0x00000001},
+       {"BBS", 0x00000002},
+       {"CAR", 0x00000004},
+       {"CELL", 0x00000008},
+       {"DOM", 0x00000010},
+       {"FAX", 0x00000020},
+       {"GIF", 0x00000040},
+       {"HOME", 0x00000080},
+       {"INTL", 0x00000100},
+       {"INTERNET", 0x00000200},
+       {"ISDN", 0x00000400},
+       {"JPEG", 0x00000800},
+       {"MODEM", 0x00001000},
+       {"MSG", 0x00002000},
+       {"PAGER", 0x00004000},
+       {"PARCEL", 0x00008000},
+       {"PCM", 0x00010000},
+       {"PCS", 0x00020000},
+       {"PNG", 0x00040000},
+       {"POSTAL", 0x00080000},
+       {"PREF", 0x00100000},
+       {"VCARD", 0x00200000},
+       {"VIDEO", 0x00400000},
+       {"VOICE", 0x00800000},
+       {"WAVE", 0x01000000},
+       {"WBMP", 0x02000000},
+       {"WORK", 0x04000000},
+       {"X400", 0x08000000}
+};
+
+/* Expect value */
+static const ValueObj pCalExpectValList[] = {
+       {"FYI", 0x00000001},
+       {"IMMEDIATE", 0x00000002},
+       {"REQUEST", 0x00000004},
+       {"REQUIRE", 0x00000008}
+};
+
+/* Role value */
+static const ValueObj pCalRoleValList[] = {
+       {"ATTENDEE", 0x00000001},
+       {"CHAIR", 0x00000002},
+       {"DELEGATE", 0x00000004},
+       {"NON_PARTICIPANT", 0x00000008},
+       {"OPT_PARTICIPANT", 0x00000010},
+       {"ORGANIZER", 0x00000020},
+       {"OWNER", 0x00000040},
+       {"REQ_PARTICIPANT", 0x00000080}
+};
+
+/* RSVP value */
+static const ValueObj pCalRSVPValList[] = {
+       {"false", 0x00000001},
+       {"NO", 0x00000002},
+       {"true", 0x00000004},
+       {"YES", 0x00000008}
+};
+
+/* Status value */
+static const ValueObj pCalStatusValList[] = {
+       {"ACCEPTED", 0x00000001},
+       {"COMPLETED", 0x00000002},
+       {"CONFIRMED", 0x00000004},
+       {"DECLINED", 0x00000008},
+       {"DELEGATED", 0x00000010},
+       {"NEEDS ACTION", 0x00000020},
+       {"SENT", 0x00000040},
+       {"TENTATIVE", 0x00000080},
+};
+
+static char *__VCalParamEncode(VObject *, int *);
+
+void _gbase64Encode(char *Dest, char *Src, int len)
+{
+       _INNER_FUNC_ENTER;
+
+       gchar *buf = g_base64_encode((guchar *) Src, strlen(Src));
+       int dest_len = 0;
+       dest_len = g_strlcpy(Dest, buf, len);
+       if (dest_len >= len) {
+               _DEBUG_ERROR("Dest buffer overflow !!");
+               /* todo : exception handling */
+       }
+       _DEBUG_TRACE("_gbase64Decode before:\n%s \n", Src);
+       _DEBUG_TRACE("_gbase64Decode after:\n%s \n", Dest);
+       g_free(buf);
+
+       _INNER_FUNC_EXIT;
+}
+
+/*
+ * vcal_free_vtree_memory() frees memory used for decoding.
+ *
+ * @param       pTree            VTree structure to be freed.
+ * @return      If succeeds, return true, else false.
+ */
+bool vcal_free_vtree_memory(VTree * pTree)
+{
+       _EXTERN_FUNC_ENTER;
+
+       VObject *pCurObj = NULL;
+       VObject *pNextObj = NULL;
+       VTree *pCurTree = NULL;
+       VTree *pNextTree = NULL;
+
+       _DEBUG_INFO("vcal_free_vtree_memory() entered.\n");
+       //SysRequireEx( pTree != NULL, false );
+       retvm_if(NULL == pTree, NULL, "[ERROR]vcal_free_vtree_memory:Invalid parameter(pTree)!\n");
+
+       if ((pTree->treeType == VCALENDAR) || ((pTree->treeType >= VEVENT) && (pTree->treeType <= DAYLIGHT))) {
+               //continue
+               ;
+       } else {
+               return false;
+       }
+
+       pCurTree = pTree;
+
+       while (pCurTree) {
+               pNextTree = pCurTree->pNext;
+               pCurObj = pCurTree->pTop;
+
+               while (pCurObj) {
+                       int count;
+                       int i;
+
+                       pNextObj = pCurObj->pSibling;
+
+                       count = pCurObj->valueCount;
+
+                       for (i = 0; i < count; i++) {
+                               if (pCurObj->pszValue[i] != NULL) {
+                                       free(pCurObj->pszValue[i]);
+                                       pCurObj->pszValue[i] = NULL;
+                               }
+                       }
+
+#ifdef VDATA_GROUPNAME_SUPPORTED
+                       if (pCurObj->pszGroupName != NULL) {
+                               free(pCurObj->pszGroupName);
+                               pCurObj->pszGroupName = NULL;
+                       }
+#endif                         // VDATA_GROUPNAME_SUPPORTED
+
+                       if (pCurObj->pParam != NULL) {
+                               VParam *pCurParam = NULL;
+                               VParam *pNextParam = NULL;
+
+                               pCurParam = pCurObj->pParam;
+
+                               while (pCurParam) {
+                                       pNextParam = pCurParam->pNext;
+
+                                       free(pCurParam);
+                                       pCurParam = NULL;
+
+                                       pCurParam = pNextParam;
+                               }
+                       }
+
+                       free(pCurObj);
+                       pCurObj = NULL;
+
+                       pCurObj = pNextObj;
+               }
+
+               free(pCurTree);
+               pCurTree = NULL;
+
+               pCurTree = pNextTree;
+       }
+
+       _DEBUG_INFO("\n---------------------------exit vcal_free_vtree_memory--------- -------------\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return true;
+}
+
+/*
+ * vCaLTypeEncoder() compares the string and VCal type, parameter value.
+ *
+ * @param              typeObj                         Data which will be encoded
+ * @param              type                            Name of the type
+ * @return      char *              Encoded result
+ */
+static char *__VCalTypeEncode(VObject * pTypeObj, const char *pType)
+{
+       _INNER_FUNC_ENTER;
+
+       int len;
+       char *pTemp = NULL;
+       char *szTypeValue = NULL;
+       int i;
+       int enc = 0;
+       char *pEncode = NULL;
+       char *pRes = NULL;
+       int total = 0;
+       int biLen = 0;
+       char *tempszTypeValue = NULL;
+       int temp_len = 0;
+
+       _DEBUG_VERBOSE("__VCalTypeEncode() enter..\n");
+
+       len = strlen(pType);
+       biLen = pTypeObj->numOfBiData;
+
+       if ((szTypeValue = (char *)malloc(total += (len + 1 + 10))) == NULL) {
+               _DEBUG_ERROR("VCalTypeEncode():malloc failed\n");
+               return NULL;
+       }
+
+       memset(szTypeValue, '\0', (len + 1 + 10));
+       memcpy(szTypeValue, pType, len);
+
+       pTemp = __VCalParamEncode(pTypeObj, &enc);
+       if (pTemp != NULL) {
+               len = strlen(pTemp);
+               tempszTypeValue = szTypeValue;
+               if ((szTypeValue = (char *)realloc(szTypeValue, (total += len + 10))) == NULL) {
+                       _DEBUG_ERROR("__VCalTypeEncode():realloc failed\n");
+                       if (pTemp != NULL) {
+                               free(pTemp);
+                               pTemp = NULL;
+                       }
+
+                       if (tempszTypeValue != NULL) {
+                               free(tempszTypeValue);
+                               tempszTypeValue = NULL;
+                       }
+                       return NULL;
+               }
+               temp_len = g_strlcat(szTypeValue, pTemp, total);
+               if (temp_len >= total) {
+                       _DEBUG_ERROR("szTypeValue buffer overflow !!");
+                       /* todo : exception handling */
+               }
+               free(pTemp);
+       }
+
+       tempszTypeValue = szTypeValue;
+       if ((szTypeValue = (char *)realloc(szTypeValue, (total += 2 + 10))) == NULL) {
+
+               _DEBUG_ERROR("__VCalTypeEncode():realloc failed\n");
+               if (tempszTypeValue != NULL) {
+                       free(tempszTypeValue);
+                       tempszTypeValue = NULL;
+               }
+               return NULL;
+       }
+       temp_len = 0;
+       temp_len = g_strlcat(szTypeValue, ":\0", total);
+       if (temp_len >= total) {
+               _DEBUG_ERROR("szTypeValue buffer overflow !!");
+               /* todo : exception handling */
+       }
+
+       len = 0;
+       for (i = 0; i < pTypeObj->valueCount; i++) {
+               if ((pTypeObj->pszValue[i] == NULL)) {
+                       free(szTypeValue);
+                       return NULL;
+               }
+
+               len += strlen(pTypeObj->pszValue[i]);
+       }
+
+       int buf_len = 0;
+       char *buf = NULL;
+       if ((pEncode = (char *)calloc(1, (len + 30) * 2 + 31)) == NULL) {
+               free(szTypeValue);
+               _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+               return NULL;
+       }
+       for (i = 0; i < pTypeObj->valueCount; i++) {
+               int len_i = strlen(pTypeObj->pszValue[i]);
+               if (buf_len < len_i) {
+                       free(buf);
+                       buf_len = len_i;
+                       if ((buf = (char *)calloc(1, buf_len * 2 + 1)) == NULL) {
+                               free(szTypeValue);
+                               _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+                               free(pEncode);
+                               return NULL;
+                       }
+               } else {
+                       if (buf != NULL)
+                               bzero(buf, buf_len);
+               }
+
+               if (buf != NULL) {
+                       strncpy(buf, pTypeObj->pszValue[i], len_i);
+                       _VEscape(buf);
+
+                       if (i) {
+                               temp_len = 0;
+                               temp_len = g_strlcat(pEncode, ";", ((len + 30) * 2 + 31));
+                               if (temp_len >= ((len + 30) * 2 + 31)) {
+                                       _DEBUG_ERROR("pEncode buffer overflow !!");
+                                       /* todo : exception handling */
+                               }
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pEncode, buf, ((len + 30) * 2 + 31));
+                       if (temp_len >= ((len + 30) * 2 + 31)) {
+                               _DEBUG_ERROR("pEncode buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+               }
+       }
+       free(buf);
+
+       temp_len = 0;
+       temp_len = g_strlcat(pEncode, "\0\0", ((len + 30) * 2 + 31));
+       if (temp_len >= ((len + 30) * 2 + 31)) {
+               _DEBUG_ERROR("pEncode buffer overflow !!");
+               /* todo : exception handling */
+       }
+       //      _VEscape( pEncode );
+       len = strlen(pEncode);
+
+       if (enc & pCalEncValList[2].flag) {
+
+               //if ( ( pRes = ( char * )malloc( len+40 ) ) == NULL )
+               //if ( ( pRes = ( char * )malloc( len+40+10 ) ) == NULL )
+               // Task description?? enter?? ??? ??? memory ?????. len * 4 + 30 -> len * 6 + 30???? ???? 2004.3.12
+               if ((pRes = (char *)malloc(len * 6 + 30)) == NULL) {
+                       _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+
+                       free(pEncode);
+                       free(szTypeValue);
+
+                       return NULL;
+               }
+               _VQPEncode(pRes, pEncode);
+               free(pEncode);
+               pEncode = NULL;
+       } else if (enc & pCalEncValList[1].flag) {
+
+               //if ( ( pRes = ( char * )malloc( ( len * 8 / 6 ) + 4 ) ) == NULL )
+               if ((pRes = (char *)malloc((len * 8 / 6) + 4 + 10)) == NULL) {
+                       _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+                       free(pEncode);
+                       free(szTypeValue);
+
+                       return NULL;
+               }
+               //memset( pRes, '\0', ( ( len * 8 / 6 ) + 4 ) );
+               memset(pRes, '\0', ((len * 8 / 6) + 4 + 10));
+//              _gbase64Encode( pRes, pEncode, biLen );
+               _gbase64Encode(pRes, pEncode, ((len * 8 / 6) + 4 + 10));
+
+               free(pEncode);
+               pEncode = NULL;
+       } else {
+
+               //if ( ( pRes = ( char * )malloc( len+2 ) ) == NULL )
+               if ((pRes = (char *)malloc(len + 2 + 10)) == NULL) {
+                       _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+
+                       free(pEncode);
+                       free(szTypeValue);
+
+                       return NULL;
+               }
+               //memset( pRes, '\0', ( len + 2 ) );
+               memset(pRes, '\0', (len + 2 + 10));
+               memcpy(pRes, pEncode, len);
+               free(pEncode);
+               pEncode = NULL;
+       }
+
+       temp_len = 0;
+       temp_len = g_strlcat(pRes, "\r\n", (len + 2 + 10));
+       if (temp_len >= (len + 2 + 10)) {
+               _DEBUG_ERROR("pRes buffer overflow !!");
+               /* todo : exception handling */
+       }
+
+       len = strlen(pRes);
+       //if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += ( len+3 ) ) ) ) == NULL )
+       tempszTypeValue = szTypeValue;
+       if ((szTypeValue = (char *)malloc((total += (len * 4 + 3 + 10)))) == NULL) {
+               _DEBUG_ERROR("__VCalTypeEncode():realloc failed\n");
+               if (pRes != NULL) {
+                       free(pRes);
+                       pRes = NULL;
+               }
+               if (tempszTypeValue != NULL) {
+                       free(tempszTypeValue);
+                       tempszTypeValue = NULL;
+               }
+
+               return NULL;
+       }
+
+       memset(szTypeValue, 0x00, total);
+       strncpy(szTypeValue, tempszTypeValue, total);
+       temp_len = 0;
+       temp_len = g_strlcat(szTypeValue, pRes, total);
+       if (temp_len >= (total + 1)) {
+               _DEBUG_ERROR("szTypeValue buffer overflow !!");
+               /* todo : exception handling */
+       }
+       _VRLSpace(szTypeValue);
+       _VRTSpace(szTypeValue);
+
+       free(tempszTypeValue);
+       free(pRes);
+       if (strlen(szTypeValue) >= 75) {
+               if ((pEncode = (char *)malloc(sizeof(char) * (strlen(szTypeValue) * 4 + (strlen(szTypeValue) / 75) * 2 + 10 + 10))) == NULL) {
+                       _DEBUG_ERROR("__VCalTypeEncode():malloc failed\n");
+                       free(szTypeValue);
+                       return NULL;
+               }
+
+               _VFolding(pEncode, szTypeValue);
+               free(szTypeValue);
+
+               return pEncode;
+       }
+
+       _DEBUG_VERBOSE("__VCalTypeEncode() end..\n");
+
+       _INNER_FUNC_EXIT;
+
+       return szTypeValue;
+}
+
+/*
+ * vcal_encode() compares the string and VCal type, parameter value.
+ *
+ * @param       pVCalRaw            Data which will be encoded
+ * @return      char *              Encoded result
+ */
+char *vcal_encode(VTree * pVCalRaw)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *pCalRes = NULL;
+       char *pTemp = NULL;
+       int len;
+       int total = 0;
+       VTree *pTmpTree = NULL;
+       VObject *pTmpObj = NULL;
+       int temp_len = 0;
+
+       _DEBUG_INFO("vcal_encode() enter..\n");
+       //SysRequireEx( pVCalRaw != NULL, NULL );
+       if (pVCalRaw == NULL)
+               return NULL;
+
+       if ((pVCalRaw->treeType == VCALENDAR) || ((pVCalRaw->treeType >= VEVENT) && (pVCalRaw->treeType <= DAYLIGHT))) {
+               //continue
+               ;
+       } else {
+               return NULL;
+       }
+
+       if ((pCalRes = (char *)malloc(total += 2)) == NULL) {
+               _DEBUG_INFO("vcal_encode():malloc failed\n");
+               return NULL;
+       }
+       memset(pCalRes, '\0', 1);
+
+       pTmpTree = pVCalRaw;
+       pTmpObj = pTmpTree->pTop;
+
+       /*
+          if( (pTmpObj == NULL) || (pTmpObj->property < 0) || (pTmpObj->valueCount < 0) )
+          {
+          if(pTmpObj !=NULL)
+          _DEBUG_INFO(  "pTmpObj = %d, pTmpObj->property = %d,pTmpObj->valueCount=%d \n",pTmpObj,pTmpObj->property,pTmpObj->valueCount);
+          else
+          _DEBUG_INFO("pTmpObj is NULL");
+          return NULL;
+          } */
+
+       while (true) {
+               switch (pTmpTree->treeType) {
+               case VCALENDAR:
+
+                       // wyj add PRODID field,set PRODID length is 100
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 18 + 100 + 15))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VCALENDAR\r\n", total);
+                       temp_len = g_strlcat(pCalRes, "PRODID:-//Samsung Electronics //Calendar //EN\r\n", total);
+                       temp_len = g_strlcat(pCalRes, "VERSION:1.0\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VEVENT:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 15))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VEVENT\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VTODO:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 14))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VTODO\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VJOURNAL:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 17))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VJOURNAL\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VFREEBUSY:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 18))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VFREEBUSY\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VTIMEZONE:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 19))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VTIMEZONE\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VALARM:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 15))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:VALARM\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case STANDARD:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 17))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:STANDARD\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case DAYLIGHT:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 17))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "BEGIN:DAYLIGHT\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               }
+
+               while (true) {
+                       if (pTmpObj != NULL) {
+                               if (pTmpObj->property < 0 || pTmpObj->property >= VCAL_TYPE_NUM) {
+                                       if (pCalRes != NULL)
+                                               free(pCalRes);
+                                       return NULL;
+                               }
+                               if ((pTemp = __VCalTypeEncode(pTmpObj, pszCalTypeList[pTmpObj->property])) != NULL) {
+                                       len = strlen(pTemp);
+                                       if ((pCalRes = (char *)realloc(pCalRes, (total += (len + 10)))) == NULL) {
+                                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                                               free(pTemp);
+                                               pTemp = NULL;
+                                               return NULL;
+                                       }
+                                       temp_len = 0;
+                                       temp_len = g_strlcat(pCalRes, pTemp, total);
+                                       if (temp_len >= (total + 1)) {
+                                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+                                       free(pTemp);
+                               }
+
+                               if (pTmpObj->pSibling != NULL)
+                                       pTmpObj = pTmpObj->pSibling;
+                               else
+                                       break;
+                       } else
+                               break;
+               }
+
+               switch (pTmpTree->treeType) {
+                       /*      case VCALENDAR:
+                          if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
+                          {
+                          _DEBUG_INFO(  "vcal_encode():realloc failed\n");
+                          return NULL;
+                          }
+                          memcpy( pCalRes, "END:VCALENDAR\r\n", 17 );
+                          break; */
+               case VEVENT:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 13))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VEVENT\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VTODO:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 12))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VTODO\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VJOURNAL:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 15))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VJOURNALO\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VFREEBUSY:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 16))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VFREEBUSY\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VTIMEZONE:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 16))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VTIMEZONE\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case VALARM:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 13))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:VALARM\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case STANDARD:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 15))) == NULL) {
+
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:STANDARD\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               case DAYLIGHT:
+                       if ((pCalRes = (char *)realloc(pCalRes, (total += 15))) == NULL) {
+                               _DEBUG_INFO("vcal_encode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(pCalRes, "END:DAYLIGHT\r\n", total);
+                       if (temp_len >= (total + 1)) {
+                               _DEBUG_ERROR("pCalRes buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               }
+
+               if (pTmpTree->pNext != NULL)
+                       pTmpTree = pTmpTree->pNext;
+               else
+                       break;
+               pTmpObj = pTmpTree->pTop;
+       }
+
+       if ((pCalRes = (char *)realloc(pCalRes, (total += 16))) == NULL) {
+
+               _DEBUG_INFO("vcal_encode():realloc failed\n");
+               return NULL;
+       }
+       temp_len = 0;
+       temp_len = g_strlcat(pCalRes, "END:VCALENDAR\r\n", total);
+       if (temp_len >= (total + 1)) {
+               _DEBUG_ERROR("pCalRes buffer overflow !!");
+               /* todo : exception handling */
+       }
+
+       _DEBUG_INFO("vcal_encode() end..\n");
+
+       _EXTERN_FUNC_EXIT;
+
+       return pCalRes;
+}
+
+/*
+ * vCalParamEncoder() compares the string and VCal type, parameter value.
+ *
+ * @param              typeObj                         Data which will be encoded
+ * @param              type                            Name of the type
+ */
+static char *__VCalParamEncode(VObject * pTypeObj, int *pEnc)
+{
+       _INNER_FUNC_ENTER;
+
+       char *szParam = NULL;
+       VParam *pTemp = NULL;
+       int i;
+       const ValueObj *pList;
+       bool bSupported;
+       int sNum;
+       int shift;
+       int len = 0;
+       int temp_len = 0;
+
+       _DEBUG_VERBOSE("__VCalParamEncode() enter..\n");
+       retvm_if(NULL == pTypeObj, NULL, "[ERROR]__VCalParamEncode:Invalid parameter(pTypeObj)!\n");
+
+       pTemp = pTypeObj->pParam;
+       if (pTemp != NULL) {
+               if ((szParam = (char *)malloc(len += 2)) == NULL) {
+                       _DEBUG_ERROR("__VCalParamEncode():malloc failed\n");
+                       return NULL;
+               }
+               memcpy(szParam, "\0\0", 2);
+       }
+
+       while (pTemp != NULL) {
+               bSupported = false;
+
+               if ((szParam = (char *)realloc(szParam, (len += 15))) == NULL) {
+
+                       _DEBUG_ERROR("__VCalParamEncode():realloc failed\n");
+                       return NULL;
+               }
+
+               temp_len = g_strlcat(szParam, ";", len);
+               temp_len = g_strlcat(szParam, pszCalParamList[pTemp->parameter], len);
+               temp_len = g_strlcat(szParam, "=", len);
+               if (temp_len >= (len + 1)) {
+                       _DEBUG_ERROR("szParam buffer overflow !!");
+                       /* todo : exception handling */
+               }
+
+               switch (pTemp->parameter) {
+               case VCAL_PARAM_ENCODING:
+                       *pEnc = pTemp->paramValue;
+                       shift = VCAL_ENCODE_PARAM_NUM;
+                       pList = pCalEncValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_CHARSET:
+                       shift = VCAL_CHARSET_PARAM_NUM;
+                       pList = pCalCharsetValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_TYPE:
+                       shift = VCAL_TYPE_PARAM_NUM;
+                       pList = pCalTypeValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_VALUE:
+                       shift = VCAL_VALUE_PARAM_NUM;
+                       pList = pCalValValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_EXPECT:
+                       shift = VCAL_EXPECT_PARAM_NUM;
+                       pList = pCalExpectValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_ROLE:
+                       shift = VCAL_ROLE_PARAM_NUM;
+                       pList = pCalRoleValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_RSVP:
+                       shift = VCAL_RSVP_PARAM_NUM;
+                       pList = pCalRSVPValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_STATUS:
+                       shift = VCAL_STATUS_PARAM_NUM;
+                       pList = pCalStatusValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_CUTYPE:
+                       shift = VCAL_CUTYPE_PARAM_NUM;
+                       pList = pCalCutypeValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_FBTYPE:
+                       shift = VCAL_FBTYPE_PARAM_NUM;
+                       pList = pCalFbtypeValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_PARTSTAT:
+                       shift = VCAL_PARTSTAT_PARAM_NUM;
+                       pList = pCalPartstatValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_RANGE:
+                       shift = VCAL_RANGE_PARAM_NUM;
+                       pList = pCalRangeValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_RELATED:
+                       shift = VCAL_RELATED_PARAM_NUM;
+                       pList = pCalRelatedValList;
+                       bSupported = true;
+                       break;
+               case VCAL_PARAM_RELTYPE:
+                       shift = VCAL_RELTYPE_PARAM_NUM;
+                       pList = pCalReltypeValList;
+                       bSupported = true;
+                       break;
+               default:
+
+                       if ((szParam = (char *)realloc(szParam, 5)) == NULL) {
+                               _DEBUG_ERROR("__VCalParamEncode():realloc failed\n");
+                               return NULL;
+                       }
+                       temp_len = 0;
+                       temp_len = g_strlcat(szParam, "NONE", 5);
+                       if (temp_len >= 5) {
+                               _DEBUG_ERROR("szParam buffer overflow !!");
+                               /* todo : exception handling */
+                       }
+                       break;
+               }
+
+               if (bSupported == true) {
+                       for (i = 0, sNum = 0x00000001; i < shift; i++) {
+                               if (pTemp->paramValue & sNum) {
+                                       if ((szParam = (char *)realloc(szParam, (len += (strlen(pList[i].szName) + 2)))) == NULL) {
+
+                                               _DEBUG_ERROR("__VCalParamEncode():realloc failed\n");
+                                               return NULL;
+                                       }
+
+                                       temp_len = 0;
+                                       temp_len = g_strlcat(szParam, pList[i].szName, len);
+                                       temp_len = g_strlcat(szParam, ", \0", len);
+                                       if (temp_len >= (len + 1)) {
+                                               _DEBUG_ERROR("szParam buffer overflow !!");
+                                               /* todo : exception handling */
+                                       }
+                               }
+                               sNum <<= 1;
+                       }
+               }
+
+               for (i = strlen(szParam); i > 0; i--) {
+                       if (szParam[i] == ' ' && szParam[i - 1] == ',') {
+                               szParam[i - 1] = '\0';
+                               break;
+                       }
+               }
+
+               if (pTemp->pNext != NULL)
+                       pTemp = pTemp->pNext;
+               else
+                       break;
+       }
+
+       _DEBUG_VERBOSE("\n ------end __VCalParamEncode ---------..\n");
+
+       _INNER_FUNC_EXIT;
+
+       return szParam;
+}
+
+bool __cal_vcalendar_get_week_day_string(struct tm * start_time, char *s2)
+{
+       _INNER_FUNC_ENTER;
+
+       char *date_string[7] = { "SU", "MO", "TU", "WE", "TH", "FR", "SA" };
+
+       struct tm temp;
+       time_t t = timegm(start_time);
+       gmtime_r(&t, &temp);
+
+       if (temp.tm_wday < 0 || temp.tm_wday > 6) {
+               return false;
+       } else {
+               snprintf(s2, 3, "%s", date_string[temp.tm_wday]);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return true;
+}
+
+struct tm *__cal_vcalendar_compute_pre_time(struct tm *start_tm, struct tm *alarm_tm, const int remind_tick, const cal_sch_remind_tick_unit_t unit, struct tm *ret_tm)
+{
+       _INNER_FUNC_ENTER;
+
+       start_tm->tm_sec = 0;
+       alarm_tm->tm_sec = 0;
+       //      time_t gap_time = cals_mktime(alarm_tm) - cals_mktime(start_tm);
+       time_t timep = timegm(alarm_tm);
+       time_t t = 0;
+
+       // Fix for prevent - B.
+       switch (unit) {
+       case CAL_SCH_TIME_UNIT_MIN:
+               t = timep - 60 * remind_tick;
+               break;
+
+       case CAL_SCH_TIME_UNIT_HOUR:
+               t = timep - 60 * 60 * remind_tick;
+               break;
+
+       case CAL_SCH_TIME_UNIT_DAY:
+               t = timep - 24 * 60 * 60 * remind_tick;
+               break;
+       case CAL_SCH_TIME_UNIT_WEEK:
+               t = timep - 7 * 24 * 60 * 60 * remind_tick;
+               break;
+
+       case CAL_SCH_TIME_UNIT_MONTH:
+               t = timep - 30 * 24 * 60 * 60 * remind_tick;
+               break;
+
+       default:
+               break;
+
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return gmtime_r(&t, ret_tm);
+}
+
+bool __cal_vcalendar_sch_vtree_add_object(VTree * tree, const cal_sch_full_t * sch, vCalType obj_type)
+{
+       _INNER_FUNC_ENTER;
+
+#if 1
+
+       VObject *object;
+       int str_len = 0;
+       int buf_len = 0;
+
+       assert((tree != NULL) && (sch != NULL));
+
+       object = (VObject *) malloc(sizeof(VObject));
+       if (object == NULL) {
+               vcal_free_vtree_memory(tree);
+               return false;
+       }
+
+       memset(object, 0, sizeof(VObject));
+
+       switch (obj_type) {
+       case VCAL_TYPE_CATEGORIES:
+               {
+                       if (sch->cal_type == CALS_SCH_TYPE_TODO) {
+                               break;
+                       }
+
+                       object->property = VCAL_TYPE_CATEGORIES;
+
+                       object->pszValue[0] = (char *)malloc(20);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       memset(object->pszValue[0], 0, 20);
+
+                       object->valueCount = 1;
+               }
+               break;
+
+       case VCAL_TYPE_SUMMARY:
+               {
+                       if (NULL != sch->summary && strlen(sch->summary) != 0) {
+                               object->property = VCAL_TYPE_SUMMARY;
+                               str_len = strlen(sch->summary);
+                               //str_len = (str_len>500)?500:str_len;
+                               _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_SUMMARY(%d) -------------", str_len);
+                               object->pParam = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam, 0, sizeof(VParam));
+
+                               object->pParam->parameter = VCAL_PARAM_CHARSET;
+                               object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
+                               object->pParam->pNext = NULL;
+
+                               object->pParam->pNext = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam->pNext == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam->pNext, 0, sizeof(VParam));
+
+                               object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
+                               object->pParam->pNext->paramValue = 0x01 << VCAL_ENC_PARAM_BASE64;
+
+                               object->pszValue[0] = (char *)malloc(str_len * 2 + 1);
+                               if ((object->pszValue[0]) == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+
+                               if (NULL != sch->summary) {
+                                       memset(object->pszValue[0], 0, str_len + 1);
+                                       memcpy(object->pszValue[0], sch->summary, str_len);
+                               }
+                               _DEBUG_INFO("sch->summary = %s,%s\n", sch->summary, object->pszValue[0]);
+
+                               object->valueCount = 1;
+                       } else {
+                               CAL_FREE(object);
+                               _INNER_FUNC_EXIT;
+                               return true;
+                       }
+               }
+               break;
+
+       case VCAL_TYPE_DESCRIPTION:
+               {
+                       _DEBUG_INFO("---__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DESCRIPTION/ -------------\n");
+
+                       if (NULL != sch->description && strlen(sch->description) != 0) {
+                               object->property = VCAL_TYPE_DESCRIPTION;
+                               str_len = strlen(sch->description);
+                               //str_len = (str_len>500)?500:str_len;
+
+                               object->pParam = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam, 0, sizeof(VParam));
+
+                               object->pParam->parameter = VCAL_PARAM_CHARSET;
+                               object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
+                               object->pParam->pNext = NULL;
+
+                               object->pParam->pNext = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam->pNext == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam->pNext, 0, sizeof(VParam));
+
+                               object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
+                               object->pParam->pNext->paramValue = 0x01 << VCAL_ENC_PARAM_BASE64;
+
+                               object->pszValue[0] = (char *)malloc(str_len + 1);
+                               if ((object->pszValue[0]) == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+
+                               if (sch->description != NULL) {
+                                       memset(object->pszValue[0], 0, str_len + 1);
+                                       memcpy(object->pszValue[0], sch->description, str_len);
+                               }
+                               object->valueCount = 1;
+
+                               _DEBUG_INFO("description = %s", object->pszValue[0]);
+
+                       } else {
+                               CAL_FREE(object);
+                               _INNER_FUNC_EXIT;
+                               return true;
+                       }
+
+               }
+               break;
+       case VCAL_TYPE_LOCATION:
+               {
+                       _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_LOCATION -------------\n");
+
+                       if (NULL != sch->location && strlen(sch->location) != 0) {
+                               object->property = VCAL_TYPE_LOCATION;
+                               str_len = strlen(sch->location);
+                               object->pParam = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam, 0, sizeof(VParam));
+
+                               object->pParam->parameter = VCAL_PARAM_CHARSET;
+                               object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
+                               object->pParam->pNext = NULL;
+
+                               object->pParam->pNext = (VParam *) malloc(sizeof(VParam));
+                               if (object->pParam->pNext == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pParam->pNext, 0, sizeof(VParam));
+
+                               object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
+                               object->pParam->pNext->paramValue = 0x01;
+
+                               object->pszValue[0] = (char *)malloc(str_len + 1);
+                               if ((object->pszValue[0]) == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+
+                               if (sch->location != NULL) {
+                                       memset(object->pszValue[0], 0, str_len + 1);
+                                       memcpy(object->pszValue[0], sch->location, str_len);
+                               }
+                               object->valueCount = 1;
+                       } else {
+                               CAL_FREE(object);
+                               _INNER_FUNC_EXIT;
+                               return true;
+                       }
+
+               }
+               break;
+       case VCAL_TYPE_DTSTART:
+               {
+                       _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DTSTART -------------\n");
+
+                       object->property = VCAL_TYPE_DTSTART;
+
+                       object->pszValue[0] = (char *)malloc(VCALENDAR_TIME_STR_LEN + 1);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       cal_vcalendar_convert_tm_to_vdata_str(&sch->start_date_time, object->pszValue[0]);
+
+                       object->valueCount = 1;
+               }
+               break;
+
+       case VCAL_TYPE_DTEND:
+               {
+                       _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DTEND -------------\n");
+
+                       if (sch->cal_type == CALS_SCH_TYPE_TODO) {
+                               break;
+                       }
+
+                       object->property = VCAL_TYPE_DTEND;
+
+                       object->pszValue[0] = (char *)malloc(VCALENDAR_TIME_STR_LEN + 1);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       cal_vcalendar_convert_tm_to_vdata_str(&sch->end_date_time, object->pszValue[0]);
+
+                       object->valueCount = 1;
+               }
+               break;
+
+               // in Calendar sch data structure, there is no due data field
+               // end_date_time is assigned to due date
+       case VCAL_TYPE_DUE:
+               {
+                       _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DUE -------------\n");
+
+                       if (sch->cal_type != CALS_SCH_TYPE_TODO) {
+                               break;
+                       }
+
+                       object->property = VCAL_TYPE_DUE;
+
+                       object->pszValue[0] = (char *)malloc(VCALENDAR_TIME_STR_LEN + 1);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+                       cal_vcalendar_convert_tm_to_vdata_str(&sch->end_date_time, object->pszValue[0]);
+
+                       object->valueCount = 1;
+               }
+               break;
+
+       case VCAL_TYPE_LAST_MODIFIED:
+               {
+                       _DEBUG_INFO("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_LAST_MODIFIED -------------\n");
+
+                       object->property = obj_type;
+                       object->pszValue[0] = (char *)malloc(VCALENDAR_TIME_STR_LEN + 1);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+                       // get current time
+                       struct tm now;
+
+                       now.tm_year = 105;
+                       now.tm_mon = 2;
+                       now.tm_mday = 4;
+                       now.tm_hour = 10;
+                       now.tm_min = 12;
+                       now.tm_sec = 34;
+
+                       cal_vcalendar_convert_tm_to_vdata_str(&now, object->pszValue[0]);
+
+                       object->valueCount = 1;
+               }
+               break;
+
+       case VCAL_TYPE_AALARM:
+               {
+                       _DEBUG_INFO("\n-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_AALARM -------------\n");
+
+                       if (sch->alarm_list != NULL) {
+                               object->property = VCAL_TYPE_AALARM;
+                               cal_alarm_info_t *tmp_alarm = ((cal_value *) sch->alarm_list->data)->user_data;
+
+                               object->pszValue[0] = (char *)malloc(VCALENDAR_TIME_STR_LEN + 1);
+                               if ((object->pszValue[0]) == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       if (object != NULL) {
+                                               free(object);
+                                               object = NULL;
+                                       }
+                                       return false;
+                               }
+                               struct tm ttm;
+
+                               // TODO: handle alarms(this is one alarm)
+                               struct tm *tm = __cal_vcalendar_compute_pre_time((struct tm *)&sch->start_date_time,
+                                                                                &tmp_alarm->alarm_time, tmp_alarm->remind_tick, tmp_alarm->remind_tick_unit, &ttm);
+                               cal_vcalendar_convert_tm_to_vdata_str(tm, object->pszValue[0]);
+
+                               object->valueCount = 1;
+                       } else {
+                               CAL_FREE(object);
+                               _INNER_FUNC_EXIT;
+                               return true;
+                       }
+               }
+               break;
+
+       case VCAL_TYPE_RRULE:
+               {
+                       _DEBUG_INFO("\n-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_RRULE -------------\n");
+
+                       if (sch->repeat_term != CAL_REPEAT_NONE) {
+                               _DEBUG_INFO(" ------------------------ begine to create RRULE-------------------------- ");
+
+                               object->property = VCAL_TYPE_RRULE;
+
+                               char repeat_end_date[VCALENDAR_TIME_STR_LEN + 1] = { 0 };
+                               char week_day_string[VCALENDAR_TIME_STR_LEN + 1] = { 0 };
+                               cal_vcalendar_convert_tm_to_vdata_str(&sch->repeat_end_date, repeat_end_date);
+
+                               _DEBUG_INFO(" repeat_end_date = %s ", repeat_end_date);
+
+                               char str[100];
+                               memset(str, 0, 100);
+
+                               switch (sch->repeat_term) {
+                               case CAL_REPEAT_EVERY_DAY:
+                                       snprintf(str, sizeof(str), "D%d %s", sch->repeat_interval, repeat_end_date);
+                                       break;
+
+                               case CAL_REPEAT_EVERY_WEEK:
+                               case CAL_REPEAT_EVERY_WEEKDAYS:
+                                       __cal_vcalendar_get_week_day_string((struct tm *)&(sch->start_date_time), week_day_string);
+                                       snprintf(str, sizeof(str), "W%d %s %s", sch->repeat_interval, week_day_string, repeat_end_date);
+                                       break;
+
+                               case CAL_REPEAT_EVERY_MONTH:
+                               case CAL_REPEAT_EVERY_MONTH_DAY:
+                                       snprintf(str, sizeof(str), "MD%d %s", sch->repeat_interval, repeat_end_date);
+                                       break;
+
+                               case CAL_REPEAT_EVERY_YEAR:
+                               case CAL_REPEAT_EVERY_YEAR_DAY:
+                                       snprintf(str, sizeof(str), "YM%d %s", sch->repeat_interval, repeat_end_date);
+                                       break;
+
+                               default:
+                                       break;
+                               }
+                               object->valueCount = 1;
+
+                               object->pszValue[0] = (char *)malloc(strlen(str) + 1);
+                               if ((object->pszValue[0]) == NULL) {
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               memset(object->pszValue[0], 0, (strlen(str) + 1));
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], str, (strlen(str) + 1));
+                               if (buf_len >= (strlen(str) + 1)) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+
+                               _DEBUG_INFO("RRULE = %s", object->pszValue[0]);
+
+                       } else {
+                               CAL_FREE(object);
+                               _INNER_FUNC_EXIT;
+                               return true;
+                       }
+               }
+               break;
+
+       case VCAL_TYPE_PRIORITY:
+               {
+                       _DEBUG_INFO("\n-------------------__cal_vcalendar_todo_vtree_add_object /VCAL_TYPE_PRIORITY -------------\n");
+
+                       object->property = VCAL_TYPE_PRIORITY;
+
+                       char str[3];
+                       memset(str, 0, 3);
+
+                       snprintf(str, sizeof(str), "%d", sch->priority);
+
+                       object->pszValue[0] = (char *)malloc(3);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       memset(object->pszValue[0], 0, 3);
+                       buf_len = 0;
+                       buf_len = g_strlcpy(object->pszValue[0], str, 3);
+                       if (buf_len >= 3) {
+                               _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       object->valueCount = 1;
+               }
+               break;
+
+       case VCAL_TYPE_STATUS:
+               {
+                       _DEBUG_INFO("\n-------------------__cal_vcalendar_todo_vtree_add_object /VCAL_TYPE_STATUS -------------\n");
+
+                       if (sch->cal_type != CALS_SCH_TYPE_TODO) {
+                               break;
+                       }
+
+                       object->property = VCAL_TYPE_STATUS;
+
+                       object->pszValue[0] = (char *)malloc(20);
+                       if ((object->pszValue[0]) == NULL) {
+                               vcal_free_vtree_memory(tree);
+                               CAL_FREE(object);
+
+                               return false;
+                       }
+
+                       memset(object->pszValue[0], 0, 20);
+
+                       switch (sch->task_status) {
+                       case CALS_EVENT_STATUS_TENTATIVE:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "TENTATIVE", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_EVENT_STATUS_CONFIRMED:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "CONFIRMED", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_EVENT_STATUS_CANCELLED:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "CANCELLED", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_TODO_STATUS_NEEDS_ACTION:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "NEEDS-ACTION", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_TODO_STATUS_COMPLETED:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "COMPLETED", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_TODO_STATUS_IN_PROCESS:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "IN-PROCESS", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       case CALS_TODO_STATUS_CANCELLED:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "CANCELLED", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       default:
+                               buf_len = 0;
+                               buf_len = g_strlcpy(object->pszValue[0], "NEEDS-ACTION", 20);
+                               if (buf_len >= 20) {
+                                       _DEBUG_ERROR("object->pszValue[0] buffer overflow !!");
+                                       vcal_free_vtree_memory(tree);
+                                       CAL_FREE(object);
+
+                                       return false;
+                               }
+                               break;
+                       }
+
+                       object->valueCount = 1;
+                       break;
+               }
+
+       default:
+               break;
+
+       }
+
+       // if current is the header of the list
+       if (tree->pTop == NULL) {
+               _DEBUG_INFO("\n--------tree->pTop = object--------------\n");
+               tree->pTop = object;
+       } else {
+               tree->pCur->pSibling = object;
+       }
+
+       // the object is the current object
+       tree->pCur = object;
+
+#endif
+       _INNER_FUNC_EXIT;
+       return true;
+}
+
+bool _cal_convert_sch_to_vcalendar(const cal_sch_full_t * sch_array, const int sch_count, char **vcal, cal_vCal_ver_t version)
+{
+       _INNER_FUNC_ENTER;
+
+#if 1
+       int i;
+       int j;
+
+       VTree *cal_tree = NULL;
+       VTree *tmp_tree = NULL;
+
+       vCalType obj_type[] = {
+               VCAL_TYPE_SUMMARY,
+               VCAL_TYPE_DESCRIPTION,
+               VCAL_TYPE_LOCATION,
+               VCAL_TYPE_DTSTART,
+               VCAL_TYPE_DTEND,
+               VCAL_TYPE_LAST_MODIFIED,
+               VCAL_TYPE_ATTACH,
+               VCAL_TYPE_CATEGORIES,
+               VCAL_TYPE_PRIORITY,
+               VCAL_TYPE_STATUS,
+               VCAL_TYPE_AALARM,
+               VCAL_TYPE_RRULE,
+               0
+       };
+
+       assert((sch_array != NULL) && (vcal != NULL));
+
+       cal_tree = (VTree *) malloc(sizeof(VTree));
+       if (cal_tree == NULL)
+               return false;
+
+       memset(cal_tree, 0, sizeof(VTree));
+
+       cal_tree->treeType = VCALENDAR;
+       cal_tree->pTop = NULL;
+       cal_tree->pCur = NULL;
+       cal_tree->pNext = NULL;
+
+       VTree *tree = cal_tree;
+
+       for (i = 0; i < sch_count; i++) {
+               tmp_tree = (VTree *) malloc(sizeof(VTree));
+               if (tmp_tree == NULL) {
+                       vcal_free_vtree_memory(cal_tree);
+                       return false;
+               }
+
+               memset(tmp_tree, 0, sizeof(VTree));
+
+               if ((sch_array + i)->cal_type == CALS_SCH_TYPE_TODO) {
+                       tmp_tree->treeType = VTODO;
+                       obj_type[4] = VCAL_TYPE_DUE;
+               } else {
+                       tmp_tree->treeType = VEVENT;
+               }
+
+               tmp_tree->pTop = NULL;
+               tmp_tree->pCur = NULL;
+               tmp_tree->pNext = NULL;
+
+               j = 0;
+               while (obj_type[j]) {
+                       if (!__cal_vcalendar_sch_vtree_add_object(tmp_tree, sch_array + i, obj_type[j])) {
+                               vcal_free_vtree_memory(cal_tree);
+                               return false;
+                       }
+                       j++;
+               }
+
+               tree->pNext = tmp_tree;
+               tree = tmp_tree;
+
+       }
+
+       tree->pNext = NULL;
+
+       *vcal = vcal_encode(cal_tree);
+       if (*vcal == NULL) {
+               _DEBUG_ERROR("vcal_encode Failed");
+               vcal_free_vtree_memory(cal_tree);
+               return false;
+       }
+
+       vcal_free_vtree_memory(cal_tree);
+       _DEBUG_TRACE("\n---------------------------exit _cal_convert_sch_to_vcalendar--------- -------------\n");
+#endif
+       _INNER_FUNC_EXIT;
+       return true;
+}
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.h b/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-codec.h
new file mode 100755 (executable)
index 0000000..7c970d2
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_ICAL_CODEC_H__
+#define __CALENDAR_SVC_ICAL_CODEC_H__
+
+#define TAB                            0x09
+#define WSP                            0x20
+#define VCALENDAR              0x02
+#define VEVENT                 0x03
+#define VTODO                  0x04
+#define VJOURNAL               0x05
+#define VFREEBUSY              0x06
+#define VTIMEZONE              0x07
+#define VALARM                 0x08
+#define STANDARD               0x09
+#define DAYLIGHT               0x0a
+#define VDATA_VALUE_COUNT_MAX  2000
+
+/****************************************************************************************************/
+/*                                                                                     ENUMERATION DECLARATION                                                                 */
+/****************************************************************************************************/
+/* Property */
+typedef enum {
+       VCAL_TYPE_AALARM,
+       VCAL_TYPE_ACTION,
+       VCAL_TYPE_ATTACH,
+       VCAL_TYPE_ATTENDEE,
+       VCAL_TYPE_BEGIN,
+       VCAL_TYPE_CALSCALE,
+       VCAL_TYPE_CATEGORIES,
+       VCAL_TYPE_CLASS,
+       VCAL_TYPE_COMMENT,
+       VCAL_TYPE_COMPLETED,
+       VCAL_TYPE_CONTACT,
+       VCAL_TYPE_CREATED,
+       VCAL_TYPE_DALARM,
+       VCAL_TYPE_DAYLIGHT,
+       VCAL_TYPE_DCREATED,
+       VCAL_TYPE_DESCRIPTION,
+       VCAL_TYPE_DTEND,
+       VCAL_TYPE_DTSTAMP,
+       VCAL_TYPE_DTSTART,
+       VCAL_TYPE_DUE,
+       VCAL_TYPE_DURATION,
+       VCAL_TYPE_END,
+       VCAL_TYPE_EXDATE,
+       VCAL_TYPE_EXRULE,
+       VCAL_TYPE_FREEBUSY,
+       VCAL_TYPE_GEO,
+       VCAL_TYPE_LAST_MODIFIED,
+       VCAL_TYPE_LOCATION,
+       VCAL_TYPE_MALARM,
+       VCAL_TYPE_METHOD,
+       VCAL_TYPE_ORGANIZER,
+       VCAL_TYPE_PALARM,
+       VCAL_TYPE_PERCENT_COMPLETE,
+       VCAL_TYPE_PRIORITY,
+       VCAL_TYPE_PRODID,
+       VCAL_TYPE_RDATE,
+       VCAL_TYPE_RECURRENCE_ID,
+       VCAL_TYPE_RELATED_TO,
+       VCAL_TYPE_REPEAT,
+       VCAL_TYPE_REQUEST_STATUS,
+       VCAL_TYPE_RESOURCES,
+       VCAL_TYPE_RNUM,
+       VCAL_TYPE_RRULE,
+       VCAL_TYPE_SEQUENCE,
+       VCAL_TYPE_STANDARD,
+       VCAL_TYPE_STATUS,
+       VCAL_TYPE_SUMMARY,
+       VCAL_TYPE_TRANSP,
+       VCAL_TYPE_TRIGGER,
+       VCAL_TYPE_TZ,
+       VCAL_TYPE_TZID,
+       VCAL_TYPE_TZNAME,
+       VCAL_TYPE_TZOFFSETFROM,
+       VCAL_TYPE_TZOFFSETTO,
+       VCAL_TYPE_TZURL,
+       VCAL_TYPE_URL,
+       VCAL_TYPE_UID,
+       VCAL_TYPE_VALARM,
+       VCAL_TYPE_VCALENDAR,
+       VCAL_TYPE_VERSION,
+       VCAL_TYPE_VEVENT,
+       VCAL_TYPE_VFREEBUSY,
+       VCAL_TYPE_VJOURNAL,
+       VCAL_TYPE_VTIMEZONE,
+       VCAL_TYPE_VTODO,
+       VCAL_TYPE_ALLDAY
+} vCalType;
+
+#define VCAL_TYPE_NUM  66
+
+/* Parameter */
+typedef enum {
+       VCAL_PARAM_ALTREP,
+       VCAL_PARAM_CHARSET,
+       VCAL_PARAM_CN,
+       VCAL_PARAM_CONTEXT,
+       VCAL_PARAM_CUTYPE,
+       VCAL_PARAM_DELEGATED_FROM,
+       VCAL_PARAM_DELEGATED_TO,
+       VCAL_PARAM_DIR,
+       VCAL_PARAM_ENCODING,
+       VCAL_PARAM_EXPECT,
+       VCAL_PARAM_FBTYPE,
+       VCAL_PARAM_FMTYPE,
+       VCAL_PARAM_LANGUAGE,
+       VCAL_PARAM_MEMBER,
+       VCAL_PARAM_PARTSTAT,
+       VCAL_PARAM_RANGE,
+       VCAL_PARAM_RELATED,
+       VCAL_PARAM_RELTYPE,
+       VCAL_PARAM_ROLE,
+       VCAL_PARAM_RSVP,
+       VCAL_PARAM_SENT_BY,
+       VCAL_PARAM_STATUS,
+       VCAL_PARAM_TYPE,
+       VCAL_PARAM_TZID,
+       VCAL_PARAM_VALUE
+} vCalendarParamName;
+
+#define VCAL_PARAM_NUM         25
+
+/* Cu type value */
+
+#define VCAL_CUTYPE_PARAM_NUM  5
+
+/* Parameter encoding value */
+typedef enum {
+       VCAL_ENC_PARAM_B,
+       VCAL_ENC_PARAM_BASE64,
+       VCAL_ENC_PARAM_QUOTED_PRINTABLE,
+       VCAL_ENC_PARAM_7BIT,
+       VCAL_ENC_PARAM_8BIT
+} vCalEncVal;
+
+#define VCAL_ENCODE_PARAM_NUM  5
+
+/* Fb Type value */
+
+#define VCAL_FBTYPE_PARAM_NUM  4
+
+/* Partstat value */
+
+#define VCAL_PARTSTAT_PARAM_NUM        7
+
+/* Range value */
+
+#define VCAL_RANGE_PARAM_NUM   2
+
+/* Related value */
+
+#define VCAL_RELATED_PARAM_NUM 2
+
+/* Rel type value */
+
+#define VCAL_RELTYPE_PARAM_NUM 3
+
+/* Value value */
+
+#define VCAL_VALUE_PARAM_NUM           21
+
+/* Parameter type value */
+
+#define VCAL_TYPE_PARAM_NUM            28
+
+/* Parameter expect value */
+
+#define VCAL_EXPECT_PARAM_NUM          4
+
+/* Parameter role value */
+
+#define VCAL_ROLE_PARAM_NUM            8
+
+/* Parameter RSVP value */
+
+#define VCAL_RSVP_PARAM_NUM            4
+
+/* Parameter Charset value */
+typedef enum {
+       VCAL_CHARSET_PARAM_UTF_8,
+       VCAL_CHARSET_PARAM_UTF_16,
+       VCAL_CHARSET_PARAM_SHIFT_JIS
+} vCalCharsetVal;
+
+#define VCAL_CHARSET_PARAM_NUM 2
+
+/* Parameter STATUS value */
+
+#define VCAL_STATUS_PARAM_NUM          8
+
+/* VCalendar encoder/decoder status */
+#define VCAL_TYPE_NAME_STATUS  1
+#define VCAL_PARAM_NAME_STATUS 2
+#define VCAL_TYPE_VALUE_STATUS 3
+#define VCAL_PARAM_VALUE_STATUS 4
+
+/****************************************************************************************************/
+/*                                                                      GLOBAL STRUCTURE DECLARATION                                                                   */
+/****************************************************************************************************/
+
+typedef struct _VParam VParam;
+typedef struct _VObject VObject;
+typedef struct _ValueObj ValueObj;
+typedef struct _VTree VTree;
+
+struct _VTree {
+       int treeType;
+       VObject *pTop;
+       VObject *pCur;
+       VTree *pNext;
+};
+
+struct _VParam {
+       int parameter;
+       int paramValue;
+       VParam *pNext;
+};
+
+struct _VObject {
+       int property;
+       VParam *pParam;
+       int valueCount;
+       int numOfBiData;
+       char *pszValue[VDATA_VALUE_COUNT_MAX];
+       VObject *pSibling;
+       VObject *pParent;
+       VObject *pChild;
+
+       char *pszGroupName;     //VDATA_GROUPNAME_SUPPORTED
+};
+
+struct _ValueObj {
+       char *szName;
+       int flag;
+};
+
+/****************************************************************************************************/
+/*                                                                             FUNCTION DECLARATION*/
+/****************************************************************************************************/
+int _VRLSpace(char *);
+int _VRTSpace(char *);
+int _VEscape(char *);
+void _VFolding(char *, char *);
+int _VQPEncode(char *, char *);
+
+bool _cal_convert_sch_to_vcalendar(const cal_sch_full_t * sch_array, const int sch_count, char **vcal, cal_vCal_ver_t version);
+#endif                         /* __CALENDAR_SVC_ICAL_CODEC_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-utils.c b/src/fw-plugins/common-public/vobject-tizen/src/cals-ical-utils.c
new file mode 100755 (executable)
index 0000000..e7633ee
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cals-typedef.h"
+#include "cals-ical-codec.h"
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "VOBJECT_TIZEN"
+#endif
+
+/* Function Declaration */
+static void __VHexaEncoder(char *);
+static int __VIsPrintable(char);
+
+/**
+ * vCardIsSpace() returns one if char is either a space, tab, or newline.
+ *
+ * @param      s1                [in] pointer to first string.
+ * @param      s2                [in] pointer to second string.
+ * @return     1                 'in' is a space character.
+ * @return     0                 'in' is not a space.
+ */
+int _VIsSpace(char in)
+{
+       _INNER_FUNC_ENTER;
+       //DLOG(  "_VIsSpace() enter..\n");
+
+       if ((in == TAB) || (in == WSP)) {
+               _INNER_FUNC_EXIT;
+               return 1;
+       } else {
+               _INNER_FUNC_EXIT;
+               return 0;
+       }
+}
+
+/*
+ * vRemLeadSpace() removes leading space in string 'in'.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int _VRLSpace(char *in)
+{
+       _INNER_FUNC_ENTER;
+
+       int i, j;
+       short int done;
+
+       //DLOG(  "_VRLSpace() enter..\n");
+
+       i = 0;
+       done = 0;
+
+       while (!done && in[i]) {
+               if (_VIsSpace(in[i])) {
+                       i++;
+               } else {
+                       done = 1;
+               }
+       }
+
+       j = 0;
+       while (in[i]) {
+               in[j++] = in[i++];
+       }
+
+       in[j] = '\0';
+
+       _INNER_FUNC_EXIT;
+
+       return 0;
+}
+
+/*
+ * vRemTermSpace() removes terminating space.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int _VRTSpace(char *in)
+{
+       _INNER_FUNC_ENTER;
+
+       int i;
+       short int done;
+
+       //DLOG(  "_VRTSpace() enter..\n");
+
+       i = strlen(in) - 1;
+       done = 0;
+
+       while (!done && !(i < 0)) {
+               if (_VIsSpace(in[i])) {
+                       in[i--] = '\0';
+               } else {
+                       done = 1;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return (0);
+}
+
+/**
+ * vFolding() decodes the base64 encoded input.
+ *
+ * @param      contentline        Original line (unfolded)
+ * @param      Dest               The destination buffer of folded result
+ */
+void _VFolding(char *result, char *contentline)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0;
+
+       //DLOG(  "_VFolding() enter..\n");
+
+       while (*contentline) {
+               if (i == 75) {
+                       i = 0;
+                       *result++ = '\r';
+                       *result++ = '\n';
+                       *result++ = ' ';
+               }
+
+               *result++ = *contentline++;
+               i++;
+       }
+
+       *result++ = '\0';
+
+       _INNER_FUNC_EXIT;
+}
+
+/*
+ * VEscape() escapes character.
+ *
+ * @param      in                 [inout] pointer to string.
+ * @return     0                  if success.
+ */
+int _VEscape(char *in)
+{
+       _INNER_FUNC_ENTER;
+
+       int i;
+       int index;
+       int len;
+       char *buf = NULL;
+       char c;
+
+       //DLOG(  "_VEscape() enter..\n");
+
+       len = strlen(in);
+       buf = (char *)calloc(1, len * 2 + 1);
+
+       for (i = 0, index = 0; i < len; i++) {
+               c = in[i];
+               if (c == ';') {
+                       buf[index++] = '\\';
+               }
+               buf[index++] = c;
+       }
+
+       strncpy(in, buf, len * 2 + 1);
+       free(buf);
+
+       _INNER_FUNC_EXIT;
+
+       return (0);
+}
+
+/**
+ * vQuotedPrintableEncoder() decodes the quoted-printalbe encoded input.
+ *
+ * @param      Src                Quoted-printable encoded input
+ * @param      Dest               The destination buffer of decoded value
+ * @return     int                The total length decoded value
+ */
+int _VQPEncode(char *dest, char *src)
+{
+       _INNER_FUNC_ENTER;
+
+       int i = 0, j = 0, k = 0;
+       char encoded[2] = { 0x0f, 0x0f };
+
+       //DLOG(  "_VQPEncode() enter..\n");
+
+       while (src[i] /*&& ( src[i] > 0 ) */ ) {
+               if (k == 73 && _VIsSpace(src[i])) {
+                       if (src[i] == WSP) {
+                               dest[j++] = '=';
+                               dest[j++] = '2';
+                               dest[j++] = '0';
+                               k += 3;
+                       } else if (src[i] == TAB) {
+                               dest[j++] = '=';
+                               dest[j++] = '0';
+                               dest[j++] = '9';
+                               k += 3;
+                       }
+               }
+               /*      else if ( k == 76 )
+                  {
+                  dest[j++] = '='; dest[j++] = WSP;
+                  k = 0;
+                  } */
+               else if (!__VIsPrintable(src[i])) {
+                       dest[j++] = '=';
+                       encoded[0] &= (src[i] >> 4);
+                       encoded[1] &= (src[i]);
+                       __VHexaEncoder(encoded);
+                       dest[j++] = encoded[0];
+                       encoded[0] = 0x0f;
+                       dest[j++] = encoded[1];
+                       encoded[1] = 0x0f;
+                       k += 3;
+               } else if (src[i] == '\r' || src[i] == '\n') {
+                       dest[j++] = '=';
+                       dest[j++] = '0';
+                       dest[j++] = 'D';
+                       k += 3;
+                       dest[j++] = '=';
+                       dest[j++] = '0';
+                       dest[j++] = 'A';
+                       k += 3;
+               } else {
+                       dest[j++] = src[i];
+                       k++;
+               }
+               i++;
+       }
+
+       dest[j] = '\0';
+
+       _INNER_FUNC_EXIT;
+
+       return j;
+}
+
+/**
+ * vIsPrintable() check whether the input is printable.
+ *
+ * @param      in
+ * @return     true/false            if input is printable :true else : false
+ */
+static int __VIsPrintable(char in)
+{
+       _INNER_FUNC_ENTER;
+       //DLOG(  "__VIsPrintable() enter..\n");
+
+       if (in >= 33 && in <= 60) {
+               _INNER_FUNC_EXIT;
+               return true;
+       } else if (in >= 62 && in <= 126) {
+               _INNER_FUNC_EXIT;
+               return true;
+       } else if (in == WSP || in == TAB) {
+               _INNER_FUNC_EXIT;
+               return true;
+       } else if (in == '\r' || in == '\n') {
+               _INNER_FUNC_EXIT;
+               return true;
+       } else {
+               _INNER_FUNC_EXIT;
+               return false;
+       }
+}
+
+/**
+ * vHexaEncoder() output the hexadecimal value of input character value.
+ *
+ * @return     qp               Character representation of input hexadecimal value
+ */
+static void __VHexaEncoder(char *qp)
+{
+       _INNER_FUNC_ENTER;
+
+       int i;
+
+       //DLOG(  "__VHexaEncoder() enter..\n");
+
+       for (i = 0; i < 2; i++) {
+               switch (qp[i]) {
+               case 0:
+                       qp[i] = '0';
+                       break;
+               case 1:
+                       qp[i] = '1';
+                       break;
+               case 2:
+                       qp[i] = '2';
+                       break;
+               case 3:
+                       qp[i] = '3';
+                       break;
+               case 4:
+                       qp[i] = '4';
+                       break;
+               case 5:
+                       qp[i] = '5';
+                       break;
+               case 6:
+                       qp[i] = '6';
+                       break;
+               case 7:
+                       qp[i] = '7';
+                       break;
+               case 8:
+                       qp[i] = '8';
+                       break;
+               case 9:
+                       qp[i] = '9';
+                       break;
+               case 10:
+                       qp[i] = 'A';
+                       break;
+               case 11:
+                       qp[i] = 'B';
+                       break;
+               case 12:
+                       qp[i] = 'C';
+                       break;
+               case 13:
+                       qp[i] = 'D';
+                       break;
+               case 14:
+                       qp[i] = 'E';
+                       break;
+               case 15:
+                       qp[i] = 'F';
+                       break;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+}
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-ical.h b/src/fw-plugins/common-public/vobject-tizen/src/cals-ical.h
new file mode 100755 (executable)
index 0000000..bfbca89
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_ICAL_H__
+#define __CALENDAR_SVC_ICAL_H__
+#define VCALENDAR_TIME_STR_LEN 16
+
+/**
+* @}
+*/
+#endif                         /* __CALENDAR_SVC_ICAL_H__ */
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-provider.c b/src/fw-plugins/common-public/vobject-tizen/src/cals-provider.c
new file mode 100755 (executable)
index 0000000..ed4dfd8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ctype.h>
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <vconf.h>
+
+#include "cals-internal.h"
+#include "cals-typedef.h"
+#include "cals-ical-codec.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "VOBJECT_TIZEN"
+#endif
+
+API int vobject_calendar_svc_util_convert_event_to_vcs(cal_struct * record, char **raw_data, int *data_size)
+{
+       _EXTERN_FUNC_ENTER;
+
+       bool is_success = FALSE;
+
+       retv_if(NULL == record, CAL_ERR_ARG_NULL);
+       retv_if(NULL == raw_data, CAL_ERR_ARG_NULL);
+
+       is_success = _cal_convert_sch_to_vcalendar((cal_sch_full_t *) (record->user_data), 1, raw_data, CAL_VCAL_VER_1_0);
+       retvm_if(!is_success, CAL_ERR_FAIL, "_cal_convert_sch_to_vcalendar() Failed");
+
+       _EXTERN_FUNC_EXIT;
+
+       return CAL_SUCCESS;
+}
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-typedef.h b/src/fw-plugins/common-public/vobject-tizen/src/cals-typedef.h
new file mode 100755 (executable)
index 0000000..932885f
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CALENDAR_SVC_TYPEDEF_H_
+#define _CALENDAR_SVC_TYPEDEF_H_
+
+#include <time.h>
+
+#include "calendar-svc-provider.h"
+
+#define BENCHMARK_YEAR                         1900L           /**< tm_year's benchmark */
+
+typedef enum {
+       CAL_STRUCT_TYPE_SCHEDULE = 0,   /**< schedule type */
+       CAL_STRUCT_TYPE_CALENDAR,       /**< calendar type */
+       CAL_STRUCT_TYPE_TODO,    /**< task type   */
+       CAL_STRUCT_TYPE_TIMEZONE,
+       CAL_STRUCT_TYPE_SCHEDULE_LIST,
+       CAL_STRUCT_TYPE_TODO_LIST,
+       CAL_STRUCT_TYPE_UPDATED_LIST,
+} cal_struct_type;
+
+typedef enum {
+       CAL_EVENT_PATICIPANT = 0,       /**< CAL_STRUCT_PARTICIPANT */
+       CAL_EVENT_CATEGORY,             /**< CAL_STRUCT_CATEFORY */
+       CAL_EVENT_RECURRENCY,   /**< CAL_STRUCT_RECURRENCY */
+       CAL_EVENT_DELETE,               /**< CAL_STRUCT_DELETE */
+       CAL_EVENT_SYNC_STATUS,  /**< CAL_STRUCT_SYNC_STATUS */
+       CAL_EVENT_CALENDAR,     /**< CAL_STRUCT_CALENDAR */
+       CAL_EVENT_ALARM,
+       CAL_EVENT_MAX,
+
+} cal_data_type_t;
+
+struct _cal_struct {
+       cal_struct_type event_type;
+       void *user_data;
+};
+
+struct _cal_value {
+       cal_data_type_t v_type;
+       void *user_data;
+};
+
+/**
+ * @enum calendar_type_t
+ * This enumeration defines calendar type.
+ */
+typedef enum {
+       CAL_ALL_CALENDAR = 0,                                   /**< all calendar type */
+       CAL_PHONE_CALENDAR,                                             /**< phone calendar type */
+       CAL_ACTIVESYNC_CALENDAR,                                /**< activesync calendar type*/
+       CAL_GOOGLE_CALENDAR                                             /**< google calendar type*/
+} calendar_type_t;
+
+/**
+ * @enum cal_type_t
+ * This enumeration defines calendar event type.
+ */
+typedef enum {
+       CALS_SCH_TYPE_NONE = 0,                 /**< None type */
+       CALS_SCH_TYPE_EVENT,    /**< schedule event type */
+       CALS_SCH_TYPE_TODO,             /**< task event type */
+       CALS_SCH_TYPE_MAX,              /**< max type */
+} cals_sch_type;
+
+/**
+ * @enum cal_vCal_ver_t
+ * This enumeration defines vCalendar version.
+ */
+typedef enum {
+       CAL_VCAL_VER_1_0 = 0,   /**< vCalendar ver 1.0 */
+       CAL_VCAL_VER_2_0,               /**< vCalendar ver 2.0 */
+       CAL_VCAL_VER_UNKNOWN    /**< vCalendar ver unknown */
+} cal_vCal_ver_t;
+
+/**
+ * @enum cal_priority_t
+ * This enumeration defines priority for todo data.
+ */
+typedef enum {
+       CAL_PRIORITY_LOW,       /**< priority low */
+       CAL_PRIORITY_MID,       /**< priority middle */
+       CAL_PRIORITY_HIGH       /**< priority high */
+} cal_priority_t;
+
+/**
+ * @enum cal_starting_day_type_t
+ * This enumeration defines starting day.
+ */
+typedef enum {
+       CAL_STARTING_DAY_SUNDAY = 0,    /**< starting day is sunday */
+       CAL_STARTING_DAY_MONDAY         /**< starting day is monday */
+} cal_starting_day_type_t;
+
+/**
+ * This structure defines schedule information.
+ */
+typedef struct {
+       int index;                              /**< Record index */
+       int account_id;                 /**< Account_id */
+       cals_sch_type cal_type;                 /**< Calendar event type */
+
+       char *summary;                  /**< Summary, appointment, task: subject, birthday:Name */
+       char *description;              /**< Description,appointment, task: description, anniversary,holiday:occasion*/
+       char *location;                 /**< Location */
+       char *categories;
+       GList *meeting_category;        /**< collection of categories */
+       bool all_day_event;             /**< All day event flag */
+       struct tm start_date_time;      /**< schedule:start time, anniv,holiday,birthday,memo,todo: date */
+       struct tm end_date_time;                /**< end time */
+       GList *alarm_list;
+       cal_repeat_term_t repeat_term;          /**< Repeat term */
+       int repeat_interval;    /**< Interval of repeat term */
+       int repeat_until_type;  /**< repeat until type */
+       int repeat_occurrences; /**< occurrences of repeat */
+       struct tm repeat_end_date;      /**< End date for repeat */
+       cal_date_type_t sun_moon;                       /**< Using sun or lunar calendar */
+       cal_starting_day_type_t week_start;                     /**< Start day of a week */
+       char *week_flag;        //[DAY_OF_A_WEEK + 1]; /**< Indicate which day is select in a week */
+       int day_date;                   /**< 0- for weekday(sun,mon,etc.), 1- for specific day(1,2.. Etc) */
+       struct tm last_modified_time;   /**< for PC Sync */
+       bool missed;                            /**< Miss alarm flag */
+       cals_status_t task_status;              /**< current task status */
+       cal_priority_t priority;                /**< Priority */
+       int timezone;                   /**< timezone of task */
+       int file_id;                    /**< file id for attach or alarm tone*/
+       int contact_id;                 /**< contact id for birthday in contact list */
+       GList *attendee_list;   /**< collection of attendee */
+       int busy_status;                /**< ACS, G : Flag of busy or not */
+       int sensitivity;                /**< ACS, G : The sensitivity (public, private, confidential). #cal_visibility_type_t*/
+       int meeting_status;             /**< ACS, G : The status of the meeting. */
+       char *uid;                              /**< ACS, G : Unique ID of the meeting item */
+       char *organizer_name;           /**< ACS, G : Name of organizer(author) */
+       char *organizer_email;  /**< ACS, G : Email of organizer */
+       calendar_type_t calendar_type;          /**< ACS, G : Type(all,phone,google) of calendar */
+       char *gcal_id;                  /**< G : Server id of calendar */
+       char *updated;                  /**< G : Updated time stamp */
+       int location_type;              /**< G : Location type */
+       char *location_summary; /**< G : A simple string value that can be used as a representation of this location */
+       char *etag;                             /**< G : ETAG of this event */
+       int calendar_id;                        /**< G : id to map from calendar table */
+       cal_sync_status_t sync_status;          /**< G : Indication for event entry whether added/ modified/ deleted */
+       char *edit_uri;      /**< G : EditUri for google calendar */
+       char *gevent_id;                        /**< G : Server id of an event */
+       int dst;                                        /**< dst of event */
+       GList *exception_date_list;                    /**< exception dates */
+       int original_event_id;        /**< original event id for recurrency exception */
+       double latitude;
+       double longitude;
+       char *tz_name;
+       char *tz_city_name;
+       int email_id;
+       int availability;
+       struct tm created_date_time; /**< created time */
+       struct tm completed_date_time; /**< completed time */
+       int progress;
+} cal_sch_full_t;
+
+/**
+ * This structure defines exception information of alarm.
+ */
+typedef struct {
+       int alarm_id;                   /**< Alarm id */
+       int event_id;
+       cal_alert_type_t alarm_type;                    /**< Alert type(see 'cal_alert_type_t') */
+       int is_deleted;
+
+       /* audio */
+       /* -- trigger */
+       struct tm alarm_time;
+       int remind_tick;
+       cal_sch_remind_tick_unit_t remind_tick_unit;
+       /* --attach */
+       char *alarm_tone;                       /**< Alert Sound File Name */
+
+       /* display */
+       char *alarm_description;                        /**< Alert description */
+
+       /* email */
+
+} cal_alarm_info_t;
+
+#endif                         // _CALENDAR_SVC_TYPEDEF_H_
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-utils.c b/src/fw-plugins/common-public/vobject-tizen/src/cals-utils.c
new file mode 100755 (executable)
index 0000000..a2b8dd9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "cals-typedef.h"
+
+#include "utility/sync_util.h"
+
+#ifndef SYNC_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "VOBJECT_TIZEN"
+#endif
+
+bool cal_vcalendar_convert_tm_to_vdata_str(const struct tm * tm, char *utc_str)
+{
+       _EXTERN_FUNC_ENTER;
+
+       memset(utc_str, 0, 17);
+
+       snprintf(utc_str, 17, "%04ld%02d%02dT%02d%02d%02dZ", tm->tm_year + BENCHMARK_YEAR, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+       _EXTERN_FUNC_EXIT;
+
+       return true;
+
+}
diff --git a/src/fw-plugins/common-public/vobject-tizen/src/cals-utils.h b/src/fw-plugins/common-public/vobject-tizen/src/cals-utils.h
new file mode 100755 (executable)
index 0000000..a27b417
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CALENDAR_SVC_UTILS_H__
+#define __CALENDAR_SVC_UTILS_H__
+
+bool cal_vcalendar_convert_tm_to_vdata_str(const struct tm *tm, char *utc_str);
+
+#endif                         /* __CALENDAR_SVC_UTILS_H__ */
diff --git a/sync-agent.manifest b/sync-agent.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/test/client/dummy/dummy_client.c b/test/client/dummy/dummy_client.c
new file mode 100755 (executable)
index 0000000..11f1a50
--- /dev/null
@@ -0,0 +1,590 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#define COMPONENT_TAG APP
+#define LOG_TAG "DUMMY_CLIENT"
+
+#define API_RESULT_FAILURE     0
+#define API_RESULT_SUCCESS     1
+
+#include <sync_agent.h>
+
+GMainLoop *g_mainloop;
+gchar g_policy_type[256];
+
+#define DUMMY_CLIENT_CONFIG_FILE       "/usr/share/dummy-cfg/dummy_client_fw_config.xml"
+
+typedef enum {
+       DUMMY_CLIENT_FAIL = -1,         /**< Fail */
+       DUMMY_CLIENT_SUCCESS = 0                /**< Successful */
+} dummy_client_error_e;
+
+typedef enum {
+       DUMMY_BACKUP_SERVICE_ITEMS_TO_FILE = 1,
+       DUMMY_GET_USED_ITEM_COUNT,
+       DUMMY_GET_DEVINFO,
+       DUMMY_EXECUTE_DEV_FUNCTION,
+       DUMMY_REMOVE_SERVICE_DATA,
+       DUMMY_GET_SERVICE_DATA
+} dummy_event_type_e;
+
+static gboolean __dummy_backup_service_items_to_file()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_BACKUP_SERVICE_ITEMS_TO_FILE;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+       char *file_path = NULL;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &file_path);
+
+       _DEBUG_INFO("file_path = %s", file_path);
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean __dummy_get_used_item_count()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_GET_USED_ITEM_COUNT;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+       int item_count = 0;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &item_count);
+
+       _DEBUG_INFO("item_count = %d", item_count);
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean __dummy_get_devinfo()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_GET_DEVINFO;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+       char *value = NULL;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean __dummy_execute_dev_function()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_EXECUTE_DEV_FUNCTION;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean __dummy_get_service_data()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_GET_SERVICE_DATA;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+       char *data = NULL;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static gboolean __dummy_remove_service_data()
+{
+       _INNER_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_FAIL;
+       int event_type = DUMMY_REMOVE_SERVICE_DATA;
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+       int api_result = API_RESULT_SUCCESS;
+
+       sync_agent_event_data_s *request_event = NULL;
+       sync_agent_event_data_s *response_event = NULL;
+
+       /* create empty event packet */
+       request_event = sync_agent_create_event(event_type);
+       if (request_event == NULL) {
+               _DEBUG_ERROR("event is NULL");
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       /* send event request to ds agent daemon, waiting for response */
+       response_event = sync_agent_send_event(request_event, &error);
+       if (error != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("error = %d", error);
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+       if (response_event == NULL) {
+               _DEBUG_ERROR("response_event is null!!");
+               sync_agent_free_event(request_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       sync_agent_get_event_data_param(response_event, &api_result);
+       if (api_result == API_RESULT_FAILURE) {
+               _DEBUG_ERROR("api_result = failed");
+               sync_agent_free_event(request_event);
+               sync_agent_free_event_data(response_event);
+               _EXTERN_FUNC_EXIT;
+               return FALSE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+int _get_service_data_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *service_data = NULL;
+
+       sync_agent_get_event_data_param(request, &service_data);
+
+       _DEBUG_VERBOSE("service_data = %s\n", service_data);
+
+       g_free(service_data);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static void _print_dummy_client()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### dummy client test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': backup service items to file\n");
+       printf(" Press '2': get used item count\n");
+       printf(" Press '3': get devinfo\n");
+       printf(" Press '4': execute dev function\n");
+       printf(" Press '5': remove service data\n");
+       printf(" Press '6': get service data\n");
+
+       printf(" Enter your choice:\n");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data)
+{
+       _INNER_FUNC_ENTER;
+
+       gsize read;
+       gchar *buf;
+       GError *error;
+
+       buf = g_policy_type;
+
+       /* Reads data from a GIOChannel. */
+       GIOError status = g_io_channel_read(gio, buf, 256, &read);
+       retvm_if(status != G_IO_ERROR_NONE, FALSE, "Error reading:");
+
+       buf[read] = '\0';
+
+       /* Removes leading and trailing whitespace from a string. */
+       g_strstrip(buf);
+
+       _DEBUG_TRACE("user input cmd is %s", buf);
+
+       if (buf[0] == '0') {
+               // quit g main loop
+               _DEBUG_TRACE("exiting...");
+               g_main_loop_quit(g_mainloop);
+       } else {
+               switch (buf[0]) {
+                       gboolean test_result = FALSE;
+               case '1':
+                       {
+                               test_result = __dummy_backup_service_items_to_file();
+                               printf(" backup service items to file : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '2':
+                       {
+                               test_result = __dummy_get_used_item_count();
+                               printf(" get item count : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '3':
+                       {
+                               test_result = __dummy_get_devinfo();
+                               printf(" get devinfo : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '4':
+                       {
+                               test_result = __dummy_execute_dev_function();
+                               printf(" dev function : result = %s\n\n", test_result ? "success" : "fail");
+
+                       }
+                       break;
+               case '5':
+                       {
+                               test_result = __dummy_remove_service_data();
+                               printf(" remove service data : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '6':
+                       {
+                               test_result = __dummy_get_service_data();
+                               printf(" get service data : result = %s\n\n", test_result ? "success" : "fail");
+
+                       }
+                       break;
+               case '7':
+                       {
+
+                       }
+                       break;
+               case '8':
+                       {
+
+                       }
+                       break;
+               case '9':
+                       {
+
+                       }
+                       break;
+               case 'a':
+                       {
+                       }
+                       break;
+               case 'b':
+                       {
+                       }
+                       break;
+               case 'c':
+                       {
+                       }
+                       break;
+               case 'd':
+                       {
+                       }
+                       break;
+               case 'e':
+                       {
+                       }
+               case 'f':
+                       {
+                       }
+               case 'g':
+                       {
+
+                       }
+                       break;
+               default:
+                       {
+                               _DEBUG_TRACE("Wrong Choice: enter your choice again...");
+                       }
+                       break;
+               }
+
+               // display menu
+               _print_dummy_client();
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+void _pipe_handler(int sig)
+{
+       printf("_pipe_handler is called");
+}
+
+int main(int argc, char *argv[])
+{
+       _EXTERN_FUNC_ENTER;
+
+       GIOChannel *stdin_channel = NULL;
+       guint result;
+
+//      signal(SIGPIPE, _pipe_handler);
+
+       dummy_client_error_e err = _dummy_client_init();
+       if (err != DUMMY_CLIENT_SUCCESS) {
+               _DEBUG_ERROR("failed to init dummy client");
+               return -1;
+       }
+
+       int noti_type = 1;
+       sync_agent_event_error_e noti_err = sync_agent_set_noti_callback(noti_type, _get_service_data_noti_cb, NULL);
+       if (noti_err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+               return -1;
+       }
+
+       /* Creates a new GIOChannel from std input */
+       stdin_channel = g_io_channel_unix_new(0);
+       retvm_if(stdin_channel == NULL, -1, "Error creating new GIOChannel!");
+
+       /* Adds the GIOChannel into the default main loop context with the default priority. */
+       result = g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) _process_cmd_input, NULL);
+       retvm_if(result == 0, -1, "Error creating watch!");
+
+       // display menu
+       _print_dummy_client();
+
+       // wait for policy receiver callback rest
+       g_mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(g_mainloop);
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+dummy_client_error_e _dummy_client_init()
+{
+       _EXTERN_FUNC_ENTER;
+
+       dummy_client_error_e result = DUMMY_CLIENT_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init(DUMMY_CLIENT_CONFIG_FILE);
+
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("ds init failed");
+               result = DUMMY_CLIENT_FAIL;
+       }
+
+       sync_agent_event_error_e err = sync_agent_run_noti_listener("dummy");
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("RUN NOTILISTNER is failed");
+               result = DUMMY_CLIENT_FAIL;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return result;
+}
diff --git a/test/client/dummy/makefile b/test/client/dummy/makefile
new file mode 100644 (file)
index 0000000..9f5eeb1
--- /dev/null
@@ -0,0 +1,5 @@
+all:
+        gcc -o dummy-client dummy_client.c `pkg-config --cflags --libs glib-2.0` `pkg-config --cflags --libs dlog` `pkg-config --cflags --libs sync-agent` `pkg-config --cflags --libs libwbxml2`
+
+clean:
+       rm -rf dummy-client
diff --git a/test/client/oma-dm/makefile b/test/client/oma-dm/makefile
new file mode 100644 (file)
index 0000000..a318f67
--- /dev/null
@@ -0,0 +1,5 @@
+all:
+        gcc -o oma-dm-client oma_dm_client.c oma_dm_admin_api.c oma_dm_alert_api.c oma_dm_cp_api.c oma_dm_fota_api.c oma_dm_noti_api.c oma_dm_registration_api.c `pkg-config --cflags --libs glib-2.0` `pkg-config --cflags --libs dlog` `pkg-config --cflags --libs sync-agent` `pkg-config --cflags --libs libwbxml2`
+
+clean:
+       rm -rf oma-dm-client
\ No newline at end of file
diff --git a/test/client/oma-dm/oma_dm_client.c b/test/client/oma-dm/oma_dm_client.c
new file mode 100755 (executable)
index 0000000..aad3d57
--- /dev/null
@@ -0,0 +1,1323 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#define COMPONENT_TAG APP
+#define LOG_TAG "OMA_DM_CLIENT"
+
+#include <sync_agent.h>
+
+#define SMASUNG_SERVER "RSate"
+#define SESSION_ID     "11111"
+
+GMainLoop *g_mainloop;
+gchar g_policy_type[256];
+static int selected_ui_num = -1;
+
+static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data);
+static void _select_ui_input();
+
+static void _print_admin_ui_test();
+static void _print_alert_ui_test();
+static void _print_cp_ui_test();
+static void _print_fota_ui_test();
+static void _print_noti_ui_test();
+static void _print_reg_ui_test();
+static void _printf_dmacc_control_ui_test();
+
+/* Admin wrapping test api */
+static gboolean __test_admin_get_fumo_config();
+static gboolean __test_admin_set_fumo_config();
+static gboolean __test_admin_get_profile();
+static gboolean __test_admin_set_profile();
+static gboolean __test_admin_reset_profile();
+static gboolean __test_admin_user_initiate();
+
+/* Alert wrapping test api */
+/*static gboolean __test_alert_display();*/
+static gboolean __test_alert_confirmation();
+static gboolean __test_alert_inputtext();
+static gboolean __test_alert_single_choice();
+static gboolean __test_alert_multiple_choice();
+
+/* CP wrapping test api */
+static gboolean __test_cp_check_pin_code();
+
+/* Fota wrapping test api */
+static gboolean __test_fota_software_update();
+static gboolean __test_fota_cancel();
+static gboolean __test_fota_download();
+static gboolean __test_fota_install();
+static gboolean __test_fota_set_interval();
+
+/* Noti wrapping test api */
+static gboolean __test_noti_software_update();
+static gboolean __test_noti_cancel();
+static gboolean __test_noti_download();
+static gboolean __test_noti_install();
+static gboolean __test_noti_set_interval();
+
+/* Registration wrapping test api */
+static gboolean __test_reg_account_registration();
+
+/* Add/Remove Dmacc */
+static gboolean __test_add_dmacc();
+static gboolean __test_remove_dmacc();
+
+static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data)
+{
+       _INNER_FUNC_ENTER;
+
+       gsize read;
+       gchar *buf;
+       GError *error;
+
+       buf = g_policy_type;
+
+       /* Reads data from a GIOChannel. */
+       GIOError status = g_io_channel_read(gio, buf, 256, &read);
+       retvm_if(status != G_IO_ERROR_NONE, FALSE, "Error reading:");
+       _DEBUG_TRACE("read data : %s (size : %d)", buf, read);
+
+       buf[read] = '\0';
+
+       /* Removes leading and trailing whitespace from a string. */
+       g_strstrip(buf);
+
+       _DEBUG_TRACE("user input cmd is %s", buf);
+
+       if (buf[0] == '0') {
+               // quit g main loop
+               _DEBUG_TRACE("exiting...");
+               g_main_loop_quit(g_mainloop);
+       } else {
+               switch (selected_ui_num) {
+                       _DEBUG_TRACE("buf[0] : %c", buf[0]);
+               case 1: /* Admin UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               test_result = __test_admin_get_fumo_config();
+                                               printf("Admin UI - get fumo config : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '2':
+                                       {
+                                               test_result = __test_admin_set_fumo_config();
+                                               printf("Admin UI - set fumo config : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '3':
+                                       {
+                                               test_result = __test_admin_get_profile();
+                                               printf("Admin UI - get profile : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '4':
+                                       {
+                                               test_result = __test_admin_set_profile();
+                                               printf("Admin UI - set profile : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '5':
+                                       {
+                                               test_result = __test_admin_reset_profile();
+                                               printf("Admin UI - reset profile : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '6':
+                                       {
+                                               test_result = __test_admin_user_initiate();
+                                               printf("Admin UI - user initiate : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("Admin UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_admin_ui_test();
+                       }
+                       break;
+               case 2: /* Alert UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               /*test_result = __test_alert_display(); */
+                                               /*do not push event */
+                                               printf("Alert UI - display : result = success");
+                                               /*
+                                                *      show UI
+                                                *
+                                                *      after
+                                                *
+                                                * must do destroy UI
+                                                *
+                                                * */
+                                       }
+                                       break;
+                               case '2':
+                                       {
+                                               test_result = __test_alert_confirmation();
+                                               printf("Alert UI - confirmation : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '3':
+                                       {
+                                               test_result = __test_alert_inputtext();
+                                               printf("Alert UI - input text : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '4':
+                                       {
+                                               test_result = __test_alert_single_choice();
+                                               printf("Alert UI - single choice : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '5':
+                                       {
+                                               test_result = __test_alert_multiple_choice();
+                                               printf("Alert UI - multiple choice : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("Alert UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_alert_ui_test();
+                       }
+                       break;
+               case 3: /* CP UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               test_result = __test_cp_check_pin_code();
+                                               printf("CP UI - check pin code : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("CP UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_cp_ui_test();
+                       }
+                       break;
+               case 4: /* Fota UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               test_result = __test_fota_software_update();
+                                               printf("Fota UI - software update : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '2':
+                                       {
+                                               test_result = __test_fota_cancel();
+                                               printf("Fota UI - cancel : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '3':
+                                       {
+                                               test_result = __test_fota_download();
+                                               printf("Fota UI - download : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '4':
+                                       {
+                                               test_result = __test_fota_install();
+                                               printf("Fota UI - install : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '5':
+                                       {
+                                               test_result = __test_fota_set_interval();
+                                               printf("Fota UI - set interval : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("Fota UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_fota_ui_test();
+                       }
+                       break;
+               case 5: /* Noti UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               test_result = __test_noti_software_update();
+                                               printf("Noti UI - software update : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '2':
+                                       {
+                                               test_result = __test_noti_cancel();
+                                               printf("Noti UI - cancel : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '3':
+                                       {
+                                               test_result = __test_noti_download();
+                                               printf("Noti UI - download : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '4':
+                                       {
+                                               test_result = __test_noti_install();
+                                               printf("Noti UI - install : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               case '5':
+                                       {
+                                               test_result = __test_noti_set_interval();
+                                               printf("Noti UI - set interval : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("Noti UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_noti_ui_test();
+                       }
+                       break;
+               case 6: /* Registration UI */
+                       {
+                               switch (buf[0]) {
+                                       gboolean test_result = FALSE;
+                               case '1':
+                                       {
+                                               test_result = __test_reg_account_registration();
+                                               printf("Registration UI - account registration : result = %s\n\n", test_result ? "success" : "fail");
+                                       }
+                                       break;
+                               default:
+                                       _DEBUG_TRACE("Registration UI - Wrong Choice: enter your choice again...");
+                                       break;
+                               }
+
+                               // display menu
+                               _print_reg_ui_test();
+                       }
+                       break;
+               case 7:
+                       switch (buf[0]) {
+                               gboolean test_result = FALSE;
+                       case '1':
+                               {
+                                       test_result = __test_add_dmacc();
+                                       printf("DMACC CONTROL UI - add dm acc : result = %s\n\n", test_result ? "success" : "fail");
+                               }
+                               break;
+                       case '2':
+                               {
+                                       test_result = __test_remove_dmacc();
+                               }
+                               break;
+                       default:
+                               printf("DMACC CONTROL UI - remove dm acc : result = %s\n\n", test_result ? "success" : "fail");
+                               break;
+                       }
+
+                       // display menu
+                       _printf_dmacc_control_ui_test();
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+static void _select_ui_input()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### oma dm client test ##########\n");
+       printf("select UI\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': Admin UI\n");
+       printf(" Press '2': Alert UI\n");
+       printf(" Press '3': CP UI\n");
+       printf(" Press '4': Fota UI\n");
+       printf(" Press '5': Noti UI\n");
+       printf(" Press '6': Registration UI\n");
+       printf(" Press '7': Dmacc control UI\n");
+       printf(" Enter your choice : ");
+
+       scanf("%d", &selected_ui_num);
+       _DEBUG_TRACE("selected ui : %d", selected_ui_num);
+
+       if (selected_ui_num == 0) {
+               _DEBUG_TRACE("Exit !!");
+               exit(0);
+       }
+
+       _INNER_FUNC_EXIT;
+}
+
+static void _print_admin_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Admin UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': get fumo config\n");
+       printf(" Press '2': set fumo config\n");
+       printf(" Press '3': get profile\n");
+       printf(" Press '4': set profile\n");
+       printf(" Press '5': reset profile\n");
+       printf(" Press '6': user initiate\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _print_alert_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Alert UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': display\n");
+       printf(" Press '2': confirmation\n");
+       printf(" Press '3': input text\n");
+       printf(" Press '4': single choice\n");
+       printf(" Press '5': multiple choice\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _print_cp_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### CP UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': check pin code\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _print_fota_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Fota UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': software update\n");
+       printf(" Press '2': cancel\n");
+       printf(" Press '3': download\n");
+       printf(" Press '4': install\n");
+       printf(" Press '5': set interval\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _print_noti_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Noti UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': software update\n");
+       printf(" Press '2': cancel\n");
+       printf(" Press '3': download\n");
+       printf(" Press '4': install\n");
+       printf(" Press '5': set interval\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _print_reg_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Registration UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': account registration\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static void _printf_dmacc_control_ui_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### Dmacc Control UI Test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': add dm acc(fota)\n");
+       printf(" Press '2': remove dm acc(fota)\n");
+       printf(" Enter your choice : ");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+/* Admin wrapping test api */
+static gboolean __test_admin_get_fumo_config()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+       int wifi_only = -1;
+
+       result = sync_agent_dm_admin_get_fumo_config(&wifi_only);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_get_fumo_config() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_get_fumo_config() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_admin_set_fumo_config()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int wifi_only = 0;      /* FIXME */
+
+       result = sync_agent_dm_admin_set_fumo_config(wifi_only);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_set_fumo_config() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_set_fumo_config() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_admin_get_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int profile_type = UI_GCF_TYPE; /* FIXME */
+       sync_agent_dm_setting_data_s *setting_data = (sync_agent_dm_setting_data_s *) calloc(1, sizeof(sync_agent_dm_setting_data_s));
+       if (setting_data == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return false;
+       }
+
+       result = sync_agent_dm_admin_get_profile(profile_type, &setting_data);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_get_profile() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_get_profile() success !!");
+               is_test_successful = TRUE;
+       }
+
+       /* free part */
+       if (setting_data != NULL) {
+               if (setting_data->profile_name != NULL)
+                       g_free(setting_data->profile_name);
+               if (setting_data->imei != NULL)
+                       g_free(setting_data->imei);
+               if (setting_data->server_url != NULL)
+                       g_free(setting_data->server_url);
+               if (setting_data->server_pwd != NULL)
+                       g_free(setting_data->server_pwd);
+               if (setting_data->client_id != NULL)
+                       g_free(setting_data->client_id);
+               if (setting_data->client_pwd != NULL)
+                       g_free(setting_data->client_pwd);
+               if (setting_data->client_auth_type != NULL)
+                       g_free(setting_data->client_auth_type);
+               if (setting_data->server_auth_type != NULL)
+                       g_free(setting_data->server_auth_type);
+
+               g_free(setting_data);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_admin_set_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int profile_type = UI_GCF_TYPE; /* FIXME */
+       sync_agent_dm_setting_data_s *setting_data = (sync_agent_dm_setting_data_s *) calloc(1, sizeof(sync_agent_dm_setting_data_s));
+       if (setting_data == NULL) {
+               _DEBUG_ERROR("calloc failed !!");
+               return false;
+       }
+
+       /* FIXME */
+       /* fumo */
+       setting_data->server_url = strdup("https://XXX");
+       setting_data->server_id = strdup("XXX");
+       setting_data->server_pwd = strdup("XXX==");
+       setting_data->client_id = strdup("IMEI:XXX");
+       setting_data->client_pwd = strdup("XXX");
+       setting_data->client_auth_type = strdup("DIGEST");
+       setting_data->server_auth_type = strdup("DIGEST");
+
+       /* lawmo */
+//      setting_data->server_url = strdup("https://XXX");
+//      setting_data->server_id = strdup("XXX");
+//      setting_data->server_pwd = strdup("XXX==");
+//      setting_data->client_id = strdup("IMEI:XXX");
+//      setting_data->client_pwd = strdup("XXX");
+//      setting_data->client_auth_type = strdup("DIGEST");
+//      setting_data->server_auth_type = strdup("DIGEST");
+
+       /* gcf */
+//      setting_data->server_url = strdup("http://XXX");
+//      setting_data->server_id = strdup("XXX");
+//      setting_data->server_pwd = strdup("XXX");
+//      setting_data->client_id = strdup("XXX");
+//      setting_data->client_pwd = strdup("XXX");
+//      setting_data->client_auth_type = strdup("DIGEST");
+//      setting_data->server_auth_type = strdup("DIGEST");
+
+       result = sync_agent_dm_admin_set_profile(profile_type, setting_data);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_set_profile() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_set_profile() success !!");
+               is_test_successful = TRUE;
+       }
+
+       /* free part */
+       if (setting_data != NULL) {
+               if (setting_data->server_url != NULL)
+                       g_free(setting_data->server_url);
+               if (setting_data->server_id != NULL)
+                       g_free(setting_data->server_id);
+               if (setting_data->server_pwd != NULL)
+                       g_free(setting_data->server_pwd);
+               if (setting_data->client_id != NULL)
+                       g_free(setting_data->client_id);
+               if (setting_data->client_pwd != NULL)
+                       g_free(setting_data->client_pwd);
+               if (setting_data->client_auth_type != NULL)
+                       g_free(setting_data->client_auth_type);
+               if (setting_data->server_auth_type != NULL)
+                       g_free(setting_data->server_auth_type);
+
+               g_free(setting_data);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_admin_reset_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int profile_type = UI_GCF_TYPE; /* FIXME */
+
+       result = sync_agent_dm_admin_reset_profile(profile_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_reset_profile() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_reset_profile() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_admin_user_initiate()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       sync_agent_dm_service_server_type_e server_type = UI_GCF_TYPE;
+
+       result = sync_agent_dm_admin_user_initiate(server_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_admin_reset_profile() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_admin_reset_profile() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+                                                                                      /* Alert wrapping test api *//*
+                                                                                         static gboolean __test_alert_display()
+                                                                                         {
+                                                                                         _INNER_FUNC_ENTER;
+
+                                                                                         gboolean is_test_successful = TRUE;
+                                                                                         sync_agent_dm_error_e result = SYNC_AGENT_DM_FAIL;
+
+                                                                                         int response_type = UI_RESPONSE_TYPE_OK;                 FIXME
+
+                                                                                         result = sync_agent_alert_display(response_type);
+                                                                                         if (result != SYNC_AGENT_DM_SUCCESS) {
+                                                                                         _DEBUG_VERBOSE("sync_agent_alert_display() failed !!");
+                                                                                         is_test_successful = FALSE;
+                                                                                         } else {
+                                                                                         _DEBUG_VERBOSE("sync_agent_alert_display() success !!");
+                                                                                         is_test_successful = TRUE;
+                                                                                         }
+
+                                                                                         _INNER_FUNC_EXIT;
+
+                                                                                         return is_test_successful;
+                                                                                         } */
+
+static gboolean __test_alert_confirmation()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+
+       result = sync_agent_dm_alert_confirmation(response_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_alert_confirmation() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_alert_confirmation() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_alert_inputtext()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+       char *input_text = strdup("alert input text");  /* FIXME */
+
+       result = sync_agent_dm_alert_inputtext(response_type, input_text);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_alert_inputtext() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_alert_inputtext() success !!");
+               is_test_successful = TRUE;
+       }
+
+       /* free part */
+       if (input_text != NULL)
+               g_free(input_text);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_alert_single_choice()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+       int selected_count = 1;
+       char *selected_number = strdup("1");    /* FIXME */
+
+       result = sync_agent_dm_alert_single_choice(response_type, selected_count, selected_number);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_alert_single_choice() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_alert_single_choice() success !!");
+               is_test_successful = TRUE;
+       }
+
+       /* free part */
+       if (selected_number != NULL)
+               g_free(selected_number);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_alert_multiple_choice()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+       GList *selected_list = NULL;
+
+       /* FIXME - add selected number */
+       selected_list = g_list_append(selected_list, strdup("1"));
+       selected_list = g_list_append(selected_list, strdup("2"));
+       selected_list = g_list_append(selected_list, strdup("3"));
+
+       result = sync_agent_dm_alert_multiple_choice(response_type, selected_list);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_alert_multiple_choice() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_alert_multiple_choice() success !!");
+               is_test_successful = TRUE;
+       }
+
+       /* free part */
+       if (selected_list != NULL) {
+               GList *iter = NULL;
+               char *data = NULL;
+               for (iter = selected_list; iter != NULL;) {
+                       data = (char *)(iter->data);
+                       iter = g_list_next(iter);
+                       selected_list = g_list_remove(selected_list, data);
+                       if (data != NULL)
+                               g_free((char *)data);
+               }
+
+               g_list_free(selected_list);
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+/* CP wrapping test api */
+static gboolean __test_cp_check_pin_code()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int ext_id = 1;         /* FIXME */
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME - RESPONSE_TYPE_CANCEL => ext_id : -1 / pin_code : NULL */
+       char *pin_code = "1234";        /* FIXME */
+
+       int user_pin_val = 0;   //fail
+
+       result = sync_agent_dm_cp_check_pin_code(ext_id, response_type, pin_code, &user_pin_val);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_cp_check_pin_code() failed !!");
+
+               _DEBUG_VERBOSE("user pin valiation : %d", user_pin_val);
+
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_cp_check_pin_code() success !!");
+
+               _DEBUG_VERBOSE("user pin valiation : %d", user_pin_val);
+
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+/* Fota wrapping test api */
+static gboolean __test_fota_software_update()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       sync_agent_dm_service_server_type_e server_type = UI_SAMSUNG_FUMO_TYPE; /* FIXME */
+
+       result = sync_agent_dm_fota_software_update(server_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_fota_software_update() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_fota_software_update() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_fota_cancel()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       result = sync_agent_dm_fota_cancel();
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_fota_cancel() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_fota_cancel() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_fota_download()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+
+       result = sync_agent_dm_fota_download(response_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_fota_download() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_fota_download() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_fota_install()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+
+       result = sync_agent_dm_fota_install(response_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_fota_install() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_fota_install() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_fota_set_interval()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int interval_type = UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR;  /* FIXME */
+
+       result = sync_agent_dm_fota_set_interval(interval_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_fota_set_interval() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_fota_set_interval() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+/* Noti wrapping test api */
+static gboolean __test_noti_software_update()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       result = sync_agent_dm_fota_update_noti(SMASUNG_SERVER, SESSION_ID);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_push_software_update() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_push_software_update() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_noti_cancel()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       result = sync_agent_dm_fota_cancel_noti();
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_push_cancel() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_push_cancel() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_noti_download()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+
+       result = sync_agent_dm_fota_download_noti(response_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_push_download() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_push_download() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_noti_install()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int response_type = UI_RESPONSE_TYPE_OK;        /* FIXME */
+
+       result = sync_agent_dm_fota_install_noti(response_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_push_install() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_push_install() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_noti_set_interval()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       int interval_type = UI_RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR;  /* FIXME */
+
+       result = sync_agent_dm_fota_set_interval_noti(interval_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_push_set_interval() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_push_set_interval() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+/* Registration wrapping test api */
+static gboolean __test_reg_account_registration()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+
+       result = sync_agent_dm_reg_account_registration();
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_reg_account_registration() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_reg_account_registration() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_add_dmacc()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       result = sync_agent_dm_add_dmacc(dmacc_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_remove_dmacc()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_FAIL;
+       sync_agent_dm_service_server_type_e dmacc_type = UI_SAMSUNG_FUMO_TYPE;
+
+       result = sync_agent_dm_remove_dmacc(dmacc_type);
+       if (result != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() failed !!");
+               is_test_successful = FALSE;
+       } else {
+               _DEBUG_VERBOSE("sync_agent_dm_remove_dmacc() success !!");
+               is_test_successful = TRUE;
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+int main(int argc, char *argv[])
+{
+       _EXTERN_FUNC_ENTER;
+
+       GIOChannel *stdin_channel = NULL;
+       guint result;
+
+//      signal(SIGPIPE, _pipe_handler);
+
+       sync_agent_dm_error_e dm_err = UI_SYNC_AGENT_DM_SUCCESS;
+
+       // select ui
+       _select_ui_input();
+       switch (selected_ui_num) {
+       case 1:
+               dm_err = sync_agent_dm_admin_init();
+               break;
+       case 2:
+               dm_err = sync_agent_dm_alert_init();
+               break;
+       case 3:
+               dm_err = sync_agent_dm_cp_init();
+               break;
+       case 4:
+               dm_err = sync_agent_dm_fota_init();
+               break;
+       case 5:
+               dm_err = sync_agent_dm_push_init();
+               break;
+       case 6:
+               dm_err = sync_agent_dm_reg_init();
+               break;
+       case 7:
+               dm_err = sync_agent_dm_dmacc_init();
+               break;
+       default:
+               break;
+       }
+
+       if (dm_err != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_ERROR("dm ui init failed !!");
+               return -1;
+       }
+
+       /* Creates a new GIOChannel from std input */
+       stdin_channel = g_io_channel_unix_new(0);
+       retvm_if(stdin_channel == NULL, -1, "Error creating new GIOChannel!");
+
+       /* Adds the GIOChannel into the default main loop context with the default priority. */
+       result = g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) _process_cmd_input, NULL);
+       retvm_if(result == 0, -1, "Error creating watch!");
+
+       // display menu
+       switch (selected_ui_num) {
+       case 1:
+               _print_admin_ui_test();
+               break;
+       case 2:
+               _print_alert_ui_test();
+               break;
+       case 3:
+               _print_cp_ui_test();
+               break;
+       case 4:
+               _print_fota_ui_test();
+               break;
+       case 5:
+               _print_noti_ui_test();
+               break;
+       case 6:
+               _print_reg_ui_test();
+               break;
+       case 7:
+               _printf_dmacc_control_ui_test();
+               break;
+       default:
+               break;
+       }
+
+       // wait for policy receiver callback rest
+       g_mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(g_mainloop);
+
+       // reaches here when g_main_loop_quit is called
+       switch (selected_ui_num) {
+       case 1:
+               dm_err = sync_agent_dm_admin_deinit();
+               break;
+       case 2:
+               dm_err = sync_agent_dm_alert_deinit();
+               break;
+       case 3:
+               dm_err = sync_agent_dm_cp_deinit();
+               break;
+       case 4:
+               dm_err = sync_agent_dm_fota_deinit();
+               break;
+       case 5:
+               dm_err = sync_agent_dm_push_deinit();
+               break;
+       case 6:
+               dm_err = sync_agent_dm_reg_deinit();
+               break;
+       case 7:
+               dm_err = sync_agent_dm_dmacc_deinit();
+               break;
+       default:
+               break;
+       }
+       if (dm_err != UI_SYNC_AGENT_DM_SUCCESS) {
+               _DEBUG_ERROR("dm ui deinit failed !!");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
diff --git a/test/client/oma-ds/makefile b/test/client/oma-ds/makefile
new file mode 100644 (file)
index 0000000..8b29232
--- /dev/null
@@ -0,0 +1,5 @@
+all:
+        gcc -o oma-ds-client oma_ds_client.c `pkg-config --cflags --libs glib-2.0` `pkg-config --cflags --libs dlog` `pkg-config --cflags --libs sync-agent` `pkg-config --cflags --libs libwbxml2`
+
+clean:
+       rm -rf oma-ds-client
\ No newline at end of file
diff --git a/test/client/oma-ds/oma_ds_client.c b/test/client/oma-ds/oma_ds_client.c
new file mode 100755 (executable)
index 0000000..c879557
--- /dev/null
@@ -0,0 +1,1106 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+
+#define COMPONENT_TAG APP
+#define LOG_TAG "OMA_DS_CLIENT"
+
+#include <sync_agent.h>
+
+GMainLoop *g_mainloop;
+gchar g_policy_type[256];
+
+static gboolean __test_add_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       int profile_id = 0;
+
+       char *profileDirName = "Sync1";
+       char *profileName = "Funambol";
+       char *addr = "http://my.funambol.com/sync";
+       char *id = "scotest2";
+       char *password = "sprc123";
+       char *syncMode = "Manual";      //Push, Manual, Periodic
+       char *syncType = "Full";        //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
+       char *interval = "5 minutes";   //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+
+       ds_profile_h profile_h = NULL;
+
+       // allocate memory for profile info
+       result = sync_agent_ds_create_profile_info(&profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               return FALSE;
+       }
+       // set profile name
+       result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set profile name!");
+               return FALSE;
+       }
+       // set server information
+       result = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync mode information
+       result = sync_agent_ds_set_sync_info(profile_h, syncMode, syncType, interval);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync_category
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+/*
+       sync_agent_ds_set_sync_category(profile_h, SYNC_AGENT_MEMO, 1, "Memo", "note", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+*/
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("adding profile\n");
+
+       // add profile information
+       result = sync_agent_ds_add_profile(profile_h, &profile_id);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to add profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to add profile!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_add_multiple_profiles()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       int profile_id = 0;
+
+       /* add first profile */
+       char *profileDirName = "Sync1";
+       char *profileName = "Funambol";
+       char *addr = "http://my.funambol.com/sync";
+       char *id = "scotest2";
+       char *password = "sprc123";
+       char *syncMode = "Manual";      //Push, Manual, Periodic
+       char *syncType = "Full";        //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
+       char *interval = "5 minutes";   //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+
+       ds_profile_h profile_h = NULL;
+
+       // allocate memory for profile info
+       result = sync_agent_ds_create_profile_info(&profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               return FALSE;
+       }
+       // set profile name
+       result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set profile name!");
+               return FALSE;
+       }
+       // set server information
+       result = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync mode information
+       result = sync_agent_ds_set_sync_info(profile_h, syncMode, syncType, interval);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync_category
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+/*
+       sync_agent_ds_set_sync_category(profile_h, SYNC_AGENT_MEMO, 1, "Memo", "note", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+*/
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("adding profile\n");
+
+       // add profile information
+       result = sync_agent_ds_add_profile(profile_h, &profile_id);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to add profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to add profile!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       /* add second profile */
+       profileDirName = "Sync2";
+       profileName = "Everdroid";
+       addr = "http://www.everdroid.com/sync/server";
+       id = "test_samsung";
+       password = "123456";
+       syncMode = "Manual";    //Push, Manual, Periodic
+       syncType = "Full";      //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
+       interval = "5 minutes"; //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+
+       // allocate memory for profile info
+       result = sync_agent_ds_create_profile_info(&profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               return FALSE;
+       }
+       // set profile name
+       result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set profile name!");
+               return FALSE;
+       }
+       // set server information
+       result = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync mode information
+       result = sync_agent_ds_set_sync_info(profile_h, syncMode, syncType, interval);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync_category
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 1, "Contacts", "card", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 0, "Organizer", "cal", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+/*
+       sync_agent_ds_set_sync_category(profile_h, SYNC_AGENT_MEMO, 1, "Memo", "note", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+*/
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("adding profile\n");
+
+       // add profile information
+       result = sync_agent_ds_add_profile(profile_h, &profile_id);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to add profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to add profile!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_update_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       char *profileDirName = "Sync1";
+       char *profileName = "Modified Funambol";
+       char *addr = "http://my.funambol.com/sync";
+       char *id = "scotest2";
+       char *password = "sprc123";
+       char *syncMode = "Manual";      //Push, Manual, Periodic
+       char *syncType = "Full";        //Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone
+       char *interval = "5 minutes";   //5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week
+
+       ds_profile_h profile_h = NULL;
+
+       // allocate memory for profile info
+       result = sync_agent_ds_create_profile_info(&profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               return FALSE;
+       }
+       // set profile name
+       result = sync_agent_ds_set_profile_name(profile_h, profileDirName, profileName);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set profile name!");
+               return FALSE;
+       }
+       // set server information
+       result = sync_agent_ds_set_server_info(profile_h, addr, id, password);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // set sync mode information
+       result = sync_agent_ds_set_sync_info(profile_h, syncMode, syncType, interval);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set server info!");
+               return FALSE;
+       }
+       // allocate memory for sync_category
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CONTACT, 0, "Contacts", "card", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+       sync_agent_ds_set_sync_service_info(profile_h, SYNC_AGENT_CALENDAR, 1, "Organizer", "cal", NULL, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set sync category!");
+               return FALSE;
+       }
+       /*sync_agent_ds_set_sync_category(profile_h, SYNC_AGENT_MEMO, 1, "Memo", "note", NULL, NULL);
+          if (result == SYNC_AGENT_DS_FAIL) {
+          _DEBUG_ERROR("failed to set sync category!");
+          return FALSE;
+          } */
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("updating profile\n");
+
+       // update profile information
+       result = sync_agent_ds_update_profile(profile_h);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to update profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to update profile!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+
+}
+
+static gboolean __test_delete_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       ds_profile_h profile_h = NULL;
+
+       char *profileDirName = "Sync1";
+
+       // allocate memory for profile info
+       result = sync_agent_ds_create_profile_info(&profile_h);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to create profile info!");
+               return FALSE;
+       }
+       // set profile name
+       result = sync_agent_ds_set_profile_name(profile_h, profileDirName, NULL);
+       if (result == SYNC_AGENT_DS_FAIL) {
+               _DEBUG_ERROR("failed to set profile name!");
+               return FALSE;
+       }
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("deleting profile\n");
+
+       // delete profile information
+       result = sync_agent_ds_delete_profile(profile_h);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to delete profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to delete profile!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_get_profile()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       ds_profile_h profile_h = NULL;
+
+       char *profileDirName = "Sync1";
+
+       char *profileDirName1 = NULL;
+       char *profileName = NULL;
+       sync_agent_ds_server_info server_info = { NULL };
+       sync_agent_ds_sync_info sync_info = { NULL };
+       GList *category_list = NULL;
+
+       int category_count = 0;
+       int i = 0;
+       sync_agent_ds_service_info *category_info = NULL;
+       int lastSessionStatus = 0, lastSessionTime = 0;
+
+       // get profile information
+       result = sync_agent_ds_get_profile(profileDirName, &profile_h);
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("getting profile\n");
+
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile!");
+               is_test_successful = FALSE;
+       }
+
+       // 1. get profile dir/name
+       result = sync_agent_ds_get_profile_name(profile_h, &profileDirName1, &profileName);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile name!");
+               _DEBUG_VERBOSE("profileDirame = %s", profileDirName1);
+               _DEBUG_VERBOSE("get_profileName = %s", profileName);
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile name!");
+               is_test_successful = FALSE;
+       }
+
+       // 2. get ds server info
+       result = sync_agent_ds_get_server_info(profile_h, &server_info);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get server info!");
+               _DEBUG_VERBOSE("addr = %s", server_info.addr);
+               _DEBUG_VERBOSE("id = %s", server_info.id);
+               _DEBUG_VERBOSE("password = %s", server_info.password);
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get server info!");
+               is_test_successful = FALSE;
+       }
+
+       // 3. get sync info
+       result = sync_agent_ds_get_sync_info(profile_h, &sync_info);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get sync info!");
+               _DEBUG_VERBOSE("syncMode = %s", sync_info.syncMode);
+               _DEBUG_VERBOSE("syncType = %s", sync_info.syncType);
+               _DEBUG_VERBOSE("interval = %s", sync_info.interval);
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get sync info!");
+               is_test_successful = FALSE;
+       }
+
+       // 4. get sync category info
+       result = sync_agent_ds_get_sync_service_info(profile_h, &category_list);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get sync category info!");
+               category_count = g_list_length(category_list);
+               for (; i < category_count; i++) {
+                       category_info = (sync_agent_ds_service_info *) g_list_nth_data(category_list, i);
+
+                       _DEBUG_VERBOSE("category[%d]->enabled = %d", i, category_info->enabled);
+                       _DEBUG_VERBOSE("category[%d]->srcURI = %s", i, category_info->srcURI);
+                       _DEBUG_VERBOSE("category[%d]->tgtURI = %s", i, category_info->tgtURI);
+                       _DEBUG_VERBOSE("category[%d]->id = %s", i, category_info->id);
+                       _DEBUG_VERBOSE("category[%d]->password = %s", i, category_info->password);
+               }
+
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get sync category info!");
+               is_test_successful = FALSE;
+       }
+
+       // 5. get last session info
+       result = sync_agent_ds_get_last_sync_info(profile_h, &lastSessionStatus, &lastSessionTime);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get sync category info!");
+               _DEBUG_VERBOSE("lastSessionStatus = %d\n", lastSessionStatus);
+               _DEBUG_VERBOSE("lastSessionTime = %d\n", lastSessionTime);
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get sync category info!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       g_free(profileDirName1);
+       g_free(profileName);
+
+       g_free(server_info.addr);
+       g_free(server_info.id);
+       g_free(server_info.password);
+
+       g_free(sync_info.syncMode);
+       g_free(sync_info.syncType);
+       g_free(sync_info.interval);
+
+       g_list_free(category_list);
+
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_get_all_profiles()
+{
+       _INNER_FUNC_ENTER;
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       GList *profile_list = NULL;
+       GList *iter = NULL;
+       ds_profile_h profile_h = NULL;
+
+       char *profileDirName1 = NULL;
+       char *profileName = NULL;
+       sync_agent_ds_server_info server_info = { NULL };
+       sync_agent_ds_sync_info sync_info = { NULL };
+       GList *category_list = NULL;
+
+       int category_count = 0;
+       int i = 0;
+       sync_agent_ds_service_info *category_info = NULL;
+       int lastSessionStatus = 0, lastSessionTime = 0;
+
+       // get  all profiles information
+       result = sync_agent_ds_get_all_profile(&profile_list);
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("getting all profiles\n");
+
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile!");
+               is_test_successful = FALSE;
+       }
+
+       for (iter = profile_list; iter != NULL; iter = g_list_next(iter)) {
+               profile_h = (ds_profile_h) iter->data;
+
+               // 1. get profile dir/name
+               result = sync_agent_ds_get_profile_name(profile_h, &profileDirName1, &profileName);
+               if (result == SYNC_AGENT_DS_SUCCESS) {
+                       _DEBUG_VERBOSE("Success to get profile name!");
+                       _DEBUG_VERBOSE("profileDirame = %s", profileDirName1);
+                       _DEBUG_VERBOSE("get_profileName = %s", profileName);
+                       is_test_successful = TRUE;
+               } else {
+                       _DEBUG_VERBOSE("Failed to get profile name!");
+                       is_test_successful = FALSE;
+               }
+
+               // 2. get ds server info
+               result = sync_agent_ds_get_server_info(profile_h, &server_info);
+               if (result == SYNC_AGENT_DS_SUCCESS) {
+                       _DEBUG_VERBOSE("Success to get server info!");
+                       _DEBUG_VERBOSE("addr = %s", server_info.addr);
+                       _DEBUG_VERBOSE("id = %s", server_info.id);
+                       _DEBUG_VERBOSE("password = %s", server_info.password);
+                       is_test_successful = TRUE;
+               } else {
+                       _DEBUG_VERBOSE("Failed to get server info!");
+                       is_test_successful = FALSE;
+               }
+
+               // 3. get sync info
+               result = sync_agent_ds_get_sync_info(profile_h, &sync_info);
+               if (result == SYNC_AGENT_DS_SUCCESS) {
+                       _DEBUG_VERBOSE("Success to get sync info!");
+                       _DEBUG_VERBOSE("syncMode = %s", sync_info.syncMode);
+                       _DEBUG_VERBOSE("syncType = %s", sync_info.syncType);
+                       _DEBUG_VERBOSE("interval = %s", sync_info.interval);
+                       is_test_successful = TRUE;
+               } else {
+                       _DEBUG_VERBOSE("Failed to get sync info!");
+                       is_test_successful = FALSE;
+               }
+
+               // 4. get sync category info
+               result = sync_agent_ds_get_sync_service_info(profile_h, &category_list);
+               if (result == SYNC_AGENT_DS_SUCCESS) {
+                       _DEBUG_VERBOSE("Success to get sync category info!");
+                       category_count = g_list_length(category_list);
+                       _DEBUG_VERBOSE("category_count = %d", category_count);
+                       for (i = 0; i < category_count; i++) {
+                               category_info = (sync_agent_ds_service_info *) g_list_nth_data(category_list, i);
+
+                               _DEBUG_VERBOSE("category[%d]->enabled = %d", i, category_info->enabled);
+                               _DEBUG_VERBOSE("category[%d]->srcURI = %s", i, category_info->srcURI);
+                               _DEBUG_VERBOSE("category[%d]->tgtURI = %s", i, category_info->tgtURI);
+                               _DEBUG_VERBOSE("category[%d]->id = %s", i, category_info->id);
+                               _DEBUG_VERBOSE("category[%d]->password = %s", i, category_info->password);
+                       }
+
+                       is_test_successful = TRUE;
+               } else {
+                       _DEBUG_VERBOSE("Failed to get sync category info!");
+                       is_test_successful = FALSE;
+               }
+
+               // 5. get last session info
+               result = sync_agent_ds_get_last_sync_info(profile_h, &lastSessionStatus, &lastSessionTime);
+               if (result == SYNC_AGENT_DS_SUCCESS) {
+                       _DEBUG_VERBOSE("Success to get sync category info!");
+                       _DEBUG_VERBOSE("lastSessionStatus = %d\n", lastSessionStatus);
+                       _DEBUG_VERBOSE("lastSessionTime = %d\n", lastSessionTime);
+                       is_test_successful = TRUE;
+               } else {
+                       _DEBUG_VERBOSE("Failed to get sync category info!");
+                       is_test_successful = FALSE;
+               }
+
+               // free profile information
+               g_free(profileDirName1);
+               g_free(profileName);
+
+               g_free(server_info.addr);
+               g_free(server_info.id);
+               g_free(server_info.password);
+
+               g_free(sync_info.syncMode);
+               g_free(sync_info.syncType);
+               g_free(sync_info.interval);
+
+               g_list_free(category_list);
+       }
+
+       for (iter = profile_list; iter != NULL; iter = g_list_next(iter)) {
+               sync_agent_ds_free_profile_info((ds_profile_h) iter->data);
+               _DEBUG_INFO("free sync_agent_ds_profile_info");
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_get_sync_statistics()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       ds_profile_h profile_h = NULL;
+       sync_agent_ds_statistics_info *statistics = NULL;
+
+       GList *statistics_list = NULL;
+
+       char *profileDirName = "Sync1";
+
+       int category_count = 0;
+       int i = 0;
+
+       // get profile information
+       result = sync_agent_ds_get_profile(profileDirName, &profile_h);
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("getting profile\n");
+
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile!");
+               is_test_successful = FALSE;
+       }
+
+       // get sync statistics
+       result = sync_agent_ds_get_sync_statistics(profile_h, &statistics_list);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               char *statistics_cat[3] = { "contacts", "schecule", "memo" };
+               _DEBUG_VERBOSE("Success to get sync statistics!");
+               category_count = g_list_length(statistics_list);
+               for (; i < category_count; i++) {
+                       statistics = (sync_agent_ds_statistics_info *) g_list_nth_data(statistics_list, i);
+
+                       _DEBUG_VERBOSE("%s dbSynced = %s\n", statistics_cat[i], statistics->dbsynced);
+                       _DEBUG_VERBOSE("%s lastSessionTime = %d\n", statistics_cat[i], statistics->last_session_time);
+                       _DEBUG_VERBOSE("%s server2Client_Total = %d\n", statistics_cat[i], statistics->server2client_total);
+                       _DEBUG_VERBOSE("%s server2Client_NrOrAdd = %d\n", statistics_cat[i], statistics->server2client_nrofadd);
+                       _DEBUG_VERBOSE("%s server2Client_NrOfDelete = %d\n", statistics_cat[i], statistics->server2client_nrofdelete);
+                       _DEBUG_VERBOSE("%s server2Client_NrOfReplace = %d\n", statistics_cat[i], statistics->server2client_nrofreplace);
+                       _DEBUG_VERBOSE("%s client2Server_Total = %d\n", statistics_cat[i], statistics->client2server_total);
+                       _DEBUG_VERBOSE("%s client2Server_NrOfAdd = %d\n", statistics_cat[i], statistics->client2server_nrofadd);
+                       _DEBUG_VERBOSE("%s client2Server_NrOfDelete = %d\n", statistics_cat[i], statistics->client2server_nrofdelete);
+                       _DEBUG_VERBOSE("%s client2Server_NrOfReplace = %d\n", statistics_cat[i], statistics->client2server_nrofreplace);
+               }
+
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to sync statistics!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+
+       return is_test_successful;
+}
+
+static gboolean __test_start_sync()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       ds_profile_h profile_h = NULL;
+
+       char *profileDirName = "Sync1";
+
+       // get profile information
+       result = sync_agent_ds_get_profile(profileDirName, &profile_h);
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("getting profile\n");
+
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile!");
+               is_test_successful = FALSE;
+       }
+
+       // start sync
+       result = sync_agent_ds_start_sync(profile_h);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to start sync!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to start sync!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+}
+
+static gboolean __test_stop_sync()
+{
+       _INNER_FUNC_ENTER;
+
+       gboolean is_test_successful = TRUE;
+       sync_agent_ds_error_e result = SYNC_AGENT_DS_FAIL;
+
+       ds_profile_h profile_h = NULL;
+
+       char *profileDirName = "Sync1";
+
+       // get profile information
+       result = sync_agent_ds_get_profile(profileDirName, &profile_h);
+
+       _DEBUG_VERBOSE("----------------------------------");
+       _DEBUG_VERBOSE("getting profile\n");
+
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to get profile!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to get profile!");
+               is_test_successful = FALSE;
+       }
+
+       // stop sync
+       result = sync_agent_ds_stop_sync(profile_h);
+       if (result == SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_VERBOSE("Success to stop sync!");
+               is_test_successful = TRUE;
+       } else {
+               _DEBUG_VERBOSE("Failed to stop sync!");
+               is_test_successful = FALSE;
+       }
+
+       // free profile information
+       sync_agent_ds_free_profile_info(profile_h);
+
+       _INNER_FUNC_EXIT;
+}
+
+int _session_process_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *profileDirName = NULL;
+       char *sync_type = NULL;
+       char *progress = NULL;
+       char *error = NULL;
+
+       sync_agent_get_event_data_param(request, &profileDirName);
+       sync_agent_get_event_data_param(request, &sync_type);
+       sync_agent_get_event_data_param(request, &progress);
+       sync_agent_get_event_data_param(request, &error);
+
+       _DEBUG_VERBOSE("profileDirName = %s\n", profileDirName);
+       _DEBUG_VERBOSE("sync_type = %s\n", sync_type);
+       _DEBUG_VERBOSE("progress = %s\n", progress);
+       _DEBUG_VERBOSE("error = %s\n", error);
+
+       g_free(profileDirName);
+       g_free(sync_type);
+       g_free(progress);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+int _process_update_noti_cb(sync_agent_event_data_s * request, void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       char *profileDirName = NULL;
+       char *syncType = NULL;
+       char *uri = NULL;
+       char *progressStatus = NULL;
+       char *operationType = NULL;
+
+       int isFromServer;
+       int totalPerOperation;
+       int syncedPerOperation;
+       int totalPerDb;
+       int syncedPerDb;
+
+       sync_agent_get_event_data_param(request, &profileDirName);
+       _DEBUG_VERBOSE("profileDirName = %s", profileDirName);
+       sync_agent_get_event_data_param(request, &syncType);
+       _DEBUG_VERBOSE("syncType = %s", syncType);
+       sync_agent_get_event_data_param(request, &uri);
+       _DEBUG_VERBOSE("uri = %s", uri);
+       sync_agent_get_event_data_param(request, &progressStatus);
+       _DEBUG_VERBOSE("progressStatus = %s", progressStatus);
+       sync_agent_get_event_data_param(request, &operationType);
+       _DEBUG_VERBOSE("operationType = %s", operationType);
+       sync_agent_get_event_data_param(request, &isFromServer);
+       _DEBUG_VERBOSE("isFromServer = %d", isFromServer);
+       sync_agent_get_event_data_param(request, &totalPerOperation);
+       _DEBUG_VERBOSE("totalPerOperation = %d", totalPerOperation);
+       sync_agent_get_event_data_param(request, &syncedPerOperation);
+       _DEBUG_VERBOSE("syncedPerOperation = %d", syncedPerOperation);
+       sync_agent_get_event_data_param(request, &totalPerDb);
+       _DEBUG_VERBOSE("totalPerDb = %d", totalPerDb);
+       sync_agent_get_event_data_param(request, &syncedPerDb);
+       _DEBUG_VERBOSE("syncedPerDb = %d", syncedPerDb);
+
+       g_free(profileDirName);
+       g_free(syncType);
+       g_free(uri);
+       g_free(progressStatus);
+       g_free(operationType);
+
+       if (request != NULL) {
+               if (request->size != NULL)
+                       g_free(request->size);
+               g_free(request);
+       }
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static void _print_omads_test()
+{
+       _INNER_FUNC_ENTER;
+
+       printf(" ####### oma ds client test ##########\n");
+       printf(" Press '0': to exit\n");
+       printf(" Press '1': add profile\n");
+       printf(" Press '2': update profile\n");
+       printf(" Press '3': delete profile\n");
+       printf(" Press '4': start sync\n");
+       printf(" Press '5': stop profile\n");
+       printf(" Press '6': get profile/category\n");
+       printf(" Press '7': get all profiles/category\n");
+       printf(" Press '8': get sync statistics\n");
+       printf(" Press '9': add multiple profiles\n");
+
+/*
+       printf(" Press '5': add profile\n");
+       printf(" Press '6': add profile\n");
+       printf(" Press '7': add profile\n");
+       printf(" Press '8': add profile\n");
+       printf(" Press '9': add profile\n");
+       printf(" Press '10': add profile\n");
+       printf(" Press '11': add profile\n");
+       printf(" Press '12': add profile\n");
+       printf(" Press '14': add profile\n");
+       printf(" Press '15': add profile\n");*/
+
+       printf(" Enter your choice:\n");
+
+       _INNER_FUNC_EXIT;
+
+       return;
+}
+
+static gboolean _process_cmd_input(GIOChannel * gio, GIOCondition condition, gpointer data)
+{
+       _INNER_FUNC_ENTER;
+
+       gsize read;
+       gchar *buf;
+       GError *error;
+
+       buf = g_policy_type;
+
+       /* Reads data from a GIOChannel. */
+       GIOError status = g_io_channel_read(gio, buf, 256, &read);
+       retvm_if(status != G_IO_ERROR_NONE, FALSE, "Error reading:");
+
+       buf[read] = '\0';
+
+       /* Removes leading and trailing whitespace from a string. */
+       g_strstrip(buf);
+
+       _DEBUG_TRACE("user input cmd is %s", buf);
+
+       if (buf[0] == '0') {
+               // quit g main loop
+               _DEBUG_TRACE("exiting...");
+               g_main_loop_quit(g_mainloop);
+       } else {
+               switch (buf[0]) {
+                       gboolean test_result = FALSE;
+               case '1':
+                       {
+                               test_result = __test_add_profile();
+                               printf(" add profile : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '2':
+                       {
+                               test_result = __test_update_profile();
+                               printf(" update profile : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '3':
+                       {
+                               test_result = __test_delete_profile();
+                               printf(" delete profile : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '4':
+                       {
+                               test_result = __test_start_sync();
+                               printf(" start sync : result = %s\n\n", test_result ? "success" : "fail");
+
+                       }
+                       break;
+               case '5':
+                       {
+                               test_result = __test_stop_sync();
+                               printf(" stop sync : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '6':
+                       {
+                               test_result = __test_get_profile();
+                               printf(" get profile : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '7':
+                       {
+                               test_result = __test_get_all_profiles();
+                               printf(" get all profiles : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '8':
+                       {
+                               test_result = __test_get_sync_statistics();
+                               printf(" get sync statistics : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case '9':
+                       {
+                               test_result = __test_add_multiple_profiles();
+                               printf(" add multiple profiles : result = %s\n\n", test_result ? "success" : "fail");
+                       }
+                       break;
+               case 'a':
+                       {
+                       }
+                       break;
+               case 'b':
+                       {
+                       }
+                       break;
+               case 'c':
+                       {
+                       }
+                       break;
+               case 'd':
+                       {
+                       }
+                       break;
+               case 'e':
+                       {
+                       }
+               case 'f':
+                       {
+                       }
+               case 'g':
+                       {
+
+                       }
+                       break;
+               default:
+                       {
+                               _DEBUG_TRACE("Wrong Choice: enter your choice again...");
+                       }
+                       break;
+               }
+
+               // display menu
+               _print_omads_test();
+       }
+
+       _INNER_FUNC_EXIT;
+
+       return TRUE;
+}
+
+void _pipe_handler(int sig)
+{
+       printf("_pipe_handler is called");
+}
+
+int main(int argc, char *argv[])
+{
+       _EXTERN_FUNC_ENTER;
+
+       GIOChannel *stdin_channel = NULL;
+       guint result;
+
+//      signal(SIGPIPE, _pipe_handler);
+
+       sync_agent_ds_error_e ds_err = sync_agent_ds_init();
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_ERROR("failed to init oma ds");
+               return -1;
+       }
+
+       int noti_type = 1;
+       sync_agent_event_error_e err = sync_agent_set_noti_callback(noti_type, _session_process_noti_cb, NULL);
+       if (err != SYNC_AGENT_EVENT_SUCCESS) {
+               _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+               return -1;
+       }
+
+       noti_type = 2;
+       err = sync_agent_set_noti_callback(noti_type, _process_update_noti_cb, NULL);
+       if (err != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_noti_callback()");
+
+       /* Creates a new GIOChannel from std input */
+       stdin_channel = g_io_channel_unix_new(0);
+       retvm_if(stdin_channel == NULL, -1, "Error creating new GIOChannel!");
+
+       /* Adds the GIOChannel into the default main loop context with the default priority. */
+       result = g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) _process_cmd_input, NULL);
+       retvm_if(result == 0, -1, "Error creating watch!");
+
+       // display menu
+       _print_omads_test();
+
+       // wait for policy receiver callback rest
+       g_mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(g_mainloop);
+
+       // reaches here when g_main_loop_quit is called
+       ds_err = sync_agent_ds_deinit();
+       if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+               _DEBUG_ERROR("failed to init oma ds");
+               return -1;
+       }
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
diff --git a/test/dummy_project/BuildFlags.cmake b/test/dummy_project/BuildFlags.cmake
new file mode 100644 (file)
index 0000000..8e64bcd
--- /dev/null
@@ -0,0 +1,32 @@
+# Set default build flags
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF()
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Werror -Wno-deprecated-declarations")
+SET(CMAKE_C_FLAGS_DEBUG "-O0")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
+
+MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+MESSAGE(STATUS "Compile flags: ${CMAKE_C_FLAGS}")
+MESSAGE(STATUS "Exe linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
+MESSAGE(STATUS "Module linker flags: ${CMAKE_MODULE_LINKER_FLAGS}")
+MESSAGE(STATUS "Shared linker flags: ${CMAKE_SHARED_LINKER_FLAGS}")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+       ADD_DEFINITIONS("-DDEBUG")
+ENDIF()
+
+MACRO(get_version _file _ver _ver_maj)
+       FILE(STRINGS ${_file} __log LIMIT_COUNT 1 REGEX "(.*)")
+       STRING(REGEX REPLACE ".*\\(\([0-9]+:\)*\([0-9a-zA-Z.]*\).*\\).*" "\\2" __ver ${__log})
+       STRING(REGEX REPLACE "^\([0-9]+\)\\..*" "\\1" __ver_maj ${__ver})
+       SET(${_ver} ${__ver})
+       SET(${_ver_maj} ${__ver_maj})
+ENDMACRO(get_version)
+
diff --git a/test/dummy_project/CMakeLists.txt b/test/dummy_project/CMakeLists.txt
new file mode 100644 (file)
index 0000000..da03f3e
--- /dev/null
@@ -0,0 +1,25 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+INCLUDE(BuildFlags.cmake)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(PLUGINDIR "${PREFIX}/lib/${PROJECT_NAME}")
+
+# get library version from debian/changelog
+get_version(debian/changelog VERSION VERSION_MAJOR)
+MESSAGE(STATUS "Package version is ${VERSION} (major: ${VERSION_MAJOR}) from changelog")
+
+# pass macro defition to source files
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPLUGINDIR=\"${PLUGINDIR}\"")
+
+ADD_DEFINITIONS("-DCOMPONENT_TAG=SYSTEM")
+ADD_DEFINITIONS("-DDUMMY_AGENT_LOG")
+ADD_DEFINITIONS("-DLOG_TAG=\"DUMMY_AGENT\"")
+
+# include source files
+ADD_SUBDIRECTORY(src/agent)
+ADD_SUBDIRECTORY(src/plugins)
+
diff --git a/test/dummy_project/debian/changelog b/test/dummy_project/debian/changelog
new file mode 100644 (file)
index 0000000..d2d822f
--- /dev/null
@@ -0,0 +1,6 @@
+dummy-agent (0.1.1) unstable; urgency=low
+
+  * Initial release 
+  * Tag: dummy-agent_0.1.1
+
+ -- shimseongwon <seongwon.shim@samsung.com>  Thu, 18 Dec 2012 16:10:05 +0900
\ No newline at end of file
diff --git a/test/dummy_project/dummy-agent.manifest b/test/dummy_project/dummy-agent.manifest
new file mode 100644 (file)
index 0000000..5ca2a4a
--- /dev/null
@@ -0,0 +1,17 @@
+<manifest>
+       <define>
+               <domain name="dummy-agent" />
+               <provide>
+                       <label name="dummy-agent::cfg" />
+               </provide>
+       </define>
+       <assign>
+               <filesystem path="/usr/share/dummy-cfg/eventconfig_dummy" label="dummy-agent::cfg"/>
+               <filesystem path="/usr/share/dummy-cfg/noticonfig_dummy" label="dummy-agent::cfg"/>
+               <filesystem path="/usr/share/dummy-cfg/dummy_client_fw_config.xml" label="dummy-agent::cfg"/>
+               <filesystem path="/usr/share/dummy-cfg/dummy_fw_config.xml" label="dummy-agent::cfg"/>
+       </assign>
+       <request>
+               <domain name="dummy-agent" />
+       </request>
+</manifest>
diff --git a/test/dummy_project/dummy-cfg/dummy_client_fw_config.xml b/test/dummy_project/dummy-cfg/dummy_client_fw_config.xml
new file mode 100644 (file)
index 0000000..76f61b1
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml  version="1.0" encoding="UTF-8" ?>\r
+<INIT>\r
+       <Agent-Key>dummy_client</Agent-Key>\r
+       <Event>\r
+               <Event-Key>dummy</Event-Key>\r
+               <Event-Config>/usr/share/dummy-cfg/eventconfig_dummy</Event-Config>\r
+               <RunEventHandler>0</RunEventHandler>\r
+       </Event>\r
+       <Noti>\r
+               <Noti-Key>dummy</Noti-Key>\r
+               <Noti-Config>/usr/share/dummy-cfg/noticonfig_dummy</Noti-Config>\r
+       </Noti>\r
+</INIT>\r
diff --git a/test/dummy_project/dummy-cfg/dummy_fw_config.xml b/test/dummy_project/dummy-cfg/dummy_fw_config.xml
new file mode 100644 (file)
index 0000000..e1b8dc6
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml  version="1.0" encoding="UTF-8" ?>\r
+<INIT>\r
+       <Agent-Key>dummy</Agent-Key>\r
+       <MainLoop>1</MainLoop>\r
+       <Event>\r
+               <Event-Key>dummy</Event-Key>\r
+               <Event-Config>/usr/share/dummy-cfg/eventconfig_dummy</Event-Config>\r
+               <RunEventHandler>1</RunEventHandler>\r
+       </Event>\r
+       <Noti>\r
+               <Noti-Key>dummy</Noti-Key>\r
+               <Noti-Config>/usr/share/dummy-cfg/noticonfig_dummy</Noti-Config>\r
+       </Noti>\r
+       <PlugIn-Mgr>\r
+               <Domain name="DataConnector" count="1">\r
+                       <Plug-In>\r
+                               <ID>0</ID>\r
+                               <Path>/usr/lib/sync-agent/dummy/libplugin-da-dummy.so</Path>\r
+                               <Description>Data Adapter dummy plugin</Description>\r
+                               <DataConverter-PlugIn>0</DataConverter-PlugIn>\r
+                               <Handle-ChangeNoti>0</Handle-ChangeNoti>\r
+                               <Use-MainLoop>0</Use-MainLoop>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="DeviceInfo" count="1">    \r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/dummy/libplugin-di-dummy.so</Path>\r
+                               <Description>Device Info dummy plugin</Description>\r
+                       </Plug-In>\r
+               </Domain>\r
+               <Domain name="PlatformMonitor" count="1">\r
+                       <Plug-In>\r
+                               <ID>1</ID>\r
+                               <Path>/usr/lib/sync-agent/dummy/libplugin-pm-dummy.so</Path>\r
+                               <Description>Platform Monitor dummy plugin</Description>\r
+                <Use-MainLoop>0</Use-MainLoop>\r
+                               <Register-Data count="0">-</Register-Data>\r
+                       </Plug-In>\r
+               </Domain>\r
+       </PlugIn-Mgr>\r
+</INIT>\r
diff --git a/test/dummy_project/dummy-cfg/eventconfig_dummy b/test/dummy_project/dummy-cfg/eventconfig_dummy
new file mode 100644 (file)
index 0000000..778eb85
--- /dev/null
@@ -0,0 +1,6 @@
+1, 1, 0, 30, da_backup_service_items_to_file
+2, 1, 0, 30, da_get_used_item_count
+3, 1, 0, 30, di_get_devinfo
+4, 1, 0, 30, di_execute_dev_function
+5, 1, 0, 30, pm_remove_service_data
+6, 1, 0, 30, pm_get_service_data
\ No newline at end of file
diff --git a/test/dummy_project/dummy-cfg/noticonfig_dummy b/test/dummy_project/dummy-cfg/noticonfig_dummy
new file mode 100644 (file)
index 0000000..505d044
--- /dev/null
@@ -0,0 +1 @@
+1, 0, 0, 30, getservicedata
\ No newline at end of file
diff --git a/test/dummy_project/dummy-plugins.manifest b/test/dummy_project/dummy-plugins.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/test/dummy_project/packaging/dummy-agent.spec b/test/dummy_project/packaging/dummy-agent.spec
new file mode 100755 (executable)
index 0000000..d91b120
--- /dev/null
@@ -0,0 +1,74 @@
+Name:       dummy-agent
+Summary:    dummy-agent daemon for data sync
+Version:    0.1.1
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    Apache License, Version 2.0 
+Source0:    %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(sync-agent)
+BuildRequires:  pkgconfig(libwbxml2)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  expat-devel
+BuildRequires:  cmake
+
+
+%description
+dummy-agent daemon (development headers)
+
+%package -n dummy-plugins
+Summary:    dummy Plugins
+Group:      TO_BE_FILLED
+
+%description -n dummy-plugins
+dummy plugins for sync-agent
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%post
+
+
+%preun
+
+
+%postun
+
+rm -f /tmp/agent_fw_event_omads*
+rm -f /tmp/agent_fw_noti_reply_omads*
+
+rm -rf /usr/share/oma-ds-cfg
+
+
+%files
+%manifest dummy-agent.manifest
+%defattr(-,root,root,-)
+
+/usr/bin/dummy-agent
+
+/usr/share/dummy-cfg/*
+
+
+%files -n dummy-plugins
+%manifest dummy-plugins.manifest
+%defattr(-,root,root,-)
+/usr/lib/sync-agent/dummy/*
diff --git a/test/dummy_project/src/agent/CMakeLists.txt b/test/dummy_project/src/agent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9137a7b
--- /dev/null
@@ -0,0 +1,66 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set a name for the entire project
+PROJECT(dummy)
+
+# set variables
+SET(EXENAME "${PROJECT_NAME}-agent")
+SET(BINDIR "${PREFIX}/bin")
+SET(DUMMY_SRC_DIR "${CMAKE_SOURCE_DIR}/src/agent")
+SET(DUMMY_COMPONETS "main")
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(LPKGS REQUIRED
+                                       glib-2.0
+                                       sync-agent
+                                       libwbxml2
+                                       dlog
+                                       )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
+
+# find all source files in a directory.
+FOREACH(DUMMY_COMPONET ${DUMMY_COMPONETS})
+       AUX_SOURCE_DIRECTORY(${DUMMY_SRC_DIR}/${DUMMY_COMPONET} SRCS)
+ENDFOREACH(DUMMY_COMPONET)
+
+# add internal include directories to the build.
+
+# add define macros
+ADD_DEFINITIONS("-DGLIB_VERSION_MIN_REQUIRED=(2<<16|32<<8) ")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# add an executable to the project using the specified source files.
+ADD_EXECUTABLE(${EXENAME} ${SRCS})
+
+# link a target to given libraries.
+TARGET_LINK_LIBRARIES(${EXENAME} ${LPKGS_LIBRARIES})
+
+# sets additional compiler flags used to build sources within the target.
+SET_TARGET_PROPERTIES(${EXENAME} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+# install executable file
+INSTALL(TARGETS ${EXENAME} DESTINATION ${BINDIR})
+
+# install dummy configuration files
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/dummy-cfg DESTINATION /usr/share)
\ No newline at end of file
diff --git a/test/dummy_project/src/agent/main/main.c b/test/dummy_project/src/agent/main/main.c
new file mode 100755 (executable)
index 0000000..92f25c1
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *   @main.c
+ *   @version                                                                  0.1
+ *   @brief                                                                            This file is the source file of implementation of main function
+ */
+
+#define NOTI_KEY       "dummy"
+
+typedef enum {
+       DA_BACKUP_SERVICE_ITEMS_TO_FILE = 1,
+       DA_GET_USED_ITEM_COUNT,
+       DI_GET_DEVINFO,
+       DI_EXECUTE_DEV_FUNCTION,
+       PM_REMOVE_SERVICE_DATA,
+       PM_GET_SERVICE_DATA
+} event_e;
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sync_agent.h>
+
+static int event_callback_backup_service_items_to_file(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int event_callback_get_used_service_item_count(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int event_callback_get_devinfo(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int event_callback_execute_dev_function(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int event_callback_get_service_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int event_callback_remove_service_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static void _send_noti(void *data);
+
+int main()
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+
+       sync_agent_init_error_e init_error = sync_agent_init("/usr/share/dummy-cfg/dummy_fw_config.xml");
+       if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+               _DEBUG_ERROR("Failed to sync_agent_init() : %d", init_error);
+       } else {
+               _DEBUG_INFO("done init_Framework");
+       }
+
+       error = sync_agent_set_event_callback(DA_BACKUP_SERVICE_ITEMS_TO_FILE, event_callback_backup_service_items_to_file);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       error = sync_agent_set_event_callback(DA_GET_USED_ITEM_COUNT, event_callback_get_used_service_item_count);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       error = sync_agent_set_event_callback(DI_GET_DEVINFO, event_callback_get_devinfo);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       error = sync_agent_set_event_callback(DI_EXECUTE_DEV_FUNCTION, event_callback_execute_dev_function);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       error = sync_agent_set_event_callback(PM_REMOVE_SERVICE_DATA, event_callback_remove_service_data);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       error = sync_agent_set_event_callback(PM_GET_SERVICE_DATA, event_callback_get_service_data);
+       if (error != SYNC_AGENT_EVENT_SUCCESS)
+               _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+       sync_agent_run_main_loop(0);
+
+       _EXTERN_FUNC_EXIT;
+
+       return 0;
+}
+
+static int event_callback_backup_service_items_to_file(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+       int service_type = 0;
+       int account_id = 0;
+       char *file_path = NULL;
+       int result = 0;
+
+       da_err = sync_agent_backup_service_items_to_file(service_type, account_id, &file_path);
+       if (da_err != SYNC_AGENT_DA_SUCCESS) {
+               _DEBUG_ERROR("failed in sync_agent_backup_service_items_to_file");
+               result = 0;
+       } else {
+               _DEBUG_INFO("file_path = %s", file_path);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)file_path);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int event_callback_get_used_service_item_count(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+       int service_type = 0;
+       int result = 0;
+
+       int count = sync_agent_get_used_service_item_count(service_type);
+       if (count < 0) {
+               _DEBUG_ERROR("failed in sync_agent_get_used_service_item_count");
+               result = 0;
+       } else {
+               _DEBUG_INFO("count = %d", count);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &count);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int event_callback_get_devinfo(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+       int device_plugin_id = 1;
+       char *info_name = "dummy";
+       char *value = NULL;
+       sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       int result = 0;
+
+       err = sync_agent_get_devinfo(device_plugin_id, info_name, &value);
+       if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               _DEBUG_ERROR("failed in sync_agent_get_devinfo");
+               result = 0;
+       } else {
+               _DEBUG_INFO("value = %s", value);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)value);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int event_callback_execute_dev_function(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+       int device_plugin_id = 1;
+       sync_agent_dev_return_e dci_result = SYNC_AGENT_DEV_RETURN_SUCCESS;
+       int result = 0;
+
+       dci_result = sync_agent_execute_dev_function(device_plugin_id, "dummy", 1, 1);
+       if (dci_result != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+               _DEBUG_ERROR("failed in sync_agent_execute_dev_function = %d", dci_result);
+               result = 0;
+       } else {
+               _DEBUG_INFO("dci_result = %d", dci_result);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int event_callback_remove_service_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+       int pm_plugin_id = 1;
+       int remove_data_id = 2;
+       int result = 0;
+
+       res = sync_agent_remove_service_data(pm_plugin_id, remove_data_id);
+       if (res != SYNC_AGENT_PM_SUCCESS) {
+               _DEBUG_ERROR("failed in sync_agent_get_service_data = %d", res);
+               result = 0;
+       } else {
+               _DEBUG_INFO("res = %d", res);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static int event_callback_get_service_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+       _EXTERN_FUNC_ENTER;
+       sync_agent_pm_return_e res = SYNC_AGENT_PM_SUCCESS;
+       int pm_plugin_id = 1;
+       int get_data_id = 2;
+       void *data = NULL;
+       int result = 0;
+
+       res = sync_agent_get_service_data(pm_plugin_id, get_data_id, &data);
+       if (res != SYNC_AGENT_PM_SUCCESS) {
+               _DEBUG_ERROR("failed in sync_agent_get_service_data = %d", res);
+               result = 0;
+       } else {
+               _DEBUG_INFO("data = %s", (char *)data);
+               result = 1;
+       }
+
+       sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+       _send_noti(data);
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
+
+static void _send_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       int notiType = 1;
+       sync_agent_event_data_s *noti = NULL;
+
+       noti = sync_agent_create_noti(notiType);
+       if (noti == NULL) {
+               _DEBUG_ERROR("failed to sync_agent_create_noti");
+               return;
+       }
+
+       sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)data);
+
+       sync_agent_event_error_e event_err;
+       sync_agent_send_noti(NOTI_KEY, noti, NULL, NULL, &event_err);
+       if (event_err != SYNC_AGENT_EVENT_SUCCESS) {
+               sync_agent_free_noti(noti);
+               _DEBUG_ERROR("failed to sync_agent_send_noti");
+               return;
+       }
+
+       sync_agent_free_noti(noti);
+
+       _EXTERN_FUNC_EXIT;
+}
diff --git a/test/dummy_project/src/plugins/CMakeLists.sub b/test/dummy_project/src/plugins/CMakeLists.sub
new file mode 100644 (file)
index 0000000..8040b54
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set lib name
+SET(LIBNAME "lib${PROJECT_NAME}")
+#SET(LIBDIR "${PREFIX}/lib")
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${PLUGIN_CFLAGS}")
+
+# add include directories to the build.
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../include)
+
+# find all source files in a directory.
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# add a library to the project using the specified source files.
+ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
+
+# link a target to given libraries from pkg-config.
+TARGET_LINK_LIBRARIES(${LIBNAME} ${PLUGIN_LDFLAGS})
+
+# sets additional compiler flags used to build sources within the target.
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+# override the default target name prefix (such as "lib")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+
+# specify the build version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
+
+# specify the api version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+# install library files
+INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIBDIR})
+
diff --git a/test/dummy_project/src/plugins/CMakeLists.txt b/test/dummy_project/src/plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a300291
--- /dev/null
@@ -0,0 +1,3 @@
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+
+ADD_SUBDIRECTORY(dummy)
diff --git a/test/dummy_project/src/plugins/dummy/CMakeLists.txt b/test/dummy_project/src/plugins/dummy/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..33bbbfe
--- /dev/null
@@ -0,0 +1,10 @@
+
+# set plguin name
+SET(PLUGIN_CATEGORY_NAME "dummy")
+
+# set plugin install path
+SET(LIBDIR "${PREFIX}/lib/sync-agent/${PLUGIN_CATEGORY_NAME}")
+
+ADD_SUBDIRECTORY(da-dummy)
+ADD_SUBDIRECTORY(di-dummy)
+ADD_SUBDIRECTORY(pm-dummy)
diff --git a/test/dummy_project/src/plugins/dummy/da-dummy/CMakeLists.txt b/test/dummy_project/src/plugins/dummy/da-dummy/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..d96f433
--- /dev/null
@@ -0,0 +1,40 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "da-dummy")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       sync-agent
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${da-dummy_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${da-dummy_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
\ No newline at end of file
diff --git a/test/dummy_project/src/plugins/dummy/da-dummy/src/plugin_interface.c b/test/dummy_project/src/plugins/dummy/da-dummy/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..ad8b3bc
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utility/sync_util.h"
+
+#include "plugin/data_connector_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DA_DUMMY"
+#endif
+
+EXPORT_API sync_agent_da_return_e sync_agent_plugin_backup_service_items_to_file(int account_ID, char **file_path)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_da_return_e ret = SYNC_AGENT_DA_SUCCESS;
+
+       *file_path = strdup("/file_path");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API int sync_agent_plugin_get_used_item_count(void)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+
+       return 100;
+}
diff --git a/test/dummy_project/src/plugins/dummy/di-dummy/CMakeLists.txt b/test/dummy_project/src/plugins/dummy/di-dummy/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..c229dca
--- /dev/null
@@ -0,0 +1,41 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "di-dummy")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       sync-agent
+                                       glib-2.0
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${di-dummy_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${di-dummy_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
diff --git a/test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devexe.c b/test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devexe.c
new file mode 100755 (executable)
index 0000000..ff0a9e6
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "utility/sync_util.h"
+#include "device/information.h"
+#include "plugin/device_info_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DI_DUMMY"
+#endif
+
+EXPORT_API int sync_agent_plugin_execute_dev_function(char *function_name, int args_cnt, va_list ap)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(function_name == NULL, 0, "function_name is NULL. FAIL !!!");
+
+       _EXTERN_FUNC_EXIT;
+       return 0;
+}
diff --git a/test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devinfo.c b/test/dummy_project/src/plugins/dummy/di-dummy/src/plugin_interface_devinfo.c
new file mode 100755 (executable)
index 0000000..73f36c1
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "utility/sync_util.h"
+#include "plugin/device_info_interface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_DI_DUMMY"
+#endif
+
+EXPORT_API int sync_agent_plugin_load_devinfo()
+{
+       _EXTERN_FUNC_ENTER;
+
+       int res = 1;
+
+       _EXTERN_FUNC_EXIT;
+       return res;
+}
+
+EXPORT_API int sync_agent_plugin_get_devinfo(char *info_name, char **value)
+{
+       _EXTERN_FUNC_ENTER;
+
+       retvm_if(info_name == NULL, 0, "info_name is NULL. FAIL !!!");
+
+       int res = 1;
+
+       *value = strdup("test_value");
+
+       _EXTERN_FUNC_EXIT;
+
+       return res;
+}
diff --git a/test/dummy_project/src/plugins/dummy/pm-dummy/CMakeLists.txt b/test/dummy_project/src/plugins/dummy/pm-dummy/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..78b33ba
--- /dev/null
@@ -0,0 +1,41 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "pm-dummy")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+                                       sync-agent
+                                       dlog)
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${pm-dummy_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${pm-dummy_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
+
diff --git a/test/dummy_project/src/plugins/dummy/pm-dummy/src/plugin_interface.c b/test/dummy_project/src/plugins/dummy/pm-dummy/src/plugin_interface.c
new file mode 100755 (executable)
index 0000000..476cfb8
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * sync-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "plugin/platform_monitor_interface.h"
+#include "utility/sync_util.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG        "PLUGIN_PM_DUMMY"
+#endif
+
+EXPORT_API void sync_agent_plugin_init_service_noti(void *data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data)
+{
+       _EXTERN_FUNC_ENTER;
+
+       sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+       *service_data = strdup("dummy_data");
+
+       _EXTERN_FUNC_EXIT;
+
+       return ret;
+}