summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-12 16:51:48 (GMT)
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-12 16:51:48 (GMT)
commitd6aa47559c38d7e20d6d6a7a3671fa48ed58b9eb (patch)
tree5fbc758662a7866e32ec1adcfd9149c71987549e
parent8fe192a924f295972402d46141e39b86241a1441 (diff)
downloadoma-ds-agent-d6aa47559c38d7e20d6d6a7a3671fa48ed58b9eb.zip
oma-ds-agent-d6aa47559c38d7e20d6d6a7a3671fa48ed58b9eb.tar.gz
oma-ds-agent-d6aa47559c38d7e20d6d6a7a3671fa48ed58b9eb.tar.bz2
Tizen 2.1 base
-rwxr-xr-xAUTHORS4
-rw-r--r--BuildFlags.cmake32
-rw-r--r--CMakeLists.txt25
-rwxr-xr-xLICENSE.APLv2202
-rwxr-xr-xNOTICE3
-rwxr-xr-xcom.samsung.omadsagent.service3
-rw-r--r--debian/changelog47
-rwxr-xr-xdebian/control22
-rw-r--r--debian/control.slp8
-rw-r--r--debian/postinst45
-rwxr-xr-xdebian/rules104
-rw-r--r--ds-public-plugins.manifest5
-rwxr-xr-xinclude/common/common_define.h1191
-rwxr-xr-xinclude/common/common_define_internal.h307
-rwxr-xr-xinclude/common/common_util.h187
-rwxr-xr-xinclude/common/common_vconf.h249
-rwxr-xr-xinclude/common/csc_keys.h50
-rwxr-xr-xinclude/framework/event/oma_ds_event_handler.h354
-rwxr-xr-xinclude/framework/event/oma_ds_platform_event_handler.h114
-rwxr-xr-xinclude/framework/san-parser/pm_sanparser.h224
-rwxr-xr-xinclude/framework/task/oma_ds_engine_controller_task.h975
-rwxr-xr-xinclude/service-adapter/network-binder/na_binder.h85
-rwxr-xr-xinclude/service-adapter/protocol-binder/oma_ds_protocol_binder.h314
-rwxr-xr-xinclude/service-adapter/protocol-binder/oma_ds_protocol_binder_definition.h188
-rwxr-xr-xinclude/service-adapter/sa_command.h866
-rwxr-xr-xinclude/service-adapter/sa_command_internal.h102
-rwxr-xr-xinclude/service-adapter/sa_common_interface.h285
-rwxr-xr-xinclude/service-adapter/sa_define.h159
-rwxr-xr-xinclude/service-adapter/sa_devinf.h134
-rwxr-xr-xinclude/service-adapter/sa_devinf_internal.h118
-rwxr-xr-xinclude/service-adapter/sa_elements.h893
-rwxr-xr-xinclude/service-adapter/sa_elements_internal.h102
-rwxr-xr-xinclude/service-adapter/sa_error.h124
-rwxr-xr-xinclude/service-adapter/sa_session.h277
-rwxr-xr-xinclude/service-adapter/sa_session_internal.h83
-rwxr-xr-xinclude/service-adapter/sa_util.h94
-rwxr-xr-xinclude/service-engine/se_account.h342
-rwxr-xr-xinclude/service-engine/se_common.h128
-rwxr-xr-xinclude/service-engine/se_error.h45
-rwxr-xr-xinclude/service-engine/se_notification.h99
-rwxr-xr-xinclude/service-engine/se_storage.h258
-rwxr-xr-xinclude/service-engine/se_sync.h234
-rwxr-xr-xoma-ds73
-rw-r--r--oma-ds-agent.manifest18
-rw-r--r--oma-ds-cfg/eventconfig_omads12
-rw-r--r--oma-ds-cfg/noticonfig_omads2
-rw-r--r--oma-ds-cfg/omadsUI_fw_config.xml13
-rw-r--r--oma-ds-cfg/omads_fw_config.xml133
-rwxr-xr-xpackaging/oma-ds-agent.spec117
-rwxr-xr-xsrc/agent/CMakeLists.txt80
-rwxr-xr-xsrc/agent/common/common_define.c750
-rwxr-xr-xsrc/agent/common/common_util.c281
-rwxr-xr-xsrc/agent/common/common_vconf.c191
-rwxr-xr-xsrc/agent/framework/event/oma_ds_event_handler.c908
-rwxr-xr-xsrc/agent/framework/event/oma_ds_platform_event_handler.c355
-rwxr-xr-xsrc/agent/framework/san-parser/pm_sanparser.c633
-rwxr-xr-xsrc/agent/framework/task/oma_ds_engine_controller_task.c1137
-rwxr-xr-xsrc/agent/main/main.c395
-rwxr-xr-xsrc/agent/service-adapter/network-binder/na_binder.c142
-rwxr-xr-xsrc/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c5256
-rwxr-xr-xsrc/agent/service-adapter/sa_command.c1016
-rwxr-xr-xsrc/agent/service-adapter/sa_common_interface.c2812
-rwxr-xr-xsrc/agent/service-adapter/sa_devinf.c1069
-rwxr-xr-xsrc/agent/service-adapter/sa_elements.c834
-rwxr-xr-xsrc/agent/service-adapter/sa_session.c1578
-rwxr-xr-xsrc/agent/service-adapter/sa_util.c177
-rwxr-xr-xsrc/agent/service-engine/se_account.c1865
-rwxr-xr-xsrc/agent/service-engine/se_notification.c133
-rwxr-xr-xsrc/agent/service-engine/se_storage.c1000
-rwxr-xr-xsrc/agent/service-engine/se_sync.c3245
-rw-r--r--src/plugins/CMakeLists.sub57
-rw-r--r--src/plugins/CMakeLists.txt3
-rwxr-xr-xsrc/plugins/ds-public/CMakeLists.txt11
-rwxr-xr-xsrc/plugins/ds-public/plain-text/CMakeLists.txt43
-rwxr-xr-xsrc/plugins/ds-public/plain-text/include/in_datastore_info_plain_text.h32
-rwxr-xr-xsrc/plugins/ds-public/plain-text/src/plugin_interface.c245
-rwxr-xr-xsrc/plugins/ds-public/vcard/CMakeLists.txt42
-rwxr-xr-xsrc/plugins/ds-public/vcard/include/encoding_util.h237
-rwxr-xr-xsrc/plugins/ds-public/vcard/include/in_datastore_info_vcard.h156
-rwxr-xr-xsrc/plugins/ds-public/vcard/include/plugin_spec.h65
-rwxr-xr-xsrc/plugins/ds-public/vcard/src/encoding_util.c814
-rwxr-xr-xsrc/plugins/ds-public/vcard/src/plugin_interface.c998
-rwxr-xr-xsrc/plugins/ds-public/xcalllog/CMakeLists.txt42
-rwxr-xr-xsrc/plugins/ds-public/xcalllog/include/encoding_util.h238
-rwxr-xr-xsrc/plugins/ds-public/xcalllog/include/plugin_spec.h33
-rwxr-xr-xsrc/plugins/ds-public/xcalllog/src/encoding_util.c812
-rwxr-xr-xsrc/plugins/ds-public/xcalllog/src/plugin_interface.c432
-rwxr-xr-xtest/include/suites/unit_test_sample_suite.h25
-rwxr-xr-xtest/include/unit_test_common.h26
-rwxr-xr-xtest/include/unit_test_run.h32
-rwxr-xr-xtest/include/unit_test_suites.h30
-rwxr-xr-xtest/src/oma_test_main.c24
-rwxr-xr-xtest/src/suites/unit_test_sample_suite.c63
-rwxr-xr-xtest/src/unit_test_run.c131
94 files changed, 37897 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100755
index 0000000..b5328d5
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+WooJin Yun <suhoangel9 at samsung dot com>
+JooHark Park <juhaki.park at samsung dot com>
+SangHyuk Ko <sanghyuk.ko at samsung dot com>
+JunHyung Park <jruss.park at samsung dot com>
diff --git a/BuildFlags.cmake b/BuildFlags.cmake
new file mode 100644
index 0000000..8e64bcd
--- /dev/null
+++ b/BuildFlags.cmake
@@ -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/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..7ddc553
--- /dev/null
+++ b/CMakeLists.txt
@@ -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("-DOMADS_AGENT_LOG")
+ADD_DEFINITIONS("-DLOG_TAG=\"OMA_DS_AGENT\"")
+
+# include source files
+ADD_SUBDIRECTORY(src/agent)
+ADD_SUBDIRECTORY(src/plugins)
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100755
index 0000000..d645695
--- /dev/null
+++ b/LICENSE.APLv2
@@ -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
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/com.samsung.omadsagent.service b/com.samsung.omadsagent.service
new file mode 100755
index 0000000..15ae0c5
--- /dev/null
+++ b/com.samsung.omadsagent.service
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.samsung.omadsagent
+Exec=/usr/bin/oma-ds-agent
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..d9f499e
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,47 @@
+oma-ds-agent (0.1.6) unstable; urgency=low
+
+ * 1. license file update.
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.6
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 21 Jan 2013 22:09:10 +0900
+
+oma-ds-agent (0.1.5) unstable; urgency=low
+
+ * 1. Revised for version release
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.5
+
+ -- Juhaki Park <juhaki.park@samsung.com> Thu, 10 Jan 2013 10:06:10 +0900
+
+oma-ds-agent (0.1.4) unstable; urgency=low
+
+ * 1. Revised for version release
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.4
+
+ -- WooJin Yun <suhoangel9@samsung.com> Wed, 09 Jan 2013 19:42:10 +0900
+
+oma-ds-agent (0.1.3) unstable; urgency=low
+
+ * 1. Fixes for Prevent defects
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.3
+
+ -- sanghyuk.ko <sanghyuk.ko@samsung.com> Wed, 09 Jan 2013 17:31:34 +0900
+
+oma-ds-agent (0.1.2) unstable; urgency=low
+
+ * 1. Internal: build error & dependency patch
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.2
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 28 Dec 2012 22:47:52 +0900
+
+oma-ds-agent (0.1.1) unstable; urgency=low
+
+ * Initial Update
+ * Git: framework/system/oma-ds-agent
+ * Tag: oma-ds-agent_0.1.1
+
+ -- WooJin Yun <suhoangel9@samsung.com> Wed, 01 Feb 2012 10:30:16 +0900
diff --git a/debian/control b/debian/control
new file mode 100755
index 0000000..5166e62
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,22 @@
+Source: oma-ds-agent
+Section: embedded
+Priority: optional
+Maintainer: WooJin Yun <suhoangel9@samsung.com>, Joohark Park <juhaki.park@samsung.com>, Junhyuk Lee <junhyuk7.lee@samsung.com>
+Uploaders: Joohark Park <juhaki.park@samsung.com>, Junhyuk Lee <junhyuk7.lee@samsung.com>
+Build-Depends: debhelper (>= 5), libglib2.0-dev, sqlite3, libsoup2.4-dev, libsqlite3-dev, check, libvconf-dev, libexpat1-dev, libsync-agent-framework-dev, libwbxml2-dev
+Standards-Version: 0.1.1
+
+Package: oma-ds-agent
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends},
+Description: OMA Data Synchronization service module
+
+Package: oma-ds-agent-dbg
+Section: debug
+Architecture: any
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}, oma-ds-agent (= ${Source-Version})
+Description: OMA Data Synchronization service module (unstripped)
+
diff --git a/debian/control.slp b/debian/control.slp
new file mode 100644
index 0000000..20474e7
--- /dev/null
+++ b/debian/control.slp
@@ -0,0 +1,8 @@
+#Mon Nov 08 05:13:18 KST 2010
+Privileges=
+AppInstallPath=/usr
+UserUninstall=yes
+IdealScreen=480x800,46x71
+Version=1.0.0
+
+
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 0000000..711fa30
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+echo ""
+echo ""
+echo "*********************************************************************************"
+echo " post install script run..."
+echo "*********************************************************************************"
+echo "executing oma agent unit test binary."
+
+OMA_TEST_BIN="/usr/bin/oma-test"
+if [ ! -e "$OMA_TEST_BIN" ]
+then
+ echo " oma-agent test binary missing. (check debian package is in release mode)"
+else
+
+ echo ""
+ echo ""
+ echo "*********************************************************************************"
+ echo " oma agent unit test run..."
+ echo "*********************************************************************************"
+ echo ""
+ $OMA_TEST_BIN
+fi
+echo "create oma-ds directory"
+if [ ! -d /opt/data/oma-ds ]
+then
+ mkdir /opt/data/oma-ds
+fi
+
+echo "deleting framework db files"
+if [ -d /usr/share/sync-agent-framework ]
+then
+ rm -rf /usr/share/sync-agent-framework
+fi
+
+echo "deleting db files"
+if [ -f /opt/dbspace/.omasyncagent.db ]
+then
+ rm -rf /opt/dbspace/.omasyncagent.db
+fi
+
+if [ -f /opt/dbspace/.omasyncagent.db-journal ]
+then
+ rm -rf /opt/dbspace/.omasyncagent.db-journal
+fi
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..a28c17d
--- /dev/null
+++ b/debian/rules
@@ -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
+
+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}
+ 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 ./oma-ds-agent
+ -rm -rf ./oma-test
+
+ -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
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/init.d
+ install -c $(CURDIR)/syncmld_mgr $(CURDIR)/debian/tmp/etc/rc.d/init.d
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
+ ln -s ../init.d/syncmld_mgr $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S91oma-ds-agent
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d
+ ln -s ../init.d/syncmld_mgr $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S91oma-ds-agent
+
+# 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=oma-ds-agent
+ 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/ds-public-plugins.manifest b/ds-public-plugins.manifest
new file mode 100644
index 0000000..97e8c31
--- /dev/null
+++ b/ds-public-plugins.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/include/common/common_define.h b/include/common/common_define.h
new file mode 100755
index 0000000..4612b39
--- /dev/null
+++ b/include/common/common_define.h
@@ -0,0 +1,1191 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Define.h
+ * @version 0.1
+ * @brief This file is the header file of interface for common structure
+ */
+
+#ifndef COMMON_DEFINE_H_
+#define COMMON_DEFINE_H_
+
+#include "common_define_internal.h"
+
+/**
+ * @par Description: API to create datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, target uri
+ * @param[in] string type, source uri
+ * @param[out] Status structure
+ *
+ * @return datastore_info_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+datastore_info_s *create_datastore_info(char *target, char *source);
+
+/**
+ * @par Description: API to free list of datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of datastore_info_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_datastore_infos(GList * datastore_infos);
+
+/**
+ * @par Description: API to free datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_info_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_datastore_info(datastore_info_s * datastore_info);
+
+/**
+ * @par Description: API to set sync type in datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_info_s structure
+ * @param[in] enum type, sync type
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_info_sync_type(datastore_info_s * datastore_info, alert_type_e sync_type);
+
+/**
+ * @par Description: API to set last anchor in datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_info_s structure
+ * @param[in] string type, last anchor
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_info_last_anchor(datastore_info_s * datastore_info, char *last_anchor);
+
+/**
+ * @par Description: API to set next anchor in datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_info_s structure
+ * @param[in] string type, next anchor
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_info_next_anchor(datastore_info_s * datastore_info, char *next_anchor);
+
+/**
+ * @par Description: API to set max_obj_size in datastore_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_info_s structure
+ * @param[in] unsigned int, max_obj_size
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_info_max_obj_size(datastore_info_s * datastore_info, unsigned int max_obj_size);
+
+/**
+ * @par Description: API to create changed_item_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, change type of item
+ * @param[in] string type, luid of item
+ * @param[out]
+ *
+ * @return changed_item_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+changed_item_s *create_changed_item(change_type_e type, char *luid);
+
+/**
+ * @par Description: API to free changed_item_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_item_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_changed_item(changed_item_s * changed_item);
+
+/**
+ * @par Description: API to set content type in changed_item_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_item_s structure
+ * @param[in] string type, content type
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_changed_item_content_type(changed_item_s * changed_item, char *content_type);
+
+/**
+ * @par Description: API to set data in changed_item_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_item_s structure
+ * @param[in] string type, data
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_changed_item_data(changed_item_s * changed_item, char *data);
+
+/**
+ * @par Description: API to set in changed_item_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_item_s structure
+ * @param[in] datastore index(0=contacts, 1=calendar, 2= memo)
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_changed_item_index_of_datastore(changed_item_s * changed_item, unsigned int indexOfDatastore);
+
+/**
+ * @par Description: API to create changed_datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, source uri
+ * @param[in] string type, target uri
+ * @param[in] int type, has numberOfChanges or not
+ * @param[in] unsigned int type, if numberOfChanges is true set count else set zero
+ * @param[out]
+ *
+ * @return changed_datastore_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+changed_datastore_s *create_changed_datastore(char *source, char *target, int has_number_of_changes, unsigned int number_of_changes);
+
+/**
+ * @par Description: API to free list of changed_datastore_s
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of changed_datastore_s
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_changed_datastores(GList * changed_datastores);
+
+/**
+ * @par Description: API to free changed_datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_datastore_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_changed_datastore(changed_datastore_s * changed_datastore);
+
+/**
+ * @par Description: API to set changed_item in changed_datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_datastore_s structure
+ * @param[in] list of changed_item_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_changed_datastore_changed_item(changed_datastore_s * changed_datastore, GList * changed_item);
+
+/**
+ * @par Description: API to add changed_item in changed_datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] changed_datastore_s structure
+ * @param[in] changed_item_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_changed_datastore_changed_item(changed_datastore_s * changed_datastore, changed_item_s * changed_item);
+
+/**
+ * @par Description: API to create applied_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, luid of item
+ * @param[in] enum type, change type( CHANGE_ADD , CHANGE_REPLACE , CHANGE_DELETE)
+ * @param[in] int type, status code(200....)
+ * @param[out]
+ *
+ * @return applied_status_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+applied_status_s *create_applied_status(char *luid, change_type_e change_type, int status);
+
+/**
+ * @par Description: API to free list of applied_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of applied_status_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_applied_statuses(GList * applied_statuses);
+
+/**
+ * @par Description: API to free applied_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] applied_status_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_applied_status(applied_status_s * applied_status);
+
+/**
+ * @par Description: API to create sending_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] source uri
+ * @param[in] target uri
+ * @param[out]
+ *
+ * @return sending_status_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sending_status_s *create_sending_status(char *source, char *target);
+
+/**
+ * @par Description: API to free list of sending_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of sending_status_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sending_statuses(GList * sending_statuses);
+
+/**
+ * @par Description: API to free sending_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sending_status_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sending_status(sending_status_s * sending_status);
+
+/**
+ * @par Description: API to add applied_status_s in sending_status_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sending_status_s structure
+ * @param[in] applied_status_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_sending_status_applied_status(sending_status_s * sending_status, applied_status_s * applied_status);
+
+/**
+ * @par Description: API to create datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, target uri
+ * @param[in] string type, source uri
+ * @param[out]
+ *
+ * @return datastore_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+datastore_s *create_datastore(char *target, char *source);
+
+/**
+ * @par Description: API to set content type infomation in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] int type, datastore_id(TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO)
+ * @param[in] int type, folder_type_id(9, 8, 10)
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_content_type_info(datastore_s * datastore, int datastore_id, int folder_type_id);
+
+/**
+ * @par Description: API to set account information in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] string type, account_id
+ * @param[in] string type, account_pw
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_account_info(datastore_s * datastore, char *account_id, char *account_pw);
+
+/**
+ * @par Description: API to set client sync type in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] enum type, sync type
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_client_sync_type(datastore_s * datastore, alert_type_e sync_type);
+
+/**
+ * @par Description: API to set server sync type in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] enum type, sync type
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_server_sync_type(datastore_s * datastore, alert_type_e sync_type);
+
+/**
+ * @par Description: API to set client anchor in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] string type, last anchor
+ * @param[in] string type, next anchor
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_client_anchor(datastore_s * datastore, char *last_anchor, char *next_anchor);
+
+/**
+ * @par Description: API to set client anchor in datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] string type, last anchor
+ * @param[in] string type, next anchor
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_datastore_server_anchor(datastore_s * datastore, char *last_anchor, char *next_anchor);
+
+/**
+ * @par Description: API to create sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[in] string type, last anchor
+ * @param[in] string type, next anchor
+ * @param[out]
+ *
+ * @return sync_result_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_result_s *create_sync_result();
+
+/**
+ * @par Description: API to duplicate sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[out]
+ *
+ * @return sync_result_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_result_s *dup_sync_result(sync_result_s * org_sync_result);
+
+/**
+ * @par Description: API to set number of total item in sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[in] number of total item
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_number_of_change(sync_result_s * sync_result, unsigned int number_of_change);
+
+/**
+ * @par Description: API to set number of received item in sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[in] number of received item
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_receive_count(sync_result_s * sync_result, unsigned int received_count);
+
+/**
+ * @par Description: API to set number of add item in sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[in] number of add item
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_add_count(sync_result_s * sync_result, unsigned int add_cnt);
+
+/**
+ * @par Description: API to set number of replace item in sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[in] number of replace item
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_replace_count(sync_result_s * sync_result, unsigned int replace_cnt);
+
+/**
+ * @par Description: API to set number of delete item in sync_result_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_result_s structure
+ * @param[in] number of delete item
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_delete_count(sync_result_s * sync_result, unsigned int delete_cnt);
+
+/**
+ * @par Description: API to free PreSyncReturnObj structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] pre_sync_return_obj_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_pre_sync_return_obj(pre_sync_return_obj_s * pre_sync_return_obj);
+
+/**
+ * @par Description: API to free sync_obj_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_obj_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sync_obj(sync_obj_s * sync_obj);
+
+/**
+ * @par Description: API to free sync_return_obj_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_return_obj_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sync_return_obj(sync_return_obj_s * sync_return_obj);
+
+/**
+ * @par Description: API to free datastore_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] datastore_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_datastore(datastore_s * datastore);
+
+/**
+ * @par Description: API to free sync_category structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_service_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sync_service(sync_service_s * category);
+
+#endif /* COMMON_DEFINE_H_ */
diff --git a/include/common/common_define_internal.h b/include/common/common_define_internal.h
new file mode 100755
index 0000000..c3078de
--- /dev/null
+++ b/include/common/common_define_internal.h
@@ -0,0 +1,307 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Define_Internal.h
+ * @version 0.1
+ * @brief This file is the header file of defined common structure for using between SE and SA
+ */
+
+#ifndef COMMON_DEFINE_INTERNAL_H_
+#define COMMON_DEFINE_INTERNAL_H_
+
+#include <malloc.h>
+#include <stdio.h>
+#include <glib.h>
+#include <string.h>
+
+/* #define COMMUNICATION_TYPE SYNC_AGENT_PB_ENCODING_XML */
+#define COMMUNICATION_TYPE SYNC_AGENT_PB_ENCODING_WBXML_12
+
+#define TRANSPORT_TYPE 1 /*http */
+ /*#define TRANSPORT_TYPE "FW_MOBEX" *//*mobex -> does not support in OMA */
+
+#define NETWORK_TIMEOUT 60
+
+#define MAXIMUM_ACCOUNT_COUNT 5
+
+#define PKG_NAME "oma-ds-agent"
+#define DEFINE_PLATFORM 1
+#define LOW_BATTERY_LEVEL 10
+
+#define OMA_DS_MSG_PATH "/opt/usr/data/oma-ds/debug_msg"
+#define OMA_DS_CSC_CHECK_PATH "/opt/usr/data/oma-ds/csc_check"
+
+#define ELEMENT_TEXT_VCARD "text/x-vcard"
+#define ELEMENT_TEXT_VCARD_30 "text/vcard"
+#define ELEMENT_TEXT_VCAL "text/x-vcalendar"
+#define ELEMENT_TEXT_ICAL "text/calendar"
+#define ELEMENT_TEXT_PLAIN "text/plain"
+#define ELEMENT_TEXT_XCALLLOG "text/x-calllog"
+#define ELEMENT_TEXT_MESSAGE "text/x-vMessage"
+
+#define DEFINE_ALERT_UNKNOWN_STR "Unknown"
+#define DEFINE_ALERT_SLOW_SYNC_STR "Full"
+#define DEFINE_ALERT_TWO_WAY_STR "Update both"
+#define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR "Update to server"
+#define DEFINE_ALERT_ONE_WAY_FROM_SERVER_STR "Update to phone"
+#define DEFINE_ALERT_REFRESH_FROM_SERVER_STR "Refresh from server"
+#define DEFINE_ALERT_REFRESH_FROM_CLIENT_STR "Refresh from phone"
+
+#define DEFINE_ALERT_SLOW_SYNC_VALUE "201"
+#define DEFINE_ALERT_TWO_WAY_VALUE "200"
+#define DEFINE_ALERT_ONE_WAY_FROM_CLIENT_VALUE "202"
+#define DEFINE_ALERT_ONE_WAY_FROM_SERVER_VALUE "204"
+#define DEFINE_ALERT_REFRESH_FROM_SERVER_VALUE "205"
+#define DEFINE_ALERT_REFRESH_FROM_CLIENT_VALUE "203"
+
+#define DEFINE_CONFIG_KEY_PROFILE_SERVER_ID "Server_id"
+#define DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE "Sync_mode"
+#define DEFINE_CONFIG_KEY_PROFILE_SERVER_IP "Server_ip"
+#define DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE "Next_nonce"
+#define DEFINE_CONFIG_KEY_PROFILE_DIR_NAME "Dir_name"
+#define DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING "Synchronising"
+#define DEFINE_CONFIG_KEY_PROFILE_RESUME "Resume"
+#define DEFINE_CONFIG_KEY_PROFILE_NAME "Name"
+#define DEFINE_CONFIG_KEY_PROFILE_CLIENT_SYNC_TYPE "Client_Sync_type"
+#define DEFINE_CONFIG_KEY_PROFILE_SERVER_SYNC_TYPE "Server_Sync_type"
+#define DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL "Sync_interval"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS "Contacts"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR "Organizer"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO "Memo"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG "CallLog"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE "source"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET "target"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID "id"
+#define DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD "password"
+#define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_STATUS "Last_session_status"
+#define DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_TIME "Last_session_time"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_DBSYNCED "dbSynced"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_LAST_TIME "last_session_time"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL "numberOfChanges"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD "add_count"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE "delete_count"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE "replace_count"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER "server"
+#define DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT "client"
+#define DEFINE_CONFIG_KEY_PROFILE_ALARM_ID "Alarm_id"
+
+#define DEFINE_SYNC_MODE_MANUAL "Manual"
+#define DEFINE_SYNC_MODE_PUSH "Push"
+#define DEFINE_SYNC_MODE_PERIODIC "Periodic"
+
+#define DEFINE_SOURCE_CONTACT_URI "Contacts"
+#define DEFINE_SOURCE_CALENDAR_URI "Organizer"
+#define DEFINE_SOURCE_MEMO_URI "Memo"
+#define DEFINE_SOURCE_CALLLOG_URI "CallLog"
+
+#define DEFINE_DIVE_SERVER_URL_HTTPS "https://syn.samsungdive.com/sync"
+#define DEFINE_DIVE_SERVER_URL_HTTP "http://syn.samsungdive.com/sync"
+#define DEFINE_DIVE_SERVER_ID "syn.samsungdive.com"
+#define DEFINE_DIVE_DEFAULT_NEXT_NONCE "pcwds"
+
+typedef enum {
+ SYNC_SESSION_NOT_SYNCED_YET = -1,
+ SYNC_SESSION_FAILED = 0,
+ SYNC_SESSION_SUCCEEDED = 1,
+ SYNC_SESSION_STOPPED = 2,
+ SYNC_SESSION_SYNCHRONIZING = 3
+} sync_session_result_e;
+
+typedef enum {
+ ALERT_UNKNOWN = 0,
+ ALERT_DISPLAY = 100,
+ ALERT_TWO_WAY = 200,
+ ALERT_SLOW_SYNC = 201,
+ ALERT_ONE_WAY_FROM_CLIENT = 202,
+ ALERT_REFRESH_FROM_CLIENT = 203,
+ ALERT_ONE_WAY_FROM_SERVER = 204,
+ ALERT_REFRESH_FROM_SERVER = 205,
+ ALERT_TWO_WAY_BY_SERVER = 206,
+ ALERT_ONE_WAY_FROM_CLIENT_BY_SERVER = 207,
+ ALERT_REFRESH_FROM_CLIENT_BY_SERVER = 208,
+ ALERT_ONE_WAY_FROM_SERVER_BY_SERVER = 209,
+ ALERT_REFRESH_FROM_SERVER_BY_SERVER = 210,
+ ALERT_RESULT = 221,
+ ALERT_NEXT_MESSAGE = 222,
+ ALERT_NO_END_OF_DATA = 223,
+ ALERT_SUSPEND = 224,
+ ALERT_RESUME = 225,
+} alert_type_e;
+
+typedef enum {
+ CHANGE_UNKNOWN = 0,
+ CHANGE_ADD = 1,
+ CHANGE_REPLACE = 2,
+ CHANGE_DELETE = 3
+} change_type_e;
+
+typedef enum {
+ TYPE_CONTACT = 0,
+ TYPE_CALENDAR,
+ TYPE_MEMO,
+ TYPE_CALLLOG,
+
+ TYPE_SERVICE_COUNT
+} service_type_e;
+
+typedef enum {
+ COMMON_INIT = 0,
+ COMMON_OK = 100,
+ COMMON_MISCONFIGURATION = 200,
+ COMMON_AUTHENTICATION_ERROR = 201,
+ COMMON_NOT_FOUND = 202,
+ COMMON_NO_MEMORY = 203,
+ COMMON_INTERNAL_ERROR = 204,
+ COMMON_SERVER_ERROR = 205,
+ COMMON_CONNECTION_ERROR = 206,
+ COMMON_AUTOCONFIG_NOT_SUPPORT_BY_SERVER = 207,
+ COMMON_BUSY_SIGNALING = 208,
+ COMMON_SUSPEND_FAIL = 209,
+ COMMON_CANCEL = 300,
+} common_error_type_e;
+
+typedef struct {
+ sync_session_result_e session_result;
+ unsigned int number_of_change;
+ unsigned int received_count;
+ unsigned int add_count;
+ unsigned int replace_count;
+ unsigned int delete_count;
+} sync_result_s;
+
+/**
+ * @brief Data Store information
+ * relevant information about Data Store\n
+ *
+ */
+typedef struct {
+ int datastore_id; /**< plugin_type : TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO, TYPE_CALL_LOG */
+ int folder_type_id; /**< folder type id 0 */
+ char *target; /**< target(server) URI */
+ char *source; /**< source(client) URI */
+ char *id; /**< account id */
+ char *pw; /**< account pw */
+ alert_type_e client_sync_type; /**< Sync Type(two-way, one-way ...) */
+ alert_type_e server_sync_type; /**< Sync Type(two-way, one-way ...) */
+ char *last_anchor_client; /**< Last Anchor of datastore for client side */
+ char *next_anchor_client; /**< Next Anchor of datastore for client side */
+ char *last_anchor_server; /**< Next Anchor of datastore for server side */
+ char *next_anchor_server; /**< Next Anchor of datastore for server side */
+ sync_result_s *client_sync_result;
+ sync_result_s *server_sync_result;
+} datastore_s;
+
+typedef struct {
+ char *target; /**< target(server) URI */
+ char *source; /**< source(client) URI */
+ alert_type_e sync_type; /**< Sync Type(two-way, one-way ...) */
+ char *last_anchor; /**< Last Anchor of datastore for client side */
+ char *next_anchor; /**< Next Anchor of datastore for client side */
+ unsigned int max_obj_size;
+} datastore_info_s;
+
+/**
+ @brief Third parameter of pre_sync function
+
+ Output data from pre_sync function\n
+ Data that need to be passed to Service Engine from Service Adapter result of pkg2
+
+ */
+typedef struct {
+ GList *datastore_info; /**< containing datastore_info structure*/
+ char *dev_id;
+} pre_sync_return_obj_s;
+
+/**
+ @brief a changed item(changelog)
+
+ */
+typedef struct {
+ change_type_e change_type; /**< type of changes (add, replace, delete, copy, move ..) */
+ char *luid; /**< luid of item */
+ char *content_type; /**< content type of data */
+ unsigned int index_of_datastore;
+ char *data; /**< data */
+} changed_item_s;
+
+/**
+ @brief item that are grouped by each Data Store
+
+ */
+typedef struct {
+ char *source; /**< source(client) URI */
+ char *target; /**< target(server) URI */
+ int need_sync_command;
+ unsigned int number_of_changes;
+ int has_number_of_changes;
+
+ GList *change_item; /**< containing changed_item all type */
+ GList *sent_item; /**< containing changed_item */
+} changed_datastore_s;
+
+/**
+ @brief result of applied command that from service engine or server
+
+ */
+typedef struct {
+ change_type_e change_type; /**< change type (add, replace, delete...) */
+ char *luid; /**< luid of item */
+ int status; /**< status of applied item */
+} applied_status_s;
+
+typedef struct {
+ char *source; /**< source(client) URI */
+ char *target; /**< target(server) URI */
+ GList *items; /**< containing appllied_status struct */
+} sending_status_s;
+
+/**
+ @brief second and third parameter of sync function
+
+ */
+typedef struct {
+ GList *changed_datastore; /**< containing changed_datastore structure when it's in SyncObj it will be command that client send to server */
+ GList *sending_status; /**< containing sending_status structure when it's in SyncObj status of add, replace, delete command from server */
+} sync_obj_s;
+
+typedef struct {
+ GList *changed_datastore; /**< containing changed_datastore structure when it's in SyncReturnObj command(add, relpace, delete) from server */
+ GList *status; /**< containing applied_status structure when it's in SyncReturnObj return to engine(status of add, replace, delete command that client sent to server)*/
+} sync_return_obj_s;
+
+typedef struct {
+ service_type_e service_type;
+ int enabled;
+ char *src_uri;
+ char *tgt_uri;
+ char *id;
+ char *password;
+} sync_service_s;
+
+typedef struct {
+ char *name;
+ char *accept;
+ char *id;
+ char *password;
+ char *auth_type;
+ char *auth_data;
+} resource_cp_s;
+
+extern datastore_s *datastoreinfo_per_content_type[4];
+
+#endif /* COMMON_DEFINE_INTERNAL_H_ */
diff --git a/include/common/common_util.h b/include/common/common_util.h
new file mode 100755
index 0000000..ce10a90
--- /dev/null
+++ b/include/common/common_util.h
@@ -0,0 +1,187 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Util.h
+ * @version 0.1
+ * @brief This file is the header file of interface for utility function
+ */
+
+#ifndef COMMON_UTIL_H_
+#define COMMON_UTIL_H_
+
+#include <stdbool.h>
+
+/**
+ * @par Description: API to create sync_agent_da_config_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, key
+ * @param[in] string type, value(char *)
+ * @param[in] string type, type of value(string, int)
+ * @param[in] string type, name of access(SE, SA...)
+ * @param[out] sync_agent_da_config_s
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool create_config_str(int account_id, char *key, char *value, char *type, char *access_name, sync_agent_da_config_s ** config);
+
+/**
+ * @par Description: API to set value into config_tbl(key, value)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, key
+ * @param[in] string type, value(char *)
+ * @param[in] string type, type of value(string, int)
+ * @param[in] string type, name of access(SE, SA...)
+ * @param[out]
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_config_str(int account_id, char *key, char *value, char *type, char *access_name);
+
+/**
+ * @par Description: API to set value into config_tbl(key, value)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, key
+ * @param[in] int type, value(int)
+ * @param[in] string type, type of value(string, int)
+ * @param[in] string type, name of access(SE, SA...)
+ * @param[out]
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_config_int(int account_id, char *key, int value, char *type, char *access_name);
+
+/**
+ * @par Description: API to get value from config_tbl(key, value)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, key
+ * @param[out] string type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_config(int account_id, char *key, char **value);
+
+/**
+ * @par Description: API to get account ID from profileDirName(Sync1...)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profileDirName(Sync1, Sync2...)
+ * @param[in] boolean type, already open agent db or not
+ * @param[out]
+ *
+ * @return account ID (more than 1) on success
+ * -1 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_account_id(char *profile, bool open);
+
+/**
+ * @brief convert sync type(UI-> Engine)
+ * @param[in] sync type(Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone)
+ * @return char *
+ * @retval value of sync type Success
+ * NULL Error
+ */
+/*int convert_synctype_value(char *syncType_str);*/
+/*char *convert_synctype_str(char *syncType_value);*/
+#endif /* COMMON_UTIL_H_ */
diff --git a/include/common/common_vconf.h b/include/common/common_vconf.h
new file mode 100755
index 0000000..19cbcd7
--- /dev/null
+++ b/include/common/common_vconf.h
@@ -0,0 +1,249 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Vconf.h
+ * @version 0.1
+ * @brief This file is the header file of defined vconf value
+ */
+
+#ifndef COMMON_VCONF_H_
+#define COMMON_VCONF_H_
+
+#include <stdbool.h>
+
+/**
+ * @par Description: API to get value(char*) from vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, base key
+ * @param[in] string type, key
+ * @param[out]
+ *
+ * @return value on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_vconf_str(char *base_key, char *key);
+
+/**
+ * @par Description: API to get value(char*) from vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, key
+ * @param[out]
+ *
+ * @return value on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_vconf_str_key(char *key);
+
+/**
+ * @par Description: API to get value(int) from vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, base key
+ * @param[in] string type, key
+ * @param[out] int type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_vconf_int(char *base_key, char *key, int *value);
+
+/**
+ * @par Description: API to get value(int) from vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, key
+ * @param[out] int type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_vconf_int_key(char *key, int *value);
+
+/**
+ * @par Description: API to set value(char*) into vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, basekey
+ * @param[in] string type, key
+ * @param[in] string type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_vconf_str(char *base_key, char *key, char *value);
+
+/**
+ * @par Description: API to set value(char*) into vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, key
+ * @param[in] string type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_vconf_str_key(char *key, char *value);
+
+/**
+ * @par Description: API to set value(int) into vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, basekey
+ * @param[in] string type, key
+ * @param[in] int type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_vconf_int(char *base_key, char *key, int value);
+
+/**
+ * @par Description: API to set value(int) into vconf
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, key
+ * @param[in] int type, value
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool set_vconf_int_key(char *key, int value);
+
+#endif /* COMMON_VCONF_H_ */
diff --git a/include/common/csc_keys.h b/include/common/csc_keys.h
new file mode 100755
index 0000000..d34c3a3
--- /dev/null
+++ b/include/common/csc_keys.h
@@ -0,0 +1,50 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @CscKeys.h
+ * @version 0.1
+ * @brief This file is the header file of define for CSC keys
+ */
+
+#ifndef CSCKEYS_H_
+#define CSCKEYS_H_
+
+/* SyncML DS */
+#define CSC_VCONF_KEY_SYNCMLDS_NBDATASYNC "db/SyncML/oma-ds-agent/DS/Accounts/NbDataSync"
+#define CSC_VCONF_KEY_SYNCMLDS_NETWORK "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/NetworkName"
+#define CSC_VCONF_KEY_SYNCMLDS_VERSION "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/DSVersion"
+#define CSC_VCONF_KEY_SYNCMLDS_NAME "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Name"
+#define CSC_VCONF_KEY_SYNCMLDS_ADDR "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/AppAddr/Addr"
+#define CSC_VCONF_KEY_SYNCMLDS_AUTHNAME "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/AuthInfo/Client/AuthName"
+#define CSC_VCONF_KEY_SYNCMLDS_AUTHPWD "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/AuthInfo/Client/AuthPWD"
+#define CSC_VCONF_KEY_SYNCMLDS_SYNCTYPE "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/GUI/SyncType"
+#define CSC_VCONF_KEY_SYNCMLDS_SYNCMODE "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/GUI/SyncMode"
+#define CSC_VCONF_KEY_SYNCMLDS_CONTACTS_ENABLED "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Contacts/Enabled"
+#define CSC_VCONF_KEY_SYNCMLDS_CONTACTS_TGTURI "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Contacts/TgtURI"
+#define CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHNAME "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Contacts/AuthInfo/Server/AuthName"
+#define CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHPWD "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Contacts/AuthInfo/Server/AuthPWD"
+#define CSC_VCONF_KEY_SYNCMLDS_CALENDAR_ENABLED "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Calendar/Enabled"
+#define CSC_VCONF_KEY_SYNCMLDS_CALENDAR_TGTURI "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Calendar/TgtURI"
+#define CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHNAME "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Calendar/AuthInfo/Server/AuthName"
+#define CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHPWD "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Calendar/AuthInfo/Server/AuthPWD"
+#define CSC_VCONF_KEY_SYNCMLDS_MEMO_ENABLED "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Memo/Enabled"
+#define CSC_VCONF_KEY_SYNCMLDS_MEMO_TGTURI "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Memo/TgtURI"
+#define CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHNAME "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Memo/AuthInfo/Server/AuthName"
+#define CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHPWD "db/SyncML/oma-ds-agent/DS/Accounts/Sync%d/Resource/Memo/AuthInfo/Server/AuthPWD"
+
+#endif /* CSCKEYS_H_ */
diff --git a/include/framework/event/oma_ds_event_handler.h b/include/framework/event/oma_ds_event_handler.h
new file mode 100755
index 0000000..27bf66b
--- /dev/null
+++ b/include/framework/event/oma_ds_event_handler.h
@@ -0,0 +1,354 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Event_Handler.h
+ * @version 0.1
+ * @brief This file is the header file of interface for event callback function(from UI)
+ */
+
+#ifndef OMA_DS_EVENT_HANDLER_H_
+#define OMA_DS_EVENT_HANDLER_H_
+
+#include <stdio.h>
+#include <sync_agent.h>
+
+/**
+ * @par Description: This API is event callback function for add profile
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_add_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for edit profile
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_edit_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for delete profile
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_delete_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for request sync
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_request_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for cancel sync
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_cancel_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for get profile data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_get_profile_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for getting profile sync category
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_get_profile_sync_category_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for last statistics
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_get_profile_last_statistics_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for add profile for CP
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_add_profile_cp_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for request callog sync
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_request_calllog_sync_async(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for request reset all data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_request_reset_all_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+/**
+ * @par Description: This API is event callback function for request reset all data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] buffer for incomming parameter
+ * @param[in] buffer for outgoing parameter
+ * @param[out]
+ *
+ * @return 0 on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int event_callback_request_get_all_profiles_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+#endif /* OMA_DS_EVENT_HANDLER_H_ */
diff --git a/include/framework/event/oma_ds_platform_event_handler.h b/include/framework/event/oma_ds_platform_event_handler.h
new file mode 100755
index 0000000..4305e43
--- /dev/null
+++ b/include/framework/event/oma_ds_platform_event_handler.h
@@ -0,0 +1,114 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Platform_Event_Handler.h
+ * @version 0.1
+ * @brief This file is the header file of interface for event callback function(platform monitor)
+ */
+
+#ifndef OMA_DS_PLATFORM_EVENT_HANDLER_H_
+#define OMA_DS_PLATFORM_EVENT_HANDLER_H_
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+/**
+ * @par Description: API to parse callback function for SAN
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, msg body
+ * @param[in] unsigned int type, size of msg
+ * @param[in] int type, version
+ * @param[out]
+ *
+ * @return 1 on success
+ * 0 on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int san_callback_parse(int item_id, void *user_data);
+
+/**
+ * @par Description: This API is callback function for scheduler
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] scheduler Id
+ * @param[in] user data
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void send_periodic_sync_msg(int scheduler_id, void *data);
+
+/**
+ * @par Description: This API is for receive ip push msg from event
+ *
+ * Parse ip push msg and request sync
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] data(ip push message)
+ *
+ * @return 1 on success
+ * 0 on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int send_ip_push_sync_msg(char *data);
+
+#endif /* OMA_DS_PLATFORM_EVENT_HANDLER_H_ */
diff --git a/include/framework/san-parser/pm_sanparser.h b/include/framework/san-parser/pm_sanparser.h
new file mode 100755
index 0000000..47b5bf5
--- /dev/null
+++ b/include/framework/san-parser/pm_sanparser.h
@@ -0,0 +1,224 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @PM_SanParser.h
+ * @version 0.1
+ * @brief This file is the header file of interface and defined structure for San Parser
+ */
+
+#ifndef PM_SANPARSER_H_
+#define PM_SANPARSER_H_
+
+/* FIXME : When initialize, set "Server_id" at config_tbl..
+#define SMLDS_MOBILEDIT_SERVER (char *)"mobiledit"
+#define SMLDS_FUNAMBOL_SERVER (char *)"funambol"
+#define SMLDS_O3SIS_SERVER_SAN_IDENTIFIER (char *)"O3SIS SyncML Server"
+*/
+
+typedef enum {
+ SAN_UIMODE_UNSPECIFIED = 0,
+ SAN_UIMODE_BACKGROUND = 1,
+ SAN_UIMODE_INFORMATIVE = 2,
+ SAN_UIMODE_USER = 3
+} san_ui_mode_e;
+
+typedef enum {
+ SAN_INITIATOR_USER = 0,
+ SAN_INITIATOR_SERVER = 1
+} san_initiator_e;
+
+typedef enum {
+ SAN_SYNC_TYPE_TWO_WAY_BY_SERVER = 206,
+ SAN_SYNC_TYPE_ONE_WAY_FROM_CLIENT_BY_SERVER = 207,
+ SAN_SYNC_TYPE_REFRESH_FROM_CLIENT_BY_SERVER = 208,
+ SAN_SYNC_TYPE_ONE_WAY_FROM_SERVER_BY_SERVER = 209,
+ SAN_SYNC_TYPE_REFRESH_FROM_SERVER_BY_SERVER = 210,
+} san_sync_type_e;
+
+typedef struct san_cred san_cred_s;
+struct san_cred {
+ char *cred_format;
+ char *cred_auth;
+ char *cred_data;
+};
+
+typedef struct san_content_type san_content_type_s;
+struct san_content_type {
+ unsigned int type;
+ char *strType;
+};
+
+typedef struct san_sync_alert san_sync_alert_s;
+struct san_sync_alert {
+ san_sync_type_e sync_type;
+ char *content_type;
+ char *server_uri;
+};
+
+typedef struct san_package san_package_s;
+struct san_package {
+ char *msg_body_without_digest;
+ unsigned int msg_body_without_digest_length;
+ char *digest;
+ unsigned int version;
+ san_ui_mode_e ui_mode;
+ san_initiator_e initiator;
+ unsigned int session_id;
+ san_cred_s *cred;
+ char *server_id;
+ unsigned int cnt_sync_alerts;
+ san_sync_alert_s *sync_alerts;
+};
+
+/**
+ * @par Description: API to parse for SAN version 1.2
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, msg body
+ * @param[in] unsigned int type, size of msg
+ * @param[out]
+ *
+ * @return san_package_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+san_package_s *san_package_12_parser(const char *msg_body, unsigned int msg_size);
+
+/**
+ * @par Description: API to parse for SAN version 1.1
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, msg body
+ * @param[in] unsigned int type, size of msg
+ * @param[out]
+ *
+ * @return san_package_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size);
+
+/**
+ * @par Description: API to free san_package_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] san_package_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void sanPackageParserFree(void *point);
+
+/**
+ * @par Description: API to print SAN msg for debugging
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] san_package_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void sanPrintMsg(san_package_s * san);
+
+/**
+ * @par Description: API to parse ip push message
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] data(ip push message)
+ * @param[out] san_package_s structure
+ * @param[out] id
+ *
+ * @return 1 on success
+ * 0 on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int parse_ip_push_msg(char *data, san_package_s ** sanpackage, char **id);
+
+#endif /* PM_SANPARSER_H_ */
diff --git a/include/framework/task/oma_ds_engine_controller_task.h b/include/framework/task/oma_ds_engine_controller_task.h
new file mode 100755
index 0000000..f4b3ccc
--- /dev/null
+++ b/include/framework/task/oma_ds_engine_controller_task.h
@@ -0,0 +1,975 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Engine_Controller_Task.h
+ * @version 0.1
+ * @brief This file is the header file of registration function for using Engine Controller
+ */
+
+#ifndef ENGINE_CONTROLLER_TASK_H_
+#define ENGINE_CONTROLLER_TASK_H_
+
+#include <stdio.h>
+#include <sync_agent.h>
+
+#define SYNC_MODE_MANUAL 0
+#define SYNC_MODE_PERIODIC 1
+#define SYNC_MODE_SAN 2
+#define SYNC_MODE_AUTOCONFIG 3
+
+typedef struct request_msg_info_s request_msg_info_t;
+struct request_msg_info_s {
+ int sync_type;
+ unsigned int request_id;
+};
+
+#define EC_MSG_TYPE_SYNC_TASK_REQUEST 1
+#define EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST "sync_request"
+#define EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE 2
+#define EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE "add_profile"
+#define EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE 3
+#define EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_PROFILE "edit_profile"
+#define EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE 4
+#define EC_MSG_TYPE_NAME_SYNC_TASK_DELETE_PROFILE "delete_profile"
+#define EC_MSG_TYPE_SAN_TASK_REQUEST 5
+#define EC_MSG_TYPE_NAME_SAN_TASK_REQUEST "SAN_request"
+#define EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_DATA 6
+#define EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_DATA "get_profile_data"
+#define EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY 7
+#define EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY "get_profile_sync_category"
+#define EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS 8
+#define EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_STATISTICS "get_profile_statistics"
+#define EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES 9
+#define EC_MSG_TYPE_NAME_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES "reset_synchronizing_profiles"
+#define EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST 10
+#define EC_MSG_TYPE_NAME_SYNC_TASK_CANCEL_SYNC_REQUEST "cancel_sync_request"
+#define EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP 11
+#define EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE_CP "add_profile_cp"
+#define EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE 12
+#define EC_MSG_TYPE_NAME_SYNC_TASK_REFRESH_FROM_SERVICE "refresh_from_service"
+#define EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA 13
+#define EC_MSG_TYPE_NAME_SYNC_TASK_RESET_ALL_DATA "reset_all_data"
+#define EC_MSG_TYPE_SYNC_TASK_GET_ALL_PROFILES_DATA 14
+#define EC_MSG_TYPE_NAME_SYNC_TASK_GET_ALL_PROFILES_DATA "get_all_profiles_data"
+
+/**
+ * @par Description: API to create synchronize task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_synchronize_task();
+
+/**
+ * @par Description: API to create synchronize task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_add_profile_task();
+
+/**
+ * @par Description: API to create edit profile task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_edit_profile_task();
+
+/**
+ * @par Description: API to create delete profiles task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_delete_profile_task();
+
+/**
+ * @par Description: API to create get profile data task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_get_profile_data_task();
+
+/**
+ * @par Description: API to create get profile sync category task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_get_profile_sync_category_task();
+
+/**
+ * @par Description: API to create get profile last statistics task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_get_profile_statistics_task();
+
+/**
+ * @par Description: API to create reset synchronizing profiles task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_reset_synchronizing_profiles_task();
+
+/**
+ * @par Description: API to create reset synchronizing profiles task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_add_profile_cp_task();
+
+/**
+ * @par Description: API to create reset refresh_from_service task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_refresh_from_service_task();
+
+/**
+ * @par Description: API to create cancel network session task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_cancel_request_task();
+
+/**
+ * @par Description: API to reset all data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_reset_all_data_task();
+
+/**
+ * @par Description: API to get all profiles data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return sync_agent_ec_task_spec_s structure on success
+ * NYLL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_get_all_profiles_data_task();
+/**
+ * @par Description: This API is callback function which runs when synchronize task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e synchronize_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when add profile task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when edit profile task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when delete profiles task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when get profile name task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when get profile sync category task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when get profile last statistics task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when reset synchronizing profiles task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e reset_synchronizing_profiles_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when cancel is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e cancel_sync_request_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when reset function is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e reset_all_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when reset function is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when add profile for cp task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: This API is callback function which runs when refresh_from_service task is requested
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, parameter count
+ * @param[in] array of parameters
+ * @param[out]
+ *
+ * @return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS on success
+ * SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_error_e refresh_from_service_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+/**
+ * @par Description: API to insert request_msg_info_t structure into list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_type(SYNC_MODE_MANUAL, SYNC_MODE_PERIODIC, SYNC_MODE_SAN, SYNC_MODE_AUTOCONFIG)
+ * @param[in] request id
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void insert_request_msg_info(int sync_type, unsigned int request_id);
+
+/**
+ * @par Description: API to delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] request id
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void delete_request_msg_info(unsigned int request_id);
+
+/**
+ * @par Description: API to get synchronizing request id and delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] request id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_synchronizing_request_id(unsigned int *request_id);
+
+/**
+ * @par Description: API to get manual sync request id and delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] request id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_manual_sync_request_id(unsigned int *request_id);
+
+/**
+ * @par Description: API to get periodic sync request id and delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] request id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_periodic_sync_request_id(unsigned int *request_id);
+
+/**
+ * @par Description: API to get SAN sync request id and delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] request id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_san_sync_request_id(unsigned int *request_id);
+
+/**
+ * @par Description: API to get auto configure sync request id and delete request_msg_info_t structure from list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] request id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_auto_configure_request_id(unsigned int *request_id);
+
+/**
+ * @par Description: cancel current sync task(auto configure task or sync task)
+ *
+ * if auto configure task is processing, cancel auto configure task
+ * if sync task is processing, cancel sync task
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool cancel_current_sync_task();
+
+#endif /* ENGINE_CONTROLLER_TASK_H_ */
diff --git a/include/service-adapter/network-binder/na_binder.h b/include/service-adapter/network-binder/na_binder.h
new file mode 100755
index 0000000..a229bd2
--- /dev/null
+++ b/include/service-adapter/network-binder/na_binder.h
@@ -0,0 +1,85 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @NA_Binder.h
+ * @version 0.1
+ * @brief This file is the header file of interface of NA Binder
+ */
+
+#ifndef NA_BINDER_H_
+#define NA_BINDER_H_
+
+#include <sync_agent.h>
+#include "service-adapter/sa_define.h"
+
+/**
+ * @par Description: API to header binding for HTTP protocol
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, access type(http, obex...)
+ * @param[in] string type, target uri
+ * @param[in] boolean type, xml or wbxml
+ * @param[out] GList type, list of header info
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int na_http_header_binder(char *acc_type, char *loc_uri, bool is_xml, char *jsession_id, GList ** list);
+
+/**
+ * @par Description: API to free sync_agent_na_common_header_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_na_common_header_info_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_header_info(sync_agent_na_common_header_info_s * common_header_info);
+
+#endif /* NA_BINDER_H_ */
diff --git a/include/service-adapter/protocol-binder/oma_ds_protocol_binder.h b/include/service-adapter/protocol-binder/oma_ds_protocol_binder.h
new file mode 100755
index 0000000..ab25ad2
--- /dev/null
+++ b/include/service-adapter/protocol-binder/oma_ds_protocol_binder.h
@@ -0,0 +1,314 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @oma_ds_protocol_binder.h
+ * @version 0.1
+ * @brief This file is the header file of interface of protocol binder
+ */
+
+#ifndef OMA_DS_PROTOCOL_BINDER_H_
+#define OMA_DS_PROTOCOL_BINDER_H_
+
+#include <sync_agent.h>
+#include "service-adapter/protocol-binder/oma_ds_protocol_binder_definition.h"
+
+/**
+ * @par Description: API to Initialize protocol binder function set
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_function_set_s structure
+ * @param[out]
+ *
+ * @return sync_agent_pb_error_e type
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e init_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s ** binder_function_set);
+
+/**
+ * @par Description: API to free sync_agent_pb_protocol_binder_function_set_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_function_set_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_oma_ds_1_2_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * binder_function_set);
+
+/**
+ * @par Description: API to Initialize protocol binder
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[in] enum type, sync_agent_pb_encoding_e(SYNC_AGENT_PB_ENCODING_XML, SYNC_AGENT_PB_ENCODING_WBXML_10, SYNC_AGENT_PB_ENCODING_WBXML_11, SYNC_AGENT_PB_ENCODING_WBXML_12, SYNC_AGENT_PB_ENCODING_WBXML_13)
+ * @param[in] boolean type, whether encode xml header or not
+ * @param[in] boolean type, whether use string table or not
+ * @param[in] boolean type, whether protocol is anonymous or not
+ * @param[in] boolean type, whether use flow mode or not
+ * @param[in] boolean type, whether use textual public id or not
+ * @param[in] sync_agent_pb_protocol_binder_function_set_s structure
+ * @param[out]
+ *
+ * @return sync_agent_pb_protocol_binder_info_s on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_protocol_binder_info_s *oma_ds_1_2_binder_init(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e enc, bool encode_xml_header,
+ bool use_strtbl, bool produce_anonymous, bool use_flow_mode, bool text_public_id, sync_agent_pb_protocol_binder_function_set_s * binder_function_set);
+
+/**
+ * @par Description: API to append specific element to WBXML tree
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[in] enum type, protocol element
+ * @param[in] content(structure to append)
+ * @param[out]
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e oma_ds_1_2_binder_append(sync_agent_pb_protocol_binder_info_s * binder, oma_ds_protocol_element_e protocol_element, Content_Ptr content);
+
+/**
+ * @par Description: API to terminate sync_agent_pb_protocol_binder_info_s structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void oma_ds_1_2_binder_terminate(sync_agent_pb_protocol_binder_info_s * binder);
+
+/**
+ * @par Description: API to get stream
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[out] string type, stream from WBXML tree
+ * @param[out] unsigned int type, size of stream
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e oma_ds_1_2_binder_get_stream(sync_agent_pb_protocol_binder_info_s * binder, char **byte_stream, unsigned int *byte_stream_size);
+
+/**
+ * @par Description: API to get stream size
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[out] unsigned int type, size of stream
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e oma_ds_1_2_binder_get_stream_size(sync_agent_pb_protocol_binder_info_s * binder, unsigned int *byte_stream_size);
+
+/**
+ * @par Description: API to get encoding type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_info_s structure
+ * @param[out] enum type, sync_agent_pb_encoding_e(SYNC_AGENT_PB_ENCODING_XML, SYNC_AGENT_PB_ENCODING_WBXML_10, SYNC_AGENT_PB_ENCODING_WBXML_11, SYNC_AGENT_PB_ENCODING_WBXML_12, SYNC_AGENT_PB_ENCODING_WBXML_13)
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e oma_ds_1_2_binder_get_encoding(sync_agent_pb_protocol_binder_info_s * binder, sync_agent_pb_encoding_e * enc);
+
+/**
+ * @par Description: API to Initialize reverse protocol binder
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, WBXML stream to parse
+ * @param[in] unsigned int type, size of stream
+ * @param[in] enum type, decoding(SYNC_AGENT_PB_DECODING_XML, SYNC_AGENT_PB_DECODING_WBXML)
+ * @param[in] user data
+ * @param[out] sync_agent_pb_protocol_binder_reverse_info_s structure
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e reverse_oma_ds_1_2_binder_init(char *byte_stream,
+ unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_binder_function_set_s * binder_function_set, void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** binder);
+
+/**
+ * @par Description: API to parse and get next contents
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_agent_pb_protocol_binder_reverse_info_s structure
+ * @param[out] protocol element
+ * @param[out] string type, protocol element
+ * @param[out] parsed contents(defined structure)
+ *
+ * @return SYNC_AGENT_PB_RETURN_OK on success
+ * others on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_pb_error_e reverse_oma_ds_1_2_binder_next(sync_agent_pb_protocol_binder_reverse_info_s * binder, Protocol_Element * protocol_element, char **protocol_element_name, Content_Ptr * content);
+
+#endif /* OMA_DS_PROTOCOL_BINDER_H_ */
diff --git a/include/service-adapter/protocol-binder/oma_ds_protocol_binder_definition.h b/include/service-adapter/protocol-binder/oma_ds_protocol_binder_definition.h
new file mode 100755
index 0000000..a74bde5
--- /dev/null
+++ b/include/service-adapter/protocol-binder/oma_ds_protocol_binder_definition.h
@@ -0,0 +1,188 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @oma_ds_protocol_binder_definition.h
+ * @version 0.1
+ * @brief This file is the header file for protocol binder definition
+ */
+
+#ifndef OMA_DS_PROTOCOL_BINDER_DEFINITION_H_
+#define OMA_DS_PROTOCOL_BINDER_DEFINITION_H_
+
+#define SYNC_AGENT_INIT_ESTIMATE_DOC_SIZE 20
+
+/* SyncML */
+#define ELEMENT_SYNCML "SyncML"
+
+/* SyncHdr */
+#define ELEMENT_SYNCHDR "SyncHdr"
+#define ELEMENT_VERDTD "VerDTD"
+#define ELEMENT_VERDRD_10 "1.0"
+#define ELEMENT_VERDRD_11 "1.1"
+#define ELEMENT_VERDRD_12 "1.2"
+#define ELEMENT_VERPROTO "VerProto"
+#define ELEMENT_VERPROTO_10 "SyncML/1.0"
+#define ELEMENT_VERPROTO_11 "SyncML/1.1"
+#define ELEMENT_VERPROTO_12 "SyncML/1.2"
+#define ELEMENT_SESSIONID "SessionID"
+#define ELEMENT_MSGID "MsgID"
+#define ELEMENT_RESPURI "RespURI"
+#define ELEMENT_NORESP "NoResp"
+#define ELEMENT_CRED "Cred"
+
+/* SyncBody */
+#define ELEMENT_SYNCBODY "SyncBody"
+#define ELEMENT_CMD "Cmd"
+#define ELEMENT_ADD "Add"
+#define ELEMENT_REPLACE "Replace"
+#define ELEMENT_ALERT "Alert"
+#define ELEMENT_SYNC "Sync"
+#define ELEMENT_PUT "Put"
+#define ELEMENT_REPLACE "Replace"
+#define ELEMENT_DELETE "Delete"
+#define ELEMENT_MAP "Map"
+#define ELEMENT_GET "Get"
+#define ELEMENT_RESULTS "Results"
+#define ELEMENT_STATUS "Status"
+#define ELEMENT_CMDID "CmdID"
+#define ELEMENT_ITEM "Item"
+#define ELEMENT_NUMBEROFCHANGES "NumberOfChanges"
+#define ELEMENT_MSGREF "MsgRef"
+#define ELEMENT_CMDREF "CmdRef"
+#define ELEMENT_TARGETREF "TargetRef"
+#define ELEMENT_SOURCEREF "SourceRef"
+#define ELEMENT_MAPITEM "MapItem"
+#define ELEMENT_MOREDATA "MoreData"
+#define ELEMENT_TARGET "Target"
+#define ELEMENT_SOURCE "Source"
+#define ELEMENT_LOCURI "LocURI"
+#define ELEMENT_LOCNAME "LocName"
+#define ELEMENT_CHAL "Chal"
+#define ELEMENT_B64 "b64"
+#define ELEMENT_DATA "Data"
+
+/* DevInf */
+#define ELEMENT_DEVINF "DevInf"
+#define ELEMENT_MAN "Man"
+#define ELEMENT_MOD "Mod"
+#define ELEMENT_OEM "OEM"
+#define ELEMENT_FWV "FwV"
+#define ELEMENT_SWV "SwV"
+#define ELEMENT_HWV "HwV"
+#define ELEMENT_DEVID "DevID"
+#define ELEMENT_DEVTYP "DevTyp"
+#define ELEMENT_PAGER "Pager"
+#define ELEMENT_HANDHELD "handheld"
+#define ELEMENT_PDA "pda"
+#define ELEMENT_PHONE "phone"
+#define ELEMENT_SMARTPHONE "smartphone"
+#define ELEMENT_SERVER "server"
+#define ELEMENT_WORKSTATION "workstation"
+#define ELEMENT_UTC "UTC"
+#define ELEMENT_SUPPORTLARGEOBJS "SupportLargeObjs"
+#define ELEMENT_SUPPORTNUMBEROFCHANGES "SupportNumberOfChanges"
+#define ELEMENT_DATASTORE "DataStore"
+#define ELEMENT_DISPLAYNAME "DisplayName"
+#define ELEMENT_MAXGUIDSIZE "MaxGUIDSize"
+#define ELEMENT_RX_PREF "Rx-Pref"
+#define ELEMENT_RX "Rx"
+#define ELEMENT_TX_PREF "Tx-Pref"
+#define ELEMENT_TX "Tx"
+#define ELEMENT_CTCAP "CTCap"
+#define ELEMENT_CTTYPE "CTType"
+#define ELEMENT_VERCT "VerCT"
+#define ELEMENT_FIELDLEVEL "FieldLevel"
+#define ELEMENT_PROPERTY "Property"
+#define ELEMENT_PROPNAME "PropName"
+#define ELEMENT_DATATYPE "DataType"
+#define ELEMENT_MAXOCCUR "MaxOccur"
+#define ELEMENT_MAXSIZE "MaxSize"
+#define ELEMENT_NOTRUNCATE "NoTruncate"
+#define ELEMENT_VALENUM "ValEnum"
+#define ELEMENT_DISPLAYNAME "DisplayName"
+#define ELEMENT_PROPPARAM "PropParam"
+#define ELEMENT_PARAMNAME "ParamName"
+#define ELEMENT_DSMEM "DSMem"
+#define ELEMENT_SHAREDMEM "SharedMem"
+#define ELEMENT_MAXMEM "MaxMem"
+#define ELEMENT_MAXID "MaxID"
+#define ELEMENT_SUPPORTHIERARCHICALSYNC "SupportHierarchicalSync"
+#define ELEMENT_SYNCCAP "SyncCap"
+#define ELEMENT_SYNCTYPE "SyncType"
+#define ELEMENT_SYNCTYPE_1 "1"
+#define ELEMENT_SYNCTYPE_2 "2"
+#define ELEMENT_SYNCTYPE_3 "3"
+#define ELEMENT_SYNCTYPE_4 "4"
+#define ELEMENT_SYNCTYPE_5 "5"
+#define ELEMENT_SYNCTYPE_6 "6"
+#define ELEMENT_SYNCTYPE_7 "7"
+#define ELEMENT_FILTER_RX "Filter-Rx"
+#define ELEMENT_FILTERCAP "FilterCap"
+
+/* MetInf */
+#define ELEMENT_META "Meta"
+#define ELEMENT_FORMAT "Format"
+#define ELEMENT_NEXTNONCE "NextNonce"
+#define ELEMENT_TYPE "Type"
+#define ELEMENT_SIZE "Size"
+#define ELEMENT_MAXMSGSIZE "MaxMsgSize"
+#define ELEMENT_MAXOBJSIZE "MaxObjSize"
+#define ELEMENT_ANCHOR "Anchor"
+#define ELEMENT_LAST "Last"
+#define ELEMENT_NEXT "Next"
+#define ELEMENT_MEM "Mem"
+#define ELEMENT_SHAREDMEM "SharedMem"
+#define ELEMENT_FREEMEM "FreeMem"
+#define ELEMENT_FREEID "FreeID"
+
+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
+} oma_ds_protocol_element_e;
+
+#endif /* OMA_DS_PROTOCOL_BINDER_DEFINITION_H_ */
diff --git a/include/service-adapter/sa_command.h b/include/service-adapter/sa_command.h
new file mode 100755
index 0000000..7ded49f
--- /dev/null
+++ b/include/service-adapter/sa_command.h
@@ -0,0 +1,866 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Commandl.h
+ * @version 0.1
+ * @brief This file is the header file of interface of Command structure
+ */
+
+#ifndef SA_COMMAND_H_
+#define SA_COMMAND_H_
+
+#include "service-adapter/sa_define.h"
+#include "common/common_define.h"
+
+/**
+ * @par Description: API to create alert command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] enum type, sync type
+ * @param[in] location_s structure(about source info)
+ * @param[in] location_s structure(about target info)
+ * @param[in] string type, last anchor
+ * @param[in] string type, next anchor
+ * @param[in] Cred structure
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_alert_command(session_s * session, alert_type_e sync_type, location_s * source, location_s * target, char *last_anchor, char *next_anchor, cred_s * cred, command_s ** command);
+
+/**
+ * @par Description: API to create get command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] location_s structure(about target info)
+ * @param[in] string type, content type
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_get_command(session_s * session, location_s * target, const char *content_type, command_s ** command);
+
+/**
+ * @par Description: API to create put command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] location_s structure(about source info)
+ * @param[in] string type, content type
+ * @param[in] DevInf structure
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_put_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
+
+/**
+ * @par Description: API to create results command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] location_s structure(about source info)
+ * @param[in] string type, content type
+ * @param[in] DevInf structure
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_results_command(session_s * session, location_s * source, const char *content_type, devinf_s * devinf, command_s ** command);
+
+/**
+ * @par Description: API to create sync start command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] location_s structure(about source info)
+ * @param[in] location_s structure(about target info)
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_sync_start_command(session_s * session, location_s * source, location_s * target, command_s ** command);
+
+/**
+ * @par Description: API to create sync end command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_sync_end_command(command_s ** command);
+
+/**
+ * @par Description: API to create add command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] enum type, change type
+ * @param[in] string type, luid of item
+ * @param[in] string type, content type
+ * @param[in] string type, data(vobject)
+ * @param[in] unsigned int type, size of data
+ * @param[in] int type, moreData(LargeObj)
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_add_command(session_s * session, change_type_e type, char *luid, const char *content_type, char *data, unsigned int size, int more_data, command_s ** command);
+
+/**
+ * @par Description: API to create replace command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] enum type, change type
+ * @param[in] string type, luid of item
+ * @param[in] string type, content type
+ * @param[in] string type, data(vobject)
+ * @param[in] unsigned int type, size of data
+ * @param[in] int type, more_data(LargeObj)
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_replace_command(session_s * session, change_type_e type, char *luid, const char *content_type, const char *data, unsigned int size, int more_data, command_s ** command);
+
+/**
+ * @par Description: API to create delete command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] enum type, change type
+ * @param[in] string type, luid of item
+ * @param[in] string type, content type
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_delete_command(session_s * session, change_type_e type, char *luid, const char *content_type, command_s ** command);
+
+/**
+ * @par Description: API to create map command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] location_s structure(about source info)
+ * @param[in] location_s structure(about target info)
+ * @param[out] command_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_map_command(session_s * session, location_s * source, location_s * target, command_s ** command);
+
+/**
+ * @par Description: API to free list of command structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of command structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_commands(GList * commands);
+
+/**
+ * @par Description: API to free command structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_command(command_s * command);
+
+/**
+ * @par Description: API to increase reference count of command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e increase_command_ref_count(command_s * command);
+
+/**
+ * @par Description: API to decrease reference count of command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e decrease_command_ref_count(command_s * command);
+
+/**
+ * @par Description: API to set msgRef in results command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Commnad structure
+ * @param[in] unsigned int type, msg reference
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_results_command_msg_ref(command_s * command, unsigned int msg_ref);
+
+/**
+ * @par Description: API to set cmdRef in results command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Commnad structure
+ * @param[in] unsigned int, cmd reference
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_results_command_cmd_ref(command_s * command, unsigned int cmd_ref);
+
+/**
+ * @par Description: API to set targetRef in results command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[in] location_s structure(target info)
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_results_command_target_ref(command_s * command, location_s * location);
+
+/**
+ * @par Description: API to set number_of_changes in sync start command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[in] unsigned int type, number of changes
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_sync_start_command_number_of_changes(command_s * command, unsigned int number_of_changes);
+
+/**
+ * @par Description: API to set Mem structure in sync start command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[in] mem_s structure
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_sync_start_command_mem(command_s * command, mem_s * mem);
+
+/**
+ * @par Description: API to set item in map command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command_s structure
+ * @param[in] item_s structure
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_map_command_item(command_s * mapCommand, item_s * temp);
+
+/**
+ * @par Description: API to create status command with locatiion structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] data (status code)
+ * @param[in] command_s structure
+ * @param[in] location_s structure(about source info)
+ * @param[in] location_s structure(about target info)
+ * @param[in] command type
+ * @param[out] status_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_new_status_location(session_s * session, oma_status_type_e data, command_s * command, location_s * source_ref, location_s * target_ref, command_type_e type, status_s ** status);
+
+/**
+ * @par Description: API to create create status command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] enum type, data (status code)
+ * @param[in] command_s structure
+ * @param[in] enum type, command type
+ * @param[out] status_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_new_status(session_s * session, oma_status_type_e data, command_s * command, command_type_e type, status_s ** status);
+
+/**
+ * @par Description: API to create status command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, data (status code)
+ * @param[in] unsigned int type, cmd ID
+ * @param[in] unsigned int type, cmd reference
+ * @param[in] unsigned int type, msg reference
+ * @param[in] location_s structure(about source info)
+ * @param[in] location_s structure(about target info)
+ * @param[in] enum type, command type
+ * @param[out] status_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_status(oma_status_type_e data, unsigned int cmd_id, unsigned int cmd_ref, unsigned int msg_ref, location_s * source_ref, location_s * target_ref, command_type_e type, status_s ** status);
+
+/**
+ * @par Description: API to free list of Status structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] list of Status structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_statuses(GList * status);
+
+/**
+ * @par Description: API to free Status structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Status structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_status(status_s * status);
+
+/**
+ * @par Description: API to get status code from Status structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Status structure
+ * @param[out]
+ *
+ * @return OMA_StatusType type
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+oma_status_type_e get_status_code(status_s * status);
+
+/**
+ * @par Description: API to convert to command type from char*
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] char* (Alert, Sync, Put, SyncHdr, Add, Replace, Map, Delete, Results, Get)
+ * @param[out]
+ *
+ * @return command_type_e type
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+command_type_e convert_command_type(char *type);
+
+/**
+ * @par Description: API to convert to change type from command type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, command_type_e
+ * @param[out]
+ *
+ * @return change_type_e type
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+change_type_e convert_change_type_command_type(command_type_e type);
+
+/**
+ * @par Description: API to convert to command type from change type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, change_type_e
+ * @param[out]
+ *
+ * @return command_type_e type
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+command_type_e convert_command_type_change_type(change_type_e type);
+
+/* unused function
+ * keep for in case
+ */
+/*
+ChangeType convertToChangeType(unsigned int type);
+char *convertFromCommandType(CommandType type);
+*/
+
+#endif /* SA_COMMAND_H_ */
diff --git a/include/service-adapter/sa_command_internal.h b/include/service-adapter/sa_command_internal.h
new file mode 100755
index 0000000..707d2e9
--- /dev/null
+++ b/include/service-adapter/sa_command_internal.h
@@ -0,0 +1,102 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Command_Internal.h
+ * @version 0.1
+ * @brief This file is the header file that structure which is available in SA is defined
+ * Command (Alert, Results, Sync, Put, Get, Map, Add, Replace, Delete)
+ * Status
+ */
+
+#ifndef SA_COMMAND_INTERNAL_H_
+#define SA_COMMAND_INTERNAL_H_
+
+#include "service-adapter/sa_define.h"
+#include "common/common_define.h"
+
+typedef struct {
+ alert_type_e type;
+ anchor_s *anchor;
+ char *content_type;
+ unsigned int max_obj_size;
+} command_alert_private_s;
+
+typedef struct {
+ unsigned int num_changed;
+ int max_obj_size;
+ int has_num_changed;
+ mem_s *mem;
+} command_sync_private_s;
+
+typedef struct {
+ char *type;
+ item_s *item;
+} command_access_private_s;
+
+typedef struct {
+ GList *items;
+ change_type_e type;
+} command_change_private_s;
+
+typedef struct {
+ GList *items;
+} command_map_private_s;
+
+typedef struct {
+ unsigned int msg_ref;
+ unsigned int cmd_ref;
+ location_s *target_ref;
+ char *type;
+ item_s *item;
+} command_results_private_s;
+
+typedef union {
+ command_alert_private_s alert;
+ command_sync_private_s sync;
+ command_access_private_s access; /*put or get */
+ command_change_private_s change;
+ command_map_private_s map;
+ command_results_private_s results;
+} command_private_u;
+
+struct command {
+ int ref_count;
+ command_type_e type;
+ unsigned int cmd_id;
+ unsigned int msg_id;
+ command_private_u private;
+ location_s *source;
+ location_s *target;
+ cred_s *cred;
+ int no_resp;
+};
+
+struct status {
+ unsigned int cmd_id;
+ unsigned int msg_ref;
+ unsigned int cmd_ref;
+ command_type_e type;
+ char *data;
+ location_s *source_ref;
+ location_s *target_ref;
+ cred_s *cred;
+ chal_s *chal;
+ item_s *item;
+};
+
+#endif /* SA_COMMAND_INTERNAL_H_ */
diff --git a/include/service-adapter/sa_common_interface.h b/include/service-adapter/sa_common_interface.h
new file mode 100755
index 0000000..56d95aa
--- /dev/null
+++ b/include/service-adapter/sa_common_interface.h
@@ -0,0 +1,285 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Common_Interface.h
+ * @version 0.1
+ * @brief This file is the header file of interface of SA
+ * called by SE
+ */
+
+#ifndef SA_COMMON_INTERFACE_H_
+#define SA_COMMON_INTERFACE_H_
+
+/**
+ * @par Description: API to process pre-action that has to be befor sync service
+ *
+ * Exchage Pkg1 and Pkg2 with server
+ * Get Device Information
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, transport Type(obex, FW_HTTP ...)
+ * @param[in] int type, account id
+ * @param[in] string type, session id
+ * @param[in] int type, whether server is fmm server for calllog or not
+ * @param[out] pre_sync_return_obj_s structure(result from pkg2)
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int pre_sync(int transport_type, int account_id, char *session_id, int server_flag, void **pre_sync_return_obj);
+
+/**
+ * @par Description: API to generate protocol specific msg
+ *
+ * Generate MSg which be considered maxMsgSize and maxObjSize
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_obj_s structure
+ * @param[in] int type, whether server is fmm server for calllog or not
+ * @param[out] msg
+ * @param[out] msg size
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int generate_msg(void **sync_obj, int server_flag, char **msg, unsigned int *msg_size);
+
+/**
+ * @par Description: API to exchange protocol specific msg with server
+ *
+ * Exchange protocol specific msg(request and response) using header binding information with server
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, transport protocol type(http, obex etc)
+ * @param[in] string type, msg to send
+ * @param[in] unsigned int type, msg size
+ * @param[out] string type, receive msg
+ * @param[out] unsigned int type, receive msg size
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int exchange_msg(int transport_type, char *send_msg, unsigned int send_msg_length, char **recv_msg, unsigned int *recv_msg_length);
+
+/**
+ * @par Description: API to process response msg from server
+ *
+ * Process response msg from server and convert to obj that return to Service Engine
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, recive msg from server
+ * @param[in] unsigned int type, receive msg size
+ * @param[in] int type, whether or not to end in pkg4
+ * @param[out] sync_return_obj_s structure
+ * @param[out] int type, flag for finsih sync session
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int process_recv_msg(char *recv_msg, unsigned int recv_msg_length, int only_from_client, void **sync_return_obj, int *is_finish);
+
+/**
+ * @par Description: API to free session_s structure and close connection
+ *
+ * This API for case that error or cancel occur in ServiceEngine so need to clean up resource which using in ServiceAdapter
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void clean_up_sa();
+
+/**
+ * @par Description: API to process auto configure function
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, server ip
+ * @param[in] string type, id
+ * @param[in] string type, password
+ * @param[out] GList type, list of auto configure results
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int auto_configure(char *addr, char *id, char *password, GList ** congifure);
+
+/**
+ * @par Description: API to check cancel status
+ *
+ * Cancel flag is set and if engine is going to process pkg 5 & 6
+ * keep going until finish sync session
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 means Do cancel
+ * 0 means Do not cancel
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int check_cancel_status();
+
+/**
+ * @par Description: API to suspend current sync session
+ *
+ * Send alert 224 to server and status if there are
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, transport Type(obex, FW_HTTP ...)
+ * @param[in] int type, account id
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int suspend_sync(int transport_type, int account_id, int server_flag);
+
+/**
+ * @par Description: API to cancel connection during sync session
+ *
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, transport Type(obex, FW_HTTP ...)
+ *
+ * @return common_error_type_e enum value
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int cancel_connection_sync_request(int transport_type);
+
+#endif /* SA_COMMON_INTERFACE_H_ */
diff --git a/include/service-adapter/sa_define.h b/include/service-adapter/sa_define.h
new file mode 100755
index 0000000..254e6ce
--- /dev/null
+++ b/include/service-adapter/sa_define.h
@@ -0,0 +1,159 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Define.h
+ * @version 0.1
+ * @brief This file is the header file of defined structure and enumeration used in SA
+ */
+
+#ifndef SA_DEFINE_H_
+#define SA_DEFINE_H_
+
+#include <malloc.h>
+#include <glib.h>
+#include <assert.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "service-adapter/sa_error.h"
+
+#define DEFINE_PROTOCOL_TYPE "OMA_DS"
+
+#define ELEMENT_DEVINF_10 "./devinf10"
+#define ELEMENT_DEVINF_11 "./devinf11"
+#define ELEMENT_DEVINF_12 "./devinf12"
+
+#define ELEMENT_DEVINF_XML "application/vnd.syncml-devinf+xml"
+#define ELEMENT_DEVINF_WBXML "application/vnd.syncml-devinf+wbxml"
+#define ELEMENT_WBXML "application/vnd.syncml+wbxml"
+#define ELEMENT_XML "application/vnd.syncml+xml"
+
+#define ELEMENT_AUTH_BASIC "syncml:auth-basic"
+#define ELEMENT_AUTH_MD5 "syncml:auth-md5"
+#define ELEMENT_FORMAT_BASE64 "b64"
+
+#define OMA_DS_HTTP_DEFAULT_CLIENT_MAX_MSG_SIZE 1024*12
+#define OMA_DS_HTTP_DEFAULT_CLIENT_MAX_OBJ_SIZE 1024*1024
+
+/*#define OMA_DS_HTTP_DEFAULT_SERVER_MAX_MSG_SIZE 61440*/
+#define OMA_DS_HTTP_DEFAULT_SERVER_MAX_MSG_SIZE 1024*5
+
+typedef struct item item_s;
+typedef struct status status_s;
+typedef struct command command_s;
+typedef struct anchor anchor_s;
+typedef struct location location_s;
+typedef struct cred cred_s;
+typedef struct syncml syncml_s;
+typedef struct sync_hdr sync_hdr_s;
+typedef struct chal chal_s;
+typedef struct devinf devinf_s;
+typedef struct devinf_datastore devinf_datastore_s;
+typedef struct devinf_content_type devinf_content_type_s;
+typedef struct devinf_ct_cap devinf_ct_cap_s;
+typedef struct devinf_property devinf_property_s;
+typedef struct devinf_prop_param devinf_prop_param_s;
+typedef struct filter_cap filter_cap_s;
+typedef struct session session_s;
+typedef struct command_status command_status_s;
+typedef struct mem mem_s;
+
+typedef enum {
+ VERSION_UNKNOWN = 0,
+ VERSION_10 = 1,
+ VERSION_11 = 2,
+ VERSION_12 = 3
+} protocol_version_e;
+
+typedef enum {
+ PROTOCOL_TYPE_UNKNOWN = 0,
+ PROTOCOL_TYPE_DS = 1,
+} protocol_type_e;
+
+typedef enum {
+ COMMAND_TYPE_UNKNOWN = 0,
+ COMMAND_TYPE_ALERT = 1,
+ COMMAND_TYPE_SYNC_START = 2,
+ COMMAND_TYPE_SYNC_END = 3,
+ COMMAND_TYPE_PUT = 4,
+ COMMAND_TYPE_HEADER = 5,
+ COMMAND_TYPE_ADD = 6,
+ COMMAND_TYPE_REPLACE = 7,
+ COMMAND_TYPE_DELETE = 8,
+ COMMAND_TYPE_MAP = 9,
+ COMMAND_TYPE_GET = 10,
+ COMMAND_TYPE_RESULTS = 11
+} command_type_e;
+
+typedef enum {
+ AUTH_TYPE_UNKNOWN = 0,
+ AUTH_TYPE_BASIC = 1,
+ AUTH_TYPE_MD5 = 2
+} auth_type_e;
+
+typedef enum {
+ FORMAT_TYPE_UNKNOWN = 0,
+ FORMAT_TYPE_BASE64 = 1
+} format_type_e;
+
+typedef enum {
+ DEVINF_VERSION_UNKNOWN = 0,
+ DEVINF_VERSION_10 = 1,
+ DEVINF_VERSION_11 = 2,
+ DEVINF_VERSION_12 = 3
+} devinf_version_e;
+
+typedef enum {
+ DEVINF_DEVTYPE_UNKNOWN,
+ DEVINF_DEVTYPE_PAGER,
+ DEVINF_DEVTYPE_HANDHELD,
+ DEVINF_DEVTYPE_PDA,
+ DEVINF_DEVTYPE_PHONE,
+ DEVINF_DEVTYPE_SMARTPHONE,
+ DEVINF_DEVTYPE_SERVER,
+ DEVINF_DEVTYPE_WORKSTATION
+} devinf_devtyp_e;
+
+typedef enum {
+ DEVINF_SYNCTYPE_UNKNOWN = 0,
+ DEVINF_SYNCTYPE_TWO_WAY = 1,
+ DEVINF_SYNCTYPE_SLOW_SYNC = 1 << 1,
+ DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT = 1 << 2,
+ DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT = 1 << 3,
+ DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER = 1 << 4,
+ DEVINF_SYNCTYPE_REFRESH_FROM_SERVER = 1 << 5,
+ DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC = 1 << 6
+} devinf_sync_cap_e;
+
+typedef enum {
+ SYNCML_PKG_1 = 1,
+ SYNCML_PKG_2 = 2,
+ SYNCML_PKG_3 = 3,
+ SYNCML_PKG_4 = 4,
+ SYNCML_PKG_5 = 5,
+ SYNCML_PKG_6 = 6,
+ SYNCML_SUSPEND = 7
+} pkg_status_e;
+
+typedef enum {
+ ITEM_UNKNOWN = 0,
+ ITEM_DATA = 1,
+ ITEM_DEVINF = 2,
+} item_data_type_e;
+
+#endif /* SA_DEFINE_H_ */
diff --git a/include/service-adapter/sa_devinf.h b/include/service-adapter/sa_devinf.h
new file mode 100755
index 0000000..95efc87
--- /dev/null
+++ b/include/service-adapter/sa_devinf.h
@@ -0,0 +1,134 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_DevInf.h
+ * @version 0.1
+ * @brief This file is the header file of interface of DevInf structure
+ */
+
+#ifndef SA_DEVINF_H_
+#define SA_DEVINF_H_
+
+#include "service-adapter/sa_define.h"
+
+/**
+ * @par Description: API to create devinf_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[out] devinf_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_ERROR, ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_devinf(session_s * session, devinf_s ** devinf);
+
+/**
+ * @par Description: API to free devinf_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] devinf_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_devinf(devinf_s * devinf);
+
+/**
+ * @par Description: API to set sync cap in devinf_datastore_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] devinf_datastore_s structure
+ * @param[in] devinf_sync_cap_e sync type
+ * @param[in] whether support or not
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_devinf_datastore_sync_cap(devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap, int supported);
+
+/**
+ * @par Description: API to get sync cap from devinf_datastore_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] devinf_datastore_s structure
+ * @param[in] devinf_sync_cap_e sync type
+ *
+ * @return True on success
+ * False on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_devinf_datastore_sync_cap(const devinf_datastore_s * devinf_datastore, devinf_sync_cap_e cap);
+
+/*
+DevInfSyncCap convert_devinf_synccap(unsigned int id);
+*/
+#endif /* SA_DEVINF_H_ */
diff --git a/include/service-adapter/sa_devinf_internal.h b/include/service-adapter/sa_devinf_internal.h
new file mode 100755
index 0000000..f60fd56
--- /dev/null
+++ b/include/service-adapter/sa_devinf_internal.h
@@ -0,0 +1,118 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_DevInf_Internal.h
+ * @version 0.1
+ * @brief This file is the header file that structure which is available in SA is defined
+ * about device information(DevInf)
+ */
+
+#ifndef SA_DEVINF_INTERNAL_H_
+#define SA_DEVINF_INTERNAL_H_
+
+#include "service-adapter/sa_define.h"
+
+#define DEFINE_DEVICE_TYPE_PAGER "pager"
+#define DEFINE_DEVICE_TYPE_HANDHELD "handheld"
+#define DEFINE_DEVICE_TYPE_PDA "pda"
+#define DEFINE_DEVICE_TYPE_PHONE "phone"
+#define DEFINE_DEVICE_TYPE_SMARTPHONE "smartphone"
+#define DEFINE_DEVICE_TYPE_SERVER "server"
+#define DEFINE_DEVICE_TYPE_WORKSTATION "workstation"
+
+struct devinf {
+ devinf_version_e version;
+
+ devinf_devtyp_e devtyp;
+ char *manufacturer;
+ char *model;
+ char *oem;
+ char *software_version;
+ char *hardware_version;
+ char *firmware_version;
+ char *dev_id;
+
+ int supports_utc;
+ int supports_large_objs;
+ int supports_number_of_changes;
+
+ GList *datastores; /*containing DevInfDataStore structure */
+};
+
+struct devinf_datastore {
+ int supports_hierarchical_sync;
+
+ char *source_ref;
+ char *display_name;
+ unsigned int max_guid_size;
+
+ devinf_content_type_s *rx_pref;
+ devinf_content_type_s *tx_pref;
+
+ GList *filter_rx; /*need to be considered filter_rx,filterCap */
+ GList *filter_cap;
+
+ GList *rx;
+ GList *tx;
+
+ int shared_mem;
+ unsigned int max_mem;
+ unsigned int max_id;
+
+ unsigned int sync_cap;
+
+ GList *ct_caps; /*containing DevInfCTCap structure */
+};
+
+struct devinf_content_type {
+ char *ct_type;
+ char *verct;
+};
+
+struct devinf_ct_cap {
+ devinf_content_type_s *ct;
+ GList *properties; /*containing DevInfProperty structure */
+};
+
+struct devinf_property {
+ char *prop_name;
+ char *data_type;
+ unsigned int max_occur;
+ unsigned int max_size;
+/* unsigned int propSize;*/
+ int no_truncate;
+ char *display_name;
+ GList *val_enums; /*containing char* */
+ GList *prop_params; /*containing DevInfPropParam structure */
+};
+
+struct devinf_prop_param {
+ char *param_name;
+ char *data_type;
+ char *display_name;
+ GList *val_enums;
+};
+
+struct filter_cap {
+ char *ct_type;
+ char *verct;
+ GList *filter_keyword;
+ GList *prop_name;
+};
+
+#endif /* SA_DEVINF_INTERNAL_H_ */
diff --git a/include/service-adapter/sa_elements.h b/include/service-adapter/sa_elements.h
new file mode 100755
index 0000000..32b4e41
--- /dev/null
+++ b/include/service-adapter/sa_elements.h
@@ -0,0 +1,893 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Elements.h
+ * @version 0.1
+ * @brief This file is the header file of interface of elements structure
+ */
+
+#ifndef SA_ELEMENTS_H_
+#define SA_ELEMENTS_H_
+
+#include "service-adapter/sa_define.h"
+
+/**
+ * @par Description: API to create anchor_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, last anchor
+ * @param[in] string type, next anchor
+ * @param[out] anchor_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_anchor(char *last, char *next, anchor_s ** anchor);
+
+/**
+ * @par Description: API to set anchor in item_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item_s structure
+ * @param[in] anchor_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED, ERROR_INTERNAL_NO_MEMORY on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_item_anchor(item_s * item, anchor_s * anchor);
+
+/**
+ * @par Description: API to set last anchor in anchor_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] anchor_s structure
+ * @param[in] string type, last anchor
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_last_anchor(anchor_s * anchor, char *lastAnchor);
+
+/**
+ * @par Description: API to set next anchor in anchor_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] anchor_s structure
+ * @param[in] string type, next anchor
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e set_next_anchor(anchor_s * anchor, char *nextAnchor);
+
+/**
+ * @par Description: API to free anchor_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] anchor_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_anchor(anchor_s * anchor);
+
+/**
+ * @par Description: API to create location_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, location uri
+ * @param[in] string type, location name
+ * @param[out] location_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY, ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_location(char *loc_uri, char *loc_name, location_s ** location);
+
+/**
+ * @par Description: API to duplicate location_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] location_s structure
+ *
+ * @return location_s structure on success
+ * NULL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+location_s *dup_location(location_s * location);
+
+/**
+ * @par Description: API to get location name from location_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] location_s structure
+ *
+ * @return location name on success
+ * NULL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_location_loc_name(location_s * location);
+
+/**
+ * @par Description: API to get location uri from location_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] location_s structure
+ *
+ * @return location uri on success
+ * NULL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_location_loc_uri(location_s * location);
+
+/**
+ * @par Description: API to free location_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] location_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_location(location_s * location);
+
+/**
+ * @par Description: API to create cred_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, ID
+ * @param[in] string type, password
+ * @param[in] enum type, authentication type(basic, md5..)
+ * @param[in] enum type, format type(base64..)
+ * @param[in] string type, credential
+ * @param[out] cred_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY, ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_cred(char *user_name, char *pwd, auth_type_e auth_type, format_type_e format_type, char *data, cred_s ** cred);
+
+/**
+ * @par Description: API to create cred_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, authentication type(basic, md5..)
+ * @param[in] credential
+ *
+ * @return cred_s structure on success
+ * NULL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+cred_s *create_cred_with_data(auth_type_e auth_type, char *data);
+
+/**
+ * @par Description: API to duplicate cred_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] cred_s structure
+ *
+ * @return cred_s structure on success
+ * NULL on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+cred_s *dup_cred(cred_s * cred);
+
+/**
+ * @par Description: API to set format type in cred_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] cred_s structure
+ * @param[in] format type(base64..)
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_cred_format_type(cred_s * cred, format_type_e format_type);
+
+/**
+ * @par Description: API to free cred_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] cred_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cred(cred_s * cred);
+
+/**
+ * @par Description: API to create syncml_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync_hdr_s structure
+ * @param[in] GList type, list of status_s structure
+ * @param[in] GList type, list of command_s structure
+ * @param[in] int type, final flag
+ * @param[out] syncml_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY, ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_syncml(sync_hdr_s * sync_hdr, GList * status, GList * commands, int is_final, syncml_s ** syncml);
+
+/**
+ * @par Description: API to free syncml_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] syncml_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_syncml(syncml_s * syncml);
+
+/**
+ * @par Description: API to create sync_hdr_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[out] sync_hdr_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY, ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_sync_hdr(session_s * session, sync_hdr_s ** sync_hdr);
+
+/**
+ * @par Description: API to free SyncHdr structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] SyncHdr structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sync_hdr(sync_hdr_s * sync_hdr);
+
+/**
+ * @par Description: API to create item_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return item_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+item_s *create_item();
+
+/**
+ * @par Description: API to create item_s structure using data
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] data
+ * @param[in] size of data
+ * @param[out]
+ *
+ * @return item_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+item_s *create_item_for_data(const char *data, unsigned int size);
+
+/**
+ * @par Description: API to create item_s structure using DevInf
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] devinf_s structure
+ * @param[out]
+ *
+ * @return item_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+item_s *create_item_for_devinf(devinf_s * devinf);
+
+/**
+ * @par Description: API to set location_s(target) structure in item_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item_s structure
+ * @param[in] location_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_item_target(item_s * item, location_s * target);
+
+/**
+ * @par Description: API to set location_s(source) structure in item_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item_s structure
+ * @param[in] location_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_item_source(item_s * item, location_s * source);
+
+/**
+ * @par Description: API to free item_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_item(item_s * item);
+
+/**
+ * @par Description: API to duplicate chal_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] chal_s structure
+ * @param[out]
+ *
+ * @return chal_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+chal_s *dup_chal(chal_s * chal);
+
+/**
+ * @par Description: API to free chal_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] chal_s structure
+ * @param[out]
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_chal(chal_s * chal);
+
+/**
+ * @par Description: API to compare server credential with local credential
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] cred_s structure
+ * @param[in] cred_s structure
+ * @param[out]
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_AUTH_REJECTED, ERROR_INTERNAL_NOT_DEFINED on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e compare_cred(cred_s * hdr_cred, cred_s * session_cred);
+
+/**
+ * @par Description: API to convert auth_type_e
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, auth type
+ * @param[out]
+ *
+ * @return AUTH_TYPE_MD5, AUTH_TYPE_BASIC on success
+ * AUTH_TYPE_UNKNOWN on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+auth_type_e convert_auth_type(char *auth_type);
+
+/**
+ * @par Description: API to convert format_type_e
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, format type
+ * @param[out]
+ *
+ * @return FORMAT_TYPE_BASE64 on success
+ * FORMAT_TYPE_UNKNOWN on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+format_type_e convert_format_type(char *format_type);
+
+/**
+ * @par Description: API to create mem_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return mem_s structure on success
+ * NULL on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+mem_s *create_mem();
+
+/**
+ * @par Description: API to set shared_mem
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mem
+ * @param[in] shared_mem
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_mem_shared_mem(mem_s * mem, int shared_mem);
+
+/**
+ * @par Description: API to set free_mem
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mem
+ * @param[in] free_mem
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_mem_free_mem(mem_s * mem, unsigned int free_mem);
+
+/**
+ * @par Description: API to set free_id
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mem
+ * @param[in] free_id
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_mem_free_id(mem_s * mem, unsigned int free_id);
+
+#endif /* SA_ELEMENTS_H_ */
diff --git a/include/service-adapter/sa_elements_internal.h b/include/service-adapter/sa_elements_internal.h
new file mode 100755
index 0000000..842ca1d
--- /dev/null
+++ b/include/service-adapter/sa_elements_internal.h
@@ -0,0 +1,102 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Elements_Internal.h
+ * @version 0.1
+ * @brief This file is the header file that structure which is available in SA is defined
+ * SyncHdr, SyncML, Cred, Chal, Item, Anchor, Location
+ */
+
+#ifndef SA_ELEMENTS_INTERNAL_H_
+#define SA_ELEMENTS_INTERNAL_H_
+
+#include "service-adapter/sa_define.h"
+
+typedef union {
+ char *data;
+ devinf_s *devinf;
+} item_data_u;
+
+struct mem {
+ int sharedmem;
+ unsigned int free_mem;
+ unsigned int free_id;
+};
+
+struct chal {
+ format_type_e format;
+ auth_type_e type;
+ char *nonce_plain;
+ unsigned int nonce_length;
+ char *nonce_b64;
+};
+
+struct item {
+ item_data_type_e data_type;
+ item_data_u private;
+ location_s *source;
+ location_s *target;
+ anchor_s *anchor;
+
+ unsigned int size; /* for data */
+ char *content_type; /* for data */
+ int more_data; /* for moredata */
+};
+
+struct anchor {
+ char *last_anchor; /**< Last Anchor*/
+ char *next_anchor; /**< Next Anchor*/
+};
+
+struct location {
+ char *loc_uri;
+ char *loc_name;
+};
+
+struct cred {
+ format_type_e format;
+ auth_type_e type;
+ char *data;
+ char *user_name;
+ char *password;
+};
+
+struct sync_hdr {
+ char *session_id;
+ protocol_version_e version;
+ protocol_type_e protocol;
+ location_s *source;
+ location_s *target;
+ cred_s *cred;
+ char *response_uri;
+ int no_response;
+ unsigned int message_id;
+
+ /*in meta element */
+ unsigned int max_msg_size;
+ unsigned int max_obj_size;
+};
+
+struct syncml {
+ sync_hdr_s *hdr;
+ GList *status; /**< containing Status struct */
+ GList *commands; /**< containing Command struct */
+ int final;
+};
+
+#endif /* SA_ELEMENTS_INTERNAL_H_ */
diff --git a/include/service-adapter/sa_error.h b/include/service-adapter/sa_error.h
new file mode 100755
index 0000000..fd9d641
--- /dev/null
+++ b/include/service-adapter/sa_error.h
@@ -0,0 +1,124 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Error.h
+ * @version 0.1
+ * @brief This file is the header file of Error is defined
+ */
+
+#ifndef SA_ERROR_H_
+#define SA_ERROR_H_
+
+typedef enum {
+ ERROR_UNKNOWN = 0,
+
+ /* Informational */
+ IN_PROGRESS = 101,
+
+ /* OK code */
+ /** No error */
+ NO_ERROR = 200,
+ /** Requested item was added */
+ ITEM_ADDED = 201,
+ /** Accepted for processing */
+ PROCESSING_ACCEPTED = 202,
+ /** Non-authoritative response */
+ NON_AUTHORITATIVE = 203,
+ /** No content */
+ NO_CONTENT = 204,
+ /** Reset content */
+ RESET_CONTENT = 205,
+ /** Partial content */
+ PARTIAL_CONTENT = 206,
+ /** Conflict resolved with merge */
+ CONFLICT_MERGE = 207,
+ /** Conflict resolved with client win */
+ CONFLICT_CLIENT_WIN = 208,
+ /** Conflict resolved with duplicate */
+ CONFLICT_DUPLICATE = 209,
+ /** Deleted without archiving */
+ DELETE_NO_ARCHIVE = 210,
+ /** Item not deleted (not found) */
+ DELETE_NOT_FOUND = 211,
+ /** Authentication accepted */
+ AUTH_ACCEPTED = 212,
+ /** Chunked item accepted */
+ CHUNK_ACCEPTED = 213,
+ /** Operation cancelled */
+ OPERATION_CANCELLED = 214,
+ /** Not executed */
+ NOT_EXECUTED = 215,
+ /** Atomic rollback ok */
+ ATOMIC_ROLLBACK_OK = 216,
+
+ /* Retry error */
+ ERROR_MULTIPLE_CHOICES = 300,
+ ERROR_MOVED_PERMANENTLY = 301,
+ ERROR_FOUND_RETRY = 302,
+ ERROR_SEE_OTHER_RETRY = 303,
+ ERROR_NOT_MODIFIED = 304,
+ ERROR_USE_PROXY = 305,
+
+ /* Errors */
+ ERROR_BAD_REQUEST = 400, /* Bad Request */
+ ERROR_AUTH_REJECTED = 401, /* Unauthorized, Invalid Credentials */
+ ERROR_PAYMENT_NEEDED = 402, /* Payment need */
+ ERROR_FORBIDDEN = 403, /* Forbidden */
+ ERROR_NOT_FOUND = 404, /* Not found */
+ ERROR_COMMAND_NOT_ALLOWED = 405, /* Command not allowed */
+ ERROR_UNSUPPORTED_FEATURE = 406, /* Optional feature unsupported */
+ ERROR_AUTH_REQUIRED = 407, /* Authentication required, Missing Credentials */
+ ERROR_SIZE_REQUIRED = 411,
+ ERROR_REQUESTED_SIZE_TOO_BIG = 416,
+ ERROR_RETRY_LATER = 417, /* Retry later */
+ ERROR_ALREADY_EXISTS = 418, /* Put or Add failed because item already exists */
+ ERROR_SIZE_MISMATCH = 424, /* Size mismatch */
+
+ /* Standard errors */
+ ERROR_GENERIC = 500,
+ ERROR_NOT_IMPLEMENTED = 501,
+ ERROR_SERVICE_UNAVAILABLE = 503,
+ ERROR_REQUIRE_REFRESH = 508,
+ ERROR_SERVER_FAILURE = 511,
+
+} oma_status_type_e;
+
+typedef enum {
+
+ /* Internal errors - never ever send this via SyncML */
+ SA_ERROR_UNKNOWN = 0,
+ SA_INTERNAL_OK = 1,
+ SA_INTERNAL_ERROR,
+ SA_INTERNAL_BINDER_ERROR,
+ SA_INTERNAL_TIMEOUT,
+ SA_INTERNAL_NOT_FOUND,
+ SA_INTERNAL_MISCONFIGURATION,
+ SA_INTERNAL_NO_MEMORY,
+ SA_INTERNAL_NOT_DEFINED,
+ SA_INTERNAL_CONNECTION_ERROR,
+ SA_INTERNAL_DA_ERROR,
+ SA_INTERNAL_CANCEL,
+ SA_INTERNAL_AUTOCONFIG_NOT_SUPPORT_BY_SERVER,
+ SA_INTERNAL_BUSY_SIGNALING,
+ SA_INTERNAL_SERVER_FAILURE,
+ SA_INTERNAL_SERVER_ERROR,
+ SA_INTERNAL_AUTHENTICATION_ERROR,
+ SA_INTERNAL_SUSPEND_FAIL,
+} sa_error_type_e;
+
+#endif /* SA_ERROR_H_ */
diff --git a/include/service-adapter/sa_session.h b/include/service-adapter/sa_session.h
new file mode 100755
index 0000000..89efe2b
--- /dev/null
+++ b/include/service-adapter/sa_session.h
@@ -0,0 +1,277 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Session.h
+ * @version 0.1
+ * @brief This file is the header file of interface of Session structure
+ */
+
+#ifndef SA_SESSION_H_
+#define SA_SESSION_H_
+
+#include "service-adapter/sa_define.h"
+
+/**
+ * @par Description: API to create session_s structure
+ * This API can be used to create session_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, protocol version(VERSION_UNKNOWN, VERSION_10, VERSION_11, VERSION_12);
+ * @param[in] enum type, protocol type(PROTOCOL_TYPE_UNKNOWN , PROTOCOL_TYPE_DS)
+ * @param[in] int type, account id
+ * @param[in] int type, session id
+ * @param[in] string type, source uri(server ip)
+ * @param[in] string type, target uri(client identifer)
+ * @param[out] session_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_session(protocol_version_e protocol_version, protocol_type_e protocol_type, int account_id, char *sess_id, location_s * source_location, location_s * target_location, session_s ** session);
+
+/**
+ * @par Description: API to free session_s structure
+ * This API can be used to free session_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_session(session_s * session);
+
+/**
+ * @par Description: API to set cred_s structure in session_s structure
+ * This API can be used to set cred_s structure in session_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] cred_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_session_cred(session_s * session, cred_s * cred);
+
+/**
+ * @par Description: API to set devinf_s structure in session_s structure
+ * This API can be used to set devinf_s structure in session_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] devinf_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_session_devinf(session_s * session, devinf_s * devInf);
+
+/**
+ * @par Description: API to create command_status_s structure
+ * This API can be used to set devinf_s structure in session_s structure
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] unsigned int type, msg id
+ * @param[in] unsigned int type, cmd id
+ * @param[out] command_status_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_command_status(unsigned int msg_id, unsigned int cmdID, command_status_s ** command_status);
+
+/**
+ * @par Description: API to process sync_hdr_s structure from server
+ * This API manage responseURI
+ * set server info in session_s structure
+ * check header credential
+ * create Status structure for header
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] sync_hdr_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e receive_header(session_s * session, sync_hdr_s * header);
+
+/**
+ * @par Description: API to process list of status_s structure from server
+ * This API check credential status
+ * process Status structure for each type
+ * create AppliedStatus structure for passing to ServiceEngine
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ * @param[in] GList type, list of status_s structure
+ * @param[out] GList type, list of applied_status_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_ERROR, ERROR_SERVER_FAILURE, ERROR_INTERNAL_BUSY_SIGNALING on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e receive_statuses(session_s * session, GList * receive_status, GList ** return_status);
+
+/**
+ * @par Description: API to process list of command_s structure from server
+ * This API check credential status
+ * process command_ structure for each type
+ * create changed_datastore_s structure for passing to ServiceEngine
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[in] GList type, list of command_s structure
+ * @param[in] whether auto configure or not
+ * @param[out] GList type, list of changed_datastore_s structure
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_ERROR, ERROR_INTERNAL_NO_MEMORY, ERROR_INTERNAL_NOT_DEFINED on error
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e receive_commands(session_s * session, GList * receive_command, bool auto_config, GList ** return_datastore);
+
+/**
+ * @par Description: API to reset cmd id(1) in session
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session_s structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_cmd_id_session(session_s * session);
+
+#endif /* SE_SESSION_H_ */
diff --git a/include/service-adapter/sa_session_internal.h b/include/service-adapter/sa_session_internal.h
new file mode 100755
index 0000000..56ff46c
--- /dev/null
+++ b/include/service-adapter/sa_session_internal.h
@@ -0,0 +1,83 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Session_Internal.h
+ * @version 0.1
+ * @brief This file is the header file of session structure is defined
+ * Session, PendingStatus
+ */
+
+#ifndef SA_SESSION_INTERNAL_H_
+#define SA_SESSION_INTERNAL_H_
+
+#include "service-adapter/sa_define.h"
+
+struct session {
+ protocol_version_e protocol_version;
+ protocol_type_e protocol_type;
+
+ char *session_id;
+ unsigned int msg_id;
+ unsigned int last_recieved_msg_id;
+ unsigned int cmd_id;
+ int is_sending_final;
+ int is_receiving_final;
+
+ GList *status; /*status to return to server */
+ GList *temp_status; /*temp status for sync add, replace, delete command(it doesnot have data element value) */
+ GList *suspend_status; /* for suspend */
+ location_s *target;
+ location_s *source;
+ location_s *org_target;
+
+ unsigned int source_max_msg_size;
+ unsigned int source_max_obj_size;
+
+ unsigned int target_max_msg_size;
+ unsigned int target_max_obj_size;
+
+ cred_s *cred; /*account info */
+ chal_s *chal; /*chal from server */
+
+ devinf_s *devinf; /*client devinf */
+ devinf_s *remote_devinf; /*server devinf */
+
+ pkg_status_e pkg_status; /*for status */
+
+ command_s *large_obj_cmd; /*for incomming large Command */
+
+ GList *map_command; /*containing map command that has sent to server(this is used to for delete map item from mapping table) */
+
+ GList *alert_command; /*containing alert command that have to send to server */
+
+ GList *results_command; /*containing results command */
+
+ command_status_s *large_obj; /*for outgoing large command */
+
+ int has_opend;
+ unsigned int naci_session_id;
+
+ int account_id;
+ char *jsession_id;
+};
+
+struct command_status {
+ unsigned int cmd_id;
+ unsigned int msg_id;
+};
+#endif /* SA_SESSION_INTERNAL_H_ */
diff --git a/include/service-adapter/sa_util.h b/include/service-adapter/sa_util.h
new file mode 100755
index 0000000..8b07eb7
--- /dev/null
+++ b/include/service-adapter/sa_util.h
@@ -0,0 +1,94 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SA_Util.h
+ * @version 0.1
+ * @brief This file is the header file of interface for utility function in SA
+ */
+
+#ifndef SA_UTIL_H_
+#define SA_UTIL_H_
+
+#include "service-adapter/sa_define.h"
+
+/**
+ * @par Description: API to put command into GList
+ * This API can be used to put structure into GList
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] GList type, first index of list
+ * @param[in] GList type, last index of list
+ * @param[in] void pointer type, structure to put in the list
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void put_into_list(GList ** commands, GList ** commands_last, void *command);
+
+/**
+ * @par Description: API to create credential string
+ * This API can be used to create credential string
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, type of authentication(AUTH_TYPE_BASIC , AUTH_TYPE_MD5...)
+ * @param[in] string type, id
+ * @param[in] string type, password
+ * @param[in] string type, nonce
+ * @param[in] unsigned int type, size of nonce
+ * @param[out] string type, credential
+ *
+ * @return ERROR_INTERNAL_OK on success
+ * ERROR_INTERNAL_NO_MEMORY on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sa_error_type_e create_cred_string(auth_type_e type, const char *user_name, const char *password, const char *nonce, unsigned int nonce_size, char **cred);
+
+/**
+ * @brief write xml to file(for debugging)
+ * @param[in] string to write
+ * @param[in] path
+ */
+void set_xml_to_file(char *xml, const char *path);
+
+#endif /* SA_UTIL_H_ */
diff --git a/include/service-engine/se_account.h b/include/service-engine/se_account.h
new file mode 100755
index 0000000..fc6563e
--- /dev/null
+++ b/include/service-engine/se_account.h
@@ -0,0 +1,342 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Account.h
+ * @version 0.1
+ * @brief This file is the header file of interface of account
+ */
+
+#ifndef SE_ACCOUNT_H_
+#define SE_ACCOUNT_H_
+
+#include <glib.h>
+#include <stdbool.h>
+#include "common/common_define.h"
+
+/**
+ * @par Description: API to add profile API
+ * This API can be used to add profile
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profile_dir_name(identify profile in UI)
+ * @param[in] string type, profile name
+ * @param[in] string type, server ip
+ * @param[in] string type, id
+ * @param[in] string type, password
+ * @param[in] string type, sync mode
+ * @param[in] string type, sync type
+ * @param[in] string type, interval(for periodic)
+ * @param[in] GList type, list of sync_service_s structure
+ * @param[out] int type, account id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool add_profile(char *profile_dir_name, char *profile_name, char *addr, char *id, char *password, char *sync_mode, char *sync_type, char *interval, GList * categories, int *account_id);
+
+/**
+ * @par Description: API to add profile from csc
+ * This API can be used to add profile from csc(vconf)
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, index of profile
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool add_profile_csc(int index);
+
+/**
+ * @par Description: API to add profile API
+ * This API can be used to add profile
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profile name
+ * @param[in] string type, server ip
+ * @param[in] string type, id
+ * @param[in] string type, password
+ * @param[in] GList type, list of resource_cp structure
+ * @param[out] int type, account id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool add_profile_cp(char *profile_name, char *addr, char *id, char *password, GList * categories, int *account_id);
+
+/**
+ * @par Description: API to add profile for call log sync
+ * This API can be used to add profile
+ * This API is part of API for call log sync
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] int type, account_id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool add_profile_dive(int *account_id);
+
+/**
+ * @par Description: API to edit profile API
+ * This API can be used to edit profile
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, profile name
+ * @param[in] string type, server ip
+ * @param[in] string type, id
+ * @param[in] string type, password
+ * @param[in] string type, sync mode
+ * @param[in] string type, sync type
+ * @param[in] string type, interval(for periodic)
+ * @param[in] GList type, list of sync_service_s structure
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool edit_profile(int account_id, char *profile_name, char *addr, char *id, char *password, char *sync_mode, char *sync_type, char *interval, GList * categories);
+
+/**
+ * @par Description: API to delete profile API
+ * This API can be used to delete profile
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] GList type, list of account id
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool delete_profiles(GList * profiles);
+
+/**
+ * @par Description: API to delete profile for call log sync
+ * This API can be used to delete profile
+ * This API is part of API for call log sync
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool delete_profile_dive();
+
+/**
+ * @par Description: API to delete profile
+ * This API can be used to delete profile
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool delete_profile(char *access_name);
+
+/**
+ * @par Description: API to delete all profiles
+ * This API can be used to delete all profiles
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool delete_all_profiles();
+
+/**
+ * @par Description: API to get profile directory name of synchronizing account
+ * This API can be used to get profile directory name
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] string type, profile_dir_name(identify profile in UI)
+ * @param[out] string type, sync_type(determined by server)
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_synchronising_profile(char **profile_dir_name, char **sync_type);
+
+/**
+ * @par Description: API to delete all agent default table(except id_provider_tbl, id_page_tbl)
+ * This API can be used to delete all agent default table
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool delete_all_agent_default_table();
+
+#endif /* SE_ACCOUNT_H_ */
diff --git a/include/service-engine/se_common.h b/include/service-engine/se_common.h
new file mode 100755
index 0000000..108acef
--- /dev/null
+++ b/include/service-engine/se_common.h
@@ -0,0 +1,128 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Common.h
+ * @version 0.1
+ * @brief This file is the header file of enumeration and define used in SE
+ */
+
+#ifndef SE_COMMON_H_
+#define SE_COMMON_H_
+
+#define DEFINE_SYNC_PROGRESS_NONE "PROGRESS_NONE"
+#define DEFINE_SYNC_INIT "INIT"
+#define DEFINE_SYNC_CONNECTING "CONNECTING"
+#define DEFINE_SYNC_AUTHENTICATED "AUTHENTICATED"
+#define DEFINE_SYNC_DONE "DONE"
+#define DEFINE_SYNC_ERROR "ERROR"
+
+#define DEFINE_ERROR_NONE "ERROR_NONE"
+#define DEFINE_ERROR_CONNECTION "CONNECTION"
+#define DEFINE_ERROR_SYNCHDR "SYNCHDR"
+#define DEFINE_ERROR_INTERNAL "INTERNAL"
+#define DEFINE_ERROR_SUSPENDED "SUSPENDED"
+#define DEFINE_ERROR_DB "DB"
+#define DEFINE_ERROR_ABORT "ABORT"
+#define DEFINE_ERROR_SERVER "SERVER"
+#define DEFINE_ERROR_MEMORY_FULL "MEMORY_FULL"
+#define DEFINE_ERROR_AUTHENTICATE "AUTHENTICATE"
+#define DEFINE_ERROR_AUTOCONFIG_NOT_SUPPORT_BY_SERVER "AUTOCONFIG_NOT_SUPPORT_BY_SERVER"
+#define DEFINE_ERROR_LOW_BATTERY "LOW_BATTERY"
+
+#define DEFINE_PROGRESS_NONE "PROGRESS_NONE"
+#define DEFINE_PROGRESS_SUCCESS "PROGRESS_SUCCESS"
+#define DEFINE_FAILED_DB "FAILED_DB"
+#define DEFINE_FAILED_DB_FORBIDDEN "FAILED_DB_FORBIDDEN"
+#define DEFINE_FAILED_DB_ITEM "FAILED_DB_ITEM"
+#define DEFINE_FAILED_DB_CONFIG "FAILED_DB_CONFIG"
+#define DEFINE_FAILED_DB_DEVICEFULL "FAILED_DB_DEVICEFULL"
+
+#define DEFINE_NOOP "NOOP"
+#define DEFINE_ADD "ADD"
+#define DEFINE_DELETE "DELETE"
+#define DEFINE_MOVE "MOVE"
+#define DEFINE_COPY "COPY"
+#define DEFINE_REPLACE "REPLACE"
+
+#define DEFINE_DBSYNC_SUCCESS "success"
+#define DEFINE_DBSYNC_STOP "stop"
+#define DEFINE_DBSYNC_FAIL "fail"
+#define DEFINE_DBSYNC_NO "No"
+
+typedef enum {
+ PROGRESS_NONE = 0,
+ PROGRESS_INIT = 1,
+ PROGRESS_CONNECTING = 2,
+ PROGRESS_AUTHENTICATED = 3,
+ PROGRESS_DONE = 4,
+ PROGRESS_ERROR = 5
+} sync_progress_e;
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_CONNECTION = 1,
+ ERROR_SYNCHDR = 2,
+ ERROR_INTERNAL = 3,
+ ERROR_SUSPENDED = 4,
+ ERROR_DB = 5,
+ ERROR_ABORT = 6,
+ ERROR_SERVER = 7,
+ ERROR_MEMORY_FULL = 8,
+ ERROR_AUTHENTICATE = 9,
+ ERROR_AUTOCONFIG_NOT_SUPPORT_BY_SERVER = 10,
+ ERROR_LOW_BATTERY = 11
+} sync_error_e;
+
+typedef enum {
+ SYNC_PROGRESS_NONE = 0,
+ SYNC_PROGRESS_SUCCESS,
+ SYNC_FAILED_DB,
+ SYNC_FAILED_DB_FORBIDDEN,
+ SYNC_FAILED_DB_ITEM,
+ SYNC_FAILED_DB_CONFIG,
+ SYNC_FAILED_DB_DEVICEFULL
+} sync_progress_status_e;
+
+typedef enum {
+ OPERATION_NOOP = 0,
+ OPERATION_ADD,
+ OPERATION_DELETE,
+ OPERATION_MOVE,
+ OPERATION_COPY,
+ OPERATION_REPLACE
+} operation_type_e;
+
+typedef enum {
+ COMMAND_RESULT_INIT = 0,
+ COMMAND_RESULT_OK = 200, /*[R] OK exception */
+ COMMAND_RESULT_ADDED = 201, /*[AR] Item added exception */
+ COMMAND_RESULT_DELETE_PARTIAL = 206, /*[D] Partial content exception condition */
+ COMMAND_RESULT_DELETE_WITHOUT_ARCHIVE = 210, /*[D] Delete without archive exception */
+ COMMAND_RESULT_NOT_EXIST = 211, /*[D] Item not deleted exception */
+ COMMAND_RESULT_UNAUTHRIZED = 401, /*[ARD] Unauthorized exception */
+ COMMAND_RESULT_AUTHENTICATION_REQUIRED = 407, /*[ARD] Authentication required exception */
+ COMMAND_RESULT_INCOMPLETE = 412, /*[D] Incomplete command exception */
+ COMMAND_RESULT_UNSUPPORTED_TYPE = 415, /*[A] Unsupported media type or format exception */
+ COMMAND_RESULT_ALREADY_EXIST = 418, /*[A] Already exists exception */
+ COMMAND_RESULT_DEVICE_FULL = 420, /*[AR] Device full exception */
+ COMMAND_RESULT_PARTIAL_REPLACE_NOT_ACCEPTED = 426, /*[R] Partial item not accepted */
+ COMMAND_RESULT_NOT_EMPTY = 427, /*[D] Item not empty */
+ COMMAND_RESULT_COMMAND_FAIL = 500 /*[ARD] Command failed exception */
+} command_result_e;
+
+#endif /* SE_COMMON_H_ */
diff --git a/include/service-engine/se_error.h b/include/service-engine/se_error.h
new file mode 100755
index 0000000..6a22139
--- /dev/null
+++ b/include/service-engine/se_error.h
@@ -0,0 +1,45 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Error.h
+ * @version 0.1
+ * @brief This file is the header file of Error is defined
+ */
+
+#ifndef SE_ERROR_H_
+#define SE_ERROR_H_
+
+typedef enum {
+ ERROR_UNKNOWN = 0,
+ SE_INTERNAL_OK = 1,
+ SE_INTERNAL_ERROR = 2,
+ SE_INTERNAL_NO_MEMORY = 3,
+ SE_INTERNAL_NOT_DEFINED = 4,
+ SE_INTERNAL_DA_ERROR = 5,
+ SE_INTERNAL_EVENT_ERROR = 6,
+ SE_INTERNAL_ENGINE_CONTROLER_ERROR = 7,
+ SE_INTERNAL_SCHEDULER_ERROR = 8,
+ SE_INTERNAL_SA_ERROR = 9,
+ SE_INTERNAL_MISCONFIGURATION = 10,
+ SE_INTERNAL_CANCEL = 11,
+ SE_INTERNAL_LOW_BATTERY = 12,
+ SE_INTERNAL_SUSPEND = 13,
+
+} se_error_type_e;
+
+#endif /* SE_ERROR_H_ */
diff --git a/include/service-engine/se_notification.h b/include/service-engine/se_notification.h
new file mode 100755
index 0000000..4789ba5
--- /dev/null
+++ b/include/service-engine/se_notification.h
@@ -0,0 +1,99 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Notification.h
+ * @version 0.1
+ * @brief This file is the header file of interface of notification to UI
+ */
+
+#ifndef SE_NOTIFICATION_H_
+#define SE_NOTIFICATION_H_
+
+#include <glib.h>
+#include "service-engine/se_error.h"
+
+/**
+ * @par Description: API to notify session process to UI
+ * This API can be used to notify session process
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profile dir name(identify profile in UI)
+ * @param[in] string type, progress(DEFINE_SYNC_PROGRESS_NONE,
+ * DEFINE_SYNC_INIT, DEFINE_SYNC_CONNECTING, DEFINE_SYNC_AUTHENTICATED,
+ * DEFINE_SYNC_DONE, DEFINE_SYNC_ERROR)
+ * @param[in] string type, error(DEFINE_ERROR_NONE, DEFINE_ERROR_CONNECTION, DEFINE_ERROR_SYNCHDR,
+ * DEFINE_ERROR_INTERNAL, DEFINE_ERROR_SUSPENDED, DEFINE_ERROR_DB, DEFINE_ERROR_ABORT,
+ * DEFINE_ERROR_SERVER, DEFINE_ERROR_MEMORY_FULL, DEFINE_ERROR_AUTHENTICATE,
+ * DEFINE_ERROR_AUTOCONFIG_NOT_SUPPORT_BY_SERVER)
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_NOT_DEFINED, SE_INTERNAL_NO_MEMORY, SE_INTERNAL_EVENT_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e send_noti_session_process(char *profile, char *progress, char *error, char *sync_type);
+
+/**
+ * @par Description: API to notify process update to UI
+ * This API can be used to notify process update
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profile dir name(identify profile in UI)
+ * @param[in] string type, server sync type
+ * @param[in] string type, datastore name
+ * @param[in] string type, progressStatus(DEFINE_PROGRESS_NONE, DEFINE_PROGRESS_SUCCESS, DEFINE_FAILED_DB,
+ * DEFINE_FAILED_DB_FORBIDDEN, DEFINE_FAILED_DB_ITEM, DEFINE_FAILED_DB_CONFIG, DEFINE_FAILED_DB_DEVICEFULL)
+ * @param[in] string type, operationType(DEFINE_NOOP, DEFINE_ADD, DEFINE_DELETE, DEFINE_MOVE, DEFINE_COPY, DEFINE_REPLACE)
+ * @param[in] int type, whether from server or from client
+ * @param[in] int type, total number per operation
+ * @param[in] int type, synced item number per operation
+ * @param[in] int type, total number per db
+ * @param[in] int type, synced item number per db
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_NOT_DEFINED, SE_INTERNAL_NO_MEMORY, SE_INTERNAL_EVENT_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e send_noti_process_update(char *profile_dir_name, char *sync_type, char *uri, char *progress_status, char *operation_type, int is_from_server, int total_per_operation, int synced_per_operation, int total_per_db, int synced_per_db);
+
+#endif /* SE_NOTIFICATION_H_ */
diff --git a/include/service-engine/se_storage.h b/include/service-engine/se_storage.h
new file mode 100755
index 0000000..ecf45d6
--- /dev/null
+++ b/include/service-engine/se_storage.h
@@ -0,0 +1,258 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Storage.h
+ * @version 0.1
+ * @brief This file is the header file of interface which saves and gets sync results
+ */
+
+#ifndef SE_STORAGE_H_
+#define SE_STORAGE_H_
+
+#include "common/common_define.h"
+#include "service-engine/se_error.h"
+
+/**
+ * @par Description: API to save sync type, sync result , last sync time(each datastore)
+ * This API can be used to save sync type, sync result , last sync time at the end of synchronization process
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] enum type, AlertType
+ * @param[in] enum type, sync_session_result_e
+ * @param[in] int type, last sync time
+ * @param[in] int type, whether or not tn end in pkg4
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_DA_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e write_profile_data(int account_id, alert_type_e alert_type, sync_session_result_e sync_session_result, int last_session_time, int only_from_client);
+
+/**
+ * @par Description: API to save sync statistics(each datastore)
+ * This API can be used to save statistics at the end of synchronization process
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] int type, content type(TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO)
+ * @param[in] bool type whether from server or from client
+ * @param[in] sync_result_s structure
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_DA_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e write_sync_statistics(int account_id, int content_type, bool is_from_server, sync_result_s * sync_result);
+
+/**
+ * @par Description: API to save sync result(each datastore)
+ * This API can be used to save sync result at the end of synchronization process
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] int type, content type(TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO)
+ * @param[in] int type, last sync time
+ * @param[in] int type, whether or not to end in pkg4
+ * @param[in] sync_result_s structure, client
+ * @param[in] sync_result_s structure, server
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_DA_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e write_sync_resource_info(int account_id, int content_type, int last_session_time, int only_from_client, sync_result_s * client_sync_result, sync_result_s * server_sync_result);
+
+/**
+ * @par Description: API to get profile data from config_tbl
+ * This API can be used to get profile data
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[out] string type, profile name
+ * @param[out] string type, server ip
+ * @param[out] string type, id
+ * @param[out] string type, password
+ * @param[out] string type, sync mode
+ * @param[out] string type, sync type
+ * @param[out] string type, interval
+ * @param[out] int type, last_session_status
+ * @param[out] int type, last_session_time
+ *
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_profile_data(int account_id, char **profile_name, char **addr, char **id, char **password, char **sync_mode, char **sync_type, char **interval, int *last_session_status, int *last_session_time);
+
+/**
+ * @par Description: API to get profile datastore information(enable, source uri, target uri, id, password) from config_tbl
+ * This API can be used to get enable, source uri, target uri, id, password
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] int type, content type(TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO)
+ * @param[out] string type, enabled
+ * @param[out] string type, source uri
+ * @param[out] string type, target uri
+ * @param[out] string type, id
+ * @param[out] string type, password
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_profile_sync_category(int account_id, int content_type, int *enabled, char **src_uri, char **tgt_uri, char **id, char **password);
+
+/**
+ * @par Description: API to get profile sync statistics for each content type from config_tbl
+ * This API can be used to get profile sync statistics for each content type
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] int type, content type(TYPE_CONTACT, TYPE_CALENDAR, TYPE_MEMO)
+ * @param[out] string type, sync result(success, fail, stop)
+ * @param[out] int type, sync time
+ * @param[out] int type, total items(server to client)
+ * @param[out] int type, add items(server to client)
+ * @param[out] int type, delete items(server to client)
+ * @param[out] int type, replace items(server to client)
+ * @param[out] int type, total items(client to server)
+ * @param[out] int type, add items(client to server)
+ * @param[out] int type, delete items(client to server)
+ * @param[out] int type, replace items(client to server)
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_profile_statistics(int account_id, int content_type, char **dbSynced, int *last_session_time,
+ int *server2client_total, int *server2client_nrofadd, int *server2client_nrofdelete, int *server2client_nrofreplace,
+ int *client2server_total, int *client2server_nrofadd, int *client2server_nrofdelete, int *client2server_nrofreplace);
+
+/**
+ * @par Description: API to get all profiles data from config_tbl
+ * This API can be used to get all profiles data
+ * This API is part of API for UI
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] GList, all profiles data
+ *
+ *
+ * @return true on success
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool get_all_profiles_data(GList ** list);
+
+#endif /* SE_STORAGE_H_ */
diff --git a/include/service-engine/se_sync.h b/include/service-engine/se_sync.h
new file mode 100755
index 0000000..7f63c5c
--- /dev/null
+++ b/include/service-engine/se_sync.h
@@ -0,0 +1,234 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Sync.h
+ * @version 0.1
+ * @brief This file is the header file of interface of Service Engine
+ */
+
+#ifndef SYNCENGINE_H_
+#define SYNCENGINE_H_
+
+#include <stdbool.h>
+#include "common/common_define_internal.h"
+#include "service-engine/se_common.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "service-engine/se_error.h"
+
+/**
+ * @par Description: API to process synchronization request
+ * This API can be used to process synchronization by predefined profile information
+ * This API uses Notification and Storage API which for notifying synchronization status to UI and saving sync results to Agent DB
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ * @param[in] string type, sync mode(manual, push(SAN), periodic)
+ * @param[in] SanPackage structure, only for SAN sync mode
+
+ * @return true on success, false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+int main()
+{
+ bool ret = 0;
+ ret = synchronize(accountId, syncMode, pSanPackage);
+ if (ret == true)
+ {
+ //synchronization success
+ }
+ else
+ {
+ //synchronization fail
+ }
+
+ return 0;
+}
+ * @endcode
+ */
+bool synchronize(int account_id, char *sync_mode, san_package_s * sanpackage);
+
+/**
+ * @par Description: API to convert SyncProgress and SyncError from common error code
+ * This API can be used to convert string to be used to notify to UI for sync results
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, common_error_type_e
+ * @param[out] enum type, sync_progress_e
+ * @param[out] enum type, sync_error_e
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void convert_common_errorcode(common_error_type_e error_code, sync_progress_e * process, sync_error_e * error);
+
+/**
+ * @par Description: API to convert SyncProgress and SyncError from engine error code
+ * This API can be used to convert string to be used to notify to UI for sync results
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, se_error_type_e
+ * @param[out] enum type, sync_progress_e
+ * @param[out] enum type, sync_error_e
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void convert_engine_errorcode(se_error_type_e err, sync_progress_e * process, sync_error_e * error);
+
+/**
+ * @par Description: API to notify sync results for specific profile to UI
+ * This API can be used to notify sync results(SyncProgress, SyncError) to UI
+ * This API uses Notification which for notification module to send data using IPC
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, profile_dir_name(identify profile in UI)
+ * @param[in] enum type, sync_progress_e
+ * @param[in] enum type, sync_error_e
+ * @param[in] enum type, se_error_type_e sync type
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_NOT_DEFINED, SE_INTERNAL_NO_MEMORY, SE_INTERNAL_EVENT_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e session_process(char *profile_dir_name, alert_type_e server_sync_type, sync_progress_e process, sync_error_e error);
+
+/**
+ * @par Description: API to reset all synchronizing profiles(off) & construct item_tbl from service for in case
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_DA_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e reset_synchronizing_profiles();
+
+/**
+ * @par Description: API to refresh from service for all contents type
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, account id
+ *
+ * @return true on success,
+ * false on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+bool refresh_from_service_all(int account_id);
+
+/**
+ * @par Description: API to cancel connection during sync session
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return SE_INTERNAL_OK on success
+ * SE_INTERNAL_DA_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+se_error_type_e cancel_sync_request();
+
+#endif /* SYNCENGINE_H_ */
diff --git a/oma-ds b/oma-ds
new file mode 100755
index 0000000..893ebdb
--- /dev/null
+++ b/oma-ds
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+DESC="OMA DS agent daemon"
+NAME=oma-ds-agent
+DAEMON=/usr/bin/$NAME
+SCRIPTNAME=/etc/init.d/oma-ds
+
+[ -x "$DAEMON" ] || exit 0
+
+do_start() {
+ PID=`pidof $NAME`
+ [ -z "$PID" ] || return 1
+ $DAEMON
+ RETVAL=$?
+ return "$RETVAL"
+}
+
+do_stop() {
+ PID=`pidof $NAME`
+ if [ -n "$PID" ]; then
+ kill $PID
+ fi
+ return 0
+}
+
+prt_res() {
+ RETVAL=$1
+
+ case "$RETVAL" in
+ 0|1)
+ echo "... done."
+ RETVAL=0
+ ;;
+ *)
+ echo "... failed!"
+ RETVAL=1
+ ;;
+ esac
+
+ return $RETVAL
+}
+
+case "$1" in
+ start)
+ echo "Starting $DESC" "$NAME"
+ if [ -f /opt/usr/data/oma-ds/.oma-ds-agent-enabled ]; then
+ do_start
+ prt_res $?
+ else
+ echo "don't exist oma-ds-agent enabled file"
+ prt_res $?
+ fi
+ ;;
+ stop)
+ echo "Stopping $DESC" "$NAME"
+ do_stop
+ prt_res $?
+ ;;
+ restart)
+ echo "Stopping $DESC" "$NAME"
+ do_stop
+ prt_res $?
+ sleep 2
+ echo "Starting $DESC" "$NAME"
+ do_start
+ prt_res $?
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
+ exit 3
+ ;;
+esac
+
diff --git a/oma-ds-agent.manifest b/oma-ds-agent.manifest
new file mode 100644
index 0000000..f415759
--- /dev/null
+++ b/oma-ds-agent.manifest
@@ -0,0 +1,18 @@
+<manifest>
+ <define>
+ <domain name="oma-ds-agent" />
+ <provide>
+ <label name="oma-ds-agent::cfg" />
+ <label name="oma-ds-agent::db" />
+ </provide>
+ </define>
+ <assign>
+ <filesystem path="/usr/share/oma-ds-cfg/eventconfig_omads" label="oma-ds-agent::cfg"/>
+ <filesystem path="/usr/share/oma-ds-cfg/noticonfig_omads" label="oma-ds-agent::cfg"/>
+ <filesystem path="/usr/share/oma-ds-cfg/omadsUI_fw_config.xml" label="oma-ds-agent::cfg"/>
+ <filesystem path="/usr/share/oma-ds-cfg/omads_fw_config.xml" label="oma-ds-agent::cfg"/>
+ </assign>
+ <request>
+ <domain name="oma-ds-agent" />
+ </request>
+</manifest>
diff --git a/oma-ds-cfg/eventconfig_omads b/oma-ds-cfg/eventconfig_omads
new file mode 100644
index 0000000..f8988c5
--- /dev/null
+++ b/oma-ds-cfg/eventconfig_omads
@@ -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/oma-ds-cfg/noticonfig_omads b/oma-ds-cfg/noticonfig_omads
new file mode 100644
index 0000000..389f69f
--- /dev/null
+++ b/oma-ds-cfg/noticonfig_omads
@@ -0,0 +1,2 @@
+1, 0, 0, 30, sessionprocess
+2, 0, 0, 30, processupdate \ No newline at end of file
diff --git a/oma-ds-cfg/omadsUI_fw_config.xml b/oma-ds-cfg/omadsUI_fw_config.xml
new file mode 100644
index 0000000..f140050
--- /dev/null
+++ b/oma-ds-cfg/omadsUI_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omads_ui</Agent-Key>
+ <Event>
+ <Event-Key>omads</Event-Key>
+ <Event-Config>/usr/share/oma-ds-cfg/eventconfig_omads</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omads</Noti-Key>
+ <Noti-Config>/usr/share/oma-ds-cfg/noticonfig_omads</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-ds-cfg/omads_fw_config.xml b/oma-ds-cfg/omads_fw_config.xml
new file mode 100644
index 0000000..96efbba
--- /dev/null
+++ b/oma-ds-cfg/omads_fw_config.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omads</Agent-Key>
+ <MainLoop>1</MainLoop>
+ <Event>
+ <Event-Key>omads</Event-Key>
+ <Event-Config>/usr/share/oma-ds-cfg/eventconfig_omads</Event-Config>
+ <RunEventHandler>1</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omads</Noti-Key>
+ <Noti-Config>/usr/share/oma-ds-cfg/noticonfig_omads</Noti-Config>
+ </Noti>
+ <EngineController>
+ <Max-Thread>5</Max-Thread>
+ </EngineController>
+ <FrameworkDB use="1">
+ <Path>/opt/dbspace/.omasyncagent.db</Path>
+ </FrameworkDB>
+ <ID-Provider>
+ <Code>1</Code>
+ <MaxID>4000000000</MaxID>
+ <PageSize>5</PageSize>
+ </ID-Provider>
+ <PlugIn-Mgr>
+ <Domain name="DataConnector" count="4">
+ <Plug-In>
+ <ID>0</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-da-contact.so</Path>
+ <Description>SLP Contact Access PlugIn</Description>
+ <DataConverter-PlugIn>1</DataConverter-PlugIn>
+ <Handle-ChangeNoti>1</Handle-ChangeNoti>
+ <Use-MainLoop>1</Use-MainLoop>
+ </Plug-In>
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/common-public/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>
+ <Plug-In>
+ <ID>2</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-da-memo.so</Path>
+ <Description>SLP Memo Access PlugIn</Description>
+ <DataConverter-PlugIn>3</DataConverter-PlugIn>
+ <Handle-ChangeNoti>1</Handle-ChangeNoti>
+ <Use-MainLoop>1</Use-MainLoop>
+ </Plug-In>
+ <Plug-In>
+ <ID>3</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-da-call-log.so</Path>
+ <Description>SLP Calllog Access PlugIn</Description>
+ <DataConverter-PlugIn>4</DataConverter-PlugIn>
+ <Handle-ChangeNoti>0</Handle-ChangeNoti>
+ <Use-MainLoop>0</Use-MainLoop>
+ </Plug-In>
+ </Domain>
+ <Domain name="DataConverter" count="4">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/ds-public/libplugin-dc-vcard.so</Path>
+ <Description>SLP Contact Converter</Description>
+ </Plug-In>
+ <Plug-In>
+ <ID>2</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-dc-vcalendar.so</Path>
+ <Description>SLP Calendar Converter</Description>
+ </Plug-In>
+ <Plug-In>
+ <ID>3</ID>
+ <Path>/usr/lib/sync-agent/ds-public/libplugin-dc-plain-text.so</Path>
+ <Description>SLP Memo Converter</Description>
+ </Plug-In>
+ <Plug-In>
+ <ID>4</ID>
+ <Path>/usr/lib/sync-agent/ds-public/libplugin-dc-xcalllog.so</Path>
+ <Description>SLP Calllog Converter</Description>
+ </Plug-In>
+ </Domain>
+ <Domain name="Account" count="1">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-account.so</Path>
+ <Description>SLP Account Accessor</Description>
+ </Plug-In>
+ </Domain>
+ <Domain name="NetworkAccess" count="1">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-na-http.so</Path>
+ <Description>Http Protocol</Description>
+ <UseNetwork>1</UseNetwork>
+ </Plug-In>
+ </Domain>
+ <Domain name="DeviceInfo" count="1">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-di-slp-device.so</Path>
+ <Description>SLP Device Accessor</Description>
+ </Plug-In>
+ </Domain>
+ <Domain name="PlatformMonitor" count="3">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-pm-slp-sysnoti-alarm.so</Path>
+ <Description>monitoring Alarm Event from SLP Platform</Description>
+ <Use-MainLoop>1</Use-MainLoop>
+ <Register-Data count="1">
+ <Data>
+ <Pkg-Name>oma-ds-agent</Pkg-Name>
+ <Additional-Data>-</Additional-Data>
+ </Data>
+ </Register-Data>
+ </Plug-In>
+ <Plug-In>
+ <ID>2</ID>
+ <Path>/usr/lib/sync-agent/common-public/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>
+ <Plug-In>
+ <ID>3</ID>
+ <Path>/usr/lib/sync-agent/common-public/libplugin-pm-slp-sysnoti-wap-push.so</Path>
+ <Description>monitoring WAP Push Event from SLP Platform</Description>
+ <Use-MainLoop>1</Use-MainLoop>
+ <Register-Data count="0">-</Register-Data>
+ </Plug-In>
+ </Domain>
+ </PlugIn-Mgr>
+</INIT>
diff --git a/packaging/oma-ds-agent.spec b/packaging/oma-ds-agent.spec
new file mode 100755
index 0000000..1782263
--- /dev/null
+++ b/packaging/oma-ds-agent.spec
@@ -0,0 +1,117 @@
+Name: oma-ds-agent
+Summary: oma-ds-agent daemon for data sync
+Version: 0.1.6
+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(libsoup-2.4)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(sync-agent)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(libwbxml2)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(check)
+BuildRequires: pkgconfig(memo)
+BuildRequires: pkgconfig(contacts-service2)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(aul)
+BuildRequires: expat-devel
+BuildRequires: cmake
+
+
+%description
+oma-ds-agent daemon (development headers)
+
+%package -n ds-public-plugins
+Summary: DS Public Plugins
+Group: TO_BE_FILLED
+
+%description -n ds-public-plugins
+ds public 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
+if [ ! -d /opt/dbspace ]
+then
+ mkdir /opt/dbspace
+fi
+if [ ! -d /etc/rc.d/rc3.d ]
+then
+ mkdir /etc/rc.d/rc3.d
+fi
+if [ ! -d /etc/rc.d/rc5.d ]
+then
+ mkdir /etc/rc.d/rc5.d
+fi
+
+ln -s /etc/init.d/oma-ds /etc/rc.d/rc3.d/S91oma-ds-agent
+ln -s /etc/init.d/oma-ds /etc/rc.d/rc5.d/S91oma-ds-agent
+
+sqlite3 /opt/dbspace/.omasyncagent.db "PRAGMA journal_mode = PERSIST; create table a(a); drop table a;" > /dev/null
+
+chmod 600 /opt/dbspace/.omasyncagent.db
+chmod 600 /opt/dbspace/.omasyncagent.db-journal
+
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+ chsmack -a oma-ds-agent::db /opt/dbspace/.omasyncagent.db
+ chsmack -a oma-ds-agent::db /opt/dbspace/.omasyncagent.db-journal
+fi
+
+#/etc/init.d/oma-ds start
+
+
+%preun
+/etc/init.d/oma-ds stop
+
+
+%postun
+
+rm -f /tmp/agent_fw_event_omads*
+rm -f /tmp/agent_fw_noti_reply_omads*
+
+rm -f /etc/rc.d/rc3.d/S91oma-ds-agent
+rm -f /etc/rc.d/rc5.d/S91oma-ds-agent
+
+rm -f /opt/dbspace/.omasyncagent.db /opt/dbspace/.omasyncagent.db-journal
+
+rm -rf /usr/share/oma-ds-cfg
+
+
+%files
+%manifest oma-ds-agent.manifest
+%defattr(-,root,root,-)
+/usr/share/dbus-1/services/*
+/usr/bin/oma-ds-agent
+
+/usr/share/oma-ds-cfg/*
+
+%defattr(700,root,root)
+/etc/init.d/oma-ds
+
+%files -n ds-public-plugins
+%manifest ds-public-plugins.manifest
+%defattr(-,root,root,-)
+/usr/lib/sync-agent/ds-public/*
diff --git a/src/agent/CMakeLists.txt b/src/agent/CMakeLists.txt
new file mode 100755
index 0000000..64fb834
--- /dev/null
+++ b/src/agent/CMakeLists.txt
@@ -0,0 +1,80 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set a name for the entire project
+PROJECT(oma-ds)
+
+# set variables
+SET(EXENAME "${PROJECT_NAME}-agent")
+SET(BINDIR "${PREFIX}/bin")
+SET(OMADS_SRC_DIR "${CMAKE_SOURCE_DIR}/src/agent")
+SET(OMADS_COMPONETS "main;common;framework/san-parser;framework/event;framework/task;service-adapter;service-adapter/network-binder;service-adapter/protocol-binder;service-engine")
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(LPKGS REQUIRED
+ glib-2.0
+ libsoup-2.4
+ sqlite3
+ sync-agent
+ vconf
+ libwbxml2
+ dlog
+ aul
+ dbus-glib-1
+ )
+
+#############################################
+#
+# 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(OMADS_COMPONET ${OMADS_COMPONETS})
+ AUX_SOURCE_DIRECTORY(${OMADS_SRC_DIR}/${OMADS_COMPONET} SRCS)
+ENDFOREACH(OMADS_COMPONET)
+
+# add internal include directories to the build.
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/san-parser)
+
+# 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 oma ds configuration files
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/oma-ds-cfg DESTINATION /usr/share)
+
+# install oma ds dbus file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/com.samsung.omadsagent.service DESTINATION /usr/share/dbus-1/services)
+
+# install booting script file
+INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/${PROJECT_NAME} DESTINATION /etc/init.d/)
+
diff --git a/src/agent/common/common_define.c b/src/agent/common/common_define.c
new file mode 100755
index 0000000..3954bb4
--- /dev/null
+++ b/src/agent/common/common_define.c
@@ -0,0 +1,750 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Define_Internal.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of defined Common structure
+ */
+
+#include <sync_agent.h>
+
+#include "common/common_define.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+datastore_s *datastoreinfo_per_content_type[4];
+
+datastore_info_s *create_datastore_info(char *target, char *source)
+{
+ _EXTERN_FUNC_ENTER;
+
+ datastore_info_s *datastore_info = (datastore_info_s *) calloc(1, sizeof(datastore_info_s));
+ retvm_if(datastore_info == NULL, NULL, "datastore_info is NULL");
+
+ if (target != NULL)
+ datastore_info->target = strdup(target);
+ if (source != NULL)
+ datastore_info->source = strdup(source);
+
+ _EXTERN_FUNC_EXIT;
+
+ return datastore_info;
+}
+
+void free_datastore_infos(GList * datastore_infos)
+{
+ _EXTERN_FUNC_ENTER;
+ retm_if(datastore_infos == NULL, "List is NULL");
+
+ GList *iter = NULL;
+ for (iter = datastore_infos; iter != NULL; iter = g_list_next(iter))
+ free_datastore_info(iter->data);
+
+ g_list_free(datastore_infos);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_datastore_info(datastore_info_s * datastore_info)
+{
+ _EXTERN_FUNC_ENTER;
+ retm_if(datastore_info == NULL, "pDatastoreInfo is NULL");
+
+ if (datastore_info->target != NULL) {
+ free(datastore_info->target);
+ datastore_info->target = NULL;
+ }
+
+ if (datastore_info->source != NULL) {
+ free(datastore_info->source);
+ datastore_info->source = NULL;
+ }
+
+ if (datastore_info->last_anchor != NULL) {
+ free(datastore_info->last_anchor);
+ datastore_info->last_anchor = NULL;
+ }
+
+ if (datastore_info->next_anchor != NULL) {
+ free(datastore_info->next_anchor);
+ datastore_info->next_anchor = NULL;
+ }
+
+ free(datastore_info);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_info_sync_type(datastore_info_s * datastore_info, alert_type_e sync_type)
+{
+ _EXTERN_FUNC_ENTER;
+ if (datastore_info != NULL)
+ datastore_info->sync_type = sync_type;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_info_last_anchor(datastore_info_s * datastore_info, char *last_anchor)
+{
+ _EXTERN_FUNC_ENTER;
+ if (datastore_info != NULL) {
+ if (last_anchor != NULL)
+ datastore_info->last_anchor = strdup(last_anchor);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_info_next_anchor(datastore_info_s * datastore_info, char *next_anchor)
+{
+ _EXTERN_FUNC_ENTER;
+ if (datastore_info != NULL) {
+ if (next_anchor != NULL)
+ datastore_info->next_anchor = strdup(next_anchor);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_info_max_obj_size(datastore_info_s * datastore_info, unsigned int max_obj_size)
+{
+ _EXTERN_FUNC_ENTER;
+ if (datastore_info != NULL)
+ datastore_info->max_obj_size = max_obj_size;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+changed_item_s *create_changed_item(change_type_e type, char *luid)
+{
+ _EXTERN_FUNC_ENTER;
+
+ changed_item_s *changed_item = (changed_item_s *) calloc(1, sizeof(changed_item_s));
+ retvm_if(changed_item == NULL, NULL, "changed_item is NULL");
+
+ changed_item->change_type = type;
+
+ if (luid != NULL)
+ changed_item->luid = strdup(luid);
+
+ changed_item->content_type = NULL;
+
+ _EXTERN_FUNC_EXIT;
+
+ return changed_item;
+}
+
+void set_changed_item_content_type(changed_item_s * changed_item, char *content_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_item == NULL, "pChangedItem is NULL");
+
+ if (content_type != NULL)
+ changed_item->content_type = strdup(content_type);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_changed_item(changed_item_s * changed_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_item == NULL, "pChangedItem is NULL");
+
+ if (changed_item->luid != NULL) {
+ free(changed_item->luid);
+ changed_item->luid = NULL;
+ }
+
+ if (changed_item->content_type != NULL) {
+ free(changed_item->content_type);
+ changed_item->content_type = NULL;
+ }
+
+ if (changed_item->data != NULL) {
+ free(changed_item->data);
+ changed_item->data = NULL;
+ }
+
+ if (changed_item != NULL)
+ free(changed_item);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_changed_item_data(changed_item_s * changed_item, char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_item == NULL, "pChangedItem is NULL");
+
+ if (data != NULL)
+ changed_item->data = strdup(data);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_changed_item_index_of_datastore(changed_item_s * changed_item, unsigned int index_of_datastore)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_item == NULL, "changed_item is NULL");
+
+ changed_item->index_of_datastore = index_of_datastore;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+changed_datastore_s *create_changed_datastore(char *source, char *target, int has_number_of_changes, unsigned int number_of_changes)
+{
+ _EXTERN_FUNC_ENTER;
+
+ changed_datastore_s *changed_datastore = (changed_datastore_s *) calloc(1, sizeof(changed_datastore_s));
+ retvm_if(changed_datastore == NULL, NULL, "changed_datastore is NULL");
+
+ if (source != NULL)
+ changed_datastore->source = strdup(source);
+ if (target != NULL)
+ changed_datastore->target = strdup(target);
+
+ changed_datastore->need_sync_command = 1;
+ changed_datastore->number_of_changes = number_of_changes;
+ changed_datastore->has_number_of_changes = has_number_of_changes;
+
+ _EXTERN_FUNC_EXIT;
+
+ return changed_datastore;
+}
+
+void free_changed_datastores(GList * changed_datastores)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_datastores == NULL, "List is NULL");
+
+ GList *iter = NULL;
+ for (iter = changed_datastores; iter != NULL; iter = g_list_next(iter))
+ free_changed_datastore(iter->data);
+
+ g_list_free(changed_datastores);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_changed_datastore(changed_datastore_s * changed_datastore)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_datastore == NULL, "pChangedDatastore is NULL");
+
+ if (changed_datastore->source != NULL) {
+ free(changed_datastore->source);
+ changed_datastore->source = NULL;
+ }
+
+ if (changed_datastore->target != NULL) {
+ free(changed_datastore->target);
+ changed_datastore->target = NULL;
+ }
+
+ GList *iter = NULL;
+ for (iter = changed_datastore->change_item; iter != NULL; iter = g_list_next(iter))
+ free_changed_item(iter->data);
+
+ g_list_free(changed_datastore->change_item);
+ changed_datastore->change_item = NULL;
+
+ for (iter = changed_datastore->sent_item; iter != NULL; iter = g_list_next(iter))
+ free_changed_item(iter->data);
+
+ g_list_free(changed_datastore->sent_item);
+ changed_datastore->sent_item = NULL;
+
+ if (changed_datastore != NULL)
+ free(changed_datastore);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_changed_datastore_changed_item(changed_datastore_s * changed_datastore, GList * changed_items)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (changed_datastore != NULL)
+ changed_datastore->change_item = changed_items;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_changed_datastore_changed_item(changed_datastore_s * changed_datastore, changed_item_s * changed_item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(changed_datastore == NULL, "changed_datastore is NULL");
+
+ changed_datastore->change_item = g_list_append(changed_datastore->change_item, changed_item);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+applied_status_s *create_applied_status(char *luid, change_type_e change_type, int status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ applied_status_s *applied_status = (applied_status_s *) calloc(1, sizeof(applied_status_s));
+ retvm_if(applied_status == NULL, NULL, "appliedStatus is NULL");
+
+ if (luid != NULL)
+ applied_status->luid = strdup(luid);
+
+ applied_status->change_type = change_type;
+ applied_status->status = status;
+
+ _EXTERN_FUNC_EXIT;
+
+ return applied_status;
+}
+
+void free_applied_statuses(GList * applied_statuses)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(applied_statuses == NULL, "List is NULL");
+
+ GList *iter = NULL;
+ for (iter = applied_statuses; iter != NULL; iter = g_list_next(iter))
+ free_applied_status(iter->data);
+
+ g_list_free(applied_statuses);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_applied_status(applied_status_s * applied_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(applied_status == NULL, "List is NULL");
+
+ if (applied_status->luid != NULL) {
+ free(applied_status->luid);
+ applied_status->luid = NULL;
+ }
+
+ free(applied_status);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+sending_status_s *create_sending_status(char *source, char *target)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sending_status_s *sending_status = (sending_status_s *) calloc(1, sizeof(sending_status_s));
+ retvm_if(sending_status == NULL, NULL, "sending_status is NULL");
+
+ if (source != NULL)
+ sending_status->source = strdup(source);
+
+ if (target != NULL)
+ sending_status->target = strdup(target);
+
+ _EXTERN_FUNC_EXIT;
+
+ return sending_status;
+}
+
+void free_sending_statuses(GList * sending_statuses)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(sending_statuses == NULL, "List is NULL");
+
+ GList *iter = NULL;
+ for (iter = sending_statuses; iter != NULL; iter = g_list_next(iter))
+ free_sending_status(iter->data);
+
+ g_list_free(sending_statuses);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_sending_status(sending_status_s * sending_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(sending_status == NULL, "pSendingStatus is NULL");
+
+ if (sending_status->source != NULL) {
+ free(sending_status->source);
+ sending_status->source = NULL;
+ }
+
+ if (sending_status->target != NULL) {
+ free(sending_status->target);
+ sending_status->target = NULL;
+ }
+
+ GList *iter = NULL;
+ for (iter = sending_status->items; iter != NULL; iter = g_list_next(iter))
+ free_applied_status(iter->data);
+
+ g_list_free(sending_status->items);
+
+ free(sending_status);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_sending_status_applied_status(sending_status_s * sending_status, applied_status_s * applied_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(sending_status == NULL, "sending_status is NULL");
+
+ sending_status->items = g_list_append(sending_status->items, applied_status);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+datastore_s *create_datastore(char *target, char *source)
+{
+ _EXTERN_FUNC_ENTER;
+
+ datastore_s *datastore = (datastore_s *) calloc(1, sizeof(datastore_s));
+ retvm_if(datastore == NULL, NULL, "datastore is NULL");
+
+ if (target != NULL)
+ datastore->target = strdup(target);
+
+ if (source != NULL)
+ datastore->source = strdup(source);
+
+ _EXTERN_FUNC_EXIT;
+
+ return datastore;
+}
+
+void set_datastore_content_type_info(datastore_s * datastore, int datastore_id, int folder_type_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL) {
+ datastore->datastore_id = datastore_id;
+ datastore->folder_type_id = folder_type_id;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_account_info(datastore_s * datastore, char *account_id, char *account_pw)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL) {
+ if (account_id != NULL)
+ datastore->id = strdup(account_id);
+ if (account_pw != NULL)
+ datastore->pw = strdup(account_pw);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_client_sync_type(datastore_s * datastore, alert_type_e sync_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL)
+ datastore->client_sync_type = sync_type;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_server_sync_type(datastore_s * datastore, alert_type_e sync_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL)
+ datastore->server_sync_type = sync_type;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_client_anchor(datastore_s * datastore, char *last_anchor, char *next_anchor)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL) {
+ if (last_anchor != NULL)
+ datastore->last_anchor_client = strdup(last_anchor);
+ if (next_anchor != NULL)
+ datastore->next_anchor_client = strdup(next_anchor);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_datastore_server_anchor(datastore_s * datastore, char *last_anchor, char *next_anchor)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (datastore != NULL) {
+ if (last_anchor != NULL)
+ datastore->last_anchor_server = strdup(last_anchor);
+ if (next_anchor != NULL)
+ datastore->next_anchor_server = strdup(next_anchor);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+sync_result_s *create_sync_result()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_result_s *syncResult = calloc(1, sizeof(sync_result_s));
+ retvm_if(syncResult == NULL, NULL, "syncResult is NULL");
+
+ _EXTERN_FUNC_EXIT;
+
+ return syncResult;
+}
+
+sync_result_s *dup_sync_result(sync_result_s * org_sync_result)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(org_sync_result == NULL, NULL, "orgSyncResult is NULL");
+
+ sync_result_s *syn_cre_sult = calloc(1, sizeof(sync_result_s));
+ retvm_if(syn_cre_sult == NULL, NULL, "syn_cre_sult is NULL");
+
+ syn_cre_sult->session_result = org_sync_result->session_result;
+ syn_cre_sult->number_of_change = org_sync_result->number_of_change;
+ syn_cre_sult->received_count = org_sync_result->received_count;
+ syn_cre_sult->add_count = org_sync_result->add_count;
+ syn_cre_sult->replace_count = org_sync_result->replace_count;
+ syn_cre_sult->delete_count = org_sync_result->delete_count;
+
+ _EXTERN_FUNC_EXIT;
+
+ return syn_cre_sult;
+
+}
+
+void set_number_of_change(sync_result_s * sync_result, unsigned int number_of_change)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (sync_result != NULL)
+ sync_result->number_of_change = number_of_change;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_add_count(sync_result_s * sync_result, unsigned int add_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (sync_result != NULL)
+ sync_result->add_count += add_cnt;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_receive_count(sync_result_s * sync_result, unsigned int received_count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (sync_result != NULL)
+ sync_result->received_count += received_count;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_replace_count(sync_result_s * sync_result, unsigned int replace_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (sync_result != NULL)
+ sync_result->replace_count += replace_cnt;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void add_delete_count(sync_result_s * sync_result, unsigned int delete_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (sync_result != NULL)
+ sync_result->delete_count += delete_cnt;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_pre_sync_return_obj(pre_sync_return_obj_s * pre_sync_return_obj)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(pre_sync_return_obj == NULL, "pre_sync_return_obj is NULL");
+
+ GList *iter = NULL;
+ for (iter = pre_sync_return_obj->datastore_info; iter != NULL; iter = g_list_next(iter))
+ free_datastore_info(iter->data);
+ g_list_free(pre_sync_return_obj->datastore_info);
+ pre_sync_return_obj->datastore_info = NULL;
+
+ if (pre_sync_return_obj->dev_id != NULL) {
+ free(pre_sync_return_obj->dev_id);
+ pre_sync_return_obj->dev_id = NULL;
+ }
+
+ free(pre_sync_return_obj);
+ pre_sync_return_obj = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_sync_obj(sync_obj_s * sync_obj)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(sync_obj == NULL, "sync_obj is NULL");
+
+ GList *iter = NULL;
+ for (iter = sync_obj->changed_datastore; iter != NULL; iter = g_list_next(iter))
+ free_changed_datastore(iter->data);
+ g_list_free(sync_obj->changed_datastore);
+ sync_obj->changed_datastore = NULL;
+
+ for (iter = sync_obj->sending_status; iter != NULL; iter = g_list_next(iter))
+ free_sending_status(iter->data);
+ g_list_free(sync_obj->sending_status);
+ sync_obj->sending_status = NULL;
+
+ free(sync_obj);
+ sync_obj = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_sync_return_obj(sync_return_obj_s * sync_return_obj)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(sync_return_obj == NULL, "pSyncReturnObj is NULL");
+
+ GList *iter = NULL;
+ for (iter = sync_return_obj->changed_datastore; iter != NULL; iter = g_list_next(iter))
+ free_changed_datastore(iter->data);
+ g_list_free(sync_return_obj->changed_datastore);
+ sync_return_obj->changed_datastore = NULL;
+
+ for (iter = sync_return_obj->status; iter != NULL; iter = g_list_next(iter))
+ free_applied_status(iter->data);
+ g_list_free(sync_return_obj->status);
+ sync_return_obj->status = NULL;
+
+ free(sync_return_obj);
+ sync_return_obj = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_datastore(datastore_s * datastore)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(datastore == NULL, "pDatastore is NULL");
+
+ if (datastore->target != NULL) {
+ free(datastore->target);
+ datastore->target = NULL;
+ }
+
+ if (datastore->source != NULL) {
+ free(datastore->source);
+ datastore->source = NULL;
+ }
+
+ if (datastore->id != NULL) {
+ free(datastore->id);
+ datastore->id = NULL;
+ }
+
+ if (datastore->pw != NULL) {
+ free(datastore->pw);
+ datastore->pw = NULL;
+ }
+
+ if (datastore->last_anchor_client != NULL) {
+ free(datastore->last_anchor_client);
+ datastore->last_anchor_client = NULL;
+ }
+
+ if (datastore->next_anchor_client != NULL) {
+ free(datastore->next_anchor_client);
+ datastore->next_anchor_client = NULL;
+ }
+
+ if (datastore->last_anchor_server != NULL) {
+ free(datastore->last_anchor_server);
+ datastore->last_anchor_server = NULL;
+ }
+
+ if (datastore->next_anchor_server != NULL) {
+ free(datastore->next_anchor_server);
+ datastore->next_anchor_server = NULL;
+ }
+
+ if (datastore->client_sync_result != NULL)
+ free(datastore->client_sync_result);
+
+ if (datastore->server_sync_result != NULL)
+ free(datastore->server_sync_result);
+
+ free(datastore);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_sync_service(sync_service_s * category)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(category == NULL, "category is NULL");
+
+ if (category->src_uri != NULL)
+ free(category->src_uri);
+
+ if (category->tgt_uri != NULL)
+ free(category->tgt_uri);
+
+ if (category->id != NULL)
+ free(category->id);
+
+ if (category->password != NULL)
+ free(category->password);
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/common/common_util.c b/src/agent/common/common_util.c
new file mode 100755
index 0000000..7c1bb70
--- /dev/null
+++ b/src/agent/common/common_util.c
@@ -0,0 +1,281 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Util.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of utility function
+ */
+
+#include <sync_agent.h>
+
+#include "common/common_util.h"
+#include "common/common_define_internal.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+#define MAX_RETRY_COUNT 10
+
+bool create_config_str(int account_id, char *key, char *value, char *type, char *access_name, sync_agent_da_config_s ** config)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e da_err = SYNC_AGENT_DA_SUCCESS;
+
+ da_err = sync_agent_create_config(config);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_config is failed");
+ goto error;
+ }
+
+ (*config)->config_id = account_id;
+ (*config)->key = strdup(key);
+ (*config)->value = value != NULL ? strcmp(value, "") == 0 ? NULL : strdup(value) : NULL;
+ (*config)->type = strdup(type);
+ (*config)->access_name = strdup(access_name);
+
+ error:
+
+ _EXTERN_FUNC_EXIT;
+
+ if (da_err == SYNC_AGENT_DA_SUCCESS)
+ return true;
+ else
+ return false;
+
+}
+
+bool set_config_str(int accountID, char *key, char *value, char *type, char *access_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e result;
+ sync_agent_da_config_s config;
+
+ config.config_id = accountID;
+ config.key = key;
+ config.value = value != NULL ? strcmp(value, "") == 0 ? NULL : value : NULL;
+ config.type = type;
+ config.access_name = access_name;
+
+ result = sync_agent_update_config(&config);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == SYNC_AGENT_DA_SUCCESS)
+ return true;
+ else
+ return false;
+}
+
+bool set_config_int(int accountID, char *key, int value, char *type, char *access_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *value_str = NULL;
+ value_str = g_strdup_printf("%u", value);
+
+ sync_agent_da_return_e result;
+ sync_agent_da_config_s config;
+
+ config.config_id = accountID;
+ config.key = key;
+ config.value = value_str;
+ config.type = type;
+ config.access_name = access_name;
+
+ result = sync_agent_update_config(&config);
+
+ if (value_str != NULL)
+ free(value_str);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == SYNC_AGENT_DA_SUCCESS)
+ return true;
+ else
+ return false;
+}
+
+bool get_config(int account_id, char *key, char **value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_config_s *config = NULL;
+
+ *value = NULL;
+
+ result = sync_agent_create_config(&config);
+ if (result != SYNC_AGENT_DA_SUCCESS)
+ return false;
+
+ result = sync_agent_get_config(account_id, key, &config);
+ if (result == SYNC_AGENT_DA_SUCCESS) {
+ if (config != NULL) {
+ if (config->value != NULL) {
+ *value = strdup(config->value);
+ _DEBUG_INFO("value = %s", *value);
+ }
+ }
+ } else {
+ /* FIXME temporary solution
+ * Try MAX_RETRY_COUNT when fail to get_config
+ * */
+ int i;
+ bool success = false;
+ for (i = 0; i < MAX_RETRY_COUNT; i++) {
+ result = sync_agent_get_config(account_id, key, &config);
+ if (result == SYNC_AGENT_DA_SUCCESS) {
+ if (config != NULL) {
+ if (config->value != NULL) {
+ *value = strdup(config->value);
+ _DEBUG_INFO("value = %s", *value);
+ success = true;
+ break;
+ }
+ }
+ }
+ }
+ if (success == false) {
+ sync_agent_free_config(config);
+ _EXTERN_FUNC_EXIT;
+ return false;
+ }
+ }
+
+ sync_agent_free_config(config);
+ _EXTERN_FUNC_EXIT;
+ return true;
+}
+
+int get_account_id(char *profile, bool open)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(profile == NULL, -1, "profile is NULL");
+
+ int accountId = -1;
+ char *profileDirName = NULL;
+ bool result;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ if (open == false) {
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_open_agent");
+ goto error;
+ }
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto error;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+
+ if (profileDirName != NULL)
+ free(profileDirName);
+
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, &profileDirName);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_Config");
+ goto error;
+ }
+
+ _DEBUG_INFO("profileDirName = %s", profileDirName);
+ if (profileDirName == NULL)
+ continue;
+
+ if (strcmp(profile, profileDirName) == 0) {
+ _DEBUG_INFO("account_list[i] = %d", fw_account->account_id);
+ accountId = fw_account->account_id;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (profileDirName != NULL)
+ free(profileDirName);
+
+ if (open == false)
+ sync_agent_close_agent();
+
+ return accountId;
+}
+
+/*int convert_synctype_value(char *syncType_str)
+{
+ int syncType_value;
+
+ if (strcmp(syncType_str, DEFINE_ALERT_SLOW_SYNC_STR) ==0)
+ syncType_value = ALERT_SLOW_SYNC ;
+ else if (strcmp(syncType_str, DEFINE_ALERT_TWO_WAY_STR) ==0)
+ syncType_value = ALERT_TWO_WAY ;
+ else if (strcmp(syncType_str, DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR) ==0)
+ syncType_value = ALERT_ONE_WAY_FROM_CLIENT;
+ else if (strcmp(syncType_str, DEFINE_ALERT_ONE_WAY_FROM_SERVER_STR) ==0)
+ syncType_value = ALERT_ONE_WAY_FROM_SERVER;
+ else if (strcmp(syncType_str, DEFINE_ALERT_REFRESH_FROM_SERVER_STR) ==0)
+ syncType_value = ALERT_REFRESH_FROM_SERVER;
+ else if (strcmp(syncType_str, DEFINE_ALERT_REFRESH_FROM_CLIENT_STR) ==0)
+ syncType_value = ALERT_REFRESH_FROM_CLIENT;
+ else
+ syncType_value = ALERT_UNKNOWN;
+
+ return syncType_value;
+}*/
+
+/*char *convert_synctype_str(char *syncType_value)
+{
+ char *syncType_str = NULL;
+
+ if (strcmp(syncType_value, DEFINE_ALERT_SLOW_SYNC_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_SLOW_SYNC_STR;
+ else if (strcmp(syncType_value, DEFINE_ALERT_TWO_WAY_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_TWO_WAY_STR;
+ else if (strcmp(syncType_value, DEFINE_ALERT_ONE_WAY_FROM_CLIENT_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR;
+ else if (strcmp(syncType_value, DEFINE_ALERT_ONE_WAY_FROM_CLIENT_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_ONE_WAY_FROM_SERVER_STR;
+ else if (strcmp(syncType_value, DEFINE_ALERT_REFRESH_FROM_SERVER_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_REFRESH_FROM_SERVER_STR;
+ else if (strcmp(syncType_value, DEFINE_ALERT_REFRESH_FROM_CLIENT_VALUE) ==0)
+ syncType_str = DEFINE_ALERT_REFRESH_FROM_CLIENT_STR;
+ else
+ syncType_str = DEFINE_ALERT_SLOW_SYNC_STR;
+
+ return syncType_str;
+}*/
diff --git a/src/agent/common/common_vconf.c b/src/agent/common/common_vconf.c
new file mode 100755
index 0000000..e874d37
--- /dev/null
+++ b/src/agent/common/common_vconf.c
@@ -0,0 +1,191 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @Common_Util.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of wrapping vconf function
+ */
+
+#include <vconf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <string.h>
+
+#include <sync_agent.h>
+
+#include "common/common_vconf.h"
+
+char *get_vconf_str(char *base_key, char *key)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char path[128];
+ char *value = NULL;
+
+ snprintf(path, sizeof(path), "%s%s", base_key, key);
+ value = vconf_get_str(path);
+
+ if (value != NULL) {
+ if (strcmp(value, "") == 0) {
+
+ if (value != NULL)
+ free(value);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return value;
+ }
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+
+}
+
+char *get_vconf_str_key(char *key)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *value = NULL;
+ value = vconf_get_str(key);
+
+ if (value != NULL) {
+ if (strcmp(value, "") == 0) {
+
+ if (value != NULL)
+ free(value);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return value;
+ }
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+}
+
+bool get_vconf_int(char *base_key, char *key, int *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char path[128];
+ int temp = 0;
+ int result;
+
+ snprintf(path, sizeof(path), "%s%s", base_key, key);
+ result = vconf_get_int(path, &temp);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0) {
+ *value = temp;
+ return true;
+ } else
+ return false;
+}
+
+bool get_vconf_int_key(char *key, int *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int temp = 0;
+ int result;
+
+ result = vconf_get_int(key, &temp);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0) {
+ *value = temp;
+ return true;
+ } else
+ return false;
+}
+
+bool set_vconf_str(char *base_key, char *key, char *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char path[128];
+ int result;
+
+ snprintf(path, sizeof(path), "%s%s", base_key, key);
+ result = vconf_set_str(path, value);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0)
+ return true;
+ else
+ return false;
+}
+
+bool set_vconf_str_key(char *key, char *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result;
+ result = vconf_set_str(key, value);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0)
+ return true;
+ else
+ return false;
+}
+
+bool set_vconf_int(char *base_key, char *key, int value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char path[128];
+ int result;
+
+ snprintf(path, sizeof(path), "%s%s", base_key, key);
+ result = vconf_set_int(path, value);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0)
+ return true;
+ else
+ return false;
+}
+
+bool set_vconf_int_key(char *key, int value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result;
+
+ result = vconf_set_int(key, value);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (result == 0)
+ return true;
+ else
+ return false;
+}
diff --git a/src/agent/framework/event/oma_ds_event_handler.c b/src/agent/framework/event/oma_ds_event_handler.c
new file mode 100755
index 0000000..01d5102
--- /dev/null
+++ b/src/agent/framework/event/oma_ds_event_handler.c
@@ -0,0 +1,908 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Event_Handler.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of event callback function(from ui)
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sync_agent.h>
+
+#include "framework/event/oma_ds_event_handler.h"
+#include "framework/event/oma_ds_platform_event_handler.h"
+#include "framework/task/oma_ds_engine_controller_task.h"
+#include "common/common_define.h"
+#include "common/common_vconf.h"
+#include "common/common_util.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+#define NOTI_KEY "OMADS"
+
+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);
+
+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)
+{
+ _INNER_FUNC_ENTER;
+
+ unsigned int request_msg_id_to_cancel = 0;
+ get_manual_sync_request_id(&request_msg_id_to_cancel);
+
+ _INNER_FUNC_EXIT;
+}
+
+int event_callback_add_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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;
+ int result = 0;
+ int account_id;
+
+ GList *categorys = NULL;
+ GList *iter = NULL;
+
+ 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);
+
+ /*
+ _DEBUG_INFO("request param : %s", profile_dir_name);
+ _DEBUG_INFO("request param : %s", profile_name);
+ _DEBUG_INFO("request param : %s", addr);
+ _DEBUG_INFO("request param : %s", id);
+ _DEBUG_INFO("request param : %s", password);
+ _DEBUG_INFO("request param : %s", sync_mode);
+ _DEBUG_INFO("request param : %s", sync_type);
+ _DEBUG_INFO("request param : %s", interval);
+ _DEBUG_INFO("request param : %d", category_count);
+ */
+
+ int i = 0;
+ for (; i < category_count; i++) {
+ sync_service_s *category = (sync_service_s *) calloc(1, sizeof(sync_service_s));
+ if (category == NULL) {
+ _DEBUG_ERROR("category is NULL !");
+
+ if (profile_dir_name != NULL)
+ free(profile_dir_name);
+
+ if (profile_name != NULL)
+ free(profile_name);
+
+ if (addr != NULL)
+ free(addr);
+
+ if (id != NULL)
+ free(id);
+
+ if (password != NULL)
+ free(password);
+
+ if (sync_mode != NULL)
+ free(sync_mode);
+
+ if (sync_type != NULL)
+ free(sync_type);
+
+ if (interval != NULL)
+ free(interval);
+
+ return 0;
+ }
+
+ 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));
+
+ categorys = g_list_append(categorys, category);
+
+ /*
+ _DEBUG_INFO("category[i]->content_type : %d", category->content_type);
+ _DEBUG_INFO("category[i]->enabled : %d", category->enabled);
+ _DEBUG_INFO("category[i]->srcURI : %s", category->src_uri);
+ _DEBUG_INFO("category[i]->tgtURI : %s", category->tgt_uri);
+ _DEBUG_INFO("category[i]->id : %s", category->id);
+ _DEBUG_INFO("category[i]->password : %s", category->password);
+ */
+ }
+
+ /* send to engine controller */
+ void *in_param_value_array[9] = { &profile_dir_name, &profile_name, &addr, &id, &password, &sync_mode, &sync_type, &interval, &categorys };
+ int in_param_index_array[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+ sync_agent_ec_value_type_e in_param_value_type_array[9] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
+ SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
+ SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
+ };
+ unsigned int request_msg_id = 0;
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE, 0, 9, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &account_id);
+
+ 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, &account_id);
+
+ for (iter = categorys; iter != NULL; iter = g_list_next(iter)) {
+ sync_service_s *category = (sync_service_s *) iter->data;
+
+ if (category != NULL)
+ free_sync_service(category);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_edit_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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;
+ int result = 0;
+
+ GList *categorys = NULL;
+ GList *iter = NULL;
+
+ sync_agent_get_event_data_param(request, &profile_dir_name);
+ if (profile_dir_name == NULL) {
+ _DEBUG_ERROR("profile_dir_name is not defined");
+ result = 0;
+ goto error;
+ }
+ _DEBUG_INFO("request param : %s", profile_dir_name);
+
+ int account_id = get_account_id(profile_dir_name, false);
+
+ 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);
+
+ _DEBUG_INFO("request param : %s", profile_name);
+ _DEBUG_INFO("request param : %s", addr);
+ _DEBUG_INFO("request param : %s", id);
+ _DEBUG_INFO("request param : %s", password);
+ _DEBUG_INFO("request param : %s", sync_mode);
+ _DEBUG_INFO("request param : %s", sync_type);
+ _DEBUG_INFO("request param : %s", interval);
+ _DEBUG_INFO("request param : %d", category_count);
+
+ int i = 0;
+ for (; i < category_count; i++) {
+ sync_service_s *category = (sync_service_s *) calloc(1, sizeof(sync_service_s));
+ if (category == NULL) {
+ _DEBUG_ERROR("category is NULL !");
+
+ if (profile_dir_name != NULL)
+ free(profile_dir_name);
+
+ if (profile_name != NULL)
+ free(profile_name);
+
+ if (addr != NULL)
+ free(addr);
+
+ if (id != NULL)
+ free(id);
+
+ if (password != NULL)
+ free(password);
+
+ if (sync_mode != NULL)
+ free(sync_mode);
+
+ if (sync_type != NULL)
+ free(sync_type);
+
+ if (interval != NULL)
+ free(interval);
+
+ return 0;
+ }
+
+ 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));
+
+ categorys = g_list_append(categorys, category);
+
+ _DEBUG_INFO("category[i]->content_type : %d", category->service_type);
+ _DEBUG_INFO("category[i]->enabled : %d", category->enabled);
+ _DEBUG_INFO("category[i]->srcURI : %s", category->src_uri);
+ _DEBUG_INFO("category[i]->tgtURI : %s", category->tgt_uri);
+ _DEBUG_INFO("category[i]->id : %s", category->id);
+ _DEBUG_INFO("category[i]->password : %s", category->password);
+ }
+
+ /* send to engine controller */
+ void *in_param_value_array[9] = { &account_id, &profile_name, &addr, &id, &password, &sync_mode, &sync_type, &interval, &categorys };
+ int in_param_index_array[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+ sync_agent_ec_value_type_e in_param_value_type_array[9] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
+ SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
+ SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
+ };
+ unsigned int request_msg_id = 0;
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE, 0, 9, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+
+ error:
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ for (iter = categorys; iter != NULL; iter = g_list_next(iter)) {
+ sync_service_s *category = (sync_service_s *) iter->data;
+
+ if (category != NULL)
+ free_sync_service(category);
+ }
+
+ if (profile_dir_name != NULL)
+ free(profile_dir_name);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_delete_profile_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ int count;
+ sync_agent_get_event_data_param(request, &count);
+ GList *profiles = NULL;
+ int *account_id = 0;
+
+ int i;
+ char *profile = NULL;
+ for (i = 0; i < count; i++) {
+ if (profile != NULL) {
+ free(profile);
+ profile = NULL;
+ }
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+ _DEBUG_INFO("request param : %s", profile);
+
+ account_id = (int *)calloc(1, sizeof(int));
+ if (account_id == NULL) {
+ _DEBUG_ERROR("account_id is NULL");
+ result = 0;
+ goto error;
+ }
+
+ *account_id = get_account_id(profile, false);
+
+ profiles = g_list_append(profiles, account_id);
+ }
+
+ /* send to engine controller */
+ void *in_param_value_array[1] = { &profiles };
+ int in_param_index_array[1] = { 0 };
+ sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT };
+ unsigned int request_msg_id = 0;
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+
+ error:
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ if (profile != NULL)
+ free(profile);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_request_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+ char *profile = NULL;
+ int result = 0;
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+ _DEBUG_INFO("request param : %s", profile);
+
+ 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);
+
+ insert_request_msg_info(SYNC_MODE_MANUAL, request_msg_id);
+
+ error:
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ if (profile != NULL)
+ free(profile);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_cancel_sync_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+ char *profile = NULL;
+ int result = 0;
+ bool res;
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+
+ _DEBUG_INFO("request param : %s", profile);
+
+ res = cancel_current_sync_task();
+ if (res == true)
+ result = 1;
+ else
+ result = 0;
+
+ error:
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ if (profile != NULL)
+ free(profile);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_get_profile_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ char *profile = 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 last_session_status = 0;
+ int last_session_time = 0;
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+
+ _DEBUG_INFO("request param : %s", profile);
+
+ int account_id = get_account_id(profile, false);
+
+ int in_param_index_array[1] = { 0 };
+ void *in_param_value_array[1] = { &account_id };
+ sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_DATA, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profile_name);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+ sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &sync_mode);
+ sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &sync_type);
+ sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
+ sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_status);
+ sync_agent_get_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_time);
+
+ error:
+
+ 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 *)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);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_get_profile_sync_category_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+ char *profile = NULL;
+ int content_type = 0;
+ int enabled = 0;
+ char *srcURI = NULL;
+ char *tgtURI = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ int result = 0;
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+
+ sync_agent_get_event_data_param(request, &content_type);
+
+ _DEBUG_INFO("request param : %s", profile);
+ _DEBUG_INFO("request param : %d", content_type);
+
+ int account_id = get_account_id(profile, false);
+ _DEBUG_INFO(" account_id: %d", account_id);
+
+ int in_param_index_array[2] = { 0, 1 };
+ void *in_param_value_array[2] = { &account_id, &content_type };
+ sync_agent_ec_value_type_e in_param_value_type_array[2] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_INT };
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY, 0, 2, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &srcURI);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+
+ /*
+ _DEBUG_INFO("result = %d", result);
+ _DEBUG_INFO("enabled = %d", enabled);
+ _DEBUG_INFO("srcURI = %s", srcURI);
+ _DEBUG_INFO("tgtURI = %s", tgtURI);
+ _DEBUG_INFO("id = %s", id);
+ _DEBUG_INFO("password = %s", password);
+ */
+
+ 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, &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);
+
+ error:
+
+ if (profile != NULL)
+ free(profile);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_get_profile_last_statistics_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *profile = NULL;
+ int content_type = 0;
+ char *dbSynced = "NO";
+ int last_session_time = -1;
+ 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;
+ int result = 0;
+
+ sync_agent_get_event_data_param(request, &profile);
+ if (profile == NULL) {
+ _DEBUG_ERROR("profile is not defined");
+ result = 0;
+ goto error;
+ }
+
+ sync_agent_get_event_data_param(request, &content_type);
+
+ _DEBUG_INFO("request param : %s", profile);
+ _DEBUG_INFO("request param : %d", content_type);
+
+ int account_id = get_account_id(profile, false);
+
+ int in_param_index_array[2] = { 0, 1 };
+ void *in_param_value_array[2] = { &account_id, &content_type };
+ sync_agent_ec_value_type_e in_param_value_type_array[2] = { SYNC_AGENT_EC_VALUE_TYPE_INT, SYNC_AGENT_EC_VALUE_TYPE_INT };
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS, 0, 2, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &dbSynced);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &last_session_time);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_Total);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfAdd);
+ sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfDelete);
+ sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfReplace);
+ sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_Total);
+ sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfAdd);
+ sync_agent_get_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOrDelete);
+ sync_agent_get_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfReplace);
+
+ /*
+ _DEBUG_INFO("result = %d", result);
+ _DEBUG_INFO("dbSynced = %s\n", dbSynced);
+ _DEBUG_INFO("last_session_time = %d\n", last_session_time);
+ _DEBUG_INFO("server2Client_Total = %d\n", server2Client_Total);
+ _DEBUG_INFO("server2Client_NrOfAdd = %d\n", server2Client_NrOfAdd);
+ _DEBUG_INFO("server2Client_NrOfDelete = %d\n", server2Client_NrOfDelete);
+ _DEBUG_INFO("server2Client_NrOfReplace = %d\n", server2Client_NrOfReplace);
+ _DEBUG_INFO("client2Server_Total = %d\n", client2Server_Total);
+ _DEBUG_INFO("client2Server_NrOfAdd = %d\n", client2Server_NrOfAdd);
+ _DEBUG_INFO("client2Server_NrOrDelete = %d\n", client2Server_NrOrDelete);
+ _DEBUG_INFO("client2Server_NrOfReplace = %d\n", client2Server_NrOfReplace);
+ */
+
+ error:
+
+ 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 *)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);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_add_profile_cp_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *profile_name = NULL;
+ char *addr = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ int category_count;
+ int result = 0;
+ int account_id;
+
+ 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, &category_count);
+
+ /*
+ _DEBUG_INFO("request param : %s", profile_name);
+ _DEBUG_INFO("request param : %s", addr);
+ _DEBUG_INFO("request param : %s", id);
+ _DEBUG_INFO("request param : %s", password);
+ _DEBUG_INFO("request param : %d", category_count);
+ */
+
+ GList *categorys = NULL;
+ int i = 0;
+ for (; i < category_count; i++) {
+ resource_cp_s *category = (resource_cp_s *) calloc(1, sizeof(resource_cp_s));
+ if (category == NULL) {
+ _DEBUG_ERROR("category is NULL !");
+
+ if (profile_name != NULL)
+ free(profile_name);
+
+ if (addr != NULL)
+ free(addr);
+
+ if (id != NULL)
+ free(id);
+
+ if (password != NULL)
+ free(password);
+
+ return 0;
+ }
+
+ sync_agent_get_event_data_param(request, &(category->name));
+ sync_agent_get_event_data_param(request, &(category->accept));
+ sync_agent_get_event_data_param(request, &(category->id));
+ sync_agent_get_event_data_param(request, &(category->password));
+ sync_agent_get_event_data_param(request, &(category->auth_type));
+ sync_agent_get_event_data_param(request, &(category->auth_data));
+
+ categorys = g_list_append(categorys, category);
+
+ /*
+ _DEBUG_INFO("category[%d]->name : %s", i, category->name);
+ _DEBUG_INFO("category[%d]->accept : %s", i, category->accept);
+ _DEBUG_INFO("category[%d]->id : %s", i, category->id);
+ _DEBUG_INFO("category[%d]->password : %s", i, category->password);
+ _DEBUG_INFO("category[%d]->authType : %s", i, category->auth_type);
+ _DEBUG_INFO("category[%d]->authData : %s\n", i, category->auth_data);
+ */
+ }
+
+ /* send to engine controller */
+ void *in_param_value_array[5] = { &profile_name, &addr, &id, &password, &categorys };
+ int in_param_index_array[5] = { 0, 1, 2, 3, 4 };
+ sync_agent_ec_value_type_e in_param_value_type_array[5] = { SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT,
+ SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT, SYNC_AGENT_EC_VALUE_TYPE_STRUCT
+ };
+ unsigned int request_msg_id = 0;
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP, 0, 5, in_param_index_array, in_param_value_type_array, in_param_value_array, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &account_id);
+
+ 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, &account_id);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_request_calllog_sync_async(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+ char *data = NULL;
+ int result = 0;
+
+ sync_agent_get_event_data_param(request, &data);
+ if (data == NULL) {
+ _DEBUG_ERROR("data is NULL");
+ result = 0;
+ goto error;
+ }
+ _DEBUG_INFO("data = %s", data);
+
+ result = send_ip_push_sync_msg(data);
+
+ error:
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_request_reset_all_data_sync(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result;
+
+ /* 1. cancel current sync session */
+ cancel_current_sync_task();
+
+ /* 2. reset all data */
+ 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);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ _DEBUG_INFO("result = %d", result);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int event_callback_request_get_all_profiles_data(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ GList *profiles_data = NULL;
+ GList *profile_iter = NULL;
+ GList *category_iter = NULL;
+
+ int profile_count = 0;
+ int category_count = 0;
+ sync_agent_ds_profile_info *profile_info = NULL;
+ sync_agent_ds_service_info *category_info = NULL;
+
+ unsigned int out_param_count;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_param_param_s **param_array = NULL;
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_sync_task(EC_MSG_TYPE_SYNC_TASK_GET_ALL_PROFILES_DATA, 0, 0, NULL, NULL, NULL, (int *)&request_msg_id, &task_error, &out_param_count, &param_array);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles_data);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &result);
+ _DEBUG_INFO("result = %d", result);
+
+ if (profiles_data != NULL) {
+ profile_count = g_list_length(profiles_data);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_count);
+ _DEBUG_INFO("profile_count = %d", profile_count);
+
+ for (profile_iter = profiles_data; profile_iter != NULL; profile_iter = g_list_next(profile_iter)) {
+ profile_info = (sync_agent_ds_profile_info *) profile_iter->data;
+
+ sync_agent_ds_server_info *server_info = &profile_info->server_info;
+ sync_agent_ds_sync_info *sync_info = &profile_info->sync_info;
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_dir_name);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)profile_info->profile_name);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->addr);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->id);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)server_info->password);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_mode);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->sync_type);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)sync_info->interval);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &profile_info->last_sync_status);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &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("server_info->addr = %s", server_info->addr);
+ _DEBUG_INFO("server_info->id = %s", server_info->id);
+ _DEBUG_INFO("server_info->password = %s", server_info->password);
+
+ _DEBUG_INFO("sync_info->sync_mode = %s", sync_info->sync_mode);
+ _DEBUG_INFO("sync_info->sync_type = %s", sync_info->sync_type);
+ _DEBUG_INFO("sync_info->interval = %s", sync_info->interval);
+
+ _DEBUG_INFO("profile_info->last_sync_status = %d", profile_info->last_sync_status);
+ _DEBUG_INFO("profile_info->last_sync_time = %d", profile_info->last_sync_time);
+
+ category_count = g_list_length(profile_info->service_list);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_count);
+
+ _DEBUG_INFO("category_count = %d", category_count);
+
+ for (category_iter = profile_info->service_list; category_iter != NULL; category_iter = g_list_next(category_iter)) {
+ category_info = (sync_agent_ds_service_info *) category_iter->data;
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_info->service_type);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &category_info->enabled);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->src_uri);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->tgt_uri);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)category_info->id);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (void *)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);
+ }
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
diff --git a/src/agent/framework/event/oma_ds_platform_event_handler.c b/src/agent/framework/event/oma_ds_platform_event_handler.c
new file mode 100755
index 0000000..ddc3547
--- /dev/null
+++ b/src/agent/framework/event/oma_ds_platform_event_handler.c
@@ -0,0 +1,355 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Platform_Event_Handler.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of event callback function(from platform)
+ */
+
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_wap_push.h>
+
+#include "framework/event/oma_ds_platform_event_handler.h"
+#include "framework/task/oma_ds_engine_controller_task.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "common/common_define_internal.h"
+#include "common/common_util.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+static void _request_periodic_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);
+
+static void _request_san_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);
+
+static void _request_periodic_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)
+{
+ _INNER_FUNC_ENTER;
+
+ unsigned int request_msg_id_to_cancel = 0;
+ get_periodic_sync_request_id(&request_msg_id_to_cancel);
+
+ _INNER_FUNC_EXIT;
+
+}
+
+static void _request_san_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)
+{
+ _INNER_FUNC_ENTER;
+
+ unsigned int request_msg_id_to_cancel = 0;
+ get_san_sync_request_id(&request_msg_id_to_cancel);
+
+ _INNER_FUNC_EXIT;
+}
+
+int san_callback_parse(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+ san_package_s *pSanPackage = NULL;
+ int accountID = -1;
+ char *sync_mode = NULL;
+ char *server_id = NULL;
+ bool result;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ pmci_san_incoming_s *incoming_data = (pmci_san_incoming_s *) user_data;
+
+ switch (incoming_data->version) {
+ case 11:
+ {
+ pSanPackage = san_package_11_parser(incoming_data->msg_body, incoming_data->msg_size);
+ }
+ break;
+ case 12:
+ {
+ pSanPackage = san_package_12_parser(incoming_data->msg_body, incoming_data->msg_size);
+ }
+ break;
+ default:
+ break;
+ }
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("da_err = %d", da_err);
+ goto return_part;
+ }
+
+ if (pSanPackage == NULL) {
+ _DEBUG_ERROR("pSanPackage is NULL");
+ goto return_part;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto return_part;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, &sync_mode);
+ if (result == true) {
+ /*One device MUST NOT register multi account at same server... */
+ if (strcmp(sync_mode, DEFINE_SYNC_MODE_PUSH) == 0) {
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_ID, &server_id);
+ if (result == true) {
+ /*One device MUST NOT register multi account at same server... */
+ if (strcmp(pSanPackage->server_id, server_id) == 0) {
+ accountID = fw_account->account_id;
+ break;
+ }
+ } else {
+ _DEBUG_ERROR("failed in get_Config");
+ goto return_part;
+ }
+ }
+ } else {
+ _DEBUG_ERROR("failed in get_Config");
+ goto return_part;
+ }
+
+ }
+
+ if (accountID < 0)
+ goto return_part;
+
+ char *syncMode = strdup(DEFINE_SYNC_MODE_PUSH);
+
+ void *in_param_value_array[3] = { &accountID, &syncMode, &pSanPackage };
+ int in_param_index_array[3] = { 0, 1, 2 };
+ sync_agent_ec_value_type_e in_param_type[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_type, in_param_value_array, _request_san_sync_task_finish_callback, NULL, (int *)&request_msg_id);
+
+ insert_request_msg_info(SYNC_MODE_SAN, request_msg_id);
+
+ sync_agent_close_agent();
+
+ if (pSanPackage != NULL)
+ sanPackageParserFree((void *)pSanPackage);
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+
+ return_part:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (sync_mode != NULL)
+ free(sync_mode);
+
+ if (server_id != NULL)
+ free(server_id);
+
+/* if( incoming_data != NULL){
+ if (incoming_data->msg_body != NULL)
+ free((void *)incoming_data->msg_body);
+
+ free(incoming_data);
+ }*/
+
+ if (pSanPackage != NULL)
+ sanPackageParserFree((void *)pSanPackage);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+void send_periodic_sync_msg(int scheduler_id, void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("#######Scheduler Send Msg Success!!!!!##########");
+ _DEBUG_INFO("schedulerId = %d", scheduler_id);
+
+ int accountId = -1;
+ int alarmId = 0;
+ char *alarmId_str = NULL;
+ bool result;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_open_agent");
+ goto error;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto error;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+ if (alarmId_str != NULL)
+ free(alarmId_str);
+
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &alarmId_str);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_Config");
+ goto error;
+ }
+ alarmId = atoi(alarmId_str);
+ _DEBUG_INFO("alarm id = %d", alarmId);
+ if (alarmId == scheduler_id) {
+ _DEBUG_INFO("account_list[i] = %d", fw_account->account_id);
+ accountId = fw_account->account_id;
+ break;
+ }
+ }
+
+ if (accountId != -1) {
+ 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
+ };
+ char *syncMode = strdup(DEFINE_SYNC_MODE_PERIODIC);
+
+ void *in_param_value_array[3] = { &accountId, &syncMode, NULL };
+
+ 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_periodic_sync_task_finish_callback, NULL, (int *)&request_msg_id);
+
+ insert_request_msg_info(SYNC_MODE_PERIODIC, request_msg_id);
+ }
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (alarmId_str != NULL)
+ free(alarmId_str);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int send_ip_push_sync_msg(char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ san_package_s *pSanPackage = NULL;
+ char *id = NULL;
+ char *server_id = NULL;
+ int accountId = -1;
+ bool result = false;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+ sync_agent_fw_account_s *account_info = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_open_agent");
+ goto error;
+ }
+
+ result = parse_ip_push_msg(data, &pSanPackage, &id);
+ if (result != true) {
+ _DEBUG_ERROR("Failed in parseIPPushMsg");
+ goto error;
+ }
+
+ cancel_current_sync_task();
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+ query.access_name = "DIVE";
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ account_info = (sync_agent_fw_account_s *) iter->data;
+
+ _DEBUG_INFO("accountId = %d", account_info->account_id);
+ result = get_config(account_info->account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_ID, &server_id);
+ if (result == true) {
+ if (strcmp(pSanPackage->server_id, server_id) == 0) {
+ accountId = account_info->account_id;
+ break;
+ }
+ } else {
+ _DEBUG_ERROR("failed in get_Config");
+ goto error;
+ }
+ }
+
+ if (accountId < 0)
+ goto error;
+
+ char *syncMode = strdup(DEFINE_SYNC_MODE_PUSH);
+
+ void *in_param_value_array[3] = { &accountId, &syncMode, &pSanPackage };
+ 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_san_sync_task_finish_callback, NULL, (int *)&request_msg_id);
+
+ insert_request_msg_info(SYNC_MODE_SAN, request_msg_id);
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (server_id != NULL)
+ free(server_id);
+
+ if (pSanPackage != NULL)
+ sanPackageParserFree((void *)pSanPackage);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (server_id != NULL)
+ free(server_id);
+
+ if (pSanPackage != NULL)
+ sanPackageParserFree((void *)pSanPackage);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
diff --git a/src/agent/framework/san-parser/pm_sanparser.c b/src/agent/framework/san-parser/pm_sanparser.c
new file mode 100755
index 0000000..bbb21e7
--- /dev/null
+++ b/src/agent/framework/san-parser/pm_sanparser.c
@@ -0,0 +1,633 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @PM_SanParser.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of San Parser
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <inttypes.h>
+#include <glib.h>
+
+#include <sync_agent.h>
+
+#include "wbxml/wbxml.h"
+#include "wbxml/wbxml_tree.h"
+#include "framework/san-parser/pm_sanparser.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+static san_content_type_s contentTypeSupported[] = {
+ {0x00, NULL},
+ {0x03, "text/plain"},
+ {0x06, "text/x-vcalendar"},
+ {0x07, "text/x-vcard"},
+ {0x0305, "text/calendar"},
+ {0x0306, "application/vnd.omads-email+xml"},
+ {0x0307, "application/vnd.omads-file+xml"},
+ {0x0308, "application/vnd.omads-folder+xml"},
+ {0x0309, "text/vcard"}
+};
+
+san_package_s *san_package_12_parser(const char *msg_body, unsigned int msg_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ unsigned int idLength = (uint8_t) msg_body[23];
+ retvm_if(msg_size < (25 + idLength), NULL, "[sanPackage12Parser] SAN package size is smaller than its minimal size specified in the spec, related to [Header] part.");
+
+ san_package_s *san = (san_package_s *) calloc(1, sizeof(san_package_s));
+ retvm_if(san == NULL, NULL, "[sanPackage12Parser] SAN package memory allocation fail. [Container]");
+
+ /* MSG BODY WITHOUT DIGEST */
+ san->msg_body_without_digest = (char *)calloc(msg_size - 16, sizeof(char));
+ if (san->msg_body_without_digest == NULL) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package memory allocation fail. [Msg body]");
+ goto error;
+ }
+ memcpy(san->msg_body_without_digest, msg_body + 16, msg_size - 16);
+ san->msg_body_without_digest_length = msg_size - 16;
+
+ /* DIGEST */
+ san->digest = (char *)calloc(16, sizeof(char));
+ if (san->digest == NULL) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package memory allocation fail. [Digest]");
+ goto error;
+ }
+ memcpy(san->digest, msg_body, 16);
+
+ /* VERSION */
+ unsigned int version = ((uint8_t) msg_body[16]) << 2;
+ version = version | ((uint8_t) msg_body[17]) >> 6;
+
+ if (version != 12) {
+ _DEBUG_ERROR("[sanPackage12Parser] Not supported SAN version %d.", version);
+ goto error;
+ }
+ san->version = version;
+
+ /* UI MODE */
+ san->ui_mode = (((uint8_t) msg_body[17]) & 0x30) >> 4;
+
+ /* INITIATOR */
+ san->initiator = (((uint8_t) msg_body[17]) & 0x08) >> 3;
+
+ /* SESSION ID */
+/*san->sessionID = ((uint8_t)msgBody[21]) << 8;
+ san->sessionID = san->sessionID | (uint8_t)msgBody[22];*/
+ san->session_id = atoi(g_strdup_printf("%02X%02X", msg_body[21], msg_body[22]));
+ _DEBUG_INFO("session id : %d \n", san->session_id);
+
+ /* SERVER ID */
+ if (idLength) {
+ san->server_id = (char *)calloc(idLength + 1, sizeof(char));
+ if (san->server_id == NULL) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package memory allocation fail. [Server ID]");
+ goto error;
+ }
+ memcpy(san->server_id, msg_body + 24, idLength);
+ }
+
+ san->cnt_sync_alerts = ((uint8_t) msg_body[24 + idLength]) >> 4;
+
+ if (san->cnt_sync_alerts == 0) {
+ if (msg_size > 24 + idLength + 1) {
+ _DEBUG_INFO("[sanPackage12Parser] There are remaining bytes at the end of the package. (w/o alerts info)");
+ }
+
+ /* If number of sync alerts equals 0, should sync all data store in the client */
+ _EXTERN_FUNC_EXIT;
+ return san;
+ }
+
+ san->sync_alerts = (san_sync_alert_s *) calloc(san->cnt_sync_alerts, sizeof(san_sync_alert_s));
+ if (san->sync_alerts == NULL) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package memory allocation fail. [syncAlerts]");
+ goto error;
+ }
+
+ msg_body += 25 + idLength;
+ unsigned int alertLength = 25 + idLength;
+ unsigned int i;
+
+ for (i = 0; i < san->cnt_sync_alerts; i++) {
+
+ idLength = (uint8_t) msg_body[4];
+ if (msg_size < (alertLength + 5 + idLength)) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package size is smaller than");
+ _DEBUG_ERROR("[sanPackage12Parser] its minimal size specified in the spec, related to [Alerts] part.");
+ goto error;
+ }
+ alertLength = alertLength + 5 + idLength;
+
+ /* SYNC TYPE */
+ san_sync_type_e alert_type = (((uint8_t) msg_body[0]) >> 4) + 200;
+ if (alert_type < 206 || alert_type > 210) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN doesn't support the sync type %d.", alert_type);
+ goto error;
+ }
+
+ unsigned int contentType = ((uint8_t) msg_body[1]) << 16;
+ contentType = contentType | ((uint8_t) msg_body[2]) << 8;
+ contentType = contentType | ((uint8_t) msg_body[3]);
+
+ /* CONTENT TYPE */
+ char *alert_ct = NULL;
+
+ int j;
+ int cnt = (int)sizeof(contentTypeSupported) / sizeof(san_content_type_s);
+ bool isContentSupported = false;
+
+ for (j = 0; j < cnt; j++) {
+ if (contentType == contentTypeSupported[j].type) {
+ alert_ct = contentTypeSupported[j].strType;
+ isContentSupported = true;
+ break;
+ }
+ }
+
+ if (!isContentSupported) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN doesn't support the content type %d.", contentType);
+ goto error;
+ }
+
+ /* SERVER URI */
+ char *alert_uri = NULL;
+
+ if (idLength) {
+ alert_uri = (char *)calloc(idLength + 1, sizeof(char));
+ if (alert_uri == NULL) {
+ _DEBUG_ERROR("[sanPackage12Parser] SAN package memory allocation fail. [Server URI]");
+ goto error;
+ }
+ memcpy(alert_uri, msg_body + 5, idLength);
+ }
+ msg_body += 5 + idLength;
+
+ san->sync_alerts[i].sync_type = alert_type;
+ san->sync_alerts[i].content_type = alert_ct;
+ san->sync_alerts[i].server_uri = alert_uri;
+
+ }
+
+ if (msg_size > alertLength) {
+ _DEBUG_INFO("[sanPackage12Parser] There are remaining bytes at the end of the package. (with alerts info)");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return san;
+
+ error:
+
+ sanPackageParserFree(san);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+
+}
+
+san_package_s *san_package_11_parser(const char *msg_body, unsigned int msg_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ san_package_s *san = (san_package_s *) calloc(1, sizeof(san_package_s));
+ if (san == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [Container]");
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+
+ WBXMLTree *wbxml_tree = NULL;
+ WBXMLError wbxml_err = wbxml_tree_from_wbxml((unsigned char *)msg_body, msg_size, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, &wbxml_tree);
+
+ if (wbxml_err != WBXML_OK) {
+ _DEBUG_ERROR("[sanPackage11Parser] Libwbxml2 failed to parse WBXML STREAM to WBXML TREE, error code : %s", wbxml_errors_string(wbxml_err));
+ goto error;
+ }
+
+ WBXMLTreeNode *synchdr_node;
+ if ((synchdr_node = wbxml_tree_node_elt_get_from_name(wbxml_tree->root, "SyncHdr", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [SyncHdr]");
+ goto error;
+ }
+ WBXMLTreeNode *child_node = NULL;
+ const char *child_node_name = NULL;
+
+ for (child_node = synchdr_node->children; child_node != NULL; child_node = child_node->next) {
+ child_node_name = (const char *)wbxml_tag_get_xml_name(child_node->name);
+
+ if ((strcmp(child_node_name, "VerDTD") == 0) || (strcmp(child_node_name, "VerProto") == 0)) {
+ char *version = NULL;
+ if (child_node->children != NULL && child_node->children->type == WBXML_TREE_TEXT_NODE && child_node->children->content != NULL) {
+
+ version = (char *)wbxml_buffer_get_cstr(child_node->children->content);
+
+ if (strcmp(version, "1.1") && strcmp(version, "SyncML/1.1")) {
+ _DEBUG_ERROR("[sanPackage11Parser] Not supported SAN version %s.", version);
+ goto error;
+ }
+ san->version = 11;
+ }
+ } else if (strcmp(child_node_name, "SessionID") == 0) {
+ char *sessionID = NULL;
+ if (child_node->children != NULL && child_node->children->type == WBXML_TREE_TEXT_NODE && child_node->children->content != NULL) {
+
+ sessionID = (char *)wbxml_buffer_get_cstr(child_node->children->content);
+
+ if (sessionID == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL sessionID detected. sessionID MUST NOT be NULL.");
+ goto error;
+ }
+ san->session_id = atoi(sessionID);
+ }
+ } else if (strcmp(child_node_name, "Source") == 0) {
+ char *serverID = NULL;
+ unsigned serverIDlen = 0;
+ WBXMLTreeNode *serverid_node;
+ if ((serverid_node = wbxml_tree_node_elt_get_from_name(child_node, "LocURI", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [LocURI]");
+ goto error;
+ }
+
+ if (serverid_node->children != NULL && serverid_node->children->type == WBXML_TREE_TEXT_NODE && serverid_node->children->content != NULL) {
+
+ serverID = (char *)wbxml_buffer_get_cstr(serverid_node->children->content);
+ serverIDlen = wbxml_buffer_len(serverid_node->children->content);
+ if (serverID == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL serverID detected. serverID MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->server_id = (char *)calloc(serverIDlen, sizeof(char));
+ if (san->server_id == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [Server ID]");
+ goto error;
+ }
+ memcpy(san->server_id, serverID, serverIDlen);
+ }
+ } else if (strcmp(child_node_name, "Cred") == 0) {
+
+ san->cred = (san_cred_s *) calloc(1, sizeof(san_cred_s));
+ if (san->cred == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [cred]");
+ goto error;
+ }
+
+ char *credFormat = NULL;
+ unsigned credFormatLen = 0;
+ WBXMLTreeNode *credformat_node;
+ if ((credformat_node = wbxml_tree_node_elt_get_from_name(child_node, "Format", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [Format]");
+ goto error;
+ }
+
+ if (credformat_node->children != NULL && credformat_node->children->type == WBXML_TREE_TEXT_NODE && credformat_node->children->content != NULL) {
+
+ credFormat = (char *)wbxml_buffer_get_cstr(credformat_node->children->content);
+ credFormatLen = wbxml_buffer_len(credformat_node->children->content);
+ if (credFormat == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL credFormat detected. credFormat MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->cred_format = (char *)calloc(credFormatLen, sizeof(char));
+ if (san->cred->cred_format == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [credFormat]");
+ goto error;
+ }
+ memcpy(san->cred->cred_format, credFormat, credFormatLen);
+ }
+
+ char *credAuth = NULL;
+ unsigned credAuthLen = 0;
+ WBXMLTreeNode *credauth_node;
+ if ((credauth_node = wbxml_tree_node_elt_get_from_name(child_node, "Type", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [Type]");
+ goto error;
+ }
+
+ if (credauth_node->children != NULL && credauth_node->children->type == WBXML_TREE_TEXT_NODE && credauth_node->children->content != NULL) {
+
+ credAuth = (char *)wbxml_buffer_get_cstr(credauth_node->children->content);
+ credAuthLen = wbxml_buffer_len(credauth_node->children->content);
+ if (credAuth == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL credAuth detected. credAuth MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->cred_auth = (char *)calloc(credAuthLen, sizeof(char));
+ if (san->cred->cred_auth == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [credAuth]");
+ goto error;
+ }
+ memcpy(san->cred->cred_auth, credAuth, credAuthLen);
+ }
+
+ char *credData = NULL;
+ unsigned credDataLen = 0;
+ WBXMLTreeNode *creddata_node;
+ if ((creddata_node = wbxml_tree_node_elt_get_from_name(child_node, "Data", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [Data]");
+ goto error;
+ }
+
+ if (creddata_node->children != NULL && creddata_node->children->type == WBXML_TREE_TEXT_NODE && creddata_node->children->content != NULL) {
+
+ credData = (char *)wbxml_buffer_get_cstr(creddata_node->children->content);
+ credDataLen = wbxml_buffer_len(creddata_node->children->content);
+ if (credData == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL credData detected. credData MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->cred_data = (char *)calloc(credDataLen, sizeof(char));
+ if (san->cred->cred_data == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [credData]");
+ goto error;
+ }
+ memcpy(san->cred->cred_data, credData, credDataLen);
+ }
+
+ }
+
+ }
+
+ WBXMLTreeNode *syncbody_node;
+ if ((syncbody_node = wbxml_tree_node_elt_get_from_name(wbxml_tree->root, "SyncBody", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [SyncBody]");
+ goto error;
+ }
+
+ WBXMLList *alertnode_list = wbxml_tree_node_get_all_children(syncbody_node);
+ unsigned int alertnode_list_len = wbxml_list_len(alertnode_list);
+
+ child_node = (WBXMLTreeNode *) wbxml_list_get(alertnode_list, alertnode_list_len - 1);
+ child_node_name = (const char *)wbxml_tag_get_xml_name(child_node->name);
+ if (strcmp(child_node_name, "Final") == 0)
+ san->cnt_sync_alerts = alertnode_list_len - 1;
+
+ if (san->cnt_sync_alerts == 0) {
+ /* If number of sync alerts equals 0, should sync all data store in the client */
+ return san;
+ } else {
+ san->sync_alerts = (san_sync_alert_s *) calloc(san->cnt_sync_alerts, sizeof(san_sync_alert_s));
+ if (san->sync_alerts == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [syncAlerts]");
+ goto error;
+ }
+
+ unsigned int indexNode;
+ for (indexNode = 0; indexNode < san->cnt_sync_alerts; indexNode++) {
+
+ WBXMLTreeNode *alert_node = (WBXMLTreeNode *) wbxml_list_get(alertnode_list, indexNode);
+
+ char *alertData = NULL;
+ WBXMLTreeNode *alertdata_node;
+ if ((alertdata_node = wbxml_tree_node_elt_get_from_name(alert_node, "Data", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [Data]");
+ goto error;
+ }
+
+ if (alertdata_node->children != NULL && alertdata_node->children->type == WBXML_TREE_TEXT_NODE && alertdata_node->children->content != NULL) {
+
+ alertData = (char *)wbxml_buffer_get_cstr(alertdata_node->children->content);
+ if (alertData == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL alertData detected. alertData MUST NOT be NULL.");
+ goto error;
+ }
+
+ if (atoi(alertData) < 206 || atoi(alertData) > 210) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN doesn't support the sync type %d.", atoi(alertData));
+ goto error;
+ }
+
+ san->sync_alerts[indexNode].sync_type = atoi(alertData);
+ }
+
+ char *alertURI = NULL;
+ unsigned alertURIlen = 0;
+ WBXMLTreeNode *alerturi_node;
+ if ((alerturi_node = wbxml_tree_node_elt_get_from_name(alert_node, "LocURI", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [LocURI]");
+ goto error;
+ }
+
+ if (alerturi_node->children != NULL && alerturi_node->children->type == WBXML_TREE_TEXT_NODE && alerturi_node->children->content != NULL) {
+
+ alertURI = (char *)wbxml_buffer_get_cstr(alerturi_node->children->content);
+ alertURIlen = wbxml_buffer_len(alerturi_node->children->content);
+ if (alertURI == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL alertURI detected. alertURI MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->sync_alerts[indexNode].server_uri = (char *)calloc(alertURIlen, sizeof(char));
+ if (san->sync_alerts[indexNode].server_uri == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN package memory allocation fail. [serverURI]");
+ goto error;
+ }
+ memcpy(san->sync_alerts[indexNode].server_uri, alertURI, alertURIlen);
+ }
+
+ char *alertContentType = NULL;
+ unsigned alertContentTypeLen = 0;
+ WBXMLTreeNode *alertcontenttype_node;
+ if ((alertcontenttype_node = wbxml_tree_node_elt_get_from_name(alert_node, "Type", TRUE)) == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL from wbxml_tree_node_elt_get_from_name. [Type]");
+ goto error;
+ }
+
+ if (alertcontenttype_node->children != NULL && alertcontenttype_node->children->type == WBXML_TREE_TEXT_NODE && alertcontenttype_node->children->content != NULL) {
+
+ alertContentType = (char *)wbxml_buffer_get_cstr(alertcontenttype_node->children->content);
+ alertContentTypeLen = wbxml_buffer_len(alertcontenttype_node->children->content);
+
+ if (alertContentType == NULL) {
+ _DEBUG_ERROR("[sanPackage11Parser] NULL alertContentType detected. alertContentType MUST NOT be NULL.");
+ goto error;
+ }
+
+ int j;
+ int cnt = (int)sizeof(contentTypeSupported) / sizeof(san_content_type_s);
+ bool isContentSupported = false;
+
+ for (j = 0; j < cnt; j++) {
+ if (contentTypeSupported[j].strType == NULL)
+ continue;
+ if (strcmp(alertContentType, contentTypeSupported[j].strType) == 0) {
+ san->sync_alerts[indexNode].content_type = contentTypeSupported[j].strType;
+ isContentSupported = true;
+ break;
+ }
+ }
+
+ if (!isContentSupported) {
+ _DEBUG_ERROR("[sanPackage11Parser] SAN doesn't support the content type %s.", alertContentType);
+ goto error;
+ }
+ }
+ }
+ }
+
+ wbxml_tree_destroy(wbxml_tree);
+
+ _EXTERN_FUNC_EXIT;
+ return san;
+
+ error:
+
+ sanPackageParserFree(san);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+
+}
+
+void sanPackageParserFree(void *point)
+{
+ _EXTERN_FUNC_ENTER;
+
+ san_package_s *san = (san_package_s *) point;
+ if (san != NULL) {
+ if (san->msg_body_without_digest != NULL)
+ free(san->msg_body_without_digest);
+ if (san->digest != NULL)
+ free(san->digest);
+ if (san->cred != NULL) {
+ if (san->cred->cred_format != NULL)
+ free(san->cred->cred_format);
+ if (san->cred->cred_auth != NULL)
+ free(san->cred->cred_auth);
+ if (san->cred->cred_data != NULL)
+ free(san->cred->cred_data);
+ free(san->cred);
+ }
+ if (san->server_id != NULL)
+ free(san->server_id);
+ if (san->sync_alerts != NULL) {
+ int i;
+ for (i = 0; i < san->cnt_sync_alerts; i++) {
+ if (san->sync_alerts[i].server_uri != NULL) {
+ free(san->sync_alerts[i].server_uri);
+ }
+ }
+ free(san->sync_alerts);
+ }
+ free(san);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void sanPrintMsg(san_package_s * san)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int i;
+
+ _DEBUG_INFO("Printing SAN package ============================\n\n");
+
+ _DEBUG_INFO("MsgBody without Digest :\n\t");
+ for (i = 0; i < san->msg_body_without_digest_length; i++) {
+ _DEBUG_INFO("%02x ", san->msg_body_without_digest[i]);
+ if ((i + 1) % 16 == 0)
+ _DEBUG_INFO("\n\t");
+ }
+ _DEBUG_INFO("\n");
+
+ _DEBUG_INFO("Digest : %s\n", san->digest);
+ if (san->cred != NULL) {
+ if (san->cred->cred_format != NULL)
+ _DEBUG_INFO("Cred Format : %s\n", san->cred->cred_format);
+ if (san->cred->cred_auth != NULL)
+ _DEBUG_INFO("Cred Type : %s\n", san->cred->cred_auth);
+ if (san->cred->cred_data != NULL)
+ _DEBUG_INFO("Cred Data : %s\n", san->cred->cred_data);
+ }
+ _DEBUG_INFO("Version : %d\n", san->version);
+ _DEBUG_INFO("UI mode : %d\n", san->ui_mode);
+ _DEBUG_INFO("Initiator : %d\n", san->initiator);
+ _DEBUG_INFO("Session ID : %u\n", san->session_id);
+ _DEBUG_INFO("Server ID : %s\n", san->server_id);
+ _DEBUG_INFO("No. of Sync : %u\n", san->cnt_sync_alerts);
+
+ for (i = 0; i < san->cnt_sync_alerts; i++) {
+ _DEBUG_INFO("\n\t=== Sync No. %d ============\n", i + 1);
+ _DEBUG_INFO("\tSync type : %d\n", san->sync_alerts[i].sync_type);
+ _DEBUG_INFO("\tContent type : %s\n", san->sync_alerts[i].content_type);
+ _DEBUG_INFO("\tServer URI : %s\n", san->sync_alerts[i].server_uri);
+ };
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int parse_ip_push_msg(char *data, san_package_s ** san_package, char **id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(data == NULL, 0, "data is NULL");
+
+ char *pay = NULL;
+ char *body = NULL;
+ char *decoded_body = NULL;
+ unsigned int decoded_size;
+
+ *id = strtok(data, "|");
+ pay = strtok(NULL, "|");
+ body = strtok(NULL, "|");
+
+ _DEBUG_INFO("id = %s", *id);
+ _DEBUG_INFO("pay = %s", pay);
+ _DEBUG_INFO("after = %s", body);
+
+ decoded_body = (char *)g_base64_decode(body, &decoded_size);
+
+ _DEBUG_INFO("decoded_body = %s", decoded_body);
+ _DEBUG_INFO("decoded_size = %d", decoded_size);
+
+ *san_package = san_package_12_parser(decoded_body, decoded_size);
+
+ if ((*san_package) != NULL) {
+ _DEBUG_INFO("serverId = %s", (*san_package)->server_id);
+ _DEBUG_INFO("sessionID = %d", (*san_package)->session_id);
+ _DEBUG_INFO("cntSyncAlerts = %d", (*san_package)->cnt_sync_alerts);
+ int i;
+ for (i = 0; i < (*san_package)->cnt_sync_alerts; i++) {
+ _DEBUG_INFO("syncAlerts = %d", (*san_package)->sync_alerts[i].sync_type);
+ }
+ } else {
+ _DEBUG_ERROR("pSanPackage is NULL");
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+
+ error:
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
diff --git a/src/agent/framework/task/oma_ds_engine_controller_task.c b/src/agent/framework/task/oma_ds_engine_controller_task.c
new file mode 100755
index 0000000..ba7012d
--- /dev/null
+++ b/src/agent/framework/task/oma_ds_engine_controller_task.c
@@ -0,0 +1,1137 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @OMA_DS_Engine_Controller_Task.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of make and register task to Engine Controller
+ */
+
+#include <string.h>
+
+#include <sync_agent.h>
+
+#include "framework/task/oma_ds_engine_controller_task.h"
+#include "service-engine/se_account.h"
+#include "service-engine/se_sync.h"
+#include "service-engine/se_storage.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_COMMON"
+#endif
+
+static GList *sync_request_id_list = NULL;
+
+static void _free_sync_categorie_list(void *list);
+static void _free_delete_profile_list(void *list);
+static void _free_resource_cp_list(void *list);
+
+static void _request_msg_info_free(request_msg_info_t * info);
+static void *_string_copy_struct(void *string);
+static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id);
+
+static void __free_resource_cp(resource_cp_s * resource);
+
+static void _free_sync_categorie_list(void *list)
+{
+ _INNER_FUNC_ENTER;
+ retm_if(list == NULL, "list is NULL");
+
+ GList *categories = (GList *) list;
+ GList *iter = NULL;
+ for (iter = categories; iter != NULL; iter = g_list_next(iter))
+ free_sync_service(iter->data);
+
+ g_list_free(categories);
+ _INNER_FUNC_EXIT;
+}
+
+static void _free_delete_profile_list(void *list)
+{
+ _INNER_FUNC_ENTER;
+ retm_if(list == NULL, "list is NULL");
+
+ GList *profiles = (GList *) list;
+ GList *iter = NULL;
+ for (iter = profiles; iter != NULL; iter = g_list_next(iter))
+ free(iter->data);
+
+ g_list_free(profiles);
+ _INNER_FUNC_EXIT;
+}
+
+static void _free_resource_cp_list(void *list)
+{
+ _INNER_FUNC_ENTER;
+ retm_if(list == NULL, "list is NULL");
+
+ GList *profiles = (GList *) list;
+ GList *iter = NULL;
+ for (iter = profiles; iter != NULL; iter = g_list_next(iter))
+ __free_resource_cp(iter->data);
+
+ g_list_free(profiles);
+ _INNER_FUNC_EXIT;
+}
+
+static void __free_resource_cp(resource_cp_s * resource)
+{
+ _INNER_FUNC_ENTER;
+ retm_if(resource == NULL, "resource is NULL");
+
+ if (resource->name != NULL)
+ free(resource->name);
+
+ if (resource->accept != NULL)
+ free(resource->accept);
+
+ if (resource->id != NULL)
+ free(resource->id);
+
+ if (resource->password != NULL)
+ free(resource->password);
+
+ if (resource->auth_type != NULL)
+ free(resource->auth_type);
+
+ if (resource->auth_data != NULL)
+ free(resource->auth_data);
+
+ free(resource);
+ _INNER_FUNC_EXIT;
+}
+
+static request_msg_info_t *_create_request_msg_info(int sync_type, unsigned int request_id)
+{
+ _INNER_FUNC_ENTER;
+ request_msg_info_t *pInfo = (request_msg_info_t *) calloc(1, sizeof(request_msg_info_t));
+ retvm_if(pInfo == NULL, NULL, "pInfo is NULL");
+
+ pInfo->sync_type = sync_type;
+ pInfo->request_id = request_id;
+
+ _INNER_FUNC_EXIT;
+ return pInfo;
+}
+
+static void _request_msg_info_free(request_msg_info_t * info)
+{
+ _INNER_FUNC_ENTER;
+
+ if (info != NULL)
+ free(info);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void *_string_copy_struct(void *string)
+{
+ _INNER_FUNC_ENTER;
+
+ void *data = NULL;
+ data = strdup((const char *)string);
+
+ _INNER_FUNC_EXIT;
+ return data;
+}
+
+sync_agent_ec_task_spec_s *make_synchronize_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_add_profile_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileDirName", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("profileName", _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("addr", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec6 = 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_spec7 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
+ true, false, false, NULL, false, NULL, false, NULL);
+
+ sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *param_spec_array[11] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
+ pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10, pParam_spec11
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile",
+ add_profile_task_process, NULL, NULL,
+ 11, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+ sync_agent_unref_param_spec(pParam_spec8);
+ sync_agent_unref_param_spec(pParam_spec9);
+ sync_agent_unref_param_spec(pParam_spec10);
+ sync_agent_unref_param_spec(pParam_spec11);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_edit_profile_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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("profileName", _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("addr", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec6 = 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_spec7 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_sync_categorie_list,
+ true, false, false, NULL, false, NULL, false, NULL);
+
+ sync_agent_ec_param_spec_s *pParam_spec10 = 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[10] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
+ pParam_spec6, pParam_spec7, pParam_spec8, pParam_spec9, pParam_spec10
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("edit_profile",
+ edit_profile_task_process, NULL, NULL,
+ 10, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+ sync_agent_unref_param_spec(pParam_spec8);
+ sync_agent_unref_param_spec(pParam_spec9);
+ sync_agent_unref_param_spec(pParam_spec10);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_delete_profile_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profiles", NULL, _free_delete_profile_list,
+ true, false, false, NULL, false, NULL, false, NULL);
+
+ sync_agent_ec_param_spec_s *pParam_spec2 = 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[2] = { pParam_spec1, pParam_spec2 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("delete_profile",
+ delete_profile_task_process, NULL, NULL,
+ 2, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_get_profile_data_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("addr", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("syncType", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_structure("interval", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("lastSessionStatus", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *param_spec_array[11] = { pParam_spec1, pParam_spec2, pParam_spec3,
+ pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
+ pParam_spec9, pParam_spec10, pParam_spec11
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_data",
+ get_profile_data_task_process, NULL, NULL,
+ 11, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+ sync_agent_unref_param_spec(pParam_spec8);
+ sync_agent_unref_param_spec(pParam_spec9);
+ sync_agent_unref_param_spec(pParam_spec10);
+ sync_agent_unref_param_spec(pParam_spec11);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_get_profile_sync_category_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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_int("contentType", true, false, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_int("enabled", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("srcURI", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_structure("tgtURI", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_structure("id", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+
+ sync_agent_ec_param_spec_s *param_spec_array[8] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4,
+ pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_sync_category",
+ get_profile_sync_category_task_process, NULL, NULL,
+ 8, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+ sync_agent_unref_param_spec(pParam_spec8);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_get_profile_statistics_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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_int("contentType", true, false, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *pParam_spec3 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("dbSynced", _string_copy_struct, free,
+ false, true, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_int("lastSessionTime", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("server2Client_Total", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("server2Client_NrOfAdd", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec8 = sync_agent_alloc_param_spec_int("server2Client_NrOfDelete", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec9 = sync_agent_alloc_param_spec_int("server2Client_NrOfReplace", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec10 = sync_agent_alloc_param_spec_int("client2Server_Total", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec11 = sync_agent_alloc_param_spec_int("client2Server_NrOfAdd", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec12 = sync_agent_alloc_param_spec_int("client2Server_NrOfDelete", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec13 = sync_agent_alloc_param_spec_int("client2Server_NrOfReplace", false, true, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *param_spec_array[13] = { pParam_spec1, pParam_spec2, pParam_spec3,
+ pParam_spec4, pParam_spec5, pParam_spec6, pParam_spec7, pParam_spec8,
+ pParam_spec9, pParam_spec10, pParam_spec11, pParam_spec12, pParam_spec13
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("get_profile_statistics",
+ get_profile_statistics_task_process, NULL, NULL,
+ 13, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+ sync_agent_unref_param_spec(pParam_spec8);
+ sync_agent_unref_param_spec(pParam_spec9);
+ sync_agent_unref_param_spec(pParam_spec10);
+ sync_agent_unref_param_spec(pParam_spec11);
+ sync_agent_unref_param_spec(pParam_spec12);
+ sync_agent_unref_param_spec(pParam_spec13);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_reset_synchronizing_profiles_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("reset_synchronizing_profiles",
+ reset_synchronizing_profiles_task_process, NULL, NULL,
+ 0, NULL);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_add_profile_cp_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("profileName", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("addr", _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("id", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec4 = sync_agent_alloc_param_spec_structure("password", _string_copy_struct, free,
+ true, false, false, NULL, false, NULL, false, NULL);
+ sync_agent_ec_param_spec_s *pParam_spec5 = sync_agent_alloc_param_spec_structure("categories", NULL, _free_resource_cp_list,
+ true, false, false, NULL, false, NULL, false, NULL);
+
+ sync_agent_ec_param_spec_s *pParam_spec6 = sync_agent_alloc_param_spec_int("result", false, true, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec7 = sync_agent_alloc_param_spec_int("accountId", false, true, false, 0, 0, false, 0, false, 0, 0);
+
+ sync_agent_ec_param_spec_s *param_spec_array[7] = { pParam_spec1, pParam_spec2, pParam_spec3, pParam_spec4, pParam_spec5,
+ pParam_spec6, pParam_spec7
+ };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("add_profile_cp",
+ add_profile_cp_task_process, NULL, NULL,
+ 7, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+ sync_agent_unref_param_spec(pParam_spec2);
+ sync_agent_unref_param_spec(pParam_spec3);
+ sync_agent_unref_param_spec(pParam_spec4);
+ sync_agent_unref_param_spec(pParam_spec5);
+ sync_agent_unref_param_spec(pParam_spec6);
+ sync_agent_unref_param_spec(pParam_spec7);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_refresh_from_service_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ 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 *param_spec_array[1] = { pParam_spec1 };
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("refresh_from_service",
+ refresh_from_service_task_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_spec_s *make_cancel_request_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("cancel_sync_request",
+ cancel_sync_request_task_process, NULL, NULL,
+ 0, NULL);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+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;
+}
+
+sync_agent_ec_task_spec_s *make_get_all_profiles_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 *pParam_spec2 = sync_agent_alloc_param_spec_structure("profilesData", NULL, NULL,
+ false, true, 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("get_all_profiles_data",
+ get_all_profiles_data_task_process, NULL, NULL,
+ 2, param_spec_array);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+}
+
+sync_agent_ec_task_error_e synchronize_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId = 0;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+ retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
+
+ char *syncMode = NULL;
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
+
+ san_package_s *pSanPackage = NULL;
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pSanPackage);
+
+ _DEBUG_INFO("accountId = %d", accountId);
+ _DEBUG_INFO("syncMode = %s", syncMode);
+
+ bool result = synchronize(accountId, syncMode, pSanPackage);
+ if (result == false)
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e add_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ char *profileDirName = NULL;
+ char *profileName = NULL;
+ char *addr = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ char *syncMode = NULL;
+ char *syncType = NULL;
+ char *interval = NULL;
+ GList *categories = NULL;
+ int accountId;
+
+ bool res;
+ int result;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileDirName);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+ sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
+ sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
+ sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
+ sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
+
+ res = add_profile(profileDirName, profileName, addr, id, password, syncMode, syncType, interval, categories, &accountId);
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+
+ /*step 2 : start refresh_from_service for added account */
+ void *in_param_value_array[1] = { &accountId };
+ int in_param_index_array[1] = { 0 };
+ sync_agent_ec_value_type_e in_param_value_type_array[1] = { SYNC_AGENT_EC_VALUE_TYPE_INT };
+ unsigned int request_msg_id = 0;
+ sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, (int *)&request_msg_id);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e edit_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId;
+ char *profileName = NULL;
+ char *addr = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ char *syncMode = NULL;
+ char *syncType = NULL;
+ char *interval = NULL;
+ GList *categories = NULL;
+
+ bool res;
+ int result;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+ sync_agent_get_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
+ sync_agent_get_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
+ sync_agent_get_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
+ sync_agent_get_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
+
+ res = edit_profile(accountId, profileName, addr, id, password, syncMode, syncType, interval, categories);
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e delete_profile_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool res;
+ int result;
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ GList *profiles = NULL;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles);
+
+ res = delete_profiles(profiles);
+ if (res == 0) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+
+}
+
+sync_agent_ec_task_error_e get_profile_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId = 0;
+ char *profileName = NULL;
+ char *addr = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ char *syncMode = NULL;
+ char *syncType = NULL;
+ char *interval = NULL;
+ int lastSessionStatus;
+ int lastSessionTime;
+ int result;
+ bool res;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+ retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
+
+ res = get_profile_data(accountId, &profileName, &addr, &id, &password, &syncMode, &syncType, &interval, &lastSessionStatus, &lastSessionTime);
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+ sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+ sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+ sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncMode);
+ sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &syncType);
+ sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &interval);
+ sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionStatus);
+ sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+
+}
+
+sync_agent_ec_task_error_e get_profile_sync_category_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId = 0;
+ int contentType;
+
+ int enabled = 0;
+ char *srcURI = NULL;
+ char *tgtURI = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ bool res;
+ int result = 0;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+ retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
+
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
+
+ res = get_profile_sync_category(accountId, contentType, &enabled, &srcURI, &tgtURI, &id, &password);
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &enabled);
+ sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &srcURI);
+ sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &tgtURI);
+ sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e get_profile_statistics_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId = 0;
+ int contentType;
+
+ char *dbSynced = NULL;
+ int lastSessionTime = -1;
+ 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_NrOfDelete = 0;
+ int client2Server_NrOfReplace = 0;
+
+ bool res;
+ int result;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+ retvm_if(accountId < 0, SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED, "account id = %d", accountId);
+
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &contentType);
+
+ res = get_profile_statistics(accountId, contentType, &dbSynced, &lastSessionTime,
+ &server2Client_Total, &server2Client_NrOfAdd, &server2Client_NrOfDelete, &server2Client_NrOfReplace, &client2Server_Total, &client2Server_NrOfAdd, &client2Server_NrOfDelete, &client2Server_NrOfReplace);
+
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &dbSynced);
+ sync_agent_set_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &lastSessionTime);
+ sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_Total);
+ sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfAdd);
+ sync_agent_set_param_value(&(param_array[7]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfDelete);
+ sync_agent_set_param_value(&(param_array[8]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &server2Client_NrOfReplace);
+ sync_agent_set_param_value(&(param_array[9]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_Total);
+ sync_agent_set_param_value(&(param_array[10]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfAdd);
+ sync_agent_set_param_value(&(param_array[11]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfDelete);
+ sync_agent_set_param_value(&(param_array[12]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &client2Server_NrOfReplace);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e reset_synchronizing_profiles_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ reset_synchronizing_profiles();
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e add_profile_cp_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ char *profileName = NULL;
+ char *addr = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ GList *categories = NULL;
+ int accountId;
+
+ bool res;
+ int result;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profileName);
+ sync_agent_get_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &addr);
+ sync_agent_get_param_value(&(param_array[2]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &id);
+ sync_agent_get_param_value(&(param_array[3]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &password);
+ sync_agent_get_param_value(&(param_array[4]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &categories);
+
+ res = add_profile_cp(profileName, addr, id, password, categories, &accountId);
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[5]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[6]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e refresh_from_service_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int accountId;
+ bool res;
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &accountId);
+
+ res = refresh_from_service_all(accountId);
+ if (res == false)
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e cancel_sync_request_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ cancel_sync_request();
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e reset_all_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+ int result = 1;
+
+ /* delete all profiles */
+ result = delete_all_profiles();
+
+ /* delete all agent default table */
+ result = delete_all_agent_default_table();
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_error_e get_all_profiles_data_task_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ bool res;
+ int result;
+ GList *profiles_data = NULL;
+
+ res = get_all_profiles_data(&profiles_data);
+
+ if (res == false) {
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ result = 0;
+ } else
+ result = 1;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &result);
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &profiles_data);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+
+}
+
+void insert_request_msg_info(int sync_type, unsigned int request_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_request_id_list = g_list_prepend(sync_request_id_list, _create_request_msg_info(sync_type, request_id));
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void delete_request_msg_info(unsigned int request_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ GList *iter = NULL;
+ request_msg_info_t *pMsg_info = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->request_id == request_id) {
+ sync_request_id_list = g_list_remove_link(sync_request_id_list, iter);
+ break;
+ }
+ }
+
+ if (iter != NULL) {
+ _request_msg_info_free(iter->data);
+ g_list_free_1(iter);
+ }
+ _EXTERN_FUNC_EXIT;
+}
+
+bool get_synchronizing_request_id(unsigned int *pRequest_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool success = false;
+ request_msg_info_t *pMsg_info = NULL;
+ GList *iter = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->sync_type == SYNC_MODE_MANUAL || pMsg_info->sync_type == SYNC_MODE_PERIODIC || pMsg_info->sync_type == SYNC_MODE_SAN) {
+ success = true;
+ *pRequest_id = pMsg_info->request_id;
+
+ _request_msg_info_free(pMsg_info);
+ sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
+
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return success;
+}
+
+bool get_manual_sync_request_id(unsigned int *pRequest_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool success = false;
+ request_msg_info_t *pMsg_info = NULL;
+ GList *iter = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->sync_type == SYNC_MODE_MANUAL) {
+ success = true;
+ *pRequest_id = pMsg_info->request_id;
+
+ _request_msg_info_free(pMsg_info);
+ sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return success;
+}
+
+bool get_periodic_sync_request_id(unsigned int *pRequest_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool success = false;
+ request_msg_info_t *pMsg_info = NULL;
+ GList *iter = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->sync_type == SYNC_MODE_PERIODIC) {
+ success = true;
+ *pRequest_id = pMsg_info->request_id;
+
+ _request_msg_info_free(pMsg_info);
+ sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
+
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return success;
+}
+
+bool get_san_sync_request_id(unsigned int *pRequest_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool success = false;
+ request_msg_info_t *pMsg_info = NULL;
+ GList *iter = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->sync_type == SYNC_MODE_SAN) {
+ success = true;
+ *pRequest_id = pMsg_info->request_id;
+
+ _request_msg_info_free(pMsg_info);
+ sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
+
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return success;
+}
+
+bool get_auto_configure_request_id(unsigned int *pRequest_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ bool success = false;
+ request_msg_info_t *pMsg_info = NULL;
+ GList *iter = NULL;
+
+ for (iter = sync_request_id_list; iter != NULL; iter = g_list_next(iter)) {
+ pMsg_info = iter->data;
+
+ if (pMsg_info->sync_type == SYNC_MODE_AUTOCONFIG) {
+ success = true;
+ *pRequest_id = pMsg_info->request_id;
+
+ _request_msg_info_free(pMsg_info);
+ sync_request_id_list = g_list_delete_link(sync_request_id_list, iter);
+
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return success;
+}
+
+bool cancel_current_sync_task()
+{
+ _EXTERN_FUNC_ENTER;
+
+ unsigned int request_msg_id_to_cancel = 0;
+ unsigned int request_msg_id = 0;
+ bool has_autoconfig = get_auto_configure_request_id(&request_msg_id_to_cancel);
+ if (has_autoconfig) {
+ _DEBUG_INFO("has_autoconfig [%d] ", request_msg_id_to_cancel);
+ sync_agent_cancel_task(request_msg_id_to_cancel);
+ } else {
+ bool has_sync = get_synchronizing_request_id(&request_msg_id_to_cancel);
+ if (has_sync) {
+ _DEBUG_INFO("has_manual_sync [%d] ", request_msg_id_to_cancel);
+ sync_agent_cancel_task(request_msg_id_to_cancel);
+
+ /*request network session cancel */
+ sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);
+ } else {
+ /* nothing to do */
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return true;
+}
diff --git a/src/agent/main/main.c b/src/agent/main/main.c
new file mode 100755
index 0000000..b6795de
--- /dev/null
+++ b/src/agent/main/main.c
@@ -0,0 +1,395 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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
+ */
+
+typedef enum {
+ OMA_DS_ADD_PROFILE = 1,
+ OMA_DS_EDIT_PROFILE = 2,
+ OMA_DS_DELETE_PROFILE = 3,
+ OMA_DS_REQUEST_SYNC = 4,
+ OMA_DS_CANCEL_SYNC = 5,
+ OMA_DS_GET_PROFILE_DATA = 6,
+ OMA_DS_GET_PROFILE_SYNC_CATEGORY = 7,
+ OMA_DS_GET_PROFILE_SYNC_STATISTICS = 8,
+ OMA_DS_GET_ALL_PROFILES_DATA = 9,
+ OMA_DS_ADD_PROFILE_CP = 10,
+ OMA_DS_REQUEST_CALLLOG_SYNC = 11,
+ OMA_DS_RESET_ALL_DATA = 12
+} oma_ds_event_e;
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+
+#include <sync_agent.h>
+
+#include "framework/event/oma_ds_platform_event_handler.h"
+#include "framework/event/oma_ds_event_handler.h"
+#include "framework/task/oma_ds_engine_controller_task.h"
+#include "common/csc_keys.h"
+#include "common/common_define_internal.h"
+#include "common/common_vconf.h"
+#include "service-engine/se_account.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_MAIN"
+#endif
+
+#define MC_SERVICE_OBJECT_PATH "/com/samsung/omadsagent" /* Don't use special character */
+#define MC_SERVICE_DBUS "com.samsung.omadsagent"
+#define MC_SERVICE_INTERFACE "com.samsung.omadsagent"
+
+static DBusConnection *connection = NULL;
+
+static void _unregistered_path(DBusConnection * connection, void *user_data)
+{
+ /* connection was finalized */
+ _INNER_FUNC_ENTER;
+
+ _INNER_FUNC_EXIT;
+}
+
+static DBusHandlerResult _message_path(DBusConnection * connection, DBusMessage * message, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+ if (dbus_message_is_method_call(message, MC_SERVICE_DBUS, "Echo")) {
+ DBusMessage *reply;
+ _DEBUG_INFO("Recived the HelloFromSelf message\n");
+
+ reply = dbus_message_new_method_return(message);
+ if (reply == NULL)
+ _DEBUG_ERROR("no memory\n");
+
+ if (!dbus_connection_send(connection, reply, NULL))
+ _DEBUG_ERROR("no memory\n");
+ } else if (dbus_message_is_method_call(message, MC_SERVICE_DBUS, "Hello_Agent")) {
+ _DEBUG_INFO("Hello_Agent");
+ } else if (dbus_message_is_method_call(message, MC_SERVICE_DBUS, "Goodbye_Agent")) {
+ _DEBUG_INFO("Goodbye_Agent");
+ _INNER_FUNC_EXIT;
+ exit(1);
+ } else {
+ _DEBUG_INFO("can't match message");
+ }
+
+ _INNER_FUNC_EXIT;
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusObjectPathVTable echo_vtable = {
+ _unregistered_path,
+ _message_path,
+ NULL,
+};
+
+static int _register_dbus_service(void)
+{
+ _INNER_FUNC_ENTER;
+ int result;
+ DBusError error;
+ void *d;
+
+ dbus_error_init(&error);
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ _DEBUG_ERROR("*** Failed to open connection to activating message bus: %s\n", error.message);
+ dbus_error_free(&error);
+ return 1;
+ }
+
+ if (!dbus_connection_register_object_path(connection, MC_SERVICE_OBJECT_PATH, &echo_vtable, (void *)0xdeadbeef)) {
+ _DEBUG_ERROR("no memory\n");
+ goto failed;
+ }
+
+ if (!dbus_connection_get_object_path_data(connection, MC_SERVICE_OBJECT_PATH, &d)) {
+ _DEBUG_ERROR("no memory\n");
+ goto failed;
+ }
+
+ if (d != (void *)0xdeadbeef) {
+ _DEBUG_ERROR("dbus_connection_get_object_path_data() doesn't seem to work right\n");
+ goto failed;
+ }
+
+ result = dbus_bus_request_name(connection, MC_SERVICE_DBUS, 0, &error);
+ if (dbus_error_is_set(&error)) {
+ _DEBUG_ERROR("Error %s\n", error.message);
+ dbus_error_free(&error);
+ dbus_connection_unref(connection);
+ _INNER_FUNC_EXIT;
+ exit(1);
+ }
+
+ _INNER_FUNC_EXIT;
+ return 0;
+
+ failed:
+ dbus_connection_unref(connection);
+ _INNER_FUNC_EXIT;
+ return 1;
+}
+
+//static void __update_csc()
+//{
+// _INNER_FUNC_ENTER;
+//
+// char profile[128];
+// int numberOfProfiles = 0;
+// char *contents = "check";
+//
+// bool result = get_vconf_Int_key(CSC_VCONF_KEY_SYNCMLDS_NBDATASYNC, &numberOfProfiles);
+// if (result == false) {
+// _DEBUG_ERROR("failed in get_vconf_Int_key");
+// goto error;
+// }
+//
+// int i;
+// for (i = 1; i <= numberOfProfiles; i++) {
+// snprintf(profile, sizeof(profile), "Sync%d", i);
+// add_profile_csc(i);
+// }
+//
+// sync_agent_write_whole_file(OMA_DS_CSC_CHECK_PATH, contents, strlen(contents), false);
+//
+//error:
+//
+// _INNER_FUNC_EXIT;
+//}
+
+static void _request_reset_synchronizing_profiles()
+{
+ _INNER_FUNC_ENTER;
+
+ unsigned int request_msg_id = 0;
+ sync_agent_request_async_task(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES, 0, 0, NULL, NULL, NULL, NULL, NULL, (int *)&request_msg_id);
+ _INNER_FUNC_EXIT;
+}
+
+static void _check_csc()
+{
+ _INNER_FUNC_ENTER;
+
+ bool exist = false;
+
+ /*FIXME(temporary do not process csc for ui reason)
+ check csc_check file is existed
+ if false do csc update
+ if true check csc xml file has been changed */
+
+ /*exist = sync_agent_is_existing_fs(OMA_DS_CSC_CHECK_PATH); */
+ exist = true;
+ _DEBUG_TRACE("update = %d", exist);
+
+ /* for prevent */
+// if (exist == false)
+// __update_csc();
+
+ _INNER_FUNC_EXIT;
+}
+
+static void _agent_daemon_signal_handler(int signo, siginfo_t * info, void *p_context)
+{
+ _INNER_FUNC_ENTER;
+
+ switch (signo) {
+ case SIGTERM:
+ _DEBUG_TRACE("Got SIGTERM");
+
+ /* stop gmain loop */
+ sync_agent_stop_main_loop(0);
+
+ break;
+
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+}
+
+int main()
+{
+ _EXTERN_FUNC_ENTER;
+
+ struct sigaction sig_act;
+
+ sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
+ sync_agent_deinit_error_e deinit_error = SYNC_AGENT_DEINIT_SUCCESS;
+
+ if (sync_agent_daemonize() < 0) {
+ _DEBUG_ERROR("daemonize error");
+ return -1;
+ }
+
+ _register_dbus_service();
+
+ sync_agent_init_error_e init_error = sync_agent_init("/usr/share/oma-ds-cfg/omads_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");
+ }
+
+ sync_agent_ec_task_spec_s *pSyncTaskSpec = make_synchronize_task();
+ sync_agent_ec_task_spec_s *pAddProfileTaskSpec = make_add_profile_task();
+ sync_agent_ec_task_spec_s *pEditProfileTaskSpec = make_edit_profile_task();
+ sync_agent_ec_task_spec_s *pDeleteProfileTaskSpec = make_delete_profile_task();
+ sync_agent_ec_task_spec_s *pGetProfileDataTaskSpec = make_get_profile_data_task();
+ sync_agent_ec_task_spec_s *pGetProfileSyncCategoryTaskSpec = make_get_profile_sync_category_task();
+ sync_agent_ec_task_spec_s *pGetProfileStatisticsTaskSpec = make_get_profile_statistics_task();
+ sync_agent_ec_task_spec_s *pResetSynchronizingProfilesTaskSpec = make_reset_synchronizing_profiles_task();
+ sync_agent_ec_task_spec_s *pAddProfileCPTaskSpec = make_add_profile_cp_task();
+ sync_agent_ec_task_spec_s *pRefreshFromServiceTaskSpec = make_refresh_from_service_task();
+ sync_agent_ec_task_spec_s *pCancelSyncRequestTaskSpec = make_cancel_request_task();
+ sync_agent_ec_task_spec_s *pResetAllDataTaskSpec = make_reset_all_data_task();
+ sync_agent_ec_task_spec_s *pGetAllProfilesData = make_get_all_profiles_data_task();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REQUEST, EC_MSG_TYPE_NAME_SYNC_TASK_REQUEST, pSyncTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE, EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE, pAddProfileTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_EDIT_PROFILE, EC_MSG_TYPE_NAME_SYNC_TASK_EDIT_PROFILE, pEditProfileTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_DELETE_PROFILE, EC_MSG_TYPE_NAME_SYNC_TASK_DELETE_PROFILE, pDeleteProfileTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_DATA, EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_DATA, pGetProfileDataTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY, EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_SYNC_CATEGORY, pGetProfileSyncCategoryTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_PROFILE_STATISTICS, EC_MSG_TYPE_NAME_SYNC_TASK_GET_PROFILE_STATISTICS, pGetProfileStatisticsTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES, EC_MSG_TYPE_NAME_SYNC_TASK_RESET_SYNCHRONIZING_PROFILES, pResetSynchronizingProfilesTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_ADD_PROFILE_CP, EC_MSG_TYPE_NAME_SYNC_TASK_ADD_PROFILE_CP, pAddProfileCPTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_REFRESH_FROM_SERVICE, EC_MSG_TYPE_NAME_SYNC_TASK_REFRESH_FROM_SERVICE, pRefreshFromServiceTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_CANCEL_SYNC_REQUEST, EC_MSG_TYPE_NAME_SYNC_TASK_CANCEL_SYNC_REQUEST, pCancelSyncRequestTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_RESET_ALL_DATA, EC_MSG_TYPE_NAME_SYNC_TASK_RESET_ALL_DATA, pResetAllDataTaskSpec, NULL);
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_SYNC_TASK_GET_ALL_PROFILES_DATA, EC_MSG_TYPE_NAME_SYNC_TASK_GET_ALL_PROFILES_DATA, pGetAllProfilesData, 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);
+
+ sync_agent_unref_queuing_rule_spec(pQueuing_rule);
+
+ _request_reset_synchronizing_profiles(); /*reset synchronizing flag 0 every account & construct item tbl */
+
+ error = sync_agent_set_event_callback(OMA_DS_ADD_PROFILE, event_callback_add_profile_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_EDIT_PROFILE, event_callback_edit_profile_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_DELETE_PROFILE, event_callback_delete_profile_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_REQUEST_SYNC, event_callback_request_sync_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_CANCEL_SYNC, event_callback_cancel_sync_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_GET_PROFILE_DATA, event_callback_get_profile_data_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_GET_PROFILE_SYNC_CATEGORY, event_callback_get_profile_sync_category_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_GET_PROFILE_SYNC_STATISTICS, event_callback_get_profile_last_statistics_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_GET_ALL_PROFILES_DATA, event_callback_request_get_all_profiles_data);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_ADD_PROFILE_CP, event_callback_add_profile_cp_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_REQUEST_CALLLOG_SYNC, event_callback_request_calllog_sync_async);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ error = sync_agent_set_event_callback(OMA_DS_RESET_ALL_DATA, event_callback_request_reset_all_data_sync);
+ if (error != SYNC_AGENT_EVENT_SUCCESS)
+ _DEBUG_ERROR("failed sync_agent_set_event_callback()");
+
+ sync_agent_pm_return_e san_err = sync_agnet_register_user_callback(3, NULL, 1, san_callback_parse);
+ if (san_err != SYNC_AGENT_PM_SUCCESS)
+ _DEBUG_ERROR("failed in sync_agnet_register_user_callback");
+
+ sync_agent_pm_return_e scheduler_err = sync_agnet_register_user_callback(1, NULL, 1, send_periodic_sync_msg);
+ if (scheduler_err != SYNC_AGENT_PM_SUCCESS)
+ _DEBUG_ERROR("failed in sync_agnet_register_user_callback");
+
+ /*register profiles from csc */
+ _check_csc();
+
+ /* Block SIGPIPE signal (client may close socket abnormally) */
+ signal(SIGPIPE, SIG_IGN);
+
+ /* register signal handler. will be called by kill command */
+ sig_act.sa_handler = NULL;
+ sig_act.sa_sigaction = _agent_daemon_signal_handler;
+ sig_act.sa_flags = SA_SIGINFO;
+ sigemptyset(&sig_act.sa_mask);
+ sigaction(SIGTERM, &sig_act, NULL);
+
+ sync_agent_run_main_loop(0);
+
+ if (connection) {
+ dbus_connection_unref(connection);
+ connection = NULL;
+ }
+
+ deinit_error = sync_agent_deinit();
+ if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS)
+ _DEBUG_ERROR("failed in sync_agent_deinit");
+
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
diff --git a/src/agent/service-adapter/network-binder/na_binder.c b/src/agent/service-adapter/network-binder/na_binder.c
new file mode 100755
index 0000000..4c9ff49
--- /dev/null
+++ b/src/agent/service-adapter/network-binder/na_binder.c
@@ -0,0 +1,142 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @NA_Binder.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of header binder function for Network Adapter
+ */
+
+#include <sync_agent.h>
+
+#include "service-adapter/network-binder/na_binder.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_SA"
+#endif
+
+int na_http_header_binder(char *acc_type, char *loc_uri, bool is_xml, char *jsession_id, GList ** list)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(acc_type == NULL, 0, "[NA Header Binder] accType is NULL");
+ retvm_if(loc_uri == NULL, 0, "[NA Header Binder] loc_uri is NULL");
+
+ if (!strcmp(acc_type, "OMA_DS")) {
+ sync_agent_na_common_header_info_s *method = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(method == NULL, 0, "[NA Header Binder] 'method' malloc fail !!");
+
+ memset(method, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ method->key = "method";
+ method->value = "post";
+ *list = g_list_append(*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));
+ retvm_if(uri == NULL, 0, "[NA Header Binder] 'uri' malloc fail !!");
+
+ memset(uri, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ uri->key = "uri";
+ uri->value = loc_uri;
+ *list = g_list_append(*list, uri);
+
+ sync_agent_na_common_header_info_s *cache_control = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(cache_control == NULL, 0, "[NA Header Binder] 'cache_control' malloc fail !!");
+
+ memset(cache_control, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ cache_control->key = "Cache-Control";
+ cache_control->value = "no-store, private";
+ *list = g_list_append(*list, cache_control);
+
+ sync_agent_na_common_header_info_s *connection = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(connection == NULL, 0, "[NA Header Binder] 'connection' malloc fail !!");
+
+ memset(connection, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ connection->key = "Connection";
+ connection->value = "Keep-Alive";
+ *list = g_list_append(*list, connection);
+
+ sync_agent_na_common_header_info_s *accept = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept == NULL, 0, "[NA Header Binder] 'accept' malloc fail !!");
+
+ memset(accept, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept->key = "Accept";
+ if (is_xml == true)
+ accept->value = "application/vnd.syncml+xml";
+ else
+ accept->value = "application/vnd.syncml+wbxml";
+ *list = g_list_append(*list, accept);
+
+ sync_agent_na_common_header_info_s *accept_language = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept_language == NULL, 0, "[NA Header Binder] 'accept_language' malloc fail !!");
+
+ memset(accept_language, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept_language->key = "Accept-Language";
+ accept_language->value = "en-US";
+ *list = g_list_append(*list, accept_language);
+
+ sync_agent_na_common_header_info_s *accept_charset = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(accept_charset == NULL, 0, "[NA Header Binder] 'accept_charset' malloc fail !!");
+
+ memset(accept_charset, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ accept_charset->key = "Accept-Charset";
+ accept_charset->value = "UTF-8";
+ *list = g_list_append(*list, accept_charset);
+
+ sync_agent_na_common_header_info_s *content_type = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(content_type == NULL, 0, "[NA Header Binder] 'content_type' malloc fail !!");
+
+ memset(content_type, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ content_type->key = "Content-Type";
+ if (is_xml == true)
+ content_type->value = "application/vnd.syncml+xml";
+ else
+ content_type->value = "application/vnd.syncml+wbxml";
+ *list = g_list_append(*list, content_type);
+
+ if (jsession_id != NULL) {
+ _DEBUG_INFO(" jsessionid : %s\n", jsession_id);
+ sync_agent_na_common_header_info_s *cookie = (sync_agent_na_common_header_info_s *) malloc(sizeof(sync_agent_na_common_header_info_s));
+ retvm_if(cookie == NULL, 0, "[NA Header Binder] 'cookie' malloc fail !!");
+
+ memset(cookie, 0x00, sizeof(sync_agent_na_common_header_info_s));
+ cookie->key = "cookie";
+ cookie->value = jsession_id;
+ *list = g_list_append(*list, cookie);
+ _DEBUG_INFO(" cookie : %s\n", cookie->value);
+ }
+ }
+
+ GList *iter = NULL;
+ for (iter = *list; iter != NULL; iter = g_list_next(iter)) {
+ _DEBUG_INFO("[NA_Header_Binder] key : %s, value : %s", ((sync_agent_na_common_header_info_s *) (iter->data))->key, ((sync_agent_na_common_header_info_s *) (iter->data))->value);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+void free_header_info(sync_agent_na_common_header_info_s * common_header_info)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if(common_header_info == NULL, "pCommon_header_info is NULL");
+
+ free(common_header_info);
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c b/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
new file mode 100755
index 0000000..b6b14db
--- /dev/null
+++ b/src/agent/service-adapter/protocol-binder/oma_ds_protocol_binder.c
@@ -0,0 +1,5256 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @oma_ds_protocol_binder.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of callback function for Protocol Binder
+ */
+
+#include <glib.h>
+
+#include <sync_agent.h>
+
+#include "service-adapter/protocol-binder/oma_ds_protocol_binder.h"
+#include "service-adapter/sa_elements_internal.h"
+#include "service-adapter/sa_command_internal.h"
+#include "service-adapter/sa_devinf_internal.h"
+#include "service-adapter/sa_command.h"
+#include "service-adapter/sa_elements.h"
+#include "service-adapter/sa_devinf.h"
+#include "service-adapter/sa_define.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_BINDER"
+#endif
+
+static sync_agent_pb_error_e __append_location_to_wbxml_node(location_s * location, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
+
+static sync_agent_pb_error_e __append_anchor_to_wbxml_node(anchor_s * anchor, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
+
+static sync_agent_pb_error_e __append_devinf_contenttype_to_wbxml_node(devinf_content_type_s * devinf_content_type, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, char *node);
+
+static sync_agent_pb_error_e __append_cred_to_wbxml_node(cred_s * cred, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node);
+
+static sync_agent_pb_error_e _oma_ds_binder_devinf_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_put_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_get_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_add_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_delete_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+static sync_agent_pb_error_e _oma_ds_binder_map_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node);
+
+static protocol_version_e __get_oma_ds_protocol_version(char *verdtd);
+static devinf_version_e __get_oma_ds_devInf_version(char *verdtd);
+static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type);
+static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node);
+static location_s *_get_location(WBXMLTreeNode * node);
+static anchor_s *_get_anchor(WBXMLTreeNode * node);
+static cred_s *__get_cred(WBXMLTreeNode * node);
+static chal_s *_get_chal(WBXMLTreeNode * node);
+
+static sync_agent_pb_error_e _oma_ds_binder_devinf_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 _oma_ds_binder_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 _oma_ds_binder_results_command_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 _oma_ds_binder_put_command_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 _oma_ds_binder_get_command_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 _oma_ds_binder_alert_command_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 _oma_ds_binder_sync_end_command_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 _oma_ds_binder_sync_start_command_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 _oma_ds_binder_add_command_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 _oma_ds_binder_replace_command_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 _oma_ds_binder_delete_command_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 _oma_ds_binder_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 _oma_ds_binder_status_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content);
+
+/*
+ PE_ADD,
+ PE_DELETE,
+ PE_REPLACE,
+ PE_ALERT,
+ PE_GET,
+ PE_MAP,
+ PE_PUT,
+ PE_RESULTS,
+ PE_STATUS,
+ PE_SYNC_START,
+ PE_SYNC_END,
+ PE_HEADER,
+ PE_FINAL
+
+ PE_COPY,
+ PE_EXEC,
+ PE_SEARCH,
+ PE_SEQUENCE_START,
+ PE_SEQUENCE_END,
+ PE_ATOMIC_START,
+ PE_ATOMIC_END,
+ PE_PUT_GET,
+ PE_CMD_GROUP,
+ PE_GENERIC,
+ */
+const sync_agent_pb_function_info_s oma_ds_binder_function_info[] = {
+ {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, _oma_ds_binder_header_reverse_converter_function, 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, _oma_ds_binder_final_reverse_converter_function, true},
+ {PE_ALERT, "Alert", _oma_ds_binder_alert_command_converter_function, _oma_ds_binder_alert_command_reverse_converter_function, true},
+ {PE_STATUS, "Status", _oma_ds_binder_status_converter_function, _oma_ds_binder_status_reverse_converter_function, true},
+ {PE_RESULTS_START, "Results", _oma_ds_binder_results_command_converter_function, _oma_ds_binder_results_command_reverse_converter_function, false},
+ {PE_RESULTS_END, "/Results", NULL, NULL, false},
+ {PE_PUT_START, "Put", _oma_ds_binder_put_command_converter_function, _oma_ds_binder_put_command_reverse_converter_function, false},
+ {PE_PUT_END, "/Put", NULL, NULL, false},
+ {PE_GET, "Get", _oma_ds_binder_get_command_converter_function, _oma_ds_binder_get_command_reverse_converter_function, true},
+ {PE_SYNC_START, "Sync", _oma_ds_binder_sync_start_command_converter_function, _oma_ds_binder_sync_start_command_reverse_converter_function, false},
+ {PE_SYNC_END, "/Sync", _oma_ds_binder_sync_end_command_converter_function, _oma_ds_binder_sync_end_command_reverse_converter_function, false},
+ {PE_ADD, "Add", _oma_ds_binder_add_command_converter_function, _oma_ds_binder_add_command_reverse_converter_function, true},
+ {PE_REPLACE, "Replace", _oma_ds_binder_replace_command_converter_function, _oma_ds_binder_replace_command_reverse_converter_function, true},
+ {PE_DELETE, "Delete", _oma_ds_binder_delete_command_converter_function, _oma_ds_binder_delete_command_reverse_converter_function, true},
+ {PE_MAP, "Map", _oma_ds_binder_map_command_converter_function, NULL, true},
+ {PE_DEVINF, "DevInf", _oma_ds_binder_devinf_converter_function, _oma_ds_binder_devinf_reverse_converter_function, true}
+};
+
+static sync_agent_pb_error_e __append_location_to_wbxml_node(location_s * location, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(location == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "location is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ if (location->loc_uri != NULL) {
+ WBXMLTreeNode *LocURI = sync_agent_add_child_text_node(binder,
+ parent_node, ELEMENT_LOCURI, location->loc_uri, strlen(location->loc_uri));
+ if (LocURI == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ } else {
+ /* error case */
+ }
+
+ if (location->loc_name != NULL) {
+ WBXMLTreeNode *locName = sync_agent_add_child_text_node(binder,
+ parent_node, ELEMENT_LOCNAME, location->loc_name, strlen(location->loc_name));
+ if (locName == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e __append_anchor_to_wbxml_node(anchor_s * anchor, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(anchor == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "anchor is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *anchor_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_ANCHOR);
+ if (anchor_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (anchor->last_anchor != NULL) {
+ WBXMLTreeNode *last_node = sync_agent_add_child_text_node(binder,
+ anchor_node, ELEMENT_LAST, anchor->last_anchor, strlen(anchor->last_anchor));
+ if (last_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (anchor->next_anchor != NULL) {
+ WBXMLTreeNode *next_node = sync_agent_add_child_text_node(binder,
+ anchor_node, ELEMENT_NEXT, anchor->next_anchor, strlen(anchor->next_anchor));
+ if (next_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e __append_devinf_contenttype_to_wbxml_node(devinf_content_type_s * devinf_content_type, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node, char *node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(devinf_content_type == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "devinf_content_type is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ WBXMLTreeNode *xnode = sync_agent_add_child_node(binder, parent_node, node);
+ if (xnode == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
+ xnode, "CTType", devinf_content_type->ct_type, strlen(devinf_content_type->ct_type));
+ if (cttype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
+ xnode, "VerCT", devinf_content_type->verct, strlen(devinf_content_type->verct));
+ if (verct_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e __append_cred_to_wbxml_node(cred_s * cred, sync_agent_pb_protocol_binder_info_s * binder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(cred == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "cred is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* check validity */
+ WBXMLTreeNode *cred_node = sync_agent_add_child_node(binder, parent_node, ELEMENT_CRED);
+ if (cred_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, cred_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = NULL;
+
+ switch (cred->type) {
+ case AUTH_TYPE_BASIC:
+
+ if (cred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_BASIC, strlen(ELEMENT_AUTH_BASIC));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (cred->data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ case AUTH_TYPE_MD5:
+
+ if (cred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_FORMAT, ELEMENT_FORMAT_BASE64, strlen(ELEMENT_FORMAT_BASE64));
+ if (format_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ type_node = sync_agent_add_child_text_node(binder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_MD5, strlen(ELEMENT_AUTH_MD5));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (cred->data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ cred_node, ELEMENT_DATA, cred->data, strlen(cred->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_devinf_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ item_s *pItem = (item_s *) content;
+ devinf_s *pDevInf = pItem->private.devinf;
+
+ if (pItem != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_create_node(binder, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder, item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pItem->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_node(binder, item_node, ELEMENT_DATA);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* devinf language setting */
+ sync_agent_switch_protocol(binder, SYNC_AGENT_PB_PROTOCOL_SYNCML_DEVINF12);
+ WBXMLTree *devinf_tree = sync_agent_create_wbxml_tree(binder);
+ if (devinf_tree == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ sync_agent_add_wbxml_tree_to_wbxml_node(data_node, devinf_tree);
+
+ /* create root node of devinf tree */
+ WBXMLTreeNode *devinf_node = sync_agent_create_node(binder, ELEMENT_DEVINF);
+ if (devinf_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ sync_agent_set_wbxml_tree_root(devinf_tree, devinf_node);
+
+ WBXMLTreeNode *verDTD_node = NULL;
+ switch (pDevInf->version) {
+ case DEVINF_VERSION_UNKNOWN:
+ verDTD_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_VERDTD);
+ break;
+ case DEVINF_VERSION_10:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_10, strlen(ELEMENT_VERDRD_10));
+ break;
+ case DEVINF_VERSION_11:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_11, strlen(ELEMENT_VERDRD_11));
+ break;
+ case DEVINF_VERSION_12:
+ verDTD_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_VERDTD, ELEMENT_VERDRD_12, strlen(ELEMENT_VERDRD_12));
+ break;
+ }
+
+ if (verDTD_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *man_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_MAN, pDevInf->manufacturer, strlen(pDevInf->manufacturer));
+ if (man_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *mod_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_MOD, pDevInf->model, strlen(pDevInf->model));
+ if (mod_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pDevInf->oem != NULL) {
+ WBXMLTreeNode *oem_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_OEM, pDevInf->oem, strlen(pDevInf->oem));
+ if (oem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *FwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_FWV, pDevInf->firmware_version, strlen(pDevInf->firmware_version));
+ if (FwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *SwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_SWV, pDevInf->software_version, strlen(pDevInf->software_version));
+ if (SwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *HwV_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_HWV, pDevInf->hardware_version, strlen(pDevInf->hardware_version));
+ if (HwV_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devID_node = sync_agent_add_child_text_node(binder,
+ devinf_node, ELEMENT_DEVID, pDevInf->dev_id, strlen(pDevInf->dev_id));
+ if (devID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *devTyp_node = NULL;
+ switch (pDevInf->devtyp) {
+ case DEVINF_DEVTYPE_UNKNOWN:
+ devTyp_node = sync_agent_add_child_node(binder, devinf_node, ELEMENT_DEVTYP);
+ break;
+ case DEVINF_DEVTYPE_PAGER:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PAGER, strlen(ELEMENT_PAGER));
+ break;
+ case DEVINF_DEVTYPE_HANDHELD:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_HANDHELD, strlen(ELEMENT_HANDHELD));
+ break;
+ case DEVINF_DEVTYPE_PDA:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PDA, strlen(ELEMENT_PDA));
+ break;
+ case DEVINF_DEVTYPE_PHONE:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_PHONE, strlen(ELEMENT_PHONE));
+ break;
+ case DEVINF_DEVTYPE_SMARTPHONE:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SMARTPHONE, strlen(ELEMENT_SMARTPHONE));
+ break;
+ case DEVINF_DEVTYPE_SERVER:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_SERVER, strlen(ELEMENT_SERVER));
+ break;
+ case DEVINF_DEVTYPE_WORKSTATION:
+ devTyp_node = sync_agent_add_child_text_node(binder, devinf_node, ELEMENT_DEVTYP, ELEMENT_WORKSTATION, strlen(ELEMENT_WORKSTATION));
+ break;
+ }
+
+ if (devTyp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pDevInf->supports_utc) {
+ WBXMLTreeNode *supportUTC_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_UTC);
+ if (supportUTC_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supports_large_objs) {
+ WBXMLTreeNode *supportLargeObjs_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_SUPPORTLARGEOBJS);
+ if (supportLargeObjs_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pDevInf->supports_number_of_changes) {
+ WBXMLTreeNode *supportNumberOfChanges_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_SUPPORTNUMBEROFCHANGES);
+ if (supportNumberOfChanges_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *datastoreIter = NULL;
+ devinf_datastore_s *devInfDataStore = NULL;
+ for (datastoreIter = pDevInf->datastores; datastoreIter != NULL; datastoreIter = g_list_next(datastoreIter)) {
+ devInfDataStore = datastoreIter->data;
+
+ WBXMLTreeNode *datastore_node = sync_agent_add_child_node(binder,
+ devinf_node, ELEMENT_DATASTORE);
+ if (datastore_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *sourceRef_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_SOURCEREF, devInfDataStore->source_ref, strlen(devInfDataStore->source_ref));
+ if (sourceRef_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfDataStore->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_DISPLAYNAME, devInfDataStore->display_name, strlen(devInfDataStore->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_guid_size) {
+ char *str_maxguidsize = g_strdup_printf("%u", devInfDataStore->max_guid_size);
+ if (str_maxguidsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxguidsize_node = sync_agent_add_child_text_node(binder,
+ datastore_node, ELEMENT_MAXGUIDSIZE, str_maxguidsize, strlen(str_maxguidsize));
+
+ if (str_maxguidsize != NULL)
+ free(str_maxguidsize);
+
+ if (maxguidsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->rx_pref, binder, datastore_node, ELEMENT_RX_PREF);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ GList *rxIter = NULL;
+ devinf_content_type_s *devInfContentType = NULL;
+ for (rxIter = devInfDataStore->rx; rxIter != NULL; rxIter = g_list_next(rxIter)) {
+ devInfContentType = rxIter->data;
+ __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_RX);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+
+ __append_devinf_contenttype_to_wbxml_node(devInfDataStore->tx_pref, binder, datastore_node, ELEMENT_TX_PREF);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ GList *txIter = NULL;
+ for (txIter = devInfDataStore->tx; txIter != NULL; txIter = g_list_next(txIter)) {
+ devInfContentType = txIter->data;
+ __append_devinf_contenttype_to_wbxml_node(devInfContentType, binder, datastore_node, ELEMENT_TX);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ }
+
+ GList *ctcapIter = NULL;
+ devinf_ct_cap_s *devInfCTCap = NULL;
+ for (ctcapIter = devInfDataStore->ct_caps; ctcapIter != NULL; ctcapIter = g_list_next(ctcapIter)) {
+ devInfCTCap = ctcapIter->data;
+
+ WBXMLTreeNode *ctcap_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_CTCAP);
+ if (ctcap_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cttype_node = sync_agent_add_child_text_node(binder,
+ ctcap_node, ELEMENT_CTTYPE, devInfCTCap->ct->ct_type, strlen(devInfCTCap->ct->ct_type));
+ if (cttype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verct_node = sync_agent_add_child_text_node(binder,
+ ctcap_node, ELEMENT_VERCT, devInfCTCap->ct->verct, strlen(devInfCTCap->ct->verct));
+ if (verct_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /*TODO FieldLevel */
+
+ GList *propertyIter = NULL;
+ devinf_property_s *devInfProperty = NULL;
+ for (propertyIter = devInfCTCap->properties; propertyIter != NULL; propertyIter = g_list_next(propertyIter)) {
+ devInfProperty = propertyIter->data;
+
+ WBXMLTreeNode *property_node = sync_agent_add_child_node(binder,
+ ctcap_node, ELEMENT_PROPERTY);
+ if (property_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *propname_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_PROPNAME, devInfProperty->prop_name, strlen(devInfProperty->prop_name));
+ if (propname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfProperty->data_type != NULL) {
+ WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_DATATYPE, devInfProperty->data_type, strlen(devInfProperty->data_type));
+ if (datatype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->max_occur) {
+ char *str_maxoccur = g_strdup_printf("%u", devInfProperty->max_occur);
+ if (str_maxoccur == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxoccur_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_MAXOCCUR, str_maxoccur, strlen(str_maxoccur));
+
+ if (str_maxoccur != NULL)
+ free(str_maxoccur);
+
+ if (maxoccur_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->max_size) {
+ char *str_maxsize = g_strdup_printf("%u", devInfProperty->max_size);
+ if (str_maxsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxsize_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_MAXSIZE, str_maxsize, strlen(str_maxsize));
+
+ if (str_maxsize != NULL)
+ free(str_maxsize);
+
+ if (maxsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->no_truncate) {
+ WBXMLTreeNode *notruncate_node = sync_agent_add_child_node(binder,
+ property_node, ELEMENT_NOTRUNCATE);
+ if (notruncate_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *valenum = NULL;
+ char *val = NULL;
+ for (valenum = devInfProperty->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfProperty->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ property_node, ELEMENT_DISPLAYNAME, devInfProperty->display_name, strlen(devInfProperty->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *propparamIter = NULL;
+ devinf_prop_param_s *devInfPropParam = NULL;
+ for (propparamIter = devInfProperty->prop_params; propparamIter != NULL; propparamIter = g_list_next(propparamIter)) {
+ devInfPropParam = propparamIter->data;
+
+ WBXMLTreeNode *propparam_node = sync_agent_add_child_node(binder,
+ property_node, ELEMENT_PROPPARAM);
+ if (propparam_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *paramname_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_PARAMNAME, devInfPropParam->param_name, strlen(devInfPropParam->param_name));
+ if (paramname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfPropParam->data_type != NULL) {
+ WBXMLTreeNode *datatype_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_DATATYPE, devInfPropParam->data_type, strlen(devInfPropParam->data_type));
+ if (datatype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ valenum = NULL;
+ val = NULL;
+ for (valenum = devInfPropParam->val_enums; valenum != NULL; valenum = g_list_next(valenum)) {
+ val = valenum->data;
+ WBXMLTreeNode *valenum_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_VALENUM, val, strlen(val));
+ if (valenum_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfPropParam->display_name != NULL) {
+ WBXMLTreeNode *displayname_node = sync_agent_add_child_text_node(binder,
+ propparam_node, ELEMENT_DISPLAYNAME, devInfPropParam->display_name, strlen(devInfPropParam->display_name));
+ if (displayname_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+
+ /* DSMem */
+ WBXMLTreeNode *dsmem_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_DSMEM);
+ if (dsmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (devInfDataStore->shared_mem) {
+ WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder,
+ dsmem_node, ELEMENT_SHAREDMEM);
+ if (sharedmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_mem) {
+ char *str_maxmem = g_strdup_printf("%u", devInfDataStore->max_mem);
+ WBXMLTreeNode *maxmem_node = sync_agent_add_child_text_node(binder,
+ dsmem_node, ELEMENT_MAXMEM, str_maxmem, strlen(str_maxmem));
+
+ if (str_maxmem != NULL)
+ free(str_maxmem);
+
+ if (maxmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (devInfDataStore->max_id) {
+ char *str_maxid = g_strdup_printf("%u", devInfDataStore->max_id);
+ WBXMLTreeNode *maxid_node = sync_agent_add_child_text_node(binder,
+ dsmem_node, ELEMENT_MAXID, str_maxid, strlen(str_maxid));
+
+ if (str_maxid != NULL)
+ free(str_maxid);
+
+ if (maxid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ /* SupportHierarchicalSync */
+ if (devInfDataStore->supports_hierarchical_sync) {
+ WBXMLTreeNode *supportshierarchicalsync_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_SUPPORTHIERARCHICALSYNC);
+ if (supportshierarchicalsync_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ WBXMLTreeNode *synccap_node = sync_agent_add_child_node(binder,
+ datastore_node, ELEMENT_SYNCCAP);
+ if (synccap_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_TWO_WAY)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_1, strlen(ELEMENT_SYNCTYPE_1));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SLOW_SYNC)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_2, strlen(ELEMENT_SYNCTYPE_2));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_3, strlen(ELEMENT_SYNCTYPE_3));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_CLIENT)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_4, strlen(ELEMENT_SYNCTYPE_4));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_ONE_WAY_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_5, strlen(ELEMENT_SYNCTYPE_5));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_REFRESH_FROM_SERVER)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_6, strlen(ELEMENT_SYNCTYPE_6));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (get_devinf_datastore_sync_cap(devInfDataStore, DEVINF_SYNCTYPE_SERVER_ALERTED_SYNC)) {
+ WBXMLTreeNode *synctype_node = sync_agent_add_child_text_node(binder,
+ synccap_node, ELEMENT_SYNCTYPE, ELEMENT_SYNCTYPE_7, strlen(ELEMENT_SYNCTYPE_7));
+ if (synctype_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ /*TODO filter-rx, filterCap */
+ }
+ sync_agent_undo_switch_protocol(binder);
+ *wbxml_dom_node = item_node;
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ WBXMLTreeNode *syncml_node = sync_agent_create_node(binder, ELEMENT_SYNCML);
+ if (syncml_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = syncml_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) content;
+
+ /* add SyncHdr, VerDTD, VerProto node */
+ WBXMLTreeNode *synchdr_node = sync_agent_create_node(binder, ELEMENT_SYNCHDR);
+ if (synchdr_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *verDTD = ELEMENT_VERDTD;
+ char *verProto = ELEMENT_VERPROTO;
+
+ char *verDTD_data = NULL;
+ char *verProto_data = NULL;
+ if (pSyncHdr->version == VERSION_10) {
+ verDTD_data = ELEMENT_VERDRD_10;
+ verProto_data = ELEMENT_VERPROTO_10;
+ } else if (pSyncHdr->version == VERSION_11) {
+ verDTD_data = ELEMENT_VERDRD_11;
+ verProto_data = ELEMENT_VERPROTO_11;
+ } else if (pSyncHdr->version == VERSION_12) {
+ verDTD_data = ELEMENT_VERDRD_12;
+ verProto_data = ELEMENT_VERPROTO_12;
+ }
+
+ if (verDTD_data == NULL || verProto_data == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *verdtd_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, verDTD, verDTD_data, strlen(verDTD_data));
+ if (verdtd_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *verProto_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, verProto, verProto_data, strlen(verProto_data));
+ if (verProto_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* session ID */
+ WBXMLTreeNode *sessionID_node = NULL;
+ if (pSyncHdr->session_id != NULL)
+ sessionID_node = sync_agent_add_child_text_node(binder, synchdr_node, ELEMENT_SESSIONID, pSyncHdr->session_id, strlen(pSyncHdr->session_id));
+ else
+ sessionID_node = sync_agent_add_child_node(binder, synchdr_node, ELEMENT_SESSIONID);
+
+ if (sessionID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* msgID */
+ char *msgID_data = g_strdup_printf("%u", pSyncHdr->message_id);
+ if (msgID_data == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgID_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
+
+ if (msgID_data != NULL)
+ free(msgID_data);
+
+ if (msgID_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pSyncHdr->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ if (pSyncHdr->response_uri != NULL) {
+ WBXMLTreeNode *respuri_node = sync_agent_add_child_text_node(binder,
+ synchdr_node, ELEMENT_RESPURI, pSyncHdr->response_uri, strlen(pSyncHdr->response_uri));
+ if (respuri_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pSyncHdr->no_response) {
+ WBXMLTreeNode *noResponse_node = sync_agent_add_child_node(binder,
+ synchdr_node, ELEMENT_NORESP);
+ if (noResponse_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pSyncHdr->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pSyncHdr->cred, binder, synchdr_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ char *meta = ELEMENT_META;
+ if (pSyncHdr->max_msg_size != 0 || pSyncHdr->max_obj_size != 0) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ synchdr_node, meta);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int maxmsgsize = pSyncHdr->max_msg_size;
+ unsigned int maxobjsize = pSyncHdr->max_obj_size;
+
+ if (maxmsgsize != 0) {
+ char *str_maxmsgsize = g_strdup_printf("%u", maxmsgsize);
+ if (str_maxmsgsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxmsgsize_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
+ if (str_maxmsgsize != NULL)
+ free(str_maxmsgsize);
+
+ if (maxmsgsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (maxobjsize != 0) {
+ char *str_maxobjsize = g_strdup_printf("%u", maxobjsize);
+ if (str_maxobjsize == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *maxobjsize_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
+ if (str_maxobjsize != NULL)
+ free(str_maxobjsize);
+
+ if (maxobjsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = synchdr_node;
+ synchdr_node = NULL;
+
+ error:
+
+ if (synchdr_node != NULL)
+ sync_agent_destroy_wbxml_node(synchdr_node);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *final_node = sync_agent_create_node(binder, "Final");
+ if (final_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = final_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *syncbody_node = sync_agent_create_node(binder, ELEMENT_SYNCBODY);
+ if (syncbody_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *wbxml_dom_node = syncbody_node;
+
+ error:
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ status_s *pStatus = (status_s *) content;
+
+ command_type_e type = pStatus->type;
+
+ char *str_cmdID = NULL;
+ char *str_msgRef = NULL;
+ char *str_cmdRef = NULL;
+
+ WBXMLTreeNode *status_node = sync_agent_create_node(binder, ELEMENT_STATUS);
+ if (status_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdID = pStatus->cmd_id;
+ str_cmdID = g_strdup_printf("%u", cmdID);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int msgRef = pStatus->msg_ref;
+ str_msgRef = g_strdup_printf("%u", msgRef);
+ if (str_msgRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdRef = pStatus->cmd_ref;
+ str_cmdRef = g_strdup_printf("%u", cmdRef);
+ if (str_cmdRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (cmdref_node == NULL) {
+ goto error;
+ }
+
+ char *str_command = NULL;
+ switch (type) {
+ case COMMAND_TYPE_ALERT:
+ {
+ str_command = ELEMENT_ALERT;
+ }
+ break;
+ case COMMAND_TYPE_SYNC_START:
+ {
+ str_command = ELEMENT_SYNC;
+ }
+ break;
+ case COMMAND_TYPE_PUT:
+ {
+ str_command = ELEMENT_PUT;
+ }
+ break;
+ case COMMAND_TYPE_HEADER:
+ {
+ str_command = ELEMENT_SYNCHDR;
+ }
+ break;
+ case COMMAND_TYPE_ADD:
+ {
+ str_command = ELEMENT_ADD;
+ }
+ break;
+ case COMMAND_TYPE_REPLACE:
+ {
+ str_command = ELEMENT_REPLACE;
+ }
+ break;
+ case COMMAND_TYPE_DELETE:
+ {
+ str_command = ELEMENT_DELETE;
+ }
+ break;
+ case COMMAND_TYPE_MAP:
+ {
+ str_command = ELEMENT_MAP;
+ }
+ break;
+ case COMMAND_TYPE_GET:
+ {
+ str_command = ELEMENT_GET;
+ }
+ break;
+ case COMMAND_TYPE_RESULTS:
+ {
+ str_command = ELEMENT_RESULTS;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (str_command == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ WBXMLTreeNode *command_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_CMD, str_command, strlen(str_command));
+ if (command_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->target_ref != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_TARGETREF, pStatus->target_ref->loc_uri, strlen(pStatus->target_ref->loc_uri));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->source_ref != NULL) {
+ WBXMLTreeNode *sourceref_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_SOURCEREF, pStatus->source_ref->loc_uri, strlen(pStatus->source_ref->loc_uri));
+ if (sourceref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pStatus->cred, binder, status_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pStatus->chal != NULL) {
+ /*TODO chal */
+ }
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ status_node, ELEMENT_DATA, pStatus->data, strlen(pStatus->data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (type == COMMAND_TYPE_ALERT) {
+ if (pStatus->item != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ status_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_DATA);
+ if (item_data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *item_data_Anchor_node = sync_agent_add_child_node(binder,
+ item_data_node, ELEMENT_ANCHOR);
+ if (item_data_Anchor_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pStatus->item->anchor != NULL) {
+ WBXMLTreeNode *item_data_Anchor_Next_node = sync_agent_add_child_text_node(binder,
+ item_data_Anchor_node, ELEMENT_NEXT, pStatus->item->anchor->next_anchor,
+ strlen(pStatus->item->anchor->next_anchor));
+
+ if (item_data_Anchor_Next_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ *wbxml_dom_node = status_node;
+ status_node = NULL;
+
+ error:
+
+ if (status_node != NULL)
+ sync_agent_destroy_wbxml_node(status_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_alert_type = NULL;
+
+ WBXMLTreeNode *alert_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_alert_private_s *pAlert = (command_alert_private_s *) (&(pCommand->private));
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pAlert->type == ALERT_UNKNOWN) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_INVALID_INPUT_PARAMETER;
+ goto error;
+ }
+
+ alert_node = sync_agent_create_node(binder, ELEMENT_ALERT);
+ if (alert_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ alert_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, alert_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ str_alert_type = g_strdup_printf("%u", pAlert->type);
+ if (str_alert_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(binder,
+ alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* item */
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ alert_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ if (pAlert->anchor != NULL) {
+ err = __append_anchor_to_wbxml_node(pAlert->anchor, binder, item_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = alert_node;
+ alert_node = NULL;
+
+ error:
+
+ if (alert_node != NULL)
+ sync_agent_destroy_wbxml_node(alert_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_alert_type != NULL)
+ free(str_alert_type);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_cmdRef = NULL;
+ char *str_msgRef = NULL;
+ WBXMLTreeNode *results_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_results_private_s *pResults = (command_results_private_s *) (&(pCommand->private));
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pResults->item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pResults->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ results_node = sync_agent_create_node(binder, ELEMENT_RESULTS);
+ if (results_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID != NULL) {
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pResults->msg_ref) {
+ str_msgRef = g_strdup_printf("%u", pResults->msg_ref);
+ if (str_msgRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ str_cmdRef = g_strdup_printf("%u", pResults->cmd_ref);
+ if (str_cmdRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ results_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pResults->target_ref != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(binder,
+ results_node, ELEMENT_TARGETREF, pResults->target_ref->loc_uri, strlen(pResults->target_ref->loc_uri));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = results_node;
+ results_node = NULL;
+
+ error:
+
+ if (results_node != NULL)
+ sync_agent_destroy_wbxml_node(results_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_cmdRef != NULL)
+ free(str_cmdRef);
+
+ if (str_msgRef != NULL)
+ free(str_msgRef);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_put_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ WBXMLTreeNode *put_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
+ if (pAccess == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ put_node = sync_agent_create_node(binder, ELEMENT_PUT);
+ if (put_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ put_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ put_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, put_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ put_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = put_node;
+ put_node = NULL;
+
+ error:
+
+ if (put_node != NULL)
+ sync_agent_destroy_wbxml_node(put_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_get_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ WBXMLTreeNode *get_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+ command_access_private_s *pAccess = (command_access_private_s *) (&(pCommand->private));
+ if (pAccess == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ if (pAccess->item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ char *content_type = (pAccess->item)->content_type;
+ if (content_type == NULL) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ get_node = sync_agent_create_node(binder, ELEMENT_GET);
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ get_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, get_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pAccess->item != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ get_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pAccess->item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = get_node;
+ get_node = NULL;
+
+ error:
+
+ if (get_node != NULL)
+ sync_agent_destroy_wbxml_node(get_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ command_s *pCommand = (command_s *) content;
+
+ char *str_cmdID = NULL;
+ char *numChanged_str = NULL;
+ char *str_freemem = NULL;
+ char *str_freeid = NULL;
+
+ WBXMLTreeNode *sync_node = sync_agent_create_node(binder, ELEMENT_SYNC);
+ if (sync_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ sync_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, sync_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ sync_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ }
+
+ /* Mem */
+ if (pCommand->private.sync.mem != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder, sync_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *mem_node = sync_agent_add_child_node(binder, meta_node, ELEMENT_MEM);
+ if (mem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->private.sync.mem->sharedmem) {
+ WBXMLTreeNode *sharedmem_node = sync_agent_add_child_node(binder, mem_node, ELEMENT_SHAREDMEM);
+ if (sharedmem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->private.sync.mem->free_mem) {
+ str_freemem = g_strdup_printf("%u", pCommand->private.sync.mem->free_mem);
+ WBXMLTreeNode *freemem_node = sync_agent_add_child_text_node(binder,
+ mem_node, ELEMENT_FREEMEM, str_freemem, strlen(str_freemem));
+ if (freemem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->private.sync.mem->free_id) {
+ str_freeid = g_strdup_printf("%u", pCommand->private.sync.mem->free_id);
+ WBXMLTreeNode *freeid_node = sync_agent_add_child_text_node(binder,
+ mem_node, ELEMENT_FREEID, str_freeid, strlen(str_freeid));
+ if (freeid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (pCommand->private.sync.has_num_changed) {
+ numChanged_str = g_strdup_printf("%u", pCommand->private.sync.num_changed);
+ if (numChanged_str == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *numberOfChanges_node = sync_agent_add_child_text_node(binder,
+ sync_node, ELEMENT_NUMBEROFCHANGES, numChanged_str, strlen(numChanged_str));
+ if (numberOfChanges_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ *wbxml_dom_node = sync_node;
+ sync_node = NULL;
+
+ error:
+
+ if (sync_node != NULL)
+ sync_agent_destroy_wbxml_node(sync_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (numChanged_str != NULL)
+ free(numChanged_str);
+
+ if (str_freemem != NULL)
+ free(str_freemem);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ _EXTERN_FUNC_EXIT;
+
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_add_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *add_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ add_node = sync_agent_create_node(binder, ELEMENT_ADD);
+ if (add_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ add_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ add_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, add_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ add_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->more_data) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->data_type == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->more_data) {
+ WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = add_node;
+ add_node = NULL;
+
+ error:
+
+ if (add_node != NULL)
+ sync_agent_destroy_wbxml_node(add_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *replace_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ replace_node = sync_agent_create_node(binder, ELEMENT_REPLACE);
+ if (replace_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ replace_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, replace_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ replace_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->more_data) {
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ if (item->data_type == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_cdata_node(binder,
+ item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ if (item->more_data) {
+ WBXMLTreeNode *moredata_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_MOREDATA);
+ if (moredata_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ }
+
+ *wbxml_dom_node = replace_node;
+ replace_node = NULL;
+
+ error:
+
+ if (replace_node != NULL)
+ sync_agent_destroy_wbxml_node(replace_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_delete_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ char *str_cmdID = NULL;
+ char *str_size = NULL;
+ WBXMLTreeNode *delete_node = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ command_change_private_s *pChange = (command_change_private_s *) (&(pCommand->private));
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ goto error;
+ }
+
+ delete_node = sync_agent_create_node(binder, ELEMENT_DELETE);
+ if (delete_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ delete_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->no_resp) {
+ WBXMLTreeNode *noResp_node = sync_agent_add_child_node(binder,
+ delete_node, ELEMENT_NORESP);
+ if (noResp_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ /*TODO Archive */
+ /*TODO sftDel */
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, delete_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ item_s *item = NULL;
+ for (Iter = pCommand->private.change.items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(binder,
+ delete_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL) {
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (item->content_type != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(binder,
+ item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_TYPE, item->content_type, strlen(item->content_type));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->size) {
+ str_size = g_strdup_printf("%u", item->size);
+ if (str_size == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(binder,
+ meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+
+ *wbxml_dom_node = delete_node;
+ delete_node = NULL;
+
+ error:
+
+ if (delete_node != NULL)
+ sync_agent_destroy_wbxml_node(delete_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ if (str_size != NULL)
+ free(str_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_map_command_converter_function(sync_agent_pb_protocol_binder_info_s * binder, Content_Ptr content, WBXMLTreeNode ** wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(content == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "content is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ char *str_cmdID = NULL;
+
+ command_s *pCommand = (command_s *) content;
+
+ WBXMLTreeNode *map_node = sync_agent_create_node(binder, ELEMENT_MAP);
+ if (map_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ str_cmdID = g_strdup_printf("%u", pCommand->cmd_id);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(binder,
+ map_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pCommand->source != NULL && pCommand->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_TARGET);
+ if (target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->target, binder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_SOURCE);
+ if (source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(pCommand->source, binder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ if (pCommand->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pCommand->cred, binder, map_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+
+ GList *iter = NULL;
+ item_s *item = NULL;
+ for (iter = pCommand->private.map.items; iter != NULL; iter = g_list_next(iter)) {
+ item = iter->data;
+ WBXMLTreeNode *mapItem_node = sync_agent_add_child_node(binder,
+ map_node, ELEMENT_MAPITEM);
+ if (mapItem_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (item->source != NULL && item->target != NULL) {
+ WBXMLTreeNode *item_target_node = sync_agent_add_child_node(binder,
+ mapItem_node, ELEMENT_TARGET);
+ if (item_target_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->target, binder, item_target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+
+ WBXMLTreeNode *item_source_node = sync_agent_add_child_node(binder,
+ mapItem_node, ELEMENT_SOURCE);
+ if (item_source_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ err = __append_location_to_wbxml_node(item->source, binder, item_source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto error;
+ }
+ }
+ }
+
+ *wbxml_dom_node = map_node;
+ map_node = NULL;
+
+ error:
+
+ if (map_node != NULL)
+ sync_agent_destroy_wbxml_node(map_node);
+
+ if (str_cmdID != NULL)
+ free(str_cmdID);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static protocol_version_e __get_oma_ds_protocol_version(char *verdtd)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(verdtd == NULL, VERSION_UNKNOWN, "verdtd is NULL");
+
+ protocol_version_e protocol_version = VERSION_UNKNOWN;
+ if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
+ protocol_version = VERSION_12;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
+ protocol_version = VERSION_11;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
+ protocol_version = VERSION_10;
+ }
+
+ _INNER_FUNC_EXIT;
+ return protocol_version;
+}
+
+static devinf_version_e __get_oma_ds_devInf_version(char *verdtd)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(verdtd == NULL, DEVINF_VERSION_UNKNOWN, "verdtd is NULL");
+
+ devinf_version_e devInf_version = DEVINF_VERSION_UNKNOWN;
+ if (strcmp(verdtd, ELEMENT_VERDRD_12) == 0) {
+ devInf_version = DEVINF_VERSION_12;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_11) == 0) {
+ devInf_version = DEVINF_VERSION_11;
+ } else if (strcmp(verdtd, ELEMENT_VERDRD_10) == 0) {
+ devInf_version = DEVINF_VERSION_10;
+ }
+
+ _INNER_FUNC_EXIT;
+ return devInf_version;
+}
+
+static devinf_devtyp_e __get_oma_ds_devInf_device_type(char *dev_type)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(dev_type == NULL, DEVINF_DEVTYPE_UNKNOWN, "dev_type is NULL");
+
+ devinf_devtyp_e device_type = DEVINF_DEVTYPE_UNKNOWN;
+ if (strcmp(dev_type, ELEMENT_PAGER) == 0) {
+ device_type = DEVINF_DEVTYPE_PAGER;
+ } else if (strcmp(dev_type, ELEMENT_HANDHELD) == 0) {
+ device_type = DEVINF_DEVTYPE_HANDHELD;
+ } else if (strcmp(dev_type, ELEMENT_PDA) == 0) {
+ device_type = DEVINF_DEVTYPE_PDA;
+ } else if (strcmp(dev_type, ELEMENT_PHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_PHONE;
+ } else if (strcmp(dev_type, ELEMENT_SMARTPHONE) == 0) {
+ device_type = DEVINF_DEVTYPE_SMARTPHONE;
+ } else if (strcmp(dev_type, ELEMENT_SERVER) == 0) {
+ device_type = DEVINF_DEVTYPE_SERVER;
+ } else if (strcmp(dev_type, ELEMENT_WORKSTATION) == 0) {
+ device_type = DEVINF_DEVTYPE_WORKSTATION;
+ }
+
+ _INNER_FUNC_EXIT;
+ return device_type;
+}
+
+static devinf_content_type_s *__get_devinf_contenttype(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ devinf_content_type_s *devinf_content_type = NULL;
+
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+ goto return_part;
+ }
+
+ /* get first child */
+ WBXMLTreeNode *child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(first_child_name, ELEMENT_CTTYPE) == 0) {
+ char *ctType = NULL;
+ err = sync_agent_get_text_from_node(child, &ctType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (ctType != NULL)
+ devinf_content_type->ct_type = strdup(ctType);
+ } else {
+ /* error */
+ goto return_part;
+ }
+
+ /* get second child */
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(second_child_name, ELEMENT_VERCT) == 0) {
+ char *verCT = NULL;
+ err = sync_agent_get_text_from_node(child, &verCT);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (verCT != NULL)
+ devinf_content_type->verct = strdup(verCT);
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return devinf_content_type;
+
+ return_part:
+
+ /* for prevent */
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+
+}
+
+static location_s *_get_location(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ location_s *location = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ char *locURI = NULL;
+ char *locName = NULL;
+
+ /* get first child : required LocURI */
+ child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LOCURI) == 0) {
+ err = sync_agent_get_text_from_node(child, &locURI);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+
+ /* get second child : optional LocName */
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_LOCNAME) == 0) {
+ err = sync_agent_get_text_from_node(child, &locName);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ sa_error_type_e error = create_location(locURI, locName, &location);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_location() failed !, error = %d", error);
+ goto return_part;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return location;
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+static anchor_s *_get_anchor(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ anchor_s *anchor = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ char *lastAnchor = NULL;
+ char *nextAnchor = NULL;
+ /* get first child : optional lastAnchor */
+ child = node->children;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+
+ const char *first_child_name = NULL;
+ if (child != NULL) {
+ first_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", first_child_name);
+ if (strcmp(first_child_name, ELEMENT_LAST) == 0) {
+ err = sync_agent_get_text_from_node(child, &lastAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ child = child->next;
+ for (; child != NULL && child->type != WBXML_TREE_ELEMENT_NODE; child = child->next) {
+ }
+ } else if (strcmp(first_child_name, ELEMENT_NEXT) == 0) {
+ err = sync_agent_get_text_from_node(child, &nextAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ child = NULL;
+ }
+
+ /* get second child : required nextAnchor */
+ if (child != NULL) {
+ const char *second_child_name = NULL;
+ second_child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ _DEBUG_TRACE("child_name = %s", second_child_name);
+ if (strcmp(second_child_name, ELEMENT_NEXT) == 0) {
+ err = sync_agent_get_text_from_node(child, &nextAnchor);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ } else {
+ /* error */
+ goto return_part;
+ }
+ }
+
+ sa_error_type_e error = create_anchor(lastAnchor, nextAnchor, &anchor);
+ if (error != SA_INTERNAL_OK) {
+ _DEBUG_ERROR("create_anchor() failed !, error = %d", error);
+ goto return_part;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return anchor;
+
+ return_part:
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+static cred_s *__get_cred(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ cred_s *cred = NULL;
+
+ char *data = NULL;
+ char *type = NULL;
+ char *format = NULL;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grand_child = child->children;
+
+ const char *grand_child_xml_name = NULL;
+ grand_child_xml_name = (const char *)wbxml_tag_get_xml_name(grand_child->name);
+
+ if (strcmp(grand_child_xml_name, ELEMENT_TYPE) == 0) {
+ err = sync_agent_get_text_from_node(grand_child, &type);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Type = [%s]", type);
+ } else if (strcmp(grand_child_xml_name, ELEMENT_FORMAT) == 0) {
+ err = sync_agent_get_text_from_node(grand_child, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Type = [%s]", format);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ err = sync_agent_get_text_from_node(child, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_VERBOSE("Data = [%s]", data);
+ }
+
+ }
+
+ cred = create_cred_with_data(convert_auth_type(type), data);
+
+ format_type_e formatType = FORMAT_TYPE_UNKNOWN;
+ if (format != NULL) {
+ if (strcmp(format, ELEMENT_B64) == 0)
+ formatType = FORMAT_TYPE_BASE64;
+ }
+
+ set_cred_format_type(cred, formatType);
+
+ _INNER_FUNC_EXIT;
+ return cred;
+
+ return_part:
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+}
+
+static chal_s *_get_chal(WBXMLTreeNode * node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(node == NULL, NULL, "node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ chal_s *pChal = (chal_s *) calloc(1, sizeof(chal_s));
+ if (pChal == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pChal is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *chal_child = node->children;
+
+ WBXMLTreeNode *meta_child = NULL;
+
+ for (meta_child = chal_child->children; meta_child != NULL; meta_child = meta_child->next) {
+ if (meta_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *meta_child_xml_name = NULL;
+ meta_child_xml_name = (const char *)wbxml_tag_get_xml_name(meta_child->name);
+
+ if (strcmp(meta_child_xml_name, ELEMENT_TYPE) == 0) {
+ char *type = NULL;
+ err = sync_agent_get_text_from_node(meta_child, &type);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Type = [%s]", type);
+
+ pChal->type = convert_auth_type(type);
+ } else if (strcmp(meta_child_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(meta_child, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Format = [%s]", format);
+
+ pChal->format = convert_format_type(format);
+ } else if (strcmp(meta_child_xml_name, ELEMENT_NEXTNONCE) == 0) {
+ char *nextnonce = NULL;
+ unsigned int nonce_len = 0;
+ err = sync_agent_get_binary_from_node(meta_child, &nextnonce, &nonce_len);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("NextNonce = [%s]", nextnonce);
+ if (pChal->format == FORMAT_TYPE_BASE64) {
+ if (nextnonce != NULL)
+ pChal->nonce_b64 = strdup(nextnonce);
+ } else {
+ pChal->nonce_plain = (char *)malloc(nonce_len + 1);
+ if (pChal->nonce_plain == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ memcpy(pChal->nonce_plain, nextnonce, nonce_len);
+ pChal->nonce_plain[nonce_len] = '\0';
+ }
+
+ pChal->nonce_length = nonce_len;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return pChal;
+
+ return_part:
+
+ if (pChal != NULL)
+ free_chal(pChal);
+
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_devinf_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ devinf_s *pDevInf = (devinf_s *) calloc(1, sizeof(devinf_s));
+ if (pDevInf == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInf is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
+ char *verdtd = NULL;
+ err = sync_agent_get_text_from_node(child, &verdtd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerDTD = [%s]", verdtd);
+
+ pDevInf->version = __get_oma_ds_devInf_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_MAN) == 0) {
+ char *man = NULL;
+ err = sync_agent_get_text_from_node(child, &man);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Man = [%s]", man);
+ if (man != NULL)
+ pDevInf->manufacturer = strdup(man);
+ } else if (strcmp(child_xml_name, ELEMENT_MOD) == 0) {
+ char *mod = NULL;
+ err = sync_agent_get_text_from_node(child, &mod);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Mod = [%s]", mod);
+ if (mod != NULL)
+ pDevInf->model = strdup(mod);
+ } else if (strcmp(child_xml_name, ELEMENT_OEM) == 0) {
+ char *oem = NULL;
+ err = sync_agent_get_text_from_node(child, &oem);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("OEM = [%s]", oem);
+ if (oem != NULL)
+ pDevInf->oem = strdup(oem);
+ } else if (strcmp(child_xml_name, ELEMENT_FWV) == 0) {
+ char *fwv = NULL;
+ err = sync_agent_get_text_from_node(child, &fwv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("FwV = [%s]", fwv);
+ if (fwv != NULL)
+ pDevInf->firmware_version = strdup(fwv);
+ } else if (strcmp(child_xml_name, ELEMENT_SWV) == 0) {
+ char *swv = NULL;
+ err = sync_agent_get_text_from_node(child, &swv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("SwV = [%s]", swv);
+ if (swv != NULL)
+ pDevInf->software_version = strdup(swv);
+ } else if (strcmp(child_xml_name, ELEMENT_HWV) == 0) {
+ char *hwv = NULL;
+ err = sync_agent_get_text_from_node(child, &hwv);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("HwV = [%s]", hwv);
+ if (hwv != NULL)
+ pDevInf->hardware_version = strdup(hwv);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVID) == 0) {
+ char *devID = NULL;
+ err = sync_agent_get_text_from_node(child, &devID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("DevID = [%s]", devID);
+ if (devID != NULL)
+ pDevInf->dev_id = strdup(devID);
+ } else if (strcmp(child_xml_name, ELEMENT_DEVTYP) == 0) {
+ char *devtyp = NULL;
+ err = sync_agent_get_text_from_node(child, &devtyp);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("DevTyp = [%s]", devtyp);
+
+ pDevInf->devtyp = __get_oma_ds_devInf_device_type(devtyp);
+ } else if (strcmp(child_xml_name, ELEMENT_UTC) == 0) {
+ _DEBUG_TRACE("UTC");
+ pDevInf->supports_utc = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTLARGEOBJS) == 0) {
+ _DEBUG_TRACE("SupportLargeObjs");
+ pDevInf->supports_large_objs = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_SUPPORTNUMBEROFCHANGES) == 0) {
+ _DEBUG_TRACE("SupportNumberOfChanges");
+ pDevInf->supports_number_of_changes = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_DATASTORE) == 0) {
+
+ devinf_datastore_s *pDevInfDataStore = (devinf_datastore_s *) calloc(1, sizeof(devinf_datastore_s));
+ if (pDevInfDataStore == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfDataStore is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *datastore_child = NULL;
+
+ for (datastore_child = child->children; datastore_child != NULL; datastore_child = datastore_child->next) {
+ if (datastore_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *datastore_child_xml_name = NULL;
+ datastore_child_xml_name = (const char *)wbxml_tag_get_xml_name(datastore_child->name);
+
+ if (strcmp(datastore_child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ char *sourceref = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &sourceref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("SourceRef = [%s]", sourceref);
+ if (sourceref != NULL)
+ pDevInfDataStore->source_ref = strdup(sourceref);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfDataStore->display_name = strdup(displayname);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_MAXGUIDSIZE) == 0) {
+ char *maxguidsize = NULL;
+ err = sync_agent_get_text_from_node(datastore_child, &maxguidsize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxGUIDSize = [%s]", maxguidsize);
+ if (maxguidsize != NULL)
+ pDevInfDataStore->max_guid_size = atoi(maxguidsize);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX_PREF) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->rx_pref = devinf_content_type;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_RX) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->rx = g_list_append(pDevInfDataStore->rx, devinf_content_type);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX_PREF) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->tx_pref = devinf_content_type;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_TX) == 0) {
+ devinf_content_type_s *devinf_content_type = __get_devinf_contenttype(datastore_child);
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ pDevInfDataStore->tx = g_list_append(pDevInfDataStore->tx, devinf_content_type);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_CTCAP) == 0) {
+
+ devinf_ct_cap_s *pDevInfCtCap = (devinf_ct_cap_s *) calloc(1, sizeof(devinf_ct_cap_s));
+ if (pDevInfCtCap == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfCtCap is null");
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+
+ devinf_content_type_s *devinf_content_type = NULL;
+ WBXMLTreeNode *ctcap_child = NULL;
+
+ for (ctcap_child = datastore_child->children; ctcap_child != NULL; ctcap_child = ctcap_child->next) {
+ if (ctcap_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *ctcap_child_xml_name = NULL;
+ ctcap_child_xml_name = (const char *)wbxml_tag_get_xml_name(ctcap_child->name);
+
+ if (strcmp(ctcap_child_xml_name, ELEMENT_CTTYPE) == 0) {
+ if (devinf_content_type == NULL) {
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ goto return_part;
+ }
+ }
+
+ char *cttype = NULL;
+ err = sync_agent_get_text_from_node(ctcap_child, &cttype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("CTType = [%s]", cttype);
+ if (cttype != NULL)
+ devinf_content_type->ct_type = strdup(cttype);
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_VERCT) == 0) {
+ if (devinf_content_type == NULL) {
+ devinf_content_type = (devinf_content_type_s *) calloc(1, sizeof(devinf_content_type_s));
+ if (devinf_content_type == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("devinf_content_type is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ }
+
+ char *verct = NULL;
+ err = sync_agent_get_text_from_node(ctcap_child, &verct);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerCT = [%s]", verct);
+ if (verct != NULL)
+ devinf_content_type->verct = strdup(verct);
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_FIELDLEVEL) == 0) {
+ /*TODO fieldlevel */
+
+ } else if (strcmp(ctcap_child_xml_name, ELEMENT_PROPERTY) == 0) {
+
+ devinf_property_s *pDevInfProperty = (devinf_property_s *) calloc(1, sizeof(devinf_property_s));
+ if (pDevInfProperty == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfProperty is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ goto return_part;
+ }
+
+ WBXMLTreeNode *property_child = NULL;
+ for (property_child = ctcap_child->children; property_child != NULL; property_child = property_child->next) {
+ if (property_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *property_child_xml_name = NULL;
+ property_child_xml_name = (const char *)wbxml_tag_get_xml_name(property_child->name);
+
+ if (strcmp(property_child_xml_name, ELEMENT_PROPNAME) == 0) {
+ char *propname = NULL;
+ err = sync_agent_get_text_from_node(property_child, &propname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("PropName = [%s]", propname);
+ if (propname != NULL)
+ pDevInfProperty->prop_name = strdup(propname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = sync_agent_get_text_from_node(property_child, &datatype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DataType = [%s]", datatype);
+ if (datatype != NULL)
+ pDevInfProperty->data_type = strdup(datatype);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXOCCUR) == 0) {
+ char *maxoccur = NULL;
+ err = sync_agent_get_text_from_node(property_child, &maxoccur);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxOccur = [%s]", maxoccur);
+ if (maxoccur != NULL)
+ pDevInfProperty->max_occur = atoi(maxoccur);
+ } else if (strcmp(property_child_xml_name, ELEMENT_MAXSIZE) == 0) {
+ char *maxsize = NULL;
+ err = sync_agent_get_text_from_node(property_child, &maxsize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxSize = [%s]", maxsize);
+ if (maxsize != NULL)
+ pDevInfProperty->max_size = atoi(maxsize);
+ } else if (strcmp(property_child_xml_name, ELEMENT_NOTRUNCATE) == 0) {
+ _DEBUG_TRACE("NoTruncate");
+ pDevInfProperty->no_truncate = 1;
+ } else if (strcmp(property_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = sync_agent_get_text_from_node(property_child, &valenum);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ValEnum = [%s]", valenum);
+ if (valenum != NULL)
+ pDevInfProperty->val_enums = g_list_append(pDevInfProperty->val_enums, strdup(valenum));
+ } else if (strcmp(property_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(property_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfProperty->display_name = strdup(displayname);
+ } else if (strcmp(property_child_xml_name, ELEMENT_PROPPARAM) == 0) {
+
+ devinf_prop_param_s *pDevInfPropParam = (devinf_prop_param_s *) calloc(1, sizeof(devinf_prop_param_s));
+ if (pDevInfPropParam == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pDevInfPropParam is null");
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+
+ WBXMLTreeNode *propparam_child = NULL;
+
+ for (propparam_child = property_child->children; propparam_child != NULL; propparam_child = propparam_child->next) {
+ if (propparam_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *propparam_child_xml_name = NULL;
+ propparam_child_xml_name = (const char *)wbxml_tag_get_xml_name(propparam_child->name);
+
+ if (strcmp(propparam_child_xml_name, ELEMENT_PARAMNAME) == 0) {
+ char *paramname = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &paramname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ParamName = [%s]", paramname);
+ if (paramname != NULL)
+ pDevInfPropParam->param_name = strdup(paramname);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DATATYPE) == 0) {
+ char *datatype = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &datatype);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DataType = [%s]", datatype);
+ if (datatype != NULL)
+ pDevInfPropParam->data_type = strdup(datatype);
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_VALENUM) == 0) {
+ char *valenum = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &valenum);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("ValEnum = [%s]", valenum);
+ if (valenum != NULL)
+ pDevInfPropParam->val_enums = g_list_append(pDevInfPropParam->val_enums, strdup(valenum));
+ } else if (strcmp(propparam_child_xml_name, ELEMENT_DISPLAYNAME) == 0) {
+ char *displayname = NULL;
+ err = sync_agent_get_text_from_node(propparam_child, &displayname);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ if (pDevInfCtCap != NULL)
+ free(pDevInfCtCap);
+
+ if (devinf_content_type != NULL)
+ free(devinf_content_type);
+
+ if (pDevInfProperty != NULL)
+ free(pDevInfProperty);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("DisplayName = [%s]", displayname);
+ if (displayname != NULL)
+ pDevInfPropParam->display_name = strdup(displayname);
+ }
+ }
+
+ pDevInfProperty->prop_params = g_list_append(pDevInfProperty->prop_params, pDevInfPropParam);
+ }
+ }
+
+ pDevInfCtCap->properties = g_list_append(pDevInfCtCap->properties, pDevInfProperty);
+ }
+ }
+ pDevInfCtCap->ct = devinf_content_type;
+ pDevInfDataStore->ct_caps = g_list_append(pDevInfDataStore->ct_caps, pDevInfCtCap);
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_DSMEM) == 0) {
+
+ /*TODO DSMem */
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_SUPPORTHIERARCHICALSYNC) == 0) {
+ _DEBUG_TRACE("SupportHierarchicalSync");
+ pDevInfDataStore->supports_hierarchical_sync = 1;
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_SYNCCAP) == 0) {
+
+ WBXMLTreeNode *synccap_child = NULL;
+
+ for (synccap_child = datastore_child->children; synccap_child != NULL; synccap_child = synccap_child->next) {
+ if (synccap_child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *synccap_child_xml_name = NULL;
+ synccap_child_xml_name = (const char *)wbxml_tag_get_xml_name(synccap_child->name);
+
+ if (strcmp(synccap_child_xml_name, ELEMENT_SYNCTYPE) == 0) {
+ char *synctype_str = NULL;
+ unsigned int synctype = 0;
+ err = sync_agent_get_text_from_node(synccap_child, &synctype_str);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+
+ if (pDevInfDataStore != NULL)
+ free(pDevInfDataStore);
+
+ goto return_part;
+ }
+ _DEBUG_TRACE("SyncType = [%s]", synctype_str);
+ if (synctype_str != NULL) {
+ synctype = atoi(synctype_str);
+ synctype = 1 << (synctype - 1);
+ }
+ /*DevInfSyncCap synccap = convert_devinf_synccap(synctype); */
+ set_devinf_datastore_sync_cap(pDevInfDataStore, synctype, 1);
+ }
+ }
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTER_RX) == 0) {
+ /*TODO filter-rx */
+ } else if (strcmp(datastore_child_xml_name, ELEMENT_FILTERCAP) == 0) {
+ /*TODO filtercap */
+ }
+ }
+ pDevInf->datastores = g_list_append(pDevInf->datastores, pDevInfDataStore);
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pDevInf;
+ } else {
+ _DEBUG_ERROR("error");
+ free_devinf(pDevInf);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) calloc(1, sizeof(sync_hdr_s));
+ if (pSyncHdr == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSyncHdr is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_VERDTD) == 0) {
+ char *verdtd = NULL;
+ err = sync_agent_get_text_from_node(child, &verdtd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("VerDTD = [%s]", verdtd);
+
+ pSyncHdr->version = __get_oma_ds_protocol_version(verdtd);
+ } else if (strcmp(child_xml_name, ELEMENT_SESSIONID) == 0) {
+ char *sessionID = NULL;
+ err = sync_agent_get_text_from_node(child, &sessionID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("SessionID = [%s]", sessionID);
+
+ if (sessionID != NULL)
+ pSyncHdr->session_id = strdup(sessionID);
+ else
+ pSyncHdr->session_id = NULL;
+ } else if (strcmp(child_xml_name, ELEMENT_MSGID) == 0) {
+ char *msgID = NULL;
+ err = sync_agent_get_text_from_node(child, &msgID);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgID = [%s]", msgID);
+ if (msgID != NULL)
+ pSyncHdr->message_id = atoi(msgID);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(child);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(child);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->source = pSourceLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_RESPURI) == 0) {
+ char *resp_uri = NULL;
+ err = sync_agent_get_text_from_node(child, &resp_uri);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("resp_uri = [%s]", resp_uri);
+ if (resp_uri != NULL)
+ pSyncHdr->response_uri = strdup(resp_uri);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("noResp\n");
+ pSyncHdr->no_response = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pSyncHdr->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pSyncHdr;
+ } else {
+ _DEBUG_ERROR("error");
+ free_sync_hdr(pSyncHdr);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pResults = (command_s *) calloc(1, sizeof(command_s));
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pResults is null");
+ goto return_part;
+ }
+
+ pResults->type = COMMAND_TYPE_RESULTS;
+ pResults->msg_id = pSyncHdr->message_id;
+ pResults->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pResults->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msg_ref = NULL;
+ err = sync_agent_get_text_from_node(child, &msg_ref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgRef = [%s]", msg_ref);
+ if (msg_ref != NULL)
+ pResults->private.results.msg_ref = atoi(msg_ref);
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmd_ref = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_ref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MsgRef = [%s]", cmd_ref);
+ if (cmd_ref != NULL)
+ pResults->private.results.cmd_ref = atoi(cmd_ref);
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pResults->private.results.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
+ /*TODO targetRef */
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ /*TODO sourceRef */
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in results command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pResults->private.results.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pResults;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pResults);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_put_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pPut = (command_s *) calloc(1, sizeof(command_s));
+ if (pPut == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pPut is null");
+ goto return_part;
+ }
+
+ pPut->type = COMMAND_TYPE_PUT;
+ pPut->msg_id = pSyncHdr->message_id;
+ pPut->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pPut->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pPut->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pPut->private.access.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in put command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pPut->private.access.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pPut;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pPut);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_get_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pGet = (command_s *) calloc(1, sizeof(command_s));
+ if (pGet == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pGet is null");
+ goto return_part;
+ }
+
+ pGet->type = COMMAND_TYPE_GET;
+ pGet->msg_id = pSyncHdr->message_id;
+ pGet->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pGet->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pGet->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ if (contentType != NULL)
+ pGet->private.access.type = strdup(contentType);
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /*create item in put command */
+ item_s *item = create_item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item = item;
+
+ WBXMLTreeNode *grandchild = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pGet->private.access.item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ /* TODO data */
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pGet;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pGet);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_alert_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pAlert = (command_s *) calloc(1, sizeof(command_s));
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pAlert is null");
+ goto return_part;
+ }
+
+ pAlert->type = COMMAND_TYPE_ALERT;
+ pAlert->msg_id = pSyncHdr->message_id;
+ pAlert->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name(child->name);
+
+ if (strcmp(child_xml_name, ELEMENT_CMDID) == 0) {
+ char *cmd_id = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd_id);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ if (cmd_id != NULL)
+ pAlert->cmd_id = atoi(cmd_id);
+ } else if (strcmp(child_xml_name, ELEMENT_NORESP) == 0) {
+ _DEBUG_TRACE("NoResp");
+ pAlert->no_resp = 1;
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE("Cred\n");
+ cred_s *cred = NULL;
+ cred = __get_cred(child);
+ if (cred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->cred = cred;
+ } else if (strcmp(child_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_node(child, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("Data = [%s]", data);
+ if (data != NULL)
+ pAlert->private.alert.type = atoi(data);
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ WBXMLTreeNode *grandchild = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ if (grandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandchild_xml_name = NULL;
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ location_s *pSourceLocation = _get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ location_s *pTargetLocation = _get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandgrandchild = NULL;
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ if (grandgrandchild->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *grandgrandchild_xml_name = NULL;
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_ANCHOR) == 0) {
+ anchor_s *anchor = _get_anchor(grandgrandchild);
+ if (anchor == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ pAlert->private.alert.anchor = anchor;
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_MAXOBJSIZE) == 0) {
+ char *maxObjSize = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &maxObjSize);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ _DEBUG_TRACE("MaxObjSize = [%s]", maxObjSize);
+ if (maxObjSize != NULL)
+ pAlert->private.alert.max_obj_size = atoi(maxObjSize);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pAlert;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pAlert);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_sync_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pSyncEnd = (command_s *) calloc(1, sizeof(command_s));
+ if (pSyncEnd == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSyncEnd is null");
+ goto return_part;
+ }
+
+ pSyncEnd->type = COMMAND_TYPE_SYNC_END;;
+ pSyncEnd->msg_id = pSyncHdr->message_id;
+ pSyncEnd->ref_count = 1;
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ *content = pSyncEnd;
+ } else {
+ _DEBUG_ERROR("error");
+ free_command(pSyncEnd);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _oma_ds_binder_sync_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * reverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * content)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(wbxml_dom_node == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "wbxml_dom_node is NULL");
+ retvm_if(reverse_binder == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "reverse_binder is NULL");
+
+ sync_hdr_s *pSyncHdr = (sync_hdr_s *) sync_agent_get_user_data_from_reverse_protocol_binder(reverse_binder);
+ retvm_if(pSyncHdr == NULL, SYNC_AGENT_PB_RETURN_NOT_DEFINED, "pSyncHdr is NULL");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ command_s *pSync = (command_s *) calloc(1, sizeof(command_s));
+ if (pSync == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_ERROR("pSync is null");
+ goto return_part;
+ }
+
+ pSync->type = COMMAND_TYPE_SYNC_START;;
+ pSync->msg_id = pSyncHdr->message_id;
+ pSync->ref_count = 1;
+
+ WBXMLTreeNode *child = NULL;
+
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ if (child->type != WBXML_TREE_ELEMENT_NODE)
+ continue;
+
+ const char *child_xml_name = NULL;
+ child_xml_name = (const char *)wbxml_tag_get_xml_name